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


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

jisyo = {}

for a in input2:
    if a not in jisyo:
        jisyo[a] = 1
    else:
        jisyo[a] += 1

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

m = result[0][1]
liststr = []
for r in result:
    if m != r[1]:
        break
    liststr.append(r[0])

liststr.sort()

for a in liststr:
    print(a)

Solution (Python):
n = int(input())
s = {}
for i in range(n):
    w = input()
    if w in s.keys():
        s[w] = s[w] + 1
    else:
        s[w] = 1
m = max(s.values())
r = [k for k, v in s.items() if v == m]
r.sort()
for i in r:
    print(i)

Solution (Python):
n = int(input())
v = list(range(n))
for x in range(n):
  v[x] = input()

import collections
c = collections.Counter(v)
values, counts = zip(*c.most_common())
num = list(counts).count(max(counts))
answers = list(values[:num])
answers.sort()
for z in range(num):
  print(answers[z])

Solution (Python):
N = int(input())
S = []
for i in range(N):
    S.append(input())
S = sorted(S)
CNT = [1]
dummy = 1
for i in range(1, N):
    if(S[i] == S[i - 1]):
        dummy += 1
    else:
        dummy = 1
    CNT.append(dummy)


MAX = max(CNT)
for i in range(N):
    if(CNT[i] == MAX):
        print(S[i])

Solution (Python):
n=int(raw_input())
d={}
for i in range(n):
    x=str(raw_input())
    try:
        d[x]+=1
    except:
        d[x]=0

key_max = max(d.keys(), key=(lambda k: d[k]))
x=d[key_max]
ans=[]
for i in d:
    if(d[i]==x):
        ans.append(i)
ans.sort()
for i in ans:
    print i

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

from collections import Counter
B = []
mycounter = Counter(S)
max_v = max(mycounter.values())
for s, v in mycounter.items():
  if v == max_v:
    B.append(s)
for a in sorted(B):
  print(a)

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

s.sort()

t=[]
icnt=0
t.append([1,s[0]])
for i in range(1,len(s)):
    if s[i-1]==s[i]:
        t[icnt][0]=t[icnt][0]+1
    else:
        icnt=icnt+1
        t.append([1,s[i]])
        

t.sort(reverse=True)


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

if len(u)==0:
    print(u[0])    
else:
    u.sort()
    for i in range(len(u)):
        print(u[i])

Solution (Python):
from collections import Counter
n=int(input().rstrip())
d=dict()
for _ in range(n):
    s=input().rstrip()
    if s not in d:
      d[s]=1
    else:
      d[s]+=1
ans=Counter(d).most_common()
ans.sort(key=lambda x: (-x[1],x[0]))
m=ans[0][1]
for i in ans:
    if i[1]!=m:
        break
    print(i[0])

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(), key=lambda x: x[1], reverse=True)
a = []
count = -1
for s in sorted_S:
    if count == -1:
        a.append(s[0])
        count = s[1]
    elif count == s[1]:
        a.append(s[0])
    else:
        break
sorted_a = sorted(a)
for s in sorted_a:
    print(s)

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

for i in range(N):
    arg = input()
    if (arg in S):
        S[arg] = S[arg] + 1
    else:
        S[arg] = 1
valSorted = sorted(S.items(), key=lambda x:(-x[1], x[0]))
breakKey = -1
for key, value in valSorted:
    if breakKey == -1:
        breakKey = value
    if breakKey != value:
        break
    print(str(key))

Solution (Python):
import collections
N = int(input())
S = []
for i in range(N):
  S.append(str(input()))
A = collections.Counter(S)
m = max(A.values())
for s in sorted(set(S)):
  if A[s] == m:
    print(s)

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

Solution (Python):
from 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 = 0
s = [""]

def format_input(filename = None):
	global n
	global s
	if filename == None:
		n = int(input())
		s = [input() for i in range(n)]

	elif filename == '__random__':
		from random import randint as rng
		from random import choices
		n = rng(1, 2 * 10**5)
		s = [''.join(choices('abcdefghijklmnopqrstuvwxyz', k = rng(1, 10))) for i in range(n)]

def get_answer():
	poll_dict = {}
	for i in s:
		if i in poll_dict:
			poll_dict[i] += 1
		else:
			poll_dict[i] = 1
	sorted_dict = sorted(poll_dict.items(), key=lambda x:x[1], reverse=True)
	name_list = [i for i, j in sorted_dict if j == sorted_dict[0][1]]
	name_list.sort()
	answer = ""
	for i in name_list:
		answer += i
		answer += '\n'
	answer = answer[:-1]
	return answer

if __name__ == '__main__':
	format_input()

	ans = get_answer()
	print(ans)

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

s_dic = dict()
a_dic = dict()

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


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




m_count = s_dic_s[0][1]


max_n = True
j = 0

while max_n:
  if s_dic_s[j][1] == m_count:
    a_dic[s_dic_s[j][0]] = s_dic_s[j][1]
    j += 1
    if j == len(s_dic_s):
      max_n = False
  else:
    max_n = False


a_dic_s = sorted(a_dic.items())
    


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

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

sorted_dic = sorted(dic.items(), key=lambda x:x[1], reverse=True)
ans = []
max = 0
for sd in sorted_dic:
    if max <= sd[1]:
        ans.append(sd[0])
        max = sd[1]
    else:
        break

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

Solution (Python):


N = int(input())
d = {}
for i in range(N):
    S = input()
    if S in d:
        cnt = d[S]
        cnt += 1
        d.update({S: cnt})
    else:
        d.update({S: 1})
list = sorted(d.items(), key=lambda x:(-x[1], x[0]))
max = list[0][1]
for v in list:
    if max == v[1]:
        print(v[0])
    else:
        break

Solution (Python):
N = int(input())
S = []
for i in range(N):
    S.append(input())
T = {}
for i in range(N):
  if S[i] in T:
    T[S[i]] += 1
  else:
    T.setdefault(S[i],1)
A = max(T.values())

keys = [k for k, v in T.items() if v == A]
U =sorted(keys)

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

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

max_n = max(n_dict.values())

max_s = [s for s in n_dict.keys() if n_dict[s] == max_n]

max_s.sort()

for s in max_s:
  print(s)

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

Solution (Python):
a = int(input())
import collections
b = [input() for i in range(a)]
clist = collections.Counter(b)

V = clist.keys()

L = clist.most_common()[0][1]


d=[]
f=[]
g=[]
for i in clist.values():
    d.append(i)
for i in clist.keys():
    f.append(i)

for j in range(len(d)):
    if d[j] == L:
        g.append(f[j])
g.sort()
for i in range(len(g)):
    print(g[i])

Solution (Python):
import collections
N = int(input())
S = [input() for i in range(N)]
c = collections.Counter(S)
values, counts = zip(*c.most_common())
i = 0
lst = [values[i] for i in range(len(c)) if counts[0] == counts[i]]
lst.sort()
for i in lst:
    print(i)

Solution (Python):
import collections
n = int(input())
a = []
for i in range(n):
  a.append(input())
c = collections.Counter(a)
b = sorted(list(c.items()))
MAX = max(c.values())
for i in range(len(b)):
  if b[i][1]==MAX:
    print(b[i][0])

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

max_val = max(dic.values())
k = [key for key in dic if dic[key] == max_val]
for i in sorted(k):
    print(i)

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

  tmp = [input() for i in range(num)]

  tmp2 = {}
  for t in tmp:
    if len(tmp2) == 0:
      tmp2[t] = 1
    else:
      if t in tmp2:
        tmp2[t] += 1
      else:
        tmp2[t] = 1

  _tmp2 = sorted(tmp2.items(), key=lambda x:x[1])
  tmp3 = sorted(tmp2.items())
  for t in tmp3:
    if _tmp2[-1][1] == t[1]:
      print(t[0])

main()

Solution (Python):
import numpy as np
from collections import Counter
 
N = int(input())
S = [input() for _ in range(N)]
c = Counter(S)
d = c.most_common()
t = 1

for i in range(1, len(d)):
  if d[0][1] == d[i][1]:
    t += 1
  else:
    pass

L = [[]]*t
for j in range(t):
  L[j] = d[j][0]
  
L = sorted(L)
for i in range(len(L)):
  print(L[i])

Solution (Python):
import collections

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

c = collections.Counter(s)

b, most = c.most_common(1)[0]

ans = []
for i,j in c.most_common():
  if j != most:
    break
  ans.append(i)
for ans_v in sorted(ans):
  print(ans_v)

Solution (Python):
from collections import Counter

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

def calculate_mode(data):
    c = Counter(data)
    
    freq_scores = c.most_common()
    
    max_count = freq_scores[0][1]

    modes = []
    
    for num in freq_scores:
        if num[1] == max_count:
            modes.append(num[0])
    return(modes)

if __name__ == '__main__':
    modes = calculate_mode(S)

    modes.sort()
    for mode in modes:
        print(mode)

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

dic = {}

for i in range(N):
    S = input()
    dic[S] = dic.setdefault(S, 0) + 1

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

l = []

k = -1
for s in sdic:
    if k == -1:
        k = dic[s[0]]
    if k == dic[s[0]]:
        l.append(s[0])
    else:
        break

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

Solution (Python):
import collections

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



count = collections.Counter(S)



max_value = max(count.values())

max_k_list = []

for k, v in sorted(count.items(), key=lambda x: x[1], reverse=True):
    if v == max_value:
        max_k_list.append(k)
    else:
        break

max_k_list.sort()

for i in max_k_list:
    print(i)

Solution (Python):
import collections

if __name__ == "__main__":
    N = int(input())
    S = []
    for i in range(N):
        S.append(input())
    S_collect = collections.Counter(S)
    S_tp = []
    for word in S_collect.most_common():
        S_tp.append(word)
    S_tp_sort = []
    for i in S_tp:
        if i[1] == S_tp[0][1]:
            S_tp_sort.append(i[0])
        else:
            break
    S_tp_sort = sorted(S_tp_sort)
    for s in S_tp_sort:
        print(s)

Solution (Python):
import collections

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

a = collections.Counter(S)
m = max(a.values())
s = []
for i in a:
    if a[i] == m:
        s.append(i)
s.sort()
for i in s:
    print(i)

Solution (Python):
n=int(input())
s = dict()
for i in range(n):
	i=input()
	if not i in s.keys():
		s[i]=1
	else:
		s[i]+=1
m = max(s.values())
l=list()
for i in s:
	if s[i] == m:
		l.append(i)
l.sort()
for i in l:
	print(i)

Solution (Python):
import collections

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

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


max_count = most_common[0][1]



c_list = [t[0] for t in most_common if t[1] == max_count]


out = sorted(c_list)
for o in out:
    print(o)

Solution (Python):
N=int(input())
S = [input() for i in range(N)]
import collections
c = collections.Counter(S)
values, counts = zip(*c.most_common())

n=0
for i in range(len(counts)-1):
  if counts[i]==counts[i+1]:
    n=n+1
  else:
    break
answer=[]    
for i in range(n+1):
  answer.append(values[i])
answer=sorted(answer)

for i in answer:
  print(i)

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

maxv=1
count=1
P=[]

for j in range(N-1):  
    if S[j]==S[j+1]:
        count+=1
    else:
        if count==maxv:
            P+=[S[j]]
        elif count>maxv:
            maxv=count
            P=[S[j]]  
        count=1
        
if count==maxv:
    P+=[S[N-1]]
elif count>maxv:
    maxv=count
    P=[S[N-1]]  

    

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

Solution (Python):
import collections

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

counted = collections.Counter(P)
m = max(counted.values())
chars = {key for key, value in counted.items() if value == m}

chars2 = sorted(chars)

for i in range (len(chars2)):
    print("{}".format(chars2[i]))

Solution (Python):
from collections import defaultdict
inpl = lambda: list(map(int,input().split()))
N = int(input())
T = defaultdict(int)
for i in range(N):
    T[input()] += 1
U = []
M = 0
for k in T.keys():
    n = T[k]
    if n > M:
        M = n
        U = [k]
    elif n == M:
        U.append(k)
U.sort()
for u in U:
    print(u)

Solution (Python):
n = int(input())
max_num = 0
s_dic = {}
for i in range(n):
    input_line = input()
    if input_line in s_dic:
        s_dic[input_line] = s_dic[input_line] + 1
    else:
        s_dic[input_line] = 1
    if s_dic[input_line] > max_num:
        max_num = s_dic[input_line]

anser_list = []
for key,value in s_dic.items():
    if value == max_num:
        anser_list.append(key)

anser_list.sort()
for key in anser_list:
    print(key)

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

res = {}
for i in range(n):
    s = input()
    if res.get(s) == None:
        res.__setitem__(s, 1)
    else:
        res.__setitem__(s, res.get(s) + 1)


def calculate(n,res):
    values = list(res.values())
    maxValue = max(values)

    results = []
    for re in res.keys():
        if res.get(re) == maxValue:
            results.append(re)

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

calculate(n,res)

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

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

Solution (Python):
sz = int(input(''))
ary = []
for i in range(0,sz):
  s = input()
  ary.append(s)

map = {}
for w in ary:
  if not w in map:
    map[w] = 1
  else:
    map[w] +=1

max = 0
maxes = []
for k,v in map.items():
  if v > max:
    max = v

for k,v in map.items():
  if v == max:
    maxes.append(k)

for m in sorted(maxes):
  print(m)

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

Solution (Python):
from collections import Counter
import collections

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

c = collections.Counter(a)
hoge = c.most_common()
i = 0

list = []
if(len(hoge) == 1):
	list.append(hoge[0][0])
elif(len(hoge) == N):
  list = a
else:
  
    while(hoge[i][1] == hoge[0][1]):
        list.append(hoge[i][0])
        i += 1



list.sort()

print(' \n'.join(map(str, list)))

Solution (Python):
import collections

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

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

t = collections.Counter(S)


maxt = max(t.values())
maxvt = [key for key in t if t[key] == maxt]
maxvt.sort()

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

Solution (Python):
import sys
from collections import Counter

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

    b = Counter(a)    
    max_val = max(b.values())
    max_val = [key for key in b if b[key] == max_val]

    sort_val = sorted(max_val)
    
    for i in sort_val:
        print(i)

if __name__ == '__main__':
    main()

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

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



dic = Counter(li)


max = max(dic.values())

list=[]

for k,v in dic.items():
    if(v == max):    
        list.append(k)


list = sorted(list)



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

Solution (Python):
import collections

n=int(input())
l=[]
for i in range(n):
    l.append(input())
l2=collections.Counter(l)
max=max(l2.values())

max_k_list = [kv[0] for kv in l2.items() if kv[1] == max]
l3=sorted(max_k_list)
print("\n".join(l3))

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

strList.sort()


maxNum = 0
Num = 1
maxStr = [strList[0]]
temp = strList[0]

for i in range(1,N):
  if(strList[i] != temp):
    
    if(Num > maxNum):
      maxNum = Num
      Num = 1
      del maxStr[:]
      maxStr.append(strList[i-1])
      temp = strList[i]
    elif(Num == maxNum):
      Num = 1
      maxStr.append(strList[i-1])
      temp = strList[i]
    else:
      Num = 1
      temp = strList[i]
  else:
    Num += 1

if(Num > maxNum):
  maxNum = Num
  Num = 1
  del maxStr[:]
  maxStr.append(strList[i])
  temp = strList[i]
elif(Num == maxNum):
  Num = 1
  maxStr.append(strList[i])
  temp = strList[i]

length = len(maxStr)
for i in range(length):
  print(maxStr[i])

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

S_common = S.most_common()

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

S_print_new = sorted(S_print)

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

Solution (Python):
'''
.append(要素) リストに要素を追加
.extend(リスト) リストを連結する
.insert(場所,要素) 指定した場所に要素追加
del 配列名[場所]
-1で末尾で末尾から一つ前

sort()
sorted(reverse=true)

配列の初期化
配列名=[a]*n+[b]*m

Decimal()
'''

from sys import stdin


from collections import Counter


Num = int(stdin.readline().rstrip())
data = []
for el in range(Num):
    data.append(stdin.readline().rstrip())
data.sort()

counter = Counter(data)

count = 0
check = 0
res = []
for el in counter.most_common():
    if count == 0:
        res.append(el[0])
        check = el[1]
        count = 1
        continue
    if check == el[1]:
        res.append(el[0])
res.sort()
for el in res:
    print(el)

Solution (Python):
import sys
from collections import Counter
N=int(input())
S=['']*N
for i in range(N):
    S[i]=input()
counter = Counter(S)
ans=[0]*len(counter)
num=0
for word, cnt in counter.most_common():
    ans[num]=cnt
    num+=1
anker=ans[0]
ankernum=0
for j in range(len(counter)):
    if ans[j]!=anker:
        ankernum=j
        break
    elif j==len(counter)-1:
        ankernum=j+1
word_ans=['']*len(counter)
k=0
for word, cnt in counter.most_common():
    word_ans[k]=word
    k+=1

for l in sorted(word_ans[:ankernum]):
    print(l)

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

for i in range(N):
  a = input()
  arr.append(a)
  
arr.sort()
arr.append("")

a = [[] for i in range(N+1)]
cnt = 0

for i in range(1,N+1):
  
  if arr[0] != arr[1] and i == 1:
    a[1].append(arr[0])
  
  if arr[i] == arr[i-1]:
    if cnt == 0:
      cnt += 1
    cnt += 1	
  else:
    if cnt > 1:
      a[cnt].append(arr[i-1])
      cnt = 1
    else:
      cnt = 1
      if arr[0] != arr[i-1]:
        a[1].append(arr[i-1])
for i in range(N):
  if a[N-i] == []:
    p = 0
  else:
    b = a[N-i]
    b.sort()
    for j in b:
      if j != "":
        print(j)
    break

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

occ = {}

for i in range(N):
    s = input()
    occ[s] = occ.get(s, 0) + 1

best = 0
for s in occ: best = max(best, occ[s])

res = []
for s in occ:
    if occ[s] == best: 
        res.append(s)

res.sort()

for i in res:
    print(i)

Solution (Python):

import itertools

n = int(input())
s = [input() for i in range(n)]
s.sort()
grs = itertools.groupby(s)
ss = []
for key, group in grs:
    cnt = len(list(group))
    ss.append([cnt, key])
sss = sorted(ss)
maxn = sss[-1][0]

for w in sss:
    if w[0] == maxn:
        print(w[1])

Solution (Python):
n = int(input())
d = {}
l = []
for i in range(n):
  w = str(input())
  if w in d.keys():
    d[w]+=1
  else:
    d[w] = 1
m = max(d.values())
for k, v in sorted(d.items(), key=lambda x: -x[1]):
  if m == v:
    l.append(k)
  else:
    break
for j in sorted(l):
  print(j)

Solution (Python):
N = int(input())
S = [input() for _ in range(N)]
 
s = {}
for i in S:
  if i in s:
    s[i] += 1
  else:
    s[i] = 1
 
max_val = max(s.values())
tmp = []
for key, value in s.items():
  if value == max_val:
    tmp.append(key)

for j in sorted(tmp):
  print(j)

Solution (Python):
import collections
a = int(input())
line = [input() for k in range(a)]
c = collections.Counter(line)
common = c.most_common()
max_number = common[0][1]
a = len(common)
max_common = []
for k in range(a):
  if common[k][1] == max_number:
    max_common.append(common[k][0])
  else:
    break
for k in sorted(max_common):
  print(k)

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())
arr = []
for i in range(N):
  arr.append(input())
found = {}



for candidate in arr:
  try:
    found[candidate] += 1
  except KeyError:
    found[candidate] = 1

s = sorted(found.items(), key=lambda n: n[1])
max = s[len(s) - 1][1]
s = list(filter(lambda t: t[1] == max, s))
s = sorted(s, key=lambda c: c[0])

print("\n".join(list(map(lambda t: t[0], s))))

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

d = {}
m = 0
for x in s:
    if x in d:
        d[x] += 1
        m = max(m, d[x])
    else:
        d[x] = 0

for x in sorted({k:v for k, v in d.items() if v == m}.keys()):
    print(x)

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

Solution (Python):
from collections import Counter

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

c = Counter(s)

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

c = sorted(c.items())

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

Solution (Python):


n = int(input())
word_list = []

for i in range(n):
  word_list.append(input())
    
w_dictionary = {} 
for i in range(n):
  if word_list[i] not in w_dictionary:
    w_dictionary[word_list[i]] = 1
  else:
    w_dictionary[word_list[i]] += 1

score_sorted = sorted(w_dictionary.items(), key=lambda x:-x[1])
max_score = score_sorted[0][1]

key_sorted = sorted(w_dictionary.items())
for key,value in key_sorted:
  if value == max_score:
    print(key)

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

strList = list([])

for i in range(N):
  strList.append(str(input()))

strDict = {}

for item in strList:
  if item not in strDict.keys():
    strDict[item] = 1
  else:
    strDict[item] += 1

maxList = list([])
maxNum = max(strDict.values())

for strKeys in strDict.keys():
  if strDict[strKeys] == maxNum:
    maxList.append(strKeys)

for srtedItem in sorted(maxList):
  print(srtedItem)

Solution (Python):
import collections

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

MaxStr = []



col = collections.Counter(VoteStr)
most_value = col.most_common()[0][1]


for val, num in col.items():
    if num == most_value:
        MaxStr.append(val)

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

Solution (Python):
import collections

case = int(input())
l = [""] * case
for i in range(case):
  l[i] = input()

c = collections.Counter(l)

values, counts = zip(*c.most_common())
cnt = 0
str_list = []
for i in range(len(counts)):
  if cnt < counts[i]:
    cnt = counts[i]
    str_list.append(values[i])
  elif cnt == counts[i]:
    str_list.append(values[i])
  else:
    break

str_list = sorted(str_list)
for tar_str in str_list:
  print(tar_str)

Solution (Python):
import collections

n = int(input())
s = [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()

moji = '\n'.join(chars)

print(moji)

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

result = []
m = 0
word = s[0]
count = 0
for i in range(n):
    if word == s[i]:
        count += 1
    else:
        result.append([word, count])
        word = s[i]
        count = 1
    if count > m:
        m = count
result.append([word, count])

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

Solution (Python):
import sys
import collections

n = input()
arr = [_.replace('\n', '') for _ in sys.stdin]
dic = collections.Counter(arr)
cnt = list(dic.values()).count(max(dic.values()))
s = [k for k,v in dic.most_common(cnt)]

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

Solution (Python):

import collections

def main():
    question_c()

def question_c():
    n = int(input())
    st = [input() for i in range(n)]

    c = collections.Counter(st)
    most = list(c.most_common())

    ans = []

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

    ans = sorted(ans)
    for box in ans:
        print(box)
main()

Solution (Python):
from collections import Counter

n = int(input())

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

maxl = 0
ans = []
for i in m.most_common():
    maxl = max(maxl, i[1])
    if maxl == i[1]:
        ans.append(i[0])

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

Solution (Python):
from collections import Counter

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

CC = Counter(S)

mcnt = max(CC.values())

for key in sorted([k for k, v in CC.most_common() if v == mcnt]):
    print(key)

Solution (Python):

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

dic = {}

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

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

st = [dic_sorted[0][0]]
num = dic_sorted[0][1]

for i in range(1, NN):
  if(dic_sorted[i][1] == num):
    st.append(dic_sorted[i][0])
  else:
    break

st.sort()
for item in st:
  print(item)

Solution (Python):
import collections
n = int(input())
S = [input() for _ in range(n)]
c = collections.Counter(S)
C = sorted(c.most_common(),key=lambda x: x[0])
C = sorted(C,key=lambda x: x[1], reverse=True)
t = C[0][1]
for i in range(len(C)):
    if C[i][1] == t:
        print(C[i][0])

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

S.sort()

ans = []
most = 0
tmpstr = S[0]
tmpcnt = 0


for s in S:
    if tmpstr == s:
        tmpcnt += 1
    else:
        if tmpcnt > most:
            ans.clear()
            ans.append(tmpstr)
            most = tmpcnt

        elif tmpcnt == most:
            ans.append(tmpstr)

        tmpcnt = 1
        tmpstr = s

if tmpcnt > most:
    ans.clear()
    ans.append(tmpstr)
    most = tmpcnt
elif tmpcnt == most:
    ans.append(tmpstr)

for a in ans:
    print(a)

Solution (Python):
import collections


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

count = collections.Counter(vote_list).most_common()


mode = count[0]
mode = int(mode[1])
count= sorted(count)

for i in range(len(count)):
    temp = count[i]
    if(temp[1] == mode):
        print(temp[0])
    else:
        pass

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


l2 = sorted(l.items(), key=lambda val:-val[1])

max_val = l2[0][1]

l3 = []
for k, v in l2:
  if max_val == v:
    
    l3.append(k)
    continue
  break
for k in sorted(l3):
  print(k)

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

ini = S[0]
l = [0]
for i in range(N):
    if ini != S[i]:
        
        ini = S[i]
        l.append(i)
l.append(N)
l_sabun = [l[i+1] - l[i] for i in range(len(l)-1)]



S_set = list(set(S))
S_set.sort()



m = max(l_sabun)
ans = [S_set[i] for i, x in enumerate(l_sabun) if x == m]






for i in ans:
    print(i)

Solution (Python):


import collections

n=int(input())
string_list=[input() for i in range(n)]
c = collections.Counter(string_list)


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

ans_list = []
values, counts = zip(*c.most_common())

for i, count in enumerate(counts):
    if(count == count_max):
        ans_list.append(values[i])
      
for ans in sorted(ans_list):
    print(ans)

Solution (Python):
d={}
k=0
j=0
l=[]
for i in range(int(input())):
    s=input()
    if d.get(s) is None:
        d[s]=1
    else:
        d[s]+=1
for i in sorted(d,key=d.get,reverse=True):
    l.append(i)
    k=d[i]
    break
for i in sorted(d,key=d.get,reverse=True):
    j+=1
    if j>1:
        if d[i]==k:
            l.append(i)
l.sort()
for i in l:
    print(i)

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

from collections import Counter

co = Counter(l).most_common()
l = [co[0][0]]

for n in range(len(co)-1):
    if co[n+1][1] == co[n][1]:
        l.append(co[n+1][0])
    else:
        break
l.sort()

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

Solution (Python):
N=int(input())
import collections
List=[input() for i in range(N)]
A=collections.Counter(List)
m=max(A.values())
X=[i for i, value in A.items() if value==m]
Y=sorted(X)
for Z in Y:
    print(Z)