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())
s = [input() for _ in range(n)]
s.sort()

max_cnt = 0
dup_str = 1
cnt = 1
ans = [""] * n
for i in range(n-1):
    if s[i+1] == s[i]: cnt +=1
    else:
        if cnt > max_cnt:
            
            max_cnt = cnt
            ans[0] = s[i] 
            dup_str = 1
        elif cnt == max_cnt:
            ans[dup_str] = s[i]
            dup_str += 1
        cnt = 1
    if i == n-2:
        if cnt > max_cnt:
            max_cnt = cnt
            ans[0] = s[i] 
        elif cnt == max_cnt:
            ans[dup_str] = s[i]
            dup_str += 1
        if max_cnt == 1 and cnt == 1:
            ans[n-1] = s[n-1]
            dup_str = n

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

Solution (Python):
import collections
import sys
input = sys.stdin.readline
n = int(input())
s = []
for i in range(n):
  s.append(input())

c = collections.Counter(s)

x = c.most_common()
m = x[0][1]
l = len(x)
ans = []
for i in range(l):
  if x[i][1] == m:
    ans.append(x[i][0])
  else:
    break
ans0 = sorted(ans)
for i in range(len(ans0)):
  print(ans0[i],end="")

Solution (Python):
N = int(input())
count_dict = {}
answer = []
for i in range(N):
  key = input()
  if key in count_dict.keys():
    count_dict[key] += 1
  else:
    count_dict[key] = 1
sorted_dict = sorted(count_dict.items(), key=lambda x:x[1], reverse=True)
max_count = sorted_dict[0][1]
answer.append(sorted_dict[0][0])

for i in range(1, len(sorted_dict)):
  if sorted_dict[i][1] == max_count:
    answer.append(sorted_dict[i][0])
  else:
    break

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

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

most_common_list=Counter(S).most_common()

common_s=[]

for i in range(len(most_common_list)):
    if most_common_list[i][1]==most_common_list[0][1]:
        common_s.append(most_common_list[i][0])
    else:
        break

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

Solution (Python):


import sys
import math
import time
import numpy as np
import collections
from collections import deque
import queue
import copy


def gcd(m,n):
  x = max(m,n)
  y = min(m,n)
  if x%y == 0:
    return y
  else:
    while x%y != 0:
      z = x%y
      x = y
      y = z
    else:
      return z


def bfs(SS, x, y, H, W):
  x_next = [0, 0, -1, 1]
  y_next = [1, -1, 0, 0]
  tempx = x
  tempy = y
  mlength = 0
  q = deque()
  xytuple = (x, y, 0)
  q.append(xytuple)


  while q:
    xytuple = q.popleft()
    SS[xytuple[0]][xytuple[1]] = "x" 
    for i in range(4): 
      tempx = xytuple[0] + x_next[i]
      tempy = xytuple[1] + y_next[i]
      
      
      if(0 <= tempx and tempx < H and 0 <= tempy and tempy < W and SS[tempx][tempy] == "."):
        temptuple = (tempx, tempy, xytuple[2]+1)
        SS[temptuple[0]][temptuple[1]] = "x" 
        mlength = max(mlength, xytuple[2] +1)
        q.append(temptuple)
      
  return mlength

def brick(a,n,m,N):
  
  if not m in a[n:]:
    print(N-(m-1))
  else:
    
    brick(a,a[n:].index(m),m+1,N)




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

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


B.append(a[0][0])

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

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

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

S_sorted = sorted(S)
dupulication = [0 for i in range(N)]
dupMax = 0
output=""

for i in range(N-1):
    if(S_sorted[i+1] == S_sorted[i]):
        dupulication[i+1] = dupulication[i] + 1
        if (dupulication[i+1] >= dupMax):
            dupMax = dupulication[i+1]

for i in range(N):
    if dupulication[i]==dupMax:
        output += S_sorted[i]+"\n"


print(output)

Solution (Python):

import collections

n = int(input())

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


c = collections.Counter(s)


max_c = max(c.values())


keys = [k for k, v in c.items() if v == max_c]
keys.sort()

for k in keys:
    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())
S = [input() for _ in range(n)]
d = {}
m = 0
for s in S:
    if s in d:
        d[s] += 1
    else:
        d[s] = 1
    m = max(m, d[s])

sd = sorted(d.items(), key=lambda x: x[1], reverse=True)
ans = []
for k, v in sd:
    if v != m:
        break
    ans.append(k)

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

Solution (Python):
N = int(input().rstrip())
d = {}
for _ in range(N):
    string = input().rstrip()
    if string in d.keys():
        d[string] += 1
    else:
        d[string] = 1
d = sorted(d.items(), key=lambda x: x[1], reverse=True)

rets = []
max = -1
for string, val in d:
    if max == -1:
        max = val
    elif max != val:
        break
    rets.append(string)

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

Solution (Python):
N = int(input())
hist = {}
for _ in range(N):
    s = input()
    hist[s] = hist.get(s,0) + 1

mx = max(list(hist.values()))
ans = []
for x in hist.keys():
    if hist[x] == mx:
        ans.append(x)
ans = sorted(ans)
for x in ans:
    print(x)

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

words = set()
cnt = dict()
for i in range(n):
  if s[i] not in words:
    words.add(s[i])
    cnt[s[i]] = 1
  else:
    cnt[s[i]] += 1

top_words = []
max_val = 0
for k, v in cnt.items():
  if v > max_val:
    max_val = v
    top_words = [k]
  elif v == max_val:
    top_words.append(k)

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

Solution (Python):
input_num = int(input())
dic = {}
strlist = []
strlist2 = []
maxi = 1
for i in range(input_num):
  strlist.append(input())
for i in range(input_num):
  if dic.setdefault(strlist[i],0) != 0:
    dic[strlist[i]] += 1
    if dic[strlist[i]] > maxi:
      maxi = dic[strlist[i]]
  else:
    dic[strlist[i]] = 1
    strlist2.append(strlist[i])
strlist2.sort()
for i in range(len(strlist2)):
  if dic[strlist2[i]] == maxi:
    print(strlist2[i])

Solution (Python):
import collections

def main():
    n = int(input())
    str_list = [input() for _ in range(n)]

    if len(str_list) == len(set(str_list)):
        str_list.sort()
        print(*str_list,sep='\n')
        exit()

    count_list = collections.Counter(str_list)

    max_num = max(count_list.values())

    output_list = []

    for k, v in count_list.items():
        if max_num == v:
            output_list.append(k)

    output_list.sort()

    print(*output_list,sep='\n')

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
A = [input() for i in range(N)]
import collections
c = dict(collections.Counter(A))
max_value = max(list(c.values()))
ans = []
for k ,v in c.items():
    if max_value == v:
        ans.append(k)
for i in sorted(ans):
    print(i)

Solution (Python):
from collections import defaultdict

N = int(input())
D = defaultdict(int)
for i in range(N):
    D[input()] += 1

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

num = max(D.values())
ans = []
for key, value in sorted_D:
    if value == num:
        ans.append(key)
    else:
        break
ans.sort()
for i in ans:
    print(i)

Solution (Python):
N = int(input())
S = [input() for i in range(N)]
count_dict = {}
for s in S:
  if not s in count_dict.keys():
    count_dict[s] = 1
  else:
    count_dict[s] += 1
maxnum = max(count_dict.values())
count_dict = dict(filter(lambda x: x[1] == maxnum, count_dict.items()))
ans = list(count_dict.keys())
ans.sort()
for s in ans:
  print(s)

Solution (Python):
import collections

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

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

ans = m[0][1]
ans_list = [i[0] for i in c.items() if i[1] >= ans]
ans_list.sort()
for i in ans_list:
    print(i)

Solution (Python):
from collections import Counter
n=int(input())
x=[]
for i in range(n):
    x.append(input())
x=Counter(x)    
x=x.most_common()
max_count=x[0][1]
max_list=[x[0][0]]
if len(x)>1:
    for i in range(1,n):
        if x[i][1] < max_count:
            break
        else:
            max_list.append(x[i][0])


max_list=sorted(max_list)
for w in max_list:
    print(w)

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

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

ans = []
s_max = max(sl.values())
for key in sl:
    if sl[key] == s_max:
        ans.append(key)

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

Solution (Python):
from collections import Counter
def main():
    N = int(input())
    S = list(input() for _ in range(N))
    counter = Counter(S)
    most_count = []
    max_count = 0
    for i, (word, cnt) in enumerate(counter.most_common()):
        if max_count>cnt:
            break
        max_count = cnt
        most_count.append(word)
    most_count.sort()
    for m in most_count:
        print(m)



if __name__=='__main__':
    main()

Solution (Python):

def main():
    N = int(input())
    S = {}
    for i in range(N):
        K = str(input())
        if(K not in S):
            S[K] = 0
        else:
            S[K] += 1
    max_v = max(S.items(), key = lambda x: x[1])
    ans = []
    for k, v in S.items():
        if v == max_v[1]:
            ans.append(k)
    ans.sort()
    for a in ans:
        print(a)




if __name__ == '__main__':
    main()

Solution (Python):
N=int(input())
dic={}
for i in range(N):
    s = input()
    try:
      dic[s]+=1
    except:
      dic[s]=0
slis = sorted(dic.items(), key=lambda x:x[1],reverse=True)
maxv=slis[0][1]
lis = []
for i in range(len(slis)):
  if slis[i][1]==maxv:
    lis += [slis[i][0]]
  else:
    break
lis=sorted(lis)
for s in lis:
  print(s)

Solution (Python):
from itertools import groupby
from operator import itemgetter

a = sorted(input() for _ in range(int(input())))
a = sorted((-sum(1 for _ in g), s) for s, g in groupby(a))
for _, s in next(groupby(a, itemgetter(0)))[1]:
  print(s)

Solution (Python):
import collections

N = int(input())

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

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

ans = list()
for s in c.most_common():
	if s[1] == max_value:
		ans.append(s[0])
	else:
		break

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

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

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

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

cnt = s[0][1]
ans = []
for i in range(len(s)):
    if s[i][1] == cnt:
        ans += [s[i][0]]
    else:
        break

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

Solution (Python):
def main():
  num = int(input())
  x = {}
  for i in range(num):
    s = input()
    if s in x:
      x[s] += 1
    else:
      x[s] = 1
  sl = []
  max_cnt = 0
  for key in x:
    if x[key] > max_cnt:
      max_cnt = x[key]
      sl = []
    if x[key] == max_cnt:
      sl.append(key)


  sl.sort()
  for s in sl:
    print(s)


main()

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

d = dict()
m = 1

for i in range(N):
    if A[i] in d:
        d[A[i]] = d[A[i]] + 1
        if m < d[A[i]]:
            m = d[A[i]]
    else:
        d[A[i]] = 1

ans = []
keys = list(d.keys())

for i in range(len(keys)):
    if m == d[keys[i]]:
        ans.append(keys[i])

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

Solution (Python):

import sys
import collections


def solve(N: int, S: "List[str]"):
    c = collections.Counter(S)
    values, counts = zip(*c.most_common())

    max_value = counts[0]
    result_index = 0
    for count in counts[1:]:
        if count == max_value:
            result_index += 1
        else:
            pass
    results = sorted(values[: result_index + 1])
    for result in results:
        print(result)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  
    S = [next(tokens) for _ in range(N)]  
    solve(N, S)


if __name__ == "__main__":
    main()

Solution (Python):


import collections
import copy

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

s_count = collections.Counter(s).most_common()
max_count = s_count[0][1]
roop = True
index = 1
s_count_len = len(s_count)
while roop and index < s_count_len:
    if s_count[index][1] == max_count:
        index += 1
    else:
        roop = False

values, counts = zip(*s_count[0:index])

out_list = sorted(values)
print("\n".join(out_list))

Solution (Python):
from collections import defaultdict
n=int(input())
d={}
for _ in range(n):
    n=input()
    if n in d:
        d[n]+=1
    else:
        d[n]=1
l=[]
mm=0
for y in d.values():
    if y>mm:
        mm=y
for x,y in d.items():
    if y==mm:
        l.append(x)
l=sorted(l)
for i in l:
    print(i)

Solution (Python):
n = int(input().strip())
S = [input().split() for i in range(n)]

mx=0

S.sort()
ni=0
ans=[]
for i in range(n):
    if ni>mx:
        ans=S[i]
        mx=ni
    elif ni==mx:
        ans+=S[i]
    if i<n-1:
        if S[i+1]==S[i]:
            ni+=1
        else:
            ni=0

    
[print(i) for i in ans]

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

d = dict()
m = 0
for i in range(N):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1
    if d[s] >= m:
        m = d[s]

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

Solution (Python):

N = int(input())

mydict = {}

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

values = list(mydict.values())
list.sort(values, reverse=True)

max_value = values[0]
keys = list()
for key, value in mydict.items():
    if value == max_value:
        keys.append(key)
list.sort(keys)

for i in keys:
    print(i)

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

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

val_max = max(s.values())
keys_val_max = [k for k in s if s[k] == val_max]

keys_val_max.sort()
for k in keys_val_max:
	print(k)

Solution (Python):
n=int(input())
lis=[]
dic={}
lis2=[]
lis3=[]
b=0
for i in range(n):
    lis.append(input())
for i in lis:
    if i in dic:
        dic[i]+=1
    else:
        dic[i]=1
for i in dic.keys():
    lis2.append(dic[i])
lis2=sorted(lis2)
a=lis2[-1]
for i in dic.keys():
    if dic[i]==a:
        lis3.append(i)
lis3=sorted(lis3)
for i in lis3:
    print(i)

Solution (Python):
import collections

n = int(input())

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

c = collections.Counter(s).most_common()
mx = c[0][1]

out = list()
for e in c:
        if e[1] == mx:
                out += [e[0]]
        else:
                break
out.sort()
print(*out, sep='\n')

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

sdict = {}

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



maximum = sdict[max(sdict, key=sdict.get)]


rlist=[]

for k, v in sdict.items():
    if v == maximum:
        rlist.append(k)

rlist.sort()

for r in rlist:
    print(r)

Solution (Python):
import collections

n = int(input())
s_list = []
for _ in range(n):
    s_list.append(input())
s_data = list(collections.Counter(s_list).most_common())
s_count = int(s_data[0][1])
s_index = 0
for s in s_data:
    if int(s[1]) == s_count:
        s_index += 1
    else:
        break
output = []
for i in range(s_index):
    output.append(s_data[i][0])
output.sort()
for s in output:
    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):




import sys
input = sys.stdin.readline



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

    dict = {S[0]:1}

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

    res = []

    most = max(dict.values())

    for i in dict:
        if dict[i] == most:
            res.append(i)

    res.sort()

    M = len(res)

    for i in range(M):
        print(res[i])



main()

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

d = {}
m = 0
for i in range(n):
    s = input()
    if s not in d:
        d[s] = 0
    d[s] += 1
    if d[s] > m:
        m = d[s]
al = []
for t in d:
    if d[t] == m:
        al.append(t)
al.sort()
for t in al:
    print(t)

Solution (Python):
import sys
input = sys.stdin.readline
import collections

def main():
    n=int(input())
    sdic={}
    for i in range(n):
        s=input()
        if s in sdic.keys():
            sdic[s]+=1
        else:
            sdic.setdefault(s,0)
    sdic_sorted = sorted(sdic.values(), reverse=True)
    mn=sdic_sorted[0]
    ans=[]
    for k,v in sdic.items():
        if v==mn:
            ans.append(k)
    ans.sort()
    for i in ans:
        print(i.rstrip('\n'))


if __name__ == '__main__':
    main()

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())
words = {}
for i in range(n):
    s = input()
    if s in words.keys():
        words[s] = words[s]+1
    else:
        words[s]=1
        
sorted_words = sorted(words.items(),reverse=True,key=lambda x:x[1])
ma = sorted_words[0][1]
ans = []
for i in range(len(sorted_words)):
    if sorted_words[i][1]==ma:
        ans.append(sorted_words[i][0])
    else:
        break
ans.sort()
for i in ans:
    print(i)

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

import collections
c = collections.Counter(S)
values, counts = zip(*c.most_common())

if len(counts)==1:
  print(values[0])
else:
  n = 0
  for j in range(1,N):
    if counts[j]!=counts[j-1]:
      n = j
      break
    else:
      n = j+1
  
  ans = list(values[:n])
  ans = sorted(list(ans))
  
  for k in ans:
    print(k)

Solution (Python):
import collections
N = int(input())
S = [input() for i in range(N)]
c = collections.Counter(S)
max = max(c.values())
d = sorted(c.items(), key=lambda x: x[0])

for i in range(len(d)):
    if d[i][1] == max:
        print(d[i][0])

Solution (Python):
from collections import defaultdict

def run():
    n = int(input())
    s = defaultdict(int)
    lst = []

    for _ in range(n):
        string = input()
        s[string] += 1
    
    max_ = 0
    
    for key in s:
        if max_ < s[key]:
            lst = [key]
            max_ = s[key]
        elif max_ == s[key]:
            lst.append(key)
    lst = sorted(lst)
    for i in lst:
        print(i)
        
    

if __name__ == "__main__":
    run()

Solution (Python):
lenght = int(input())
items = []
for _ in range(lenght):
  items.append(input())
counts = dict()
for i in items:
  counts[i] = counts.get(i, 0) + 1
a = sorted(counts.items(), key=lambda x: x[0])    
b = sorted(a, key=lambda x: x[1], reverse = True)
for i in b:
  if(i[1] == b[0][1]):
    print(i[0])
  else:
    break

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

poll = {}
max_val = 1
for i in range(n):
    name = input()

    if name not in poll:
        poll[name] = 1
    else:
        poll[name] += 1
        max_val = max(poll[name], max_val)

winner = []

for name, vote in poll.items():
    if vote == max_val:
        winner.append(name)
        
winner.sort()
for w in winner:
    print(w)

Solution (Python):
import collections

cou = int(input())
a = []
momo = []

for i in range(cou):
    s = str(input())
    a.append(s)

c = collections.Counter(a)
values, counts = zip(*c.most_common())

d = counts.count(counts[0])

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

for i in ans:
    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 = int(input())
S = [input() for i in range(N)]
mydict = {}
for i in range(N):
    if S[i] not in mydict.keys():
        mydict[S[i]] = 1
    else:
        mydict[S[i]] += 1
sortedDict = sorted(mydict.items(), key=lambda x:x[1], reverse=True)
mylist = [sortedDict[0][0]]
length = len(sortedDict)
if(length > 1):
    for i in range(length-1):
        if sortedDict[i][1] == sortedDict[i+1][1]:
            mylist += [sortedDict[i+1][0]]
            i += 1
        else: break
    mylist.sort()
for i in range(len(mylist)):
    print(mylist[i])

Solution (Python):
import collections
n = int(input())
s = [input() for _ in range(n)]
c = collections.Counter(s)
if len(c) == 1:
    print(s[0])
    exit()
a = c.most_common()[0][1]
b = c.most_common()
d = collections.deque()
for i in range(n):
    if b[i][1] == a:
        d.append(b[i][0])
    else:
        break
for i in sorted(list(d)):
    print(i)

Solution (Python):







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


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

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

ans.sort()


for a in ans:
    print(a)

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

Solution (Python):
import sys
input=sys.stdin.readline

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

for i in range(N):
    s_list.append(input().strip())

s_list.sort()
s_old=s_list[0]
cnt=1
maxc=0
max_list=[]
for s in s_list[1:]:
    if s==s_old:
        cnt+=1
    else:
        if cnt>maxc:
            max_list=[s_old]
            maxc=cnt
        elif cnt==maxc:
            max_list.append(s_old)
        else:
            pass

        cnt=1

    s_old=s

if cnt>maxc:
    max_list=[s_list[-1]]
elif cnt==maxc:
    max_list.append(s_list[-1])

for s in max_list:
    print(s)

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

ans=[]
cnt=0
m=counts[0]
for i in range(len(values)):
    if counts[i]==m:
        ans.append(values[i])
        cnt+=1
    else:
        break
ans.sort()
for i in range(cnt):
    print(ans[i])

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

a1 = collections.Counter(a)
values, counts = zip(*a1.most_common())

ans = values[0:counts.count(counts[0])]
ans = sorted(ans)
for i in ans:
  print(i)

Solution (Python):
import collections

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

setted_S = set(S)
counted_S = collections.Counter(S)
sorted_S = sorted(counted_S.items(), key=lambda x: x[1], reverse=True)

ans_ls = []
for s in sorted_S:
    a = sorted_S[0][1]
    if s[1] == a:
        ans_ls.append(s[0])
    else:
        break

ans_ls.sort()

for i in ans_ls:
    print(i)

Solution (Python):
import collections

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

A = []

d = collections.Counter(S)
max_v = max(d.values())

for k, v in d.items():
    if v == max_v:
        A.append(k)

A.sort()

for result in A:
    print(result)

Solution (Python):
n=int(input())
s={}
ans=[]
max=0
for i in range(n):
    st=input()
    if st in s:
        s[st]+=1
    else:
        s[st]=1
    if max<s[st]:
        max=s[st]
        ans=[st]
    elif max==s[st]:
        ans.append(st)
ans.sort()
for i in ans:
    print(i)

Solution (Python):
from collections import Counter

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

counter_S = Counter(S)

max_val = max(counter_S.values())

for k,v in sorted(counter_S.items()):
    if (v == max_val):
        print(k)

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

cnt_max = 1
cnt = 1
ans = [0] * N
ans[0] = S[0]
flag = 0
for i in range(1, N):
    if S[i-1] == S[i]:
        cnt += 1
        if i == N-1:
            if cnt > cnt_max:
                print(S[i])
                exit()
            elif cnt == cnt_max:
                ans[flag] = S[i]
    else:
        if cnt > cnt_max:
            ans = [0] * N
            ans[0] = S[i-1]
            flag = 1
            cnt_max = cnt
        elif cnt == cnt_max:
            ans[flag] = S[i-1]
            flag += 1
        cnt = 1
        if cnt == cnt_max and i == N-1:
            ans = S
    


i = 0
while ans[i] != 0:
    i += 1
    if i == N:
      break
ans = ans[:i]
for i in range(len(ans)):
    print(ans[i])

Solution (Python):
from collections import Counter

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

S = Counter(S)
max_val = max(S.values()) 
k_list = [ k for k, v in S.items() if v == max_val]

for k in sorted(k_list):
    print(k)

Solution (Python):
import collections
from collections import Counter
n = int(input())
s = []
ans = []
for i in range(n):
    S = input()
    s.append(S)
count = collections.Counter(s)
values, counts = zip(*count.most_common())
counts2 = list(counts).sort(reverse = True)
ans.append(values[0])
for j in range(1,len(counts)):
    if counts[0] == counts[j]:
        ans.append(values[j])
    else:
        break
ans.sort()
for k in ans:
    print(k)

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

dic = {}
mx = 0

for i in range(N):
  s = input()
  if s in dic:
    dic[s] = dic[s] + 1
  else:
    dic[s] = 1
  
  if mx < dic[s]:
    mx = dic[s]


for s in sorted({k for k,v in dic.items() if v==mx}):
  print(s)

Solution (Python):

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

    
dic = {}
m = 0

for i in L:
    if i in dic:
        dic[i] = dic[i] + 1
    else:
        dic[i] = 1
        
    if m < dic[i]:
        m = dic[i]

n = []
for i in dic:
    if dic[i] == m:
        n.append(i)
n.sort()
for i in n:
    print(i)

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

S = sorted(S.items(), key=lambda x: x[1], reverse=True)
max_str = []
before = S[0][1]
for i in range(len(S)):
    if before > S[i][1]:
        break
    max_str.append(S[i][0])
    before = S[i][1]
max_str.sort()
for s in max_str:
  print(s)

Solution (Python):
n = int(input())
s = ["" for i in range(n)]
for j in range(n):
    s[j] = str(input())
s.sort()
count = [0 for _ in range(len(set(s)))]
l = 0
name = list(sorted(set(s)))
for k in range(n-1):
    count[l] += 1
    if(s[k] != s[k+1]):
        l += 1

count[-1] += 1

m_v = max(count)
ansnum = []

for h in range(len(count)):
    if(count[h] == m_v):
        ansnum.append(name[h])

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

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

dict = {}
max_count = 0
for i in range(n):
  input_line = input()
  if input_line in dict:
    dict[input_line] += 1
  else:
    dict[input_line] = 1
  if max_count < dict[input_line]:
    max_count = dict[input_line]

keys = [k for k, v in dict.items() if v == max_count]
keys.sort()
print("\n".join(keys))

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

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

top = D_sorted[0][1]
for k in D_sorted:
  if top == k[1]:
    print(k[0])
  else:
    exit()

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

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

dic = {}

for i in A:
        if i not in dic:
                dic[i] = 1
        else:
                dic[i] += 1

de = 0

ans_list = []


for k, v in sorted(dic.items(), key=lambda x: x[1], reverse = True):
        if v != de and de !=0:
                break
        else:
                ans_list.append(k)
        de = v

ans_list_n = sorted(ans_list)


for i in ans_list_n:
        print(i)

Solution (Python):
n = int(input())
mymap = {}
maxi = 1
for x in range(n):
	inp = input()
	if inp in mymap:
		mymap[inp] += 1
		if mymap[inp] > maxi:
			maxi = mymap[inp]
	else:
		mymap[inp] = 1

answer = []

for x in mymap:
	if mymap[x] == maxi:
		answer.append(x)

answer.sort()

for x in answer:
	print(x)

Solution (Python):
N=int(input())
dictionary={}
for i in range(N):
    a=input()
    if a not in dictionary:
        dictionary[a] =1
    else:
        dictionary[a] +=1
dict_sorted = sorted(dictionary.items(), key=lambda x:x[0])
dict_sorted = sorted(dict_sorted, key=lambda x:x[1],reverse=True)
max_count=dict_sorted[0][1]
for i,j in dict_sorted:
    if j==max_count:
        print(i)

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