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())
list0 = {}
for i in range(N):
  x = input()
  if x in list0:
    list0[x] = list0[x] + 1
  else:
    list0[x] = 1
m = max(list0.values())
k_m = [key for key in list0 if list0[key] == m]
k_m.sort()
for i in range(len(k_m)):
  print(k_m[i])

Solution (Python):
import collections
N = int(input())
S = [str(input()) for i in range(N)]
new_S = collections.Counter(S)
M = max(new_S.values())
X = []
for K,V in new_S.items():
  if V == M:
    X.append(K)
X.sort()
for x in X:
  print(x)

Solution (Python):
import collections

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

S = collections.Counter(S) 
maxFreq = S.most_common()[0][1]

S = sorted(S.items())
values, counts = zip(*S)

for v, c in zip(values, counts):
    if c == maxFreq:
        print(v)

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

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip()
d={} ; a=[]
from collections import Counter
for _ in range(int(input())):
    s=input()
    a.append(s)
d=Counter(a)
maxx=max(d.values())
ans=[]
for i in d:
    if d[i]==maxx:
        ans.append(i)
ans.sort()
for i in ans:
    print(i)

Solution (Python):
d={} ; a=[]
from collections import Counter
for _ in range(int(input())):
    s=input()
    a.append(s)
d=Counter(a)
maxx=max(d.values())
ans=[]
for i in d:
    if d[i]==maxx:
        ans.append(i)
ans.sort()
for i in ans:
    print(i)

Solution (Python):
n = int(input())
mozi = list()
for i in range(n):
    mozi.append(input())

di = dict()
for i in mozi:
    if (i in di.keys()):
        di[i] += 1
    else :
        di[i] = 1

m = max(di.values())
di = sorted(di.items())

for i in di:
    if (i[1] == m):
        print(i[0])

Solution (Python):
import collections

n = int(input())
mozi = list()
for i in range(n):
    mozi.append(input())

c = collections.Counter(mozi)
m = max(c.values())
c = sorted(c.items())

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

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

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

max = max(s.values())
s = sorted(s.items())
for i in s:
  if i[1] == max:
    print(i[0])

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

    
    
    



    target = {}

    for word in S:
        if word in target:
            target[word] += 1
        else:
            target[word] = 1




    maximum = max(target.values())

    for key,val in sorted(target.items()):
        if(val == maximum):
            print(key)

if __name__ == '__main__':
    main()

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

Solution (Python):
import collections
N=int(input())
S=collections.Counter(input() for i in range(N))
maximum=max(S.values())
sort=sorted(key for key,value in S.items() if value==maximum)
for s in sort:
    print(s)

Solution (Python):
n=int(input())
d=dict()
for i in range(n):
    s=input()
    if s not in d.keys():
        d[s]=-1
    else:
        d[s]-=1

a=sorted(d.items(),key=lambda x:(x[1],x[0]))
for k,v in a:
    if v!=a[0][1]:
        break
    print(k)

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

Solution (Python):
import collections

H  = int(input())
dic = collections.defaultdict(int)
for _ in range(H):
    dic[input()]+=1
ma = max(dic.values())
res = []
for k in dic.keys():
    if dic[k] == ma:
        res.append(k)
for s in sorted(res):
    print(s)

Solution (Python):
import collections

N = int(input())
words = []
top = int()
for i in range(N):
    words.append(input())
c = collections.Counter(words)

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

top = int(c_sorted[0][1])
answer = []
count = int(0)
length = len(c_sorted)
unko = str()

if length == 1:
    unko = "unko"
else:
    for i in range(N):
        if int(c_sorted[i][1]) == top:
            answer.append(c_sorted[i][0])
            count = count + 1
        else:
            break

answer.sort()

if unko == "unko":
    print(c_sorted[0][0])
else:
    for i in range(count):
        print(answer[i])

Solution (Python):
import numpy as np
import math as m

def main(**kwargs):
    c = {}
    maxc = 0

    for s in S:
        if s in c.keys():
            c[s] += 1

        else:
            c[s] = 1
        
        maxc = max(c[s], maxc)

    rs = []

    for ckey, cvalue in c.items():
        if cvalue == maxc:
            rs.append(ckey)

    rs.sort()
    r = "\n".join(rs)
    return r

if __name__ == "__main__":
    cin = np.array(input().split(" ")).astype("int")
    n, *_ = cin
    S = []
    
    for i in range(n):
        cin = input()
        S.append(cin)
    
    cout = main(n=n, S=S)
    print(cout)

Solution (Python):

from collections import Counter

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

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

o = [k for k, v in c.items() if v == ma]


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

Solution (Python):

from collections import Counter

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

ma = c.most_common()[0][1]
o = [k for k, v in c.items() if v == ma]
o.sort()
print('\n'.join(o))

Solution (Python):
import collections

H  = int(input())
dic = collections.defaultdict(int)
for _ in range(H):
    dic[input()]+=1
ma = max(dic.values())
res = []
for k in dic.keys():
    if dic[k] == ma:
        res.append(k)
for s in sorted(res):
    print(s)

Solution (Python):
import collections

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

l=collections.Counter(s).most_common()
i=0
ans=[l[0][0]]
if len(l)>2:
    while i<len(l)-1 and l[i][1]==l[i+1][1]:
        ans.append(l[i+1][0])
        i+=1
ll=sorted(ans)
for i in range(len(ll)):
    print(ll[i])

Solution (Python):
n=int(input())
x=[]
for k in range(n):
  x.append(input())
x.sort()
count=[1]
head=[0]
for k in range(1,n):
  if x[k]!=x[k-1]:
    head.append(k)
    count.append(1)
  else:
    count[-1]+=1
maxim=max(count)
for k in range(len(count)):
  if count[k]==maxim:
    print(x[head[k]])

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

sc=Counter(s).most_common()
max_idx=sc[0][1]
ans=[]
for i, j in sc:
    if j==max_idx:
        ans.append(i)
ans=sorted(ans)
print(*ans)

Solution (Python):
import collections

n=int(input())
lst=[]
for k in range(0,n):
  lst.append(input())
c0=collections.Counter(lst)
a,b=zip(*c0.most_common())
maxb=max(b)
op=[]
for sa,sb in zip(a,b):
  if sb==maxb:
    op.append(sa)
op.sort()
for ss in op:
  print(ss)

Solution (Python):
n = int(input())
s = []
for i in range(n):
  s.append(input())
s = sorted(s)
max_count = 1
count = 1
ans = []
for i in range(n-1):
  if s[i] == s[i+1]:
    count += 1
    if count == max_count:
      ans.append(s[i])
    if count > max_count:
      max_count = count
      ans = [s[i]]
  else:
    count = 1
    if max_count == 1:
      ans.append(s[i])
if max_count == 1:
  ans.append(s[n-1])
ans = sorted(ans)
for i in range(len(ans)):
  print(ans[i])

Solution (Python):
from collections import defaultdict
n = int(input())
S = [input() for i in range(n)]
d = defaultdict(int)
num=0
for s in S:
  d[s] += 1
  if d[s] > num: num=d[s]
  
max_strs = []
for s in S:
  if d[s]==num: max_strs.append(s)

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

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

most = -1
answer = []
for k, v in sorted(counts.items(), key=lambda x: x[1], reverse=True):
    if most == -1:
        most = v
    if most > v:
         break
    answer.append(k)

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

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

count = {}
max_v = 0
max_lst = []
for i in range(n):
    word = s[i]
    if word in count.keys():
        count[word] += 1
    else:
        count[word] = 1
    if max_v < count[word]:
        max_v = count[word]



for kv in count.items():
    if kv[1] == max_v:
        max_lst.append(kv[0])

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

Solution (Python):
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
from collections import defaultdict
def resolve():
    N = ir()
    S = defaultdict(int)
    for i in range(N):
        S[sr()] += 1
    max_value = max(S.values())
    max_k_list = sorted([kv[0] for kv in S.items() if kv[1] == max_value])
    for l in max_k_list:
        print(l)
resolve()

Solution (Python):
import sys
from math import *
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def main():
    n = int(input())
    Ss = [input() for i in range(n)]

    c = Counter(Ss)
    mc = c.most_common()
    mcn = mc[0][1]

    ans = list()

    for i in range(len(mc)):
        if mc[i][1] == mcn:
            ans.append(mc[i][0])
        else:
            break
    ans.sort()
    
    for i in range(len(ans)):
        print(ans[i])
    
    return

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
d = dict()
for i in range(n):
    s = input()
    if not s in d:
        d[s] = 1
    else:
        d[s] += 1

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

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

counter = Counter(words).most_common()
ans =[]
for i in range(int(len(counter))):
    if counter[0][1] > counter[i][1]:
        break
    ans.append(counter[i][0])
ans.sort()

for i in ans:
    print(i)

Solution (Python):
import collections

num = int(input())

num_list = []
count_list = []
ans = []

for i in range(0,num):
  num_list.append(input())

num_list_2 =collections.Counter(num_list).most_common()

for i in range(0,len(num_list_2)):
  if num_list_2[0][1] > num_list_2[i][1]:
    break
  
  ans.append(num_list_2[i][0])

ans.sort()

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

Solution (Python):
def poll(s_list):
  s_dict = {}
  for s in s_list:
    if s not in s_dict:
      s_dict[s] = 1
    else:
      s_dict[s] += 1

  max_val = max(s_dict.values())
  max_key = [key for key in s_dict if s_dict[key] == max_val]

  new_s_list = sorted(max_key)
  return new_s_list

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

new_list = poll(s_list)

for s in new_list:
  print(s)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
	n = INT()
	count = Counter([input() for _ in range(n)])
	m = max(count.values())
	[print(s) for s in sorted([x for x in count if count[x] == m])]

if __name__=='__main__':
	main()

Solution (Python):
import collections
i = int(input())
S = collections.Counter([input() for _ in range(i)])
max_v = max(S.values())
[print(s) for s in sorted([s for s in S if S[s] == max_v])]

Solution (Python):
import collections

if __name__ == '__main__':

    n = int(input())
    s = [input() for i in range(n)]
    c = collections.Counter(s).most_common()
    n = c[0][1]
    
    result = [i[0] for i in c if i[1] == n]
    
    for i in sorted(result):
        print(i)

Solution (Python):
N = int(input())
d = {}
max = 0
ans = []

for _ in range(N):
    key = input()
    if not(key in d):
        d[key] = 1
        if max<d[key]:
            max = d[key]
    else:
        d[key] += 1
        if max<d[key]:
            max = d[key]

for key in d:
    if d[key]==max:
        ans.append(key)

ans.sort()

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

Solution (Python):
s = {}
m = 0
for _ in range(int(input())):
  t = input()
  if t in s:
    s[t] += 1
  else:
    s[t] = 1
  m = max(m, s[t])
ans = []
for el in s:
  if s[el] == m:
    ans.append(el)
ans.sort()
for a in ans:
  print(a)

Solution (Python):
import collections
a=int(input())
s=[input()for _ in range(a)]
c=collections.Counter(s)
m=0 
for v in c.values(): 
    m=max(m,v)
ans=[]
for k,v in c.items():
    if m == v:
        ans.append(k)
ans.sort()
for i in ans:
    print(i)

Solution (Python):
import collections

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

c = collections.Counter(l)

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

c1 = collections.Counter(list(counts))
n = c1[max(c1.keys())]

v = list(v)
v = v[:n]
v.sort()


for i in v:
  print(i)

Solution (Python):
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
c = Counter(s)
m = 0
for v in c.values():
	m = max(m, v)
ans = []
for k, v in c.items():
	if v == m:
		ans.append(k)
ans.sort()
print(*ans, sep="\n")

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

maxi = 1
count = 1
i = 0
tmp = [0]
while i<N-1:
    if S_S[i] == S_S[i+1]:
        count = count + 1
        if count > maxi:
            maxi = count
            tmp = []
        i = i + 1
    else:
        count = 1
        i = i + 1
    if maxi == count:
        tmp.append(i)


for i in range(len(tmp)):
    print(S_S[tmp[i]])

Solution (Python):
import collections
n = int(input())
s = [input() for i in range(n)]
s.sort()
t = collections.Counter(s)
maxv = max(t.values())
li = []
for key,value in t.items():
    if value == maxv:
        li.append(key)
li.sort()
for i in range(len(li)):
    print(li[i])

Solution (Python):
from collections import defaultdict

N = int(input())
d = defaultdict(int)

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

v = max(d.values())
for s in sorted([i[0] for i in d.items() if i[1]==v]):
    print(s)

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

res = []
for k, v in dic.items():
  if v == max_:
    res.append(k)

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

Solution (Python):
N = int(input())
voteString = {}
count = 0
highList = []

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

for key in voteString:
  count = max(voteString[key], count)
  
for key in voteString:
  if voteString[key] == count:
    highList.append(key)

highList.sort()

for element in highList:
  print(element)

Solution (Python):
N = int(input())
S_map = {}
for _ in range(N):
    Si = input().rstrip('\r')
    if S_map.get(Si) == None:
        S_map[Si] = 1
    else:
        S_map[Si] += 1
S_map_sorted = sorted(S_map.items(), reverse=True, key=lambda x:x[1])
count = S_map_sorted[0][1]
ans = []
for s, c in S_map_sorted:
    if c == count:
        ans.append(s)
    else:
        break
for s in sorted(ans):
    print(s)

Solution (Python):
import collections

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

ans = []
for index, s in enumerate(c):

    if index == 0:
        ans.append(s[0])
    elif c[index][1] == c[index-1][1]:
        ans.append(s[0])
    else:
        break
for result in sorted(ans):
    print(result)

Solution (Python):
from collections import Counter

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

M=Counter(S)
X=max(M.values())
tmp=[]
for i,j in M.items():
	if j==X:
		tmp.append(i)
ans=sorted(tmp)
for i in range(len(ans)):
	print(ans[i])

Solution (Python):
from collections import Counter

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

c = Counter(S)

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

for i, j in c.items():
    if j == m:
        ans.append(i)
ans.sort()

for i in ans:
    print(i)

Solution (Python):
dic={}
max1=0
ans=[]
n=int(input())
for i in range(n):
    word=input()
    if word in dic:
        dic[word]+=1
    else:
        dic[word]=1

for k in dic.values():
    if k>max1:
        max1=k

for n,b in dic.items():
    if b==max1:
        ans.append(n)


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

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

from collections import Counter

c = Counter(s)
m = max(c.values())
ans = []
for k,v in c.items():
    if v == m:
        ans.append(k)
ans.sort()
for i in ans:
    print(i)

Solution (Python):
from collections import Counter

n = int(input())
s = [str(input()) for i in range(n)]
cnt = Counter(s)
l = max(cnt.values())  
ans = [s for s, c in cnt.items() if c == l]
ans.sort()
print('\n'.join(ans))

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

max_val = counts[0]
ans = []
for i in range(len(counts)):
    if counts[i] == max_val:
        ans.append(values[i])
    else:
        break
        
ans.sort()
for a in ans:
    print(a)

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

for i in range(n):
    votes.append(input())

dic = {}    
for vote in votes:
    if vote in dic:
        dic[vote] += 1
    else:
        dic[vote] = 0

maxv = 0        

for value in dic:
    maxv = max(maxv,dic[value])

results =[]    
for value in dic:
    if dic[value] == maxv:
        results.append(value)
        
results.sort()

for result in results:
    print(result)

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

from collections import Counter

counter = Counter(S)
ans = []
c = counter.most_common(1)[0][1]
for word, cnt in counter.most_common():
    if cnt == c:
        ans.append(word)

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

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

res = {}
res_res = []
biggest = 0

for i in range(N):
    x = input()
    if x not in res:
        res[x] = 1
    else:
        res[x] = res[x] + 1

for i in res:
    if res[i] > biggest:
        biggest = res[i]

for i in res:
    if res[i] == biggest:
        res_res.append(i)

res_res = sorted(res_res)

for i in res_res:
    print(i)

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

x = {}
for _ in range(N):
    a = input()
    if a not in x:
        x[a] = 0
    x[a] += 1

mx = max(x.values())

ans = []
for k in x.keys():
    if x[k] == mx:
        ans.append(k)
ans.sort()
for a in ans:
    print(a)

Solution (Python):
from collections import defaultdict

N = int(input())
counter = defaultdict(int)
max_ = 0
for _ in range(N):
    s = input()
    counter[s] += 1
    max_ = max(counter[s], max_)

words = [word for word, n in counter.items() if n == max_]
words.sort()
for word in words:
    print(word)

Solution (Python):


count_dic = {}

item_count = int(input().rstrip())

for i in range(item_count):
    w = input().rstrip()
    if w in count_dic:
        count_dic[w] += 1
    else:
        count_dic[w] = 1
max_count = max(count_dic.values())
keys = [k for k,v in count_dic.items() if v == max_count]
for k in sorted(keys):
    print(k)

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

for count in range(n):
    txt = input()
    if(txt in dict_str):
        dict_str[txt] += 1
    else:
        dict_str[txt] = 1


max = max(dict_str.values())

ans = []
ans = [k for k, v in dict_str.items() if v == max]

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

Solution (Python):
N=int(input())
a=[]
for i in range(N):
  a.append(input())
b={}
for j in range(len(a)):
  if a[j] in b:
    b[a[j]]+=1
  else:
    b[a[j]]=1
max_b=max(b.values())
c=[]
for k,l in b.items():
  if l==max_b:
    c.append(k)
c.sort()
for m in c:
  print(m)

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

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

max_dic = max(dic.values())
ans = [i for i, j in dic.items() if j == max_dic]
ans.sort()

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

Solution (Python):
n = int(input())
moji = dict()
for i in range(n):
    s = input()
    moji[s] = moji.get(s, 0) + 1
max_cnt = max([value for value in moji.values()])
for key, value in sorted(moji.items(), key=lambda x: x[0]):
    if value == max_cnt:
        print(key)

Solution (Python):
N = input()
dic = {}
max = 0
for i in range(int(N)):
  word = input()
  if word not in dic.keys():
    
    if max == 0:
      max += 1
    dic[word] = 1
    
  else:
    
    if max == dic[word]:
      max += 1
    dic[word] += 1

candidates = sorted([word for word in dic.keys() if dic[word] == max])
for word in candidates:
  print(word)

Solution (Python):
n = int(input())
dict = {}
max = 1
for i in range(n):
  str = input()
  if str in dict:
    dict[str] = dict[str] + 1
    if dict[str] > max:
      max += 1
  else:
    dict[str] = 1
keys = [k for k, v in dict.items() if v == max]
keys.sort()
for i in range(len(keys)):
  print(keys[i])

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

s = []

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

s.sort()

l = [1] * n

for i in range(1, n):
    if s[i] == s[i - 1]:
        l[i] = l[i - 1] + 1

m = max(l)

for i in range(n):
    if l[i] == m:
        print(s[i])

Solution (Python):
from collections import Counter

n = int(input())
d = Counter()
for _ in range(n):
    s = input()
    d[s] += 1
mc = d.most_common()
occ = mc[0][1]
ret = []
for w, o in mc:
    if o == occ:
        ret.append(w)
    else:
        break
for w in sorted(ret):
    print(w)

Solution (Python):
import collections
N = int(input())
S = [input() for _ in range(N)]
c = collections.Counter(S)
m = max(c.values())
ans = []
for k, v in c.items():
    if m == v:
        ans.append(k)
ans.sort()
for i in ans:
    print(i)

Solution (Python):
N = int(input())
stats = {}
for i in range(N):
  s = input()
  if s not in stats:
    stats[s] = 1
  else:
    stats[s] += 1
max = max(stats.values())
out = sorted([name for name, num in stats.items() if num == max])
for i in out:
  print(i)

Solution (Python):
def main():
    dic = {}
    n = int(input())
    for _ in range(n):
        s = input().rstrip()
        if s in dic.keys():
            dic[s] += 1
        else:
            dic[s] =  1
    m = max(dic.values())
    ans = [key for key, val in dic.items() if val == m]
    for a in sorted(ans):
        print(a)

if __name__ == "__main__":
    main()

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

dict = {}
for count in range(N):
    tcount = 0
    S= str(input())
    
    if S in dict.keys():
        tcount = dict[S] + 1
        dict.pop(S)
        dict[S] = tcount
    else:
        dict[S] = 1

maxval = max(dict.values())

keys = [k for k, val in dict.items() if val == maxval]
keys.sort()

for count in range(len(keys)):
    print(keys[count])

Solution (Python):

import sys
from collections import Counter
n = int(sys.stdin.readline())
S = [sys.stdin.readline().rstrip() for _ in range(n)]
S = Counter(S)
max_cnt = S.most_common()[0][1]

ans = [key for key, value in S.items() if value==max_cnt]

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

Solution (Python):
n = int(input())
s = [input() for _ in range(n)]
import collections
c = collections.Counter(s)
d = c.most_common()
e = [d[0][0]]
for i in range(len(d)-1): 
   if d[0][1] == d[i+1][1]:
      e.append(d[i+1][0])       
e.sort()
print('\n'.join(e))

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

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

d = {}
for s in S:
  if s in d:
    d[s] += 1
  else:
    d[s] = 1

list = []
max = max(d.values())
for k, v in d.items():
  if max == v:
    list.append(k)

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

Solution (Python):


from collections import Counter


def main():
    N = int(input())
    S = [input() for _ in range(N)]
    S = Counter(S)

    SM = S.most_common()[0][1]
    S = sorted(S.items(), key=lambda x: [-x[1], x[0]])
    for key, value in S:
        if value == SM:
            print(key)
        else:
            break


if __name__ == "__main__":
    main()

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

S_dict = {}

for string in S_list:
    if not string in S_dict:
        S_dict[string] = 1
    else:
        S_dict[string] += 1

max_k = max(S_dict.values())
result = []
for k, v in S_dict.items():
    if v == max_k:
        result.append(k)

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

Solution (Python):
n = int(input())
s = [input() for _ in range(n)]
d = {}
for w in s:
    if w not in d:
        d[w] = 0
    d[w] += 1
d2 = sorted(d.items(), key=lambda x:x[1], reverse=True)
maxcnts = [w[0] for w in d2 if w[1] == d2[0][1]]
maxcnts.sort()
for ans in maxcnts:
    print(ans)

Solution (Python):
import collections


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

c = collections.Counter(S)

max_vale = max(c.values())

hoge = []
for k, v in c.items():
    if max_vale == v:
        hoge.append(k)

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

Solution (Python):
import collections


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

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

hoge = []
for k, v in c.items():
    if max_vale == v:
        hoge.append(k)

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

Solution (Python):
from collections import Counter

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


counter = Counter(S)

mostnum = 0
ans = []
for c in counter.most_common():
    if mostnum <= c[1]:
        mostnum = c[1]
        ans.append(c[0])
    else:
        break

ans.sort()

for a in ans:
    print(a)

Solution (Python):
import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    n = int(input())
    dic = defaultdict(lambda: 0)
    count = 0
    for _ in range(n):
        s = input()
        dic[s] += 1
        count = max(count, dic[s])

    candidates = []
    for key in dic.keys():
        if dic[key] == count:
            candidates.append(key)

    candidates.sort()
    for c in candidates:
        print(c)

if __name__ == '__main__':
    main()

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

def resolve():
    N = int(input())
    S_list = []
    for i in range(N):
        S_list.append(input())
    
    cc = collections.Counter(S_list)
    cc_list = cc.most_common()

    most_num = cc_list[0][1]
    tmp_list = []

    for i in cc_list:
        if most_num == i[1]:
            tmp_list.append(i[0])
        else:
            break

    tmp_list_sorted = sorted(tmp_list)
    for tls in tmp_list_sorted:
        print(tls)


if __name__ == "__main__":
    resolve()

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

max_value = max(count.values())
max_key_list = [kv[0] for kv in count.items() if kv[1] == max_value]
max_key_list.sort()
for key in max_key_list:
    print(key)

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

c = Counter(S)
cnt = 1
c = c.most_common()
for i in range(len(c)-1):
    if c[i][1] == c[i+1][1]:
        cnt += 1
    else:
        break
ans_list = [""] * cnt
for i in range(cnt):
    ans_list[i] = c[i][0]
ans_list.sort()
for i in range(cnt):
    print(ans_list[i])

Solution (Python):
import collections
N = int(input())
listA = []
listB = []
for i in range(N):
    listA.append(input())
c = collections.Counter(listA)
c = c.most_common()
max_number = c[0][1]
listB.append(c[0][0])
A = len(c)
for i in range(1,A):
    if max_number == c[i][1]:
        listB.append(str(c[i][0]))
    else:
        break
listB.sort()
for i in listB:
    print(i)

Solution (Python):
countStr = {}
maxKeys = []

n = int(input())

for i in range(n):
    s = input()
    countStr.setdefault(s, 0)
    countStr[s] = countStr[s] + 1

maxValue = max(countStr.values())

countStr = list(countStr.items())

for i in countStr:
    if i[1] == maxValue:
        maxKeys.append(i[0])

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

Solution (Python):
from collections import Counter

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

cnt = Counter(s).most_common()

res = [cnt[0][0]]
if len(cnt) > 1:
    for i in range(1, n):
        if cnt[i-1][1] == cnt[i][1]:
            res.append(cnt[i][0])
        else:
            break

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

Solution (Python):
from collections import Counter

N = int(input())
c = Counter([input() for _ in range(N)])
mv = max(c.values())
[print(w) for w in sorted(c.keys()) if c[w] == mv]

Solution (Python):
N = int(input())
d = {}
mv = 0
mfw = []
for _ in range(N):
    w = input()
    d[w] = d.get(w, 0) + 1
    if d[w] > mv:
        mv += 1
        mfw.clear()
        mfw.append(w)
    elif d[w] == mv:
        mfw.append(w)
[print(w) for w in sorted(mfw)]

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

d = {}
for s in S:
  if s in d:
    d[s] += 1
  else:
    d[s] = 1
d = sorted(d.items(), key = lambda x:(-x[1],x[0]))

for di in d:
  if di[1] == d[0][1]:
    print(di[0])
  else:
    break