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):
N = int(input())

S = dict()
for i in range(N):
    tmp = input()
    if tmp in S:
        S[tmp] += 1
    else:
        S[tmp] = 1

max_v = 0
for k, v in S.items():
    if max_v < v:
        max_v = v

S = sorted(S.items(), key=lambda x:x[0])
        
for k, v in S:
    if v == max_v:
        print(k)

Solution (Python):
n = int(input())
raw = []
for _ in range(n):
  raw.append(input())
raw.sort()
raw2 = [[-1,raw[0]]]
for i in range(1,n):
  if raw[i] == raw[i-1]:
    raw2[-1][0] -= 1
  else:
    raw2.append([-1,raw[i]])
raw2.sort()
maxi = raw2[0][0]
for x in raw2:
  if x[0] == maxi:
    print(x[1])
  else:
    break

Solution (Python):
n=int(input())
d={}
for i in range(n):
    s=input()
    try:
        if d[s]>0:
            d[s]+=1
    except:
        d[s]=1
l=[]
maxi=-1
for i in d:
    if d[i]>maxi:
        maxi=d[i]
for i in d:
    if d[i]==maxi:
        l.append(i)
l.sort()
for i in l:
    print(i)

Solution (Python):
def main():
    N = int(input())
    strings = {}
    for _ in range(N):
        s = input()
        if s in strings.keys():
            strings[s] += 1
        else:
            strings[s] = 1
    strings = sorted(strings.items(), key=lambda x: x[1], reverse=True)
    maximum = strings[0][1]
    answer = []
    for s in strings:
        if s[1] == maximum:
            answer.append(s[0])
    answer.sort()
    for ans in answer:
        print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
'''
n = int(input())
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [int(input()) for i in range n]
p = [list(map(int, input().split()))]

a = input()
a, b = input().split()
a = [input() for i in range n]
'''
n = int(input())
a = [input() for i in range(n)]

ans = []

import collections
counter = collections.Counter(a)

max_h = max(counter.values())


for i in counter.items():
    
    if i[1] == max_h:
        ans.append(i[0])
    else:
        pass

ans.sort()

[print(i) for i in ans]

Solution (Python):
n = int(input())
vote = {}
v_max = 0
for i in range(n):
    s = input()
    if s not in vote:
        vote[s] = 1
    else:
        vote[s] += 1
    
    if(v_max<vote[s]): v_max = vote[s]

res = []
for k in vote:
    if vote[k]==v_max: res.append(k)

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

Solution (Python):
from collections import *
n = int(input())
s = Counter(input() for _ in range(n))

l = sorted((-i, k) for k, i in  s.items())

m = l[0][0]
for i, k in l:
  if i != m:
    break
  print(k)

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

for i in range(n):
    s = input()
    if s not in count:
        count[s] = 1
    else:
        count[s] += 1

maximum = 0
for v in count.values():
    maximum = max(v, maximum)

ans = []

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

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

Solution (Python):
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True 
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)
from collections import defaultdict
n = inn()
h = defaultdict(int)
for i in range(n):
    s = ins()
    h[s] += 1
mx = max(list(h.values()))
ss = []
for s in h:
    if h[s]==mx:
        ss.append(s)
ss.sort()
for s in ss:
    print(s)

Solution (Python):

def counter_list(A):
 def counter_dic(A): 
  dic = {}
  for a in A:
   dic[a] = dic.get(a,0) + 1
  return dic

 dic_ = counter_dic(A)
 B = []
 for k in dic_:
  B.append([dic_[k], k])
 B.sort(reverse=True) 
 return B

N = int(input())
S = []

for i in range(N):
 s = input()
 S.append(s)
  
ans = []
cnt = counter_list(S)
for i in range(len(cnt)):
  if(cnt[i][0] == cnt[0][0]):
    ans.append(cnt[i][1])
  else:
    break
    
ans.sort()
for i in range(len(ans)):
  print(ans[i])

Solution (Python):
from collections import Counter

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

c = Counter(l)
common = c.most_common()
max_count = common[0][1]
tmp = []
for s, num in common:
    if num == max_count:
        tmp.append(s)
    else:
        break

for item in sorted(tmp):
    print(item)

Solution (Python):
N = int(input())
S = ['0'] * N
for i in range(N):
    S[i] = input()
import collections
c = collections.Counter(S)
li = list(c.values())
ca = list(c.keys())
li.sort()
max = li[-1]
lia = []
for i in ca:
    if c[i] == max:
        lia.append(i)
lia.sort()
n = len(lia)
for i in range(n):
    print(lia[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
max_v = max(dic.values())
ans = []
for k,v in dic.items():
    if v == max_v:
        ans.append(k)
ans.sort()
for i in ans:
    print(i)

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

dic = {}
maxn = 1
for _ in range(n):
    s = input()
    if s in dic:
        dic[s] += 1
        maxn = max(maxn, dic[s])
    else:
        dic[s] = 1

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


for k, v in dic:
    if v == maxn:
        print(k)

Solution (Python):
N = int(input())
S = [input() for i in range(N)]
s_dict = {}
ans = ['{'] * N

for i in S:
    if i in s_dict:
        s_dict[i] += 1
    else:
        s_dict[i] = 1

s_dict = sorted(s_dict.items(), key = lambda x: -x[1])


max_count = s_dict[0][1]
for i in range(len(s_dict)):
    if s_dict[i][1] == max_count:
        ans[i] = s_dict[i][0]
    else:
        break

ans.sort()
for i in ans:
    if i == '{':
        break
    else:
        print(i)

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

m = 0
for i in dic:
    m = max(dic[i],m)
    
lis = []
for i in dic:
    if dic[i] == m:
        lis.append(i)
        
lis.sort()
for i in lis:
    print(i)

Solution (Python):
n = int(input())
l = [input() for _ in range(n)]
d = {}
for w in l:
  d[w] = d.get(w,0)+1
m = max(d.values())
lt = sorted(d.items(),key=lambda k:-k[1])
ans = sorted([k for k,v in lt if v==m])
print(*ans,sep='\n')

Solution (Python):
import collections

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

c = collections.Counter(a)
d = c.most_common()
e = d[0][1]
f = []
for i, j in d:
    if e == j:
        f.append(i)
f.sort()

for i in f:
    print(i)

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

d1 = {}
for _ in range(N):
    S = input()
    if S in d1:
        d1[S] += 1
    else:
        d1[S] = 1

d2 = {}
for key in d1:
    value = d1[key]
    if value in d2:
        d2[value].append(key)
    else:
        d2[value] = [key]

key = sorted(d2.keys(), reverse=True)[0]
for s in sorted(d2[key]):
    print(s)

Solution (Python):
from collections import defaultdict as d

n = int(input())
dico = d(int)
for i in range(n):
	s = input()
	dico[s] += 1
x = 0
tab = []
for k in dico.keys():
	if dico[k] > x:
		tab = [k]
		x = dico[k]
	elif dico[k] == x:
		tab.append(k)
tab.sort()
for i in tab:
	print(i)

Solution (Python):
N = int(input())
words = {}
ans = []
for i in range(N):
  w = input()
  words.setdefault(w, 0)
  words[w] += 1
m = max(list(words.values()))
for k, v in words.items():
  if v == m:
    ans.append(k)
ans.sort()
for w in ans:
  print(w)

Solution (Python):
N=int(input())
sdic={}

for s in range(N):
  s=input()
  if s in sdic:
    sdic[s]+=1
  else:
    sdic[s]=1

max_s=0
for s in sdic:
  if sdic[s]>max_s:
    max_s=sdic[s]
    

slist=[]
for s in sdic:
  if sdic[s]==max_s:
    slist.append(s)
    
slist.sort()

for s in slist:
  print(s)

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

_max = 0
_list = sorted(dic.items(), key=lambda x:x[0])
for s, num in sorted(_list, key=lambda x:x[1], reverse=True):
    if num < _max:
        break
    else:
        _max = num
        print(s)

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

d = {}
maxval=0
for i in range(N):
    tmp = input()
    if tmp in d.keys():
        d[tmp] +=1
        maxval = max(d[tmp], maxval)
    else:
        d[tmp] = 1
        maxval = max(d[tmp], maxval)

        
ans = []
for istr in  d.keys():
    if d[istr] == maxval:
        ans += [istr]
ans.sort()
        
for istr in ans:
    print(istr)

Solution (Python):
from collections import Counter

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

c = Counter(S)
mc = c.most_common()
L = []
for p in mc:
    if p[1] < mc[0][1]:
        break
    L.append(p[0])
L.sort()
for l in L:
    print(l)

Solution (Python):
from collections import defaultdict
n=int(input())
s=[input() for i in range(n)]
cnt=defaultdict(lambda:0)
for i in s:
    cnt[i]+=1

cnt=list(cnt.items())
cnt=sorted(cnt,reverse=True,key=lambda x: x[1])
maxim=cnt[0][1]
ans=[]
for i in range(len(cnt)):
    if cnt[i][1]==maxim:
        ans+=[cnt[i][0]]
ans=sorted(ans)
print(*ans,sep='\n')

Solution (Python):
from collections import Counter
n = int(input())
S = ['_']*n
for i in range(n):
    S[i] = input()
cS = Counter(S).most_common()
mx = cS[0][1]
ans = []
for i in range(len(cS)):
    if cS[i][1]==mx:
        ans.append(cS[i][0])
    else:
        break
ans = sorted(ans)
for i in range(len(ans)):
    print(ans[i])

Solution (Python):
from collections import Counter
n = int(input())
s = [input() for i in range(n)]
d = sorted(list(Counter(s).items()), key=lambda x:x[1], reverse=True)
MAX = d[0][1]
ans = []
for S,i in d:
  if i == MAX:
    ans.append(S)
  else:
    break
ans.sort()
for i in ans:
  print(i)

Solution (Python):
N = int(input())
d = {}
m = 1
for i in range(N):
    s = input()
    if s not in d:
        d[s] = 1
    else:
        d[s] += 1
        m = max(m, d[s])

l = []
for k, v in d.items():
    if v == m:
        l.append(k)

for n in sorted(l):
    print(n)

Solution (Python):
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
 

def ii(): return int(sys.stdin.readline().rstrip()) 
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) 
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]

def ss(): return sys.stdin.readline().rstrip() 
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) 
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]





n=ii()
arr=lst(n)

b = Counter(arr)
ak=list(b.keys())
av=list(b.values())

am=max(av)
ans=[]
for i in range(len(ak)):
    if av[i]==am:
      ans.append(ak[i])
ans.sort()
for i in ans:
    print(i)

Solution (Python):

import sys,os
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7
    from collections import defaultdict
    
    N = II()
    countS = defaultdict(int)
    max_count = 0
    max_words = []
    for _ in range(N):
        s = input()
        countS[s] += 1
        if countS[s] > max_count:
            max_words = [s]
            max_count = countS[s]
        elif countS[s] == max_count:
            max_words.append(s)
    
    max_words.sort()
    for w in max_words:
        print(w)

if __name__ == '__main__':
    main()

Solution (Python):
import itertools
import math
import sys
from collections import Counter

n = int(input())
s = [input() for i in range(n)]
s_cnt = Counter(s).most_common()

cnt = s_cnt[0][1]

ans = []
for i in s_cnt:
    if i[1] == cnt:
        ans.append(i[0])
ans.sort()
for i in ans:
    print(i)

Solution (Python):

from collections import deque, defaultdict

def comb(a, b):
    result = 1
    for i in range(b):
        result *= (a - i) / (i + 1)
    return result


def main():
    N = int(input())

    counter = defaultdict(int)

    max_value = 0
    for i in range(N):
        S = input().strip()
        counter[S] += 1

        if max_value < counter[S]:
            max_value = counter[S]

    most_freq_string = []
    for S in counter:
        if counter[S] == max_value:
            most_freq_string.append(S)

    most_freq_string = sorted(most_freq_string)
    for S in most_freq_string:
        print(S)


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
max_num = 0
word_dict = {}
for i in range(n):
    w = input()
    temp = word_dict.get(w, 0) + 1
    word_dict[w] = temp
    if temp > max_num:
        max_num = temp

ans_list = []
for w in word_dict:
    if word_dict[w] == max_num:
        ans_list.append(w)

ans_list.sort()

for w in ans_list:
    print(w)

Solution (Python):
from collections import Counter

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

c = Counter(S)
max_count = max(c.values())
word = [k  for k,v in c.items() if v == max_count]

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

Solution (Python):
from collections import Counter
def main():
    N = int(input())
    s = [input() for i in range(N)]

    t = Counter(s)
    T = t.most_common()

    m = T[0][1]
    c = []
    for w, n in T:
        if n == m:
            c.append(w)
        else:
            break

    c.sort()
    print("\n".join(c))



if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
d = dict()
m = 0
for i in range(n):
    s = input()
    d[s] = d.get(s, 0) + 1
    m = max(m, d[s])
res = list()
for k, v in d.items():
    if v == m:
        res.append(k)
res.sort()
for r in res:
    print(r)

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


c = collections.Counter(v)
x = 0
u = []
for t in c.most_common():
    if x>0 and t[1] != x:
        break
    else:
        x = t[1]
        u.append(t[0])

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

Solution (Python):
N = int(input())
S = list(input() for i in range(N))

S.sort()
count = 0
hoge = ""
ans = [""]
ansnum = -1
for c in S:
    if hoge == c:
        count += 1
    else:
        count = 1
        hoge = c
    if count > ansnum:
        ans = [c]
        ansnum = count
    elif count == ansnum:
        ans.append(c)

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

Solution (Python):



from fractions import gcd 
from functools import reduce
import sys
sys.setrecursionlimit(200000000)
from inspect import currentframe




def printargs2err(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' : '+repr(arg) for arg in args),file=sys.stderr)
def debug(x):
    print(x,file=sys.stderr)
def printglobals():
    for (symbol, value) in globals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
def printlocals():
    for (symbol, value) in locals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)



def pin(type=int):
    return map(type,input().split())

"""
愚直に操作を実装する
"""

N=int(input())
S=[input() for i in range(N)]
import collections as cl

a=cl.Counter(S)
b=(a.most_common())

maxvalue=b[0][1]
ans=[]
for i in range(len(b)):
    if b[i][1] == maxvalue:
        ans.append(b[i][0])
for w in sorted(ans):
    print(w)

Solution (Python):
import sys
input = sys.stdin.readline
from collections import defaultdict

def main():
    N = int(input())
    S = defaultdict(int)
    for _ in range(N):
        S[input().rstrip("\n")] += 1
    S = sorted(S.items(), key=lambda x:x[1])

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

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

if __name__ == "__main__":
    main()

Solution (Python):
n=int(input())
s=[0]*n
for i in range(n):
    s[i] = input()
    
lis = set(s)
dic = {ss:0 for ss in lis }
for ss in s:
    dic[ss]+=1
    
ma = max(dic.values())
ans = [k for k,v in dic.items() if v==ma]
ans.sort()
print("\n".join(ans) )

Solution (Python):
from collections import defaultdict
a, *D,  = [s.split()[0] for s in open(0)] 
d = defaultdict(int)

for w in D:
    d[w] += 1 

d = sorted(d.items(),key = lambda x:(-x[1], x[0]))
max_v = d[0][1]
for v in d:
    if v[1] == max_v:
        print(v[0])

Solution (Python):
N = int(input())
count = {}
for _ in range(N):
    s = input()
    if s in count:
        count[s] += 1
    else:
        count[s] = 1
res = sorted(count.items(), key=lambda x: (-x[1], x[0]))
max_count = res[0][1]
res = [x[0] for x in res if x[1] == max_count]
print(*res, sep='\n')

Solution (Python):
from collections import Counter


n = int(input())
S = list()
for i in range(n):
    S.append(input())

count = Counter(S)
v_max = max(count.values())
keys = list()
for key, value in count.items():
    if value == v_max:
        keys.append(key)

keys = sorted(keys)
for key in keys:
    print(key)

Solution (Python):
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
C = Counter(s)
L = C.most_common()
x = 0
ans = []
for i, l in enumerate(L):
    if i == 0:
        x = l[1]
        ans.append(l[0])
    elif x == l[1]:
        ans.append(l[0])
    else:
        break
ans.sort()
for a in ans:
    print(a)

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

d = {}
for _ in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1

MAX = 0
ans = []
for k, v in d.items():
    if v > MAX:
        ans = [k]
        MAX = v
    elif v == MAX:
        ans.append(k)


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

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

maxx = 0
for i in d:
    if d[i] > maxx:
        maxx = d[i]
ans = []
for i in d:
    if d[i] == maxx:
        ans.append(i)
for i in sorted(ans):
    print(i)

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

cnt = {}
for Si in S:
    cnt[Si] = cnt.setdefault(Si, 0) + 1

result = sorted(cnt.items(), key=lambda x: -x[-1])

ans_list = []
for i, (key, value) in enumerate(result):
    if i == 0:
        ans_cnt = value
    
    if value >= ans_cnt:
        ans_list.append(key)
    else:
        break

for key in sorted(ans_list):
    print(key)

Solution (Python):
import sys
input = sys.stdin.readline
n=int(input())
s=[input().strip() for _ in range(n)]
from collections import Counter
s=Counter(s).most_common()
a=s[0][1]
ans=[]
for w,k in s:
    if k==a:
        ans.append(w)
ans.sort()
for a in ans:
    print(a)

Solution (Python):
from collections import defaultdict
N = int(input())
s = [input() for _ in range(N)]
d = defaultdict(int)
for i in s:
    d[i] += 1

dsort = sorted(d.items(), key=lambda x : x[1], reverse=True)
ans = []
tmp = dsort[0][1]
for i, v in dsort:
    if tmp == v:
        ans.append(i)

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

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

ans=[]
for s in dic:
    if dic[s]==m: ans.append(s)
ans.sort()
for i in range(len(ans)):
    print(ans[i])

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

from collections import Counter

ctr = Counter(s)
sorted(ctr.most_common(), key=lambda x: x[1], reverse=True)
mx = sorted(ctr.most_common(), key=lambda x: x[1], reverse=True)[0][1]
li = []
for k, v in sorted(ctr.most_common(), key=lambda x: x[1], reverse=True):
    if v == mx:
        li.append(k)

li.sort()
for val in li:
    print(val)

Solution (Python):

import copy
import random
import bisect 
import fractions 
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) 

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

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

c = collections.Counter(S)

max_c = -1
anss = []
for key, count in c.most_common():
    if max_c <= count:
        max_c = count
    else:
        break
    anss.append(key)
anss.sort()
for ans in anss:
    print(ans)

Solution (Python):
N=int(input())
S=[]
for i in range(0,N):
    S.append(input())
d={}
for s in S:
    if s not in d:
        d[s]=1
    else:
        d[s]+=1
A=[]
B=[]
for k in d:
    A.append([d[k], k])
    B.append(d[k])
A.sort(reverse=True)
B.sort(reverse=True)
M=B[0]
C=[]
for a in A:
    if a[0]==M:
        C.append(a[1])
C.sort()
for c in C:
    print(c)

Solution (Python):
from collections import Counter
N = int(input())
S = []
for n in range(N):
    S.append(input())
c = Counter(S)
num = c.most_common()[0][1]
ans = []
for x in c:
    if c[x] == num:
        ans.append(x)
for x in sorted(ans):
    print(x)

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

maxkey = max([dic[i] for i in dic])

anslist = []

for i in dic:
    if dic[i] == maxkey:
        anslist.append(i)
anslist.sort()

for i in anslist:
    print(i)

Solution (Python):
from bisect import bisect_right, bisect_left
from collections import Counter, deque
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import groupby, permutations, combinations, product
from sys import stdin, stderr





def gcd(x, y):
    return x if y == 0 else gcd(y, x % y)





def exgcd(x, y):
    if y == 0:
        return 1, 0
    a, b = exgcd(y, x % y)
    return b, a - (x // y) * b



def lcm(x, y):
    m = gcd(x, y)
    return (x // m) * (y // m)


def main():
    n = int(input())
    ss = {}
    m = 0
    for i in range(n):
        s = input()
        if s not in ss:
            ss[s] = 0
        ss[s] += 1
        m = max(m, ss[s])
    ret = []
    for s in ss.keys():
        if ss[s] == m:
            ret.append(s)
    ret = sorted(ret)
    return "\n".join(ret)


if __name__ == "__main__":
    print(main())

Solution (Python):
import collections
n=int(input())
a=[]
for i in range(n):
    a.append(input())
a=list(collections.Counter(a).most_common())
b=a[0][1]
c=[]
for i in range(len(a)):
    c.append(a[i][0])
    if i+1==len(a):
        break
    if a[i+1][1]!=b:
        break
c=sorted(c)
for i in range(len(c)):
    print(c[i])

Solution (Python):
def solve():
    import itertools
    from operator import itemgetter

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

    l = []
    gr = itertools.groupby(B)
    max_key = 0
    for key, group in gr:
        length = len(list(group))
        l.append((length, key))
        if length > max_key:
            max_key = length

    l.sort(key = itemgetter(0), reverse=True)

    key = l[0][0]
    for k, v in l:
        if key == k:
            print(v)
        else:
            break

solve()

Solution (Python):

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

mydic = {}
for s in S:
    mydic[s] = 0

for s in S:
    mydic[s] += 1

MIN = -1
for s in S:
    MIN = max(MIN, mydic[s])

ans = []
for s in S:
    if mydic[s] == MIN:
        ans.append(s)

ans.sort()
print(ans[0])
for i in range(1,len(ans)):
    if ans[i] == ans[i-1]:
        continue
    else:
        print(ans[i])

Solution (Python):
import sys
input = sys.stdin.readline
n = int(input())
d = {}
for i in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1
l = [[-d[key], key] for key in d]
l.sort()

m = l[0][0]
for v, k in l:
    if v == m:
        print(k.rstrip("\n"))

Solution (Python):
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
def gcd(a,b):return fractions.gcd(a,b) 
def lcm(a,b):return (a*b) // fractions.gcd(a,b) 
def iin(): return int(input()) 
def ifn(): return float(input()) 
def isn(): return input().split() 
def imn(): return map(int, input().split()) 
def fmn(): return map(float, input().split()) 
def iln(): return list(map(int, input().split())) 
def iln_s(): return sorted(iln()) 
def iln_r(): return sorted(iln(), reverse=True) 
def fln(): return list(map(float, input().split())) 
def join(l, s=''): return s.join(l) 
def perm(l, n): return itertools.permutations(l, n) 
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) 
def comb(l, n): return itertools.combinations(l, n) 
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) 
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 
def m_add(a,b): return (a+b) % MOD

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

s = collections.Counter(S)

mv = s.most_common()[0][1]
ans = []
for k,v in s.items():
    if v == mv:
        ans.append(k)
ans = sorted(ans)
for a in ans:
    print(a)

Solution (Python):
import collections
n=int(input())
slist=[input() for i in range(n)]
c = collections.Counter(slist)
most = c.most_common()
num = most[0][1]
most = [i[0] for i in most if i[1]==num]
most.sort()
for s in most:
  print(s)

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

_, m = c.most_common(1)[0]

ans = []
for x, y in c.most_common():
    if y == m:
        ans.append(x)
    else:
        break

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

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

s_dict = {}
max_count = 0
max_words = []

for _ in range(n):
    s = input()
    if s in s_dict:
        s_dict[s] += 1
        count = s_dict[s] + 1
    else:
        s_dict[s] = 1
        count = 1
    if count == max_count:
        max_words.append(s)
    elif count > max_count:
        max_words = [s]
    max_count = max(max_count,count)

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

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

dic = {}
for i in range(N):
    s = input()

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

mm = 0
li = []

for i in dic:
    if dic[i] > mm:
        li = [i]
        mm = dic[i]
    elif dic[i] == mm:
        li.append(i)

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

Solution (Python):


if __name__ == '__main__':
    N = int(input())

    emp_dict = {}

    for i in range(N):
        s = input()
        if s in emp_dict:
            emp_dict[s] += 1
        else:
            emp_dict[s] = 1

    a = max(list(emp_dict.values()))

    A = []

    for k in emp_dict.keys():
        if emp_dict[k] == a:
            A.append(k)

    A.sort()
    for a in A:

        print(a)

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

c = Counter(l)

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

ans = []
for k,v in c.items():
    if v < d:
        pass
    else:
       ans.append(k)
       
       
ans = sorted(ans)

print(*ans,sep = '\n')

Solution (Python):
n = int(input())
s = []
for i in range(n):
    s0 = input()
    s.append(s0)
l = []
s.sort()
count = 0
for i in range(n-1):
    count += 1
    if s[i] == s[i+1]:
        continue
    else:
        l.append([s[i],count])
        count = 0
count += 1
l.append([s[n-1],count])
l.sort(key=lambda x:x[1],reverse=True)
m = len(l)
a = l[0][1]
for i in range(m):
    if l[i][1] == a:
        print(l[i][0])
    else:
        break

Solution (Python):
from collections import Counter
def main():
    N = int(input())
    d = Counter()
    l = 0
    for _ in range(N):
        s = input()
        if s not in d:
            d[s] = 1
        else:
            d[s] += 1
        l = max(d[s], l)
    d2 = []
    for i in d:
        if d[i] == l:
            d2.append(i)
    d2.sort()
    for j in d2:
        print(j)
main()

Solution (Python):
from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
c = Counter(S)
m = max(c.values())
ans = []
for k in c.keys():
    if c[k] == m:
        ans.append(k)
for a in sorted(ans):
    print(a)

Solution (Python):
from collections import Counter

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

c = Counter(S).most_common()
m = c[0][1]
print("\n".join(sorted(s[0] for s in c if s[1] == m)))

Solution (Python):
from collections import defaultdict

N=int(input())
S=[input() for _ in range(N)]
d=defaultdict(int)
maxV=0
for s in S:
    d[s]+=1
    maxV=max(maxV, d[s])
ans=[]
for key, value in d.items():
    if value==maxV:
        ans.append(key)
ans.sort()
for a in ans:
    print(a)

Solution (Python):

n = int(input())
s = {}
for i in range(n):
    tmp = input()
    try:
        s[tmp] += 1
    except:
        s[tmp] = 1
smax = max(s.values())
ls = []
for i in s.keys():
    if s[i] == smax:
        ls.append(i)
ls.sort()
for i in ls:
    print(i)

Solution (Python):
from collections import Counter

def main():
    n = int(input().strip())
    cnt = Counter()
    for _ in range(n):
        cnt[input().strip()] += 1
    
    maxval = max(cnt.values())
    for s in sorted(k for k, v in cnt.items() if v == maxval):
        print(s)


main()

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

num_of_votes = {}

for _ in range(n):
  s = input()
  if num_of_votes.get(s) == None:
    num_of_votes[s] = 0
  num_of_votes[s] += 1

ans = []
max_v = 0
for k, v in num_of_votes.items():
  if max_v < v:
    ans = [k]
    max_v = v
  elif max_v == v:
    ans.append(k)
  else:
    pass

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

Solution (Python):
import sys
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    c = collections.Counter()
    for i in range(N):
        S = input().strip()
        c[S] += 1

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

    ans = []
    for v in c.most_common():
        if v[1] == ma:
            ans.append(v[0])
        else:
            break
    ans.sort()

    for a in ans:
        print(a)


if __name__ == '__main__':
    main()

Solution (Python):
import collections
n=int(input())
S=[]
for i in range(n):
    S.append(input())
SS=collections.Counter(S).most_common()
s,ct=SS[0]
Ans=[]
for s,c in SS:
    if c==ct:
        Ans.append(s)
Ans.sort()
for ans in Ans:
    print(ans)

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

S = list(input() for _ in range(n))
from collections import Counter

c = Counter(S).most_common()

max_cnt = c[0][1]
lst = []

for i in c:
  if i[1] != max_cnt:
    break
  else:
    lst.append(i[0])
    

for node in sorted(lst):
  print(node)