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):
from functools import reduce

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

for i, s in enumerate(S):
    if s in s_map:
        s_map[s] += 1
    else:
        s_map[s] = 1

s_list = list(s_map.items())
s_list.sort(key=lambda x:x[1], reverse=True)
max_num = s_list[0][1]
res = list(filter(lambda item: item[1] == max_num, s_list))
res.sort(key=lambda x: x[0], reverse=False)
for i, item in enumerate(res):
    print(item[0])

Solution (Python):
import collections

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

c = collections.Counter(S)
d = c.most_common()
d = d + [("test", 0)]
e = list()

e.append(d[0][0])

for j in range(N):
  if d[j][1] == d[j+1][1]:
    e.append(d[j+1][0])
  else:
    break

f = sorted(e)

for k in range(len(f)):
  print(f[k])

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

s = collections.Counter(s).most_common()
mx = s[0][1]

ans = []
for k, v in s:
    if mx == v:
        ans.append(k)


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

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

max=d[0][1]

A=[]
for i in d:
  if i[1]==max:
    A.append(i[0])
print(*sorted(A),sep='\n')

Solution (Python):
from heapq import heapify,heappop,heappush
que = []
heapify(que)
N = int(input())
S =[]
for i in range(0,N,1):
    S.append(input())
S.sort()
count=1
max_count =0
pre = S[0]
for i in range(1,N,1):
    if S[i]==pre:
        count+=1
    else:
        count=1
    if max_count < count:
        max_count = count
    pre = S[i]

count=1
pre = S[0]
for i in range(1,N,1):
    if S[i]==pre:
        count+=1
    else:
        if count ==max_count:
            print(pre)
        count=1
    pre = S[i]

if count ==max_count:
            print(pre)

Solution (Python):
from collections import *
n,*s=map(str,open(0).read().split())
s=Counter(s).most_common()
print(*sorted((a+'\n')*(i==s[0][1]) for a,i in s))

Solution (Python):
n = int(input())
s = list(input() for i in range(n))

import collections
A = collections.Counter(s)
 
B = max(A.values())
C = [i for i in A if A[i] == B]
C = sorted(C)
 
for i in C:
    print(i)

Solution (Python):
from collections import defaultdict

n = int(input())
s = defaultdict(int)

for i in range(n):
    s[input()] += 1

top = max(s.values())
ans = []

for k in s.keys():
    if s[k] == top:
        ans.append(k)

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

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

import collections
A = collections.Counter(S)

B = max(A.values())
C = [i for i in A.keys() if A[i] == B]
C = sorted(C)

for i in C:
    print(i)

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

import collections
A = collections.Counter(S)

B = max(A.values())
C = [i for i in A if A[i] == B]
C = sorted(C)
 
for i in C:
    print(i)

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

A = Counter(S)
A = sorted(A.items(),key=lambda x:x[1],reverse = True)
i,s = A[0]
Ans = []
for i,j in A:
    if j==s:
        Ans.append(i)
    else:
        break
Ans = sorted(Ans)
for i in Ans:
    print(i)

Solution (Python):
import collections as col

if __name__ == '__main__':
	N = int(input())
	lst = []
	for _ in range(N):
		lst.append(input())

	c = col.Counter(lst)
	C = c.most_common()
	l = []
	co = C[0][1]
	for cc in C:
		if cc[1] == co:
			l.append(cc[0])
		else:
			break
	l.sort()
	for s in l:
		print(s)

Solution (Python):
N = int(input())
Sn = [input() for _ in range(N)]
Sn.sort()
cnt = {}
ans = []
for k in range(N):
  if Sn[k] in cnt:
    cnt[Sn[k]] += 1 
  else:
    cnt[Sn[k]] = 1
max_val = max(cnt.values())
ans = list(filter(lambda x:cnt[x] == max_val, cnt))
ans.sort()
[print(a) for a in ans]

Solution (Python):
import collections
import itertools


N =int(input())
List = []
Dictionary = []
for i in range(N):
    In = input()
    List.append(In)
    
counters= collections.Counter(List)
counter = sorted(counters.items())
mode_v = counters.most_common()[0][-1]

for j in range(len(counter)):
    an = counter[j][1]
    if mode_v == an:
        print(counter[j][0])
    else:
        continue

Solution (Python):
n=int(input())
s=[]
m={}
for i in range(n):
    st=input()
    if(st in m):m[st]+=1
    else:m[st]=1
mx=max(m.values())
ans=[]
for i in m:
    if(m[i]==mx):ans.append(i)
ans=sorted(ans)
for i in ans:
    print(i)

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

c = collections.Counter(S_list)
c2 = c.most_common()
cnt_list = c.values()
cnt_max = max(cnt_list)

str_list = []

for j in range(len(c)):
  if c2[j][1] == cnt_max:
    str_list.append(c2[j][0])

str_list.sort()

for k in range(len(str_list)):
  print(str_list[k])

Solution (Python):
from collections import defaultdict

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

d = defaultdict(int)

for s in S:
    d[s] += 1
    
mx = max(d.values())
for k, v in sorted(d.items(), key=lambda x: x[0]):
    if v == mx:
        print(k)

Solution (Python):
N=int(input())
DIC={}
for i in range(N):
    S=input()
    if S in DIC:
        DIC[S]+=1
    else:
        DIC[S]=1
largest=max(DIC.values())
ans=[]
for s in DIC:
    if DIC[s]==largest:
        ans.append(s)
    else:
        continue
ans.sort()
for t in ans:
    print(t)

Solution (Python):
from collections import Counter
N=int(input())
listS=[]
for i in range(N):
  S=input()
  listS+=[S]
listS=Counter(listS)
listS=listS.most_common()
ans=[]
MAX=listS[0][1]
for i in range(len(listS)):
  if listS[i][1]==MAX:
    ans+=[listS[i][0]]
  else:
    break   
ans.sort()
for i in ans:
  print(i)

Solution (Python):
from collections import Counter
N=int(input())
listS=[]
for i in range(N):
  S=input()
  listS+=[S]
listS=Counter(listS).most_common()
ans=[]
MAX=listS[0][1]
for i in range(len(listS)):
  if listS[i][1]==MAX:
    ans+=[listS[i][0]]
  else:
    break   
ans.sort()
for i in ans:
  print(i)

Solution (Python):
N=int(input())
listS=[]
for i in range(N):
  S=input()
  listS+=[S]
listS.sort()
counter=[]
count=1
for i in range(N-1):
  if listS[i]==listS[i+1]:
    count+=1
  else:
    counter+=[count]
    count=1
    
counter+=[count]    
MAX=max(counter)
count=1

for i in range(N-1):
  if listS[i]==listS[i+1]:
    count+=1
  else:
    count=1
  if count==MAX:
    print(listS[i])
    
if MAX==1:
  print(listS[-1])

Solution (Python):
from collections import Counter


n = int(input())
s = [input() for _ in range(n)]
c = Counter(s).most_common()  




ans = []
max = c[0][1]  
for item, count in c:
	if count == max:
		ans.append(item)
	else:
		break  

ans.sort()  

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

Solution (Python):
import collections


n = int(input())
s = [input() for _ in range(n)]
c = collections.Counter(s).most_common() 
d = collections.Counter([c[x][1] for x in range(len(c))])




ans = []
max = c[0][1] 
for item,count in c[0:d[max]]:
	if count==max:
		ans.append(item)
	else:
		break 

ans.sort() 

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

Solution (Python):
import collections


n = int(input())
s = [input() for _ in range(n)]
c = collections.Counter(s).most_common() 




ans = []
max = c[0][1] 
for item,count in c:
	if count==max:
		ans.append(item)
	else:
		break 

ans.sort() 

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

Solution (Python):
import sys;input=lambda:sys.stdin.readline().rstrip();aint=lambda:int(input());ints=lambda:list(map(int,input().split()))
import math;floor,ceil=lambda x:int(math.floor(x)),lambda x:int(math.ceil(x))
from functools import reduce;gcd=lambda*x:reduce(math.gcd,x);lcm=lambda*x:reduce(lambda x,y:(x*y)//gcd(x,y),x,1)
from collections import deque
import bisect
Yes=lambda b:print("Yes"if b else"No");YES=lambda b:print("YES"if b else"NO")
is_even=lambda x:True if x%2==0 else False

def main():
  n=aint()
  d=dict()
  for i in range(n):
    inp=input()
    if inp in d:
      d[inp]+=1
    else:
      d[inp]=1
  d_sorted=sorted(d.items(),key=lambda x:x[0])
  num=max(d.values())
  for cont in d_sorted:
    if cont[1]==num:
      print(cont[0])

if __name__ == '__main__':
    main()

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

c = collections.Counter(s)
l=c.most_common()
x=[l[0][0]]
for i in range(1,len(l)):
  if l[i-1][1]==l[i][1]:
    x.append(l[i][0])
  else:
    break
x.sort()    
for i in x:
  print(i)

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

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

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

m = d[0][1]
l = []
for i in range(len(d)):
    if(d[i][1] < m):break
    l.append(d[i][0])
l.sort()
for r in l:print(r)

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

count = Counter(lst)
m = max(count.values())

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

ans.sort()

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

Solution (Python):
from collections import defaultdict


def main():
    N = int(input())
    counter = defaultdict(int)
    for _ in range(N):
        s = input()
        counter[s] += 1
    max_cnt = 0
    max_cnt_str_list = list()
    for s, cnt in counter.items():
        if cnt > max_cnt:
            max_cnt = cnt
            max_cnt_str_list = [s]
        elif cnt == max_cnt:
            max_cnt_str_list.append(s)
    max_cnt_str_list = sorted(max_cnt_str_list)
    for s in max_cnt_str_list:
        print(s)


if __name__ == '__main__':
    main()

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

maxi = 0
ans = []
count = 1

for i in range(n):
  if lst[i] == lst[i+1]:
    count += 1
  else:
    if count > maxi:
      ans = [lst[i]]
      maxi = count
    elif count == maxi:
      ans.append(lst[i])
    count = 1
    
for i in range(len(ans)):
  print(ans[i])

Solution (Python):
from collections import Counter
n = int(input())
s = []
for _ in range(n):
    s.append(input())
s = Counter(s)
words, counts = zip(*s.most_common())
selected = []
num = None
for w, c in zip(words, counts):
    if num == None:
        num = c
        selected.append(w)
    else:
        if c == num:
            selected.append(w)
        else:
            break
print(*sorted(selected), sep='\n')

Solution (Python):
N = int(input())
S = [input() for _ in range(N)]
dic = dict()
for s in S:
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1
score_sorted = sorted(dic.items(), key=lambda x: -x[1])
m = score_sorted[0][1]
ret = []
for k,v in score_sorted:
    if v == m:
        ret.append(k)
    else:
        break
ret = sorted(ret)
for item in ret:
    print(item)

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

from collections import Counter
words = []
counter = Counter(s)

items = list(counter.items())
max_count = max(counter.values())

for i in range(len(items)):
    if items[i][1] != max_count:
        continue
    else:
        words.append(items[i][0])

words.sort()

for word in words:
    print(word)

Solution (Python):
from collections import Counter

def solve():
    N = int(input())
    S = [input() for i in range(N)]    
    ctr = Counter(S)
    max_cnt = max(ctr.values())
    names = [name for name, cnt in ctr.items() if cnt == max_cnt]
    names.sort()
    return names

print(*solve(), sep = "\n")

Solution (Python):
N = int(input())
cnt_s = {}
for _ in range(N):
  s = input()
  if s in cnt_s:
    cnt_s[s] += 1
  else:
    cnt_s[s] = 1
  
max_cnt = max(cnt_s.values())

ans = []
for key, value in cnt_s.items():
  if value == max_cnt:
    ans.append(key)
  
[print(s) for s in sorted(ans)]

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

for _ in range(N):
    s = input()
    if s not in dic:
        dic[s] = 1
    else:
        dic[s] += 1
maxlist = []

maxv = max(dic.values())
for di, dv in dic.items():
    if dv == maxv:
        maxlist.append(di)

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

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

for _ in range(N):
    s = input()
    if s not in dic:
        dic[s] = 1
    else:
        dic[s] += 1
maxlist = []

maxv = max(dic.values())
for di, dv in dic.items():
    if dv == maxv:
        maxlist.append(di)

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

Solution (Python):

def myAnswer(N:int,S:list) -> None:
    dic = {}
    for s in S:
        if(s in dic.keys()):
            dic[s]+=1
        else:
            dic[s] = 1
    ans = []
    dic2 = sorted(dic.items(), key=lambda x:x[1],reverse = True)
    MAX = dic2[0][1]
    for key,value in dic2:
        if(MAX == value):
            ans.append(key)
        else:
            break
    ans.sort()
    for a in ans:
        print(a)




def main():
    N = int(input())
    S = [(input()) for _ in range(N)]
    myAnswer(N,S[:])
if __name__ == '__main__':
   main()

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

N = int(input())

Slist = []
for i in range(N):
    Slist.append(input())
    
    
    
    
    
    
Slist.sort()

max_cnt = 1
cnt = 1
s_old = Slist[0]
max_Slist = []

for i in range(1,N):
    if Slist[i] == s_old:
        cnt += 1
    else:
        if cnt > max_cnt:
            max_cnt = cnt
            max_Slist = [s_old]
        elif cnt == max_cnt:
            max_Slist.append(s_old)
        s_old = Slist[i]
        cnt = 1

if Slist[N-1] == s_old:
    if cnt > max_cnt:
        max_Slist = [s_old]
    elif cnt == max_cnt:
        max_Slist.append(s_old)

for str in max_Slist:
    print(str)

Solution (Python):



N = int(input())

Slist = []
for i in range(N):
    Slist.append(input())
    
    
    
    
    
    
Slist.sort()

max_cnt = 1
cnt = 1
s_old = Slist[0]
max_Slist = []

for i in range(1,N):
    if Slist[i] == s_old:
        cnt += 1
    else:
        if cnt > max_cnt:
            max_cnt = cnt
            max_Slist = [s_old]
        elif cnt == max_cnt:
            max_Slist.append(s_old)
        s_old = Slist[i]
        cnt = 1

if Slist[N-1] == s_old:
    if cnt > max_cnt:
        max_Slist = [s_old]
    elif cnt == max_cnt:
        max_Slist.append(s_old)

for str in max_Slist:
    print(str)

Solution (Python):
from collections import defaultdict
dic = defaultdict(int)

n = int(input())
A = [input() for i in range(n)]
for elem in A:
    dic[elem] += 1

m = max(dic.values())


Ans = []
for key in dic:
    
    if dic[key] == m:
        Ans.append(key)

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

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

mx = max(d.values())
ans_list = [k for k, v in d.items() if v == mx]
ans_list.sort()
for i in range(len(ans_list)):
         print(ans_list[i])

Solution (Python):
from collections import Counter


def solve():
    N = int(input())
    S = Counter(input() for _ in range(N))
    max_app = max(S.values())
    print('\n'.join(sorted(k for k, v in S.items() if v == max_app)))


if __name__ == "__main__":
    solve()

Solution (Python):
from collections import Counter


N = int(input())
S = Counter(input() for _ in range(N))
max_app = max(S.values())
print('\n'.join(sorted(k for k, v in S.items() if v == max_app)))

Solution (Python):
from collections import Counter


N = int(input())
S = Counter(input() for _ in range(N))
max_app = max(S.values())
ans = sorted(k for k, v in S.items() if v == max_app)
[print(string) for string in ans]

Solution (Python):
n=int(input())
s = {}
for i in range(n):
    ss = input()
    if ss in s:
        s[ss] += 1
    else:
        s[ss] = 1
s2 = sorted(s.items(),key=lambda x:x[1], reverse = True)
ans = []
va = -1
for key,value in s2:
    if va == -1:
        va = value
        ans.append(key)
    else:
        if va == value:
            ans.append(key)

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

Solution (Python):
from collections import defaultdict

n = int(input())
d = defaultdict(int)
for i in range(n):
	s = input()
	d[s] += 1
l = sorted(d.items(), key=lambda x: (-x[1], x[0]))
m = l[0][1]

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

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

import collections
c = collections.Counter(S)
c = c.most_common()

ans = [c[0][0]]

for i in range(len(c)-1):
    if c[i][1] == c[i+1][1]:
        ans.append(c[i+1][0])
    else:
        break
        
ans = sorted(ans)
        
print("\n".join(ans))

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

M=max(d.values())
d1 = sorted(d.items())
for i,k in d1:
    if k==M:
        print(i)

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

Solution (Python):
n=int(input())
d={}
mx=0
for i in range(n):
  s=input()
  if s not in d:
    d[s]=1
  else:
    d[s]+=1
    if d[s]>mx:
      mx=d[s]
l=[]
if mx==0:
  mx=1
for i in d:
  if d[i]==mx:
    l.append(i)


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

Solution (Python):
import collections
N=int(input())
S=[]
for i in range(N):
   S.append(str(input())) 
c=collections.Counter(S)
c_sorted=sorted(c.items(),key=lambda x:x[0])
s=max(c.values())
for i in c_sorted:
    if i[1]==s:
        print(i[0])

Solution (Python):
from collections import Counter


def main():
    N = int(input())
    S = [input() for _ in range(N)]
    c = Counter(S).most_common()
    ans = []
    for item in c:
        if c[0][1] == item[1]:
            ans.append(item[0])
        else:
            break
    ans.sort()

    for i in ans:
        print(i)


if __name__ == "__main__":
    main()

Solution (Python):
N=int(input())
S=[]
for i in range(N):
  S.append(input())  
  
dic={}
for s in S:
  if s in dic:
    dic[s]=dic[s]+1
  else:
    dic[s]=1
num=max(dic.values())
[print(k) for k, v in sorted(dic.items()) if v==num]

Solution (Python):
from collections import Counter


N = int(input())
S = []
s_append = S.append

for i in range(N):
    s = input()
    s_append(s)


s_counter = Counter(S)
max = max(s_counter.values())

printed_items = []
append = printed_items.append
max_s = [s[0] for s in s_counter.items() if s[1] == max]
for i in sorted(max_s):
    print(i)

Solution (Python):
from collections import Counter

c = Counter(input() for _ in range(int(input())))
m = max(c.values())
for s in sorted(s for s, k in c.items() if k == m): 
  print(s)

Solution (Python):


n=int(input())
dic={}
for i in range(n):
    s=input()
    if s in dic:
        dic[s]+=1
    else:
        dic[s]=1
m=max(dic.values())
ans=[]
for s in dic:
    if dic[s]==m:
        ans.append(s)
ans.sort()
for s in ans:
    print(s)

Solution (Python):
import collections

n = int(input())
l = []*n

for x in range(0, n) :
    l.append(input())

l_sorted = sorted(l)
c = collections.Counter(l_sorted)
mc = c.most_common()

pre_v = 0
ans = []
for m in mc :
    k = m[0]
    v = m[1]
    if v < pre_v :
        break
    pre_v = v
    ans.append(k)

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

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

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

num = max(dic.values())
ans = []
for i in dic:
  if dic[i] == num:
    ans.append(i)
    
ans.sort()
for i in ans:
  print(i)

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

cnt = collections.Counter(S)
m = max(cnt.values())

ans = []
for k, v in cnt.items():
    if v == m:
        ans.append(k)
        
ans.sort()
for a in ans:
    print(a)

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

num = max(l.values())

for i in l:
    
    if l[i]==num:
      ans.append(i)
b = sorted(ans)
for i in b:
    print(i)

Solution (Python):
N = int(input())
dic = {}
for i in range(1,N+1):
    key = input()
    if key not in dic:
        dic[key] = 1
    else:
        dic[key] += 1
lis = []
for key,val in dic.items():
    lis.append([val,key])
lis.sort(reverse = True)

lis2 = []
fnum = lis[0][0]

for j in range(0,len(lis)): 
    if lis[j][0] == fnum:
        lis2.append(lis[j][1])
    else:
        break
lis2.sort()
for k in lis2:
    print(k)

Solution (Python):
N = int(input())
dic = {}
for i in range(1,N+1):
    key = input()
    if key not in dic:
        dic[key] = 1
    else:
        dic[key] += 1
lis = []
for key,val in dic.items():
    lis.append([val,key])
lis.sort(reverse = True)

lis2 = []
fnum = lis[0][0]

for j in range(0,len(lis)): 
    if lis[j][0] == fnum:
        lis2.append(lis[j][1])
    else:
        break
lis2.sort()
for k in lis2:
    print(k)

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




ans = [k for k,v in count.items() if v == max]
ans.sort()
for i in ans:
    print(i)

Solution (Python):
n=int(input())
s=[input() for _ in range(n)]
 
 
 
count={}
for i in range(n):
    if s[i] not in count:
        count[s[i]] = 1
    else:
        count[s[i]] += 1
 
max = max(count.values())
ans = []
for word in count:
    if count[word] == max:
        ans.append(word)

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

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

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





max_value=max(l.values())





ans=[]

for i in l:
  if max_value==l[i]:
    ans.append(i)
ans.sort()

for i in ans:
  print(i)

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

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






max_value=0
for i in l:
  if max_value<l[i]:
    max_value=l[i]


ans=[]

for i in l:
  if max_value==l[i]:
    ans.append(i)
ans.sort()

for i in ans:
  print(i)

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

polls = {}
result = []

for k in range(N):
    S_k = input()
    if (S_k in polls):
        
        polls[S_k] = str(int(polls[S_k]) + 1)
    else:
        
        polls[S_k] = "1"

max = 0

for key in polls:
    if(max < int(polls[key])):
        max = int(polls[key])

for key in polls:
    if(max == int(polls[key])):
        result.append(key)

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

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

Solution (Python):
from collections import Counter
def solve():
    N = int(input())
    S = tuple(input() for _ in range(N))
    a = Counter(S).most_common()
    max = a[0][1]
    count = 0
    ans = set()
    for i,j in a:
        if j < max:
            break
        ans.add(i)
        count += 1
    ans = sorted(ans)
    print("\n".join(ans))
if __name__ == '__main__':
    solve()

Solution (Python):

from collections import Counter
N = int(input())
S = []
for i in range(N):
    s = input()
    S.append(s)
S = Counter(S).most_common()
a = []
b = []
for i in S:
    a.append(i[0])
    b.append(i[1])
c = []
for i in range(b.count(max(b))):
    c.append(a[i])
c.sort()
print(*c, sep="\n")

Solution (Python):

import sys
from collections import Counter

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
S = [sr() for _ in range(N)]
counter = Counter(S)
mo = counter.most_common()
ma = mo[0][1]
answer = []
for k, v in mo:
    if v == ma:
        answer.append(k)

answer.sort()
print(*answer, sep='\n')

Solution (Python):
from collections import Counter
n=int(input())
s=Counter([input() for i in range(n)])
k=max([i for i in s.values()])
l=[]
for i,v in s.items():
  if v==k:
    l.append(i)
l=sorted(list(l))
for i in l:
  print(i)

Solution (Python):
from collections import Counter
n=int(input())
s=Counter([input() for i in range(n)])
k=max([i for i in s.values()])
l=[]
for i,v in s.items():
  if v==k:
    l.append(i)
l=sorted(list(l))
for i in l:
  print(i)

Solution (Python):

n = int(input())
dic = {}
b = []
for i in range(n):
    a = input()
    b.append(a)
for o in b:
    if o in dic:
        dic[o] += 1
    else:
        dic[o] = 1
M = max(dic.values())
for j,k in sorted(dic.items()):
    if k == M:
        print(j)

Solution (Python):
import math
import sys
n = int(input())
li=[input()]
for i in range(n-1):
    li.append(input())
li.sort()
cnt = 0
tmp = 1
li.append('')
for i in range(n):
    if (li[i] == li[i + 1]):
        tmp += 1
    else:
        if(cnt<tmp):
            cnt=tmp
        tmp = 1
tmp=1
for i in range(n):
    if (li[i] == li[i + 1]):
        tmp += 1
    else:
        if (cnt == tmp):
                print(li[i])
        tmp = 1

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

i=0
q1=-1
for p,q in sorted(dic.items(),key=lambda x: (-x[1],x[0])):
    if i>0 and q1!=q:
        break
    else:
        print(p)
        i+=1
        q1=q

Solution (Python):
dict={}
n=int(input())
for i in range(n):
    s=input()
    if s in dict:
        dict[s]+=1
    else:
        dict.setdefault(s,0)
itemMaxValue = max(dict.items(), key=lambda x: x[1])
listOfKeys = []

for key, value in dict.items():
    if value == itemMaxValue[1]:
        listOfKeys.append(key)
        
listOfKeys.sort()
for x in listOfKeys:
    print(x)

Solution (Python):

from collections import Counter
N = int(input())
S = []
U = []
X = []
Y = []
for i in range(N):
    s = input()
    S.append(s)
S = Counter(S)
for i in S.most_common():
    X.append(i[0])
    U.append(i[1])
for i in range(U.count(max(U))):
    Y.append(X[i])
Y.sort()
print(*Y, sep = "\n")

Solution (Python):
n = int(input())
d = {}
for i in range(n):
  s = input()
  d[s] = d.get(s, 0) + 1
m = max(d.values())
maxKeys = [x[0] for x in d.items() if x[1] == m]
so = sorted(maxKeys)
for e in so:
  print(e)

Solution (Python):
from collections import defaultdict
N = int(input())
touhyou = defaultdict(int)
for _ in range(N):
    s = input()
    touhyou[s] +=1
touhyou1=dict(sorted(touhyou.items(),key = lambda x: x[1],reverse = True))
maxn=max(touhyou1.values())
ans=[]
for key,val in zip(touhyou1.keys(),touhyou1.values()):
    if val == maxn:
        ans.append(key)

ans=sorted(ans)

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

Solution (Python):
import collections
n = int(input())
a = [input() for hoge in range(n)]
counted = collections.Counter(a)
m = max(counted.values())
chars = [key for key, value in counted.items()
             if value == m]
c = sorted(chars)
for poge in c:
  print(poge)

Solution (Python):
n = int(input())
ss = []

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

d = {}
m = 0

for s in ss:
    if s not in d:
        d[s] = 1
    else:
        d[s] += 1
    m = max(d[s], m)

ans = sorted([k for k, v in d.items() if v == m])

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

Solution (Python):
N = int(input())
S = [input() for _ in range(N)]
dictionary = {}
for word in S:
  if word in dictionary:
    dictionary[word] += 1 
  else:
    dictionary[word] = 1
maximum = max(dictionary.values()) 
for key,value in sorted(dictionary.items()): 
  if value == maximum:
    print(key)

Solution (Python):
from collections import Counter as C
n = int(input())
ll = [input() for _ in [0]*n]
p = dict(C(ll))
i = max(p.values())
ld = [x for x in p if p[x] == i]
[print(x) for x in sorted(ld)]

Solution (Python):
N = int(input())
from collections import defaultdict
d = defaultdict(int)
for i in range(N):
    d[input()] += 1
m = max(d.values())
l = []
for a,b in d.items():
  if b == m:
    l.append(a)
l.sort()
for i in l:
  print(i)

Solution (Python):
from collections import Counter

N=int(input())

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

c = Counter(Words)

max_value = max(c.values())

word_list=[i[0] for i in c.most_common() if i[1] == max_value]

for k in sorted(word_list):
    print(k)

Solution (Python):
from collections import Counter

n = int(input())
s = [input() for _ in range(n)]
smax = max(Counter(s).values())
kmax = [k for k, v in Counter(s).items() if v == smax]
print("\n".join(sorted(kmax)))

Solution (Python):
import sys
import collections

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

count = collections.Counter(s)

c = count.most_common()
num = c[0][1]

ans = []
for i,v in c:
	if v == num:
		ans.append(i)
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)
t = c.most_common()
x = 0
ans = []
for k,v in t:
  if x <= v:
    ans.append(k)
    x = v
ans.sort()
for i in range(len(ans)):
  print(ans[i])

Solution (Python):
N = int(input())
d = {}
for i in range(N):
    s = str(input())
    if not s in d:
        d[s] = 1
    else:
        d[s] = d[s] + 1
max = 0
res = []
for key in d:
    num = d[key]
    if num < max:
        continue
    elif num == max:
        res.append(key)
    else:
        max = num
        res = [key]
res.sort()
for r in res:
    print(r)

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

import collections
u = collections.Counter(s)

m = max(u.values())
v = []
for j in list(u.items()):
    if j[1] == m:
        v.append(j[0])   

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

Solution (Python):

from collections import Counter


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

count = Counter(S)
countkey = list(count.keys())
countval = list(count.values())

lcv = len(countkey)

maxval = max(countval)

Se = [None for _ in range(N)]

for i in range(lcv):
  if countval[i] == maxval:
    Se[i] = countkey[i]

Seprint = [se for se in Se if type(se) == str]

Seprint = sorted(Seprint)

lSe = len(Seprint)

for i in range(lSe):
  print(Seprint[i])

Solution (Python):

from collections import Counter


N = int(input())
S = [None for _ in range(N)]
for i in range(N):
  S[i] = input()
count = Counter(S)
countkey = list(count.keys())
countval = list(count.values())
lcv = len(countval)
maxval = max(countval)
Se = [None for _ in range(N)]
for i in range(lcv):
  if countval[i] == maxval:
    Se[i] = countkey[i]
Seprint = [se for se in Se if type(se) == str]
Seprint = sorted(Seprint)
lSe = len(Seprint)
for i in range(lSe):
  print(Seprint[i])