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 collections import Counter
import heapq

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

word_count=Counter(word)
ma=max(word_count.values())

ans=[k for k, v in word_count.items() if v == ma]
cnt=len(ans)
heapq.heapify(ans)
for i in range(cnt):
    print(heapq.heappop(ans))

Solution (Python):
import collections

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

li = collections.Counter(s)
ma= max(li.values())

ans= [i for i,j in li.items() if(j==ma)]
print("\n".join(sorted(ans)))

Solution (Python):
from collections import Counter

n=int(input())
string_list=[input() for i in range(n)]
 
counter = Counter(string_list)

m = max(counter.values())

out_li = []

for k,v in counter.items():
  if v == m:
    out_li.append(k)

out_li.sort()
    
print('\n'.join(out_li))

Solution (Python):
import collections

n = int(input())
l = []
for i in range(n):
    l.append(str(input()))
c = collections.Counter(l)
c = c.most_common()
max_l = c[0][1]
ans = []
for i in c:
    if i[1] == max_l:
        ans.append(i[0])
    else:
        break

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

Solution (Python):
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
s_cnt = Counter(s)
s_cnt_common = s_cnt.most_common()
max_cnt = s_cnt_common[0][1]
ans = []
for i in range(len(s_cnt_common)):
    if s_cnt_common[i][1] == max_cnt:
        ans.append(s_cnt_common[i][0])
ans.sort()
print(*ans)

Solution (Python):
import collections

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

dicdata = collections.Counter(data)

m = max(dicdata.values())

newdata = [k for k, v in dicdata.items() if v == m]

newdata.sort()

[print(i) for i in newdata]

Solution (Python):
import collections
N = int(input())
s = [input() for i in range(N)]
 
counter = collections.Counter(s)
count = counter.most_common()
 
most = count[0][1]
 
c =[]
for i in range(len(counter)):
    if count[i][1] == most:
        c.append(count[i][0])
 
c.sort()
 
for i in range(len(c)):
    print(c[i])

Solution (Python):




n = int(input())

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

l.sort()

max_count = 0
count = 0
results = []
ps = None
for s in l:
    if s == ps or ps is None:
        count += 1
    else:
        if max_count < count:
            max_count = count
            results = [ps]
        elif count == max_count:
            results.append(ps)
        count = 1
    ps = s

if max_count < count:
    max_count = count
    results = [ps]
elif count == max_count:
    results.append(ps)

results.sort()
for str in results:
    print(str)

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

a = 0
for i in range(n):
    s = str(input())
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1
    if dic[s] > a:
        a = dic[s]
box= []
for i in dic:
    if dic[i] == a:
        box.append(i)

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

Solution (Python):
import collections

n = int(input())
List = [input() for i in range(n)]
res = []

c = collections.Counter(List)


leng = len(c)

ac = c.most_common()
res.append(ac[0][0])
for i in range(1, leng):
    if ac[i][1] >= ac[i-1][1]:
        res.append(ac[i][0])
    else:
        break


res.sort()
for j in range(len(res)):
    print(res[j])

Solution (Python):

from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    n = I()
    sli = [input() for i in range(n)]
    rank = defaultdict(lambda: 0)
    for i in sli:
        rank[i] += 1
    rank = list(rank.items())
    rank.sort(key=lambda x: (-x[1], x[0]))
    for i, j in rank:
        if j == rank[0][1]:
            print(i)



if __name__ == "__main__":
    solve()

Solution (Python):

n = int(input())
s= []
for _ in range(n):
    x = input()
    s.append(x)
s.sort()
mydict = {}
for i in range(n):
    x = s[i]
    if x in mydict:
        mydict[x]+=1
    else :
        mydict[x] = 1

max_n = -1
for v in mydict.values():
    max_n = max(max_n,v)
aa = []
for k in mydict:
    if mydict[k] == max_n:
        aa.append(k)
aa = sorted(aa)
for i in aa:
    print(i)

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


S_set = set(S_lis)
S_dict = dict()

for s in S_set:
    S_dict[s] = 0

for val in S_lis:
    S_dict[val] += 1
max_num = max(S_dict.values())
ans = list()
for k, v in S_dict.items():
    if v == max_num:
        ans.append(k)
ans = sorted(ans)
for res in ans:
    print(res)

Solution (Python):
from collections import *
n=int(input())
a=[]
for _ in range(n):
  a.append(input())
aset=set(a)
cnt=Counter(a)
cnt=dict(cnt)
maxi=0
for k in cnt.keys():
  maxi=max(maxi,cnt[k])

anss=[]
for s in aset:
  if cnt[s]==maxi:
    anss.append(s)
anss.sort()
for i in range(len(anss)):
  print(anss[i])

Solution (Python):
from collections import Counter
N = int(input())
S = []
for i in range(N):
    S.append(input())
A = []
d = Counter(S)
md = d.most_common(1)[0][1]

for key, value in d.items():
    if value == md:
        A.append(key)

As = sorted(A)
for a in As:
    print(a)

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

import collections

c = collections.Counter(S)
max = max(c.values())
 
max_k_list = [kv[0] for kv in c.items() if kv[1] == max]
max_k_list.sort()
for l in max_k_list:
    print(l)

Solution (Python):
import collections
N = int(input())
s = [input() for i in range(N)]
 
counter = collections.Counter(s)
count = counter.most_common()
 
most = count[0][1]
 
c =[]
for i in range(len(count)):
    if count[i][1] == most:
        c.append(count[i][0])
 
c.sort()
 
for i in range(len(c)):
    print(c[i])

Solution (Python):
n = int(input())
d = {}
for i in range(n):
  s = input()
  if s not in d:d[s] = 1
  d[s] += 1
max_cnt = sorted(d.items(), key=lambda x:x[1])[-1][1]
s = [x for x, y in d.items() if y == max_cnt]
s.sort()
for name in s:
    print(name)

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

print(*sorted([a for a,s in S if s==c]),sep="\n")

Solution (Python):
from collections import  Counter
n = int(input())
a  = [input() for i in range(n)]
cnt = Counter(a)
l = max(cnt.values())
ans = [s for s,c in cnt.items()if c ==l]
ans.sort()
print('\n'.join(ans))

Solution (Python):










from collections import Counter

n = int(input())
s=[input() for i in range(n)]
l=Counter(s)
m=0
for i in l.values():
  m=max(m,i)
ans=[]
for k,v in l.items():
  if v==m:
    ans.append(k)
ans.sort()
print(*ans,sep='\n')

Solution (Python):



def main():
    n = int(input())
    polls_dict = {}
    for _ in range(n):
        poll = input()
        if poll not in polls_dict:
            polls_dict[poll] = 1
        else:
            polls_dict[poll] += 1

    max_poll = max(polls_dict.values())
    
    polls_set = set()
    for key, value in polls_dict.items():
        if value == max_poll:
            polls_set.add(key)

    polls_set = sorted(polls_set)
    for poll in polls_set:
        print(poll)
    
    return 0


if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter


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

counted = Counter(s)
counted_sort=counted.most_common()

for i in range(len(counted_sort)):
    if counted_sort[i][1]==counted_sort[0][1]:
        ans.append(counted_sort[i][0])


[print(i) for i in sorted(ans)]

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

c = collections.Counter(s)

m = max(c.values())
for k,v in c.items():
    if v ==m:
        ans.append(k)
ans.sort()
print(*ans,sep="\n")

Solution (Python):
import collections

n = int(input())
l = [input() for _ in [0] * n]

counted = collections.Counter(l)



m = max(counted.values())



chars = [key for key, value in counted.items()
             if value == m]






print(*sorted(chars),sep='\n')

Solution (Python):
dic={}
n=int(input())
d=[]
for i in range(n):
  d.append(input())
  if d[-1] in dic:
  	dic[d[-1]]+=1
  else:
    dic[d[-1]]=1
mx=max(dic.values())
for k,v in sorted(dic.items(),key=lambda x:(-x[1],x[0])):
  if mx==v:
    print(k)

Solution (Python):
import collections
 
n=int(input())
 
li=[]
ma=0
an=[]
 
for i in range(n):
    li.append(input())
 
c=collections.Counter(li)
c2=c.most_common()
ma=c2[0][1]

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

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

for _ in range(N):
    S.append(input())
S_set = set(S)
S_dict = dict()
for s in S_set:
    S_dict[s] = 0

for val in S:
    S_dict[val] += 1
max_num = max(S_dict.values())
ans = list()
for k, v in S_dict.items():
    if v == max_num:
        ans.append(k)
ans = sorted(ans)
for res in ans:
    print(res)

Solution (Python):
import collections


N = int(input())

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

count = collections.Counter(S)


mx = max(count.values())

result = [key for key, val in count.items() if val == mx]
print("\n".join(sorted(result)))

Solution (Python):
import collections

n = int(input())
List = [input() for i in range(n)]
res = []

c = collections.Counter(List)
m = 0
for v in c.values():
  m = max(m, v)
  
for k, v in c.items():
  if v == m:
    res.append(k)
    
res.sort()
for i in range(len(res)):
  print(res[i])

Solution (Python):
import collections

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

c = collections.Counter(S)
max = max(c.values())

max_k_list = [kv[0] for kv in c.items() if kv[1] == max]

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

Solution (Python):
from collections import Counter


N = int(input())
list = [input() for _ in range(0,N)]
counted = Counter(list)
res_max= counted.most_common()[0][1]
ans = []
for k, v in counted.items():
    if v == res_max:
        ans.append(k)

ans.sort()
print(*ans, sep="\n")

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

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

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

m = sortdic[len(sortdic)-1][1]
ans = []
for i in range(len(sortdic)):
    if sortdic[i][1] == m:
        ans.append(sortdic[i][0])

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

Solution (Python):
import collections

N = int(input())
S = list(input() for i in range(N))
dict = {}

for l in S:
        if l in dict:
            dict[l] += 1;
        else:
            dict[l] = 1;
            
max = max(dict.values())

max_k_list = [kv[0] for kv in dict.items() if kv[1] == max]

max_k_list.sort()

for i in max_k_list:
    print(i)

Solution (Python):
n = int(input())
l = [str(input()) for i in range(n)]
l.sort()
i = 0
count = 1
ans = []
max = 1
while i < n-1:
  if l[i] == l[i+1]:
    count += 1
    i += 1
    if count >= max:
      max = count
    if i == n-1:
      ans.append([l[n-1], count])

  else:
      ans.append([l[i],count])
      count = 1
      i += 1

if max == 1:
  ans.append([l[n-1], 1])
      
for i in ans:
  if i[1] == max:
    print(i[0])

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

maxv=max(dic.values())
words=sorted(dic.items(),key=lambda x:x[0])
for item in words:
  if item[1]==maxv:
    print(item[0])

Solution (Python):
import collections
a = int(input())
l = []
for i in range(a):
    l.append(input())
counted = collections.Counter(l)
 
m = max(counted.values())
 
chars = [key for key, value in counted.items()
             if value == m]
chars.sort()
 
for i in chars:
    print(i)

Solution (Python):

from collections import defaultdict
n = int(input())
d = defaultdict(int)

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

l = []
for k in d:
    l.append((d[k],k))
l.sort(key=lambda x:(-x[0],x[1]))
m = l[0][0]
i = 0
while i<len(l) and l[i][0]==m:
    print(l[i][1])
    i += 1

Solution (Python):
import sys
import math
import itertools as it
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx():return list(map(lambda x:int(x)*-1,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":pass
n = i()
s = [input() for _ in range(n)]
s.sort()
ss = list(set(s))
ss.sort()
a = [0]*len(ss)
i = 0
j = 0
while n-1 > i:
    if s[i] == s[i+1]:
        a[j] += 1
        i += 1
    else:
        i += 1
        j += 1
m = max(a)
for k in range(len(a)):
    if m == a[k]:
        print(ss[k])

Solution (Python):
import collections

n = int(input())
l = [input() for _ in [0] * n]

counted = collections.Counter(l)


m = max(counted.values())


chars = [key for key, value in counted.items()
             if value == m]

print(*sorted(chars),sep='\n')

Solution (Python):
from collections import Counter

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

L = Counter(S)
m = 0
for v in L.values():
    m = max(m, v)
ans = []
for k, v in L.items():
    if v == m:
        ans.append(k)
ans.sort()
print(*ans, sep="\n")

Solution (Python):
n=int(input())
s=sorted([input() for i in range(n)])
ans = ['']
x=1
max=0
for k in range(n):
    if k<n-1:
        if s[k]==s[k+1]:
            x+=1
        else:
            if max<x:
                ans=[s[k]]
                max=x
            elif max==x:
                ans.append(s[k])
            x=1
    else:
        if max<x:
            ans=[s[k]]
            max=x
        elif max==x:
            ans.append(s[k])

    

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

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

counter = collections.Counter(s)
count = counter.most_common()

most = count[0][1]

c =[]
for i in range(len(count)):
    if count[i][1] == most:
        c.append(count[i])

c.sort()

for i in range(len(c)):
    print(c[i][0])

Solution (Python):
from collections import Counter
N = int(input())
S = []
for n in range(N):
    S.append(input())
c = Counter(S)
K = []
for i,(k,v) in enumerate(c.most_common()):
    if i==0:
        vmax = v
    else:
        if vmax!=v:
            break
    K.append(k)

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

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):
from collections import defaultdict
N = int(input())
d = defaultdict(int)

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

m = 0
for k in d.keys():
    m = max(d[k],m)

li = []
for k in d.keys():
    if d[k] == m:
        li.append(k)

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

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

kkk=1
data=[]
for i in range(1,N):
    if S[i]==S[i-1]:
        kkk+=1
    else:
        data.append([kkk,S[i-1]])
        kkk=1
data.append([kkk,S[-1]])
data.sort()
num=data[-1][0]

for u in data:
    if u[0]==num:
        print(u[1])

Solution (Python):
n = int(input())
li = []
for i in range(0,n):
    li.append(input())
di = dict()
for j in range(0,len(li)):
    if li[j] in di.keys():
        di[li[j]]+=1
    else:
        di[li[j]] = 1
li.clear()
di = {k: v for k, v in sorted(di.items(), key=lambda item: item[1])}
total = max(di.values())
for k,v in di.items():
    if v == total:
        li.append(k)
li.sort()
for l in li:
    print(l)

Solution (Python):
from collections import Counter
n = int(input())
d = [input() for _ in range(n)]
c = Counter(d).most_common()
now = c[0][1]

data = []
for x in c:
    if x[1] < now:
        break
    data.append(x[0])
data.sort()
for x in data:print(x)

Solution (Python):
from collections import Counter

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

ans_box, maxi = [], 0

for s in S_cnt:
    cnt = S_cnt[s]
    if maxi < cnt:
        maxi = cnt
        ans_box = [s]
    elif maxi == cnt:
        ans_box.append(s)

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

Solution (Python):
import collections

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

for i in range(N):
  SSS.append(input())



hindo_ck = collections.Counter(SSS).most_common()

i = 1
hindo_max = list(hindo_ck[0])

if len(hindo_ck) > 1:
  del hindo_max[-1]
  while i < N and hindo_ck[i-1][1] == hindo_ck[i][1]:
    hindo_max.append(hindo_ck[i][0])
    i += 1
  hindo_max.sort()
  
  for h in hindo_max:
    print(h)
  
else:
  hindo_max = hindo_ck[0][0]
  print(hindo_max)

Solution (Python):
n=int(input())
arr=[input() for _ in range(n)]
dic={}
for i in range(n):
  if arr[i] not in dic:
    dic[arr[i]]=1
  else:
    dic[arr[i]]+=1
largest=max(dic.values())
ans=[]
for keys in dic.keys():
  if dic[keys]==largest:
    ans.append(keys)
ans=sorted(ans)
for words in ans:
  print(words)

Solution (Python):
from collections import Counter
n = int(input())
ls = []
for _ in range(n):
    ls.append(input())
res = []
counter = Counter(ls).most_common()
for x in counter:
    if x[1] == counter[0][1]:
        res.append(x[0])
print("\n".join(sorted(res)))

Solution (Python):


N=int(input())

S_list = []
S_count = []
max = 1
temp_list = []



S_dict = {}
for i in range(N):
    s = input()
    if s in S_dict.keys():
        S_dict[s] += 1
        if max < S_dict[s]:
            max = S_dict[s]
    else:
        S_dict[s] = 1
    
     



S_max = []
for j in S_dict:
    if S_dict[j] == max:
        S_max.append(j)

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

Solution (Python):
from collections import Counter

N = int(input())

str_lis = [str(input()) for i in range(N)]
c = Counter(str_lis)
a = c.most_common()
num = a[0][1]
b = []
for i in a:
  if i[1] == num:
    b.append(i[0])
    num = i[1]
  else:
    break
    
new_b = sorted(b)
for i in new_b:
  print(i)

Solution (Python):

a= int(input())
liss = [input() for i in range(a)]

lis = sorted(liss)

maxCount = 1
nCount = 1
maxlist = []


for i in range(a):
    if i != a-1:
        if lis[i] == lis[i + 1]:
            nCount += 1
            if nCount > maxCount:
                maxCount += 1
                maxlist.clear()
            continue
        elif maxCount == nCount:
            maxlist.append(lis[i])

        nCount = 1
    else:
        if maxCount == nCount:
            maxlist.append(lis[i])



lis = sorted(lis)

for s in maxlist:
    print(s)

Solution (Python):


def main():
    n = int(input())
    lines = []
    for i in range(0, n):
        lines.append(input())

    dct = {}
    for l in lines:
        if l in dct:
            dct[l] += 1;
        else:
            dct[l] = 1;

    cmax = max(dct.values())

    print('\n'.join(sorted([k for k,v in dct.items() if v == cmax])))

if __name__ == '__main__':
    main()

Solution (Python):
import collections

N = int(input())
s = [input() for i in range(N)]
k = 0
i = 0
ans =[]

c = collections.Counter(s)
c_mc=c.most_common()
for i in range(len(c)):
    if c_mc[i][1] ==c_mc[0][1]:
        ans.append(c_mc[i][0])

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

Solution (Python):
n = int(input())
a = []
for i in range(n):
  si = str(input())
  a.append(si)
a.sort()
mx = 1
w = []
j = 1
for i in range(1,n):
  if a[i] == a[i-1]:
    j += 1
  else:
    if j > mx:
      w = [a[i-1]]
      mx = j
    elif j == mx:
      w.append(a[i-1])
    j = 1
if j > mx:
  w = [a[n-1]]
elif j == mx:
  w.append(a[n-1])
for wi in w:
  print(wi)

Solution (Python):
from collections import Counter
num = int(input())
value = [input() for i in range(num)]
votes = Counter(value)
dict = {}

for value in votes.values():
    dict[value] = []

for (key, value) in votes.items():
    dict[value].append(key)
maxVote = sorted(dict.keys(), reverse=True)[0]
list_data = dict[maxVote]
list_data.sort()
for i in list_data:
    print(i)

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

put = []
stor = {}
i=0
while i<num :
    name = input()
    if name in stor.keys():
        stor[name] += 1
    else:
        stor[name] = 1
    i += 1

stor=sorted(stor.items(), key=lambda item:item[1], reverse=True)

m = stor[0][1]

for i in range(0,len(stor)):
    if stor[i][1]==m:
        put.append(stor[i][0])
    else:
        break
put.sort()

for i in put:
    print(i)

Solution (Python):
from collections import Counter

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

for i in range(N):
    S.append(input())

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

for item in sorted(c.items()):
    if item[1]==max:
        print (item[0])

Solution (Python):
from collections import defaultdict

n =int(input())

d = defaultdict(int)

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

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

max_val = 0
maxes = []
for r in result:
    if max_val > r[1]:
        break
    else:
        max_val = r[1]
        maxes.append(r[0])

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

Solution (Python):
n=int(input())
dic=dict()
for _ in range(n):
    s=input()
    if s in dic:
        dic[s] +=1
    else:
        dic[s]=1
m=max(dic.values())
dic=sorted(dic.items(),key=lambda x: x[0])
for i in range(len(dic)):
    if dic[i][1]==m:
        print(dic[i][0])

Solution (Python):
N = int(input())
 
mes_dict = {}
for i in range(N):
  m = input()
  try:
    mes_dict[m] += 1
  except:
    mes_dict[m] = 1

ma =max(mes_dict.values())
answer = sorted([k for k, v in mes_dict.items() if v == ma])
for ans in answer:
  print(ans)

Solution (Python):
n = int(input())
s = [input() for i in range(n)]
import collections
c = collections.Counter(s).most_common()
fin = [c[0][0]]
for j in range(1,len(c)):
    if c[j][1]==c[j-1][1]:
        fin.append(c[j][0])
        continue
    break
for kekka in sorted(fin):
    print(kekka)

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):
n=int(input())
s=[input() for _ in range(n)]
s.sort()
s.append("")
a=[]
count=[]
buf=1
count_max=1
for i in range(n):
    s_i=s[i]
    if s_i==s[i+1]:
        buf+=1
    else:
        if buf>=count_max:
            a.append(s_i)
            count.append(buf)
            if buf>count_max:
                count_max=buf
        buf=1
count_max=max(count)
for i in range(len(a)):
    if count[i]==count_max:
        print(a[i])

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

l={}
for i in range(n):
    s = input()
    if s in l:
        l[s]+=17
    else:
        l[s]=1

xa = max(l.values())

keys = [k for k, v in l.items() if v == xa]
keys.sort()

for i in keys:
    print(i)

Solution (Python):
import sys
import collections

N = int(input())
S = []
for _ in range(N):
    S.append(input()) 
c = collections.Counter(S)
a = c.most_common()
s = c.most_common()[0][1]
ans = []
for i in sorted(a):
    if i[1] == s:
        print(i[0])
        sys.stdout.flush

Solution (Python):
n=int(input())
s=[]
for i in range(n):
    s.append(input())
s=sorted(s)
t=0
c=0
ct=[]
for i in range(1,n):
    c+=1
    if s[t]!=s[i]:
        ct.append(c)
        c=0
        t=i
ct.append(c+1)
u=0
cm=max(ct)
for i in ct:
    if i==cm:
        print(s[u])
    u+=i

Solution (Python):
n = int(input())
s = [input() for i in range(n)]
import collections
c = collections.Counter(s).most_common()
fin = [c[0][0]]
for j in range(1,len(c)):
    if c[j][1]==c[j-1][1]:
        fin.append(c[j][0])
        continue
    break
a = sorted(fin)
for kekka in a:
    print(kekka)

Solution (Python):
import collections
n = int(input())
s = [input() for i in range(n)]
lst = collections.Counter(s)
max_val = max(lst.values())
keys_of_max_val = [key for key in lst if lst[key] == max_val]
print("\n".join(sorted(keys_of_max_val)))

Solution (Python):
from collections import Counter

n = int(input())
s_list = sorted(list(input() for _ in range(n)))

s = Counter(s_list)

ans_num = s.most_common(1)[0][1]

s_1 = sorted(list(s.items()), key=lambda x: x[0])

for i in range(len(s_1)):
    if s_1[i][1] == ans_num:
        print(s_1[i][0])

Solution (Python):
def solve(n: int, words: list):
    word_map = dict()
    max_count = 0
    for word in words:
        count = word_map.get(word, 0) + 1
        word_map[word] = count
        max_count = max(max_count, count)
   
    for word in sorted(word_map.keys()):
        if(word_map[word] == max_count):
            print(word)


def main():
    n = int(input())
    li = []
    for i in range(n):
        li.append(input())
    solve(n, li)


main()

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

def calcFreq(list):
    freq_dict = {}
    for i in list:
        if i in freq_dict:
            freq_dict[i] += 1
        else:
            freq_dict[i] = 1
    sorted_freq_list=sorted(freq_dict.items(), key=lambda x:x[1], reverse=True)
    return sorted_freq_list

freq_list=calcFreq(string_list)
max_freq_number=freq_list[0][1]
string_list_most_freq=[]
for i in freq_list:
    if i[1] != max_freq_number:
        break 
    string_list_most_freq.append(i[0])
string_list_most_freq.sort()    

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

Solution (Python):
from collections import Counter
import itertools

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

cnt_words = Counter(s)

mode_v = cnt_words.most_common()[0][-1]
it = itertools.takewhile(
    lambda kv: kv[-1] == mode_v, cnt_words.most_common()
)
m = []
for i in it:
    m.append(i[0])
m.sort()
for item in m:
    print(item)

Solution (Python):
from collections import Counter
N=int(input())
ll=[input() for i in range(N)]
ll=Counter(ll)
ll=ll.most_common()
ll=sorted(ll,key=lambda x:(x[1]),reverse=True)
ans=[l for l in ll if l[1]==ll[0][1] ]
ans=sorted(ans,key=lambda x:(x[0]),reverse=False)
for i in ans:
    print(i[0])

Solution (Python):
from collections import defaultdict
N = int(input())
S = [input() for i in range(N)]
input_dict = defaultdict(int)
for key in S:
    input_dict[key] += 1
max_value = max(input_dict.values())
max_list = []
for k, v in input_dict.items():
    if v == max_value:
        max_list.append(k)
max_list.sort()
[print(i) for i in max_list]

Solution (Python):
import collections

N = input()
M = [input()for i in range(int(N))]
X = collections.Counter(M)
max(X.items(), key=lambda x:x[1])[0]
i = max(X.values())
Y = [k for k, v in X.items() if v == i]
b = len(Y)
Z = sorted(Y,key =str.lower)
for i, v in enumerate(Z):
    if i > b:
        break
    else:
        print(Z[i])

Solution (Python):
import collections, sys

n = sys.stdin.readline()
s = []
for _ in range(0,int(n)):
  s.append(sys.stdin.readline().replace('\n',''))

c = collections.Counter(s)
max = c.most_common()[0][1]
l = sorted(list(dict(filter(lambda x: x[1]==max, c.items())).keys()))
for k in l:
  print(k)

Solution (Python):
import collections
 
N = int(input())
l = [input() for _ in range(N)]
 
c = collections.Counter(l)
 
L = c.most_common()
 
values, counts = zip(*c.most_common())
 
A = list(values)
B = list(counts)
 
b = B.count(B[0])
 
a = A[0:b]
c = sorted(a)

for i in c[0:]:
		print(i)

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

max_value = max(Ss.values())  
max_keys = [k for k, v in Ss.items() if v == max_value]
for k in sorted(max_keys):
  print(k)

Solution (Python):
from collections import Counter 
num = input()
ins = list()
aa = list()
qc = 0
for abhsa in range(0, int(num)):
  ins.append(input())
cnt = Counter(ins)
nums = cnt.most_common()
res = nums[0][0]
values, counts = zip(*cnt.most_common())
aa.append(values[0])
for haha in counts:
  aqc = qc + 1
  if int(len(counts) - int("1")) >= aqc:
    if counts[qc] == counts[aqc]:
      aa.append(values[aqc])
      qc += 1
    else:
      break
aca = sorted(aa)
print("\n".join(aca))

Solution (Python):
from collections import defaultdict
N = int(input())
mm = defaultdict(int)

for i in range(N):
    key = input()
    mm[key] += 1

max_val= max(mm.values())
mm_max = []
for kv in mm.items():
    if kv[1] == max_val:
        mm_max.append(kv)

mm_max.sort()
for v in mm_max:
    print(v[0])

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

Solution (Python):

import collections

n = int(input())

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

c = collections.Counter(ss)

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

ans.sort()

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

Solution (Python):
import collections
n = int(input())
a_list = [str(input()) for i in range(n)]
c = collections.Counter(a_list)

cc = c.most_common()
values, counts = zip(*c.most_common())
max_counts = max(counts)


counts_num = counts.count(max_counts)

ans = []
for i in range(counts_num):
    ans.append(values[i])
    
ans = sorted(ans)

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

Solution (Python):
import collections
n = int(input())
s = list(input() for i in range(n))
counted = collections.Counter(s)

m = max(counted.values())
chars = [key for key, value in counted.items()
             if value == m]
chars.sort()
for i in range(len(chars)):
    print(chars[i])