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):
def solve():
    N = int(input())
    S = []
    for i in range(N):
        S.append(input())
    worddic = {}
    for i in range(N):
        if S[i] not in worddic.keys():
            worddic[S[i]] = 1
        else:
            worddic[S[i]] += 1

    worddic_sorted = sorted(worddic.items(), key=lambda x:x[1], reverse=True)
    selected = list(filter(lambda x:x[1] == worddic_sorted[0][1], worddic_sorted))
    selected_sorted = sorted(selected, key=lambda x:x[0])
    for i in range(len(selected_sorted)):
        print(selected_sorted[i][0])

solve()

Solution (Python):
import collections
from collections import Counter
n=int(input())
string_list=[input() for i in range(n)]
c = collections.Counter(string_list)
max = c.most_common()[0][1]
list = []

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

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

Solution (Python):
def main():
    n = int(input())
    s = [input() for i in range(n)]
    res = {}
    for i in s:
        if i not in res:
            res[i] = 1
        res[i] += 1
    keys = max(res.values())
    max_keys = sorted([key for key in res if res[key] == keys])
    for k in max_keys:
        print(k)

if __name__ == "__main__":
    main()

Solution (Python):
from collections import defaultdict

N = int(input())
dic = defaultdict(int)

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


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

ans = [dic[0][0]]

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

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

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

    v_max = max(S.values())
    keys = [k for k, v in S.items() if v == v_max]
    keys.sort()

    for k in keys:
        print(k)


if __name__ == "__main__":
    main()

Solution (Python):
import collections
import itertools

n = int(input())
lst = []
for _ in range(n):
    lst.append(str(input()))
    
c = collections.Counter(lst)

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

lst2 = [k for k, v in it]

print(' '.join(sorted(lst2)))

Solution (Python):
N = int(input())
sMap = {}
sList = []

for i in range(N):
    s = input()
    if s  not in sMap:
        sMap[s] = len(sList)
        sList.append([1, s])
    else:
        num = int(sMap[s])
        sList[num][0] = sList[num][0] + 1
    

sList.sort(reverse=True)
max = sList[0][0]

ansList = []
for s in sList:
    if s[0] != max:
        break
    ansList.append(s[1])


ansList.sort()
ans = '\n'.join(ansList)
print(ans)

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




result={}
for i in range (0,len(S)):
    item = S[i]
    if item in result:
        result[item] = result[item]+1
    else:
        result[item] = 1

max_v = max(result.values())

keys = [k for k, v in result.items() if v == max_v]

keys.sort()
s_n = '\n'.join(keys)
print(s_n)

Solution (Python):
from collections import defaultdict

N = int(input())
S = defaultdict(int)
for _ in range(N):
    s = input()
    S[s] += 1

t = max(S.values())
for v in sorted(dict(filter(lambda kv: kv[1] == t, S.items())).keys()):
    print(v)

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

scount = Counter(s)
scsort = scount.most_common()
x = scsort[0][1]
anss = []
for i in scsort:
    if i[1] != x:
        break
    anss.append(i[0])

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

Solution (Python):
N=int(input())
S=[input() for i in range(N)]
S.sort()
def list_count(my_list):
    dic={} 
    for num in my_list:
        if num in dic: 
            dic[num]+=1 
        else: 
            dic[num]=1 
    return dic
K=[]
A=list_count(S)
ookii=max(A.values())
K.append(ookii)
max_k_list = [kv[0] for kv in A.items() if kv[1] == K[0]]
max_k_list.sort()
for j in range(len(max_k_list)):
    print(max_k_list[j])

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

target = dict()
max_count = 0
max_key = list()
for i in range(N):
	S = str(input())
	if S in target:
		count = target[S] +1
		target[S] = count	
	else:
		target[S] = 1
		count = 1

	if max_count < count:
		max_count = count
		max_key = [S]
	elif max_count == count:
		max_key.append(S)

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

Solution (Python):
import collections

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

c = collections.Counter(S)
values, counts = zip(*c.most_common())
c_most = []
for s in range(len(values)):
    if counts[0] == counts[s]:
        c_most.append(values[s])
    else:
        break
ans = sorted(c_most)
for j in range(len(ans)):
    print(ans[j])

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):
import collections

count = input()

l = []
ans = []
for i in range(int(count)):
    l.append(input())
c = collections.Counter(l)



max_count = c.most_common()[0][1]
for i in c.most_common():
    if i[1] != max_count:
        break
    
    ans.append(i[0])
ans.sort()
for i in ans:
    print(i)

Solution (Python):
n = int(input())
l = {}
max = 0
for _ in range(n):
  s = input()
  l[s] = l.get(s, 0) + 1
  if max < l[s]:
    max = l[s]

for i in sorted(list(filter(lambda s: l[s] == max, l.keys()))):
  print(i)

Solution (Python):
from collections import Counter

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

list = []

l = Counter(s)
max = max(l.values())

list = [k for k, v in l.items() if v == max]

list.sort()

for j in list:
    print(j)

Solution (Python):
n = int(input())
counts = {}
best = 0
best_words = []
for idx in range(n):
    string = input()
    if counts.get(string) is None: counts[string] = 1
    else: counts[string] += 1

    score = counts[string]

    if score > best:
        best = score
        best_words = [string]
    
    elif score == best:
        best_words.append(string)

for string in sorted(best_words):
    print(string)

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

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

B=sorted(A)

import collections
import itertools

counter = collections.Counter(A)

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

answer=[]
for i in it:
    answer.append(i[0])

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

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

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

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

s.sort()

max_list = []
max_v = 1

count = 1
prev = s[0]


for i in range(1, N):
  
  if s[i] == prev:
    count += 1
  else:
    if max_v == count:
      max_list.append(prev)
    elif max_v < count:
      max_list = [prev]
      max_v = count
    count = 1
    prev = s[i]


if max_v == count:
  max_list.append(prev)
elif max_v < count:
  max_list = [prev]
  max_v = count

for k in max_list:
  print(k)

Solution (Python):
import collections

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

values, cnts = zip(*cnt.most_common())
maxCnt = cnts[0]
maxStr = []
for i in range(len(cnts)):
    if cnts[i] == maxCnt:
        maxStr.append(values[i])
maxStr.sort()
for i in maxStr:
    print(i)

Solution (Python):
import collections

n = int(input())
s = []
for i in range(n):
    si = input()
    s.append(si)
    
s.sort()
counted = collections.Counter(s)
M = max(counted.values())

ms = [k for k, v in counted.items() if v == M]
ms.sort()

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

Solution (Python):
N = input()
N = int(N)
S = {}
for n in range(N):
  word = input()
  if word in S.keys():
    S[word] += 1
  else:
    S[word] = 1
max_value = max(S.values())
keys = sorted(list(S.keys()))
for word in keys:
  if S[word] == max_value:
    print(word)

Solution (Python):
import sys
import itertools

N = int(input())
S = sys.stdin.read().split()

max_len = 0
for key, group in itertools.groupby(sorted(S)):
	length = len(list(group))
	if length > max_len:
		max_len = length
		ans = []
	
	if max_len == length:
		ans.append(key)

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

Solution (Python):
from collections import Counter

N = int(input())
S = [str(input()) for i in range(N)]
X = Counter(S)
ans = X.most_common()
p = ans[0][1]

A = [i[0] for i in X.items() if i[1] == p]
A.sort()

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

Solution (Python):
n = int(input())
s = [None] *n
countdict = {}
for i in range(n):
    s[i] = str(input())
for moji in s:
    if moji in countdict.keys():
        countdict[moji] += 1
    else:
        countdict[moji] = 0
ma = max(countdict.values())
ma_lis = []
for ke in countdict.keys():
    if countdict[ke] == ma:
        ma_lis.append(ke)
ma_lis.sort()
for name in ma_lis:
    print(name)

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

maxCnt = 0
cnt = 0
result = []
str = ''
for S in Sj:
	if S == str:
		cnt += 1
	else:
		str = S
		cnt = 1
	if cnt > maxCnt:
		maxCnt = cnt
		result = [S]
	elif cnt == maxCnt:
		result.append(S)
for rStr in result:
	print(rStr)

Solution (Python):
n = int(input())
s = {}
count = 0
while n > count:
    st = input()
    if st not in s:
        s[st] = 1
        count += 1
    else:
        s[st] += 1
        count += 1

sorteditems = sorted(s.items(), key = lambda x : x[1], reverse= True)
max = 0
ans = []
for a, b in sorteditems:
    if max == 0:
        ans.append(a)
        max = b
    elif max == b:
        ans.append(a)
for i in sorted(ans):
    print(i)

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


c = Counter(s)


imax = len

values, counts = zip(*c.most_common())

for i in range(len(counts)):
    if counts[0]==counts[i]:
        imax = i

value = [values[i] for i in range(imax+1)]
value.sort()
print(*value, sep='\n')

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

    count = dict()
    for i in range(N):
        s = input()
        try:
            count[s] += 1
        except:
            count[s] = 1
    
    sort_ = sorted(count.items(), key=lambda x:x[1], reverse=True)

    max_value = sort_[0][1]
    item = []
    for key,value in sort_:
        if value == max_value:
            item.append(key)
        else:
            break
    
    item.sort()
    for ans in item:
        print(ans)
    
if __name__ == '__main__':
    main()

Solution (Python):
N=int(input())
S=[input() for _ in range(N)]
S.sort()
cnt=1
sheet=[[],[]]

for i in range(1,N):
    if S[i]==S[i-1]:
        cnt+=1
        if i==N-1:
            sheet[0].append(S[i-1])
            sheet[1].append(cnt)
    else:
        sheet[0].append(S[i-1])
        sheet[1].append(cnt)
        cnt=1
        if i==N-1:
            sheet[0].append(S[i])
            sheet[1].append(cnt)

cmax=max(sheet[1])
for j in range(len(sheet[1])):
    if sheet[1][j]==cmax:
        print(sheet[0][j])

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


s_count ={}

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


max_val = max(s_count.values())
max_s_list = [key for key in s_count if s_count[key] == max_val]
result = sorted(max_s_list)

for k in result:
    print(k)

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

s.sort()
s0 = [s[0]]
s0n = [0]
cnt = 0
for i in range(1, n):
    if s[i] == s0[cnt]:
        s0n[cnt] += 1
    else:
        s0.append(s[i])
        s0n.append(0)
        cnt += 1



max_s0n = max(s0n)
for i in range(cnt+1):
    if s0n[i] == max_s0n:
        print(s0[i])

Solution (Python):
import collections

N = int(input())
A = [0] * N

for i in range(N):
    A[i] = input()
B = collections.Counter(A)    
C = B.most_common()
Max = B.most_common()[0]

Ans =[]
for i in C:
    if Max[1] == i[1]:
        Ans.append(i[0])
    else:
        break
Ans = sorted(Ans)
for i in Ans:
    print(i)

Solution (Python):
from collections import Counter
from itertools import takewhile
n=int(input())
s=[input() for _ in range(n)]
count=Counter(s)
v=count.most_common()[0][-1]
it=takewhile(lambda kv: kv[-1]==v,count.most_common())
for t in sorted(list(it)):
    print(t[0])

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

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


c = collections.Counter(ab)

score_sorted = sorted(c.items(), key=lambda x:-x[1])
value = 0
count = 0
res = []
for k, i in score_sorted:
    if count == 0:
        res.append(k)
        count += 1
        value = i
    else:
        if value == i:
            res.append(k)
res.sort()
for i in res:
    print(i)

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

S = {}
for i in range(N):
    s = input()
    if s not in S.keys():
        S[s] = 0
    S[s] += 1

m = 0
ans = []
for s, c in S.items():
    if c > m:
        ans = []
        ans.append(s)
        m = c
    elif c == m:
        ans.append(s)


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

Solution (Python):
import math
import itertools



N = int(input())

S = []
count = [0]*N
for i in range(N):
    S.append(input())

S.sort()

point = 0
for i in range(N-1):
    if S[i]==S[i+1]:
       point+=1
       if i==N-2:
           point+=1
           count[i]=point
    else:
        point+=1
        count[i]=point
        point = 0
        if i==N-2:
            count[i+1]=1

m = max(count)


for i in range(N):
    if m==count[i]:
        print(S[i])

Solution (Python):
N=int(input())
S=[input() for i in range(N)]
S.sort()
def list_count(my_list):
    dic={} 
    for num in my_list:
        if num in dic: 
            dic[num]+=1 
        else: 
            dic[num]=1 
    return dic
K=[]
A=list_count(S)
ookii=max(A.values())
K.append(ookii)
max_k_list = [kv[0] for kv in A.items() if kv[1] == K[0]]
max_k_list.sort()
for j in range(len(max_k_list)):
    print(max_k_list[j])

Solution (Python):
from collections import Counter
n = int(input())
s = []
for i in range(n):
    s.append(input())
counter = Counter(s)
maxnum = max(counter.values())
keys = [k for k, v in counter.items() if v == maxnum]
keys.sort()
for ans in keys:
    print(ans)

Solution (Python):
import collections

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



c = collections.Counter(S)

temp = c.most_common()
max_count = temp[0][1]

T = []
for i in range(N):
    if len(temp) > 1:
        if temp[i][1] == max_count:
            T.append(temp[i][0])
        else:
            break
    else:
        T.append(temp[0][0])
        break

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

Solution (Python):
from collections import Counter
N = int(input())
S = Counter(list(input() for _ in range(N)))


max_v = max(S.values())
words = []
for k, v in S.most_common():
    if v == max_v:
        words.append(k)
    else:
        break

words.sort()
for w in words:
    print(w)

Solution (Python):
import collections
N = int(input())
S = [input() for i in range(N)]
c = collections.Counter(S)
max_count = c.most_common()[0][1]
max_k_list = [kv[0] for kv in c.items() if kv[1] == max_count]
max_k_list.sort()
for max_k in max_k_list:
    print(max_k)

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

c = Counter(s)
m = max(c.values())
l = sorted(list(c.items()))

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

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

c = collections.Counter(S)
d = c.most_common()
values, counts = zip(*d)
M = max(counts)

M_counts = counts.count(M)
ans = []
for i in range(M_counts):
    ans.append(values[i])

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

Solution (Python):
from collections import Counter

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

s = s.most_common()

k = s[0][1]
lst = []
for i in range(len(s)):
    if k == s[i][1]:
        lst.append(s[i][0])
    else:
        break

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

Solution (Python):
N = int(input())
S = {}
for i in range(N):
  s = input()
  if s in S: S[s] += 1
  else: S[s] = 1  
sorted_S = sorted(S.items(), reverse = True, key=lambda x: x[1]) 
ans = []
for word, value in sorted_S:
  if value == sorted_S[0][1]: ans.append(word)
ans.sort()
for i in ans:
  print(i)

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

t = collections.Counter(s)
u = list(t.items())

x = max(list(t.values()))
ans = []


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

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

Solution (Python):

import collections
from collections import Counter

n = int(input())
s = []
for i in range(n):
    s.append(str(input()))
"""
s.sort()
count = 1
max_ = 0
ans = []
for i in range(n - 1):
    if s[i] == s[i + 1]:
        count += 1
    elif s[i] != s[i + 1]:
        if max_ <= count:
            max_ = count
            ans.append(s[i])
            count = 1

for i in range(len(ans)):
    print(ans[i], end = '')
"""

count = Counter(s)
max_number = 0
ans = []
for i in count.most_common():
    ans.append(list(i))
len_ans = len(ans)
ans.sort(key = lambda x : x[1])
tmp = ans[len_ans - 1][1]
ans.sort()
for i in range(len_ans):
    if ans[i][1] == tmp:
        print(ans[i][0])

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

b = sorted(a)

word = b[0]
word_idx = 0
w = []
for i in range(n):
  if word == b[i]:
    word_idx += 1
  else:
    w.append((word,word_idx))
    word_idx = 1
    word = b[i]
    
w.append((word,word_idx))

n_max = max(w, key=lambda x:x[1])[1]

for i in range(len(w)):
  if w[i][1] == n_max:
    print(w[i][0])

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=input('')
n=int(n)
s=[]
for a in range(n):
    b=input('')
    s.append(b)

vdic={}
for a in range(n):
    if s[a] in vdic:
        vdic[s[a]]=vdic[s[a]]+1
    else:
        vdic[s[a]]=1

max=0
for a in vdic:
    if vdic[a]>=max:
        max=vdic[a]

maxname=[]
for a in vdic:
    if vdic[a]==max:
        maxname.append(a)

maxname=sorted(maxname)

for a in maxname:
    print(a)

Solution (Python):
import collections

n = int(input())
l = []
for i in range(n):
  l.append( input() )
  
c = collections.Counter(l).most_common()
mn = c[0][1]

res = []
for cc in c:
  if cc[1]==mn:
    res.append(cc[0])
  else:
    break

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

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

num = int(input())
votes = []
for i in range(num):
  votes.append(input())
  
c = collections.Counter(votes)

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

words = []
for word, freq in c.items():
  if freq == max_freq:
    words.append(word)

words = sorted(words)
for word in words:
    print(word)

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

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

mode_v = counter.most_common()[0][-1]
it = itertools.takewhile(
    lambda kv: kv[-1] == mode_v, counter.most_common()
)
u=[]
for k, v in it:
  u.append(k)
  
u.sort()
for i in range(len(u)):
  print(u[i])

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())

word = {}
x = set()
for i in range(n):
    s = str(input())
    x.add(s)
    if not s in word :
        word[s] = 1
    else:
        word[s] = int(word[s]) + 1

m = sorted(word.values(),reverse=True)
items_sorted = sorted(word.items())

for i in range(len(x)):
    if items_sorted[i][1] == m[0]:
        print(items_sorted[i][0])

Solution (Python):
n = int(input())
dictionary = {}
for i in range(n) :
    new_word = input()
    if new_word in dictionary.keys() :
        dictionary[new_word] += 1
    else :
        dictionary[new_word] = 1

max_val = max(dictionary.values())
keys_of_max_val = [key for key in dictionary if dictionary[key] == max_val]

keys_of_max_val.sort()

for word in keys_of_max_val :
    print(word)

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

max_cnt = max(cnt_list.values())
res_list = []

for a in cnt_list.items():
  if a[1] == max_cnt:
    res_list.append(a[0])

res_list.sort()

for res in res_list:
  print(res)

Solution (Python):
from collections import Counter

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

ans = []
w = max(c.values())
for k, v in sorted(c.items()):
    if v == w:
        ans += [k]


for i in ans:
    print(i)

Solution (Python):
n = int(input())
dics = {}
for i in range(n):
    try:
        s = input()
        dics[s] += 1
    except KeyError:
        dics[s] = 1
max_v = max(dics.values())

max_k_list = [kv[0] for kv in dics.items() if kv[1] == max_v]
max_k_list.sort()
for i in max_k_list:
    print(i)

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

import collections
s_counter = collections.Counter(s_list)

import sys
max_count = s_counter.most_common()[0][1]

s_list_keys = list(s_counter.keys())
s_list_values = list(s_counter.values())

list_ans = []

for i in range(len(s_list_keys)):
    if s_list_values[i] == max_count:
        list_ans.append(s_list_keys[i])

list_ans.sort()

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

Solution (Python):
import collections
z = int(input())
a = [input() for i in range(z)]
a = collections.Counter(a).most_common()
a.sort(key = lambda x:x[1],reverse = True)
c = a[0][1]
ans = []
for i in a:
  if i[1] == c:
    ans.append(i[0])
  else:
    break
ans.sort()
for i in ans:
    print(i)

Solution (Python):
num = int(input())
i = [input() for _ in range(num)]
 
count_dict = {}
for ele in i:
  if ele not in count_dict:
    count_dict[ele] = 1
  else:
    count_dict[ele] += 1
 
max_count = max(count_dict.values())
max_str = [a for a in count_dict if count_dict[a] == max_count]
for string in sorted(max_str):
  print(string)

Solution (Python):
from collections import Counter

a = int(input())
a_list = []
ans_list = []

for i in range(a):
  a_list.append(input())

a_counter = Counter(a_list)

_v = 0
for k, v in a_counter.most_common():
    if _v == 0 or _v == v:
      _v = v
      ans_list.append(k)
    elif _v > v:
      break

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

Solution (Python):

import collections

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

c = collections.Counter(s)
count_max = max(c.values())
for key, num in c.items():
    if num == count_max:
        ans.append(key)

ans = sorted(ans)

for i in ans:
    print(i)

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

c = Counter(S)
max_value = max(list(c.values()))
ans_list = sorted(list(c.items()))

for i in range(len(ans_list)):
  if ans_list[i][1] == max_value:
    print(ans_list[i][0])

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

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

li = {}
key = []
for _ in range(n):
    tmp = input()
    if tmp in li.keys():
        li[tmp] += 1

    else:
        li[tmp] = 1
        key.append(tmp)

mord = max(li.values())

ans = []
for i in key:
    if li[i] == mord:
        ans.append(i)

ans.sort()

for i in ans:
    print(i)

Solution (Python):
import collections
n=int(input())
lst=[]
for i in range(n):
    lst.append(input())
cnt=collections.Counter(lst)
ma=0
for val in cnt.values():
    val=int(val)
    if(val>ma):
        ma=val
li=[]
for key,val in cnt.items():
    val=int(val)
    if(val==ma):
        li.append(key)
li.sort()
for i in li:
    print(i)

Solution (Python):
import collections

N = int(input())
L = [input() for _ in range(N)]
result = []
c = collections.Counter(L)
mostC =  c.most_common()[0][1]

for k,v in c.items():
    if v == mostC:
        result.append(k)

result.sort()

for name in result:
    print(name)

Solution (Python):
from collections import Counter

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

polls = Counter(s)
max_count = max(polls.values())

l = list(map(lambda t: t[0], filter(lambda item: item[1] == max_count , polls.items())))
l.sort()
print(*l, sep="\n")

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

sorted_S = sorted(S)
count = [0]*N

index_str = sorted_S[0]
index_num = 0

for i in range(N):
    if sorted_S[i] == index_str:
        count[index_num] += 1
    else:
        index_str = sorted_S[i]
        index_num = i

        count[i] += 1

max_num = max(count)

tousen = list()
for i in range(N):
    if count[i] == max_num:
        tousen.append(sorted_S[i])

sorted_tousen = sorted(tousen)
num_of_tousen = len(sorted_tousen)

for i in range(num_of_tousen):
    print(sorted_tousen[i])

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


sdic = {}

nMax = 1

for i in range(N):
    s = str(input())
    if s in sdic:
        sdic[s] += 1
        nMax = max(nMax,sdic[s])
    else:
        sdic[s] = 1

slist = []
for k in sdic:
    if sdic[k] == nMax:
        slist.append(k)

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

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

d = {}
cnt = 0
for i in range(n):
	if s[i] in d: d[s[i]] += 1
	else: d[s[i]] = 1
	cnt = max(cnt, d[s[i]])

l = []
for i in range(n):
	if d[s[i]] == cnt:
		l.append(s[i])

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

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

existed_dict = {}
max_count = 0
max_text_list = []
for _ in range(N):
    text = input()
    if existed_dict.get(text):  
        existed_dict[text] += 1
    else:
        existed_dict[text] = 1
    if existed_dict[text] == max_count:
        max_count = existed_dict[text]
        max_text_list.append(text)
    elif existed_dict[text] > max_count:
        max_count = existed_dict[text]
        max_text_list = []
        max_text_list.append(text)
    else:
        pass

for text in sorted(max_text_list):  
    print(text)

Solution (Python):
from collections import Counter

def main():
    n = int(input())
    sn = []
    for _ in range(n):
        sn.append(input())

    sn_counter = Counter(sn)
    ans = sn_counter.most_common()
    max_num = sn_counter.most_common()[0][1]
    
    cut_num = 0
    for it in range(len(ans)):
        if ans[it][1] == max_num:
            cut_num += 1
        else:
            break
    
    ans = ans[:cut_num]
    ans.sort()

    for s in ans:
        print(s[0])

if __name__ == "__main__":
    main()

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_v=max(d.values())
ans=list(filter(lambda x: x[1] == max_v, d.items()))
[print(i[0]) for i in sorted(ans)]

Solution (Python):
from collections import defaultdict

N=int(input())
cnt=defaultdict(int)
for i in range(N):
    ai=input()
    cnt[ai]+=1
count=0
ans=[]
for idx, val in cnt.items():
    if count<val:
        count=val
        ans=[]
        ans.append(idx)
    elif count==val:
        ans.append(idx)
ans = sorted(ans)
for i in ans:
    print(i)

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

a = {}
l = []

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

num = max(a.values())

for i in a:
  if a[i] == num:
    l.append(i)

l.sort()

for j in l:
  print(j)

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

d = {}
for i in range(n): 
    s = input()
    if(d.get(s) is None):
        d[s] = 1
    else:
        d[s] = d[s] + 1

l = list(d.items())

l.sort(key=lambda x: (-x[1], x[0])) 

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

Solution (Python):


N = int(input())

m = {}
for i in range(0,N):
    S = input()
    if S in m:
        m[S] = m[S] + 1
    else:
        m[S] = 1

top = 0
r = list()
for k,v in sorted(m.items(), key=lambda x: -x[1]):
    if top == 0:
        top = v
    if top != v:
        break
    r.append(k)

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

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

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

mx = 0
ans = []

for itm in d.items():
  if itm[1] == mx:
    ans.append(itm[0])
  elif itm[1] > mx:
    ans = [itm[0]]
    mx = itm[1]
  else:
    continue

ans.sort()

for x in ans:
  print(x)

Solution (Python):

import sys
from collections import defaultdict

def solve(N: int, S: "List[str]"):
    d = defaultdict(int)
    for s in S:
        d[s]+=1
    dd = []
    for key in d.keys():
        dd.append((-d[key],key))
    sd = sorted(dd)
    n = sd[0][0]
    for sdd in sd:
        if sdd[0] != n:
            break
        print(sdd[1])
    return



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

if __name__ == '__main__':
    main()