Problem:
 Score: 300 points    Problem Statement  We have N voting papers. The i -th vote (1 \leq i \leq N) has the string S_i written on it.  Print all strings that are written on the most number of votes, in lexicographical order.      Constraints   1 \leq N \leq 2 \times 10^5  S_i  (1 \leq i \leq N) are strings consisting of lowercase English letters.  The length of S_i  (1 \leq i \leq N) is between 1 and 10 (inclusive).         Input  Input is given from Standard Input in the following format:  N  S_1  :  S_N       Output  Print all strings in question in lexicographical order.        Sample Input 1 7
beat
vet
beet
bed
vet
bet
beet      Sample Output 1 beet
vet  beet and vet are written on two sheets each, while beat , bed , and bet are written on one vote each. Thus, we should print the strings beet and vet .       Sample Input 2 8
buffalo
buffalo
buffalo
buffalo
buffalo
buffalo
buffalo
buffalo      Sample Output 2 buffalo       Sample Input 3 7
bass
bass
kick
kick
bass
kick
kick      Sample Output 3 kick       Sample Input 4 4
ushi
tapu
nichia
kun      Sample Output 4 kun
nichia
tapu
ushi

Solution (Python):
import sys
import math
import fractions
import bisect
import queue
import heapq
import collections
import itertools
sys.setrecursionlimit(4100000)

MOD = int(1e9+7)
PI = 3.14159265358979323846264338327950288
INF = 1e18

'''
1行のint=====================================
N, K = map(int, input().split())
N, M = map(int, input().split())
A, B = map(int, input().split())

H, W = map(int, input().split())

L, R = map(int, input().split())

1行のstring=================================
S, T = input().split()

1行の整数配列================================
P = list(map(int,input().split()))

A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
D = list(map(int,input().split()))

L = list(map(int,input().split()))
R = list(map(int,input().split()))

T = list(map(int,input().split()))

改行あり整数==================================
X = []
Y = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    X.append(x1)
    Y.append(y1)

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

Pair = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    Pair.append((x1, y1))
    
2次元整数配列=====================================
A = []
for i in range(N):
    tmp = list(map(int,input().split()))
    A.append(tmp)


N行M列の初期化====================================
dp = [[VAL] * RETU for i in range(GYO)]

'''


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

S.sort()

count = collections.Counter(S)

most = count.most_common()[0][1]

ans = []

for c in count.most_common():
    if c[1] == most:
        ans.append(c[0])

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

Solution (Python):
from collections import defaultdict
n = int(input())
d = defaultdict(int)
t = 0
for _ in range(n):
    s = input()
    d[s] += 1
    t = max(t, d[s])
res = []
for i in d:
    if d[i] == t:
        res.append(i)
res.sort()
for i in res:
    print(i)

Solution (Python):
n=int(input())
a=[]
import collections as cc
a=[input() for i  in range(n)]
f=cc.Counter(a)
ch=max(f.values())
ans=[]
for i in a:
    if f[i]==ch:
        ans.append(i)
ans=list(set(ans))
ans.sort()
for i in ans:
    print(i)

Solution (Python):
n = int(input())
li = []
for i in range(n):
  li.append(input())
from collections import Counter
s = Counter(li)
a = list(s.values())
b = list(s.keys())
ans = []
m = 0
for x in a:
  m = max(m, x)
for i in range(len(a)):
  if a[i] == m:
    ans.append(b[i])
ans_a = sorted(ans)
ans_b = "\n".join(ans_a)
print(ans_b)

Solution (Python):
from collections import Counter

N = int(input())
A = [input() for x in range(N)]
cnt = Counter(A)
mx = max(cnt.values())
s = [s for s, v in cnt.items() if v == mx]
s.sort()
print('\n'.join(s))

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

s = []

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

dictionary = {}

for i in s:
    if i in dictionary:
        dictionary[i] += 1
    else:
        dictionary[i] = 0

max_val = max(dictionary.values())
keys_of_max_val = []

for key in dictionary:
    if dictionary[key] == max_val:
        keys_of_max_val.append(key)

keys_of_max_val.sort()

for ans in keys_of_max_val:
    print(ans)

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

d = {}

for _ in range(n):
    tmp = input()
    if tmp not in d.keys():
        d[tmp] = 1
    else:
        d[tmp] += 1

max_value = max(d.values())

ans = []

for k in d.keys():
    if d[k] == max_value:
        ans.append(k)

ans.sort()

for a in ans:
    print(a)

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

maxim = max(m.values())
mySet = set(key for key, value in m.items() if value == maxim)
for i in sorted(mySet):
    print(i)

Solution (Python):
import collections
def main():
    N = int(input())
    s = [input() for i in range(N)]
    ss = collections.Counter(s).most_common()
    
    sss = sorted([ss[i][0] for i in range(len(ss)) if ss[i][1] == ss[0][1]])
    for i in range(len(sss)):
        print(sss[i])
main()

Solution (Python):

from collections import Counter
import sys


def solve(N: int, S: "List[str]"):
    c = Counter(S)
    words = []
    w, m = c.most_common()[0]
    words.append(w)
    for _w, _c in c.most_common()[1:]:
        if _c==m:
            words.append(_w)
        else:
            break
    print('\n'.join(sorted(words)))
    



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

Solution (Python):
n = input()
d = dict()
M = 1
for i in range(n):
  w = raw_input()
  if w in d:
    d[w] += 1
    M = max(d[w], M)
  else:
    d[w] = 1
l = []
for k in d:
  if d[k] == M:
    l.append(k)
l = sorted(l)
for one in l:
  print (one)

Solution (Python):
N = int(input())
L = [input() for i in range(N)]
L = sorted(L)
D = {}

for i in L:
    if i in D:
        V = D.get(i) + 1
    else:
        V = 1
    D[i] = V

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

Ans = []

Ans.append(D[0][0])

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

Ans = sorted(Ans)

for i in Ans:
    print(i)

Solution (Python):
n = int(input())
s = []
for _ in range(n):
    s.append(input())
set_s = set(s)
dict_s = {}
for si in set_s:
    dict_s[si] = 0
for si in s:
    dict_s[si] += 1
sorted_ds = sorted(dict_s.items(), key=lambda x: x[1], reverse=True)
f = True
for str_, c in sorted_ds:
    if f:
        list_ = [str_]
        p = c
        f = False
    else:
        if c == p:
            list_.append(str_)
list_ = sorted(list_)
for si in list_:
    print(si)

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

max_num = max(cnt.values())

ans_list = []

for i in cnt.items():
    if i[1] == max_num:
        ans_list.append(i[0])
    else:
        pass

ans_list.sort()

for i in ans_list:
    print(i)

Solution (Python):
from collections import defaultdict
n = int(input())
d = defaultdict(int)
for _ in range(n):
    s = input()
    d[s] += 1
t = max([i for i in d.values()])
res = []
for i in d:
    if d[i] == t:
        res.append(i)
res.sort()
for i in res:
    print(i)

Solution (Python):

from collections import Counter


def main():
    n = int(input())
    polls_list = []
    for _ in range(n):
        polls_list.append(input())
    polls_dict = Counter(polls_list)
    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):
import collections
N=int(input())
S=[input() for i in range(N)]

C=collections.Counter(S)
C_S=C.most_common()
m=C.most_common()[0][1]
ans=[]

for i in range(len(C_S)):
    if C_S[i][1]!=m:
        break
    else:
        ans.append(C_S[i][0])

ans.sort()

for i in ans:
    print(i)

Solution (Python):
import sys
from collections import Counter
N = int(input())
S = (str(x) for x in sys.stdin.read().split())
cnt = Counter(s for s in S)
max_cnt = max(cnt.values())
keys = [k for k, v in cnt.items() if v == max_cnt]
print("\n".join(sorted(keys)))

Solution (Python):
from collections import defaultdict
def solve():
    N = int(input())
    d = defaultdict(int)

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

    items = list(d.items())
    items.sort(key=lambda x:x[1], reverse=True)
    mx = items[0][1]
    cand = []
    for item in items:
        if item[1] == mx:
            cand.append(item[0])
        else:
            break
    
    ans = sorted(cand)
    print(*ans, sep='\n')
    
if __name__ == '__main__':
    solve()

Solution (Python):

from collections import Counter
from operator import itemgetter
def main():
    n = int(input())
    s = [(x, -y) for x, y in Counter([input() for i in range(n)]).items()]
    s.sort(key=itemgetter(1,0))
    MAX = s[0][1]
    for i in range(len(s)):
        if s[i][1] == MAX:
            print(s[i][0])
        else:
            break

main()

Solution (Python):
def solve():
    N = int(input())
    dict = {}

    for _ in range(N):
        S = input()
        if S in dict:
            dict[S] += 1
        else:
            dict[S] = 1
    sorted_dict = list(sorted(dict.items(), key=lambda x:x[1], reverse=True))
    mx = sorted_dict[0][1]
    cand = []
    for d in sorted_dict:
        if d[1] == mx:
            cand.append(d[0])
        else:
            break
    print(*sorted(cand), sep='\n')
    
if __name__ == '__main__':
    solve()

Solution (Python):
import collections

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

c = collections.Counter(l)

col_tuple_list = c.most_common()

a = []

most_num = col_tuple_list[0][1]
for word_tuple in col_tuple_list:
    if most_num == word_tuple[1]:
        a.append(word_tuple[0])
    else:
        break
a = sorted(a)
for i in a:
    print(i)

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

ans = {}
M = 1
for _ in range(N):
    word = input()
    tmp = ans.get(word)
    if tmp == None:
        ans[word] = 1
    else:
        ans[word] = tmp + 1
        if tmp + 1 > M:
            M = tmp + 1

tmp = sorted(list(ans.keys()))
for t in tmp:
    if M == ans.get(t):
        print(t)

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

m = max(count.values())

ans = [a for a,b in count.items() if b == m]
ans.sort()
for S in ans:
    print(S)

Solution (Python):
def main():
    N = int(input())
    S = [input() for _ in range(N)]
    dict = {}
    for i in range(N):
        if S[i] not in dict:
            dict[S[i]] = 1
        else:
            dict[S[i]] += 1
    ans = {}
    p = 0
    for i ,j in dict.items():
        if p < j : p = j

        if j not in ans:
            ans[j] = [i]
        else:
            ans[j].append(i)
    ans[p].sort()
    for i in range(len(ans[p])):
        print(ans[p][i])
if __name__ == '__main__':
    main()

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

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

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

res_list.sort()

for res in res_list:
  print(res)

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

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

m = max(d.values())
ans = []

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

Solution (Python):
from collections import Counter
def main():
  _, *A = open(0).read().split()
  c = Counter(A)
  maxc = max(c.values())
  print(*sorted([i[0] for i in c.items() if i[1] == maxc]))

if __name__ == "__main__":
  main()

Solution (Python):
table={}
import sys
input=sys.stdin.readline
n=int(input())
ss=[]
for i in range(n):
	s=input().rstrip()
	if s in table:
		table[s]+=1
	else:
		table[s]=1
		ss.append(s)
ans=[]
saidai=max(table.values())
for i in range(len(ss)):
	if table[ss[i]]==saidai:
		ans.append(ss[i])
ans.sort()
for x in ans:
	print(x)

Solution (Python):
from collections import Counter
n=int(input())
s=[input() for _ in range(n)]
d=Counter(s)
m=max(d.values())
keys = [k for k,v in d.items() if v==m]
print("\n".join(sorted(keys)))

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

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

max_count = max(arr.values())
dic = [key[0] for key in arr.items() if key[1] == max_count]

out_sort = sorted(dic)
print("\n".join(out_sort))

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

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

max_count = max(arr.values())
dic = [key[0] for key in arr.items() if key[1] == max_count]

out_sort = sorted(dic)
for i in out_sort:
    print(i)

Solution (Python):
n=int(input())
d=dict()
for _ in range(n):
    a=input()
    if a in d:
        d[a]+=1
    else:
        d[a]=1
m=max(d.values())
keys = [k for k,v in d.items() if v==m]
print("\n".join(sorted(keys)))

Solution (Python):
from collections import Counter
n=int(input())
s=[input() for _ in range(n)]
d=Counter(s)
m=max(d.values())
keys = [k for k,v in d.items() if v==m]
print("\n".join(sorted(keys)))

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

hash = {}
for i in range(N):
	key = input()
	if key in hash:
		hash[key] += 1
	else:
		hash[key] = 1
        
max = 0
results = []
for i, v in hash.items():
	if max == v:
		results.append(i)
	elif max < v:
		results = [i]
		max = v

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

Solution (Python):
N = int(input())
d = dict()
m = 0
for i in range(N):
    w = input()
    if w in d:
        d[w] += 1
        m = max(d[w], m)
    else:
        d[w] = 1
        m = max(d[w], m)
res_list = []

for w, n in d.items():
    if (n == m):
        res_list.append(w)

for w in sorted(res_list):
    print(w)

Solution (Python):
N = int(input())
S = ["" for i in range(N)]
dict1 = {}
names =[]
for i in range(N):
    S[i] = input()

for i in range(N):
    if not (S[i] in dict1.keys()):
        names.append(S[i])
        dict1.update({S[i]:1})
    else:
        dict1[S[i]] +=1
maxv = 0
for i in range(len(names)):
    if maxv < dict1[names[i]]:
        maxv = dict1[names[i]]

winners = []

for i in range(len(names)):
    if dict1[names[i]] == maxv:
        winners.append(names[i])

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

Solution (Python):
n = int(input())
s = [input() for i in range(n)]
u = set(s)
dic = dict(zip(u, [0]*len(u)))
for i in range(n):
    dic[s[i]] += 1
m = max(dic.values())
res = []
for k, v in dic.items():
    if v == m:
        res.append(k)
res.sort()
print(*res, sep="\n")

Solution (Python):
import collections
s = collections.Counter([input() for s in range(int(input()))])
m = max(s.values())
 
a = []
for d in s.items():
  if d[1] == m:
    a.append(d[0])
print("\n".join(sorted(a)))

Solution (Python):
from collections import Counter

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

counter = Counter(s)
count = counter.most_common()
most = count[0][1]

c = []

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

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

Solution (Python):
from collections import Counter
n = int(input())
s = [input() for i in range(n)]
c = Counter(s)
m = 0
for i in c.values():
    m = max(m, i)
res = []
for k, v in c.items():
    if v == m:
        res.append(k)
res.sort()
print('\n'.join(res))

Solution (Python):
import sys
import collections
n = int(sys.stdin.readline())
a = []
for _ in range(n):
  a.append(sys.stdin.readline().strip())
c = collections.Counter(a)
maxc = max(c.values())
print(*sorted([i[0] for i in c.items() if i[1] == maxc]))

Solution (Python):

import collections as co
n = int(input())
s = []
for i in range(n):
    s.append(input())
SS = co.Counter(s)
ma = max(SS.values())

ans = []
for i in SS.keys():
    if SS[i] == ma:
        ans.append(i)

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

Solution (Python):
from collections import Counter

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
S = read().split()

res = []
c = Counter(S)
max_num = c.most_common(1)[0][1]
for i, j in list(c.items()):
    if j == max_num:
        res.append(i)
        
res.sort()

        
print('\n'.join(list(map(lambda x:x.decode(), res))))

Solution (Python):
import collections

N = int(input())
L = []
O = []

for i in range(N):
    s = input()
    L.append(s)

c = collections.Counter(L)
M = max(c.values())

for k in c.keys():
    if c[k] == M:
        O.append(k)

O.sort()

for j in O:
    print(j)

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

for i in range(n):
    s=input()
    count=dic.get(s,0)
    count+=1
    dic[s]=count
mx=1
for v in dic.values():
    mx=max(v,mx)
ans=[]
for k,v in dic.items():
    if v==mx:
        ans.append(k)
ans.sort()

for st in ans:
    print(st)

Solution (Python):
from collections import Counter
def solve():
  n = int(input())
  a = [input() for _ in range(n)]
  c = Counter(a)
  values, counts = zip(*c.most_common())
  maxc = max(counts)
  array = []
  for i in range(len(values)):
    if counts[i] == maxc:
      array.append(values[i])
    else:
      break
  array.sort()
  for i in array:
    print(i)
solve()

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

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

_max = 0
for v in dic.values():
  if _max < v:
    _max = v
dic2 = sorted(dic.items())

for (k,v) in dic2:
  if v == _max:
    print(k)

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

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


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


m = max(d.values())
for s in sorted(k for k in d if d[k] == m):
    print(s)

Solution (Python):
n = int(input())
res = []
d = dict()
for _ in range(n):
    s = input()
    if s not in d:
        d[s] = 0
    d[s] +=1
mm = -1
for k,v in d.items():
    if v > mm:
        mm = v

for k,v in d.items():
    if v == mm:
        res.append(k)

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

Solution (Python):

N = int(input())
C = dict()


for i in range(N):
    a = input()
    if(a not in C.keys()):
        C[a] = 1
    else:
        val = C[a]
        C[a] = val + 1

m=0
for i in C.values():
    if(i > m):
        m=i

ans = sorted(C.items())
for i  in ans:
    if(m==i[1]):
        print(i[0])

Solution (Python):
import collections
n=int(input())
A=[]
for i in range(n):
  A.append(input())
c=collections.Counter(A)
B=c.most_common()
C=[]
i=0
while B[i][1]==B[0][1]:
  C.append(B[i][0])
  i=i+1
  if i==len(B):
    break
C=sorted(C)
for i in range(len(C)):
  print(C[i])

Solution (Python):
import collections as col

n = int(input())
L_W = []
for i in range(0,n):
    L_W.append(input())
 
dic = col.Counter(L_W)

dic_values_max = max(list(dic.values()))
 
max_key = [i for i, j in dic.items() if j == dic_values_max]
 
max_key.sort()
 
for k in max_key:
    print(k)

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

DD = sorted(D.items(), key=lambda x:x[1])

sn=DD[-1][1]
ans=[]
for i in DD:
    if i[1]==sn:
        ans.append(i[0])
ans.sort()
for i in ans:
    print(i)

Solution (Python):
from collections import Counter


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

c = Counter(S)
c_sorted = sorted(c.items(), key=lambda x: x[1], reverse=True)
j = -1
for i in range(len(c_sorted)):
    if i == len(c_sorted) - 1:
        break
    if c_sorted[i + 1][1] < c_sorted[i][1]:
        break

c_sorted_best = c_sorted[:i + 1]
c_sorted_best_dicOrder = sorted(c_sorted_best, key=lambda x: x[0])
print('\n'.join([x[0] for x in c_sorted_best_dicOrder]))

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

c=collections.Counter(S)
most=c.most_common()
m_cnt=most[0][1]

dicts=[]

for i in most:
    if i[1]==m_cnt:
        dicts.append(i[0])
    else:
        break
dicts.sort()
for i in dicts:
    print(i)

Solution (Python):
from collections import Counter

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

Solution (Python):
from collections import Counter

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

c=Counter(S)
m=max(c.values())
ans = sorted(k for k,v in c.items() if v == m)
print("\n".join(ans))

Solution (Python):
from collections import Counter

N = int(input())
S = [input() for _ in range(N)]
c = Counter(S)
m = max(c.values())
ans = sorted([(k,v) for k,v in c.items() if m==v], key=lambda x: (-x[1], x[0]))
[print(k[0])for k in ans]

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
s = [input() for i in range(n)]
l = []
d = defaultdict(int)
ss = set()
for i,j in enumerate(s):
    d[j] += 1
for jj in list(d):
    l.append([jj,d[jj]])
l.sort()
l.sort(key=lambda x:x[1],reverse = True)
max = l[0][1]

for i,j in enumerate(l):
    if j[1] == max:
        print(j[0])
    else:
        break

Solution (Python):
import sys
input = sys.stdin.readline
N = int(input())
S = []
for _ in range(N):
    s = input().replace("\n", "")
    S.append(s)
S.sort()
f = 0
tres = 0
res = [S[0]]
for i in range(1, N):
    if S[i] == S[i-1]:
        f += 1
    else:
        f = 0
    if f == tres:
        res.append(S[i])
    elif f > tres:
        tres = f
        res = [S[i]]

print("\n".join(map(str, res)))

Solution (Python):
import sys
N = int(input())
d = {}
max = 0

for i in range(N):
    S = input()
    if not(S in d):
        d[S] = 0
        continue
    d[S] = d[S] + 1
    if max<d[S]:
        max = d[S]

A = []

for k in d:
    if d[k]==max:
        A.append(k)

A.sort()

for a in A:
    print(a)

Solution (Python):
n = int(input())
count_dict = {}
for _ in range(n):
    e = input()
    if e in count_dict.keys():
        count_dict[e] += 1
    else:
        count_dict[e] = 1

m = max(count_dict.values())
for e in sorted(k for k in count_dict if count_dict[k] == m):
    print(e)

Solution (Python):


def main():
    n = int(input())
    d = dict()

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

    d_m = max(d.values())
    m_list = [kv[0] for kv in d.items() if kv[1] == d_m]
    m_list = sorted(m_list)
    print('\n'.join(m_list))

if __name__ == "__main__":
    main()

Solution (Python):
import sys
from collections import Counter

n = int(sys.stdin.readline().rstrip())
s = sys.stdin.read().split()

def main():
    c = Counter(s)
    ma = max(c.values())
    res = []
    for l, v in c.items():
        if v == ma:
            res.append(l)
    return sorted(res)

if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n')

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

ans = []
count = 1
max_count = 0

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

    else:
        if count > max_count:
            ans = [s[i]]
            max_count = count
            count = 1
        elif count == max_count:

            ans += [s[i]]
            count = 1
        else:
            count = 1

for a in ans:
    print(a)

Solution (Python):
N = int(input())
words = dict()
for i in range(N):
    w = input()
    if w in words:
        words[w] -= 1
    else:
        words[w] = -1
        
wd_list = list()
for w,c in words.items():
    wd_list.append((c,w))  
    
wd_list.sort()
max_c = wd_list[0][0]
for w in wd_list:
    if w[0] != max_c:
        break
    print(w[1])

Solution (Python):

N = int(input())

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

ans = {}
for cnt in S:
  if cnt in ans:
    ans[cnt] += 1
  else:
  	ans[cnt] = 1
max_v = max(ans.values())

for k, v in sorted(ans.items()):
  if v == max_v:
    print(k)

Solution (Python):
n = int(input())
dic = {}
m = 0
for i in range(n):
  s = input()
  if s in dic:
    dic[s] += 1
    m = max(m, dic[s])
  else:
    dic[s] = 1
    m = max(m, dic[s])
ans = []
for s in dic:
  if dic[s] == m:
    ans.append(s)
print('\n'.join(sorted(ans)))

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

for i in range (n):
  key=input()
  if key not in dic:
    dic[key]=1
  else:
    dic[key]+=1
    
max_v=max(dic.values())

ls=sorted(list(filter(lambda key:dic[key]==max_v,list(dic))))

for key in ls:
  print (key)

Solution (Python):
n = int(input())
s = [input() for i in range(n)]
s.sort()
ans = []
c = 1
max = 0
for i in range(1, n):
    if s[i - 1] == s[i]:
        c += 1
    else:
        if c == max:
            ans.append(s[i - 1])
        elif c > max:
            ans.clear()
            ans.append(s[i - 1])
            max = c
        c = 1
if c == max:
    ans.append(s[-1])
elif c > max:
    ans.clear()
    ans.append(s[n - 1])
for des in ans:
    print(des)

Solution (Python):
import collections
N = int(input())
l=[]
for i in range(N):
    l.append(input())
c = collections.Counter(l)
values, counts = zip(*c.most_common())
s=len(values)
l=[]
for i in range(s):
    l.append(values[i])
    if i!=s-1 and counts[i] != counts[i+1]:
        break
l=sorted(l)
for i in l:print(i)

Solution (Python):
import collections

n = int(input())
s = [input() for _ in range(n)]
c_sort = collections.Counter(s).most_common()
list_most = [c_sort[i][0] for i in range(len(c_sort)) if c_sort[i][1] == c_sort[0][1]]
for i in sorted(list_most):
    print(i)

Solution (Python):
from collections import Counter
n, cnt, mx, arr = int(input()), Counter(), -1, []
for i in range(n):
    s = input()
    arr.append(s)
    cnt[s] += 1
    mx = max(mx,cnt[s])
res = []
for i in arr:
    if cnt[i] == mx:
        res.append(i)
        cnt[i] = 0
res.sort()
for i in res:
    print(i)

Solution (Python):
import collections

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

count = collections.Counter(vote_list)
max_count = count.most_common()[0][1]
ans = []

for alpha, beta in count.items():
    if beta == max_count:
        ans.append(alpha)
ans.sort()
print("\n".join(ans))

Solution (Python):
n=int(input())
poll={}
m=0
rtn=[]
for v in range(n):
    s=input()
    if s in poll:
        poll[s]+=1
        if poll[s]>m:
            m=poll[s]
    else:
        poll[s]=0
for s in poll:
    if poll[s]==m:
        rtn.append(s)
rtn.sort()
for x in rtn:
    print(x)

Solution (Python):
from collections import Counter

def main():
    n = int(input())
    s = [input() for _ in range(n)]
    C = Counter(s)
    mx = max(C.values())
    ans = []
    for k,v in C.items():
        if v == mx:
            ans.append(k)
    ans.sort()
    print("\n".join(ans))


if __name__ == "__main__":
    main()

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

ans = []
counter = 1
memo = 0

for i in range(1, N):
    if S[i] == S[i-1]:
        counter += 1
    else:
        if counter == memo:
            ans.append(S[i-1])
        elif counter > memo:
            ans.clear()
            ans.append(S[i-1])
            memo = counter
        counter = 1
if counter == memo:
    ans.append(S[N-1])
elif counter > memo:
    ans.clear()
    ans.append(S[N-1])
    memo = counter
for a in ans:
    print(a)

Solution (Python):
from collections import Counter

def main():
    n = int(input())
    s = [input() for _ in range(n)]
    C = Counter(s)
    cl = C.most_common()
    mx = cl[0][1]
    ans = []
    for c in cl:
        if (c[1] == mx):
            ans.append(c[0])
        else:
            break
    ans.sort()
    for i in ans:
        print(i)


if __name__ == "__main__":
    main()

Solution (Python):
N=int(input())
L=[input() for i in range(N)]
L.sort()
c=1
memo=0
ans=[]
for i in range(1,N):
  if L[i]==L[i-1]:
    c+=1
  else:
    if c==memo:
      ans.append(L[i-1])
    elif c>memo:
      ans.clear()
      ans.append(L[i-1])
      memo=c
    c=1
if c==memo:
  ans.append(L[N-1])
elif c>memo:
  ans.clear()
  ans.append(L[N-1])
for i in range(len(ans)):
  print(ans[i])

Solution (Python):
from collections import defaultdict
n=int(input())
s=defaultdict(lambda: 0)
m=-1
for _ in range(n):
    k=input()
    s[k] += 1
    m=max(s[k],m)
for x in sorted([k for k,v in s.items() if v==m]):
    print(x)

Solution (Python):
from collections import Counter

n = int(input())
a = [input() for x in range(n)]
b = Counter(a)
c = max(b.values())
s = [s for s, g in b.items() if g == c]
s.sort()
print('\n'.join(s))

Solution (Python):
def main():
    n = int(input())
    dic = {}
    mx = 0
    for i in range(n):
        s = input()
        if s in dic:
            dic[s] += 1
        else:
            dic[s] = 1
        mx = max(mx,dic[s])
    l = []
    for k,v in dic.items():
        if v == mx:
            l.append(k)
    l.sort()
    for i in l:
        print(i)


if __name__ == "__main__":
    main()

Solution (Python):
def main():
    n = int(input())
    dic = {}
    mx = 0
    for i in range(n):
        s = input()
        if s in dic:
            dic[s] += 1
        else:
            dic[s] = 1
        mx = max(mx,dic[s])
    l = []
    for k,v in dic.items():
        if v == mx:
            l.append(k)
    l.sort()
    for i in range(len(l)):
        print(l[i])


if __name__ == "__main__":
    main()

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

Solution (Python):
def main():
    dic = {}
    n = int(input())
    for i in range(n):
        s = input().rstrip()
        if s in dic.keys():
            dic[s] += 1
        else:
            dic[s] =  1
    m = 0
    for v in dic.values():
        if m < v:
            m = v
    s_dic = sorted(dic.items(), key=lambda x:x[0])
    for k, v in s_dic:
        if v == m:
            print(k)

if __name__ == "__main__":
    main()

Solution (Python):
from collections import Counter

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

c = Counter(S)
most_cnt = 0

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

Solution (Python):
from operator import itemgetter
import datetime

n = int(input())
sn = dict()

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

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


max_val = max(dict(sn).values())

for si in sn:
    if(int(si[1]) == max_val):
        print(si[0])
    else:
        break