Problem:
 Score: 300 points    Problem Statement  We have N voting papers. The i -th vote (1 \leq i \leq N) has the string S_i written on it.  Print all strings that are written on the most number of votes, in lexicographical order.      Constraints   1 \leq N \leq 2 \times 10^5  S_i  (1 \leq i \leq N) are strings consisting of lowercase English letters.  The length of S_i  (1 \leq i \leq N) is between 1 and 10 (inclusive).         Input  Input is given from Standard Input in the following format:  N  S_1  :  S_N       Output  Print all strings in question in lexicographical order.        Sample Input 1 7
beat
vet
beet
bed
vet
bet
beet      Sample Output 1 beet
vet  beet and vet are written on two sheets each, while beat , bed , and bet are written on one vote each. Thus, we should print the strings beet and vet .       Sample Input 2 8
buffalo
buffalo
buffalo
buffalo
buffalo
buffalo
buffalo
buffalo      Sample Output 2 buffalo       Sample Input 3 7
bass
bass
kick
kick
bass
kick
kick      Sample Output 3 kick       Sample Input 4 4
ushi
tapu
nichia
kun      Sample Output 4 kun
nichia
tapu
ushi

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
S = [input() for _ in range(N)]

cnt_s = Counter(S)
tmp = cnt_s.most_common()[0][1]
for key, val in sorted(cnt_s.most_common(), key=lambda x:x[0]):
		if val == tmp:
      			print(key)

Solution (Python):
n= int(input())
s = {}

for _ in range(n):
    t = input()
    s.setdefault(t, 1)
    s[t] += 1

ans = []
m = max(s.values())
for k, v in s.items():
    if v == m:
        ans.append(k)

for m in sorted(ans):
    print(m)

Solution (Python):
from collections import Counter

n = int(input())
l = list("")
for i in range(n):
    l.append(input())
c = Counter(l)
c = c.most_common()
max = c[0][1]
a = list("")
for i in range(len(c)):
    if c[i][1] == max:
        a.append(c[i][0])
    else:
        break
a.sort()
for i in range(len(a)):
    print(a[i])

Solution (Python):
import math
from functools import reduce
import itertools

def input1():
	return int(input())


def input2():
	return map(int,input().split())


def input_array():
	return list(map(int,input().split()))





N=input1()
S=[]
for _ in range(N):
	S.append(str(input()))

dic={}
results=[]
for s in S:
	if s not in dic:
		dic[s]=1
	else:
		dic[s]+=1
ans=10000010010


score_sorted = sorted(dic.items(), key=lambda x:x[1])

max_count=max(dic.values())
for x in score_sorted:
	if x[1]==max_count:
		results.append(x[0])
results.sort()
for i in results:
	print(i)

Solution (Python):
N=input()
n=int(N)

p=[]
for i in range(n):
    p.append(input())

ha = {}

for i in p :
    if (i not in ha.keys()) :
        ha[i] = 1
    else :
        ha[i] += 1

res = ha.items()

res = sorted(ha.items(), key = lambda x : x[1] , reverse = True )

i = 1
k = res[0][1]

while (i < len(res) and res[i][1] == k) :
    i += 1

res = res[ : i]

res.sort()
for i in res :
    print (i[0])

Solution (Python):
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

from collections import Counter

n = int(readline())
s = [input() for i in range(n)]
check = list(Counter(s).items())
check.sort(key=lambda x: (-x[1], x[0]))
max_a = check[0][1]
for k, v in check:
    if v != check[0][1]:
        break
    print(k)

Solution (Python):
import collections as c
 
n = int(input())
alist = [input() for i in range(n)]
 
clist = c.Counter(alist)
anlist = clist.most_common()
anslist = []
for i in range(0,len(anlist)):
    if anlist[0][1] == anlist[i][1]:
        anslist.append(anlist[i][0])
anslistt = sorted(anslist)
 
for i in (anslistt):
    print(i)

Solution (Python):
n=int(input())
s=[]
ha={}

for i in range (n):
    s.append(input())
    if (s[i] not in ha.keys()):
        ha[s[i]]=1
    else:
        ha[s[i]]=ha[s[i]]+1

ans=sorted(ha.items(),key=lambda x:x[1], reverse=True)

k=ans[0][1]
i=0
while (i< len(ans) and ans[i][1]==k):
    i+=1

ans=ans[:i]
ans.sort()
for ss in ans:
    print(ss[0])

Solution (Python):
import sys
from collections import Counter
from operator import itemgetter
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    S=[input()for _ in range(n)]
    s_cnt=Counter(S)
    s_list=sorted(list(s_cnt.items()),key=itemgetter(1),reverse=True)
    s_list=[s[0] for s in s_list if s[1]==s_list[0][1]]
    s_list.sort()
    for s in s_list:
        print(s)
if __name__=='__main__':
    main()

Solution (Python):
import sys
from collections import Counter
from operator import itemgetter
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    S=[input()for _ in range(n)]
    s_cnt=Counter(S)
    s_list=sorted(list(s_cnt.items()),key=itemgetter(1),reverse=True)
    s_list=[s[0] for s in s_list if s[1]==s_list[0][1]]
    s_list.sort()
    for s in s_list:
        print(s)
if __name__=='__main__':
    main()

Solution (Python):
N = int(input())

cnt = dict()
maxcnt = 0
for _ in range(N):
    s = input()
    if s not in cnt:
        cnt[s] = 1
    else:
        cnt[s] += 1
    maxcnt = max(maxcnt, cnt[s])

ans = [s for s, c in cnt.items() if c == maxcnt]
ans = sorted(ans)
for s in ans:
    print(s)

Solution (Python):
N=int(input())
d=dict()
A=[]
ma=0
for i in range(N):
  s=input()
  if s not in d:
    d[s]=0
  d[s]+=1
ma=max(d.values())
for i,j in sorted(d.items()):
  if j==ma:
    print(i)

Solution (Python):
from collections import OrderedDict
N=int(input())
d=dict()
A=[]
ma=0
for i in range(N):
  s=input()
  if s not in d:
    d[s]=0
  d[s]+=1
d=OrderedDict(sorted(d.items(), key=lambda x:x[1], reverse=True))
for i in d:
  if ma<=d[i]:
    ma=d[i]
  if ma!=d[i]:
    break
  A.append(i)
print(*sorted(A),sep="\n")

Solution (Python):
n = int(input())
strings = [input().strip() for i in range(n)]
counter = {}

for string in strings:
    counter[string] = counter.get(string, 0) + 1

res = sorted(list(counter.items()), key=lambda x: -x[1])

result2 = []

for string, count in res:
    if count == res[0][1]:
        result2.append(string)
    else:
        break
result2.sort()
print('\n'.join(result2))

Solution (Python):
n= int(input())
s= sorted([input() for i in range(n)])
s.append("END")
ans=[]
max=-1
past=s[0]
c=1
for i in range(1,n+1):
	if past==s[i]:
		c+=1
	else:
		if c>max:
			max=c
			ans=[]
			ans.append(s[i-1])
		elif c==max:
			ans.append(s[i-1])
		c=1
	past=s[i]
for i in range(len(ans)):
	print(ans[i])

Solution (Python):
from collections import Counter
N=int(input())
s_li=[]
for i in range(N):
    s=input()
    s_li.append(s)
c=Counter(s_li)
c=c.most_common()
tmp=c[0][1]
res=[]
for j in range(len(c)):
    if tmp>c[j][1]:
        break
    res.append(c[j][0])
res.sort()
for k in range(len(res)):
    print(res[k])

Solution (Python):
from collections import Counter
_, *s = open(0)
c = Counter(s).most_common()
print(*sorted(a*(b == c[0][1]) for a,b in c))

Solution (Python):


n = int(input())

string_dict = {}

for i in range(n):
    s = str(input())
    if s in string_dict.keys():
        string_dict[s] += 1
    else:
        string_dict[s] = 1

ans = []
ans_value = 0
for key, value in string_dict.items():
    if ans_value < value:
        ans = [key]
        ans_value = value
    elif ans_value == value:
        ans.append(key)

ans.sort()

for i in ans:
    print(i)

Solution (Python):
from collections import Counter

N=int(input())
S=[input() for _ in range(N)]
S=Counter(S)
count=S.most_common()
count.sort(key=lambda x:x[0])
count.sort(key=lambda x:x[1], reverse=True)

n=count[0][1]
for i in range(len(count)):
  if n==count[i][1]:
    print(count[i][0])
  else:
    break

Solution (Python):
N=int(input())
S = []
for i in range(N):
    S.append(input())

from collections import *

cnt = Counter(S).most_common()
ans = []
for a,b in cnt:
    if b == cnt[0][1]:
        ans.append(a)
for i in sorted(ans):
    print(i)

Solution (Python):
n = int(input())
s = []
for _ in range(n):
    s.append(input())

import collections

a = collections.Counter(s)
b = a.most_common()
c = len(b)

ans = [b[0][0]]
for i in range(c-1):
    if b[i][1] > b[i+1][1]:
        break
    else:
        ans.append(b[i+1][0])

ans.sort()

for i in ans:
    print(i)

Solution (Python):


n = int(input())
s = [input() for _ in range(n)]

d = {}
for i in s:
    if i in d.keys():
        d[i] += 1
    else:
        d[i] = 1 
ans = []
m = max(d.values())
for k, v in d.items():
    if v == m:
        ans.append(k)

for s in sorted(ans):
    print(s)

Solution (Python):
n=int(input())
x={}
for i in range(n):
    s=input()
    if s in x: x[s]+=1
    else :     x[s] =0
m=max(x[i] for i in x)
q=[]
for i in x:
    if x[i]==m: q.append(i)
print(*sorted(q),sep='\n')

Solution (Python):
n = int(input())
s = [input() for _ in range(n)]

dic={}
for i in range(n):
    if s[i] not in dic:
        dic[s[i]]=1
    else:
        dic[s[i]]+=1

largest=max(dic.values())
ans=list()

for key in dic.keys():
    if dic[key]==largest:
        ans.append(key)

ans.sort()
for answers in ans:
    print(answers)

Solution (Python):
n = int(input())
dic = {}
for i in range(n):
    s = input()
    if not s in dic.keys():
        dic[s]=1
    else:
        dic[s]+=1
maxv = max(dic.values())
ls = [i for i in dic if dic[i] == maxv]
for key in sorted(ls):
    print(key)

Solution (Python):
from collections import defaultdict

d = defaultdict(int)

n = int(input())
li = [input() for _ in range(n)]

for i in li:
    d[i] += 1
    
d = sorted(d.items(), key=lambda x:x[1], reverse=True)

ans = []

s = 0
for i in range(len(d)):
    if s == 0:
        s = d[i][1]
    
    if s == d[i][1]:
        ans.append(d[i][0])
    else:
        break
    
ans.sort()

for i in ans:
    print(i)

Solution (Python):
import operator
n = int(input())
arr=[]
for i in range(n):
    arr.append(input())
d={}
for i in arr:
    d[i]=0
for i in arr:
    d[i]+=1

val = sorted(d.values(),reverse=True)[0]

ans=[]
for i in d:
    if(d[i]==val):
        ans.append(i)

ans=sorted(ans)

for x in ans:
    print(x)

Solution (Python):
import os

def main():
        num = int(input())
        dict_list = {}
        for i in range(num):
                strings = input()
                if strings in dict_list.keys():
                        dict_list[strings] += 1
                else:
                        dict_list[strings] = 1 

        max_num = max(dict_list.values())
        result = []
        
        for k,v in dict_list.items():
                if v == max_num:
                        result.append(k)
        result.sort()
        for i in result:
                print(i)

if __name__ == "__main__":
        main()

Solution (Python):
from collections import Counter as cnt
n = int(input())
S = [input().replace('\n', '') for _ in range(n)]
S = cnt(S)
m = max(S.values())
S = sorted(S.items(), key=lambda x: x[0])
for s, i in S:
    if i==m: print(s)

Solution (Python):
n = int(input())

s = []
for i in range(n):
  s.append(input())
  
s.sort()
t =[]
count = 1
for i in range(1,n):
  if s[i-1] == s[i] and i != n-1:
    count+=1
  elif s[i-1] == s[i] and i == n-1:
    count += 1
    t.append([s[i-1],count])
  elif i == n-1:
    t.append([s[i-1],1])
    t.append([s[i],1])
    
  else:
    t.append([s[i-1],count])
    count = 1

t.sort(key=lambda x:x[1])
ma = t[len(t)-1][1]

for i in range(len(t)):
  if t[i][1] == ma:
    print(t[i][0])

Solution (Python):
N=int(input())

S=[input() for _ in range(N)]
S.sort()

label=1
l=1
out=[]
for i in range(N-1):
    if S[i]==S[i+1]:
        l+=1
    else:
        if label<l:
            out=[S[i]]
            label=l
        elif label==l:
            out.append(S[i])
        l=1
if label<l:
    out=[S[-1]]
elif label==l:
    out.append(S[-1])

for i in range(len(out)):
    print(out[i])

Solution (Python):
n = int(input())
dic = {}

max = 0
for i in range(n):
    string = input()
    dic.setdefault(string, 0)
    dic[string] = dic[string] + 1
    if(dic[string] > max):
        max = dic[string]

dic2 = sorted(dic.items())
for s ,val in dic2:
    if(val == max):
        print(s)

Solution (Python):
N = int(input())

S = {}
for i in range(N):
    a = input()
    if not a in S.keys():
        S[a] = 1
    else:
        S[a] += 1

maxv = max(S.values())
ans = []
for i, j in S.items():
    if j == maxv:
        ans.append(i)

ans = sorted(ans)
for i in ans:
    print(i)

Solution (Python):

n = int (input ())
s = []
ha = {}
for i in range (n) :
    s.append (input ())
    if (s[i] not in ha.keys()) :
        ha[s[i]] = 1
    else :
        ha[s[i]] += 1

ans = sorted (ha.items(), key=lambda x : x[1], reverse=True)

k = ans[0][1]
i = 0
while (i < len (ans) and ans[i][1] == k) :
    i += 1

ans = ans[ : i]
ans.sort()
for ss in ans :
    print (ss[0])

Solution (Python):
N = int(input())
S = [0]*N
for i in range(0,N):
    S[i] = input()

S = sorted(S)

words = [0]
word_num = 0
word_count = []
count = 0
max = 0
for i in range(0,N):
    if len(words) == 0:
        words.append(S[i])
        word_num += 1
        count += 1
    elif len(words) != 0 and S[i] != words[word_num]:
        word_count.append(count)
        if count > max:
            max = count
        count = 1
        words.append(S[i])
        word_num += 1
    elif words[word_num] == S[i]:
        count += 1
word_count.append(count)
if count > max:
            max = count

max_words = []
for i in range(0,len(words)):
    if word_count[i] == max:
        max_words.append(words[i])

for i in max_words:
    print(i)

Solution (Python):
n = int(input())
d = {}

for _ in range(n):
  s = input()
  d[s] = d.get(s, 0) + 1 

n = max(d.values())
max_k_list = [kv[0] for kv in d.items() if kv[1] == n]

for i in sorted(max_k_list):
  print(i)

Solution (Python):
n = int(input())
d = {}

for _ in range(n):
  s = input()
  d[s] = d.get(s, 0) + 1 

n = max(d.values())
max_k_list = [kv[0] for kv in d.items() if kv[1] == n]
max_k_list.sort()

for i in max_k_list:
  print(i)

Solution (Python):
n = int(input())
s_li = [input() for x in range(n)]
from collections import Counter
c = Counter(s_li)
c = c.most_common()
tmp = c[0][1]
res = []
for x in c:
    if tmp > x[1]:
        break
    res.append(x[0])
res.sort()
for x in res:
    print(x)

Solution (Python):


N=int(input())
S=[input() for i in range(N)]


result={}
for i in S:
    if i in result:
        result[i]+=1
    else:
        result[i]=1

x=max(result.values())

Z=[]
for i in result.items():
    if i[1]==x:
        Z.append(i[0])
Z.sort()
for i in Z:
    print(i)

Solution (Python):

N=int(input())
S={}
for i in range(N):
    x=input()
    if x in S:
        S[x]+=1
    else:
        S[x]=1
t=max(S.values())
ans=[k for (k,v) in S.items() if v==t]
ans.sort()

for i in ans:
    print(i)
""""

while len(S):
    if len(S)==1:
        x = [S.pop(), 1]
        ans.append(x)
        break
    x = [S.pop(), 1]
    for i in S[:]:
        if x[0] == i:
            S.remove(i)
            x[1]+=1
    ans.append(x)
ans.sort()
ans.sort(key=lambda x:x[1],reverse=True)

for i in range(len(ans)):
    t=ans[0][1]
    if ans[i][1]==t:
        print(ans[i][0])



import queue

q=queue.Queue()
for i in S:
    q.put(i)

while not q.empty():
    x = [q.get(), 1]
    if len(ans)==0:
        ans.append(x)
        continue
    t=0
    for i in range(len(ans)):
        if x[0] == ans[i][0]:
            ans[i][1]+=1
            t+=1
            break
    if t==0:
        ans.append(x)
ans.sort()
ans.sort(key=lambda x:x[1],reverse=True)

for i in range(len(ans)):
    t=ans[0][1]
    if ans[i][1]==t:
        print(ans[i][0])

"""

Solution (Python):
from collections import Counter

n = int(input())
s = [input() for _ in range(n)]
cnt = Counter(s)
l = max(cnt.values())
ans = [s for s, j in cnt.items() if j == l]
ans.sort()

print("\n".join(ans))

Solution (Python):
n = int(input())
table = [input() for _ in range(n)]
d = dict()
for s in table:
    if s in d.keys():
        d[s] += 1
    else:
        d[s] = 0
m = max(d.values())
l = [key for key, value in d.items() if value == m]
l.sort()
print(*l, sep = "\n")

Solution (Python):
from collections import Counter
n = int(input())
table = [input() for _ in range(n)]
c = Counter(table)
m = max(c.values())
l = [key for key, value in c.items() if value == m]
l.sort()
print(*l, sep = "\n")

Solution (Python):



if False:
    N=int(input())
    A=[int(i) for i in input().split()]
    ans=[(i,a) for i,a in enumerate(A)]
    ans.sort(key=lambda x: x[1],reverse=True)
    for i in range(N): print(ans[i][0]+1)


if False:
    N,P=map(int,input().split())
    A=[int(i) for i in input().split()]
    flag=True 
    for a in A:
        if a%2==1:
            flag=False
            break
    if flag:
        if P==0:
            print(2**N)
        else:
            print(0)
    else:
        print(2**(N-1))


if False:
    print('Yes' if len(set(input().split()))==2 else 'No')

if False:
    N=int(input())
    A=[int(i) for i in input().split()]
    ans='APPROVED'
    for a in A:
        if a%2==0:
            if not(a%3==0 or a%5==0):
                ans='DENIED'
    print(ans)

if True:
    
    def cnt(lis): 
        ret={}
        for x in set(lis):
            ret[x]=0
        for e in lis:
            ret[e]+=1
        return ret

    
    def DtoL(dic):
        return list(zip(dic.keys(),dic.values()))

    N=int(input())
    S=[input() for _ in range(N)]
    RES=DtoL(cnt(S))
    
    MAX=max(RES,key=lambda x: x[1])
    ANS=[]
    for r in RES:
        if r[1]==MAX[1]:
            ANS.append(r)
    ANS.sort(key=lambda x: x[0])
    for ans in ANS:
        print(ans[0])

Solution (Python):
from collections import defaultdict
d = defaultdict(int)
N = int(input())
MAX = 0
max_keys = []
for i in range(N):
    k = input()
    d[k] += 1
    if d[k] == MAX:
        max_keys.append(k)
    elif d[k] > MAX:
        MAX = d[k]
        max_keys = [k]

for i in sorted(max_keys):
    print(i)

Solution (Python):
N=int(input())
dic = {}
for i in range(N):
    s =input()
    if s in dic:
        dic[s]+=1
    else:
        dic[s] =1

items = list(dic.items())
max_num = max([v[1] for v in items])
ans = []

for k,v in items:
    if max_num == v:
        ans.append(k)

ans.sort()

for v in ans:
    print(v)

Solution (Python):
import collections


N = int(input())
S = [None] * N
for i in range(N):
    S[i] = input()

count = collections.Counter(S)
max_n = max(count.values())


keys = [k for k, v in count.items() if v == max_n]
keys.sort()

for s in keys:
    print(s)

Solution (Python):
N = int(input())
A = [input() for i in range(N)]
import collections
c = collections.Counter(A)

max = c.most_common()[0][1]


li = list(c)

keys = [k for k, v in c.items() if v == max]

keys.sort()
for i in keys:
    print(i)

Solution (Python):
N=int(input())
d={}
for _ in range(N):
    s=input()
    if s in d:
        d[s]+=1
    else:
        d[s]=1
mv=max(d.values())
l=list()
for k,v in d.items():
    if v==mv:
        l.append(k)
l.sort()
for li in l:
    print(li)

Solution (Python):
n = int(input())
d = dict()

for _ in range(n):
    s = input()

    if s in d:
        d[s] += 1
    else:
        d[s] = 1


items = list(d.items())
max_num = max([v[1] for v in items])
ans = []

for k,v in items:
    if max_num == v:
        ans.append(k)

ans.sort()

for v in ans:
    print(v)

Solution (Python):
import sys
input = sys.stdin.readline
import numpy as np
def print_ans(N, ar):
    """Test Case
    >>> print_ans(7, ["beat", "vet", "beet", "bed", "vet", "bet", "beet"])
    beet
    vet
    >>> print_ans(8, ["buffalo", "buffalo", "buffalo", "buffalo", "buffalo", "buffalo", "buffalo", "buffalo"])
    buffalo
    >>> print_ans(7, ["bass", "bass", "kick", "kick", "bass", "kick", "kick"])
    kick
    >>> print_ans(4, ["ushi", "tapu", "nichia", "kun"])
    kun
    nichia
    tapu
    ushi
    """
    dict = {}
    for a in ar:
        if a in dict:
            dict[a] = dict[a] + 1
        else:
            dict[a] = 0
    max_val = max(dict.values())
    key_list = sorted([key for key in dict if dict[key] == max_val])
    for key in key_list:
        print(key)


    
    

if __name__ == '__main__':
    N = int(input().rstrip())
    ar = [ input().rstrip() for _ in range(N)]
    print_ans(N, ar)

Solution (Python):
from collections import Counter
n = int(input())
l = Counter([input() for _ in range(n)])
a = sorted(list(l.items()),key=lambda x:x[1])[::-1]
t = a[0][1]
q = []
for i in range(len(l)):
  if t == a[i][1]:
    q.append(a[i][0])
  else:
    break
c = sorted(q)
print(*c,sep="\n")

Solution (Python):
n = int(input())

dic = {}

for i in range(n):
  word = input()
  if word not in dic:
    dic[word] = 1
  else:
    dic[word] += 1
    
max_num = max(dic[word] for word in dic)
l = []
for word in dic:
  if dic[word]==max_num:
    l.append(word)
    
l = sorted(l)
for i in range(len(l)):
  print(l[i])

Solution (Python):
n=int(input())
d={}
for i in range(n):
  k=input()
  d[k]=d.get(k,0)+1
val=list(d.values())
key=list(d.keys())
m=max(val)
key.sort()
for i in key:
  if d[i]==m:
    print(i)

Solution (Python):
n = int(input())

s_dict = {}
for _ in range(n):
    s = input()
    if s not in s_dict:
        s_dict[s] = 0
    s_dict[s] += 1


count_max = sorted(s_dict.values())[-1]


s_list = []
for s, count in s_dict.items():
    if count == count_max:
        s_list.append(s)
s_list.sort()


for s in s_list:
    print(s)

Solution (Python):
import collections
N = int(input())
S = [input() for _ in range(N)]
c = collections.Counter(S)
cnt=max(c.values())
tmp = [k for k, v in c.items() if cnt==v]
print(*sorted(tmp), sep='\n')

Solution (Python):
import collections
N = int(input())
S = [input() for _ in range(N)]
c = dict(collections.Counter(S))
tmp=[]
cnt=max(c.values())
for k, v in c.items():
    if v==cnt:
        tmp.append(k)
print(*sorted(tmp), sep='\n')

Solution (Python):
N=int(input())
S=[]
for _ in range(N):
    S.append(input())
S.sort()


m=1
c=1
L={S[0]}
for i in range(N-1):
    if S[i]==S[i+1]:
        c+=1
        if c==m:
            L.add(S[i])
        elif c>m:
            L.clear()
            L.add(S[i])
            m=c
    else:
        if c==m:
            if 0<=i<N-2:
                L.add(S[i])
            else:
                L.add(S[i])
                L.add(S[i+1])
        c=1
    

R=sorted(list(L))
for j in range(len(R)):
    print(R[j])

Solution (Python):
import collections as col
N = int(input())
l = [0]*N
for i in range(N):
    l[i] = input()
ans = []

counter = col.Counter(l)
common = counter.most_common()
ans = []
ans.append(common[0][0])

for i in range(len(common)-1):
    if common[i][1] == common[i+1][1]:
        ans.append(common[i+1][0])
        i += 1
    else:
        break

ans.sort()
for i in range(len(ans)):
    print(ans[i])

Solution (Python):
from collections import Counter
N = int(input())
S = [input() for _ in range(N)]

c = Counter(S).most_common()
cnt_max = c[0][1]
ans = []
for s, cnt in c:
    if cnt != cnt_max:
        break
    ans.append(s)

print('\n'.join(sorted(ans)))

Solution (Python):
from collections import Counter
n = int(input())
S = [input() for _ in range(n)]

poll = Counter(S)
max_c = max(list(poll.values()))
ans = [k for k in poll.keys() if poll[k] == max_c]
ans.sort()
for a in ans:
     print(a)

Solution (Python):
n = int(input())
lst = [input() for _ in range(n)]

dct = {}
for st in lst:
    if st not in dct:
        dct[st] = 1

    dct[st] += 1


dct_srt = sorted(dct.items(), key=lambda x: x[1], reverse=True)
mx = 0
ans_ = []
for key, value in dct_srt:
    if value >= mx:
        mx = value
        ans_.append(key)
    else:
        break

ans = sorted(ans_)
for i in ans:
    print(i)

Solution (Python):
N = int(input())
S = [input() for _ in range(N)]

dic={}
for i in range(N):
    if S[i] not in dic:
        dic[S[i]]=1
    else:
        dic[S[i]]+=1

largest=max(dic.values())
ans=list()

for key in dic.keys():
    if dic[key]==largest:
        ans.append(key)

ans.sort()
for word in ans:
    print(word)

Solution (Python):
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n=n0()
s=s2(n)

from collections import Counter
c=Counter(s)
d=dict(c.most_common())
m=max(d.values())
a=[x for x,y in d.items() if y==m]
[print(x) for x in sorted(a)]

Solution (Python):
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s
def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)
def mCn(m, n):
    def factorial_ntimes(m, n):
        r = 1
        while n:
            r *= m
            m -= 1
            n -= 1
        return r
    return int(factorial_ntimes(m, n) / factorial(n))

n = load()
A = []
for _ in range(n):
    A.append(load(str))

cnt = defaultdict(int)
mx = 0
mxl = []

for a in A:
    cnt[a] += 1

for key, value in cnt.items():
    if value == mx:
        mxl.append(key)
        continue
    if value > mx:
        mx = value
        mxl = [key]
        continue

for m in sorted(mxl):
    print(m)

Solution (Python):
import collections
N=int(input())
list1=[]
for i in range(N) :
  list1.append(input())
c=collections.Counter(list1)


key_list=list(c.keys())
value_list=list(c.values())
list2=[]

curerent=0
k=max(value_list)
for i,item in enumerate(key_list) :
  if value_list[i]==k :
    list2.append(item)
  

list2.sort()
for item in list2 :
  print(item)