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

using namespace std;

#define BS 313

#define ull unsigned long long

#define rint register int

#define gc() getchar()

inline int read(int r=0,int s=0,int c=gc()){for(;c<48||c>57;s=c,c=gc());for(;c>=48&&c<=57;(r*=10)+=c-48,c=gc());return s^'-'?r:-r;}

ull H[605][605], R[605][605], B[605]; char S[605][605]; int n, Ans;

inline ull HH(int i, int l, int r){return H[i][r]-H[i][l-1]*B[r-l+1];}

inline ull HR(int j, int l, int r){return R[r][j]-R[l-1][j]*B[r-l+1];}

inline bool Check(int a, int b)

{

	for(rint i = 1, x = a, y = b; i <= n; i++, x = x%n+1, y = y%n+1)

		if(HH(x,y,y+n-1) != HR(y,x,x+n-1)) return false; return true;

}

int main()

{

	n = read(); for(rint i = 1, j; i <= n; i++) for(scanf("%s",S[i]+1), j = 1; j <= n; S[i+n][j] = S[i][j+n] = S[i+n][j+n] = S[i][j], j++);

	B[0] = 1; B[1] = BS; for(rint i = 2; i <= n<<1; B[i] = B[i-1]*BS, i++);

	for(rint i = 1, j; i <= n<<1; i++) for(j = 1; j <= n<<1; H[i][j] = H[i][j-1]*BS+S[i][j], j++);

	for(rint j = 1, i; j <= n<<1; j++) for(i = 1; i <= n<<1; R[i][j] = R[i-1][j]*BS+S[i][j], i++);

	for(rint A = 1, B; A <= n; A++) for(B = 1; B <= n; B++) Ans += Check(A,B); printf("%d\n",Ans); return 0;

}

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

#define r register

int n;

char ch[305][305];

#define loop(x) (x>=n?(x-n):x)

int main(){

	scanf("%d",&n);r int ans=0;

	for(r int i=0;i<n;i++)scanf("%s",ch[i]);

	for(r int i=0,f=1;i<n;i++,f=1){

		for(r int j=0;j<n&&f;j++)

			for(r int k=j+1;k<n&&f;k++)

				f=(ch[j][loop(k+i)]==ch[k][loop(j+i)]);

		ans+=n*f;

	}

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

}

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

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

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

#define dF(i,a,b) for(int i=(a);i>=(b);--i)

#define dF2(i,a,b) for(int i=(a);i>(b);--i)

#define dF3(i,a,b) for(int i=(a)-1;i>=(b);--i)

using namespace std;typedef long long ll;typedef double ld;int INF=0x3f3f3f3f;int INF2=0x7fffffff;ll LNF=0x3f3f3f3f3f3f3f3f;ll LNF2=0x7fffffffffffffff;



int n; char str[305];

int a[305][305],Ans;



int main(){

	scanf("%d",&n);

	F(i,1,n){

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

		F(j,1,n) a[i][j]=str[j];

	}

	F(k,1,n){

		int Ok=1;

		F(i,1,n) F(j,1,n){

			int I=(j-k-1+n)%n+1;

			int J=(i+k-1)%n+1;

			if(a[i][j]!=a[I][J]) Ok=0;

		}

		if(Ok) Ans+=n;

	} printf("%d",Ans);

	return 0;

}

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

#define r register

int n;

char ch[305][305];

#define loop(x) (x>=n?(x-n):x)

int main(){

	scanf("%d",&n);r int ans=0;

	for(r int i=0;i<n;i++)scanf("%s",ch[i]);

	for(r int i=0,f=1;i<n;i++,f=1){

		for(r int j=0;j<n&&f;j++)

			for(r int k=j+1;k<n&&f;k++)

				f=(ch[j][loop(k+i)]==ch[k][loop(j+i)]);

		ans+=n*f;

	}

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

}

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

#define F(i) for(int i=1;i<=n;++i)

int n; char str[305];

int a[305][305],Ans;

int main(){

	scanf("%d",&n);

	F(i){

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

		F(j) a[i][j]=str[j];

	}

	F(k){

		int Ok=1;

		F(i) F(j){

			int I=(j-k-1+n)%n+1;

			int J=(i+k-1)%n+1;

			if(a[i][j]!=a[I][J]) Ok=0;

		}

		if(Ok) Ans+=n;

	} printf("%d",Ans);

	return 0;

}

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

#define r register

int n;

char ch[305][305];

#define loop(x) (x>=n?(x-n):x)

int main(){

	scanf("%d",&n);r int ans=0;

	for(r int i=0;i<n;i++)scanf("%s",ch[i]);

	for(r int i=0,f=1;i<n;i++,f=1){

		for(r int j=0;j<n&&f;j++)

			for(r int k=j+1;k<n&&f;k++)

				f=(ch[j][loop(k+i)]==ch[k][loop(j+i)]);

		ans+=n*f;

	}

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

}

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

#include<cstdio>

using namespace std;

char s[305][305];

int n,ans=0,flag;

int main(){

	scanf("%d",&n);

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

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

		flag=1;

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

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

				if(s[i][(j+k)%n]!=s[j][(i+k)%n]){

					flag=0;

					break;

				}

			}

		}

		ans+=n*flag;

	}

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

	return 0;

}

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

#define r register

int n;

char ch[305][305];

#define loop(x) (x>=n?(x-n):x)

int main(){

	scanf("%d",&n);r int ans=0;

	for(r int i=0;i<n;i++)scanf("%s",ch[i]);

	for(r int i=0,f=1;i<n;i++,f=1){

		for(r int j=0;j<n&&f;j++)

			for(r int k=j+1;k<n&&f;k++)

				f=(ch[j][loop(k+i)]==ch[k][loop(j+i)]);

		ans+=n*f;

	}

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

}

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

#include <vector>

#include <string>

#include <algorithm>

#include <cstdio>

#include <cstring>

#include <cmath>

using namespace std;

using ll = long long;



char s[300][301];

char t[300][301];

int n;

int k = 0;



int f() {

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

    //    for (int j = 0; j < n; j++) {

    //        cout << s[i][j];

    //    }

    //    cout << endl;

    //}

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

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

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

                return 0;

            }

        }

    }

    return 1;

}



int main() {

    ios::sync_with_stdio(false);

    cin.tie(0);



    cin >> n;



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

        cin >> s[i];

    }



    int r = 0;

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

        memcpy(t, s, sizeof(s));

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

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

                int i1 = i - 1; if (i1 < 0) i1 += n;

                s[i][j] = t[i1][j];

            }

        }

        r += f() * n;

        k++;

    }



    cout << r << endl;



    return 0;

}

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

#include <vector>

#include <string>

#include <algorithm>

#include <map>

#include <cstdio>

#include <cstring>

#include <cmath>

using namespace std;

using ll = long long;



int main() {

    ios::sync_with_stdio(false);

    cin.tie(0);



    int n;

    cin >> n;



    char s[300][600];

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

        cin >> s[i];

        memcpy(&s[i][n], &s[i][0], n);

    }



    int r = 0;

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

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

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

                if (s[i][j + x] != s[j][i + x]) goto chigau;

            }

        }

        r++;

        continue;

    chigau:

        continue;

    }



    cout << r * n << endl;



    return 0;

}

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

using namespace std;



int n,b[2][100100],f[2][100100];

bool v[100100];



int dfs(int s, int now, int maxi, int num){

  v[now] = true;

  

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

    if(!v[b[i][now]]){

      if(maxi == f[i][now])num++;

      else if(maxi < f[i][now]){

	maxi = f[i][now];

	num = 1;

      }

      if(b[i][now] == s)return num;

      return dfs(s,b[i][now],maxi,num);

    }

  }

  if(maxi == f[1][s])return num+1;

  else if(maxi < f[1][s])return 1;

  else return num;

}



int main(){

  while(cin >> n,n){

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

      cin >> b[0][i] >> f[0][i] >> b[1][i] >> f[1][i];

      v[i] = false;

    }



    int ans = 1;

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

      if(!v[i]){

	v[i] = true;

	ans = (ans * dfs(i,b[0][i],f[0][i],1) ) % 10007;

      }

    }

    cout << ans << endl;

  }

}

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

using namespace std;



int n,b[2][100100],f[2][100100],maxi,num;

bool v[100100];



int dfs(int s, int now){

  v[now] = true;

  

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

    if(!v[b[i][now]]){

      if(maxi == f[i][now])num++;

      else if(maxi < f[i][now]){

	maxi = f[i][now];

	num = 1;

      }

      return dfs(s,b[i][now]);

    }

  }

  if(maxi == f[1][s])return num+1;

  else if(maxi < f[1][s])return 1;

  else return num;

}



int main(){

  while(scanf("%d",&n),n){

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

      scanf("%d%d%d%d",&b[0][i],&f[0][i],&b[1][i],&f[1][i]);

      v[i] = false;

    }



    int ans = 1;

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

      if(!v[i]){

	v[i] = true;

	maxi = f[0][i]; num = 1;

	ans = (ans * dfs(i,b[0][i]) ) % 10007;

      }

    }

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

  }

}

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

using namespace std;



typedef long long llt;



const int MaxN = 100000 + 5;



int N;

llt A[MaxN];

llt ans1, ans2;

deque <llt> que1, que2;



inline llt llAbs(llt x) {

    if (x < 0) return -x;

    return x;

}



int main() {

    scanf("%d", &N);

    for (int i = 1; i <= N; ++i) scanf("%lld", &A[i]);



    sort(A + 1, A + 1 + N);



    que1.push_back(A[1]);

    que2.push_back(A[N]);



    llt Max = A[N], Min = A[2];

    int Maxi = N, Mini = 2;

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

        llt F = que1.front(), L = que1.back();

        llt ValF = max(llAbs(F - Max), llAbs(F - Min)),

            ValL = max(llAbs(L - Max), llAbs(L - Min));

        if (ValF > ValL) {

            ans1 += ValF;

            // printf("ans1 += %lld\n", ValF);

            if (llAbs(F - Max) == ValF) que1.push_front(Max), Maxi--;

            else que1.push_front(Min), Mini++;

        } else {

            ans1 += ValL;

            // printf("ans1 += %lld\n", ValL);

            if (llAbs(L - Max) == ValL) que1.push_back(Max), Maxi--;

            else que1.push_back(Min), Mini++;

        }

        Max = A[Maxi]; Min = A[Mini];

    }



    Max = A[N - 1], Min = A[1];

    Maxi = N - 1, Mini = 1;

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

        llt F = que2.front(), L = que2.back();

        llt ValF = max(llAbs(F - Max), llAbs(F - Min)),

            ValL = max(llAbs(L - Max), llAbs(L - Min));

        if (ValF > ValL) {

            ans2 += ValF;

            // printf("ans2 += %lld\n", ValF);

            if (llAbs(F - Max) == ValF) que2.push_front(Max), Maxi--;

            else que2.push_front(Min), Mini++;

        } else {

            ans2 += ValL;

            // printf("ans2 += %lld\n", ValL);

            if (llAbs(L - Max) == ValL) que2.push_back(Max), Maxi--;

            else que2.push_back(Min), Mini++;

        }

        Max = A[Maxi]; Min = A[Mini];

    }



    cout << max(ans1, ans2) << endl;

    return 0;

}

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

#include <algorithm>



const int MaxN = 100000 + 5;



int N;

long long A[MaxN];



void init() {

  scanf("%d", &N);

  for (int i = 1; i <= N; ++i) {

    scanf("%lld", &A[i]);

  }

}



void solve() {

  std::sort(A + 1, A + 1 + N);



  if (N % 2 == 0) {

    long long ans = 0;

    for (int i = 1; i < N / 2; ++i) {

      ans -= 2 * A[i];

    }

    ans -= A[N / 2];

    ans += A[N / 2 + 1];

    for (int i = N / 2 + 2; i <= N; ++i) {

      ans += 2 * A[i];

    }



    printf("%lld\n", ans);

  } else {

    long long ans1 = 0, ans2 = 0;



    for (int i = 1; i <= N / 2 - 1; ++i) {

      ans1 -= 2 * A[i];

    }

    ans1 -= A[N / 2] + A[N / 2 + 1];

    for (int i = N / 2 + 2; i <= N; ++i) {

      ans1 += 2 * A[i];

    }



    for (int i = 1; i <= N / 2; ++i) {

      ans2 -= 2 * A[i];

    }

    ans2 += A[N / 2 + 1] + A[N / 2 + 2];

    for (int i = N / 2 + 3; i <= N; ++i) {

      ans2 += 2 * A[i];

    }



    printf("%lld\n", std::max(ans1, ans2));

  }

}



int main() {

  init();

  solve();

  return 0;

}

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



using namespace std;

typedef long long LL;

LL a[100005];

int main()

{

    int n;

    cin>>n;

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

    {

        cin>>a[i];

    }

    sort(a+1,a+1+n);

    LL ans=0;

    if(n%2==1)

    {

        int num=(n-1)/2;

        for(int i=n;i>=n-(n-1)/2+1;i--)

        {

            ans+=a[i]*2;

        }

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

        {

            ans-=a[i]*2;

        }

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

        {

            ans-=a[i];

        }

        LL sum=0;

        for(int i=1;i<=n/2;i++)

        {

            sum-=a[i]*2;

        }

        sum+=a[n/2+1]+a[n/2+2];

        for(int i=n/2+3;i<=n;i++)

        {

            sum+=a[i]*2;

        }

        if(sum>ans)

        {

            ans=sum;

        }

    }

    else

    {     

         for(int i=n;i>=n-(n-2)/2+1;i--)

         {

             ans+=a[i]*2;

         }

         ans+=a[n-(n-2)/2];

         ans-=a[n-(n-2)/2-1];

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

         {

             ans-=a[i]*2;

         }

    }

    cout<<ans<<endl;

}


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

#include<cstring>

#include<cmath>

#include<algorithm>

using namespace std;

const int maxn=1e5+100;

int a[maxn];

int main(){

	int n;

	while(~scanf("%d",&n)){

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

			scanf("%d",a+i);

		sort(a+1,a+n+1);

		long long ans=0;

		if(n<=3){

			if(n==2)

				ans=a[2]-a[1];

			else

				ans=max(a[2]+a[3]-2*a[1],2*a[3]-a[1]-a[2]);

			goto loop;

		}

		if(n&1){

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

				if(i==n/2+1)continue;

				else if(i<n/2+1){

					if(i==n/2)

						ans-=a[i];

					else

						ans-=a[i]*2;

				}

				else if(i>n/2+1){

					if(i==n/2+2)

						ans+=a[i];

					else

						ans+=a[i]*2;

				}

			}

			ans+=max(a[n/2+1]-a[n/2],a[n/2+2]-a[n/2+1]);

		}

		else{

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

				if(i<n/2)

					ans-=a[i]*2;

				else if(i>n/2+1)

					ans+=a[i]*2;			

			}

			ans+=a[n/2+1]-a[n/2];

		}

loop:	printf("%lld\n",ans);

	}

}

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

#include <cstdio>

#include <cmath>

#include <cstring>

#include <algorithm>



using namespace std;



const int N = 200010;



void QuickSort(char s[][11], int l, int h)

{

    int i = l;

    int j = h;

    char t[11],d[11];

    strcpy(t,s[(l+h)/2]);

        while (i <= j)

        {

            while(strcmp(s[j],t)>0)     

            j--;

            while(strcmp(s[i],t)<0)      

            i++;

            if(i<=j)

            {

                strcpy(d,s[i]);

                strcpy(s[i],s[j]);

                strcpy(s[j],d);

                i++;

                j--;

            }

        }    

        if(l<j) QuickSort(s, l, j);     

        if(i<h) QuickSort(s, i, h);    

    

}

int main()

{

	int i,j,n,a[N]={0},b=0,q=0;

	char s[N][11],t[11];

	scanf("%d",&n);

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

	scanf("%s",s[i]);

	QuickSort(s,0, n-1);

	

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

	{

		if(strcmp(s[j],s[j+1])==0)

		{

			a[j-b]++;

			b=a[j-b];

		}

		else

		{

			if(a[j-b]>q)

			q=a[j-b];

			b=0;

		}

	}

	

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

	{

		if(a[i]==q)

		printf("%s\n",s[i]);

	}



return 0;

}

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

using namespace std;



typedef long long ll;



int main(void)

{

    //freopen("input.txt", "r", stdin);



    int i, n;

    cin >> n;

    string a;

    map <string, int> m;

    vector <string> v;



    int cnt = 1;

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

    {

        cin >> a;



        auto it = m.find(a);

        if(it != m.end())

        {

            m[a]++;

            if(m[a] > cnt)

                cnt = m[a];

        }

        else

        {

            m.insert(make_pair(a, 1));

        }

    }



    for(auto it = m.begin(); it != m.end(); it++)

    {

        if(it->second == cnt)

            cout << it->first << "\n";

    }



    return 0;

}


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

#include <string>

#include <set>

#include <map>

using namespace std;



map<string, int> M;

set<string> ans;

string s[222222];



int main(void)

{

	cin.tie(NULL);

	cout.tie(NULL);

	ios::sync_with_stdio(false);



	int n, i;



	cin >> n;

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

	{

		cin >> s[i];

		M[s[i]]++;

	}



	int maxi = -1;

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

		if (maxi < M[s[i]])

			maxi = M[s[i]];



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

		if (maxi == M[s[i]])

			ans.insert(s[i]);



	set<string>::iterator it;

	for (it = ans.begin(); it != ans.end(); ++it)

		cout << *it << endl;

	return 0;

}

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

#include <string>

#include <set>

#include <map>

using namespace std;



map<string, int> M;

set<string> ans;

string s;



int main(void)

{

	cin.tie(NULL);

	cout.tie(NULL);

	ios::sync_with_stdio(false);



	int n, i, maxi = 0;



	cin >> n;

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

	{

		cin >> s;

		M[s]++;

        maxi = max(maxi, M[s]);

	}



	for (auto p : M)

        if (p.second == maxi)

			cout << p.first << '\n';

	return 0;

}

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



#define ll long long

#define fornum(A,B,C) for(A=B;A<C;++A)

#define pii pair<int,int>

#define pll pair<ll,ll>



using namespace std;



/////////////////////////////////////////////////////



ll N;

string S[202020];

ll i, j, k;

ll ans = 1;

int main(){

    scanf("%lld", &N);

    fornum(i,0,N){

        cin >> S[i];

    }

    sort(S, S + N);

    string s = S[0];

    j = 0;

    fornum(i,1,N+1){

        if(s!=S[i]){

            ans = max(ans,i - j);

            j = i;

            s = S[i];

        }

    }

    s = S[0];

    j = 0;

    fornum(i,1,N+1){

        if(s!=S[i]){

            if(ans==i-j){

                

                cout << s << endl;

            }

            j = i;

            s = S[i];

        }

    }



    return 0;

}

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



#define ll long long

#define fornum(A,B,C) for(A=B;A<C;++A)

#define pii pair<int,int>

#define pll pair<ll,ll>



using namespace std;



/////////////////////////////////////////////////////



ll N;

char S[202020][14];

pll s[202020];

ll i, j, k;

ll ans = 1;

int main(){

    scanf("%lld", &N);

    fornum(i,0,N){

        scanf("%s", S[i]);

        k = 0;

        fornum(j,0,10){

            k *= 30;

            if(S[i][j])

                k += S[i][j] - 'a' + 1;

        }

        s[i] = {k, i};

    }

    sort(s, s + N);

    j = 0;

    fornum(i,1,N+1){

        if(s[j].first!=s[i].first){

            ans = max(ans, i - j);

            j = i;

        }

    }



    j = 0;

    fornum(i,1,N+1){

        if(s[j].first!=s[i].first){

            if(i-j==ans){

                printf("%s\n", S[s[j].second]);

            }

            j = i;

        }

    }



    return 0;

}

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

#include<algorithm>

#include<stdio.h>

#include<cstdio>



#include<string>

#include<map>

#include<vector>

using namespace std;

map<string,int> mp;

vector<string> v;

vector<string> ans;

int main(){

	int n;

	cin>>n;

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

		string s;

		cin>>s;

		if(!mp[s]){

			v.push_back(s);

		}

		mp[s]++;

	}

	int MAX=0;

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

		if(mp[v[i]]>MAX){

			MAX=mp[v[i]];

		}

	}

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

		if(mp[v[i]]==MAX){

			ans.push_back(v[i]);

		}

	}

	sort(ans.begin(),ans.end());

	for(int i=0;i<ans.size();i++){

		cout<<ans[i]<<endl;

	}

	return 0;

}

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

#include <string.h>

#include <algorithm>

#define N 200002

using namespace std;





char s[N][11];

int a[N], c, p[N];



int cmp(int x, int y)

{

	return strcmp(s[x], s[y]) < 0;

}



int main() 

{

	int n, i, max = 0, j, pi, t;

				

	scanf("%d", &n);

	for(i = 0; i < n; i++) scanf("%s", s[i]), p[i] = i;

	sort(p, p + n, cmp);

	

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

		pi = p[i];

		for(j = i + 1; j < n && !strcmp(s[pi], s[p[j]]); j++);

		t = j - i;

		if(t > max){

			max = t;

			a[c = 0] = pi;

		}

		else if(t == max) a[++c] = pi;

	}

	for(i = 0; i <= c; i++){

		puts(s[a[i]]);

	}

			

	return 0;

}

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

#include<cstdlib>

#include<queue>

#include<set>

#include<vector>

#include<string>

#include<cmath>

#include<algorithm>

#include<stack>

#include<map>

#include<deque>

#include<cstdio>

#include<cstdio>

#include<time.h>

using namespace std;

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

#define pd(a,n) for(int i=0;i<n;i++)cout<<a[i]<<((i==n-1)?"\n":" ")

#define pdd(a,n,m)for(int i=0;i<m;i++)pd(a,m)

#define mp make_pair

#define pb push_back

#define ll __int64

#define __int64 long long

#define P pair<int,int>

#define PP pair<P,int>



int n;

string s[222222];

map<string,int> ta;



int main(){

  cin>>n;

  rep(i,n)cin>>s[i];

  rep(i,n)ta[s[i]]++;

  int ma=-1;



  rep(i,n){

    ma=max(ma,ta[s[i]]);

  }

  sort(s,s+n);

  rep(i,n){

    if(ma==ta[s[i]]){

      cout<<s[i]<<endl;

      i+=(ta[s[i]]-1);

    }

  }



  return 0;

}


// Optimized solution to the same problem (faster):
#include<algorithm>//sort,二分探索,など

#include<bitset>//固定長bit集合

#include<cmath>//pow,logなど

#include<complex>//複素数

#include<deque>//両端アクセスのキュー

#include<functional>//sortのgreater

#include<iomanip>//setprecision(浮動小数点の出力の誤差)

#include<iostream>//入出力

#include<map>//map(辞書)

#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)

#include<queue>//キュー

#include<set>//集合

#include<stack>//スタック

#include<string>//文字列

#include<utility>//pair

#include<list>

#include<vector>//可変長配列

using namespace std;

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

#define mp make_pair

#define pb push_back

#define ll __int64

#define __int64 long long

#define P pair<int,int>

#define PP pair<P,int>

#define F first

#define S second

int dx[8] = { 1,0,-1,0,1,-1,-1,1 };

int dy[8] = { 0,1,0,-1,1,1,-1,-1 };





int n;

map<string, int>ta;



int main() {

    cin >> n;

    rep(i, n) {

        string s;

        cin >> s;

        ta[s]++;

    }



    int cnt = -1;

    for (auto it = ta.begin(); it != ta.end(); it++) {

        cnt = max(cnt, (*it).second);

    }

    for (auto it = ta.begin(); it != ta.end(); it++) {



        if(cnt==(*it).second)

        cout << (*it).first << endl;



    }



    return 0;

}


// Fastest known solution for this problem: