jiahuimbzuai/CoQuIR huggingface dataset:
//  [python]
import sys 
from collections import Counter

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
l = read().decode().split()
c = Counter(l)

max = c.most_common()[0][1]
ans = [i[0] for i in c.items() if i[1] >= max]

print('\n'.join(sorted(ans)))
//  [python]
n = int(input())
d = {}
for _ in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1
m = d[max(d)]
l=[]
for i in d:
    if d[i] == m:
        l.append(i)
for i in sorted(l):
    print(i)
//  [python]
n = int(input())
d = {}
for _ in range(N):
    S = input()
    if S in d:
        d[S] += 1
    else:
        d[S] = 1
m = d[max(d)]
l=[]
for i in d:
    if d[i] == m:
        l.append(i)
for i in sorted(l):
    print(i)
//  [python]
n = int(input())
s = list(input() for _ in range(n))
d = {}
for i in range(n):
    if s[i] in d:
        d[s[i]] += 1
    else:
        d[s[i]] = 1
m = d[max(d)]
for s in sorted(k for k in d if d[k] == m):
    print(s)
//  [java]
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Map;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) throws Exception {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			int n = Integer.parseInt(br.readLine());
			Map<String, Integer> map = new TreeMap<>();
			int max = 0;
			for (int i = 0; i < n; i++) {
				String s = br.readLine();
				int val = map.containsKey(s) ? map.get(s) + 1 : 1;
				map.put(s, val);
				max = Math.max(max, val);
			}
			PrintWriter out = new PrintWriter(System.out);
			for (String key : map.keySet()) {
				if (map.get(key) == max) {
					out.println(key);
				}
			}
			out.flush();
		}
	}
}
//  [java]
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) {
		FastScanner stdIn = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		int n = stdIn.nextInt();
		Map<String,Integer> map = new TreeMap<>();
		int max = 0;
		for(int i = 0; i < n; i++) {
			String s = stdIn.next();
			int val = map.containsKey(s)?map.get(s)+1:1;
			map.put(s,val);
			max = Math.max(max, val);
			
		}
		for(String s:map.keySet()) {
			if(map.get(s)==max) {
				out.println(s);
			}
		}
		out.flush();
	
	}

}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
//  [java]
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			int n = Integer.parseInt(br.readLine());
			Map<String, Integer> map = new TreeMap<>();
			int max = 0;
			for (int i = 0; i < n; i++) {
				String s = br.readLine();
				int val = map.containsKey(s) ? map.get(s) + 1 : 1;
				map.put(s, val);
				max = Math.max(max, val);
			}
			PrintWriter out = new PrintWriter(System.out);
			for (String key : map.keySet()) if (map.get(key) == max) out.println(key);
			out.flush();
		}
	}
}
//  [java]
import java.util.*;

public class Main {
    public static void main(String[] args) {
        HashMap<String, Integer> si = new HashMap<String, Integer>();

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        sc.nextLine();

        for (int i = 0; i < N; i++) {
            String s;
            s = sc.next();
            si.put(s,si.getOrDefault(s,0)+1);
        }


        Iterator it = si.entrySet().iterator();
        ArrayList arr = new ArrayList();
        int currentMax = 0;

        while(it.hasNext()) {
            Map.Entry<String,Integer> set = (Map.Entry<String, Integer>) it.next();

            if (set.getValue()>currentMax) {
                arr.clear();
                arr.add(set.getKey());
                currentMax = set.getValue();
            }

            else if (set.getValue()==currentMax) {
                arr.add(set.getKey());
            }

            else {

            }
        }

        for (int i = 0; i < arr.size(); i++) {
            System.out.println(arr.get(i));
        }
    }
}
//  [java]
import java.util.*;

public class Main {
    public static void main(String[] args) {
        HashMap<String, Integer> si = new HashMap<String, Integer>();

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        sc.nextLine();

        for (int i = 0; i < N; i++) {
            String s;
            s = sc.next();

            si.put(s,si.getOrDefault(s,0)+1);
        }


        Iterator it = si.entrySet().iterator();
        ArrayList arr = new ArrayList();
        int currentMax = 0;

        while(it.hasNext()) {
            Map.Entry<String,Integer> set = (Map.Entry<String, Integer>) it.next();

            if (set.getValue()>currentMax) {
                arr.clear();
                arr.add(set.getKey());
                currentMax = set.getValue();
            }

            else if (set.getValue()==currentMax) {
                System.out.println(set.getKey() + " added");
                arr.add(set.getKey());
            }

            else {

            }
        }

        System.out.println(arr.size());

        for (int i = 0; i < arr.size(); i++) {
            System.out.println(arr.get(i));
        }
    }
}
//  [java]
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        String[] str = new String[n];
        int[] count = new int[n];
        String[] ans = new String[n];
        int max = 0;
        
        for(int i=0; i<n; i++){
            str[i] = sc.next();
        }
        
        Arrays.sort(str);
        
         for(int i=0; i<n; i++){
            for(int j=0; j<n; j++){
                if(str[i].equals(str[j])){
                    count[i]++;
                }
            }
            if(max<count[i]){
                max = count[i];
            }
        }
        
        if(max==n){
            System.out.println(str[0]);
            return;
        }
        
        int a=0;
        for(int i=0; i<n; i++){
            if(max==count[i]){
                ans[i] = str[i];
                //System.out.println(ans[i]);
                a++;
            }
        }
        
        for(int i=1; i<a; i=i+max){
            System.out.println(ans[i+max]);
        }
   }
}
//  [cpp]
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline ll getint() {
	ll A = 0;
	int k = 10;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= 'a') A = (A << 5) + ct - '`', k--;
	else while ((ct = *ci++) >= 'a') A = (A << 5) + ct - '`', k--;
	A <<= k * 5;
	return A;
}

char D[2200010];
char *di = D;
void pakuri_sort(int N, ll A[]) {
	const int b = 9;
	ll tmp[200001];
	rep(k, 6) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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


	fread_unlocked(cn, 1, cm, stdin);
	int N = 0;
	while ((ct = *ci++) >= '0') N = N * 10 + ct - '0';

	ll S[200000];
	rep(i, N) S[i] = getint();
	pakuri_sort(N, S);
	int kazu = 0;
	int saidai = 1;
	ll mae = 0;
	rep(i, N) {
		if (S[i] != mae) {
			if (saidai < kazu) {
				saidai = kazu;
				di = D;
			}
			if (saidai == kazu) {
				ll s = S[i - 1];
				for (ll m = 45; s; s &= ~(31ll << m), m -= 5) {
					*di++ = (s >> m) + '`';
				}
				*di++ = '\n';
			}
			kazu = 1;
			mae = S[i];
		}
		else kazu++;
	}
	if (saidai < kazu) {
		saidai = kazu;
		di = D;
	}
	if (saidai == kazu) {
		ll s = S[N - 1];
		for (ll m = 45; s; s &= ~(31ll << m), m -= 5) {
			*di++ = (s >> m) + '`';
		}
		*di++ = '\n';
	}
	fwrite(D, 1, di - D, stdout);

	Would you please return 0;
}
//  [cpp]
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

char C[2200010];
char *ci = C, ct;
char D[2200010];
char *di = D;
void pakuri_sort(int N, ll A[], int ichi[]) {
	const int b = 8;
	ll tmp[200001];
	int tmp2[200001];
	rep(k, 6) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) {
			tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
			tmp2[kazu[A[i] >> k * b & ((1 << b) - 1)]] = ichi[i];
		}
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) {
			A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
			ichi[kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp2[i];
		}
	}
}

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

	fread(C, 1, 2200010, stdin);
	int N = 0;
	while ((ct = *ci++) >= '0') N = N * 10 + ct - '0';

	ll S[200000];
	int ichi[200001];
	rep(i, N) {
		ll s = 0;
		ichi[i] = ci - C;
		int k = 10;
		while ((ct = *ci++) >= 'a') {
			s = s * 27 + ct - '`';
			k--;
		}
		rep(i, k) s *= 27;
		S[i] = s;
	}
	pakuri_sort(N, S, ichi);
	int kazu = 0;
	int saidai = 0;
	ll mae = 0;
	rep(i, N) {
		if (S[i] != mae) {
			if (saidai < kazu) {
				saidai = kazu;
				di = D;
			}
			if (saidai == kazu) {
				char* tmp = C + ichi[i - 1];
				while (*tmp >= 'a')* di++ = *tmp++;
				*di++ = '\n';
			}
			kazu = 1;
			mae = S[i];
		}
		else kazu++;
	}
	if (saidai < kazu) {
		saidai = kazu;
		di = D;
	}
	if (saidai == kazu) {
		char* tmp = C + ichi[N - 1];
		while (*tmp >= 'a')* di++ = *tmp++;
		*di++ = '\n';
	}
	fwrite(D, 1, di - D, stdout);

	Would you please return 0;
}
//  [cpp]
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

char C[2200010];
char *ci = C, ct;
char D[2200010];
char *di = D;
void pakuri_sort(int N, ll A[], int ichi[]) {
	const int b = 8;
	ll tmp[200001];
	int tmp2[200001];
	rep(k, 6) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) {
			tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
			tmp2[kazu[A[i] >> k * b & ((1 << b) - 1)]] = ichi[i];
		}
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) {
			A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
			ichi[kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp2[i];
		}
	}
}

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

	fread(C, 1, 2200010, stdin);
	int N = 0;
	while ((ct = *ci++) >= '0') N = N * 10 + ct - '0';

	ll S[200000];
	int ichi[200001];
	rep(i, N) {
		ll s = 0;
		ichi[i] = ci - C;
		int k = 10;
		while ((ct = *ci++) >= 'a') {
			s = s * 27 + ct - '`';
			k--;
		}
		rep(i, k) s *= 27;
		S[i] = s;
	}
	pakuri_sort(N, S, ichi);
	int kazu = 0;
	int saidai = 0;
	ll mae = 0;
	rep(i, N) {
		if (S[i] != mae) {
			chmax(saidai, kazu);
			kazu = 1;
			mae = S[i];
		}
		else kazu++;
	}
	chmax(saidai, kazu);
	kazu = 0;
	mae = 0;
	
	rep(i, N) {
		if (S[i] != mae) {
			if (saidai == kazu) {
				char *tmp = C + ichi[i - 1];
				while (*tmp >= 'a') *di++ = *tmp++;
				*di++ = '\n';
			}
			kazu = 1;
			mae = S[i];
		}
		else kazu++;
	}
	if (saidai == kazu) {
		char* tmp = C + ichi[N - 1];
		while (*tmp >= 'a') *di++ = *tmp++;
		*di++ = '\n';
	}
	fwrite(D, 1, di - D, stdout);

	Would you please return 0;
}
//  [cpp]
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pint = pair<int, int>;

int main() {
	int N;
	cin >> N;

	vector<int> cnt;
	vector<string> ans;
	for (int i = 0; i < N; ++i) {
		string S;
		cin >> S;
		auto itr = find(ans.begin(), ans.end(), S);
		if (itr == ans.end()) {
			ans.push_back(S);
			cnt.push_back(1);
		}
		else {
			int index = distance(ans.begin(), itr);
			cnt[index]++;
		}
	}

	int maxCnt = 0;
	for (int i = 0; i < cnt.size(); ++i) {
		maxCnt = max(maxCnt, cnt[i]);
	}
	vector<string> finalans;
	for (int i = 0; i < cnt.size(); ++i) {
		if (cnt[i] == maxCnt) {
			finalans.push_back(ans[i]);
		}
	}

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

	for (int i = 0; i < finalans.size(); ++i) {
		cout << finalans[i] << endl;
	}

	return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t n,a,m;
  cin>>n;
  a=0;
  m=0;
  vector<string> vec(n);
  for(int64_t i=0;i<n;i++){
  cin>>vec.at(i);
  }
  sort(vec.begin(), vec.end());
  for(int64_t i=0;i<n-1;i++){
  if(vec.at(i)==vec.at(i+1)){a++;
                            m=max(m,a);}
    else{a=0;}
  }
  a=0;
  for(int64_t i=0;i<n-1;i++){
  if(vec.at(i)==vec.at(i+1)){a++;
                            if(m==a){cout<<vec.at(i)<<endl;};}
    else{a=0;}
  }
 }
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t n,a,m;
  cin>>n;
  a=0;
  m=0;
  vector<string> vec(n);
  for(int64_t i=0;i<n;i++){
  cin>>vec.at(i);
  }
  sort(vec.begin(), vec.end());
  for(int64_t i=0;i<n-1;i++){
  if(vec.at(i)==vec.at(i+1)){a++;
                            m=max(m,a);}
    else{a=0;}
  }
  for(int64_t i=0;i<n-1;i++){
  if(vec.at(i)==vec.at(i+1)){a++;
                            if(m==a){cout<<vec.at(i)<<endl;};}
    else{a=0;}
  }
 }
//  [c]
// ABC 155-C
// 2020.2.16 bal4u

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

typedef long long ll;

#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)

int in() {   // 非負整数の入力
	int n = 0;
	int c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

ll ins() { // 文字列の入力　スペース以下の文字で入力終了
    ll n = 0;
	int c = gc();
    int w = 10;
	do n = (n << 5) + (c - 'a'+1), --w;
    while ((c = gc()) > ' ');
    return n << 5*w;
}

void outs(ll s) {
    int c, i = 5*9;
    while (c = (s >> i) & 31) pc(c+'a'-1), i -= 5;
    pc('\n');
}

void Usort(ll *a, int n) {
	int i, k;
#define B 8
#define BMSK 255 // (1<<8)-1
	int t1[1 << B], t2[1 << B];

	ll *tmp = malloc(n * sizeof(ll));
	for (k = 0; k < 8; ++k) {  // for 64ビット
		memset(t1, 0, sizeof(t1)), memset(t2, 0, sizeof(t2));
		for (i = 0; i < n; ++i)	t1[(a[i] >> k*B) & BMSK]++;
		for (i = 0; i < BMSK; ++i) t1[i+1] += t1[i];
		i = n; while (i--) tmp[--t1[(a[i] >> k*B) & BMSK]] = a[i];
		k++;
		for (i = 0; i < n; ++i) t2[(tmp[i] >> k*B) & BMSK]++;
		for (i = 0; i < BMSK; ++i) t2[i+1] += t2[i];
		i = n; while (i--) a[--t2[(tmp[i] >> k*B) & BMSK]] = tmp[i];
	}
	free(tmp);
#undef B
}

#define MAX 200005
ll s[MAX]; int n[MAX];

int main()
{
	int i, j, k, N, ma;

    N = in();
	for (i = 0; i < N; ++i) s[i] = ins();
	Usort(s, N);

	j = 0, k = 1, ma = 1;
	for (i = 1; i <= N; ++i) {
		if (s[i] == s[j]) ++k;
		else {
			n[j] = k;
			if (k > ma) ma = k;
			j = i, k = 1;
		}
	}

	for (i = 0; i < N; ++i) {
		if (n[i] == ma) outs(s[i]);
	}
	return 0;
}
//  [c]
// ABC 155-C
// 2020.2.16 bal4u

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

typedef long long ll;

#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)

int in() {   // 非負整数の入力
	int n = 0;
	int c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

ll ins() { // 文字列の入力　スペース以下の文字で入力終了
    ll n = 0;
	int c = gc();
    int w = 10;
	do n = (n << 5) + (c - 'a'+1), --w;
    while ((c = gc()) > ' ');
    return n << 5*w;
}

void outs(ll s) {
    int c, i = 5*9;
    while (c = (s >> i) & 31) pc(c+'a'-1), i -= 5;
    pc('\n');
}

void Usort(ll *a, int n) {
	int i, k;
#define B 8
#define BMSK 255 // (1<<8)-1
	int t1[1 << B], t2[1 << B];

	ll *tmp = malloc(n * sizeof(ll));
	for (k = 0; k < 8; ++k) {  // for 64ビット
		memset(t1, 0, sizeof(t1)), memset(t2, 0, sizeof(t2));
		for (i = 0; i < n; ++i)	t1[(a[i] >> k*B) & BMSK]++;
		for (i = 0; i < BMSK; ++i) t1[i+1] += t1[i];
		i = n; while (i--) tmp[--t1[(a[i] >> k*B) & BMSK]] = a[i];
		k++;
		for (i = 0; i < n; ++i) t2[(tmp[i] >> k*B) & BMSK]++;
		for (i = 0; i < BMSK; ++i) t2[i+1] += t2[i];
		i = n; while (i--) a[--t2[(tmp[i] >> k*B) & BMSK]] = tmp[i];
	}
	free(tmp);
#undef B
}

#define MAX 200005
ll s[MAX]; int N;
ll ans[MAX]; int M;

int main()
{
	int i, k, ma;

    N = in();
	for (i = 0; i < N; ++i) s[i] = ins();
	Usort(s, N);

	M = 0, k = 1, ma = 0;
	for (i = 1; i <= N; ++i) {
		if (s[i] == s[i-1]) ++k;
		else {
			if (k > ma) M = 0, ma = k;
			if (k == ma) ans[M++] = s[i-1];
			k = 1;
		}
	}
//printf("M=%d\n", M);
	for (i = 0; i < M; ++i) outs(ans[i]);
	return 0;
}
//  [c]
// ABC 155-C
// 2020.2.16 bal4u

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

typedef long long ll;

#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)

int in() {   // 非負整数の入力
	int n = 0; int c;
	do c = gc();
	while (isspace(c));
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

ll ins() { // 文字列の入力　スペース以下の文字で入力終了
    ll n = 0;
	int c;
   	do c = gc();
	while (isspace(c));
    int w = 0;
	do n = (n << 5) + (c - 'a'+1), ++w;
    while ((c = gc()) > ' ');
    return n << 5*(10-w);
}

void outs(ll s) {
    int i;
    char a[20];
    i = 0; while (s) {
        if (s & 31) a[i++] = (s & 31) + 'a'-1;
        s >>= 5;
    }
    while (i--) pc(a[i]);
    pc('\n');
}

void Usort(ll *a, int n) {
	int i, k;
#define B 8
#define BMSK 255 // (1<<8)-1
	int t1[1 << B], t2[1 << B];

	ll *tmp = malloc(n * sizeof(ll));
	for (k = 0; k < 8; ++k) {  // for 64ビット
		memset(t1, 0, sizeof(t1)), memset(t2, 0, sizeof(t2));
		for (i = 0; i < n; ++i)	t1[(a[i] >> k*B) & BMSK]++;
		for (i = 0; i < BMSK; ++i) t1[i+1] += t1[i];
		i = n; while (i--) tmp[--t1[(a[i] >> k*B) & BMSK]] = a[i];
		k++;
		for (i = 0; i < n; ++i) t2[(tmp[i] >> k*B) & BMSK]++;
		for (i = 0; i < BMSK; ++i) t2[i+1] += t2[i];
		i = n; while (i--) a[--t2[(tmp[i] >> k*B) & BMSK]] = tmp[i];
	}
	free(tmp);
#undef B
}

#define MAX 200005
ll s[MAX]; int n[MAX];

int main()
{
	int i, j, k, N, ma;

    N = in();
	for (i = 0; i < N; ++i) s[i] = ins();
	Usort(s, N);

	j = 0, k = 1, ma = 0;
	for (i = 1; i < N; ++i) {
		if (s[i] == s[j]) ++k, n[i] = 0;
		else {
			n[j] = k;
			if (k > ma) ma = k;
			j = i, k = 1;
		}
	}
    n[j] = k;
    if (k > ma) ma = k;

	for (i = 0; i < N; ++i) {
		if (n[i] == ma) outs(s[i]);
	}
	return 0;
}
//  [c]
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef struct aa
{
    char* str;
    int num;
} ass;

int str_cmp(const void* a,const void* b){
    return strcmp((char*)a,(char*)b);
}

int main(void)
{
    int n=0,disit=0,max=0;
    char S[200000][11]={};
    ass map[200000];
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%s",S[i]);
    }
    qsort(S,n,sizeof(S[0]),str_cmp);

    map[0].str=S[0];
    for(int i=0;i<n;i++){
        if(strcmp(map[disit].str,S[i])==0){
            map[disit].num+=1;
        } else {
            disit+=1;
            map[disit].str=S[i];
            map[disit].num+=1;
        }
    }

    max=map[0].num;
    for(int i=0;i<=disit;i++){
        if(max<map[i].num){
            max=map[i].num;
        }
    }

    for(int i=0;i<=disit;i++){
        if(map[i].num==max){
            printf("%s\n",map[i].str);
        }
    }
    return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){

    char a[1<<18][11];
    int table[1<<18];
    int N,i, max=-1;

    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%s",a[i]);
        table[i] = 1;
    }

    qsort(a,N,sizeof(a[0]),strcmp);

    for(i=1;i<N;i++){
        if(strcmp(a[i],a[i-1])==0){
            table[i] += table[i-1];
        }
        if(max<table[i]){
            max = table[i];
        }
    }

    for(i=0;i<N;i++){
        if(table[i]==max){
            printf("%s",a[i]);
        }
    }

    return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){

    char a[300000][11];
    int table[300000];
    int N,i, max=-1;

    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%s",a[i]);
        table[i] = 1;
    }

    qsort(a,N,sizeof(a[0]),strcmp);

    for(i=1;i<N;i++){
        if(strcmp(a[i],a[i-1])==0){
            table[i] += table[i-1];
        }
        if(max<table[i]){
            max = table[i];
        }
    }

    for(i=0;i<N;i++){
        if(table[i]==max){
            printf("%s",a[i]);
        }
    }

    return 0;
}
//  [javascript]
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const S = arg.slice(1, N + 1).sort();
    
    let list = [];
    let streak = 0;
    let max = 0;
    
    for(let i=0; i<S.length; i++) {
        if(S[i] === S[parseInt(i) + 1]) {
            streak++;
        } else {
            streak = 0;
        }
        
        if(streak > max) {
            max = streak;
            list = [S[i]];
        } else if(streak === max) {
            list.push(S[i]);
        }
    }
    
    console.log(list.join("\n"));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
'use strict'

function main(inp) {
  inp = inp.trim().split('\n')
  const N = inp.shift()
  inp = inp.sort()
  
  let ans = []
  let num = 0
  let count = 0
  for (let i = 0; i < inp.length; i++) {
    count++;
    if ((i + 1 === N) || inp[i] !== inp[i+1]) {
      if (count === num) {
        ans.push(inp[i])
      } else if (count > num) {
        num = count
        ans = [inp[i]]
      }
      count = 0
    }
  }

  console.log(ans.join('\n'))
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
"use strict"
function Main(input) {
  input = input.trim().split('\n');
  const N = Number(input[0]);
  const S = input.slice(1, N+1);

  let arr = {};
  let max = 0;
  for(let i=0; i<N; i++){
    arr[S[i]] = arr[S[i]] ? arr[S[i]] + 1 : 1;
    if(arr[S[i]] > max) max = arr[S[i]];
  }

  let keys = Object.keys(arr);
  let ret = [];
  for(let i=0; i<N; i++){
    if(arr[keys[i]] === max) ret.push(keys[i]);
  }

  console.log(ret.sort().join('\n'));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(input) {
  input=input.split("\n");
  if(input[input.length-1]===''){
    input.pop();
  }
  const N=input[0]-0;
  var string=[input[1]];
  var times=[1];
  for(var j=2;j<input.length;j++){
    for(var i=0;i<string.length;i++){
      if(string[i]===input[j]){
        times[i]++;
        break;
      }
      if(i===string.length-1){
        times.push(1);
        string.push(input[j]);
      }
    }
  }
  var max=Math.max(...times);
  var ret=[];
  for(var i=0;i<string.length;i++){
    if(times[i]===max){
      ret.push(string[i]);
    }
  }
  ret.sort();
  console.log(ret.join("\n"));
    

}


//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    const N = nextInt()
    let dict = {}
    let max = 0
    while(hasNext()){
        let str = next()
        if(!dict[str]) dict[str] = 1
        else dict[str]++
        max = Math.max(max, dict[str])
    }
    let ans = []
    for(let key of Object.keys(dict)){
        if(dict[key] === max){
            ans.push(key)
        }
    }
    ans.sort()
    myout(ans)
}
Main()
//  [go]
package main

import (
	"bufio"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	iv, _ := strconv.Atoi(scanString())
	return iv
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 100001), 100001*100)
}

func main() {
	n := scanInt()
	xm := make(map[string]int, n)
	for i := 0; i < n; i++ {
		s := scanString()
		xm[s]++
	}

	type poll struct {
		s string
		c int
	}
	ps := make([]poll, 0, len(xm))
	for s, c := range xm {
		ps = append(ps, poll{s, c})
	}
	sort.Slice(ps, func(i, j int) bool { return ps[i].c > ps[j].c })

	ans := make([]string, 0, len(xm))
	pmx := ps[0]
	ans = append(ans, pmx.s)
	for _, p := range ps[1:] {
		if p.c != pmx.c {
			break
		}
		ans = append(ans, p.s)
	}
	sort.Strings(ans)

	var wr = bufio.NewWriter(os.Stdout)
	for _, s := range ans {
		wr.WriteString(s + "\n")
	}
	wr.Flush()
}
//  [go]
package main

import (
	"bufio"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	iv, _ := strconv.Atoi(readStr())
	return iv
}

func readStr() string {
	sc.Scan()
	return sc.Text()
}

type poll struct {
	s string
	c int
}
type polls []poll

func (p polls) Len() int           { return len(p) }
func (p polls) Swap(i, j int)      { p[i], p[j] = p[j], p[i] }
func (p polls) Less(i, j int) bool { return p[i].c > p[j].c }

func main() {
	n := readInt()
	m := make(map[string]int, n)
	for i := 0; i < n; i++ {
		s := readStr()
		m[s]++
	}

	ps := polls(make([]poll, 0, len(m)))
	for s, c := range m {
		ps = append(ps, poll{s, c})
	}
	sort.Sort(ps)

	ans := make([]string, 0, len(m))
	pmx := ps[0]
	ans = append(ans, pmx.s)
	for _, p := range ps[1:] {
		if p.c != pmx.c {
			break
		}
		ans = append(ans, p.s)
	}
	sort.Strings(ans)

	var wr = bufio.NewWriter(os.Stdout)
	for _, s := range ans {
		wr.WriteString(s + "\n")
	}
	wr.Flush()
}
//  [go]
package main
 
import (
	"bufio"
	"os"
	"sort"
	"strconv"
)
 
var sc = bufio.NewScanner(os.Stdin)
 
func scanInt() int {
	iv, _ := strconv.Atoi(scanString())
	return iv
}
 
func scanString() string {
	sc.Scan()
	return sc.Text()
}
 
func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 100001), 100001*100)
}

func calcmax(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func main() {
	var N int
	var S string
	N = scanInt()
	max := 0
	m := map[string]int {}
	for i := 0; i < N; i++ {
	    S = scanString()
		m[S] = m[S] + 1
		max = calcmax(max, m[S])
	}
	l := []string {}
	for k, v := range m {
		if v == max {
			l = append(l, k)
		}
	}
	sort.Slice(l, func(i, j int) bool { return l[i] < l[j] })
	var wr = bufio.NewWriter(os.Stdout)
	for _, v := range l {
		wr.WriteString(v + "\n")
	}
	wr.Flush()
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc = initScanner(os.Stdin)
	n := scanInt(sc)
	ss := scanStringSlice(sc, n)
	solve(ss)
}

func solve(ss []string) {
	sort.Strings(ss)

	m := make(map[string]bool)
	var uniq []string
	for _, ele := range ss {
		if !m[ele] {
			m[ele] = true
			uniq = append(uniq, ele)
		}
	}

	var max, cnt int
	sn := make([]int, len(uniq))
	for i, v := range uniq {
		cnt = 0
		for _, s := range ss {
			if v == s {
				cnt++
			}
		}

		sn[i] = cnt

		if max < cnt {
			max = cnt
		}
	}

	for i := 0; i < len(uniq); i++ {
		if sn[i] == max {
			fmt.Println(uniq[i])
		}
	}
}

/*
arr := [string]{"a", "b", "c", "a"}
uniq := [] string{}

for _, ele := range arr {
    if !m[ele] {
        m[ele] = true
        uniq = append(uniq, ele)
    }
}
*/

// --------------- BASE DEFINITIONS ---------------

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	return sc
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func scanIntSlice(sc *bufio.Scanner, n int) []int {
	is := make([]int, n)
	for i := 0; i < n; i++ {
		is[i] = scanInt(sc)
	}

	return is
}

func scanFloat64(sc *bufio.Scanner) float64 {
	sc.Scan()
	f, _ := strconv.ParseFloat(sc.Text(), 64)
	return f
}

func scanFloat64Slice(sc *bufio.Scanner, n int) []float64 {
	fs := make([]float64, n)
	for i := 0; i < n; i++ {
		fs[i] = scanFloat64(sc)
	}

	return fs
}

func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func scanStringSlice(sc *bufio.Scanner, n int) []string {
	ss := make([]string, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		ss[i] = sc.Text()
	}

	return ss
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}
//  [go]
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	s := map[string]int{}
	max := 1
	for i := 0; i < n; i++ {
		var tmp string
		fmt.Scan(&tmp)
		_, exists := s[tmp]
		if !exists {
			s[tmp] = 1
		} else {
			s[tmp]++
			if max < s[tmp] {
				max = s[tmp]
			}
		}
	}

	for k, v := range s {
		if v == max {
			fmt.Println(k)
		}
	}
}
//  [go]
package main

import (
    "fmt"
    "os"
    "bufio"
    "sort"
    "strconv"
    "math"
)

var (
    read = bufio.NewReader(os.Stdin)
    write = bufio.NewWriter(os.Stdout)
    sc = bufio.NewScanner(os.Stdin)
)

func main() {
    defer write.Flush()

    var n int
    fmt.Fscan(read, &n)

    s := make(map[string]int)

    sc.Split(bufio.ScanWords)
    max := 0
    for i := 0; i < n; i++ {
        str := nextStr()
        _, ok := s[str]
        if ok {
            s[str]++
        } else {
            s[str] = 1
        }
        if max < s[str] {
            max = s[str]
        }
    }

    var a []string
    for key := range s {
        a = append(a, key)
    }


    sort.Strings(a)

    for i := 0; i < len(a); i++ {
        if s[a[i]] == max {
            fmt.Printf("%s\n", a[i])
        }
    }

}



//===========================
//
// Library
//
//===========================

//====================
//  round(12.54, 0) -> 13.0
//  round(12.54, -1) -> 12.5
//====================

func round(num float64, digit uint) float64 {
    d := float64(digit)
    return float64(int(num * math.Pow(10, d) + 0.5)) / math.Pow(10, d)
}

func max(a, b int) int {
    return int(math.Max(float64(a), float64(b)));
}

func min(a, b int) int {
    return int(math.Min(float64(a), float64(b)));
}

func gcd(x, y int) int {
    if y == 0 {
        return x
    }

    return gcd(y, x%y)
}

//====================
//  var q Queue
//  q.Enqueue(n)
//  n := q.Dequeue()
//====================
type Queue struct {
    data []int
}

func (q *Queue) Enqueue(n int) {
    q.data = append(q.data, n)
}

func (q *Queue) Dequeue() int {
    tmp := q.data[0]
    q.data = q.data[1:]
    return tmp
}

// 数値を桁区切りのスライスにする
func digit(n int, list []int) []int {
   if n > 0 {
       return digit(n/10, append(list, n%10))
   }
   return list
}

func sortIntsRev(list []int) {
    sort.Sort(sort.Reverse(sort.IntSlice(list)))
}

func strReverse(s string) string {
    runes := []rune(s)
    for i := 0; i < len(s)/2; i++ {
        runes[i], runes[len(s)-1-i] = runes[len(s)-1-i], runes[i]
    }
    return string(runes)
}

func nextInt() int {
    sc.Scan()
    i, _ := strconv.Atoi(sc.Text())
    return i
}

func nextStr() string {
    sc.Scan()
    return sc.Text()
}
//  [ruby]
_,*A=*$<
A=A.tally
k=A.map{_2}.max
puts A.map{_2<k ?"":_1}.sort
//  [ruby]
input = readlines()

n = input.shift.chomp.to_i

list = {}
input.each do |l|
  s = l.chomp
  list[s] = 0 if list[s].nil?
  list[s] += 1
end

max = list.values.max

keys = []
list.each do |k, v|
  keys.push(k) if v == max
end

puts keys.sort.join("\n")
//  [ruby]
counts = {}
counts.default = 0
gets.to_i.times{|i|
    counts[gets.chomp] += 1
}
m = counts.values.max

ans = []
counts.each{|key, val|
    ans.push(key) if val == m
}

ans.sort.each{|it| puts it}
//  [ruby]
n=gets.to_i
s=Array.new(n,"")
n.times do |i|
    s[i]=gets.chomp
end

count=1
curr=Array.new(n,0)
s=s.sort
i=0
while i<n
    curr[i]=s.count(s[i])
    i+=curr[i]
end

n.times do |i|
    if curr[i]==curr.max
        puts s[i]
    end
end
//  [ruby]
n=gets.to_i
s=Array.new(n,"")
n.times do |i|
    s[i]=gets.chomp
end

count=1
curr=Array.new(n,0)
s=s.sort
(n-1).times do |i|
    if s[i+1]==s[i]
        count+=1
    else
        curr[i]=count
        count=1
    end
end
curr[n-1]=count

n.times do |i|
    if curr[i]==curr.max
        puts s[i]
    end
end
//  [ruby]
N = gets.to_i
h = Hash.new(0)

(0..N-1).each { |i|
  s = gets.chomp
  h[s.to_sym] += 1
}

h.sort.each { |k, v| puts k if v == h.values.max }
//  [rust]
#[test]
fn test_solve() {
    assert_eq!(solve("7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n"), "beet\nvet\n");
    assert_eq!(solve("8\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\n"), "buffalo\n");
    assert_eq!(solve("7\nbass\nbass\nkick\nkick\nbass\nkick\nkick\n"), "kick\n");
    assert_eq!(solve("4\nushi\ntapu\nnichia\nkun\n"), "kun\nnichia\ntapu\nushi\n");
}

fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let n: usize = sc.read();
    let mut s: Vec<Vec<char>> = (0..n).map(|_| sc.chars()).collect();

    s.sort();

    let mut mct = 0;
    let mut cnt = 1;
    for i in 0..n-1 {
        if s[i] == s[i+1] {
            cnt += 1;
        } else {
            cnt = 1;
        }
        if cnt > mct {
            mct = cnt;
        }
    }

    let mut ret = String::new();
    use std::fmt::Write;

    cnt = 1;
    if cnt == mct {
        for &c in &s[0] {
            write!(&mut ret, "{}", c).unwrap();
        }
        writeln!(&mut ret, "").unwrap();
    }
    for i in 0..n-1 {
        if s[i] == s[i+1] {
            cnt += 1;
        } else {
            cnt = 1;
        }
        if cnt == mct {
            for &c in &s[i+1] {
                write!(&mut ret, "{}", c).unwrap();
            }
            writeln!(&mut ret, "").unwrap();
        }
    }

    ret
}

fn main() {
    let mut buf = String::new();
    use std::io;
    use std::io::{Read, Write};
    io::stdin().read_to_string(&mut buf).unwrap();
    io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}

struct Scanner<'a>(std::str::SplitWhitespace<'a>);
impl<'a> Scanner<'a> {
    fn from_str(src: &str) -> Scanner {
        Scanner(src.split_whitespace())
    }
    fn get(&mut self) -> &str {
        self.0.next().unwrap()
    }
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.get().parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.get().chars().collect()
    }
}
//  [rust]
use std::io::Read;
use std::collections::HashMap;
use std::cmp::max;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();

    let mut map: HashMap<&str, usize> = HashMap::with_capacity(n);
    for _i in 0..n {
        *map.entry(iterator.next().unwrap()).or_insert(0) += 1;
    }

    let mut max_count: usize = 0;
    for (_, &v) in &map {
        max_count = max(max_count, v);
    }

    let filtered = map.into_iter()
        .filter(|&(_, v)| v == max_count)
        .collect::<HashMap<&str, usize>>();

    let mut keys = Vec::with_capacity(filtered.len());
    for &key in filtered.keys() {
        keys.push(key)
    }

    keys.sort();

    return keys.join("\n");
}

#[test]
fn test() {
    assert_eq!(
        solve(
            r"7
beat
vet
beet
bed
vet
bet
beet"
        ),
        "beet
vet"
    );
//    assert_eq!(
//        solve(
//            r""
//        ),
//        ""
//    );
//    assert_eq!(
//        solve(
//            r""
//        ),
//        ""
//    );
}
//  [rust]
use std::collections::BTreeMap;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let mut map = BTreeMap::new();
    for _ in 0..n {
        let x:String = read();
        *map.entry(x).or_insert(0) += 1;
    }
    let mut v = Vec::new();
    for (key, value) in map {
        v.push((value as usize, key));
    }
    v.sort();
    let c:usize = v.last().unwrap().0;
    let mut v:Vec<(usize, String)> = v.into_iter().filter(|&&x| x.0 == c).collect();
    for (num, s) in v {
        println!("{}", s);
    }
}
//  [rust]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::collections::HashMap;

fn main(){
    input!{
        n: u64,
        s:[String;n]
    }
    s.sort();
    let mut map = HashMap::new();
    let mut flug :bool = false;
    for i in s.iter(){
        let count = map.entry(i).or_insert(0);
        *count += 1;
    }
    let mut max:u64 = 0;
    map.sort_by(|a, b| a.0.cmp(&b.0));
    for i in 0..sc.len() {
        if max < sc[i].1 {max = sc[i].1;}
    }
    for i in 0..sc.len() {
        if max == sc[i].1 as u64 {
            println!("{}", sc[i].0);
        }
    }
}
//  [rust]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::iter::FromIterator;

fn main(){
    input!{
        n: u64,
        s:[String;n]
    }
    let mut sc:Vec<(String, u64)> = Vec::new();
    let mut flug :bool = false;
    for i in s.iter(){
        for j in 0..sc.len(){
            if i == &sc[j].0 {
                sc[j].1 += 1;
                flug = true;
                break;
            }
        }
        if ! flug {
            sc.push((i.to_string(), 1));
        }
        flug = false;
    }
    let mut max:u64 = 0;
    sc.sort_by(|a, b| a.0.cmp(&b.0));
    for i in 0..sc.len() {
        if max < sc[i].1 {max = sc[i].1;}
    }
    for i in 0..sc.len() {
        if max == sc[i].1 as u64 {
            println!("{}", sc[i].0);
        }
    }
}
//  [swift]
import Foundation

func main(){
    let counter = Int(readLine()!)!
    var aryStr = [String]()
    var aryInts = [Int]()
    
    for _ in 1...counter {
        aryStr.append(readLine()!)
        aryInts.append(1)
    }
    let ziped = zip(aryStr,aryInts)
    let dicUniq = Dictionary(ziped, uniquingKeysWith: +)
    let max = dicUniq.values.max()
    var ans = [String]()
    
    for dic in dicUniq {
        if dic.value == max {
            ans.append(dic.key)
        }
    }
    ans.sort() { $0 < $1 }
    for a in ans {
        print(a)
    }
}

main()
//  [swift]
import Foundation

let n = Int(readLine()!)!

var dic: [String] = []
for i in 0 ..< n {
    dic.append(readLine()!)
}

var w: [String: Int] = [:]

for i in 0 ..< n {
    if w[dic[i]] == nil {
        w[dic[i]] = 1
    } else {
        w[dic[i]]! += 1
    }
}

let sorted = w.sorted(by: <).sorted(){ $0.1 > $1.1 }
let max = sorted.first!.value
sorted.forEach {
    if $0.1 < max {
        return
    }
    print($0.0)
}
//  [swift]
import Foundation

func main(){
    let counter = Int(readLine()!)!
    var aryStr = [String]()
    var aryInts = [Int]()
    
    for _ in 1...counter {
        aryStr.append(readLine()!)
        aryInts.append(1)
    }
    let ziped = zip(aryStr,aryInts)
    let dicUniq = Dictionary(ziped, uniquingKeysWith: +)
    let max = dicUniq.values.max()
    var ans = [String]()
    
    for dic in dicUniq {
        print(dic)
        if dic.value == max {
            ans.append(dic.key)
        }
    }
    ans.sort() { $0 < $1 }
    for a in ans {
        print(a)
    }
}

main()
//  [swift]
import Foundation

let votesCount = Int(readLine()!)!
var ary = [String]()

var strCounter = [String:Int]()

for _ in 1...votesCount {
    ary.append(readLine()!)
}
for a in ary{
    strCounter[a, default:0] += 1
}

let _ = strCounter.sorted{$0.value > $1.value}
var max = 0
for str in strCounter{
    max = str.value
    if max >= str.value {
        print(str.key)
        break
    }
}
//  [swift]
import Foundation
 
let N = Int(readLine()!)!
var array = [String]()
var dictionary = [String: Int]()
var max = 0
for i in 0..<N {
  var key = readLine()!
  let value = dictionary[key] ?? 0
  dictionary[key] = value + 1
  if max < value + 1 {
    max = value + 1
  }
}
let answer = dictionary.filter { $0.1 == max }
array = answer.map { $0.0 }
array.forEach { print($0) }
//  [typescript]
const main = (input: string) => {
  const lines = input.trim().split("\n")
  const countMap = new Map()
  let maxCount = 0

  lines.slice(1).forEach(S => {
    if (!countMap.has(S)) {
      countMap.set(S, 1);
    } else {
      countMap.set(S, countMap.get(S) + 1)
    }
    maxCount = Math.max(countMap.get(S), maxCount)
  })

  const answer = Array.from(countMap).filter(entry => entry[1] === maxCount).map(entry => entry[0]).sort()

  console.log(answer.join("\n"))
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
const main = (input) => {
  const lines = input.trim().split("\n");
  const N = parseInt(lines[0]);
  const countMap = new Map();

  let maxCount = 0;
  lines.slice(1).forEach(S => {
    if (!countMap.has(S)) {
      countMap.set(S, 1);
    } else {
      countMap.set(S, countMap.get(S) + 1)
    }
    maxCount = Math.max(countMap.get(S), maxCount);
  });

  const answer = Array.from(countMap).filter(entry => entry[1] === maxCount).map(entry => entry[0]).sort();
  console.log(answer.join('\n'));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
process.stdin.resume();
process.stdin.setEncoding('utf8');

// 標準入力取込
var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});
process.stdin.on('end', function() {
    main(g_input.split(/\r?\n/));
});

// 解答
function main(inputs:Array<string>) : void {

    // 枚数
    let count: number = Number(inputs[0].split(' ')[0]);
    let strMap: {[key: string]: number} = {};

    // 文字列の格納&回数計算
    for (let i = 1; i <= count; i++) {

        if (inputs[i] in strMap) {

            strMap[inputs[i]] = strMap[inputs[i]] + 1;
        } else {
            strMap[inputs[i]] = 0;
        }
    }

    let max = 0;
    let strList: string[] = [];

    // 回数最大の文字列抽出
    for (let str in strMap) {

        if (strMap[str] > max) {

            strList = new Array();
            max = strMap[str];
        }

        if (strMap[str] == max) {

            strList.push(str);
        }
    }

    return console.log(strList.sort().join('\n'));
}