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
import 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(str, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def has_duplicates(seq):
    return len(seq) != len(set(seq))


N = INT()

S = []
for n in range(N):
    s = input()
    S.append(s)

import collections
S = collections.Counter(S)

T = S.most_common()

ans = []

num = T[0][1]
for t in T:
    if t[1] == num:
        ans.append(t[0])
    else:
        break
ans = sorted(ans)
for a in ans:
    print(a)

Solution (Python):
from collections import Counter
def main():
    n=int(input())
    S=tuple(input() for _ in range(n))
    D=Counter(S)
    m=max(D.values())
    L = [d[0] for d in D.items() if d[1]==m]
    L=sorted(L)
    for l in L:
        print(l)
main()

Solution (Python):
N = int(input())
S = []

for i in range(N):
  S.append(input())
  
S.sort()
SS = S
count = 1
maxcount = 1
ans = []

for i in range(1, N):
  if S[i-1] == S[i]:
    count += 1
    if count == maxcount:
      ans.append(S[i])
    if count > maxcount:
      ans = []
      ans.append(S[i])
      maxcount = count
  else:
    count = 1
    
if ans == []:
  ans = SS
  
for a in ans:
  print(a)

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

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

dic.reverse()

ans = []
mx = dic[0][1]
for i in range(len(dic)):
    if dic[i][1] == mx:
        ans.append(dic[i][0])
ans.sort()
for i in range(len(ans)):
    print(ans[i])

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

import collections
c = collections.Counter(s)
values, counts = zip(*c.most_common())

maxn = counts[0]
cnt = counts.count(maxn)
l = []
for i in range(cnt):
  l.append(values[i])

l.sort()

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

Solution (Python):
import collections


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

counter = collections.Counter(w_l)

c_l = counter.most_common()
max_v = c_l[0][1]
ans_l = []
for i in range(len(c_l)):
    word, num = c_l[i]
    if max_v != num:
        break
    ans_l.append(word)

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

Solution (Python):
import collections

n = int(input())
l = [input() for _ in range(n)] 
c = collections.Counter(l)
mc = c.most_common()
maxlist = list()
for v, i in mc:
    if i == mc[0][1]:
        maxlist.append(v)
    else:
        break

maxlist.sort()

for j in maxlist:
    print(j)

Solution (Python):
from sys import stdin

def ria(sep = ''):
    if sep == '' :
        return list(map(int, input().split())) 
    else: return list(map(int, input().split(sep)))
def rsa(sep = ''):
    if sep == '' :
        return input().split() 
    else: return input().split(sep)
def ri(): return int(input())
def rd(): return float(input())
def rs(): return input()



N = ri()
S = [""] * N
for i in range(N):
    S[i] = rs()

di = dict()
for s in S:
    if not s in di: di[s] = 0
    di[s] += 1

ma = 0
for s in di:
    ma = max(ma, di[s])

l = []
for s in di:
    if di[s] == ma: l.append(s)

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

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

c = Counter(S)
keys, values = zip(*c.most_common())

name = []
k = values[0]

for i in range(len(keys)):
    if values[i] == k:
        name.append(keys[i])

name.sort()

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

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

s = []
ans = []

for _ in range(n):
    s.append(input())

c = collections.Counter(s)
max_c = max(c.values())

for si, vi in c.items():
    if vi == max_c:
        ans.append(si)

ans2 = sorted(ans)

for s2 in ans2:
    print(s2)

Solution (Python):
import collections

n=int(input())
list=[]
for i in range(n):
    s=input()
    list.append(s)
c=collections.Counter(list)
most=c.most_common()
i=0
ans=[most[0][0]]
flag=1
for i in range(len(most)-1):
    if most[i][1]==most[i+1][1]:
            ans.append(most[i+1][0])
    else:
        break
ans.sort()
for i in range(len(ans)):
    print(ans[i])

Solution (Python):
from itertools import groupby
def main():
    n=int(input())
    ss=[]
    for _ in range(n):
        ss.append(input())
    ss=sorted(ss)
    c=0
    for k,g in groupby(ss):
        lg=len(list(g))
        if lg>c:
            c=lg
            zz=[k]
        elif lg==c:
            zz.append(k)
    for k in sorted(zz):
        print(k)
main()

Solution (Python):




n = int(input())

max_v = 0

s = {}
list = [[] for _ in range(n+1)]
for _ in range(n):
    str = input()
    if str in s:
        v = s[str] + 1
    else:
        v = 1
    s[str] = v
    max_v = max(max_v, v)
    list[v].append(str)

list[max_v].sort()

for str in list[max_v]:
    print(str)

Solution (Python):
import sys
from collections import deque

n=int(input())
s=['']*n
for i in range(n):
    s[i]=sys.stdin.readline().strip()

ss=sorted(s)

cnt=0
i=0
while i<n:
    curcnt=1
    j=i+1
    while j<n:
        if ss[i]!=ss[j]:
            break
        j+=1
        curcnt+=1
    i=i+curcnt
    cnt=max(cnt,curcnt)

i=0
while i<n:
    curcnt=1
    j=i+1
    while j<n:
        if ss[i]!=ss[j]:
            break
        j+=1
        curcnt+=1
    if curcnt==cnt:
        print(ss[i])
    i=i+curcnt

Solution (Python):
import sys
input=sys.stdin.readline
def main():
    N=int(input())
    S=[""]*N
    result={}
    for i in range(N):
        S[i]=input().strip()
        if S[i] not in result:
            result[S[i]]=1
        else:
            result[S[i]]+=1

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

    max_num=result[0][1]
    for i in range(len(result)):
        if result[i][1]==max_num:
            print(result[i][0])
        else:
            break
    
if __name__=="__main__":
    main()

Solution (Python):
import collections

if __name__ == '__main__':
    N = int(input())
    kv = collections.defaultdict(int)
    max_cnt = 0
    res = []
    for _ in range(N):
        word = input()
        kv[word] += 1
        if kv[word] == max_cnt:
            res.append(word)
        elif kv[word] > max_cnt:
            res = [word]
            max_cnt = kv[word]
    for s in sorted(res):
        print(s)

Solution (Python):
from collections import Counter
from itertools import groupby
from operator import itemgetter

c = Counter(input() for _ in range(int(input())))
a = sorted((-c[x],x) for x in c)
for _, s in next(groupby(a, itemgetter(0)))[1]:
  print(s)

Solution (Python):
n = int(input())
mymap = {}
for x in range(n):
	inp = input()
	if inp in mymap:
		mymap[inp] += 1
	else:
		mymap[inp] = 0

sorted_map = sorted(mymap.items(), key=lambda kv: kv[1], reverse = True )

maxi = sorted_map[0][1]


answer = []

for x in sorted_map:
	if x[1] == maxi:
		answer.append(x[0])
	else:
		break

answer.sort()

for x in answer:
	print(x)

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

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

    m = max(list(c.values()))
    ss = sorted(list(c.keys()))
    for s in ss:
        if c[s] == m:
            print(s)

if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
mydic = {}
mynumdic = {} 
mymax = 0

for n in range(N):
    s = input()
    if s in mydic:
        mydic[s] += 1
    else:
        mydic[s] = 1
    
    if mymax <= mydic[s]:
        mymax = mydic[s]
        
        if mydic[s] in mynumdic:
            mynumdic[mydic[s]] += [s]
        else:
            mynumdic[mydic[s]] = [s]

mylist = mynumdic[mymax]
mylist.sort()
for d in mylist:
    print(d)

Solution (Python):
N=int(input())
S=[input() for i in range(N)]
if len(set(S))==1:
  print(S[0])
else:  
  T=sorted(S)
  A=[]
  cnt=1
  for i in range(N-1):
    if T[i+1]!=T[i]:
      A.append((cnt,T[i]))
      cnt=1
    else:
      cnt+=1
  A.append((cnt,T[-1]))
  X=sorted(A)[::-1]
  x=X[0][0]
  C=[]
  for i in range(N):
    if X[i][0]==x:
      C.append(X[i][1])
    else:
      break
  for i in sorted(C):
    print(i)

Solution (Python):
import collections
n = input()



S = [input() for i in range(int(n))]
max = 0
stri = []
c = collections.Counter(S)

for i in c.most_common():
    li = list(i)
    if int(li[1]) >= int(max):
        max = li[1]
        stri.append(li[0])
li2 = sorted(stri)

for i in li2:
    print(i)

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

for i in range(N):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1
y = sorted(d.items(), key=lambda x: x[0])
z = sorted(y, key=lambda b: b[1], reverse=True)
m = 0
for s in z:
    if s[1] >= m:
        print(s[0])
        m = s[1]
    else:
        break

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

a=sorted(a)
b=[]
c=[]

tmp="."
count=0

for i in range(n):
  if tmp != a[i]:
    b.append(tmp)
    c.append(count)
    tmp=a[i]
    count=1
  else:
    count += 1
 
b.append(tmp)
c.append(count)
k=sorted(c)[-1]
for i in range(len(b)):
  if c[i]==k:
    print(b[i])

Solution (Python):
import collections
n=int(input())
s=[]
for i in range(n):
  S=input()
  s.append(S)
d=collections.Counter(s)
e=list(d.items())
e.sort(key=lambda x:-x[1])
lst=[]
for i in range(len(e)):
  if e[i][1]==e[0][1]:
    lst.append(e[i][0])
  else:
    break
lst.sort()
for j in range(len(lst)):
  print(lst[j])

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

P = [input() for i in range(N)]

d = {}
for n in P:
    if n not in d.keys():
        d[n] = 0
    d[n] += 1



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

max_num = sorted_list[0][1]

new_list = [sorted_list[0][0]]
for e in sorted_list[1:]:
    if max_num != e[1]:
        break
    new_list.append(e[0])


for r in sorted(new_list):
    print(r)

Solution (Python):
s = list(map(int, input().split()))
n=s[0]
dic={}
for i in range(n):
    s=input().split()
    s=s[0]
    if s in dic.keys():
        dic[s]+=1
    else:
        dic[s]=1
m=max(dic.values())
ans=[]
for i in dic:
    if dic[i]==m:
        ans.append(i)
ans.sort()
for i in ans:
    print(i)

Solution (Python):

n = int(input())

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

x = set(s)

dic = {}
for i in x:
    dic[i] = 0


for i in s:
    dic[i] +=1

max_dic = max(dic.values())

ans = []
for i in x:
    if dic[i] == max_dic:
        ans.append(i)


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

Solution (Python):
n = int(input())
s = []
for _ in range(n):
    s.append(input())
s = sorted(s)
s.append('')
tmp_max = []
tmp = ''
cnt_max = 0
cnt = 0
for ss in s:
    if tmp == ss:
        cnt += 1
    else:
        if cnt > cnt_max:
            cnt_max = cnt
            tmp_max = []
        if cnt == cnt_max:
            tmp_max.append(tmp)
        tmp = ss
        cnt = 1
tmp_max = sorted(tmp_max)
for t in tmp_max:
    print(t)

Solution (Python):
from collections import defaultdict

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

d=defaultdict(int)

for ls in l:
    d[ls]+=1

fg=0
th=list(d.values())

gh=list(d.keys())

for i in range(len(th)):
    fg=max(fg,th[i])

ans=[]
for i in range(len(gh)):
    if th[i]==fg:
        ans.append(gh[i])

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

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

from collections import defaultdict
 
counter = defaultdict(int)
 
for x in S:
    counter[x] += 1

X = max(counter.values())
s = set(S)
ans=[]
for i in s:
    if counter[i] == X:
        ans.append(i)

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

Solution (Python):
import collections

usrCount = int(input())
usrStrList = []

mostStrList = []

for n in range(usrCount):
    usrStrList.append(input())

countObj = collections.Counter(usrStrList)
mostedList = countObj.most_common()

for n in range(len(mostedList)):
    if mostedList[0][1] == mostedList[n][1]:
        mostStrList.append(mostedList[n][0])

sortedList = sorted(mostStrList, reverse = False)

for m in range(len(sortedList)):
    print(sortedList[m])

Solution (Python):
input()
d = dict()
while True:
    try:
        s = input()
    except EOFError:
        break
    try:
        d[s] = d[s] + 1
    except KeyError:
        d[s] = 1
m = max(d.values())
d = sorted(d.items(), key=lambda x: x[1], reverse=True)
for i, item in enumerate(d):
    if item[1] < m:
        d = d[:i]
        break
d = sorted(d, key=lambda x: x[0])
for item in d:
    print(item[0])

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip() 
import collections
from operator import itemgetter

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

    counter = collections.Counter(S)

    max_freq = max(counter.values())
    most_freq = [k for k, v in counter.items() if v==max_freq]
    for i in sorted(most_freq):
        print(i)

if __name__ == '__main__':
    resolve()

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

S.sort()


max_count=0
cur_count=1
cur_str=[]
for i in range(N):
  if i==0:
    max_count=1
    cur_count=1
    cur_str=[S[0]]
  else:
    
    if S[i]==S[i-1]:
      cur_count+=1
    else:
      cur_count=1
      
    if max_count<cur_count:
      max_count=cur_count
      cur_str=[S[i]]
    elif max_count==cur_count:
      cur_str+=[S[i]]
  
  
  

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

Solution (Python):

import sys
from collections import Counter


def solve(N: int, S: "List[str]"):
    cnt = Counter()
    for s in S:
        cnt[s] += 1
    
    lst = []
    mx = max(cnt.values())
    for key, val in cnt.items():
        if val == mx:
            lst += [key]

    for word in sorted(lst):
        print(word)
    
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    S = [next(tokens) for _ in range(N)]  
    solve(N, S)

if __name__ == '__main__':
    main()

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

for i in range(n):
    aaa = input()
    if aaa in vote_ls.keys():
        vote_ls[aaa]+=1
    else:
        vote_ls[aaa] = 1

sub_ls = []
'''
max_vote = max(vote_)
for i in range(n):
    if vote_num[i] == max_vote:
        sub_ls.append(vote_ls[i])
sub_ls.sort()
for i in range(len(sub_ls)):
    print(sub_ls[i])
'''
sorted = sorted(vote_ls.items(), key=lambda x:x[1])
sub_ls.append(sorted[-1])
for i in range(len(sorted)-2,-1,-1):
    if sorted[i][1] == sorted[-1][1]:
        sub_ls.append(sorted[i])
    else:
        break

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

Solution (Python):
import collections
N=int(input())
A=[]
for i in range(N):
  a=str(input())
  A.append(a)

S = collections.Counter(A)
T=[]
R=[]
ans=0
T=S.most_common()
T.sort(reverse=True,key=lambda x: x[1])
a=T[0][1]
for i in range(len(T)):
  if T[i][1]==a:
    R.append(T[i][0])
R.sort()
for i in R:
  print(i)

Solution (Python):
import collections

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

counter = collections.Counter(S)
maxcount = max(counter.values())

strs_max = []
for k, v in counter.items():
    if v == maxcount:
        strs_max.append(k)

ans_list = sorted(strs_max)
for a in ans_list:
    print(a)

Solution (Python):
n = int(input())
s = [str(input()) for i in range(n)]
sorted_s = sorted(s)
count = 1
max = 1
ans_list = []
prev = sorted_s[0]
for i in sorted_s[1:]:
    if i == prev:
        count += 1
    else:
        if count > max:
            ans_list = [prev]
            max = count
        elif count == max:
            ans_list.append(prev)
        prev = i
        count = 1
if count > max:
    ans_list = [prev]
elif count == max:
    ans_list.append(prev)
for i in ans_list:
    print(i)

Solution (Python):
n=int(input())
s=[input() for _ in range(n)]
t={}
u=[]
for i in range(n):
    if s[i] not in t.keys():
        t[s[i]]=1
    else:
        t[s[i]]+=1

max=0
for i in t:
    if max<=t[i]:
        max=t[i]
for i in t:
    if max==t[i]:
        u.append(i)
u.sort()
for i in range(len(u)):
    print(u[i])

Solution (Python):
n = int(input())
sen = {}
maxsen = 0
for i in range(n):
    s = input()
    if s not in sen:
        sen[s] = 1
        maxsen = max(maxsen,sen[s])
    else:
        sen[s]+=1
        maxsen = max(maxsen,sen[s])
p = []
for key in sen:
    val = sen[key]
    if val ==  maxsen:
        p.append(key)
p = sorted(p)
for x in p:
    print(x)

Solution (Python):
import collections

N=int(input())
S=[input() for _ in range(N)]
max=0
l=[]
c=collections.Counter(S)
values=list(c.values())
key=list(c.keys())

for i in range(len(key)):
    l.append([key[i],values[i]])

x=sorted(l,key=lambda x:x[0])
x.sort(key=lambda x:x[1],reverse=True)
max=x[0][1]
i=0

while True:
    if (x[i][1]==max):
        print(x[i][0])
        i=i+1
        if i+1>len(x):
            break
    else:
        break

Solution (Python):
n = int(input())
d = {}
for _ in range(n):
    s = input()
    if not s in d:
        d[s] = 1
    else:
        d[s] += 1
d_max = max(d.values())
ans = [k for k, v in d.items() if v == d_max]
for a in sorted(ans):
    print (a)

Solution (Python):
n = int(input())
d = {}
for i in range(n):
    key = input()
    if key in d:
        d[key] += 1
    else:
        d[key] = 1
l = list(d.items())
l = sorted(l, key=lambda x: x[1], reverse=True)

tmp = l[0][1]
tmp2 = l[0][1]
i = 0
ans = []
while tmp == tmp2 and i < len(l):
    ans.append(l[i][0])
    i += 1
    if i < len(l):
        tmp2 = l[i][1]
    else:
        break

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

Solution (Python):
N = int(input())
dct = {}
for i in range(N):
    S = input()
    if dct.get(S) == None:
        dct[S] = 1
    else:
        dct[S] += 1
sortedDct = sorted(dct.items(), key=lambda x: -x[1])
L = []
maxNum = 0
for k, v in sortedDct:
    if (maxNum <= v):
        L.append(k)
        maxNum = v
L.sort()
for l in L:
    print(l)

Solution (Python):
from collections import Counter

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

c = Counter(ss)

max_count = max(c.values())

out_k = []
for k, v in c.items():
  if v == max_count:
    out_k.append(k)
out_k.sort()
for k in out_k:
  print(k)

Solution (Python):
import collections
n = int(input())
vs = collections.Counter()
for i in range(n):
  vs[input()] += 1
j = 0
ans = []
for m in vs.most_common():
  if m[1] >= j:
    j = m[1]
    ans.append(m[0])
for a in sorted(ans):
  print(a)

Solution (Python):
from collections import defaultdict

d = defaultdict(lambda : 0)

n = int(input())
for _ in range(n):
    item = input()
    d[item] += 1

items = sorted(d.items(), key=lambda x: (x[1], x[0]), reverse=True)
c = items[0][1]
l = []
for k, v in items:
    if v < c:
        break
    l.append(k)
if len(l) == 1:
    print(l[0])
else:
    print('\n'.join(l[::-1]))

Solution (Python):



import pdb
import sys
F = sys.stdin

N = int(F.readline().rstrip())
string_count_dict = {}
max = 1
ans = []

for i in range(N):
    s = F.readline().rstrip()
    if s in string_count_dict:
        string_count_dict[s]  += 1
        if max < string_count_dict[s]:
            max = string_count_dict[s]
        continue
    string_count_dict[s] = 1

for st in string_count_dict:
    if string_count_dict[st] == max:
        ans.append(st)

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

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

c = collections.Counter(S)
mc = c.most_common()
max_count = mc[0][1]

lst = []

for x, y in mc:
    if y == max_count:
       lst.append(x)
    
for z in sorted(lst):
    print(z)

Solution (Python):



from operator import itemgetter




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

s.sort()


wks = s[0]
cnt = 1
strmap = list()
for i in range(1, n):
    
    if wks != s[i]:
        wklist = list()
        wklist.append(wks)
        wklist.append(cnt)
        strmap.append(wklist)

        
        wks = s[i]
        cnt = 1
    else:
        cnt = cnt + 1

wklist = list()
wklist.append(wks)
wklist.append(cnt)
strmap.append(wklist)

strmap.sort(key=itemgetter(1), reverse=True)


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

Solution (Python):
n = int(input())
dict={}
while n > 0:
    s = input()
    if s in dict.keys():
        dict[s] = dict[s] + 1
    else:
        dict[s]=1
    n = n - 1
maxnum = 0
for v in dict.values():
    if v > maxnum:
        maxnum = v
a=[]
for k,v in dict.items():
    if v == maxnum:
        a.append(k)
a.sort()
for s in a:
    print(s)

Solution (Python):
from collections import defaultdict
from collections import OrderedDict
N = int(input())
ans = dict()
for _ in range(N):
    k = str(input())
    if k in ans:
        ans[k]+=1
    else:
        ans.update({k:1})
groupedByValue = defaultdict(list)
for key, value in sorted(ans.items()):
    groupedByValue[value].append(key)
l = groupedByValue[max(groupedByValue)]
for i in l:
    print(i)

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

c = collections.Counter(l)
result = c.most_common()

m = 0
ans = []
for i in result:
    if i[1]<m:
        break
    else:
        ans.append(i[0])
        m = i[1]

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

Solution (Python):
import collections

n = int(input())
a = [input() for _ in range(n)]
c = collections.Counter(a)
num = max(c.values())
keys = [k for k, v in c.items() if v == num]
keys.sort()
for i in range(len(keys)):
  print(keys[i])

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

s = {}

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

sorted_s = sorted(s.items(), key=lambda x:x[1], reverse=True)
max_v = sorted_s[0][1]
ans = []
for i in range(len(sorted_s)):
    if max_v == sorted_s[i][1]:
        ans.append(sorted_s[i][0])
    else:
        break
ans.sort()
for a in ans:
    print(a)

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

d={}
maxN=0
for i in range(N):
  k = input()
  if k in d:
    d[k] += 1
  else:
    d[k]=1
  maxN = max(d[k], maxN)

s = []
for k,v in d.items():
  if maxN==v:
    s.append(k)
s=sorted(s)
for _ in s:
  print(_)

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

for i in range(N):
  S[i]=input()
S.sort()
A={}
B=set()
for i in range(N):
  if S[i] in B:
    A[S[i]]=A[S[i]]+1
  else:
    A[S[i]]=1
    B.add(S[i])


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

flag=slist[0][1]
x=[]
for i in range(len(B)):
  if slist[i][1]<flag:
    break
  x.append(slist[i][0])
x.sort()
for i in x:
  print(i)

Solution (Python):
import collections

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

moji_count = collections.Counter(moji)
max_kv = max(moji_count.items(), key=lambda x: x[1])

max_moji = []
for i, j in moji_count.items():
    
    if j==max_kv[1]:
        max_moji.append(i)

max_sort = sorted(max_moji)
for i in max_sort:
    print(i)

Solution (Python):
N = int(input())
S = {}
for i in range(N):
  Si = input()
  if S.setdefault(Si, 0) == 0:
    S[Si] = 1
  else:
    S[Si] += 1
S_sorted = sorted(S.items(), key=lambda x:-x[1])
anslist = []
for s in S_sorted:
  if s[1] < S_sorted[0][1]:
    break
  anslist.append(s)
anslist.sort()
for s in anslist:
  print(s[0])

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

maxi = 0
for _ in range(n):
    s = input()
    if s not in d:
        d[s] = 1
    else:
        d[s] += 1
    maxi = max(maxi, d[s])
    
max_k_list = [kv[0] for kv in d.items() if kv[1] == maxi]



max_k_list.sort()
for v in max_k_list:
    print(v)

Solution (Python):
import collections

n = int(input())

strs = [ input() for _ in range(n) ]

cntr = collections.Counter(strs)

maxvalue = 0
ans = []
for st, num in cntr.most_common():
    if maxvalue <= num:
        ans.append(st)
        maxvalue = num
    else:
        break

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

Solution (Python):
from collections import defaultdict
from collections import OrderedDict
N = int(input())
ans = dict()
for _ in range(N):
    k = str(input())
    if k in ans:
        ans[k]+=1
    else:
        ans.update({k:1})
groupedByValue = defaultdict(list)
for key, value in sorted(ans.items()):
    groupedByValue[value].append(key)
l = groupedByValue[max(groupedByValue)]
for i in l:
    print(i)

Solution (Python):
from itertools import takewhile
n = int(input())
d = {}
for _ in range(n):
    s = input()
    d[s] = d.get(s, 0) + 1

m = max(d.values())
ss = filter(lambda x: d[x] == m, d)
for s in sorted(ss):
    print(s)

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

m=max(D.values())
d=list(D.values())
k=list(D.keys())
ans=[]
for i in range(len(D)):
    if m==d[i]:
        ans.append(k[i])

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

Solution (Python):

from collections import defaultdict
def resolve():
    N = int(input())
    S = [input() for _ in range(N)]
    
    res = defaultdict(int)

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

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

    max_k_list.sort()
    for k in max_k_list:
        print(k)


if __name__ == "__main__":
    resolve()

Solution (Python):
from collections import Counter
def main():
  n = int(input())
  s = [input() for _ in range(n)]
  s_c = Counter(s)
  s_c_l = [c for c in s_c.items()]
  m = max([c[1] for c in s_c_l])
  s_c_l_max = [c[0] for c in s_c_l if c[1] == m]
  s_c_l_max_s = set(s_c_l_max)
  s_c_l_max_s = sorted(s_c_l_max_s)
  for ch in s_c_l_max_s:
    print(ch)
  
main()

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

dict={}
for str in lst:
    if str in dict:
        dict[str]+=1
    else:
        dict[str]=1

max_value=max(dict.values())
ans=[k for k,v in dict.items() if v==max_value]
ans.sort()
[print(ans[i]) for i in range(len(ans))]

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

S_ = {}
for a in S:
  if a not in S_:
    S_[a] = 1
  else:
    S_[a] += 1

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


max_ = 0
a = []
for i in range(len(S_)):
  
  if S_[i][1] >= max_:
    max_ = S_[i][1]
    
    a.append(S_[i][0])
  else:
    break
a =sorted(a)
print(*a)

Solution (Python):
from collections import Counter
n = int(input())
l = []
for i in range(n):
  s = input()
  l.append(s)

c = Counter(l)
max_n = c.most_common()[0][1]

out = []
for key, val in c.items():
  if val == max_n:
    out.append(key)
for o in sorted(out):
  print(o)

Solution (Python):

N=int(input())
d={}
for i in range(N):
    k=input()
    d[k]= d[k]+1 if k in d else 1
dd=sorted(d.items(),key=lambda x:x[1])  
max_k=max(d,key=d.get)
max_v=d[max_k]
keys=[k for k,v in d.items() if v==max_v]
kk=sorted(keys)
for i in kk:
    print(i)

Solution (Python):
import collections
N=int(input())
S=[0 for i in range(N)]
for i in range(N):
  S[i]=str(input())
c = collections.Counter(S)
p=max(c.values())
T=[]
for i in c:
  if c[i]==p:
    T.append(i)
T=sorted(T)
for i in range(len(T)):
  print(T[i])

Solution (Python):
import collections
n = int(input())
l=[input() for i in range(n)]
ans = []
cnt=0
c = collections.Counter(l)
for i in c.most_common():
    if i[1] >= cnt:
        ans.append(i[0])
        cnt = i[1]
ans.sort()
for j in ans:
    print(j)

Solution (Python):
n=int(input())
a=[]
d={}
b=0
m=0
for i in range(n):
    s=input()
    try:
        a[d[s]][1]+=1
    except:
        d[s]=b
        a.append([s,1])
        b+=1
    m=max(m,a[d[s]][1])
a.sort()
for i in range(len(a)):
    if a[i][1]==m:
        print(a[i][0])

Solution (Python):
import collections
S=collections.Counter([input() for _ in range(int(input()))]).most_common()
m=S[0][1]
L=[]
for s in S:
  if s[1]==m:L.append(s[0])
for l in sorted(L):print(l)

Solution (Python):
import collections

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



c = collections.Counter(l)
m=c.most_common()[0][1]
a=[]
values, counts=zip(*c.most_common())
for value, count in zip(values, counts):
    if count==m:
        a.append(value)
a=sorted(a)
for b in a:
    print(b)

Solution (Python):
import sys
from io import StringIO
import unittest

def resolve():
    n=int(input().strip())
    ls=[]
    for i in range(n):
        ls.append(input().strip())
    
    d={}

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

    saidai=0
    for k in d.keys():
        if d[k] > saidai:
            saidai=d[k]

    l=[]

    for k in d.keys():
        if d[k] == saidai:
            l.append(k)

    l.sort(reverse=False)

    for p in l:
        print(p)
        
resolve()

Solution (Python):
import sys





import time


mod = int(1e9+7)
INF = 1<<29

def main():
    n = int(input())
    s = []
    for i in range(n):
        s.append(input())
    s.sort()
    ans = []
    num = 0
    count = 1
    for i in range(1,n):
        if s[i] == s[i-1]:
            count += 1
        else:
            if count > num:
                ans = [s[i-1]]
            elif count == num:
                ans.append(s[i-1])
            num = max(num,count)
            count = 1
        if i == n - 1:
            if count > num:
                ans = [s[i]]
            elif count == num:
                ans.append(s[i])
    for a in ans:
        print(a)
    return

if __name__=='__main__':
    main()