#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+10;
int a[maxn],s[maxn],n,ma;
struct pa{
int l;
int r;
bool operator<(const pa x)const{
    return r<x.r;
}
}ans1[maxn],ans2[maxn];
unordered_map<int,vector<pa>> f;
vector<pa> g;

int main(){
    ma=-1;
    f.reserve(1510*1510);
    f.max_load_factor(0.25);
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        s[i]=s[i-1]+a[i];
    }
    for(int j=1;j<=n;j++)
        for(int i=1;i<=j;i++)
            f[s[j]-s[i-1]].push_back({i,j});
    int pt=0,r1=0;
    for(auto i:f){
        g=i.second;
         r1=0;
        pt=0;
        for(int j=0;j<g.size();j++){
            if(g[j].l>r1){
                pt++;
                ans2[pt].l=g[j].l;
                ans2[pt].r=g[j].r;
                r1=max(r1,g[j].r);
            }
        }
        if(pt>ma){
         ma=pt;
         for(int j=1;j<=pt;j++){
            ans1[j]=ans2[j];
         }
        }
        }
    printf("%d\n",ma);
    for(auto i=1;i<=ma;i++){
        printf("%d %d\n",ans1[i].l,ans1[i].r);
    }
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+10;
int a[maxn],s[maxn],n,ma;
struct pa{
int l;
int r;
bool operator<(const pa x)const{
    return r<x.r;
}
}ans1[maxn],ans2[maxn];
unordered_map<int,vector<pa>> f;
vector<pa> g;

int main(){
    ma=-1;
    f.reserve(1510*1510);
    f.max_load_factor(0.25);
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        s[i]=s[i-1]+a[i];
    }
    for(int j=1;j<=n;j++)
        for(int i=1;i<=j;i++)
            f[s[j]-s[i-1]].push_back({i,j});
    int pt=0,r1=0;
    for(auto i:f){
        g=i.second;
         r1=0;
        pt=0;
        for(int j=0;j<g.size();j++){
            if(g[j].l>r1){
                pt++;
                ans2[pt].l=g[j].l;
                ans2[pt].r=g[j].r;
                r1=max(r1,g[j].r);
            }
        }
        if(pt>ma){
         ma=pt;
         for(int j=1;j<=pt;j++){
            ans1[j]=ans2[j];
         }
        }
        }
    printf("%d\n",ma);
    for(auto i=1;i<=ma;i++){
        printf("%d %d\n",ans1[i].l,ans1[i].r);
    }
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+10;
int a[maxn],s[maxn],n,ma;
struct pa{
int l;
int r;
bool operator<(const pa x)const{
    return r<x.r;
}
}ans1[maxn],ans2[maxn];
map<int,vector<pa>> f;
map<int,bool> ch;
vector<int> q;

int main(){
    ma=-1;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        s[i]=s[i-1]+a[i];
    }
    for(int i=1;i<=n;i++){
        for(int j=i;j<=n;j++){
            f[s[j]-s[i]+a[i]].push_back({i,j});
            if(!ch[s[j]-s[i]+a[i]]){
                ch[s[j]-s[i]+a[i]]=true;
                q.push_back(s[j]-s[i]+a[i]);
            }
        }
    }
    int pt=0,r1=0;
    for(auto i:q){
        sort(f[i].begin(),f[i].end());
         r1=0;
        pt=0;
        for(int j=0;j<f[i].size();j++){
            if(f[i][j].l>r1){
                pt++;
                ans2[pt].l=f[i][j].l;
                ans2[pt].r=f[i][j].r;
                r1=max(r1,f[i][j].r);
            }
        }
        if(pt>ma){
         ma=pt;
         for(int j=1;j<=pt;j++){
            ans1[j].l=ans2[j].l,
            ans1[j].r=ans2[j].r;
         }
        }
        }
    printf("%d\n",ma);
    for(auto i=1;i<=ma;i++){
        printf("%d %d\n",ans1[i].l,ans1[i].r);
    }
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=1505;
int a[maxn],s[maxn],n,ma;
struct pa{
int l;
int r;
bool operator<(const pa x)const{
    return r<x.r;
}
}ans1[maxn],ans2[maxn];
unordered_map<int,vector<pa>> f;
vector<pa> g;

int main(){
    f.reserve(1510*1510);
    f.max_load_factor(0.25);
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        s[i]=s[i-1]+a[i];
    }
    for(int j=1;j<=n;j++)
        for(int i=1;i<=j;i++)
            f[s[j]-s[i-1]].push_back({i,j});
    int pt=0,r1=0;
    for(auto i:f){
        g=i.second;
         r1=0;
        pt=0;
        for(int j=0;j<g.size();j++){
            if(g[j].l>r1){
                pt++;
                ans2[pt].l=g[j].l;
                ans2[pt].r=g[j].r;
                r1=g[j].r;
            }
        }
        if(pt>ma){
         ma=pt;
         for(int j=1;j<=pt;j++){
            ans1[j]=ans2[j];
         }
        }
        }
    printf("%d\n",ma);
    for(auto i=1;i<=ma;i++){
        printf("%d %d\n",ans1[i].l,ans1[i].r);
    }
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+10;
int a[maxn],s[maxn],n,ma;
struct pa{
int l;
int r;
bool operator<(const pa x)const{
    return r<x.r;
}
}ans1[maxn],ans2[maxn];
unordered_map<int,vector<pa>> f;
unordered_map<int,bool> ch;
vector<int> q;

int main(){
    ma=-1;
    f.reserve(1510*1510);
    f.max_load_factor(0.25);
    ch.reserve(1510*1510);
    ch.max_load_factor(0.25);
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        s[i]=s[i-1]+a[i];
    }
    for(int j=1;j<=n;j++){
        for(int i=1;i<=j;i++){
            f[s[j]-s[i]+a[i]].push_back({i,j});
            if(!ch[s[j]-s[i]+a[i]]){
                ch[s[j]-s[i]+a[i]]=true;
                q.push_back(s[j]-s[i]+a[i]);
            }
        }
    }
    int pt=0,r1=0;
    for(auto i:q){
         r1=0;
        pt=0;
        for(int j=0;j<f[i].size();j++){
            if(f[i][j].l>r1){
                pt++;
                ans2[pt].l=f[i][j].l;
                ans2[pt].r=f[i][j].r;
                r1=max(r1,f[i][j].r);
            }
        }
        if(pt>ma){
         ma=pt;
         for(int j=1;j<=pt;j++){
            ans1[j].l=ans2[j].l,
            ans1[j].r=ans2[j].r;
         }
        }
        }
    printf("%d\n",ma);
    for(auto i=1;i<=ma;i++){
        printf("%d %d\n",ans1[i].l,ans1[i].r);
    }
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+10;
int a[maxn],s[maxn],n,ma;
struct pa{
int l;
int r;
bool operator<(const pa x)const{
    return r<x.r;
}
}ans1[maxn],ans2[maxn];
map<int,vector<pa>> f;
map<int,bool> ch;
vector<int> q;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    cin>>n;
    ma=-1;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        s[i]=s[i-1]+a[i];
    }
    for(int i=1;i<=n;i++){
        for(int j=i;j<=n;j++){
            f[s[j]-s[i]+a[i]].push_back({i,j});
            if(!ch[s[j]-s[i]+a[i]]){
                ch[s[j]-s[i]+a[i]]=true;
                q.push_back(s[j]-s[i]+a[i]);
            }
        }
    }
    int pt=0,r1=0;
    for(auto i:q){
        sort(f[i].begin(),f[i].end());
         r1=0;
        pt=0;
        for(int j=0;j<f[i].size();j++){
            if(f[i][j].l>r1){
                pt++;
                ans2[pt].l=f[i][j].l;
                ans2[pt].r=f[i][j].r;
                r1=max(r1,f[i][j].r);
            }
        }
        if(pt>ma){
         ma=pt;
         for(int j=1;j<=pt;j++){
            ans1[j].l=ans2[j].l,
            ans1[j].r=ans2[j].r;
         }
        }
        }
    cout<<ma<<endl;
    for(int i=1;i<=ma;i++){
        cout<<ans1[i].l<<' '<<ans1[i].r<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+10;
int a[maxn],s[maxn],n,ma;
struct pa{
int l;
int r;
bool operator<(const pa x)const{
    return r<x.r;
}
}ans1[maxn],ans2[maxn];
map<int,vector<pa>> f;
unordered_map<int,bool> ch;
vector<int> q;

int main(){
    ma=-1;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        s[i]=s[i-1]+a[i];
    }
    for(int j=1;j<=n;j++){
        for(int i=1;i<=j;i++){
            f[s[j]-s[i]+a[i]].push_back({i,j});
            if(!ch[s[j]-s[i]+a[i]]){
                ch[s[j]-s[i]+a[i]]=true;
                q.push_back(s[j]-s[i]+a[i]);
            }
        }
    }
    int pt=0,r1=0;
    for(auto i:q){
         r1=0;
        pt=0;
        for(int j=0;j<f[i].size();j++){
            if(f[i][j].l>r1){
                pt++;
                ans2[pt].l=f[i][j].l;
                ans2[pt].r=f[i][j].r;
                r1=max(r1,f[i][j].r);
            }
        }
        if(pt>ma){
         ma=pt;
         for(int j=1;j<=pt;j++){
            ans1[j].l=ans2[j].l,
            ans1[j].r=ans2[j].r;
         }
        }
        }
    printf("%d\n",ma);
    for(auto i=1;i<=ma;i++){
        printf("%d %d\n",ans1[i].l,ans1[i].r);
    }
}


#include <bits/stdc++.h>

using namespace std;

#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define amen exit(0)
#define DIM 1509
#define INF ((int)1e16+9ll)
#define pairll pair<int,int>
#define fi first
#define se second
#define ld long double
#define eps 0.0000001

int i,j,k,l,n,m,num,H,mid,r,sum,res;

int a[DIM];

map<int,stack<pairll> >mp;

int main()
{
    fast;

    cin>>n;
    for(i=1;i<=n;i++)cin>>a[i];

    for(i=1;i<=n;i++){
        sum=0;
        for(j=i;j<=n;j++){
            sum+=a[j];
            if(mp.count(sum)==0)mp[sum].push({i,j});
            else{
                while(!mp[sum].empty() && mp[sum].top().se>=j)mp[sum].pop();
                if(mp[sum].empty())mp[sum].push({i,j});
                else{
                    if(mp[sum].top().se<i)mp[sum].push({i,j});
                }
            }
        }
    }

    for(auto to:mp){
        if(to.se.size()>mp[res].size()){
            res=to.fi;
        }
    }

    cout<<mp[res].size()<<endl;
    while(!mp[res].empty()){
        cout<<mp[res].top().fi<<' '<<mp[res].top().se<<endl;
        mp[res].pop();
    }

    amen;
}


#include <bits/stdc++.h>

using namespace std;

#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define amen exit(0)
#define DIM 1509
#define INF ((int)1e16+9ll)
#define pairll pair<int,int>
#define fi first
#define se second
#define ld long double
#define eps 0.0000001

const long long DIMM = 3e6+2;

int i,j,k,l,n,m,num,H,mid,r,sum,res;

int a[DIM],pref[DIM];

map<long long,long long>nums;

vector<pairll>mp[DIMM];

int main()
{
    fast;

    cin>>n;
    for(i=1;i<=n;i++)cin>>a[i];

    for(i=1;i<=n;i++){
        sum=0;
        for(j=i;j<=n;j++){
            sum+=a[j];
            if(nums.count(sum)==0)nums[sum]=nums.size();
        }
    }

    for(i=1;i<=n;i++){
        sum=0;
        for(j=i;j<=n;j++){
            sum+=a[j];
            k=nums[sum];
            if(mp[k].size()==0)mp[k].push_back({i,j});
            else{
                while(mp[k].size()>0 && mp[k][mp[k].size()-1].se>=j)mp[k].pop_back();
                if(mp[k].size()==0)mp[k].push_back({i,j});
                else{
                    if(mp[k][mp[k].size()-1].se<i)mp[k].push_back({i,j});
                }
            }
            if(mp[k].size()>mp[res].size())res=k;
        }
    }

    cout<<mp[res].size()<<endl;
    for(auto to:mp[res]){
        cout<<to.fi<<' '<<to.se<<endl;
    }

    amen;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long int;

#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define amen exit(0)
#define DIM 1509
#define INF ((long long)1e16+9ll)
#define pairll pair<long long,long long>
#define fi first
#define se second
#define ld long double
#define eps 0.0000001

long long i,j,k,l,n,m,num,H,mid,r,sum;

long long a[DIM],pref[DIM];

map<long long,stack<pairll> >mp;

stack<pairll>res;

int main()
{
    fast;

    cin>>n;
    for(i=1;i<=n;i++)cin>>a[i];

    for(i=1;i<=n;i++){
        sum=0;
        for(j=i;j<=n;j++){
            sum+=a[j];
            if(mp.count(sum)==0)mp[sum].push({i,j});
            else{
                while(!mp[sum].empty() && mp[sum].top().se>=j)mp[sum].pop();
                if(mp[sum].empty())mp[sum].push({i,j});
                else{
                    if(mp[sum].top().se<i)mp[sum].push({i,j});
                }
            }
        }
    }

    for(auto to:mp){
        if(to.se.size()>res.size()){
            res=to.se;
        }
    }

    cout<<res.size()<<endl;
    while(!res.empty()){
        cout<<res.top().fi<<' '<<res.top().se<<endl;
        res.pop();
    }

    amen;
}


#include <bits/stdc++.h>

using namespace std;

#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define amen exit(0)
#define DIM 1509
#define INF ((long long)1e16+9ll)
#define pairll pair<long long,long long>
#define fi first
#define se second
#define ld long double
#define eps 0.0000001

long long i,j,k,l,n,m,num,H,mid,r,sum;

long long a[DIM],pref[DIM];

map<long long,stack<pairll> >mp;

stack<pairll>res;

int main()
{
    fast;

    cin>>n;
    for(i=1;i<=n;i++)cin>>a[i];

    for(i=1;i<=n;i++){
        sum=0;
        for(j=i;j<=n;j++){
            sum+=a[j];
            if(mp.count(sum)==0)mp[sum].push({i,j});
            else{
                while(!mp[sum].empty() && mp[sum].top().se>=j)mp[sum].pop();
                if(mp[sum].empty())mp[sum].push({i,j});
                else{
                    if(mp[sum].top().se<i)mp[sum].push({i,j});
                }
            }
        }
    }

    for(auto to:mp){
        if(to.se.size()>res.size()){
            res=to.se;
        }
    }

    cout<<res.size()<<endl;
    while(!res.empty()){
        cout<<res.top().fi<<' '<<res.top().se<<endl;
        res.pop();
    }

    amen;
}


#include <bits/stdc++.h>

using namespace std;

#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define amen exit(0)
#define DIM 1509
#define INF ((int)1e16+9ll)
#define pairll pair<int,int>
#define fi first
#define se second
#define ld long double
#define eps 0.0000001

int i,j,k,l,n,m,num,H,mid,r,sum,res;

int a[DIM],pref[DIM];

map<int,stack<pairll> >mp;

int main()
{
    fast;

    cin>>n;
    for(i=1;i<=n;i++)cin>>a[i];

    for(i=1;i<=n;i++){
        sum=0;
        for(j=i;j<=n;j++){
            sum+=a[j];
            if(mp.count(sum)==0)mp[sum].push({i,j});
            else{
                while(!mp[sum].empty() && mp[sum].top().se>=j)mp[sum].pop();
                if(mp[sum].empty())mp[sum].push({i,j});
                else{
                    if(mp[sum].top().se<i)mp[sum].push({i,j});
                }
            }
        }
    }

    for(auto to:mp){
        if(to.se.size()>mp[res].size()){
            res=to.fi;
        }
    }

    cout<<mp[res].size()<<endl;
    while(!mp[res].empty()){
        cout<<mp[res].top().fi<<' '<<mp[res].top().se<<endl;
        mp[res].pop();
    }

    amen;
}


#include <bits/stdc++.h>

using namespace std;

#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define amen exit(0)
#define DIM 400009
#define INF ((long long)1e16+9ll)
#define pairll pair<long long,long long>
#define fi first
#define se second
#define ld long double
#define eps 0.0000001

long long i,j,k,l,n,m,num,H,mid,r,sum;

long long a[DIM],pref[DIM];

map<long long,stack<pairll> >mp;

stack<pairll>res;

int main()
{
    fast;

    cin>>n;
    for(i=1;i<=n;i++)cin>>a[i];

    for(i=1;i<=n;i++){
        sum=0;
        for(j=i;j<=n;j++){
            sum+=a[j];
            if(mp.count(sum)==0)mp[sum].push({i,j});
            else{
                while(!mp[sum].empty() && mp[sum].top().se>=j)mp[sum].pop();
                if(mp[sum].empty())mp[sum].push({i,j});
                else{
                    if(mp[sum].top().se<i)mp[sum].push({i,j});
                }
            }
        }
    }

    for(auto to:mp){
        if(to.se.size()>res.size()){
            res=to.se;
        }
    }

    cout<<res.size()<<endl;
    while(!res.empty()){
        cout<<res.top().fi<<' '<<res.top().se<<endl;
        res.pop();
    }

    amen;
}


#include <bits/stdc++.h>
using namespace std;

const int MAXN=2e6;
const int inf=2e9+2137;

int val[MAXN];
int b[MAXN];
int p[MAXN];

vector<pair<int,pair<int,int>>> v;
vector<int> dp;

int pos(int l,int r,int x)
{
    int mid,ans=-1;
    while(l<=r)
    {
        mid=(l+r)/2;
        if(v[mid].second.second<x)
            ans=mid,l=mid+1;
        else
            r=mid-1;
    }
    return ans;
}

bool cmp(pair<int,pair<int,int>> a,pair<int,pair<int,int>> b)
{
    if(a.first!=b.first)
        return a.first<b.first;
    return a.second.second<b.second.second;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,i,in,j,sum,last=-inf,ans=0,pans=-1;
    cin>>n;
    for(i=1;i<=n;i++)
        cin>>val[i];
    for(i=1;i<=n;i++)
    {
        sum=0;
        for(j=i;j<=n;j++)
            sum+=val[j],v.emplace_back(make_pair(sum,make_pair(i,j))),dp.emplace_back(0);
    }
    sort(v.begin(),v.end());
    for(i=0;i<v.size();i++)
    {
        if(v[i].first!=last)
            last=v[i].first,b[i]=i,dp[i]=1,p[i]=i;
        else
            b[i]=b[i-1],dp[i]=dp[i-1],p[i]=p[i-1];
        if(pos(b[i],i,v[i].second.first)!=-1&&dp[pos(b[i],i,v[i].second.first)]+1>dp[i])
            dp[i]=dp[pos(b[i],i,v[i].second.first)]+1,p[i]=i;
        if(dp[i]>ans)
            ans=dp[i],pans=p[i];
    }
    cout<<ans<<"\n";
    while(pans!=-1)
    {
        cout<<v[pans].second.first<<" "<<v[pans].second.second<<"\n";
        pans=pos(b[pans],pans,v[pans].second.first);
    }
}


#include <bits/stdc++.h>
using namespace std;

const int MAXN=4e6;
const int inf=2e9+2137;

int val[MAXN];
int b[MAXN];
int p[MAXN];

vector<pair<int,pair<int,int>>> v;
vector<int> dp;

int pos(int l,int r,int x)
{
    int mid,ans=-1;
    while(l<=r)
    {
        mid=(l+r)/2;
        if(v[mid].second.second<x)
            ans=mid,l=mid+1;
        else
            r=mid-1;
    }
    return ans;
}

bool cmp(pair<int,pair<int,int>> a,pair<int,pair<int,int>> b)
{
    if(a.first!=b.first)
        return a.first<b.first;
    return a.second.second<b.second.second;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,i,in,j,sum,last=-inf,ans=0,pans=-1;
    cin>>n;
    for(i=1;i<=n;i++)
        cin>>val[i];
    for(i=1;i<=n;i++)
    {
        sum=0;
        for(j=i;j<=n;j++)
            sum+=val[j],v.emplace_back(make_pair(sum,make_pair(i,j))),dp.emplace_back(0);
    }
    sort(v.begin(),v.end(),cmp);
    for(i=0;i<v.size();i++)
    {
        if(v[i].first!=last)
            last=v[i].first,b[i]=i,dp[i]=1,p[i]=i;
        else
            b[i]=b[i-1],dp[i]=dp[i-1],p[i]=p[i-1];
        if(pos(b[i],i,v[i].second.first)!=-1&&dp[pos(b[i],i,v[i].second.first)]+1>dp[i])
            dp[i]=dp[pos(b[i],i,v[i].second.first)]+1,p[i]=i;
        if(dp[i]>ans)
            ans=dp[i],pans=i;
    }
    cout<<ans<<"\n";
    while(pans!=-1)
    {
        pans=p[pans];
        cout<<v[pans].second.first<<" "<<v[pans].second.second<<"\n";
        pans=pos(b[pans],pans,v[pans].second.first);
    }
}


#include <bits/stdc++.h>
using namespace std;

const int MAXN=4e6;
const int inf=2e9+2137;

int val[MAXN];
int b[MAXN];
int p[MAXN];

vector<pair<int,pair<int,int>>> v;
vector<int> dp;

int pos(int l,int r,int x)
{
    int mid,ans=-1;
    while(l<=r)
    {
        mid=(l+r)/2;
        if(v[mid].second.second<x)
            ans=mid,l=mid+1;
        else
            r=mid-1;
    }
    return ans;
}

bool cmp(pair<int,pair<int,int>> a,pair<int,pair<int,int>> b)
{
    if(a.first!=b.first)
        return a.first<b.first;
    return a.second.second<b.second.second;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,i,in,j,sum,last=-inf,ans=0,pans=-1;
    cin>>n;
    for(i=1;i<=n;i++)
        cin>>val[i];
    for(i=1;i<=n;i++)
    {
        sum=0;
        for(j=i;j<=n;j++)
            sum+=val[j],v.emplace_back(make_pair(sum,make_pair(i,j))),dp.emplace_back(0);
    }
    sort(v.begin(),v.end(),cmp);
    for(i=0;i<v.size();i++)
    {
        if(v[i].first!=last)
            last=v[i].first,b[i]=i,dp[i]=1,p[i]=i;
        else
            b[i]=b[i-1],dp[i]=dp[i-1],p[i]=p[i-1];
        if(pos(b[i],i,v[i].second.first)!=-1&&dp[pos(b[i],i,v[i].second.first)]+1>dp[i])
            dp[i]=dp[pos(b[i],i,v[i].second.first)]+1,p[i]=i;
        if(dp[i]>ans)
            ans=dp[i],pans=i;
    }
    cout<<ans<<"\n";
    while(pans!=-1)
    {
        pans=p[i];
        cout<<v[pans].second.first<<" "<<v[pans].second.second<<"\n";
        pans=pos(b[pans],pans,v[pans].second.first);
    }
}


#include <bits/stdc++.h>
using namespace std;

const int MAXN=4e6;
const int inf=2e9+2137;

int val[MAXN];
int b[MAXN];
int p[MAXN];

vector<pair<int,pair<int,int>>> v;
vector<int> dp;

int pos(int l,int r,int x)
{
    int mid,ans=-1;
    while(l<=r)
    {
        mid=(l+r)/2;
        if(v[mid].second.second<x)
            ans=mid,l=mid+1;
        else
            r=mid-1;
    }
    return ans;
}

bool cmp(pair<int,pair<int,int>> a,pair<int,pair<int,int>> b)
{
    if(a.first!=b.first)
        return a.first<b.first;
    return a.second.second<b.second.second;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,i,in,j,sum,last=-inf,ans=0,pans=-1;
    cin>>n;
    for(i=1;i<=n;i++)
        cin>>val[i];
    for(i=1;i<=n;i++)
    {
        sum=0;
        for(j=i;j<=n;j++)
            sum+=val[j],v.emplace_back(make_pair(sum,make_pair(i,j))),dp.emplace_back(0);
    }
    sort(v.begin(),v.end(),cmp);
    for(i=0;i<v.size();i++)
    {
        if(v[i].first!=last)
            last=v[i].first,b[i]=i,dp[i]=1,p[i]=i;
        else
            b[i]=b[i-1],dp[i]=dp[i-1],p[i]=p[i-1];
        if(pos(b[i],i,v[i].second.first)!=-1&&dp[pos(b[i],i,v[i].second.first)]+1>dp[i])
            dp[i]=dp[pos(b[i],i,v[i].second.first)]+1,p[i]=i;
        if(dp[i]>ans)
            ans=dp[i],pans=p[i];
    }
    cout<<ans<<"\n";
    while(pans!=-1)
    {
        cout<<v[pans].second.first<<" "<<v[pans].second.second<<"\n";
        pans=pos(b[pans],pans,v[pans].second.first);
    }
}


#include <bits/stdc++.h>
using namespace std;

const int MAXN=2e6;
const int inf=2e9+2137;

int val[MAXN];
int b[MAXN];
int p[MAXN];

vector<pair<int,pair<int,int>>> v;
vector<int> dp;

int pos(int l,int r,int x)
{
    int mid,ans=-1;
    while(l<=r)
    {
        mid=(l+r)/2;
        if(v[mid].second.second<x)
            ans=mid,l=mid+1;
        else
            r=mid-1;
    }
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,i,in,j,sum,last=-inf,ans=0,pans=-1;
    cin>>n;
    for(i=1;i<=n;i++)
        cin>>val[i];
    for(i=1;i<=n;i++)
    {
        sum=0;
        for(j=i;j<=n;j++)
            sum+=val[j],v.emplace_back(make_pair(sum,make_pair(i,j))),dp.emplace_back(0);
    }
    sort(v.begin(),v.end());
    for(i=0;i<v.size();i++)
    {
        if(v[i].first!=last)
            last=v[i].first,b[i]=i,dp[i]=1,p[i]=i;
        else
            b[i]=b[i-1],dp[i]=dp[i-1],p[i]=p[i-1];
        if(pos(b[i],i,v[i].second.first)!=-1&&dp[pos(b[i],i,v[i].second.first)]+1>dp[i])
            dp[i]=dp[pos(b[i],i,v[i].second.first)]+1,p[i]=i;
        if(dp[i]>ans)
            ans=dp[i],pans=p[i];
    }
    cout<<ans<<"\n";
    while(pans!=-1)
    {
        cout<<v[pans].second.first<<" "<<v[pans].second.second<<"\n";
        pans=pos(b[pans],pans,v[pans].second.first);
    }
}


#include <bits/stdc++.h>
using namespace std;

const int MAXN=15e2;
const int inf=2e9+2137;

int val[MAXN];
int b[MAXN];
int p[MAXN];

vector<pair<int,pair<int,int>>> v;
vector<int> dp;

int pos(int l,int r,int x)
{
    int mid,ans=-1;
    while(l<=r)
    {
        mid=(l+r)/2;
        if(v[mid].second.second<x)
            ans=mid,l=mid+1;
        else
            r=mid-1;
    }
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,i,in,j,sum,last=-inf,ans=0,pans=-1;
    cin>>n;
    for(i=1;i<=n;i++)
        cin>>val[i];
    for(i=1;i<=n;i++)
    {
        sum=0;
        for(j=i;j<=n;j++)
            sum+=val[j],v.emplace_back(make_pair(sum,make_pair(i,j))),dp.emplace_back(0);
    }
    sort(v.begin(),v.end());
    for(i=0;i<v.size();i++)
    {
        if(v[i].first!=last)
            last=v[i].first,b[i]=i,dp[i]=1,p[i]=i;
        else
            b[i]=b[i-1],dp[i]=dp[i-1],p[i]=p[i-1];
        if(pos(b[i],i,v[i].second.first)!=-1&&dp[pos(b[i],i,v[i].second.first)]+1>dp[i])
            dp[i]=dp[pos(b[i],i,v[i].second.first)]+1,p[i]=i;
        if(dp[i]>ans)
            ans=dp[i],pans=p[i];
    }
    cout<<ans<<"\n";
    while(pans!=-1)
    {
        cout<<v[pans].second.first<<" "<<v[pans].second.second<<"\n";
        pans=pos(b[pans],pans,v[pans].second.first);
    }
}


#include <bits/stdc++.h>
using namespace std;

const int MAXN=4e6;
const int inf=2e9+2137;

int val[MAXN];
int b[MAXN];
int p[MAXN];

vector<pair<int,pair<int,int>>> v;
vector<int> dp;

int pos(int l,int r,int x)
{
    int mid,ans=-1;
    while(l<=r)
    {
        mid=(l+r)/2;
        if(v[mid].second.second<x)
            ans=mid,l=mid+1;
        else
            r=mid-1;
    }
    return ans;
}

bool cmp(pair<int,pair<int,int>> a,pair<int,pair<int,int>> b)
{
    if(a.first!=b.first)
        return a.first<b.first;
    return a.second.second<b.second.second;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,i,in,j,sum,last=-inf,ans=0,pans=-1;
    cin>>n;
    for(i=1;i<=n;i++)
        cin>>val[i];
    for(i=1;i<=n;i++)
    {
        sum=0;
        for(j=i;j<=n;j++)
            sum+=val[j],v.emplace_back(make_pair(sum,make_pair(i,j))),dp.emplace_back(0);
    }
    sort(v.begin(),v.end());
    for(i=0;i<v.size();i++)
    {
        if(v[i].first!=last)
            last=v[i].first,b[i]=i,dp[i]=1,p[i]=i;
        else
            b[i]=b[i-1],dp[i]=dp[i-1],p[i]=p[i-1];
        if(pos(b[i],i,v[i].second.first)!=-1&&dp[pos(b[i],i,v[i].second.first)]+1>dp[i])
            dp[i]=dp[pos(b[i],i,v[i].second.first)]+1,p[i]=i;
        if(dp[i]>ans)
            ans=dp[i],pans=p[i];
    }
    cout<<ans<<"\n";
    while(pans!=-1)
    {
        cout<<v[pans].second.first<<" "<<v[pans].second.second<<"\n";
        pans=pos(b[pans],pans,v[pans].second.first);
    }
}


#include<bits/stdc++.h>
using namespace std;

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin>>n;
  int a[n];
  int b[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
    b[i]=a[i];
  }
  for(int i=1;i<n;i++){
    b[i]+=b[i-1];
  }
  vector<pair<int,pair<int,int>>> v;
  v.push_back(make_pair(b[0],make_pair(0,0)));
  for(int i=0;i<n;i++){
    for(int j=i;j<n;j++){
        if(i-1>=0){
      v.push_back(make_pair(b[j]-b[i-1],make_pair(i,j)));
        }
    }
  }
  sort(v.begin(),v.end());

  int g=v[0].first;
  int f=1;
  for(int i=0;i<v.size();i++){
    int k=0;
    int l=i;
    for(int j=i+1;j<v.size();j++){
      if(v[j].first==v[i].first){
      if(v[j].first==v[i].first && v[j].second.first>v[l].second.second){
        k++;
        l=j;
      }
      }else{
        if(k+1>=f){
          g=v[i].first;
          f=k+1;
        }
        i=j-1;
        j=v.size();
      }
    }
  }
  cout<<f<<endl;

  for(int i=0;i<v.size();i++){
      if(g==v[i].first){
          int l=i;
          cout<<v[i].second.first+1<<" "<<v[i].second.second+1<<endl;
          for(int j=i;j<v.size();j++){

              if(v[j].first==v[i].first){
              if(v[j].first==v[i].first && v[j].second.first>v[l].second.second){
                  cout<<v[j].second.first+1<<" "<<v[j].second.second+1<<endl;
                  l=j;

              }
              }else{
                  return 0;
              }
          }
      }
  }

}


#include<bits/stdc++.h>
using namespace std;

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin>>n;
  int a[n];
  int b[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
    b[i]=a[i];
  }
  for(int i=1;i<n;i++){
    b[i]+=b[i-1];
  }
  vector<pair<int,pair<int,int>>> v;
  v.push_back(make_pair(b[0],make_pair(0,0)));
  for(int i=0;i<n;i++){
      v.push_back(make_pair(b[i],make_pair(0,i)));
  }

  for(int i=0;i<n;i++){
    for(int j=i;j<n;j++){
        if(i-1>=0){
      v.push_back(make_pair(b[j]-b[i-1],make_pair(i,j)));
        }
    }
  }
  sort(v.begin(),v.end());

  int g=v[0].first;
  int f=1;
  for(int i=0;i<v.size();i++){
    int k=0;
    int l=i;
    for(int j=i+1;j<v.size();j++){
      if(v[j].first==v[i].first){
      if(v[j].first==v[i].first && v[j].second.first>v[l].second.second){
        k++;

        l=j;
      }
      if(j==v.size()-1){
          f=max(k+1,f);
      }

      }else{
        if(k+1>=f){
          g=v[i].first;
          f=k+1;
        }
        i=j-1;
        j=v.size();
      }
    }
  }
  cout<<f<<endl;

  for(int i=0;i<v.size();i++){
      if(g==v[i].first){
          int l=i;
          cout<<v[i].second.first+1<<" "<<v[i].second.second+1<<endl;
          if(v[i].second.second+1>=n){
              return 0;
          }

          for(int j=i;j<v.size();j++){

              if(v[j].first==v[i].first){
              if(v[j].first==v[i].first && v[j].second.first>v[l].second.second){
                  cout<<v[j].second.first+1<<" "<<v[j].second.second+1<<endl;
                  l=j;
                 if(v[j].second.second+1>=n){
                     return 0;
                 }

              }
              }else{
                  return 0;
              }
          }

      }
  }

}


#include<bits/stdc++.h>
using namespace std;

bool sorter(const pair<int,int> &a, const pair<int,int> &b){
  return a.second<b.second;
}

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin>>n;
  int a[n];
  int b[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
    b[i]=a[i];
  }
  for(int i=1;i<n;i++){
    b[i]+=b[i-1];
  }
  unordered_map<int, vector<pair<int,int>>> m;
  for(int i=0;i<n;i++){
    for(int j=i;j<n;j++){
      if(i-1>=0){
        m[b[j]-b[i-1]].push_back({i,j});
      }else{
        m[b[j]].push_back({0,j});
      }
    }
  }
  int g=-1;
  vector<pair<int,int>> ans;
  for(auto it:m){
    vector<pair<int,int>> v=it.second;
    vector<pair<int,int>> z;
    sort(v.begin(),v.end(),sorter);
    int p=-1;
    int q=0;
    for(int i=0;i<v.size();i++){
         pair<int,int> initial=v[i];
         if(v[i].first>p){
          q++;
          p=v[i].second;
          z.push_back(v[i]);
         }
    }
    if(q>g){
      g=q;
      ans=z;
    }

  }
   cout<<g<<endl;
  for(int i=0;i<(int)ans.size();i++){
    cout<<ans[i].first+1<<" "<<ans[i].second+1<<endl;
  }

}


#include<bits/stdc++.h>
using namespace std;

bool sorter(const pair<int,pair<int,int>> &a,const pair<int,pair<int,int>> &b){
    if(a.first!=b.first){
        return a.first<b.first;
    }else{
        if(a.second.second!=b.second.second){
        return a.second.second<b.second.second;
        }else{
         return a.second.first<=b.second.first;
        }
    }
}
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin>>n;
  int a[n];
  int b[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
    b[i]=a[i];
  }
  for(int i=1;i<n;i++){
    b[i]+=b[i-1];
  }
  if(b[0]==b[n-1]){
      cout<<n<<endl;
      for(int i=0;i<n;i++){
          cout<<i+1<<" "<<i+1<<endl;
      }
  }else{
  vector<pair<int,pair<int,int>>> v;

  for(int i=0;i<n;i++){
    for(int j=i;j<n;j++){
        if(i-1>=0){
      v.push_back(make_pair(b[j]-b[i-1],make_pair(i,j)));
        }else{
            v.push_back(make_pair(b[j],make_pair(0,j)));
        }
    }
  }
  sort(v.begin(),v.end(),sorter);

  int g=v[0].first;
  int f=1;
  for(int i=0;i<v.size();i++){
    int k=0;
    int l=i;
    for(int j=i+1;j<v.size();j++){
      if(v[j].first==v[i].first){
      if(v[j].first==v[i].first && v[j].second.first>v[l].second.second){
        k++;

        l=j;
      }
      if(j==v.size()-1){
          if(f<=k+1){
              f=k+1;
              g=v[l].first;
          }

      }

      }else{
        if(k+1>=f){
          g=v[i].first;
          f=k+1;
        }
        i=j-1;
        j=v.size();
      }
    }
  }
  cout<<f<<endl;

  for(int i=0;i<v.size();i++){
      if(g==v[i].first){
          int l=i;
          cout<<v[i].second.first+1<<" "<<v[i].second.second+1<<endl;
          if(v[i].second.second+1>=n){
              return 0;
          }

          for(int j=i;j<v.size();j++){

              if(v[j].first==v[i].first){
              if(v[j].first==v[i].first && v[j].second.first>v[l].second.second){
                  cout<<v[j].second.first+1<<" "<<v[j].second.second+1<<endl;
                  l=j;
                 if(v[j].second.second+1>=n){
                     return 0;
                 }

              }
              }else{
                  return 0;
              }
          }

      }
  }
  }

}


#include<bits/stdc++.h>
using namespace std;

bool sorter(const pair<int,pair<int,int>> &a,const pair<int,pair<int,int>> &b){
    if(a.first!=b.first){
        return a.first<b.first;
    }else{
        if(a.second.second!=b.second.second){
        return a.second.second<b.second.second;
        }else{
         return a.second.first<=b.second.first;
        }
    }
}
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin>>n;
  int a[n];
  int b[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
    b[i]=a[i];
  }
  for(int i=1;i<n;i++){
    b[i]+=b[i-1];
  }
  vector<pair<int,pair<int,int>>> v;

  for(int i=0;i<n;i++){
    for(int j=i;j<n;j++){
        if(i-1>=0){
      v.push_back(make_pair(b[j]-b[i-1],make_pair(i,j)));
        }else{
            v.push_back(make_pair(b[j],make_pair(0,j)));
        }
    }
  }
  sort(v.begin(),v.end(),sorter);

  int g=v[0].first;
  int f=1;
  for(int i=0;i<v.size();i++){
    int k=0;
    int l=i;
    for(int j=i+1;j<v.size();j++){
      if(v[j].first==v[i].first){
      if(v[j].first==v[i].first && v[j].second.first>v[l].second.second){
        k++;

        l=j;
      }
      if(j==v.size()-1){
          if(f<=k+1){
              f=k+1;
              g=v[l].first;
          }

      }

      }else{
        if(k+1>=f){
          g=v[i].first;
          f=k+1;
        }
        i=j-1;
        j=v.size();
      }
    }
  }
  cout<<f<<endl;

  for(int i=0;i<v.size();i++){
      if(g==v[i].first){
          int l=i;
          cout<<v[i].second.first+1<<" "<<v[i].second.second+1<<endl;
          if(v[i].second.second+1>=n){
              return 0;
          }

          for(int j=i;j<v.size();j++){

              if(v[j].first==v[i].first){
              if(v[j].first==v[i].first && v[j].second.first>v[l].second.second){
                  cout<<v[j].second.first+1<<" "<<v[j].second.second+1<<endl;
                  l=j;
                 if(v[j].second.second+1>=n){
                     return 0;
                 }

              }
              }else{
                  return 0;
              }
          }

      }
  }

}


#include<bits/stdc++.h>
using namespace std;

bool sorter(const pair<int,pair<int,int>> &a,const pair<int,pair<int,int>> &b){
    if(a.first!=b.first){
        return a.first<b.first;
    }else{
        return a.second.second<b.second.second;
    }
}
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin>>n;
  int a[n];
  int b[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
    b[i]=a[i];
  }
  for(int i=1;i<n;i++){
    b[i]+=b[i-1];
  }
  vector<pair<int,pair<int,int>>> v;
  v.push_back(make_pair(b[0],make_pair(0,0)));

  for(int i=0;i<n;i++){
    for(int j=i;j<n;j++){
        if(i-1>=0){
      v.push_back(make_pair(b[j]-b[i-1],make_pair(i,j)));
        }else{
            v.push_back(make_pair(b[j],make_pair(0,j)));
        }
    }
  }
  sort(v.begin(),v.end(),sorter);

  int g=v[0].first;
  int f=1;
  for(int i=0;i<v.size();i++){
    int k=0;
    int l=i;
    for(int j=i+1;j<v.size();j++){
      if(v[j].first==v[i].first){
      if(v[j].first==v[i].first && v[j].second.first>v[l].second.second){
        k++;

        l=j;
      }
      if(j==v.size()-1){
          if(f<=k+1){
              f=k+1;
              g=v[l].first;
          }

      }

      }else{
        if(k+1>=f){
          g=v[i].first;
          f=k+1;
        }
        i=j-1;
        j=v.size();
      }
    }
  }
  cout<<f<<endl;

  for(int i=0;i<v.size();i++){
      if(g==v[i].first){
          int l=i;
          cout<<v[i].second.first+1<<" "<<v[i].second.second+1<<endl;
          if(v[i].second.second+1>=n){
              return 0;
          }

          for(int j=i;j<v.size();j++){

              if(v[j].first==v[i].first){
              if(v[j].first==v[i].first && v[j].second.first>v[l].second.second){
                  cout<<v[j].second.first+1<<" "<<v[j].second.second+1<<endl;
                  l=j;
                 if(v[j].second.second+1>=n){
                     return 0;
                 }

              }
              }else{
                  return 0;
              }
          }

      }
  }

}


#include<bits/stdc++.h>
using namespace std;

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin>>n;
  int a[n];
  int b[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
    b[i]=a[i];
  }
  for(int i=1;i<n;i++){
    b[i]+=b[i-1];
  }
  vector<pair<int,pair<int,int>>> v;
  v.push_back(make_pair(b[0],make_pair(0,0)));
  for(int i=0;i<n;i++){
    for(int j=i;j<n;j++){
        if(i-1>=0){
      v.push_back(make_pair(b[j]-b[i-1],make_pair(i,j)));
        }
    }
  }
  sort(v.begin(),v.end());

  int g=v[0].first;
  int f=1;
  for(int i=0;i<v.size();i++){
    int k=0;
    int l=i;
    for(int j=i+1;j<v.size();j++){
      if(v[j].first==v[i].first){
      if(v[j].first==v[i].first && v[j].second.first>v[l].second.second){
        k++;

        l=j;
      }
      if(j==v.size()-1){
          f=max(k+1,f);
      }

      }else{
        if(k+1>=f){
          g=v[i].first;
          f=k+1;
        }
        i=j-1;
        j=v.size();
      }
    }
  }
  cout<<f<<endl;

  for(int i=0;i<v.size();i++){
      if(g==v[i].first){
          int l=i;
          cout<<v[i].second.first+1<<" "<<v[i].second.second+1<<endl;

          for(int j=i;j<v.size();j++){

              if(v[j].first==v[i].first){
              if(v[j].first==v[i].first && v[j].second.first>v[l].second.second){
                  cout<<v[j].second.first+1<<" "<<v[j].second.second+1<<endl;
                  l=j;
                 if(v[j].second.second+1>=n){
                     return 0;
                 }

              }
              }else{
                  return 0;
              }
          }

      }
  }

}


#include<bits/stdc++.h>
using namespace std;

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin>>n;
  int a[n];
  int b[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
    b[i]=a[i];
  }
  for(int i=1;i<n;i++){
    b[i]+=b[i-1];
  }
  vector<pair<int,pair<int,int>>> v;
  v.push_back(make_pair(b[0],make_pair(0,0)));
  for(int i=0;i<n;i++){
      v.push_back(make_pair(b[i],make_pair(0,i)));
  }

  for(int i=0;i<n;i++){
    for(int j=i;j<n;j++){
        if(i-1>=0){
      v.push_back(make_pair(b[j]-b[i-1],make_pair(i,j)));
        }
    }
  }
  sort(v.begin(),v.end());

  int g=v[0].first;
  int f=1;
  for(int i=0;i<v.size();i++){
    int k=0;
    int l=i;
    for(int j=i+1;j<v.size();j++){
      if(v[j].first==v[i].first){
      if(v[j].first==v[i].first && v[j].second.first>v[l].second.second){
        k++;

        l=j;
      }
      if(j==v.size()-1){
          f=max(k+1,f);
      }

      }else{
        if(k+1>=f){
          g=v[i].first;
          f=k+1;
        }
        i=j-1;
        j=v.size();
      }
    }
  }
  cout<<f<<endl;

  for(int i=0;i<v.size();i++){
      if(g==v[i].first){
          int l=i;
          cout<<v[i].second.first+1<<" "<<v[i].second.second+1<<endl;

          for(int j=i;j<v.size();j++){

              if(v[j].first==v[i].first){
              if(v[j].first==v[i].first && v[j].second.first>v[l].second.second){
                  cout<<v[j].second.first+1<<" "<<v[j].second.second+1<<endl;
                  l=j;
                 if(v[j].second.second+1>=n){
                     return 0;
                 }

              }
              }else{
                  return 0;
              }
          }

      }
  }

}


#include<bits/stdc++.h>
using namespace std;

bool sorter(const pair<int,int> &a, const pair<int,int> &b){
  return a.second<b.second;
}

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin>>n;
  int a[n];
  int b[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
    b[i]=a[i];
  }
  for(int i=1;i<n;i++){
    b[i]+=b[i-1];
  }
  map<int, vector<pair<int,int>>> m;
  for(int i=0;i<n;i++){
    for(int j=i;j<n;j++){
      if(i-1>=0){
        m[b[j]-b[i-1]].push_back({i,j});
      }else{
        m[b[j]].push_back({0,j});
      }
    }
  }
  int g=-1;
  vector<pair<int,int>> ans;
  for(auto it:m){
    vector<pair<int,int>> v=it.second;
    vector<pair<int,int>> z;
    sort(v.begin(),v.end(),sorter);
    int p=-1;
    int q=0;
    for(int i=0;i<v.size();i++){
         pair<int,int> initial=v[i];
         if(v[i].first>p){
          q++;
          p=v[i].second;
          z.push_back(v[i]);
         }
    }
    if(q>g){
      g=q;
      ans=z;
    }

  }
   cout<<g<<endl;
  for(int i=0;i<(int)ans.size();i++){
    cout<<ans[i].first+1<<" "<<ans[i].second+1<<endl;
  }

}


#include<bits/stdc++.h>
using namespace std;

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin>>n;
  int a[n];
  int b[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
    b[i]=a[i];
  }
  for(int i=1;i<n;i++){
    b[i]+=b[i-1];
  }
  vector<pair<int,pair<int,int>>> v;
  v.push_back(make_pair(b[0],make_pair(0,0)));

  for(int i=0;i<n;i++){
    for(int j=i;j<n;j++){
        if(i-1>=0){
      v.push_back(make_pair(b[j]-b[i-1],make_pair(i,j)));
        }else{
            v.push_back(make_pair(b[j],make_pair(0,j)));
        }
    }
  }
  sort(v.begin(),v.end());

  int g=v[0].first;
  int f=1;
  for(int i=0;i<v.size();i++){
    int k=0;
    int l=i;
    for(int j=i+1;j<v.size();j++){
      if(v[j].first==v[i].first){
      if(v[j].first==v[i].first && v[j].second.first>v[l].second.second){
        k++;

        l=j;
      }
      if(j==v.size()-1){
          if(f<=k+1){
              f=k+1;
              g=v[l].first;
          }

      }

      }else{
        if(k+1>=f){
          g=v[i].first;
          f=k+1;
        }
        i=j-1;
        j=v.size();
      }
    }
  }
  cout<<f<<endl;

  for(int i=0;i<v.size();i++){
      if(g==v[i].first){
          int l=i;
          cout<<v[i].second.first+1<<" "<<v[i].second.second+1<<endl;
          if(v[i].second.second+1>=n){
              return 0;
          }

          for(int j=i;j<v.size();j++){

              if(v[j].first==v[i].first){
              if(v[j].first==v[i].first && v[j].second.first>v[l].second.second){
                  cout<<v[j].second.first+1<<" "<<v[j].second.second+1<<endl;
                  l=j;
                 if(v[j].second.second+1>=n){
                     return 0;
                 }

              }
              }else{
                  return 0;
              }
          }

      }
  }

}


#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define pb push_back
#define sz(x)  ((int)x.size ())
#define all(x) (x).begin(), (x).end()
#define re return
#define mp make_pair
#define sqrt(x) sqrt (abs(x))
#define y0 y3451
#define y1 y4562
#define j0 j25624
#define j1 j45624
#define makeunique(x) sort(all(x)), (x).resize (unique(all(x)) - (x).begin())

typedef pair <int, int> ii;
typedef long long ll;
typedef unsigned long long ull;
typedef double D;
typedef long double ld;
typedef unsigned int uint;
typedef vector <string> vs;
typedef vector <int> vi;
typedef vector <ii> vii;
typedef vector <vi> vvi;
typedef vector <ll> vll;

template <class T> T abs (T x) { re x > 0 ? x : -x; }
template <class T> T sqr (T x) { re x * x; }
template <class T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }
template <class T> int sgn (T x) { re x > 0 ? 1 : (x < 0 ? -1 : 0); }

#define filename ""

const int N = 2e3 + 20;
const int inf = 1e9 + 7;

int n, m;
int a[N];
ll s[N];
map<ll, int> dp[N], pr[N], g[N];
map<ll, vector<pair<int, ii>>> ma;

ll sum (int l, int r) {
	re l ? s[r] - s[l - 1] : s[r];
}

int bin (vector<pair<int, ii>>& a, int x) {
	int l = 0;
	int r = sz(a) - 1;
	while (l <= r) {
		int c = (l + r) / 2;
		if (a[c].fi >= x) r = c - 1;
		else l = c + 1;
	}
	re r;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) scanf("%d", a + i);
	s[0] = a[0];
	for (int i = 1; i < n; i++) s[i] = s[i - 1] + a[i];
	pair<int, pair<int, ll>>  ans = mp(-1, mp(-1, -1));
	for (int i = 0; i < n; i++)
		for (int j = 0; j <= i; j++) {
			ll cur = sum(j, i);
			dp[i][cur] = max(dp[i][cur], 1);
			if (!pr[i].count(cur)) pr[i][cur] = -1;
			g[i][cur] = j;
			int* xx = &dp[i][cur];
			if (ma.count(cur)) {
				int x = bin(ma[cur], j);
				if (x != -1 && *xx < dp[ma[cur][x].se.se][cur] + 1) {
					*xx = dp[ma[cur][x].se.se][cur] + 1;
					pr[i][cur] = ma[cur][x].se.se;
				}
			}
			if (ma.count(cur) && ma[cur].back().fi == i) {
				ma[cur].back() = max(ma[cur].back(), mp(i, mp(*xx, i)));
			} else {
				ma[cur].pb(mp(i, mp(*xx, i)));
				if (sz(ma[cur]) != 1) ma[cur].back().se = max(ma[cur].back().se, ma[cur][sz(ma[cur]) - 2].se);
			}
			ans = max(ans, mp(*xx, mp(i, cur)));
		}
	cout << ans.fi << endl;
	pair<int, ll> cur = ans.se;
	while (cur.fi != -1) {
		cout << g[cur.fi][cur.se] + 1 << " " << cur.fi + 1 << endl;
		cur.fi = pr[cur.fi][cur.se];
	}
}


#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define pb push_back
#define sz(x)  ((int)x.size ())
#define all(x) (x).begin(), (x).end()
#define re return
#define mp make_pair
#define sqrt(x) sqrt (abs(x))
#define y0 y3451
#define y1 y4562
#define j0 j25624
#define j1 j45624
#define makeunique(x) sort(all(x)), (x).resize (unique(all(x)) - (x).begin())

typedef pair <int, int> ii;
typedef long long ll;
typedef unsigned long long ull;
typedef double D;
typedef long double ld;
typedef unsigned int uint;
typedef vector <string> vs;
typedef vector <int> vi;
typedef vector <ii> vii;
typedef vector <vi> vvi;
typedef vector <ll> vll;

template <class T> T abs (T x) { re x > 0 ? x : -x; }
template <class T> T sqr (T x) { re x * x; }
template <class T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }
template <class T> int sgn (T x) { re x > 0 ? 1 : (x < 0 ? -1 : 0); }

#define filename ""

const int N = 2e3 + 20;
const int inf = 1e9 + 7;

int n, m;
int a[N];
ll s[N];
map<ll, int> dp[N], pr[N], g[N];
map<ll, vector<pair<int, ii>>> ma;

ll sum (int l, int r) {
	re l ? s[r] - s[l - 1] : s[r];
}

int bin (vector<pair<int, ii>>& a, int x) {
	int l = 0;
	int r = sz(a) - 1;
	while (l <= r) {
		int c = (l + r) / 2;
		if (a[c].fi >= x) r = c - 1;
		else l = c + 1;
	}
	re r;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) scanf("%d", a + i);
	s[0] = a[0];
	for (int i = 1; i < n; i++) s[i] = s[i - 1] + a[i];
	pair<int, pair<int, ll>>  ans = mp(-1, mp(-1, -1));
	for (int i = 0; i < n; i++)
		for (int j = 0; j <= i; j++) {
			ll cur = sum(j, i);
			g[i][cur] = j;
			auto& prv = pr[i][cur];
			auto& xx = dp[i][cur];
			auto& p = ma[cur];
			if (xx < 1) { xx = 1; prv = -1; }
			if (sz(p)) {
				int x = bin(p, j);
				if (x != -1 && xx < p[x].se.fi + 1) {
					xx = p[x].se.fi + 1;
					prv = p[x].se.se;
				}
			}
			if (sz(p) && p.back().fi == i) {
				p.back() = max(p.back(), mp(i, mp(xx, i)));
			} else {
				p.resize(sz(p) + 1);
				p.back() = mp(i, mp(xx, i));
				if (sz(p) != 1) p.back().se = max(p.back().se, p[sz(p) - 2].se);
			}
			ans = max(ans, mp(xx, mp(i, cur)));
		}
	cout << ans.fi << endl;
	pair<int, ll> cur = ans.se;
	while (cur.fi != -1) {
		cout << g[cur.fi][cur.se] + 1 << " " << cur.fi + 1 << endl;
		cur.fi = pr[cur.fi][cur.se];
	}
}


#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define pb push_back
#define sz(x)  ((int)x.size ())
#define all(x) (x).begin(), (x).end()
#define re return
#define mp make_pair
#define sqrt(x) sqrt (abs(x))
#define y0 y3451
#define y1 y4562
#define j0 j25624
#define j1 j45624
#define makeunique(x) sort(all(x)), (x).resize (unique(all(x)) - (x).begin())

typedef pair <int, int> ii;
typedef long long ll;
typedef unsigned long long ull;
typedef double D;
typedef long double ld;
typedef unsigned int uint;
typedef vector <string> vs;
typedef vector <int> vi;
typedef vector <ii> vii;
typedef vector <vi> vvi;
typedef vector <ll> vll;

template <class T> T abs (T x) { re x > 0 ? x : -x; }
template <class T> T sqr (T x) { re x * x; }
template <class T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }
template <class T> int sgn (T x) { re x > 0 ? 1 : (x < 0 ? -1 : 0); }

#define filename ""

const int N = 2e3 + 20;
const int inf = 1e9 + 7;

int n, m;
int a[N];
ll s[N];
map<ll, int> dp[N], pr[N], g[N];
map<ll, vi> w;

ll sum (int l, int r) {
	re l ? s[r] - s[l - 1] : s[r];
}

int bin (vector<int>& aa, int x) {
	int l = 0;
	int r = sz(aa) - 1;
	while (l <= r) {
		int c = (l + r) / 2;
		if (aa[c] >= x) r = c - 1;
		else l = c + 1;
	}
	re r;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) scanf("%d", a + i);
	s[0] = a[0];
	for (int i = 1; i < n; i++) s[i] = s[i - 1] + a[i];
	pair<int, pair<int, ll>>  ans = mp(-1, mp(-1, -1));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= i; j++) {
			ll cur = sum (j, i);
			g[i][cur] = j;
			int pos = -1;
			if (w.count(cur)) pos = bin(w[cur], j);
			if (pos != -1) {
				pos = w[cur][pos];
				int q = dp[pos][cur] + 1;
				if (dp[i][cur] <= q) {
					dp[i][cur] = dp[pos][cur] + 1;
					pr[i][cur] = pos;
				}
			} else {
				if (!dp[i].count(cur)) {
					dp[i][cur] = 1;
					pr[i][cur] = -1;
				}
			}
			ans = max(ans, mp(dp[i][cur], mp(i, cur)));
			if (!(w.count(cur) && w[cur].back() == i)) w[cur].pb(i);
		}
	}
	cout << ans.fi << endl;
	pair<int, ll> cur = ans.se;
	while (cur.fi != -1) {
		cout << g[cur.fi][cur.se] + 1 << " " << cur.fi + 1 << endl;
		cur.fi = pr[cur.fi][cur.se];
	}
}


#include<bits/stdc++.h>
#define mp make_pair
#define fs first
#define sc second
#define pb push_back
using namespace std;

//inline void scan(int* p) {
//	static char c;
//	while ((c = getchar_unlocked()) < '0');
//	for (*p = c-'0'; (c = getchar_unlocked()) >= '0'; *p = *p*10+c-'0');
//}

string baca;

int ini[26][5005][26];
int nyak[26];

int main(){
//	ios::sync_with_stdio(0); cin.tie(0);
	cin >> baca;

	int cnt = 0;
	int l = baca.length();
	for(int i = 0; i < l; i++){
		int idx = baca[i] - 'a';
		int it = (i + 1) % l;
		nyak[idx]++;
		int hm = 1;
		while(it != i){
			ini[idx][hm][baca[it] - 'a']++;
		//	cout << it << " ";
			it = (it + 1) % l;
			hm++;
		}
	//	cout << "\n";
	}

	for(int i = 0; i < 26; i++){
		int maks = 0;
		for(int j = 1; j < l; j++){
			int now = 0;
			for(int k = 0; k < 26; k++){
				if(ini[i][j][k] >= 2) continue;
				now = now + ini[i][j][k];
			}
			maks = max(maks,now);
		}
		cnt = cnt + maks;
	}

	double prob = (double) cnt / baca.length();
	printf("%.9lf\n",prob);
}


#include<bits/stdc++.h>
#define mp make_pair
#define fs first
#define sc second
#define pb push_back
using namespace std;

//inline void scan(int* p) {
//	static char c;
//	while ((c = getchar_unlocked()) < '0');
//	for (*p = c-'0'; (c = getchar_unlocked()) >= '0'; *p = *p*10+c-'0');
//}

string baca;

int ini[26][5005][26];
int nyak[26];

int main(){
	cin >> baca;

	int cnt = 0;
	memset(ini,0,sizeof(ini));
	memset(nyak,0,sizeof(nyak));
	for(int i = 0; i < baca.length(); i++){
		string now = "";
		for(int j = i; j < baca.length(); j++){
			now = now + baca[j];
		}
		for(int j = 0; j < i; j++){
			now = now + baca[j];
		}
		int idx = now[0] - 'a';
		nyak[idx]++;
		for(int j = 1; j < now.length(); j++){
			ini[idx][j][now[j] - 'a']++;
		}
	}

	for(int i = 0; i < 26; i++){
		int maks = 0;
		for(int j = 1; j < baca.length(); j++){
			int now = 0;
			for(int k = 0; k < 26; k++){
				if(ini[i][j][k] >= 2) continue;
				now = now + ini[i][j][k];
			}
			maks = max(maks,now);
		}
		cnt = cnt + maks;
	}

	double prob = (double) cnt / baca.length();
	printf("%.9lf\n",prob);
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=5005;
char s[maxn<<1];
int n,ans=0,a[26][26][maxn];
int main()
{
    scanf("%s",s+1);
    n=strlen(s+1);
    for(int i=1;i<=n;i++)
        s[i+n]=s[i];
    memset(a,0,sizeof(a));
    for(int i=1;i<=n;i++)
        for(int j=i+1;j<n+i;j++)
            a[s[i]-'a'][s[j]-'a'][j-i+1]++;
    for(int i=0;i<26;i++)
    {
        int tmp=0;
        for(int j=1;j<=n;j++)
        {
            int sum=0;
            for(int k=0;k<26;k++)
            {
                if(a[i][k][j]==1)
                    sum++;
            }
            tmp=max(tmp,sum);
        }
        ans+=tmp;
    }
    printf("%.15f\n",(double)ans/n);
}


#include <bits/stdc++.h>
using namespace std;

typedef int ll;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define endl '\n'

typedef pair<int,int>pii;
typedef pair<int,pair<int,int> > piii;

const int mod=1e9+7;

int POWER[65];
int power(int a, int b) {int ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=mod) ret%=mod;if(a>=mod) a%=mod;b>>=1;}return ret;}
int inv(int x) {return power(x,mod-2);}

void precompute() {
	POWER[0]=1;
	for(int i=1;i<63;i++) POWER[i]=POWER[i-1]<<1LL;
}

const int maxn=5e3+55,maxx=1e7+55;
map<piii,int>mpp;
int v[maxx];
piii pp[maxx];
map<pii,int>sum;
int ana[205],fre[205];

ll main() {
	// freopen("Task.in","r",stdin);freopen("Task.out","w",stdout);

	std:ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	string s;
	cin>>s;
	for (int i=0 ; i<sz(s) ; i++){
		fre[s[i]]++;
	}

	int cnt=0;
	for (int j=0 ; j<sz(s) ; j++) {
		for (int i=0 ; i<sz(s) ; i++) {
			int ii=(i+j)%sz(s);
			if(mpp.find(mp(i,mp(s[j],s[ii])))==mpp.end()) {
				/*if(cnt>=maxx) {
					while (1){}
				}*/
				pp[cnt]=mp(i,mp(s[j],s[ii]));
				mpp[mp(i,mp(s[j],s[ii]))]=cnt++;
			}
			v[mpp[mp(i,mp(s[j],s[ii]))]]++;
			// cout<<j<<" "<<i<<" "<<mpp[mp(i,mp(s[j],s[ii]))]<<" "<<s[j]<<" "<<s[ii]<<endl;
		}

	}

	long double ret=0;
	for (int i=0 ; i<cnt ; i++) {
		if(v[i]==1) {
			sum[mp(pp[i].ff,pp[i].ss.ff)]++;
			ana[pp[i].ss.ff]=max(ana[pp[i].ss.ff],sum[mp(pp[i].ff,pp[i].ss.ff)]);
		}
	}
	for (char i='a' ; i<='z' ; i++) {
		long double gg=0;
		if(ana[i]!=0)	gg=((long double)ana[i]/(long double) sz(s));
		ret+=gg;
	}

	cout<<setprecision(15)<<fixed<<ret<<endl;
}


#include <bits/stdc++.h>
using namespace std;

typedef int ll;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define endl '\n'

typedef pair<int,int>pii;
typedef pair<int,pair<int,int> > piii;

const int mod=1e9+7;

int POWER[65];
int power(int a, int b) {int ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=mod) ret%=mod;if(a>=mod) a%=mod;b>>=1;}return ret;}
int inv(int x) {return power(x,mod-2);}

void precompute() {
	POWER[0]=1;
	for(int i=1;i<63;i++) POWER[i]=POWER[i-1]<<1LL;
}

const int maxn=5e3+55,maxx=1e7+55;
int mpp[maxn][30][30];
int v[maxx];
piii pp[maxx];
map<pii,int>sum;
int ana[205],fre[205];

ll main() {
	// freopen("Task.in","r",stdin);freopen("Task.out","w",stdout);

	std:ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	string s;
	cin>>s;
	for (int i=0 ; i<sz(s) ; i++){
		fre[s[i]]++;
	}

	int cnt=1;
	for (int j=0 ; j<sz(s) ; j++) {
		for (int i=0 ; i<sz(s) ; i++) {
			int ii=(i+j)%sz(s);
			if(mpp[i][s[j]-'a'][s[ii]-'a']==0) {
				/*if(cnt>=maxx) {
					while (1){}
				}*/
				pp[cnt]=mp(i,mp(s[j],s[ii]));
				mpp[i][s[j]-'a'][s[ii]-'a']=cnt++;
			}
			v[mpp[i][s[j]-'a'][s[ii]-'a']]++;
			// cout<<j<<" "<<i<<" "<<mpp[mp(i,mp(s[j],s[ii]))]<<" "<<s[j]<<" "<<s[ii]<<endl;
		}

	}

	long double ret=0;
	for (int i=0 ; i<cnt ; i++) {
		if(v[i]==1) {
			sum[mp(pp[i].ff,pp[i].ss.ff)]++;
			ana[pp[i].ss.ff]=max(ana[pp[i].ss.ff],sum[mp(pp[i].ff,pp[i].ss.ff)]);
		}
	}
	for (char i='a' ; i<='z' ; i++) {
		long double gg=0;
		if(ana[i]!=0)	gg=((long double)ana[i]/(long double) sz(s));
		ret+=gg;
	}

	cout<<setprecision(15)<<fixed<<ret<<endl;
}


#include <bits/stdc++.h>
using namespace std;

typedef int ll;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define endl '\n'

typedef pair<int,int>pii;
typedef pair<int,pair<int,int> > piii;

const int mod=1e9+7;

int POWER[65];
int power(int a, int b) {int ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=mod) ret%=mod;if(a>=mod) a%=mod;b>>=1;}return ret;}
int inv(int x) {return power(x,mod-2);}

void precompute() {
	POWER[0]=1;
	for(int i=1;i<63;i++) POWER[i]=POWER[i-1]<<1LL;
}

const int maxn=5e3+55;
map<piii,int>mpp;
int v[maxn];
bool vis[maxn];
piii pp[maxn];
map<pii,int>sum;
int ana[maxn],fre[maxn];

ll main() {
	// freopen("Task.in","r",stdin);freopen("Task.out","w",stdout);

	std:ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	string s;
	cin>>s;
	for (int i=0 ; i<sz(s) ; i++){
		fre[s[i]]++;
	}

	int cnt=0;
	for (int j=0 ; j<sz(s) ; j++) {
		for (int i=0 ; i<sz(s) ; i++) {
			int ii=(i+j)%sz(s);
			if(mpp.find(mp(i,mp(s[j],s[ii])))==mpp.end())	pp[cnt]=mp(i,mp(s[j],s[ii])),mpp[mp(i,mp(s[j],s[ii]))]=cnt++;
			v[mpp[mp(i,mp(s[j],s[ii]))]]++;
			// cout<<j<<" "<<i<<" "<<mpp[mp(i,mp(s[j],s[ii]))]<<" "<<s[j]<<" "<<s[ii]<<endl;
		}

	}

	long double ret=0;
	for (int i=0 ; i<cnt ; i++) {
	/*	for (int j=0 ; j<sz(v[i]) ; j++)	cout<<v[i][j]<<" ";
			cout<<endl;*/
		if(v[i]==1) {
			// cout<<"gg"<<endl;
			sum[mp(pp[i].ff,pp[i].ss.ff)]++;
			ana[pp[i].ss.ff]=max(ana[pp[i].ss.ff],sum[mp(pp[i].ff,pp[i].ss.ff)]);
		}
	}
	// cout<<ret<<endl;
	for (char i='a' ; i<='z' ; i++) {

		// cout<<ana[i]<<" "<<fre[i]<<" "<<ret<<endl;
		long double gg=0;
		if(ana[i]!=0)	gg=((long double)ana[i]/(long double) sz(s));
		ret+=gg;
		// cout<<gg<<endl;
	}

	cout<<setprecision(15)<<fixed<<ret<<endl;
}


#include <bits/stdc++.h>
using namespace std;

typedef int ll;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define endl '\n'

typedef pair<int,int>pii;
typedef pair<int,pair<int,int> > piii;

const int mod=1e9+7;

int POWER[65];
int power(int a, int b) {int ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=mod) ret%=mod;if(a>=mod) a%=mod;b>>=1;}return ret;}
int inv(int x) {return power(x,mod-2);}

void precompute() {
	POWER[0]=1;
	for(int i=1;i<63;i++) POWER[i]=POWER[i-1]<<1LL;
}

const int maxn=5e3+55,maxx=4e6+55;
int mpp[maxn][30][30];
int v[maxx];
pii pp[maxx];
map<pii,int>sum;
int ana[205],fre[205];

ll main() {
	// freopen("Task.in","r",stdin);freopen("Task.out","w",stdout);

	std:ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	string s;
	cin>>s;
	for (int i=0 ; i<sz(s) ; i++){
		fre[s[i]]++;
	}

	int cnt=1;
	for (int j=0 ; j<sz(s) ; j++) {
		for (int i=0 ; i<sz(s) ; i++) {
			int ii=(i+j)%sz(s);
			if(mpp[i][s[j]-'a'][s[ii]-'a']==0) {

				pp[cnt]=mp(i,s[j]);
				mpp[i][s[j]-'a'][s[ii]-'a']=cnt++;
			}
			v[mpp[i][s[j]-'a'][s[ii]-'a']]++;
			// cout<<j<<" "<<i<<" "<<mpp[mp(i,mp(s[j],s[ii]))]<<" "<<s[j]<<" "<<s[ii]<<endl;
		}

	}

	double ret=0;
	for (int i=0 ; i<cnt ; i++) {
		if(v[i]==1) {
			sum[mp(pp[i].ff,pp[i].ss)]++;
			ana[pp[i].ss]=max(ana[pp[i].ss],sum[mp(pp[i].ff,pp[i].ss)]);
		}
	}
	for (char i='a' ; i<='z' ; i++) {
		double gg=0;
		if(ana[i]!=0)	gg=((double)ana[i]/(double) sz(s));
		ret+=gg;
	}

	cout<<setprecision(15)<<fixed<<ret<<endl;
}


#include <bits/stdc++.h>
using namespace std;

typedef int ll;

#define int long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define endl '\n'

typedef pair<int,int>pii;
typedef pair<int,pair<int,int> > piii;

const int mod=1e9+7;

int POWER[65];
int power(int a, int b) {int ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=mod) ret%=mod;if(a>=mod) a%=mod;b>>=1;}return ret;}
int inv(int x) {return power(x,mod-2);}

void precompute() {
	POWER[0]=1;
	for(int i=1;i<63;i++) POWER[i]=POWER[i-1]<<1LL;
}

const int maxn=5e3+55;
map<piii,int>mpp;
vector<int>v[maxn];
bool vis[maxn];
piii pp[maxn];
map<pii,int>sum;
int ana[maxn],fre[maxn];

ll main() {
	// freopen("Task.in","r",stdin);freopen("Task.out","w",stdout);

	std:ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	string s;
	cin>>s;
	for (int i=0 ; i<sz(s) ; i++){
		fre[s[i]]++;
	}

	int cnt=0;
	for (int j=0 ; j<sz(s) ; j++) {
		for (int i=0 ; i<sz(s) ; i++) {
			int ii=(i+j)%sz(s);
			if(mpp.find(mp(i,mp(s[j],s[ii])))==mpp.end())	pp[cnt]=mp(i,mp(s[j],s[ii])),mpp[mp(i,mp(s[j],s[ii]))]=cnt++;
			v[mpp[mp(i,mp(s[j],s[ii]))]].pb(j);
			// cout<<j<<" "<<i<<" "<<mpp[mp(i,mp(s[j],s[ii]))]<<" "<<s[j]<<" "<<s[ii]<<endl;
		}

	}

	long double ret=0;
	for (int i=0 ; i<cnt ; i++) {
	/*	for (int j=0 ; j<sz(v[i]) ; j++)	cout<<v[i][j]<<" ";
			cout<<endl;*/
		if(sz(v[i])==1) {
			// cout<<"gg"<<endl;
			sum[mp(pp[i].ff,pp[i].ss.ff)]++;
			ana[pp[i].ss.ff]=max(ana[pp[i].ss.ff],sum[mp(pp[i].ff,pp[i].ss.ff)]);
		}
	}
	// cout<<ret<<endl;
	for (char i='a' ; i<='z' ; i++) {

		// cout<<ana[i]<<" "<<fre[i]<<" "<<ret<<endl;
		long double gg=0;
		if(ana[i]!=0)	gg=((long double)ana[i]/(long double) sz(s));
		ret+=gg;
		// cout<<gg<<endl;
	}

	cout<<setprecision(15)<<fixed<<ret<<endl;
}


#include <bits/stdc++.h>
using namespace std;

typedef int ll;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define endl '\n'

typedef pair<int,int>pii;
typedef pair<int,pair<int,int> > piii;

const int mod=1e9+7;

int POWER[65];
int power(int a, int b) {int ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=mod) ret%=mod;if(a>=mod) a%=mod;b>>=1;}return ret;}
int inv(int x) {return power(x,mod-2);}

void precompute() {
	POWER[0]=1;
	for(int i=1;i<63;i++) POWER[i]=POWER[i-1]<<1LL;
}

const int maxn=5e3+55,maxx=4e6+55;
int mpp[30][30][maxn];
int v[maxx];
pii pp[maxx];
map<pii,int>sum;
int ana[205],fre[205];

ll main() {
	// freopen("Task.in","r",stdin);freopen("Task.out","w",stdout);

	std:ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	string s;
	cin>>s;

	assert(sz(s)<=5000);
	for (int i=0 ; i<sz(s) ; i++){
		fre[s[i]]++;
	}

	int cnt=1;
	for (int j=0 ; j<sz(s) ; j++) {
		for (int i=0 ; i<sz(s) ; i++) {
			int ii=(i+j)%sz(s);
			if(mpp[s[j]-'a'][s[ii]-'a'][i]==0) {

				pp[cnt]=mp(i,s[j]);
				mpp[s[j]-'a'][s[ii]-'a'][i]=cnt++;
			}
			v[mpp[s[j]-'a'][s[ii]-'a'][i]]++;
			// cout<<j<<" "<<i<<" "<<mpp[mp(i,mp(s[j],s[ii]))]<<" "<<s[j]<<" "<<s[ii]<<endl;
		}

	}

	double ret=0;
	for (int i=0 ; i<cnt ; i++) {
		if(v[i]==1) {
			sum[mp(pp[i].ff,pp[i].ss)]++;
			ana[pp[i].ss]=max(ana[pp[i].ss],sum[mp(pp[i].ff,pp[i].ss)]);
		}
	}
	for (char i='a' ; i<='z' ; i++) {
		double gg=0;
		if(ana[i]!=0)	gg=((double)ana[i]/(double) sz(s));
		ret+=gg;
	}

	cout<<setprecision(15)<<fixed<<ret<<endl;
}


#include <bits/stdc++.h>
using namespace std;

typedef int ll;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define endl '\n'

typedef pair<int,int>pii;
typedef pair<int,pair<int,int> > piii;

const int mod=1e9+7;

int POWER[65];
int power(int a, int b) {int ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=mod) ret%=mod;if(a>=mod) a%=mod;b>>=1;}return ret;}
int inv(int x) {return power(x,mod-2);}

void precompute() {
	POWER[0]=1;
	for(int i=1;i<63;i++) POWER[i]=POWER[i-1]<<1LL;
}

const int maxn=5e3+55;
map<piii,int>mpp;
int v[maxn];
bool vis[maxn];
piii pp[maxn*1000];
map<pii,int>sum;
int ana[205],fre[205];

ll main() {
	// freopen("Task.in","r",stdin);freopen("Task.out","w",stdout);

	std:ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	string s;
	cin>>s;
	for (int i=0 ; i<sz(s) ; i++){
		fre[s[i]]++;
	}

	int cnt=0;
	for (int j=0 ; j<sz(s) ; j++) {
		for (int i=0 ; i<sz(s) ; i++) {
			int ii=(i+j)%sz(s);
			if(mpp.find(mp(i,mp(s[j],s[ii])))==mpp.end())	pp[cnt]=mp(i,mp(s[j],s[ii])),mpp[mp(i,mp(s[j],s[ii]))]=cnt++;
			v[mpp[mp(i,mp(s[j],s[ii]))]]++;
			// cout<<j<<" "<<i<<" "<<mpp[mp(i,mp(s[j],s[ii]))]<<" "<<s[j]<<" "<<s[ii]<<endl;
		}

	}

	long double ret=0;
	for (int i=0 ; i<cnt ; i++) {
		if(v[i]==1) {
			sum[mp(pp[i].ff,pp[i].ss.ff)]++;
			ana[pp[i].ss.ff]=max(ana[pp[i].ss.ff],sum[mp(pp[i].ff,pp[i].ss.ff)]);
		}
	}
	for (char i='a' ; i<='z' ; i++) {
		long double gg=0;
		if(ana[i]!=0)	gg=((long double)ana[i]/(long double) sz(s));
		ret+=gg;
	}

	cout<<setprecision(15)<<fixed<<ret<<endl;
}


#include <bits/stdc++.h>
using namespace std;

typedef int ll;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define endl '\n'

typedef pair<int,int>pii;
typedef pair<int,pair<int,int> > piii;

const int mod=1e9+7;

int POWER[65];
int power(int a, int b) {int ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=mod) ret%=mod;if(a>=mod) a%=mod;b>>=1;}return ret;}
int inv(int x) {return power(x,mod-2);}

void precompute() {
	POWER[0]=1;
	for(int i=1;i<63;i++) POWER[i]=POWER[i-1]<<1LL;
}

const int maxn=5e3+55,maxx=1e7+55;
map<piii,int>mpp;
int v[maxx];
piii pp[maxx];
map<pii,int>sum;
int ana[205],fre[205];

ll main() {
	// freopen("Task.in","r",stdin);freopen("Task.out","w",stdout);

	std:ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	string s;
	cin>>s;
	for (int i=0 ; i<sz(s) ; i++){
		fre[s[i]]++;
	}

	int cnt=0;
	for (int j=0 ; j<sz(s) ; j++) {
		for (int i=0 ; i<sz(s) ; i++) {
			int ii=(i+j)%sz(s);
			if(mpp.find(mp(i,mp(s[j],s[ii])))==mpp.end()) {
				if(cnt>=maxx) {
					while (1){}
				}
				pp[cnt]=mp(i,mp(s[j],s[ii]));
				mpp[mp(i,mp(s[j],s[ii]))]=cnt++;
			}
			v[mpp[mp(i,mp(s[j],s[ii]))]]++;
			// cout<<j<<" "<<i<<" "<<mpp[mp(i,mp(s[j],s[ii]))]<<" "<<s[j]<<" "<<s[ii]<<endl;
		}

	}

	long double ret=0;
	for (int i=0 ; i<cnt ; i++) {
		if(v[i]==1) {
			sum[mp(pp[i].ff,pp[i].ss.ff)]++;
			ana[pp[i].ss.ff]=max(ana[pp[i].ss.ff],sum[mp(pp[i].ff,pp[i].ss.ff)]);
		}
	}
	for (char i='a' ; i<='z' ; i++) {
		long double gg=0;
		if(ana[i]!=0)	gg=((long double)ana[i]/(long double) sz(s));
		ret+=gg;
	}

	cout<<setprecision(15)<<fixed<<ret<<endl;
}


#include <bits/stdc++.h>
using namespace std;

typedef int ll;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define endl '\n'

typedef pair<int,int>pii;
typedef pair<int,pair<int,int> > piii;

const int mod=1e9+7;

int POWER[65];
int power(int a, int b) {int ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=mod) ret%=mod;if(a>=mod) a%=mod;b>>=1;}return ret;}
int inv(int x) {return power(x,mod-2);}

void precompute() {
	POWER[0]=1;
	for(int i=1;i<63;i++) POWER[i]=POWER[i-1]<<1LL;
}

const int maxn=5e3+55,maxx=1e7+55;
map<piii,int>mpp;
int v[maxn];
bool vis[maxn];
piii pp[maxx];
map<pii,int>sum;
int ana[205],fre[205];

ll main() {
	// freopen("Task.in","r",stdin);freopen("Task.out","w",stdout);

	std:ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	string s;
	cin>>s;
	for (int i=0 ; i<sz(s) ; i++){
		fre[s[i]]++;
	}

	int cnt=0;
	for (int j=0 ; j<sz(s) ; j++) {
		for (int i=0 ; i<sz(s) ; i++) {
			int ii=(i+j)%sz(s);
			if(mpp.find(mp(i,mp(s[j],s[ii])))==mpp.end()) {
				assert(cnt<maxx);
				pp[cnt]=mp(i,mp(s[j],s[ii]));
				mpp[mp(i,mp(s[j],s[ii]))]=cnt++;
			}
			v[mpp[mp(i,mp(s[j],s[ii]))]]++;
			// cout<<j<<" "<<i<<" "<<mpp[mp(i,mp(s[j],s[ii]))]<<" "<<s[j]<<" "<<s[ii]<<endl;
		}

	}

	long double ret=0;
	for (int i=0 ; i<cnt ; i++) {
		if(v[i]==1) {
			sum[mp(pp[i].ff,pp[i].ss.ff)]++;
			ana[pp[i].ss.ff]=max(ana[pp[i].ss.ff],sum[mp(pp[i].ff,pp[i].ss.ff)]);
		}
	}
	for (char i='a' ; i<='z' ; i++) {
		long double gg=0;
		if(ana[i]!=0)	gg=((long double)ana[i]/(long double) sz(s));
		ret+=gg;
	}

	cout<<setprecision(15)<<fixed<<ret<<endl;
}


#include<bits/stdc++.h>
#define maxn 5005
using namespace std;
char s[maxn];
int a[26][26][maxn], h[26];
int main()
{
	scanf("%s", s);
	int n = strlen(s);
	for (int i = 1; i <= n; i++)
	{
		int now = 0;
		for (int j = i + 1; j <= n; j++)
		{
			now++;
			a[s[i - 1] - 'a'][s[j - 1] - 'a'][now]++;
		}
		for (int j = 1; j <= i - 1; j++)
		{
			now++;
			a[s[i - 1] - 'a'][s[j - 1] - 'a'][now]++;
		}
	}
	double ans = 0;
	for (int i = 0; i <= 25; i++)
	{
		int mx = 0;
		for (int j = 1; j <= n - 1; j++)
		{
			int sum = 0;
			for (int k = 0; k <= 25; k++)
				if (a[i][k][j] == 1) sum++;
			mx = max(mx, sum);
		}
		ans += (double)mx / n;
	}
	printf("%.10lf\n", ans);
	return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>

using namespace std;

typedef pair<int,int> ii;
typedef vector<int> vi;
#define REP(i, a, b) for(int i = int(a); i <= int(b); i++)
#define LOOP(i, v) for(int i = 0; i < v.size(); i++)
#define EPS 1e-9
#define INF 1e12
#define debug(x) cerr << "DEBUG : " << (#x) << " => " << (x) << endl

int main()
{
  string s;
  int combien[26][26][5000];

  getline(cin, s);

  REP(i, 0, 25) REP(j, 0, 25) LOOP(k, s) combien[i][j][k] = 0;

  LOOP(i, s)
  {
    for(int j = i+1; j < s.size(); j++)
    {
      {
        combien[s[i]-'a'][s[j]-'a'][j-i]++;
        combien[s[j]-'a'][s[i]-'a'][i-j+s.size()]++;
      }
    }
  }

  int tot = 0;
  REP(i, 0, 25)
  {
    // Lettre i
    int nombre[5000];
    LOOP(k, s) nombre[k] = 0;
    REP(j, 0, 25)
    {
      LOOP(k, s)
      {
        if(combien[i][j][k] == 1) nombre[k]++;
      }
    }
    int mieux = 0;
    LOOP(k, s)
    {
      mieux = max(mieux, nombre[k]);
    }
    tot += mieux;
  }

  printf("%.12lf\n", tot/(double)s.size());

  return 0;
}


#include <stdio.h>
#include <string.h>

char s[10100];
int ok[10100];
int as[1010];
int fir[1010];
int le[30] ,temple[30];
int max(int aa ,int bb)
{
	if (aa>=bb)
	{
		return aa;
	}
	return bb;
}
int main(void)
{
	int c1 ,c2;
	int i ,j ,j2;
	int lens;
	int ans;
	double anss;
	int p ,ga;
	int tt;

	while (scanf("%s" ,s+1)!=EOF)
	{
		lens=strlen(s+1);
		for (i=1 ; i<=lens ; i++)
		{
			ok[i]=0;
		}
		for (i=1 ; i<=lens ; i++)
		{
			s[i+lens]=s[i];
		}
		for (i=0 ; i<=1000 ; i++)
		{
			as[i]=0;
			fir[i]=0;
		}
		for (i=0 ; i<=25 ; i++)
		{
			le[i]=0;
		}

		p=0;
		for (i=1 ; i<lens ; i++)
		{
			ga=p;
			for (j=1 ; j<=lens ; j++)
			{
				p++;
				j2=j+i;
				tt=(s[j]-'a')*26+(s[j2]-'a');
				if (as[tt]<=ga)
				{
					as[tt]=p;
					if (ok[j]==0)
					{
						fir[tt]=j;
						ok[j]=1;
					}
				}
				else
				{
					if (fir[tt])
					{
						ok[fir[tt]]=0;
						fir[tt]=0;
					}
				}
			}
			for (j=0 ; j<=25 ; j++)
			{
				temple[j]=0;
			}
			for (j=1 ; j<=lens ; j++)
			{
				if (ok[j])
				{
					temple[s[j]-'a']++;
					ok[j]=0;
				}
			}
			for (j=0 ; j<=25 ; j++)
			{
				le[j]=max(le[j],temple[j]);
			}
		}
		ans=0;
		for (i=0 ; i<=25 ; i++)
		{
			ans+=le[i];
		}
		anss=((double)ans)/lens;
		printf("%.9f\n" ,anss);
	}

	return 0;
}


#include <cstdio>
#include <vector>
using namespace std;
char s[10010];
vector<int> v[26];
int f[5010][26];
int main() {
	scanf("%s", s);
	int l;
	for (l = 0; s[l]; l++) ;
	for (int i = 0; i < l; i++) {
		s[i] -= 'a';
		v[s[i]].push_back(i);
		s[i+l] = s[i];
	}
	double ans = 0;
	for (int i = 0; i < 26; i++) {
		if (!v[i].size()) continue;
		for (int j = 0; j < v[i].size(); j++) {
			int st = v[i][j];
			for (int k = 1; k < l; k++) {
				int p = s[st+k];
				f[k][p]++;
			}
		}
		int mx = 0;
		for (int k = 1; k < l; k++) {
			int w = 0;
			for (int j = 0; j < 26; j++) {
				if (f[k][j] == 1) {
					w++;
				}
			}
			if (mx < w) {
				mx = w;
			}
		}
		ans += mx;
		for (int j = 0; j < v[i].size(); j++) {
			int st = v[i][j];
			for (int k = 1; k < l; k++) {
				int p = s[st+k];
				f[k][p]--;
			}
		}
	}
	printf("%.12f\n", ans / l);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int cnt[26][26][5003];
char str[5003];
int ans, n;

int main() {
	gets(str);
	n = strlen(str);
	for (int i = 0; i < n; i++) {
		for (int j = i+1; j < i+n; j++) {
			cnt[str[i] - 97][str[j % n] - 97][j - i + 1]++;
		}
	}
	for (int i = 0; i < 26; i++) {
		int b = 0;
		for (int j = 1; j <= n; j++) {
			int t = 0;
			for (int k = 0; k < 26; k++) {
				t += (cnt[i][k][j] == 1);
			}
			b = max(b, t);
		}
		ans += b;
	}
	printf("%.14f", 1.*ans/n);
	return 0;
}


#include<cmath>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
double Ans;
int a[100005],map[27][5005][27],num[5005],p[27][5005],n;
char ch;
int main()
{
    while(ch=getchar(),ch<='z'&&ch>='a')
        a[++n]=ch-'a'+1;
    for(int i=1;i<=n;++i)
    {
        num[a[1]]++;
        for(int j=2;j<=n;++j)
        {
            map[a[1]][j][a[j]]++;
        }

        int t=a[1];
        for(int i=1;i<n;++i) a[i]=a[i+1];
        a[n]=t;
    }
    for(int i=1;i<=n;++i)
    {
        for(int j=2;j<=n;++j)
        {
            if(map[a[1]][j][a[j]]==1)
            {
                p[a[1]][j]++;
            }
        }

        int t=a[1];
        for(int i=1;i<n;++i) a[i]=a[i+1];
        a[n]=t;
    }
    for(int i=1;i<=26;++i)
    if(num[i])
    {
        int now=0;
        for(int j=2;j<=n;++j)
            now=max(now,p[i][j]);
        Ans+=(double)now;
    }
    printf("%.9lf",Ans/n);
    return 0;
}


//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("avx")
#include<bits/stdc++.h>
#define N 10050
using namespace std;

inline int read()
{
	int ret=0; char c=getchar();
	while(c<48||c>57)c=getchar();
	while(c>=48 && c<=57)ret=ret*10+c-48,c=getchar();
	return ret;
}

char s[N];
int u[27],ans,l,a[N],p[N],tot,fl,fl_;
int main()
{
	scanf("%s",s+1);
	l=strlen(s+1);
	for(int i=1; i<=l; ++i)a[i]=s[i]-'a'+1;
	for(int i=l+1; i<=l+l; ++i)a[i]=a[i-l];
	for(int o=1; o<=26; ++o)
	{
		tot=0;
		for(int i=1; i<=l; ++i)if(a[i]==o){
			p[++tot]=i;
		}
		if(tot<=1)
		{
		    ans+=tot;
		    continue;
		}
		fl=0;
		for(int j=2; j<=l; ++j)
		{
			fl_=0;
			memset(u,0,sizeof(u));
		    for(int i=1; i<=tot; ++i)
				++u[a[p[i]+j-1]];//=1; //
			for(int i=1; i<=26; ++i)if(u[i]==1)++fl_;//fl_++
			fl=max(fl,fl_);
		}
//		if(fl)
		ans+=fl;
	}
		//(int)  -4.9 -4.9  .0f
	printf("%.9lf",(double)ans/l);
}


#include <bits/stdc++.h>
using namespace std;

const int MAXN = 5000;

vector<int> pos_letra[26];
char sig_letra[MAXN + 2][MAXN + 2];

string s;
int n;

long double prob_letra(char c){
	long double ret = pos_letra[c - 'a'].size();
	ret /= (long double) n;
	return ret;
}

long double gano(char c){
	int idx = c - 'a';
	int tam = pos_letra[idx].size();
	long double mayor = 0, aux;
	for(int pasos = 1; pasos < n; pasos++){
		map<char, int> conjunto;
		int unicos = 0;
		for(int i = 0; i < tam; i++){
			char t = sig_letra[pos_letra[idx][i]][pasos];
			if(conjunto.find(t) == conjunto.end()){
				conjunto[t] = 1;
				unicos++;
			}else{
				if(conjunto[t] == 1) unicos--;
				conjunto[t]++;
			}
		}
		aux = (long double) unicos / (long double) tam;
		mayor = max(mayor, aux);
	}
	return mayor;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	cin >> s;
	n = s.size();
	for(int i = 0; i < n; i++){
		pos_letra[s[i] - 'a'].push_back(i);
		for(int j = 1; j < n; j++){
			sig_letra[i][j] = s[(i + j) % n];
		}
	}

	long double resp = 0, aux;
	for(char i = 'a'; i <= 'z'; i++){
		aux = gano(i);
		aux *= prob_letra(i);
		resp += aux;
	}
	cout << setprecision(9) << fixed;
	cout << resp << "\n";

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 5000 + 10;

int n;
char s[N];
vector< int > g[26];

int main() {
  scanf(" %s", s);
  n = strlen(s);
  for(int i = 0; i < n; ++i) g[s[i] - 'a'].push_back(i);
  double ans = 0;
  for(int i = 0; i < 26; ++i) {
    double cur = 0;
    for(int j = 0; j < n; ++j) {
      map< int, int > cnt;
      for(int k = 0; k < g[i].size(); ++k) cnt[s[(j + g[i][k]) % n] - 'a']++;
      double foo = 0;
      for(int k = 0; k < 26; ++k) foo += (cnt[k] == 1);
      cur = max(cur, foo);
    }
    ans += cur;
  }
  printf("%.10lf\n", ans / (double)n);
  return 0;
}


#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
using namespace std ;

int n ;
string a ;
vector < int > v[ 37 ] ;

int used[ 37 ] ;

void input ( ) {
    cin >> a ;
    n = a.size ( ) ;
}

void solve ( ) {
    int i , j , t ;
    for ( i = 0 ; i < n ; i ++ ) {
        v[ ( a[ i ] - 'a' ) ].push_back ( i ) ;
    }
    double ret = 0.0000 ;
    for ( t = 0 ; t < 26 ; t ++ ) {
        int sz = v[ t ].size ( ) ;
        if ( sz == 0 ) { continue ; }
        int mx = 0 ;
        for ( i = 1 ; i < n ; i ++ ) {
            for ( j = 0 ; j <= 26 ; j ++ ) {
                used[ j ] = 0 ;
            }
            for ( j = 0 ; j < sz ; j ++ ) {
                int id = ( v[ t ][ j ] + i ) ;
                if ( id >= n ) { id -= n ; }
                int ch = ( a[ id ] - 'a' ) ;
                used[ ch ] ++ ;
            }
            int cur = 0 ;
            for ( j = 0 ; j <= 26 ; j ++ ) {
                if ( used[ j ] == 1 ) { cur ++ ; }
            }
            if ( mx < cur ) { mx = cur ; }
        }
        ret += mx ;
    }
    ret /= n ;
    printf ( "%.12lf\n" , ret ) ;
}

int main ( ) {
    ios_base::sync_with_stdio ( false ) ;
    cin.tie ( NULL ) ;
    input ( ) ;
    solve ( ) ;
    return 0 ;
}


#include <bits/stdc++.h>
using namespace std;
const int p=1e4+7;
string a;
set<int> s;
vector<int> poz[30];
int up,ok,In[30],uz;
int P(char x){
    return (x-'a');
}
double best=0,rez=0;
int main()
{
    cin>>a;
    for(int i=0;i<a.length();i++){
        poz[P(a[i])].push_back(i);
    }
    for(int i=0;i<30;i++){
        if(poz[i].size()>0){
            best=0,uz=0;
            for(int k=0;k<a.length();k++){
                for(int j=0;j<poz[i].size();j++){
                    int y=(poz[i][j]+k)%a.length();
                    int x=P(a[y]);
                    In[x]++;
                }
                int cnt=0;
                for(int f=0;f<30;f++){
                    if(In[f]==1){
                        cnt++;
                    }
                    In[f]=0;
                }
                uz=max(cnt,uz);
            }
            double s=(double)uz/poz[i].size();
            double d=(double)poz[i].size()/a.length();
            rez+=s*d;
        }
    }
    printf("%.8lf",rez);
    return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int maxn = 5000+5;
char str[maxn*2];
int a[26][26][maxn];
int tot,n;

int main(){
    scanf("%s",str+1);
    n = strlen(str+1);
    for (int i=1; i<=n; i++) str[i+n] = str[i];
    memset(a,0,sizeof(a));
    for (int i=1; i<=n; i++)
        for (int j=i+1; j<i+n; j++) a[str[i]-'a'][str[j]-'a'][j-i+1]++;

    tot = 0;
    for (int i=0; i<26; i++) {
        int tmp = 0;
        for (int j=1; j<=n; j++) {
            int sum = 0;
            for (int k=0; k<26; k++) if (a[i][k][j]==1) sum++;
            tmp = max(sum,tmp);
        }
        tot += tmp;
    }
    printf("%.14f\n",double(tot)/n);
    return 0;
}


// author: lkx
// Problem:
// ID:
#include<bits/stdc++.h>
using namespace std;

#define pii pair<int,int>
#define fi first
#define se second
#define PB push_back
#define MP make_pair
#define PH push
#define ll long long

const int MOD=1e9+7;

string s;
int cnt[30][5050][30];
double res;

int main()
{
	cin>>s;
	for(int i=0;i<s.size();i++)
		for(int j=0;j<s.size();j++)
			cnt[s[i]-'a'][j][s[(i+j)%s.size()]-'a']++;
	for(int i=0;i<26;i++)
	{
		double mx=0;
		for(int j=0;j<s.size();j++)
		{
			double chk=0;
			for(int k=0;k<26;k++)
				if(cnt[i][j][k]==1)
					chk++;
			mx=max(mx,chk);
		}
		res+=1.0*mx/s.size();
	}
//	cout<<res;
	printf("%.8f\n",res);
}


#include<bits/stdc++.h>
using namespace std;

std::vector<int> a[26];

int main(){
    cin.sync_with_stdio(false);
    cin.tie(0);
	cout << setprecision(8) << fixed;
	string s;
	cin >> s;
	int n = s.length();
	long double ans = 0;
	for(int i = 0; i < n; i++){
		int x = s[i]-'a';
		a[x].push_back(i);
	}
	for(int i = 1; i < n; i++){
		long double temp = 0;
		for(int j = 0; j < 26; j++){
			long double p = a[j].size();
			int flag[26] = {0};
			for(int k = 0; k < a[j].size(); k++){
				int pos = a[j][k];
				pos = (pos+i)%n;
				flag[s[pos]-'a']++;
			}
			int count = 0;
			for(int i = 0; i < 26; i++){
				if(flag[i] == 1){
					count++;
				}
			}
			temp += (long double)count/n;
		}
		ans = max(temp, ans);
	}
	cout << ans << "\n";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

std::vector<int> a[26];

int main(){
	cout << setprecision(8) << fixed;
	string s;
	cin >> s;
	int n = s.length();
	for(int i = 0; i < n; i++){
		int x = s[i]-'a';
		a[x].push_back(i);
	}

	long double ans = 0;
	for(int j = 0; j < 26; j++){
		long double p = 0;
		for(int i = 0; i < n; i++){
			int flag[26] = {0};
			long double temp = 0;
			for(int k = 0; k < a[j].size(); k++){
				int pos = a[j][k];
				pos = (pos+i)%n;
				flag[s[pos]-'a']++;
			}
			int count = 0;
			for(int l = 0; l < 26; l++){
				if(flag[l] == 1){
					count++;
				}
			}
			temp += count;
			p = max(temp, p);
		}
		ans += p;
	}
	cout << ans/n << "\n";
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#define fo(i,a,b) for (i=a; i<=b; i++)
using namespace std;

const int N=5005;
int n, i, j, k, p, q, t, ans;
int lst[26], e[N][2];
int s[N*2], b[26], bz[26], bz2[26];
char ch[N];

void link(int x,int y)
{
	e[++t][0]=lst[x], e[t][1]=y, lst[x]=t;
}

int main()
{
	//freopen("b.in","r",stdin); freopen("b.out","w",stdout);

	scanf("%s",ch+1); n=strlen(ch+1);
	fo(i,1,n) s[i]=ch[i]-'a', s[n+i]=s[i], b[s[i]]++, link(s[i],i);
	fo(t,0,25)
	{
		memset(bz,0,sizeof(bz)); p=0;
		fo(i,1,n-1)
		{
			j=lst[t], q=0;
			while (j)
			{
				k=i+e[j][1], j=e[j][0];
				if (bz[s[k]]!=i) bz[s[k]]=i, q++; else
				{
					if (bz2[s[k]]!=i) bz2[s[k]]=i, q--;
				}
			}
			if (q>p) p=q;
		}
		ans+=p;
	}
	printf("%LF",(long double)ans/n);
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#define fo(i,a,b) for (i=a; i<=b; i++)
using namespace std;

const int N=5005;
int n, i, j, k, p, q, t, ans;
int lst[26], e[N][2];
int s[N*2], b[26], bz[26], bz2[26];
char ch[N];

void link(int x,int y)
{
	e[++t][0]=lst[x], e[t][1]=y, lst[x]=t;
}

int main()
{
	scanf("%s",ch+1); n=strlen(ch+1);
	fo(i,1,n) s[i]=ch[i]-'a', s[n+i]=s[i], b[s[i]]++, link(s[i],i);
	fo(t,0,25)
	{
		memset(bz,0,sizeof(bz)); p=0;
		fo(i,1,n-1)
		{
			j=lst[t], q=0;
			while (j)
			{
				k=i+e[j][1], j=e[j][0];
				if (bz[s[k]]!=i) bz[s[k]]=i, q++; else
				{
					if (bz2[s[k]]!=i) bz2[s[k]]=i, q--;
				}
			}
			if (q>p) p=q;
		}
		ans+=p;
	}
	printf("%lf",(double)ans/n);
}


#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#define MAXN 5050
using namespace std;
string s; int u, v, x, y;
int DP[26][MAXN][26];
int good[MAXN][MAXN]; bool flag;
int best[26][MAXN];
int b[MAXN];
int cnt[26];
double ans;
int main()
{
    cin>>s;
    for(int i=0; i<s.length(); i++)
    {
        for(int j=i+1; j<s.length(); j++)
        {
            if(i!=j)
            {
                u = s[i]-'a';
                v = s[j]-'a';
                x = (j-i+s.length())%s.length();
                y = (i-j+s.length())%s.length();
                DP[u][x][v]++;
                DP[v][y][u]++;
            }
        }
    }
    for(int i=0; i<s.length(); i++)
    {
        for(int j=0; j<s.length(); j++)
        {
            if(j!=i)
            {
                u = s[i]-'a';
                v = s[j]-'a';
                x = (j-i+s.length())%s.length();
                if(DP[u][x][v]<=1)
                {
                    good[i][j] = true;
                }
            }
        }
    }
    for(int i=0; i<s.length(); i++)
    {
        u = s[i]-'a';
        cnt[u]++;
        for(int j=0; j<s.length(); j++)
        {
            if(i!=j)
            {
                if(good[i][j])
                {
                    u = s[i]-'a';
                    x = (j-i+s.length())%s.length();
                    best[u][x]++;
                }
            }
        }
    }
    for(int i=0; i<26; i++)
    {
        for(int j=0; j<s.length(); j++)
        {
            b[i] = max(b[i], best[i][j]);
        }
        //cout<<b[i]<<endl;
        ans += ((double)(b[i]))/((double)(s.length()));
    }
    cout<<fixed<<setprecision(8)<<ans<<endl;
}


#include <bits/stdc++.h>
using namespace std;
vector<int> v[26];
int cnt[26];
int main() {
	#ifdef LOCAL
	freopen("a.in", "r", stdin);
	freopen("a.out", "w", stdout);
	#endif
	string s; cin >> s;
	int n = s.size();
	for (int i = 0; i < n; i++) {
		v[s[i] - 'a'].push_back(i);
	}
	int res = 0;
	int ID = 0;
	for (int i = 0; i < 26; i++) if (v[i].size() > 0) {
		if (v[i].size() == 1) {
			res++;
			continue;
		}
		int ma = 0;
		for (int j = 1; j < n; j++) {
			ID++;
			bool bad = false;
			memset(cnt, 0, sizeof(cnt));
			for (int k = 0; k < (int)v[i].size(); k++) {
				int let = s[(v[i][k] + j) % n] - 'a';
				cnt[let]++;
			}
			int ans = 0;
			for (int k = 0; k < 26; k++) {
				if (cnt[k] == 1) ans++;
			}
			ma = max(ma, ans);
			if (ma == v[i].size()) break;
		}
		res += ma;
	}
	//cout << res << " " << n << endl;
	printf("%.9f", 1.0 * res / n);
	return 0;
}


# include<cstdio>
# include<cstring>
# include<algorithm>
using namespace std;
const int N = 5e3 + 5;
char s[N][N];
int t[26][N][26],c[26];
int n;
int main()
{
	scanf("%s",s[1] + 1); n = strlen(s[1] + 1);
	for (int i = 2 ; i <= n ; ++i)
		for (int j = i ; j <= i + n - 1 ; ++j)
			if (j <= n ) s[i][j - i + 1] = s[1][j];
			else s[i][j - i + 1] = s[1][j - n];
	for (int i = 1 ; i <= n ; ++i)
	{
		int h = s[i][1] - 'a'; ++c[h];
		for (int j = 2 ; j <= n ; ++j) ++t[h][j][s[i][j] - 'a'];
	}
	int ans = 0;
	for (int i = 0 ; i < 26 ; ++i)
	{
		int cnt = 0;
		for (int j = 2 ; j <= n ; ++j)
		{
			int ret = 0;
			for (int k = 0 ; k < 26 ; ++k) if (t[i][j][k] == 1) ++ret;
			cnt = max(cnt,ret);
		}
		ans += cnt;
	}
	printf("%lf",(double)ans / (double)n);
	return 0;
}


#include <bits/stdc++.h>

#define x first

#define y second

#define eps 1e-9

#define pb push_back

#define inf 0x3f3f3f3f

#define mod 1000000007

#define sq(_) ((_)*(_))

#define cb(_) ((_)*(_)*(_))

#define bit(x, y) (((x)>>(y))&1)

#define bctz(x) (__builtin_ctz(x))

#define bclz(x) (__builtin_clz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define bclzl(x) (__builtin_clzll(x))

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef double DO;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

template<class T> inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T1, class T2> inline void gn(T1 &x1, T2 &x2) {gn(x1), gn(x2);}

template<class T1, class T2, class T3> inline void gn(T1 &x1, T2 &x2, T3 &x3) {gn(x1), gn(x2), gn(x3);}

template<class T1, class T2, class T3, class T4> inline void gn(T1 &x1, T2 &x2, T3 &x3, T4 &x4) {gn(x1), gn(x2), gn(x3), gn(x4);}

template<class T> inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

template<class T> inline void printsp(T x) {print(x); putchar(' ');}

template<class T> inline void println(T x) {print(x); putchar('\n');}

template<class T1, class T2> inline void print(T1 x1, T2 x2){printsp(x1), println(x2);}

template<class T1, class T2, class T3> inline void print(T1 x1, T2 x2, T3 x3){printsp(x1), printsp(x2), println(x3);}

template<class T1, class T2, class T3, class T4> inline void print(T1 x1, T2 x2, T3 x3, T4 x4){printsp(x1), printsp(x2), printsp(x3), println(x4);}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

#ifndef ONLINE_JUDGE

void debug() {cout << endl;}

template<typename T, typename... Args>void debug(T&& head, Args&&... tail) {cout << head << ' ';debug(tail...);}

#endif

#define NN 5010

#define MM 30

char s[NN<<1];

string ss[NN];

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	scanf("%s", s);

	int n=strlen(s);

	for(int i=0; i<n; i++) {

		s[n+i]=s[i];

	}

	int num=0;

	for(int k=1; k<n; k++) {

		for(int i=0; i<n; i++) {

			ss[i].clear();

			ss[i].pb(s[i]);

			ss[i].pb(s[i+k]);

		}

		int cnt=0;

		sort(ss, ss+n);

		for(int i=0, j=0; i<n; i=j) {

			for(j=i; j<n; j++) if(ss[i]!=ss[j]) {

				break;

			}

			if(j==i+1) cnt++;

		}

		smax(num, cnt);

	}

	printf("%.7lf\n", 1.*num/n);

}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define mod 1000000007

#define hmod 911382323

#define pb push_back

#define sq(x) ((x)*(x))

#define sz(a) ((int)a.size())

#define LEN(a) (a.length())

#define x first

#define y second

#define ls (u<<1)

#define rs (ls + 1)

#define mid (st + ed >> 1)

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define rands(n) (rand()%n+1)

#define rand0(n) (rands(n)-1)

#define Rands(n) ((INT)rand()*rand()%n+1)

#define Rand0(n) (Rands(n)-1)

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

#define rep(i, a, b) for(int i=a; i<b; i++)

#define eprintf(...) fprintf(stderr, __VA_ARGS__)

#define shit(a) (1 << (a))

#define all(a) ((a).begin(), (a).end())

#define rev(a) (power(a, mod-2, mod))

#define add_edge(u, v) {nxt[E]=head[u];to[E]=v;head[u]=E++;}

#define init_edge(n) {memset(head, -1, sizeof head);E=0;}

#define input_tree {int n;cin>>n;init_edge(n); for(int i=0, u, v; i<n-1; i++) {gn(u); gn(v); add_edge(u,v); add_edge(v,u);}}

#define ADD(u, v) {u+=v;u%=mod;}

using namespace std;

typedef long long INT;

typedef unsigned long long UINT;

typedef unsigned int uint;

typedef complex<double> Complex;

typedef double DO;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<INT, INT> PII;

typedef pair<pii, int> ppi;

typedef pair<int, pii> pip;

typedef pair<DO, DO> pdd;

typedef pair<int, DO> pid;

typedef pair<DO, int> pdi;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

template<class T>inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T>inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

template<class T, class T1>inline void gn(T &x, T1 &y) {gn(x); gn(y);}

template<class T, class T1, class T2>inline void gn(T &x, T1 &y, T2 &z) {gn(x); gn(y); gn(z);}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

inline uint myrand(int n) {

	uint u = rand()%n;

	int c = rand()%10;

	u ^= u << c;

	u^=(u<<7)&263692864;

	u^=(u<<15)&402273075;

	u%=n;

	return u;

}

#define NN 5050

char s[NN];

int flag[NN];

int vst[NN];

int val[NN][NN];

int cnt[NN];

vector<int> st[NN];

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

	int _time=clock();

#endif

	int n;

	scanf("%s", s+1);

	n = strlen(s+1);

	for(int i=n+1; i<=2*n; i++) s[i] = s[i-n];

	DO ans=0;

	for(int i=1; i<=n; i++) st[s[i]].pb(i);

	for(int i='a'; i<='z'; i++) {

		int mx=0;

		for(int k=1; k<n; k++) {

			int val=0;

			for(int j=0; j<sz(st[i]); j++) {

				vst[s[st[i][j]+k]]++;

			}

			for(int j='a'; j<='z'; j++) if(vst[j]==1) val++;

			smax(mx, val);

			for(int j='a'; j<='z'; j++) vst[j]=0;

		}

		if(sz(st[i])) ans += mx;//, cout <<mx<<endl;

//		cout << ans << endl;

	}

	printf("%.10lf\n", ans/n);

#ifndef ONLINE_JUDGE

	cerr<<"The running time is : " << (DO)(clock()-_time) / CLOCKS_PER_SEC<<endl;

#endif

	return 0;

}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define MOD 1000000007

#define pb push_back

#define sq(x) ((x)*(x))

#define x first

#define y second

#define eps 1e-9

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define sgn(x) (((x)>eps)-((x)<-eps))

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef long double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

template<class T>inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T, class T1>inline void gn(T &x, T1 &y) {gn(x); gn(y);}

template<class T, class T1, class T2>inline void gn(T &x, T1 &y, T2 &z) {gn(x); gn(y); gn(z);}

template<class T>inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

template<class T>inline void printsp(T x) {print(x); putchar(' ');}

template<class T>inline void println(T x) {print(x); putchar('\n');}

template<class T, class U>inline void print(T x, U y) {printsp(x); println(y);}

template<class T, class U, class V>inline void print(T x, U y, V z) {printsp(x); printsp(y); println(z);}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

#define NN 101010

char s[NN];

VI a[26];

int flag, vst[26];

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	scanf("%s", s);

	int n=strlen(s);

	for (int i=0; i<n; i++) a[s[i]-'a'].pb(i);

	for (int i=0; i<n; i++) s[i+n]=s[i];

	double ans, m=0;

	for (int i=0; i<26; i++) if (a[i].size()) {

		int c=0;

		for (int r=0; r<n; r++) {

			for (int j=0; j<26; j++) vst[j]=0;

			for (int j=0; j<a[i].size(); j++) vst[s[a[i][j]+r]-'a']++;

			int ok=0;

			for (int j=0; j<26; j++) if (vst[j]==1) ok++;

			smax(c, ok);

		}

		ans+=c;

	}

	printf("%.15lf\n", (double)(ans/n));

	return 0;

}


#include <bits/stdc++.h>

#define x first

#define y second

#define eps 1e-9

#define pb push_back

#define inf 0x3f3f3f3f

#define mod 1000000007

#define sq(_) ((_)*(_))

#define cb(_) ((_)*(_)*(_))

#define bit(x, y) (((x)>>(y))&1)

#define bctz(x) (__builtin_ctz(x))

#define bclz(x) (__builtin_clz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define bclzl(x) (__builtin_clzll(x))

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef double DO;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

template<class T> inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T1, class T2> inline void gn(T1 &x1, T2 &x2) {gn(x1), gn(x2);}

template<class T1, class T2, class T3> inline void gn(T1 &x1, T2 &x2, T3 &x3) {gn(x1), gn(x2), gn(x3);}

template<class T1, class T2, class T3, class T4> inline void gn(T1 &x1, T2 &x2, T3 &x3, T4 &x4) {gn(x1), gn(x2), gn(x3), gn(x4);}

template<class T> inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

template<class T> inline void printsp(T x) {print(x); putchar(' ');}

template<class T> inline void println(T x) {print(x); putchar('\n');}

template<class T1, class T2> inline void print(T1 x1, T2 x2){printsp(x1), println(x2);}

template<class T1, class T2, class T3> inline void print(T1 x1, T2 x2, T3 x3){printsp(x1), printsp(x2), println(x3);}

template<class T1, class T2, class T3, class T4> inline void print(T1 x1, T2 x2, T3 x3, T4 x4){printsp(x1), printsp(x2), printsp(x3), println(x4);}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

#ifndef ONLINE_JUDGE

void debug() {cout << endl;}

template<typename T, typename... Args>void debug(T&& head, Args&&... tail) {cout << head << ' ';debug(tail...);}

#endif

#define NN 5010

char s[NN<<1];

string ss[NN];

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	scanf("%s", s);

	int n=strlen(s);

	for(int i=0; i<n; i++) s[n+i]=s[i];

	int num=0;

	for(int k=0; k<n; k++) {

		for(int i=0; i<n; i++) {

			ss[i].clear();

			ss[i].pb(s[i]);

			ss[i].pb(s[i+k]);

		}

		int cnt=0;

		sort(ss, ss+n);

		for(int i=0, j=0; i<n; i=j) {

			for(j=i+1; j<n and ss[i]==ss[j]; j++) ;

			if(j==i+1) cnt++;

		}

		smax(num, cnt);

	}

	printf("%.12lf\n", 1.*num/n);

}