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)]
d = {}

for i in s:
    d[i] = d.get(i, 0) + 1

d = sorted(d.items(), key=lambda x: x[1], reverse=True)
maxv = d[0][1]
ans = []
for s in d:
    if s[1] == maxv:
        ans.append(s[0])
    else:
        break

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

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

for i in s:
    d[i] = d.get(i, 0) + 1


d = sorted(d.items(), key=lambda x: x[1], reverse=True)
maxv = d[0][1]
ans = []
for s in d:
    if s[1] == maxv:
        ans.append(s[0])
    else:
        break

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

Solution (Python):
import sys
import collections

input = sys.stdin.readline

def main():
    N = int(input())
    Slist = []
    for _ in range(N):
        Slist.append(str(input()[:-1]))
    SlistCounter = list(collections.Counter(Slist).items())
    SlistCounter.sort(key=lambda x: x[0])
    SlistCounter.sort(key=lambda x: x[1], reverse=True)
    maxcnt = SlistCounter[0][1]
    for s, cnt in SlistCounter:
        if cnt != maxcnt:
            break
        print(s)

if __name__ == "__main__":
    main()

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

Solution (Python):
from collections import Counter
n = int(input())
s = [input() for i in range(n)]
num = Counter(s)
mx = max(num.values())
T = []
for n in sorted(num):
    if num[n] == mx:
        print(n)

Solution (Python):
n = int(input())
S = ['']*n
T = []
for i in range(n):
    S[i] = input()
S.sort()
if n == 1:
    print(S[0])
    exit()
cnt = 1
mxcnt = 1
for i in range(n-1):
    if S[i] == S[i+1]:
        cnt += 1
    else:
        cnt = 1
    mxcnt = max(mxcnt,cnt)
cnt = 1
for i in range(n-1):
    if S[i] == S[i+1]:
        cnt += 1
    else:
        cnt = 1
    if cnt == mxcnt:
        T.append(S[i])
if mxcnt == 1:
    T.append(S[-1])
for t in T:
    print(t)

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

words = {}
for i in range(n):
  word = input()
  if word in words:
    words[word] += 1
  else :
    words[word] = 1
words_sorted = sorted(words.items(), key=lambda x:x[1], reverse=True)    
score = words_sorted[0][1]
answers = []
for word in words_sorted:
  if score == word[1]:
    answers.append(word[0])
  else :
    break
    
for answer in sorted(answers) :
  print(answer)

Solution (Python):
from collections import Counter
n = int(input())
s = [str(input()) for _ in range(n)]
num = Counter(s)
ans = []
ma = max(num.values())
for i in sorted(num):
    if num[i] == ma:
        print(i)

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

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

C = sorted(dic.items())
max_dic = max(dic.values())

for name,i in C:
    if i == max_dic:
        print(name)

Solution (Python):
from collections import defaultdict
N = int(input())
dic = defaultdict(lambda:0)
for _ in range(N):
    key = input()
    dic[key] += 1

maxnum = max(dic.values())
collection = []
for key, value in dic.items():
    if value == maxnum:
        collection.append(key)

collection.sort()
for word in collection:
    print(word)

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

for _ in range(N):
  S = input()
  if S not in index: index[S] = 1
  else: index[S] += 1

max_cnt = max(index.values())

ls = [key for key in index.keys() if index[key] == max_cnt]

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

Solution (Python):
import collections

N=int(input())
S=sorted([input() for _ in range(N)])
s=sorted(list(set(S)))
l=len(s)
c=collections.Counter(S)
max_v = max(c.values())
for i in range(l):
    if max_v==c[s[i]]:
        print(s[i])

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




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

max_count = max(dic.values()) 


l = [key for key in dic.keys() if dic[key] == max_count]


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

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




S = Counter(S).most_common()

max_count = S[0][1] 


l = [s[0] for s in S if s[1] == max_count]


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

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




S = Counter(S).most_common()
max_count = S[0][1] 

l = [s[0] for s in S if s[1] == max_count]


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

Solution (Python):
n=int(input())
wl={}
for i in range(n):
    w=input()
    if w not in wl:
        wl[w]=0
    wl[w]+=1
wm=max(wl.values())
wl3=sorted(wl.items())
for i in range(len(wl3)):
    if wl3[i][1]==wm:
        print(wl3[i][0])

Solution (Python):
from collections import Counter as c
N = int(input())
S = list(input() for _ in range(N))
S.sort()
C, i = c(S).most_common(), 0
l, n = len(C), C[0][1]
while i < l:
  if n == C[i][1]: print(C[i][0])
  else: break
  i += 1

Solution (Python):
from collections import Counter
n=int(input())
a=[]
for i in range(n):
  a.append(input())
ac=Counter(a)
acs=sorted(ac.items(),key=lambda x:x[1],reverse=1)
z=len(acs)
i=0
temp=[]

while i<=z-1 and acs[i][1]==acs[0][1] :
  temp.append(acs[i][0])
  i+=1
temp.sort()
for i in temp:
  print(i)

Solution (Python):
from collections import Counter

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

S = Counter(S).most_common()
l = []
for i in S:
  if i[1] == S[0][1]: l.append(i[0])

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

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from collections import Counter

    N = int(readline())
    c = Counter()

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

    _, cnt = c.most_common(1)[0]

    res = []
    for key, val in c.items():
        if val == cnt:
            res.append(key)

    res.sort()

    for x in res:
        print(x)


if __name__ == '__main__':
    main()

Solution (Python):

import sys
def input():
    return sys.stdin.readline()[:-1]

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

    T = sorted((set(S)))
    l = len(T)

    D = {}
    for i in range(l):
        D[T[i]] = 0
    for i in range(N):
        D[S[i]] += 1

    m = max(D.values())
    for i in range(l):
        if D[T[i]] == m:
            print(T[i])


if __name__ == '__main__':
    main()

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

dc = {}

def cnt_str(s , d:dict):
    if s in d.keys():
        d[s]+=1
    else:
        d[s]=1

for i in range(n):
    cnt_str(input(), dc)

maxc = max([c for k, c in dc.items()])

[print(s) for s in sorted(dc.keys()) if dc[s]==maxc]

Solution (Python):
N=int(input())
S=[input() for i in range(N)]
L=dict()
for i in range(N):
  if S[i] in L:
    L[S[i]]+=1
  else:
    L[S[i]]=1
M=max(L.values())
ans=list()
for X in L:
  if L[X]==M:
    ans.append(X)
ans.sort()
for X in ans:
  print(X)

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

S = dict(Counter(S))
m = max(S.values())

ans = []
for s, v in S.items():
    if v == m:
        ans.append(s)
ans.sort()

for a in ans:
    print(a)

Solution (Python):

import collections

N = int(input())

all_str = []
for i in range(N):
    str_temp = input()
    all_str.append(str_temp)
all_str.sort()
coll_str = (collections.Counter(all_str))
count_max = 0
j = 0
max_str = coll_str.most_common()
for i in max_str:
    
    num_of_str =  i[1]
    if num_of_str == count_max or j == 0:
        print(i[0])
        j = 1
        count_max = num_of_str
        
    if num_of_str < count_max:
        break

Solution (Python):
import collections

N = int(input())

S_list = []

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

c = collections.Counter(S_list)
c_max = c.most_common()
max_num = c.most_common()[0][1]
ans_list = []
ans_list.append(c.most_common()[0][0])

for i in range(1, len(c_max)):
    if c_max[i][1] != max_num:
        break
    else:
        ans_list.append(c_max[i][0])

print(*sorted(ans_list), sep='\n')

Solution (Python):
n = int(input())
a = [input() for _ in range(n)]
cnt = {}
for i in range(n):
    if a[i] not in cnt:
        cnt[a[i]] = 1
    else:
        cnt[a[i]] += 1
mx = max(cnt.values())
ans = []
for i in cnt.keys():
    if cnt[i] == mx:
        ans.append(i)
ans.sort()
for _ in ans:
    print(_)

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

maxcount = max([d[k] for k in d])
maxlist = list(filter(lambda x: d[x] == maxcount, d))
maxlist = sorted(maxlist)
for m in maxlist:
    print(m)

Solution (Python):
def main():
    n = int(input())
    s_dict = dict()

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

    max_appear = max(s_dict.values())
    lst = []

    for key, value in s_dict.items():
        if value == max_appear:
            lst.append(key)

    lst.sort()

    for s in lst:
        print(s)


if __name__ == "__main__":
    main()

Solution (Python):
from collections import *
n=int(input())
l=[]
for i in range(n):
    l.append(input())
c=Counter(l)
m=max(c.values())
d=[]
for i in c:
    if(c[i]==m):
        d.append(i)
d.sort()
for i in d:
    print(i)

Solution (Python):
n=int(input())
s=[input() for _ in range(n)]
from collections import Counter
c=Counter(s)
d=[]
x=c.most_common()[0][1]
for k in c.keys():
    if c[k]==x:
        d.append(k)

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

Solution (Python):
from collections import defaultdict
dic=defaultdict(int)
n=int(input())
for _ in range(n): dic[input()]+=1
lis=sorted(dic.items(),key=lambda x:x[1],reverse=True)
M=lis[0][1]
ans=[]
for i in range(len(lis)):
    if lis[i][1]==M: ans.append(lis[i][0])
    else: break
ans.sort()
for i in ans: print(i)

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

d = {}

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

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

name = []
cnt = dsorted[0][1]

for i in dsorted:
  if i[1] == cnt:
    name.append(i[0])
  else:
    break

name.sort()

for i in name:
  print(i)

Solution (Python):
def main():
    from sys import stdin
    from collections import Counter
    readline = stdin.readline

    n = int(readline())
    S = [readline()[:-1] for _ in [0]*n]

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

    answers = [i[0] for i in s.items() if i[1] == most]
    answers = sorted(answers)

    for ans in answers:
        print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
n= int(input())
l={}
a=0

for i in range(n):
  s=input()
  if s in l:
    l[s]+=1
  else:
    l[s]=1
  if a<l[s]:
    a=l[s]
  
ans=[]
for i in l.keys():
  if l[i]==a:
    ans.append(i)

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

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

import sys
from collections import Counter

count_dict = Counter(S)
most_freq = count_dict.most_common(1)[0][1]

words = []

for word, freq in sorted(count_dict.items(), key=lambda x: -x[1]):
    if freq == most_freq:
        words.append(word)

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

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

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):
N = int(input())
d = {}
for i in range(N):
  s = input()
  if s in d.keys():
    d[s] += 1
  else:
    d[s] = 1
mx = 0
for i in d.values():
  mx = max(mx, i)
for i in sorted(d.items()):
  if i[1] == mx:
    print(i[0])

Solution (Python):


import sys
from collections import Counter
import numpy as np
n=int(input())
S=[]
for i in range(n):
    S.append(input())
s=Counter(S)
keys, values = zip(*s.most_common())

values=np.array(values)
index=np.where(values==np.max(values))
answer=[]
for i in index[0]:
    answer.append(keys[i])
answer.sort()
for i in answer:
    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):

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

ds = sorted(d.items(), key=lambda t:(-t[1],t[0]))

m = ds[0][1]

ans = []
for k, v in ds:
  if v != m:
    break
  print(k)

Solution (Python):
N=int(input())
votes = dict()
for _ in range(N):
    S = input()
    if votes.get(S):
        votes[S] += 1
    else:
        votes[S] = 1
max = 0
for k in votes:
    if votes[k] > max:
        max = votes[k]
keys = []
for k in votes:
    if votes[k] == max:
        keys.append(k)
keys.sort()
for k in keys:
    print(k)

Solution (Python):
N = int(input())
d = dict()
for i in range(N):
  let = input()
  if let in d:
    d[let] += 1
  else:
    d[let] = 0
max = 0
res = []
for i in d:
  if d[i]  > max:
    max = d[i]
    res =[i]
  elif d[i] == max:
    res.append(i)
for i in sorted(res):
  print(i)

Solution (Python):

from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def SL(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def R(n): return [sys.stdin.readline().strip() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [SL() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]

def perm(n, r): return math.factorial(n) // math.factorial(r)
def comb(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))

def make_list(n, *args, default=0): return [make_list(*args, default=default) for _ in range(n)] if len(args) > 0 else [default for _ in range(n)]

sys.setrecursionlimit(1000000)
dire, dire8 = [[1, 0], [0, 1], [-1, 0], [0, -1]], [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
alphabets, ALPHABETS = "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
MOD, INF = 1000000007, float("inf")

def main():
    N = I()
    S = R(N)
    c = Counter(S)
    [common] = c.most_common(1)
    for k, v in sorted(c.items(), key=lambda x: (-x[1], x[0])):
        if common[1] != v:
            break
        print(k)


if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
d={}
m=1
for i in range(n):
    s=input()
    if s in d:
        d[s]+=1
        m=max(m,d[s])
    else:
        d[s]=1
se=set()
for i in d:
    if d[i]==m:
        se.add(i)
se=list(se)
se.sort()
print(*se)

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

counter = collections.Counter(P)
mode_v = counter.most_common()[0][-1]
it = list(itertools.takewhile(lambda kv: kv[-1] == mode_v, counter.most_common()))
for i in range(len(it)):
    ans.append(it[i][0])
s_ans = sorted(ans)
for i in range(len(s_ans)):
    print(s_ans[i])

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

max = max(num.values())
keys = []
for k, v in num.items():
    if v == max:
        keys.append(k)
keys.sort()

for key in keys:
    print(key)

Solution (Python):
import collections

N = int(input())
L = [input() for i in range(N)]
c = collections.Counter(L)

max_L = max(list(c.values()))

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

for key in keys:
    print(key)

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

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

abc155c_poll()

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

maxS=max(S.values())
S=[k for k,v in S.items() if v==maxS]
print('\n'.join(sorted(S)))

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

maxS=max(S.values())
S={k:v for k, v in S.items() if v==maxS}
S=sorted(S.items(), key=lambda x:(-x[1],x[0]))
for k,cnt in S:
  print(k)

Solution (Python):
N=int(input())
S={}
for n in range(N):
  s=input()
  S[s]=S.get(s,0)+1
  
S=sorted(S.items(), key=lambda x:(-x[1],x[0]))
maxS=S[0][1]
for s, cnt in S:
  if cnt!=maxS:
    break
  print(s)

Solution (Python):
N = int(input())
D = {}
for i in range(N):
	S = input()
	M = D.get(S)
	if M == None:
		D.update([(S, 1)])
	else:
		D.update([(S, M+1)])
E = list(D.keys())
F = list(D.values())
MA = max(F)
I = [i for i,x in enumerate(F) if x == MA]
ans =[]
for i in I:
	ans.append(E[i])
ans = sorted(ans)
print('\n'.join(ans))

Solution (Python):
n = int(input())
dic1 = {}
for i in range(n):
    s = input()
    if s not in dic1.keys():
        dic1[s] = 1
    else:
        dic1[s] += 1
dic2 = sorted(dic1.items(), key=lambda j: j[1], reverse=True)

ans_ls = []
for k in range(len(dic2)):
    if dic2[k][1] != dic2[0][1]:
        break
    ans_ls.append(dic2[k][0])
ans_ls.sort()
for _ in ans_ls:
  	print(_)

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

ans = []

for i in c:
    if m == c[i]:
        ans.append(i)

ans = sorted(ans)

for i in ans:
    print(i)

Solution (Python):
import sys

input = sys.stdin.readline
N = int(input())
d = {}
for _ in range(N):
    s = input().replace('\n', '')
    d[s] = d.get(s, 0) + 1
max_count = 0
for count in d.values():
    max_count = max(max_count, count)

ans = sorted([k for k, v in d.items() if v == max_count])
print('\n'.join(ans))

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

ls={}
max_ch=0
for i in range(N):
    ch=input()
    if not ch in ls:
        ls[ch]=1
    else:
        ls[ch]+=1
    if max_ch<ls[ch]:
        max_ch=ls[ch]

S=[]
for j in ls:
    if max_ch==ls[j]:
        S.append(j)

S=sorted(S)

for i in S:
    print(i)

Solution (Python):
count = {}
for i in range(int(input())):
    S = input()
    if S in count:
        count[S] += 1
    else:
        count[S] = 1
ans = max(count.values())
print(*sorted([A[0] for A in count.items() if A[1] == ans]))

Solution (Python):
import collections
n=int(input())
s=[]
for i in range(n):
  c=input()
  s.append(c)
a=collections.Counter(s)
d=sorted(a.items(), key=lambda x:x[1])
e=max(a.values())
l=[]
for i in a:
  if a[i]==e:
    l.append(i)
l.sort()
for i in l:
  print(i)

Solution (Python):
N=int(input())
kouholist=[]
worddict=dict()
maxvalue=0
for i in range(N):
    S=input()
    if S in worddict.keys():
        worddict[S]+=1
    else:
        worddict[S]=1
    maxvalue=max(maxvalue,worddict[S])


for k in worddict.keys():
    if worddict[k]==maxvalue:
        kouholist.append(k)
kouholist=sorted(kouholist)
for h in range(len(kouholist)):
    print(kouholist[h])

Solution (Python):
from collections import defaultdict
Poll_Dict = defaultdict(int)

N = int(input())

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

Max_Number = max(Poll_Dict.values())    
Max_List = sorted([k[0] for k in Poll_Dict.items() if k[1] == Max_Number])

for i in Max_List:
    print(i)

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

maxcount = max(x.values())
ans = []
for s, count in x.items():
    if count == maxcount:
        ans.append(s)
ans.sort()
for a in ans:
    print(a)

Solution (Python):


num_of_votes = int(input())

poll = {}

for i in range(num_of_votes):
    entry = input()
    
    if (poll.get(entry) == None):
        poll[entry] = 0
    
    poll[entry] += 1

max_votes = 0
most_voted_entries = []

for key in poll:
    num_of_votes = poll[key]

    if num_of_votes > max_votes:
        most_voted_entries = [ key ]
        max_votes = num_of_votes
    elif num_of_votes == max_votes:
        most_voted_entries.append(key)

for entry in sorted(most_voted_entries):
    print(entry)

Solution (Python):
n = int(input())
s = [input() for _ in range(n)]
ss = sorted(s)
t = ss
x = 0
maxx = 0
for i in range(n-1):
    if ss[i] == ss[i+1]:
        x += 1
        if x == maxx:
            maxx = x
            t.append(ss[i])
        elif x > maxx:
            maxx = x
            t = [ss[i]]
    else:
        x = 0
for j in t:
    print(j)