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 numpy as np
import collections

n = int(input())

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

c = collections.Counter(s)

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

max = c_sort[0][1]
max_list = []

for it in c_sort:
    if (it[1] == max):
        max_list.append(it[0])   
max_list.sort()
for list in max_list:
    print(list)

Solution (Python):
import collections

N = int(input())
S_list = []
for i in range(N):
  S_list.append(input())
c = collections.Counter(S_list)
most_count = c.most_common()[0][1]

ans_list = []
for i in c.items():
  if i[1] == most_count:
    ans_list.append(i[0])

ans_list.sort()

for i in ans_list:
  print(i)

Solution (Python):
import collections

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

c = collections.Counter(S)
max = c.most_common()[0][1]
ans = [i[0] for i in c.items() if i[1] == max]
ans.sort()

for s in ans:
    print(s)

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

count=1
counts=[]
max=0
top_number=[]
for i in range(n-1):
  if s[i]==s[i+1]:
    count+=1
  if i==n-2 and s[i]==s[i+1]:
    counts.append(count)
    if max<count:
      max=count
      top_number=[i]
    elif max==count:
      top_number.append(i)
  if i==n-2 and s[i]!=s[i+1]:
    counts.append(count)
    if max<count:
      max=count
      top_number=[i]
    elif max==count:
      top_number.append(i)
    if max==1:
      top_number.append(i+1)
  elif s[i]!=s[i+1]:
    counts.append(count)
    if max<count:
      max=count
      top_number=[i]
    elif max==count:
      top_number.append(i)
    count=1


for i in range(len(top_number)):
  print(s[top_number[i]])

Solution (Python):
import collections
def main(input_s):
    c = collections.Counter(input_s)
    c_sort = c.most_common(1)
    max_count = c_sort[0][1]
    out_result = []
    for key, value in c.items():
        if value==max_count:
            out_result.append(key)
    return out_result

if __name__ == '__main__':
    N = int(input()) 
    s = [input() for i in range(N)] 
    huga = main(s)
    huga = sorted(huga)
    for i in huga:
        print(i)

Solution (Python):
import collections
n = int(input())
s = [input() for i in range(n)]
p = collections.Counter(s)
res = sorted(p.items(), key=lambda x: x[1],reverse = True)
 
keys = []

u = max(p.values())
for i,m in res:
  if(m == u):
    keys.append(i)
  else:
    break
keys=sorted(keys)
for i in range(len(keys)):
  print(keys[i])

Solution (Python):
import bisect

n = int(input())
sl = ['']*n
for i in range(n):
    sl[i] = input()
sl = sorted(sl, key=str.lower)

c = 0
anss = []
max_n = 0
for i, t in enumerate(sl):
    if i == 0:
        c += 1
        target = t
        continue

    if t == target:
        c += 1
    else:
        if max_n < c:
            anss = []
            anss.append(target)
            max_n = c
        elif max_n == c:
            anss.append(target)
            max_n = c
        target = t
        c = 1

if max_n < c:
    anss = []
    anss.append(t)
elif max_n == c:
    anss.append(t)


print(*anss)

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

S = list(str(input()) for i in range(n))
SortedS = sorted(S) 
s = [] 
S2 = [] 
count = 1
for i in range(n - 1):
    if i == n - 2 and SortedS[i] != SortedS[i + 1]:
        s.append(count)
        s.append(1)
        S2.append(SortedS[i])
        S2.append(SortedS[i + 1])
    
    else:
        if SortedS[i] == SortedS[i + 1]:
            count += 1
            if i == n - 2:
                s.append(count)
                S2.append(SortedS[i])
        else:
            s.append(count)
            S2.append(SortedS[i])
            count = 1

M = max(s)
for i in range(len(s)):
    if s[i] == M:
        print(S2[i])

Solution (Python):
from collections import Counter
n = int(input())
sList = [input() for _ in range(n)]
c = Counter(sList).most_common()
ans = []
for i in range(len(c)):
    if c[i][1] == c[0][1]:
        ans.append(c[i][0])
    else:
        break
ans.sort()
print("\n".join(ans))

Solution (Python):
N = int(input())
dp = {}
max_num = 0
max_list =[]
for i in range(N):
    S = input()
    if S in dp:
        dp[S] += 1
    else:
        dp[S] = 1
    if dp[S] == max_num:
        max_list.append(S)
    elif dp[S] > max_num:
        max_list = [S]
        max_num = dp[S]
max_list.sort()
for s in max_list:
    print(s)

Solution (Python):
import collections
def resolve_c():
    n = input()
    s_l = [input() for i in range(int(n))]
    c = collections.Counter(s_l)
    values, counts = zip(*c.most_common())
    results = sorted(list(values[:collections.Counter(counts)[max(counts)]]))
    fin = [print(r) for r in results]
resolve_c()

Solution (Python):
from itertools import groupby
from operator import itemgetter
 
a = sorted(input() for _ in range(int(input())))
a = sorted((-len(list(g)), s) for s, g in groupby(a))
for _, s in next(groupby(a, itemgetter(0)))[1]:
  print(s)

Solution (Python):
n = int(input())
s = []
for i in range(n):
  s.append(input())
s.sort()
k = 0
f = s
maxk = 0
for i in range(n-1):
  if s[i] == s[i+1]:
    k = k+1
    if k == maxk :
      maxk = k
      f.append(s[i])
    elif k > maxk :
      maxk = k
      f = [s[i]]
  else:
    k = 0
for i in range(len(f)):
  print(f[i])

Solution (Python):
n = int(input())
s = [input() for _ in range(n)]
s.sort()
p = [s[0]]
k = [1]
for i in range(1,len(s)):
    if s[i] != s[i-1]:
        p.append(s[i])
        k.append(1)
    else: k[-1] += 1
max_k = max(k)
for i in range(len(p)):
    if k[i] == max_k:
        print(p[i])

Solution (Python):
from itertools import groupby
from operator import itemgetter
 
a = sorted(input() for _ in range(int(input())))
a = sorted((-len(tuple(g)), s) for s, g in groupby(a))
for _, s in next(groupby(a, itemgetter(0)))[1]:
  print(s)

Solution (Python):
def main():
    n = int(input())
    words = {}
    for _ in range(n):
        a = input()
        if a in words:
            words[a] += 1
        else:
            words[a] = 1
    max_val = 0
    results = []
    for i in words.keys():
        if words[i] > max_val:
            max_val = words[i]
            results = []
            results.append(i)
        elif words[i] == max_val:
            results.append(i)

            
            
            
    results.sort()
    print('\n'.join(map(str, results)))


if __name__ == "__main__":
    main()

Solution (Python):
import collections
 
n = int(input())
st = [input() for i in range(n)]
 
c = collections.Counter(st)
c.most_common()
c_val, c_key= zip(*c.most_common()) 
c_key,c_val = list(c_val),list(map(int,c_key))
counter = 0
res = []
if len(c_val) == 1:
  print(c_key[0])
else:
  for i in range(len(c_val)):
    if c_val[i] >= counter:
      counter = c_val[i]
      res.append(c_key[i])
  res = list(set(res))
  res.sort()
  
  for i in range(len(res)):
    print(res[i])

Solution (Python):
import collections
from sys import stdin


def get_result(data):
    N, S = data[0], data[1:]
    c = collections.Counter(S)
    max_count = max(c.values())
    output_s = [key for key, val in c.items() if val == max_count]
    output_s = sorted(output_s)
    return '\n'.join(output_s)

if __name__ == '__main__':
    raw_data = [val.rstrip('\n') for val in stdin.readlines()]
    data = [val for val in raw_data]
    result = get_result(data)
    print(result)

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

max_count = 0
max_str = []
for s, count in S.items():
    if count > max_count:
        max_count = count
        max_str = [s]
    elif count == max_count:
        max_str.append(s)

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

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

L = {}

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

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

S = []
c = L[0][1]
for i in range(len(L)):
    if c == L[i][1]:
        S.append(L[i][0])
    else:
        break
S = sorted(S)
for s in S:
    print(s)

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

hashs = {}

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

maxs = 0
for key, value in hashs.items():
    maxs = max(maxs, value)

res = []
for key, value in hashs.items():
    if value == maxs:
        res.append(key)
res.sort()
for m in range(len(res)):
    print(res[m])

Solution (Python):
import collections

words = []
number = int(input())
for i in range(number):
    word = input()
    words.append(word)
new = collections.Counter(words)
most = max(new.values())
ans = new.most_common()
answer = []
for i in ans:
    if i[1] >= most:
        answer.append(i[0])
    else:
        pass
answer.sort()
for i in answer:
    print(i)

Solution (Python):
import collections
from collections import Counter
N= int(input())
S = []
for _ in range(N):
    S.append(input())
SS = Counter(S)    
Svalues = list(Counter(S).values())
SSS = max(Svalues)

keys = [k for k, v in SS.items() if v == SSS]
keys.sort()
X = len(keys)
for i in range (X):
   print(keys[i])

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

ans = {}
m = 1
for _ in range(N):
    w = input()
    c = ans.get(w)
    
    
    if c == None:
        ans[w] = 1
    else:
        ans[w] = c + 1
        if c + 1 > m:
            m = c + 1


tmp = []
for a in ans:
    if ans[a] == m:
        tmp.append(a)

tmp.sort()
for t in tmp:
    print(t)

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

max_val = max(A.values())
keys = [key for key in A if A[key] == max_val]
keys.sort()
for s in keys:
  print(s)

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

dic = {}

for i in range(N):
	key = input()
	if key not in dic:
		dic[key] = 1
	else:
		dic[key] +=1

maxnum = max(dic.values())



keys = list(dic.keys())
for key in sorted(keys):
	if dic[key] == maxnum:
		print(key)

Solution (Python):
import collections as cl
from operator import itemgetter, attrgetter
n = int(input())
s = []
for i in range(n):
    s.append(input())
h = cl.Counter(s)
itm = h.items()

m = max(list(h.values()))

mfil = list(filter(lambda x:x[1]==m ,itm))
mfil = sorted(mfil,key=itemgetter(0))
for j in mfil:
    print(j[0])

Solution (Python):
from collections import defaultdict

H=int(input())
d = defaultdict(int)
for _ in range(H):
    d[input()] += 1
max_appeard=max(d.items(), key=lambda x: x[1])[1]
ans=[k for k,v in d.items() if v == max_appeard]
ans.sort()
for item in ans:
  print (item)

Solution (Python):
from collections import Counter
N = int(input())
arr = []
arr_max = []
for i in range(N):
    arr.append(input())
dic = Counter(arr)
inverse = [(value, key) for key, value in dic.items()]
max_s = max(inverse)[0]
for key,value in dic.items():
    if value == max_s: 
        arr_max.append(key)
    else: continue
for j in sorted(arr_max): print (j)

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


max_letter = []
max_count = 0
tmp_S = S[0]
count = 0

for i in range(len(S)):
  if i == 0:
    count=1
    max_letter.append(S[i])
    tmp_S = S[i]
  elif tmp_S != S[i]:
    if max_count < count:
      max_count = count
      max_letter = []
      max_letter.append(tmp_S)
    elif max_count == count:
      max_letter.append(tmp_S)
    tmp_S = S[i]
    count=1
  else:
    count+=1
if max_count < count:
  max_letter = list([tmp_S])
elif max_count == count:
  max_letter.append(tmp_S)
  
for i in range(len(max_letter)):
  print(max_letter[i])

Solution (Python):
def main():
	
	n = int(input())
	l = [str(input()) for i in range(n)]
	
	import collections

	c = collections.Counter(l)
	lc = sorted(list(c.items()), key = lambda x:x[1] , reverse = True)
	
	ans = []
	checker = 0
	i = 0
	while checker == 0 and i < len(lc):
		if lc[i][1] == lc[0][1]:
			ans.append(lc[i][0])
		else:
			checker += 1
		i += 1

	
	
	
	
	
	ans.sort()
	print('\n'.join(map(str, ans)))

	
	
 
if __name__ == '__main__':
	main()

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)
j = groupedByValue[max(groupedByValue)]
for i in j:
    print(i)

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

for i in lst :
    if i in dic.keys() :
        dic[i] += 1
    else :
        dic[i] = 1

dic = sorted(dic.items(), key=lambda x:x[1], reverse=True)
result = [dic[0][0]]
if len(dic) > 1 :
    for j in range(n-1) :
        if dic[j][1] == dic[j+1][1] :
            result += [dic[j+1][0]]
        else :
            break

result = sorted(result)
for k in result :
    print(k)

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

c=1
m=0
for i in range(n-1):
  if s[i]==s[i+1]:
    c+=1
  else:
    if c > m:
      ans=[s[i]]
      m=c
      c=1
    elif c==m:
      ans.append(s[i])
      c=1
    else:
      c=1
if c > m:
  ans=[s[n-1]]
elif c==m:
   ans.append(s[n-1])
for i in range(len(ans)):
  print(ans[i])

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 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 = input()
mylist = []
for i in range(0, int(n)):
    val = input()
    mylist.append(val)

c = collections.Counter(mylist)
ma = c.most_common()[0][1]
ans = []
for target_list in c.items():   
    if target_list[1] == ma:
        ans.append(target_list[0])

ans.sort()

for target_list in ans:
    print(target_list)

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

ans = [dic[0][0]]

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

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

Solution (Python):

N = int(input())
S = [str(input()) for i in range(N)]
S = sorted(S)
count = 1
tmpcount = 1
DP = [S[0]]
for i in range(1,N):
    if S[i] == S[i-1]:
        count += 1
        if tmpcount < count:
            DP.clear()
            DP.append(S[i])
            tmpcount = count
        elif tmpcount == count:
            DP.append(S[i])
        else:
            pass
    else:
        count = 1
        if tmpcount == count:
            DP.append(S[i])
        else:
            pass

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

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

from collections import defaultdict
dic = defaultdict(int)

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

k = {}
k = [key for m in [max(dic.values())] for key,val in dic.items() if val == m]
k.sort()
for i in k:
  print(i)

Solution (Python):
a=int(input())
li={}
while(a):
    a=a-1
    b=input()
    if b in li:
        li[b]+=1
    else:
        li[b]=1
m = max(li.values())
l=[]
for t in li:
    if m==li[t]:
        l.append(t)
l=sorted(l)
for y in l:
    print(y)

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


keys = [k for k, v in dic.items() if v == max]
print(("\n").join(sorted(keys)))

Solution (Python):
n=int(input())
memo={}
for i in range(n):
  s=input()
  if s not in memo:
    memo[s]=1
  else:
    memo[s]+=1
    
a=[]
max_v = max(memo.values())
for k, v in memo.items():
  if v==max_v:
    a.append(k)
print('\n'.join(sorted(a)))

Solution (Python):
from collections import Counter


N=int(input())
l=['']*N
for i in range(N):
    l[i]=input()

l.sort()

c=1
c_crt=1
pre=""
ans=[]
for e in l+[""]:
    if e == pre:
        c_crt+=1
    else:
        if c_crt > c:
            ans=[pre]
            c=c_crt
        elif c_crt == c:
            ans.append(pre)
        c_crt=1
    pre=e
for e in ans:
    print(e)

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())
dic = sorted(dic, key=lambda x: -x[1])
dic.append(('_', 0))
for i in range(n):
    if dic[i][1] == dic[i + 1][1]:
        print(dic[i][0])
    else:
        print(dic[i][0])
        break

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

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

dic = sorted(S)

i = 0
while i < N-1:
    j = 0
    while i+j+1 < N and dic[i+j] == dic[i+j+1]:
        j += 1
    num[i] = j
    i += j + 1

flag = 1
for i in range(N):
    if flag == 1:
        if num[i] > 0:
            Max = num[0]
            flag = 0
    if flag == 0:
        if num[i] >= Max:
            Max = num[i]

i = 0
while i < N:
    if num[i] == Max:
        print(dic[i])
    i += num[i] + 1

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

P=collections.Counter(S)

y=max(P.values())
A = [k for k, v in P.items() if v == y]

A.sort()

for List in A:
    print(List)

Solution (Python):
import collections

N=int(input())
data=[input() for i in range(N)]
c = collections.Counter(data)
score=c
com=c.most_common()

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

val=score_sorted
L=len(val)
count="Yes"
ii=0
ansa=1
if L==1:
    print(val[0][0])
else:
    while count=="Yes":
        if val[ii][1]==val[ii+1][1]:
            ii+=1

            ansa+=1
            if ii == L-1:
                break
        else:
            count="No"
    data2=[]
    for i in range(ansa):
        data2.append(val[i][0])

    data2.sort()
    for i in range(ansa):
        print(data2[i])

Solution (Python):
n=int(input())
d={}
for i in range(n):
    tmp = input()
    if tmp in d:
        d[tmp]+=1
    else:
        d[tmp]=1
max_k_list=[]
max_d = max(d.values())
for k,v in d.items():
    if v == max_d:
        max_k_list.append(k)
max_k_list.sort()
for i in max_k_list:
    print(i)

Solution (Python):
n = int(input())
candidates = {}
for i in range(n):
    now = input()
    if now in candidates:
        candidates[now] += 1
    else:
        candidates[now] = 1
winners = []
max_poll = 0
for key in candidates:
    if candidates[key] > max_poll:
        max_poll = candidates[key]
for key in candidates:
    if candidates[key] == max_poll:
        winners.append(key)
winners.sort()
for winner in winners:
    print(winner)

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
import sys
input = sys.stdin.readline
num = int(input())
word_list = []
for i in range(num):
    word_list.append(input())
word_dict = collections.Counter(word_list)
most_common = word_dict.most_common()[0][1]
word_list = [k for k,v in word_dict.items() if v == most_common]
word_list.sort()
for word in word_list:
    print(word)

Solution (Python):
import collections
N=int(input())
S=[]
for i in range(N):
  s=str(input())
  S +=[s]
T=collections.Counter(S)
answer=T.most_common()
A=[]
for i in range(len(T)):
  if answer[i][1]==answer[0][1]:
    A +=[answer[i][0]]
  else:
    break
A=sorted(A)
for a in A:
  print(a)

Solution (Python):
N = int(input())
a = [input() for i in range(N)]
a.sort()
b = [0] * N
flag = 1
cc = 0
bef = 132
c = 1
for i in range(N):
    if a[i] == bef:
        c = c + 1
    else:
        c = 1
    bef = a[i]
    b[i] = c
    if flag == 1:
        max = c
        flag = 0
    if c > max:
        max = c
        
for i in range(N):
    if b[i] == max:
        print(a[i])

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

dic=dict()
for i in range(n):
  s=input()
  if s not in dic:
    dic[s]=1
  else:
    dic[s]+=1
a=(max(dic, key=dic.get))
b=dic[a]
keys = [k for k, v in dic.items() if v == b]
keys.sort()

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

Solution (Python):
from collections import Counter
def solve():
    n = int(input())
    c = Counter(input() for _ in range(n))
    t = c.most_common()[0][1]
    ans = []
    for a in c.most_common():
        if a[1] != t:
            break
        ans.append(a[0])
    print(*sorted(ans), sep="\n")
solve()

Solution (Python):
n = int(input())
vote = dict()
for i in range(n):
  s = input()
  if s not in vote.keys():
    vote[s] = 0
  else:
    vote[s] += 1

res = []
mx = max(vote.values())
for key, value in vote.items():
    if value== mx:
        res.append(key)

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

Solution (Python):
def poll(arr):
    ans_h = {}
    for ele in arr:
        if ele in ans_h.keys():
            ans_h[ele] += 1
        else:
            ans_h[ele] = 0
    max_v = max(ans_h.values())
    mkv = [kv for kv in ans_h.items() if kv[1] == max_v]
    for ele in sorted(mkv):
        print(ele[0])

if __name__ == "__main__":
    n = int(input())
    arr = [input() for _ in range(0, n)]
    poll(arr)

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

d = {}
for i in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1
max_d = max(d.values())
max_d_list = [kv[0] for kv in d.items() if kv[1] == max_d]

ans = sorted(max_d_list)

for i in ans:
    print(i)

Solution (Python):
import numpy as np

num = int(input())

words = []
for _ in range(num):
    words.append(input())

words = tuple(words)

d = {}
for word in words:
    if word in d:
        d[word] += 1
    else:
        d[word] =1



keys = np.array([a[0] for a in d.items()])


values = np.array([a[1] for a in d.items()])


keys_of_max_val = keys[values == values.max()]

keys_of_max_val.sort()

print('\n'.join(keys_of_max_val))

Solution (Python):
n=int(input())
import collections
d=collections.defaultdict(int)
for i in range(n):
    d[input()]+=1
m=0
ans=[]
for i,j in d.items():
    if j>m:
        ans=[i]
        m=j
    elif j==m:
        ans.append(i)
ans.sort()
for i in ans:
    print(i)

Solution (Python):
n = int(input())
s = []
for _ in range(n):
    s.append(input())
import collections
s1 = collections.Counter(s)
x = max(s1.values())
key = [k for k,v in s1.items() if v == x]
s2 = sorted(key)
ans = '\n'.join(s2)
print(ans)

Solution (Python):
n = int(input())
S = []
for _ in range(n):
    S.append(input())
d = {}

for _ in S:
    d[_]=0

for _ in S:
    d[_]+=1

max_ = max(d.values())

_sorted = sorted(d.items(), key=lambda x:x[0])
for _ in _sorted:
    if _[1]== max_:
        print(_[0])

Solution (Python):
n = int(input())
s_list = []
import collections

for i in range(n):
    s_list.append(input())

s_dict = collections.Counter(s_list)
maxv = max(s_dict.values())

keys = [k for k,v in s_dict.items() if v == maxv]
keys.sort()
for i in range (len(keys)):
    print(keys[i])

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

numbers = dict()
maxval = 1
for val in s:
    if val in numbers:
        if maxval == numbers[val]:
            maxval = maxval + 1
        numbers[val] += 1
    else:
        numbers[val] = 1

ret = [kv[0] for kv in numbers.items() if kv[1] == maxval]
for v in sorted(ret):
    print(v)

Solution (Python):
N=int(input())
a=[]
b=0
for i in range(N):
	a.append(input())
d={}
sor={}
for i in range(N):
    if a[i] in d.keys():
        d[a[i]]+=1
    else:
        d.setdefault(a[i],1)
        b+=1
sod = sorted(d.keys())

maxval=0
for i in range(N):
    if maxval<=d[a[i]]:
        maxval=d[a[i]]
for i in range(b):
    if maxval==d[sod[i]]:
        print(sod[i])

Solution (Python):
import collections

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

for i in range(N):
  tmp = input()
  S.append(tmp)
  
c = collections.Counter(S)

d = c.most_common()

max_ = d[0][1]

for i,k in enumerate(d):
  if d[i][1] == max_:
    solution.append(d[i][0])
    
solution.sort()

for i in solution:
  print(i)

Solution (Python):
import collections as cl
ans = []
n = int(input())
list1 = []
for x in range(n): 
  list1.append(input())

clist = cl.Counter(list1)
max = max(clist.values())
citem =list(clist.items())
for y in citem:
    if y[1] == max:
      ans.append(y[0])

ans = sorted(ans)

for l in ans:
  print(l)

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

c = collections.Counter(S_list)

d = c.most_common() 

keys = [k for k, v in c.items() if v == d[0][1]]

keys = sorted(keys)

for i in keys:
  print(i)

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())
data_list = [input() for i in range(n)]
data_list.sort()

count_dict = collections.Counter(data_list)

max_val = max(count_dict.values())
max_keys = [key for key in count_dict if count_dict[key] == max_val]

max_keys.sort()

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

Solution (Python):
from collections import Counter

def poll(N, S):
  take = []
  counted = Counter(S)
  mode = max(counted.values())
  for i, value in counted.items():
    if value == mode:
      take.append(i)
  newtake = sorted(take)
  for i in range(len(take)):
    print(newtake[i])

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

Solution (Python):
from collections import Counter
N=int(input())
S=list()
Y=list()
for i in range(N):
    S.append(input())
X=Counter(S)
F=X.most_common()[0][1]
keys = [k for k, v in X.items() if v == F]
keys.sort()
for i in range(len(keys)):
    print(keys[i])

Solution (Python):
import collections
import itertools

n = int(input())
l = [input() for _ in range(n)]
counter = collections.Counter(l)

mode_v = counter.most_common()[0][-1]
it = itertools.takewhile(
    lambda kv: kv[-1] == mode_v, counter.most_common()
)

l2 = list((k for k, v in it))
l2.sort()
print(*l2)

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

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

d = {}
for x in S:
    if x in d:
        d[x] += 1
    else:
        d.setdefault(x, 1)

d_sorted = sorted(d.items(), key=lambda x:x[1], reverse=True)
count = d_sorted[0][1]
result = []

for x in d_sorted:
    if x[1] == count:
        result.append(x[0])

result.sort()

for z in result:
    print(z)

Solution (Python):
import collections
from operator import itemgetter

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

s = collections.Counter(S)

ss = list(s.items())

maxint = s.most_common()[0][1]
s3 = sorted(ss, key=itemgetter(0))
s4 = sorted(s3, key=itemgetter(1), reverse=True)


count = 0
for i in range(N):
    if(s4[i][1] == maxint):
        print(s4[i][0])
        count += s4[i][1]
        if(N==count):
            break
    else:
        break

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

mn = max(S.values())
for letter, count in sorted(S.most_common()):
    if(count==mn):
        print(letter)

Solution (Python):
import sys
input = sys.stdin.readline
from collections import defaultdict
N, = map(int, input().split())
d = defaultdict(int)
for _ in range(N):
    s = input().strip()
    d[s] += 1
mx = 0
for k in d:
    mx = max(d[k], mx)
rs = set()
for k in d:
    if d[k] == mx:
        rs.add(k)
rs = list(rs)
rs.sort()
for r in rs:
    print(r)

Solution (Python):
n=int(input())
dic={}
for i in range(n):
  a=input()
  if a not in dic.keys():dic[a]=1
  else:dic[a]+=1
max_value=max(dic.values())
dic_max=[k for k, v in dic.items() if v==max_value]
dic_s=sorted(dic_max)
[print(i) for i in dic_s]

Solution (Python):
N = int(input())
Dict = {}
List = []

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

Max = max(list(Dict.values()))
for i in list(Dict.items()):
    if i[1]>=Max:
        List.append(i[0])
for i in sorted(List):
    print(i)

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

dic_={}
n = 1

for i in range(N):
    a = input()
    if a in dic_.keys():
        b = dic_.get(a) + 1
        dic_.update({a: b})
        if n < b:
            n = b
    else:
        dic_.update({a: 1})

ANS = []

for i in dic_:
    if dic_.get(i) == n:
        ANS += [i]

ANS = sorted(ANS)

for key in ANS:
        print(key)

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

for i in range(n):
    tmp = input()
    
    if tmp in d :
        d[tmp] += 1
    else :
        d[tmp] = 1

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

num = 0
l =[]
for k in sd:
    if k[1] < num:
        break
    num = k[1]
    l.append(k[0])

l.sort()

for n in l:
    print(n)

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

li={}
an=[]
ma=0

for i in range(n):
    t=input()
    if t in li:
        li[t]+=1
    else:
        li[t]=1

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

ma=li2[0][1]

for j in range(n):
    if li2[j][1]==ma:
        an.append(li2[j][0])
        
        if len(li2)==j+1:
            break
    else:
        break

an.sort()
 
for k in range(len(an)):
    print(an[k])

Solution (Python):
import collections

n = int(input())
a = []
max_list = []
max_i = 1

a = [str(input()) for x in range(n)]

c = collections.Counter(a)
c = c.most_common()
max_i = c[0][1]

for i in range(len(c)):
    if max_i == c[i][1]:
        max_list.append(c[i][0])
    else:
        break

max_list.sort()

for i in max_list:
    print(i)