stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

const int N=2e5+5;

char tmp[N];

pair<int,string> A[N];

map<string , int> idx;

map<string , int>mp;

map<int,vector<string> > rmp;

int main()

{

    int n,mx=-1;

    scanf("%d",&n);

    string s;

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

        scanf("%s",tmp);

        string s(tmp);

        mx = max(mx,++mp[s]);

        rmp[mp[s]].push_back(s);

    }

    sort(rmp[mx].begin(),rmp[mx].end());

    for(auto x:rmp[mx]){

        printf("%s\n",x.c_str());

    }



    return 0;

}


// Optimized solution to the same problem (faster):
#include<iostream>

#include<algorithm>

#include <bits/stdc++.h>

#include <map>

#define endl "\n"

using namespace std;





int main()

{

    map <string,int> poll;

    int i,n,maxi=0;

    string S;

    cin >> n;

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

    {

        cin >> S;

        poll[S]++;

    }

    map <string,int>:: iterator itr;

    for (itr=poll.begin();itr != poll.end();itr++)

    {

        if (itr->second > maxi)

        {

            maxi = itr->second;

        }

    }

    for (itr=poll.begin();itr != poll.end();itr++)

    {

        if (itr->second == maxi)

        {

            cout << itr->first << endl;

        }

    }





}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include "bits/stdc++.h"

using namespace std;

#define ll long long int

#define rep(i,n) for( int i = 0; i < n; i++ )

#define rrep(i,n) for( int i = n; i >= 0; i-- )

#define REP(i,s,t) for( int i = s; i <= t; i++ )

#define RREP(i,s,t) for( int i = s; i >= t; i-- )

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define INF 2000000000

#define mod 1000000007

#define INF2 1000000000000000000



string S[200010];

int main(void)

{

    cin.tie(0);

    ios::sync_with_stdio(false);

    int N; cin >> N;

    map<string, int> mp;

    rep(i, N) {

        cin >> S[i];

        mp[S[i]]++;

    }

    int cnt = 0;

    rep(i, N) {

        cnt = max(cnt, mp[S[i]]);

    }

    set<string> v;

    rep(i, N) if (mp[S[i]] == cnt) v.insert(S[i]);

    for(auto itr = v.begin(); itr != v.end(); itr++) {

        cout << *itr << endl;

    }



        



    return 0;

}


// Optimized solution to the same problem (faster):
#include <iostream>

#include <fstream>

#include <set>

#include <map>

#include <string>

#include <vector>

#include <queue>

#include <deque>

#include <stack>

#include <functional>

#include <algorithm>

#include <climits>

#include <cmath>

#include <iomanip>

using namespace std;

#define ll long long int

#define rep(i,n) for( int i = 0; i < n; i++ )

#define rrep(i,n) for( int i = n; i >= 0; i-- )

#define REP(i,s,t) for( int i = s; i <= t; i++ )

#define RREP(i,s,t) for( int i = s; i >= t; i-- )

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define INF 2000000000

#define mod 1000000007

#define INF2 1000000000000000000



map<string, int> mp;

int main(void)

{

    cin.tie(0);

    ios::sync_with_stdio(false);

    int N; cin >> N;

    rep(i, N) {

        string S; cin >> S;

        mp[S]++;

    }

    int len = 0;

    for(auto itr = mp.begin(); itr != mp.end(); itr++) {

        len = max(len, itr->second);

    }

    for(auto itr = mp.begin(); itr != mp.end(); itr++) {

        if(itr->second == len)

        cout << itr->first << endl;

    }

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cstdio>

#include<cmath>

#include<cstdlib>

#include<cstring>

#include<algorithm>

#define ll long long

using namespace std;



int T;

bool tag;

ll a,b,c,d,now,x,y;



int main(){

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

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

	int i;

	scanf("%d",&T);

	while (T--){

		scanf("%lld%lld%lld%lld",&a,&b,&c,&d);

		if (a<b){

			printf("No\n");

			continue;

		}

		now=a; tag=1;

		if (b>d){

			printf("No\n");

			continue;

		}

		if (b<=c){

			printf("Yes\n");

			continue;

		}

		if (b==d){

			if (now%b>c) printf("No\n");

			else printf("Yes\n");

			continue;

		}

		now=now%b;

		x=d%b;

		if (now>c){

			printf("No\n");

			continue;

		}

		if (x==0){

			printf("Yes\n");

			continue;

		}

		if (c==b-1){

			printf("Yes\n");

			continue;

		}

		for (i=1;i<=100000;i++){

			y=(b-1-now)/x;

			now=now+x*y;

			if (now>c){

				tag=0;

				break;

			}

			now=(now+x)%b;

		}

		if (tag) printf("Yes\n");

		else printf("No\n");

	}

	return 0;

}

// Optimized solution to the same problem (faster):
#include<iostream>

#include<cstdio>

#include<cmath>

#include<cstdlib>

#include<cstring>

#include<algorithm>

#define ll long long

using namespace std;



int T;

bool tag;

ll a,b,c,d,now,x,y,g;



ll gcd(ll a,ll b){

	if (!b) return a;

	else return gcd(b,a%b);

} 



int main(){

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

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

	int i;

	scanf("%d",&T);

	while (T--){

		scanf("%lld%lld%lld%lld",&a,&b,&c,&d);

		if (a<b){

			printf("No\n");

			continue;

		}

		now=a; tag=1;

		if (b>d){

			printf("No\n");

			continue;

		}

		if (b<=c){

			printf("Yes\n");

			continue;

		}

		if (b==d){

			if (now%b>c) printf("No\n");

			else printf("Yes\n");

			continue;

		}

		now=now%b;

		x=d%b;

		if (now>c){

			printf("No\n");

			continue;

		}

		if (x==0){

			printf("Yes\n");

			continue;

		}

		if (c==b-1){

			printf("Yes\n");

			continue;

		}

		g=gcd(x,b);

		if (b-g+now%g<=c) printf("Yes\n");

		else printf("No\n");

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>



using namespace std;



int main()

{

    int a,b,c,k,cont;

    cin>>a>>b>>c>>k;

    while(a>=b)

    {

        cont++;

        b=b*2;

    }

    while(b>=c)

    {

        cont++;

        c=c*2;

    }

    if(cont>k)

    {

        cout<<"No";

    }

    else

    {

        cout<<"Yes";

    }

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

int main(){

	int a,b,c,k,count=0;

	scanf("%d%d%d%d",&a,&b,&c,&k);

	while(a>=b){

		b=b*2;

		count++;

	}

	while(b>=c){

		c=c*2;

		count++;

	}

	if(count>k)

	printf("No");

	else

	printf("Yes");

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int main()

{

	int a,b,c,k,turn;

	scanf("%d%d%d%d",&a,&b,&c,&k);

	for(;;)

	{

		if(b<=a)

		{

			b*=2;

			turn++;

		}

		else

		{

			break;

		}

	}

	for(;;)

	{

		if(c<=b)

		{

			c*=2;

			turn++;

		}

		else

		{

			break;

		}

	}

	if(turn<=k)

	{

		printf("Yes");

	}

	else

	{

		printf("No");

	}

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

int main(){

	int a,b,c,k,count=0;

	scanf("%d%d%d%d",&a,&b,&c,&k);

	while(a>=b){

		b=b*2;

		count++;

	}

	while(b>=c){

		c=c*2;

		count++;

	}

	if(count>k)

	printf("No");

	else

	printf("Yes");

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <cstdio>

#include <cstdlib>

#include <algorithm>



using namespace std;



long long n;



bool check(long long a, long long b)

{

	return a % b == 0;

}



void work()

{

	for (long long i = 1; i <= 3500; i++)

	{

		for (long long j = i; j <= 3500; j++)

		{

			if (4*i*j-(i+j)*n <= 0) continue;

			if (check(i*j*n, 4*i*j-(i+j)*n))

			{

				printf("%I64d %I64d %I64d\n", i,j, (i*j*n)/(4*i*j-(i+j)*n));

				return;

			}

		}

	}

}



int main()

{

	scanf("%I64d", &n);

	work(); 

	return 0;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <math.h>

typedef long long ll;

int main()

{

	ll N;

	scanf("%lld",&N);

	int flag=0;

	for(ll h=1;h<=3500;h++)

	{

		if (flag) break;

		for(ll n=1;n<=3500;n++)

		{

			if(flag) break;

			if(N-4*n>0) continue;

				ll de=4*h*n-N*(h+n);

				ll bde=N*h*n;

				if(de<=0||bde<=0) continue;

				if(de>0&&bde>0&&bde%de==0)

				{

					printf("%lld %lld %lld\n",h,n,bde/de);

					flag=1; 

				} 

				

				

		}

		

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<stdio.h>

using namespace std;

long long N;

int main()

{

	while (scanf("%lld", &N) != EOF)

	{

		long long  h, n, t1, t2;

		bool flag = 0;

		for (h = 1; h <= 3500; h++) 

		{

			for (n = 1; n <= 3500; n++)

			{

				t1 = N*h*n;

				t2 = 4 * h*n - n*N - h*N;

				if (t1 > 0 && t2 > 0 && t1%t2 == 0)

				{

					printf("%lld %lld %lld\n", h, n, t1 / t2);

					flag = 1;

					break;

				}

			}

			if (flag)

				break;

		}

	}

	return 0;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <math.h>

typedef long long ll;

int main()

{

	ll N;

	scanf("%lld",&N);

	int flag=0;

	for(ll h=1;h<=3500;h++)

	{

		if (flag) break;

		for(ll n=1;n<=3500;n++)

		{

			if(flag) break;

			if(N-4*n>0) continue;

				ll de=4*h*n-N*(h+n);

				ll bde=N*h*n;

				if(de<=0||bde<=0) continue;

				if(de>0&&bde>0&&bde%de==0)

				{

					printf("%lld %lld %lld\n",h,n,bde/de);

					flag=1; 

				} 

				

				

		}

		

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

using namespace std;

int main()

{

	long long N, h, n, w;

	cin >> N;

	int flag = 0;

	for (h = 1; h <= 3500; h++)

	{

		for (n = 1; n <= 3500; n++)

		{

			if ((4 * h*n - N*h - N*n) > 0 && ((N*h*n) % (4 * h*n - N*h - N*n) == 0))

			{

				flag = 1;

				break;

			}

		}

		if (flag == 1)

		{

			cout << h << " " << n << " " << (N*h*n) / (4 * h*n - N*h - N*n) << endl;

			break;

		}

	}

	return 0;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <math.h>

typedef long long ll;

int main()

{

	ll N;

	scanf("%lld",&N);

	int flag=0;

	for(ll h=1;h<=3500;h++)

	{

		if (flag) break;

		for(ll n=1;n<=3500;n++)

		{

			if(flag) break;

			if(N-4*n>0) continue;

				ll de=4*h*n-N*(h+n);

				ll bde=N*h*n;

				if(de<=0||bde<=0) continue;

				if(de>0&&bde>0&&bde%de==0)

				{

					printf("%lld %lld %lld\n",h,n,bde/de);

					flag=1; 

				} 

				

				

		}

		

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
/*main*/

#include <iostream>

#include <stdio.h>

#include <cstdlib>

using namespace std;



typedef long long LL;

LL N,molecule,denominator;

int main()

{

    LL h,n,w;

    int flag = 0;

    scanf("%I64d",&N);

    for(h=1; h<=3500; h++)

    {

        for(n=1; n<=3500; n++)

        {

            molecule = 4*h*n - N*n - N*h;

            denominator = N*h*n;

            if(molecule>0 && denominator%molecule==0 && denominator/molecule<=3500)

            {

                w = denominator / molecule;

                printf("%I64d %I64d %I64d",h,n,w);

                flag = 1; break;

            }

        }

        if(flag) break;

    }

    return 0;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <math.h>

typedef long long ll;

int main()

{

	ll N;

	scanf("%lld",&N);

	int flag=0;

	for(ll h=1;h<=3500;h++)

	{

		if (flag) break;

		for(ll n=1;n<=3500;n++)

		{

			if(flag) break;

			if(N-4*n>0) continue;

				ll de=4*h*n-N*(h+n);

				ll bde=N*h*n;

				if(de<=0||bde<=0) continue;

				if(de>0&&bde>0&&bde%de==0)

				{

					printf("%lld %lld %lld\n",h,n,bde/de);

					flag=1; 

				} 

				

				

		}

		

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>//暴力？

using namespace std;



int main()

{

	long long N, h, n, w;

	long long up, down;

	while (cin >> N)

	{

		w = 0;

		for (h = 1; h <= 3500; h++)

		{

			for (n = 1; n <= 3500; n++)

			{

				up = 4 * h*n - N*h - N*n;

				down = N*h*n;

				if (up > 0 && down%up == 0 && down / up <= 3500)

				{

					w = down / up;

					cout << h << " " << n << " " << w << endl;

				}

				if (w != 0)

				{

					break;

				}

			}

			if (w != 0)

			{

				break;

			}

		}

	}

	return 0;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>



int main()

{

    long long N, n, h, w;

    scanf("%lld", &N);

    int flag = 0;

    for(n = 1; n <= 3500; n++)

    {

        for(h = 1; h <= 3500; h++)

        {

            long long u = N * n * h;

            long long d = 4 * h * n - N * h - N * n;

            if(d > 0 && u % d == 0)

            {

                w = u / d;

                flag = 1;

                break;

            }

        }

        if(flag)

            break;

    }

    printf("%lld %lld %lld\n", h, n, w);

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<stdio.h>

using namespace std;

long long N;

int main()

{

	while (scanf("%lld", &N) != EOF)

	{

		long long  h, n, t1, t2;

		bool flag = 0;

		for (h = 1; h <= 3500; h++) 

		{

			for (n = 1; n <= 3500; n++)

			{

				t1 = N*h*n;

				t2 = 4 * h*n - n*N - h*N;

				if (t1 > 0 && t2 > 0 && t1%t2 == 0)

				{

					printf("%lld %lld %lld\n", h, n, t1 / t2);

					flag = 1;

					break;

				}

			}

			if (flag)

				break;

		}

	}

	return 0;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>



int main()

{

    long long N, n, h, w;

    scanf("%lld", &N);

    int flag = 0;

    for(n = 1; n <= 3500; n++)

    {

        for(h = 1; h <= 3500; h++)

        {

            long long u = N * n * h;

            long long d = 4 * h * n - N * h - N * n;

            if(d > 0 && u % d == 0)

            {

                w = u / d;

                flag = 1;

                break;

            }

        }

        if(flag)

            break;

    }

    printf("%lld %lld %lld\n", h, n, w);

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int main()

{

	string s;

	cin>>s;

	for(int i=0;i<(int)s.length()-1;i++) if(s[i]=='A'&&s[i+1]=='C') return puts("Yes"),0;

	return puts("No"),0;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <string.h>

int main()

{

	char a[6];

	scanf("%s",a);

	if(strstr(a,"AC")) printf("Yes\n");

	else printf("No\n");

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

using namespace std;

char n;

int main()

{

	while(cin>>n)

	{

		if(n=='A')

		{

			cin>>n;

			if(n=='C')

			{

				cout<<"Yes"<<endl;

				return 0;

			}

		}

	}

	cout<<"No"<<endl;

	return 0;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <string.h>

int main()

{

	char a[6];

	scanf("%s",a);

	if(strstr(a,"AC")) printf("Yes\n");

	else printf("No\n");

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int main()

{   

    string s;

    cin >> s;

    for(int i = 0; s[i] != '\0'; i++)

    {

        if(s[i]=='A'&&s[i+1]=='C')

        {

            cout << "Yes" << endl;

            return 0;

        }

    }

    cout << "No" << endl;

    return 0;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <string.h>

int main()

{

	char a[6];

	scanf("%s",a);

	if(strstr(a,"AC")) printf("Yes\n");

	else printf("No\n");

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int main(){   

    string s;

    cin>>s;

    for(int i=0;s[i]!='\0';i++){

        if(s[i]=='A'&&s[i+1]=='C'){

            cout<<"Yes"<<endl;

            return 0;

        }

    }

    cout<<"No"<<endl;

    return 0;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <string.h>

int main()

{

	char a[6];

	scanf("%s",a);

	if(strstr(a,"AC")) printf("Yes\n");

	else printf("No\n");

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



int kmp[1000010];

char s1[1000010], s2[1000010];



int main() {

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

    s2[1] = 'A';

    s2[2] = 'C';

    int len1 = strlen( s1 + 1 );

    int len2 = strlen( s2 + 1 );

    for( int i = 2 ; i <= len2 ; i++ ) {

        int j = kmp[i-1];

        while ( j && s2[j+1] != s2[i] ) j = kmp[j];

        kmp[i] = j + ( s2[j+1] == s2[i] );

    }

    for( int i = 1 , j = 0 ; i <= len1 + 1 ; i++ ) {

        if ( j == len2 ){ printf("Yes\n"); return 0; }

        while ( j && s2[j+1] != s1[i] ) j = kmp[j];

        j += ( s2[j+1] == s1[i] );

    }

    printf("No\n");

    return 0;

}

// Optimized solution to the same problem (faster):
#include <cstdio>

int a;

char s[20];

int main ()

{

	scanf ("%s",s);

	for (a=0;s[a];a=s[a]=='A'&&s[a+1]=='C'?10:a+1) ;

	printf ("%s\n",a==10?"Yes":"No");

	return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<cstdio>

#include<iostream>

#include<cstring>

using namespace std;

char a[6];

int main(){

	cin>>a;

	for(int i=0;i<strlen(a);i++){

		if(a[i]=='A'&&a[i+1]=='C'){

			puts("Yes");

			return 0;

		}

	}

	puts("No");

	return 0;

}

// Optimized solution to the same problem (faster):
#include <cstdio>

int a;

char s[20];

int main ()

{

	scanf ("%s",s);

	for (a=0;s[a];a=s[a]=='A'&&s[a+1]=='C'?10:a+1) ;

	printf ("%s\n",a==10?"Yes":"No");

	return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

int main()

{

    char a[6];

    scanf("%s",a);

    if(strstr(a,"AC")) cout<<"Yes"<<endl;

    else cout<<"No"<<endl;

    return 0;}

// Optimized solution to the same problem (faster):
#include <cstdio>

int a;

char s[20];

int main ()

{

	scanf ("%s",s);

	for (a=0;s[a];a=s[a]=='A'&&s[a+1]=='C'?10:a+1) ;

	printf ("%s\n",a==10?"Yes":"No");

	return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



int main() {

	ios::sync_with_stdio(0);

	cin.tie(0); cout.tie(0);

	string s; cin >> s;

	for (int i = 0; i < s.length() - 1; i++) if (s[i] == 'A' && s[i + 1] == 'C') {

		cout << "Yes" << endl;

		return 0;

	}

	cout << "No" << endl;

	return 0;

}




// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cstring>



int main() {

	char str[1010];

	scanf("%s", str);

	puts(strstr(str, "AC") ? "Yes" : "No");

	return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include<string>

#include<map>

#include<queue>

using namespace std;

map<string, int> sop;string s;

bool check(int mid)

{

	for (int i =1; i <= s.size() - mid+1; i++) {

		string op = s.substr(i-1, mid);

		if (sop[op])

		{

			if (i - sop[op] >= mid)

				return true;

		}

		else

			sop[op] = i;

	}

	return false;

}

int main()

{

	int n;

	cin >> n;

	cin >> s;

	int l = 0, r = n / 2;

	while (l < r) {

		int mid =(l + r + 1)/2;

		if (check(mid))

			l = mid;

		else

			r = mid - 1;

	}

	cout << l << endl;

	return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<string.h>

#include<algorithm>

#include<queue>

using namespace std;

typedef struct pp

{   char x[50];

    int t,R;

}S;

S s[105];

bool cmp(int a,int b)

{   return a>b;

}

int main()

{   int i,j,T,n,maxn=0,k,s=0,q;

    int y[26]={0};

    char x[6000];

    scanf("%d",&n);

    scanf("%s",x);

    for(i=0;i<n-1;i++)

    {

        for(j=i+1;j<n;j++)

        {   if(x[i]==x[j]&&x[i-1]!=x[j-1])

            {   //if(j==2)printf("##\n");

                q=1;

                for(k=1;k<j-i;k++)

                {   if(x[i+k]==x[j+k])q++;

                    else break;

                }

                if(q>maxn&&j-i>=q)maxn=q;

                //if(j==2)printf("##%d\n",q);

            }

        }

    }

    printf("%d\n",maxn);

    return 0;

}




// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<cstdio>

#include<cstring>

#include<cmath>

#include<algorithm>

#include<iostream>

#include<set>

#include<queue>

#include<map>

using namespace std;

int n;

string str;

int check(int a)

{

	map<string, int> m;

	for (int i = 1; i <=n + 1 - a; i++)

	{

		string s = str.substr(i - 1, a);

		if (m[s])

		{

			if (i - m[s] >= a) return true;

		}

		else

			m[s] = i;

	}

	return false;

}



int main()

{

	cin >> n >> str;

	int l = 0,r = n / 2;

	while (l <= r)

	{

		int mid = l + r >> 1;

		if (check(mid)) l = mid+1;

		else  r = mid-1;

	}

	cout << r << endl;



}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<string.h>

#include<algorithm>

#include<queue>

using namespace std;

typedef struct pp

{   char x[50];

    int t,R;

}S;

S s[105];

bool cmp(int a,int b)

{   return a>b;

}

int main()

{   int i,j,T,n,maxn=0,k,s=0,q;

    int y[26]={0};

    char x[6000];

    scanf("%d",&n);

    scanf("%s",x);

    for(i=0;i<n-1;i++)

    {

        for(j=i+1;j<n;j++)

        {   if(x[i]==x[j]&&x[i-1]!=x[j-1])

            {   //if(j==2)printf("##\n");

                q=1;

                for(k=1;k<j-i;k++)

                {   if(x[i+k]==x[j+k])q++;

                    else break;

                }

                if(q>maxn&&j-i>=q)maxn=q;

                //if(j==2)printf("##%d\n",q);

            }

        }

    }

    printf("%d\n",maxn);

    return 0;

}




// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cmath>

#include<algorithm>

#include<queue>

using namespace std;

int a[5001][5001] = {0};

int main() 

{



	int n,i,j;

	string s;

	cin >> n;

	cin >> s;

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

		for (j = 0; j < n; j++)

		{

			if (i == j)

				continue;

			if (s[i]==s[j])

			{

				a[i + 1][j + 1] = a[i][j] + 1;

			}

		}

	int max = 0;

	for (i = 1; i <= n; i++)

		for (j = 1; j <= n; j++)

		{

			if (a[i][j] > max&&(i-a[i][j])>=j)

				max = a[i][j];

		}

	cout << max;

	return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<string.h>

#include<algorithm>

#include<queue>

using namespace std;

typedef struct pp

{   char x[50];

    int t,R;

}S;

S s[105];

bool cmp(int a,int b)

{   return a>b;

}

int main()

{   int i,j,T,n,maxn=0,k,s=0,q;

    int y[26]={0};

    char x[6000];

    scanf("%d",&n);

    scanf("%s",x);

    for(i=0;i<n-1;i++)

    {

        for(j=i+1;j<n;j++)

        {   if(x[i]==x[j]&&x[i-1]!=x[j-1])

            {   //if(j==2)printf("##\n");

                q=1;

                for(k=1;k<j-i;k++)

                {   if(x[i+k]==x[j+k])q++;

                    else break;

                }

                if(q>maxn&&j-i>=q)maxn=q;

                //if(j==2)printf("##%d\n",q);

            }

        }

    }

    printf("%d\n",maxn);

    return 0;

}




// Fastest known solution for this problem: