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())
A = {}

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

B = sorted(A.items())
for k, v in B:
    if v == MAX:
        print(k)

Solution (Python):
from collections import *
n=int(input())
l=[]
for i in range(n):
    s=input()
    l.append(s)
c=Counter(l)
cs=c.most_common()
m=c.most_common()[0][1]
tmp=0
ans=[]
for i in range(len(cs)):
    if cs[i][1]!=m:
        break
    else:
        ans.append(cs[i][0])
ans.sort()
for i in ans:
    print(i)

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
max_val = max(d.values())
key_list = [kv[0] for kv in d.items() if kv[1] == max_val]
for k in sorted(key_list):
    print(k)

Solution (Python):
n = int(input())
dic = {}
for i in range(n):
    s = input()
    try:
        dic[s] += 1
    except:
        dic[s] = 1
high=max(dic.values())
val= sorted(dic.items())
for i in val:
    if(i[1]==high):
        print(i[0])

Solution (Python):
n = int(input())
dic = {}
for i in range(n):
    s = input()
    try:
        dic[s] += 1
    except:
        dic[s] = 1

mx = max(dic.values())
sorted = sorted(dic.items())

ans = []
for i in sorted:
    if i[1] == mx:
        print(i[0])

Solution (Python):
c={}
for _ in range(int(input())): s=input(); c[s]=c.get(s,0)+1
m = max(c.values())
print(*sorted(k for k in c if c[k]==m))

Solution (Python):
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
s.sort()
d = Counter(s)
a = max(d.values())
for k in d.keys():
  if d[k]==a:
    print(k)

Solution (Python):
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
s.sort()
d = Counter(s)
a = 0
for v in d.values():
  if v>a:
    a = v
for k in d.keys():
  if d[k]==a:
    print(k)

Solution (Python):
N = int(input())
d = {}
M = 1

for i in range(N) :
    S = input()
    if S in d.keys() :
        d[S] += 1
        if d[S] > M :
            M = d[S]
    else :
        d.setdefault(S,1)

d = sorted(d.items())
for w,t in d :
    if t == M :
        print(w)

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

c = Counter(S)
c_keys=np.array(list(c.keys()))
c_values=list(c.values())
max_value=max(c_values)
index_list=[index for index, value in enumerate(c_values) if value == max_value]
ans_list=list(c_keys[index_list])
ans_list.sort()
for text in ans_list:
    print(text)

Solution (Python):
from collections import Counter

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

max = s[0][1]
max_s = []

for i in range(len(s)):
    if int(s[i][1]) == int(max):
        max_s.append(s[i][0])
max_s.sort()

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

Solution (Python):
def main():
    d = {}
    N = int(input())
    for i in range(N):
        s = input()
        d.setdefault(s, 1)
        d[s] += 1
    
    d = sorted(d.items())
    d = sorted(d, key=lambda x:x[1], reverse=True)
    n = d[0][1]
    for i in range(len(d)):
        if d[i][1] != n:
            break
        print(d[i][0])

if __name__ == '__main__':
    main()

Solution (Python):
import collections

N = int(input())
S = sorted([input() for i in range(N)])
slist = collections.Counter(S)

items = list(slist.keys())
numbers = list(slist.values())

maximum = max(numbers)

for i in range(len(numbers)):
    if numbers[i] == maximum:
        print(items[i])

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

cnt = 0
for _ in range(n):
    si = input()
    if si not in s.keys():
        s[si] = 1
    else:
        s[si] += 1

    cnt = max(cnt, s[si])

for k in sorted(s):
    if s[k] == cnt:
        print(k)

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


dic1 = {}
for i in range(n):
  temp = input()
  dic1.setdefault(temp, 0)
  dic1[temp] += 1
fmax = max(dic1.values())
mflst = []
ks = list(dic1.keys())
for i in dic1:
  if dic1[i] == fmax:
    mflst.append(i)
    
mflst.sort()
for i in range(len(mflst)):
  print(mflst[i])

Solution (Python):
n=int(input())
s=[]
for _ in range(n):
  s.append(input())
import collections 
d=collections.Counter(s)
larger=max(list(d.values()))
ans=[]
for key in d.keys():
  if d[key]==larger:
    ans.append(key)
ans.sort()
for _ in range(len(ans)):
  print(ans[_])

Solution (Python):
n=int(input())
s=[]
for _ in range(n):
  s.append(input())
import collections
d=collections.Counter(s)
largest=max(list(d.values()))
ans=[]
for key in d.keys():
  if d[key]==largest:
    ans.append(key)
ans.sort(reverse=True)
while len(ans)>0:
  print(ans.pop(-1))

Solution (Python):
n=int(input())
s=[]
for _ in range(n):
  s.append(input())
import collections
d=collections.Counter(s)
largest=max(list(d.values()))
ans=[]
for key in d.keys():
  if d[key]==largest:
    ans.append(key)
ans.sort()
for _ in range(len(ans)):
  print(ans[_])

Solution (Python):
import collections
n = int(input())
s = [input() for i in range(n)]
d = collections.Counter(s)
largest = max(d.values())
ans = []
for key in d.keys():
    if d[key] == largest:
        ans.append(key)
common_values = sorted(ans)
for val in common_values:
    print(val)

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

count = {}
for s_i in s:
    try:
        count[ s_i ] += 1
    except KeyError:
        count[ s_i ] = 1

max_count = 0
for t in count.keys():
    if count[ t ] > max_count:
        max_count = count[ t ]

max_t = []
for t in count.keys():
    if count[ t ] == max_count:
        max_t.append( t )

max_t.sort()

for t in max_t:
    print( t )

Solution (Python):
from collections import Counter
N = int(input())
l = []
for i in range(N):
  l.append(input())
  
c = Counter(l).most_common()
ma = c[0][1]
ans = []
for i in c:
  if i[1] == ma:
    ans.append(i[0])
  else:
    break;
    
ans.sort()
for i in ans:
  print(i)

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

dic = {}
for i in S:
  dic[i] = 0
for i in S:
  dic[i] += 1
M = max(dic.values())
for i in dic:
  if dic[i] == M:
    print(i)

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

S.sort()

l=[]
c=[]
prev=S[0]
cnt=0
for n in range(len(S)):
    if S[n]==prev:
        cnt+=1
    else:
        c.append(cnt)
        cnt=1
        l.append(prev)
        prev=S[n]
if cnt!=0:
    c.append(cnt)
    l.append(prev)

max_cnt=max(c)

max_str=[]
for n in range(len(c)):
    if c[n]==max_cnt:
       max_str.append(l[n])
max_str.sort()

for e in max_str:
    print(e)

Solution (Python):
N=int(input())
t=dict()
ans=list()
for i in range(N):
    tmp=input()
    if tmp in t:
        t[tmp]+=1
    else:
        t[tmp]=1
max_v=max(t.values())
ans=[kv[0] for kv in t.items() if kv[1] == max_v]
ans.sort()
for i in ans:
    print(i)

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

dic = {}

for _ in range(N):
    a = input()
    if a in dic:
        dic[a] += 1
    else:
        dic[a] = 1

m = max(dic.values())
l = [k for k in dic if dic[k] == m]
l.sort()
for s in l:
    print(s)

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

dic = {}

for _ in range(N):
    a = input()
    if a in dic:
        dic[a] += 1
    else:
        dic[a] = 1

m = max(dic.values())

for s in sorted(k for k in dic if dic[k] == m):
    print(s)

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):
import sys
read = sys.stdin.read
from collections import Counter
def main():
    n, *s = read().split()
    n = int(n)
    sc = Counter(s)
    scm = sc.most_common()
    maxnum = scm[0][1]
    r = []
    for scme in scm:
        if scme[1] == maxnum:
            r.append(scme[0])
        else:
            break
    r.sort()
    print(*r, sep="\n")

if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
c={}
for _ in range(n): s=input(); c[s]=c.get(s,0)+1
m=max(c.values())
print(*sorted(k for k in c if c[k]==m))

Solution (Python):
n=int(input())
from collections import *
c=Counter()
for _ in range(n): c[input()]+=1
m=max(c.values())
print(*sorted(k for k,v in c.items() if v==m))

Solution (Python):
n=int(input())
c={}
for _ in range(n): s=input(); c[s]=c.get(s,0)+1
m=max(c.values())
print(*sorted(k for k,v in c.items() if v==m))

Solution (Python):






import collections





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





mylist = collections.Counter(sorted(S)).most_common()
cnt_tmp = mylist[0][1]
for word, cnt in mylist:
    if cnt != cnt_tmp:
        break
    print(word)
    cnt_tmp = cnt

Solution (Python):
n = int(input())
d = {}
for _ in range(n):
    s = str(input())
    d[s] = 1 if s not in d else d[s] + 1
M = max(d.values())
L = [k for k, v in d.items() if v == M]
L.sort()
for x in L:
    print(x)

Solution (Python):
n = int(input())
d = {}
for _ in range(n):
    s = str(input())
    d[s] = 1 if s not in d else d[s] + 1
M = max(d.values())
L = []
for k, v in d.items():
    if v == M:
        L.append(k)
L.sort()
for x in L:
    print(x)

Solution (Python):
import collections
N = int(input())
S = {}
for i in range(N):
    value = input()
    if value not in S:
        S[value] = 1
    else:
        S[value] += 1
S_largest = max(S.values())
S_sorted = sorted(S.items(), key=lambda x:x[1], reverse=True)
ans = []
for i in range(len(S_sorted)):
    if S_sorted[i][1] == S_largest:
        ans.append(S_sorted[i][0])
    else:
        break
ans_sorted = sorted(ans)
for a in ans_sorted:
    print(a)

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

Solution (Python):
n=int(input())
ar = []
for i in range(n):
    a = input()
    ar.append(a)
dic = {}

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

highest = max(dic.values())
ans = []

for keys in dic.keys():
    if dic[keys] == highest:
        ans.append(keys)

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

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

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

x=co.Counter(s)
x=x.most_common()
ans=[]
m=0

for i in x:
    if i[1]<m:
        break
    else:
        ans.append(i[0])
        m=i[1]

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)
d = c.most_common()

t = []
t.append(d[0])
cnt = 1

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

    t= sorted(t)

    for i in range(cnt):
        print(t[i][0])

else:
    print(d[0][0])

Solution (Python):

import collections as col

n = int(input())

s = []

for i in range(n):
    s.append(input())
    
x = col.Counter(s)

m = 0

x = x.most_common()

ans = []

for i in x:
    if i[1]<m:
        break
    else:
        ans.append(i[0])
        m = i[1]
        
ans.sort()

for i in ans:
    print(i)

Solution (Python):
n = int(input())
cnt_dict = {}
for _ in range(n):
    s = input()
    cnt_dict.setdefault(s,0)
    cnt_dict[s] += 1

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

ans_s = []
max_cnt = cnt_t[0][1]
for t in cnt_t:
    if t[1] != max_cnt:
        break
    ans_s.append(t[0])

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

Solution (Python):
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    N = I()
    S = [_S() for _ in range(N)]
    S_count = collections.Counter(S).most_common()
    S_most = list(filter(lambda t:t[1]>=S_count[0][1],S_count))
    for s in sorted(S_most,key=lambda tup:tup[0]):
        print(s[0])

main()

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
max_val = max(d.values())
key_list = [kv[0] for kv in d.items() if kv[1] == max_val]
for k in sorted(key_list):
    print(k)

Solution (Python):
def resolve():
    N = int(input())
    S = [str(input()) for _ in range(N)]
    words = dict(zip(set(S), [0] * len(S)))
    for s in S:
        if s in words:
            words[s] += 1

    words = sorted(words.items(), key=lambda x: x[1], reverse=True)
    mx = words[0][1]
    words = sorted(words, key=lambda x: x[0])
    for word in words:
        if word[1] == mx:
            print(word[0])

    return


resolve()

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

d=defaultdict(int)
for i in range(n):
    s=input()
    d[s]+=1

mx=0
for i,j in d.items():
    if j>mx:
        mx=j

ans=[]
for i, j in d.items():
    if j==mx:
        ans.append(i)

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

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

count = {}
for w in [input() for _ in range(N)]:
    if w in count:
        count[w] += 1
    else:
        count[w] = 1
max_values = max(count.values())
keys = [k for k, v in count.items() if v == max_values]
for w in sorted(keys):
    print(w)

Solution (Python):
N = int(input())
input_line = [input() for _ in range(N)]
count = {}
for w in input_line:
    if w in count:
        count[w] += 1
    else:
        count[w] = 1
max_values = max(count.values())
keys = [k for k, v in count.items() if v == max_values]
for w in sorted(keys):
    print(w)

Solution (Python):
n = int(input())
s = [input() for i in range(n)]
ans = []
d = {}
for i in s:
    d.setdefault(i, 0)
    d[i] += 1

maxv = 0
for i in d.values():
    maxv = max(maxv,i)
for i in d.keys():
    if d[i] == maxv:
        ans.append(i)

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

Solution (Python):
import collections
N=int(input())
S = [str(input()) for _ in range(N)]
c = collections.Counter(S)
most = []
most_num=c.most_common()[0][1]
for i in c.most_common():
    if i[1]==most_num:
        most.append(i[0])
most.sort()
for i in most:
    print(i)

Solution (Python):

def main():
    N = int(input())
    S = [input() for i in range(N)]
    S.sort()
    ans = []
    max_len = 0
    streak = 1
    for i in range(N-1):
        if(S[i]==S[i+1]):
            streak+=1
            if(i==N-2):
                if(streak>max_len):
                    max_len = streak
                    ans = [S[i]]
                elif(streak==max_len):
                    ans.append(S[i])
        else:
            if(streak>max_len):
                max_len = streak
                ans = [S[i]]
            elif(streak==max_len):
                ans.append(S[i])
            streak=1
    if(N==1 or S[-2]!=S[-1]):
        ans.append(S[-1])
    for a in ans:
        print(a)
main()

Solution (Python):
import collections
N = int(input())
List = [str(input()) for i in range(N)]
c = collections.Counter(List)




most=[]
most_num=c.most_common()[0][1]
for i in c.most_common():
    if i[1]==most_num:
        most.append(i[0])
most.sort()
for i in most:
    print(i)

Solution (Python):
N=int(input())
S_dict={}
 
for s_idx in range(N):
    s = input()
    
    if s not in S_dict:
        S_dict.update({s:1})
    else:
        S_dict.update({s:S_dict[s]+1})
        
s_max=max(S_dict.values())
 
ans = []    
 
for a,b in S_dict.items():
    if b == s_max:
        ans.append(a)
    
ans.sort()
 
for i in ans:
    print(i)

Solution (Python):
N = int(input())
 
counter = {}
 
for i in range(N):
    temp = input()
    if temp not in counter:
        counter.update({temp : 1})
    else:
        counter.update({temp : counter[temp] + 1})
 
m = max(counter.values())
        
ans = []    
 
for a,b in counter.items():
    if b == m:
        ans.append(a)
    
ans.sort()
 
for i in ans:
    print(i)

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

count = Counter(s)
t = max(count.values())
ans = []
for i in count.items():
  if i[1] == t:
    ans.append(i[0])
print(*sorted(ans), sep='\n')

Solution (Python):
n=int(input())
dic={}
for i in range(n):
  s=input()
  if s in dic:
    dic[s]+=1
  else:dic[s]=1
sc=[[] for _ in range(n+1)]
mx=0
for i in dic:
  sc[dic[i]].append(i)
  mx=max(mx,dic[i])

for i in sorted(sc[mx]):
  print(i)

Solution (Python):
n=int(input())
S=[]
for i in range(n):
    S.append(input())
S=sorted(S)
from collections import defaultdict
d = defaultdict(int)

for k in S:
    d[k]+=1

d=dict(d)
dmax=max(d.values())
ans=[]
for i in d.keys():
    if d[i]==dmax:
        ans.append(i)

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

Solution (Python):
import collections
N = int(input())
S = ['']*N
for T in range(0,N):
    S[T] = input()
Count = collections.Counter(S).most_common()
MaxC = Count[0][1]
Disp = []
for T in range(0,len(Count)):
    if Count[T][1] < MaxC:
        break
    Disp.append(Count[T][0])
print('\n'.join(sorted(Disp)))

Solution (Python):


N = int(input())

counter = {}

for i in range(N):
    temp = input()
    if temp not in counter:
        counter.update({temp : 1})
    else:
        counter.update({temp : counter[temp] + 1})

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

for a,b in counter.items():
    if b == m:
        ans.append(a)
    
ans.sort()

for i in ans:
    print(i)

Solution (Python):
from collections import Counter
n = int(input())
S = [input() for i in range(n)]
L = Counter(S).most_common()
ans = []
for i in range(len(L)):
  if L[i][1] == L[0][1]:
    ans.append(L[i][0])
  else:
    break
ans.sort()
for i in range(len(ans)):
  print(ans[i])

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

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



ret_dict = []
for k, v in word_dict.items():
    if v == max_count:
        ret_dict.append(k)
ret_dict.sort()

for ret in ret_dict:
    print("{}".format(ret))

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 sys
sys.setrecursionlimit(10**7) 
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right

from collections import deque


from collections import Counter

from itertools import accumulate

from heapq import heapify,heappop,heappush


from functools import lru_cache

def input(): return sys.stdin.readline()[:-1]
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    

    N = int(input())
    
    
    L = tuple(input() for i in range(N)) 
    

    l=Counter(L)
    m=max(l.values())
    ans=[]
    for s in l.keys():
        n=l[s]
        if n==m:
            ans.append(s)
    ans.sort()
    printl(ans)



if __name__ == "__main__":
    main()

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

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

Solution (Python):
from collections import Counter
n = int(input())
s = Counter([str(input()) for _ in range(n)])
max_list = []
max_count = 0
for k, v in s.items():
    if max_count < v:
        max_count = v
        max_list = []
    if max_count == v:
        max_list.append(k)
max_list.sort()
for x in max_list:
    print(x)

Solution (Python):

def main():
    N = int(input())
    d = {}
    m = 0
    for n in range(N):
        s = input()
        d[s] = d.setdefault(s, 0) + 1
        if d[s] > m:
            m = d[s]
    keys = [k for k, v in d.items() if v == m]
    print('\n'.join(sorted(keys)))

if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter

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

counter = Counter(s)
max_cnt = max(counter.values())

names = [name for name,val in counter.items() if val==max_cnt]
names.sort()

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

Solution (Python):
n = int(input())
dic = {}
val_set = set()
ans = []

for i in range(n):
  temp = input()
  try:
    dic[temp] += 1
  except:
    dic[temp] = 1

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

for key,val in dic:
  val_set.add(val)
  if len(val_set) == 2:
    break
  else:
    ans.append(key)
  
ans = sorted(ans)

for x in ans:
  print(x)

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

max=max(s.values())
ans=[]
for i,j in s.items():
    if j == max:
        ans.append(i)
ans=sorted(ans)
print('\n'.join(ans))

Solution (Python):
import collections

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

str = collections.Counter(s)
cntmax = str.most_common()[0][1]

slist = list(str.items())

ans = []
for i in range(len(set(s))):
    if slist[i][1] == cntmax:
       ans.append(slist[i][0])
ans.sort()

for i in range(len(ans)):
    print(ans[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
dic2=sorted(dic.items(), key=lambda x:x[1],reverse=True)
ma=dic2[0][1]

keys=sorted([k for k,v in dic.items() if v==ma])
for i in keys:
    print(i)

Solution (Python):
from collections import Counter


def main():
    n = int(input())
    s = []
    for i in range(n):
        s.append(input())
    cnt = Counter(s).most_common()
    num = cnt[0][1]
    for v in  sorted([v for v, c in cnt if c == num]):
        print(v)


if __name__ == '__main__':
    main()

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

data = dict()

for i in range(n):
    s = input()
    if s in data:
        data[s] += 1
    else:
        data.setdefault(s,1)
ans = sorted(data.items(),key=lambda x:x[1],reverse=True)
max_num = ans[0][1]
A = []
for item,i in ans:
    if i == max_num:
        A.append(item)
A.sort()

for item in A:
    print(item)

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

N = int(input())
data = dict()
for _ in range(N):
    s = input()[:-1]
    if s in data:
        data[s] += 1
    else:
        data.setdefault(s, 1)

ans = sorted(data.items(), key=lambda x:x[1], reverse=True)
M = ans[0][1]
A = []
for item, i in ans:
    if M == i:
        A.append(item)
    else:
        break
A.sort()
for item in A:
    print(item)

Solution (Python):
class Counter(dict):
  def __missing__(self, i):
    return 0

n = int(input())

s = Counter()

for _ in range(n):
  i = input()
  s[i] += 1

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

ans = []
for key, value in s:
  if value == m:
    ans.append(key)
  else:
    break

ans.sort()

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

Solution (Python):
class Counter(dict):
  def __missing__(self, i):
    return 0

n = int(input())

s = Counter()

for _ in range(n):
  i = input()
  s[i] += 1

s = dict(sorted(s.items(), key=lambda x: -x[1]))
m = max(list(s.values()))

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

ans.sort()

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

Solution (Python):
from collections import Counter
N = int(input())
words = [0]*N
for i in range(N):
    words[i] = input()
counter = Counter(words)
cnt = max(counter.values())
ans = []
for key,value in counter.items():
    if value == cnt:
        ans.append(key)
ans.sort()
print(*ans,sep="\n")

Solution (Python):
from collections import Counter

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

for _ in range(N):
    s=input()
    S.append(s)

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

maxnum=arr[0][1]
ans=[]

for i in range(len(arr)):
    if arr[i][1]==maxnum:
        ans.append(arr[i][0])        
    else:
        break
FA=sorted(ans)
for j in FA:
    print(j)

Solution (Python):
from collections import Counter

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

max_count = max(cnt.values())
ans = [k for k, count in cnt.items() if count == max_count]
ans.sort()
print("\n".join(ans))

Solution (Python):
from collections import Counter

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

max_count = max(cnt.values())
ans = [k for k, count in cnt.items() if count == max_count]

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

Solution (Python):
from collections import Counter

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

max_count = max(cnt.values())
ans = [k for k, count in cnt.items() if count == max_count]

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

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

max_count = max(d.values())
ans = [s for s, count in d.items() if count == max_count]

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

Solution (Python):
from collections import defaultdict
d = defaultdict(int)
n = int(input())
for i in range(n):
  s = input()
  d[s] += 1
d = dict(d)
d = sorted(d.items(), key=lambda x:x[1], reverse=True)
max_s = d[0][1]
l = [d[i][0] for i in range(len(d)) if d[i][1] == max_s]
l.sort()
for s in l:
  print(s)

Solution (Python):
import collections

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

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

s = collections.Counter(S)

max_num = max(s.values())

ans = []

for k, v in s.items():
    if v == max_num:
        ans.append(k)

ans.sort()

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

Solution (Python):
import collections
N = int(input())
S = [input() for i in range(N)]
cnt = collections.Counter(S)
oldVal = cnt.most_common()[0][1]

ans = []
for i in cnt.most_common():
    if oldVal == i[1]:
        ans.append(i[0])
        oldVal = i[1]
    else:
        break
ans.sort()
print('\n'.join(ans))

Solution (Python):
n=int(input())
dic={}
mxd=[]
mxc=0
for i in range(n):
  s = input()
  if s in dic:
    dic[s] += 1
  else:
    dic[s] = 1
  if dic[s] > mxc:
    mxc=dic[s]
    mxd=[]
  if dic[s] == mxc:
    mxd.append(s)
mxd.sort()
for d in mxd:
  print(d)

Solution (Python):
n=int(input())
dic={}
mxd=[]
mxc=0
for i in range(n):
  s = input()
  if s in dic:
    dic[s] += 1
  else:
    dic[s] = 1
  if dic[s] > mxc:
    mxc=dic[s]
    mxd=[]
  if dic[s] == mxc:
    mxd.append(s)
mxd.sort()
for d in mxd:
  print(d)

Solution (Python):
n=int(input())
you=[]
al=[]
vot=[]
ans=[]
for i in range(n):
  s=input()
  al.append(s)
al.sort()
bef="zzzzzzzzzzz"
co=0
mx=1
for x in al:
  if bef!=x:
    if mx<co:
      mx=co
      ans=[bef]
    elif mx==co:
      ans.append(bef)
    co=1
    bef=x
  else:
    co+=1
if mx<co:
  mx=co
  ans=[bef]
elif mx==co:
  ans.append(bef)
for x in ans:
  print(x)

Solution (Python):
N = int(input())
dic = {}
max_v = 0

for i in range(N):
    temp = input()
    if temp in dic:
        dic[temp] += 1
    else:
        dic[temp] = 1
    max_v = max(max_v, dic[temp])

keys = sorted(dic.keys())
for k in keys:
    if dic[k] == max_v:
        print(k)

Solution (Python):
N = int(input())
dic = {}
max_v = 0

for i in range(N):
    temp = input()
    if temp in dic:
        dic[temp] += 1
    else:
        dic[temp] = 1
    max_v = max(max_v, dic[temp])

keys = sorted(dic.keys())
for k in keys:
    if dic[k] == max_v:
        print(k)

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

Solution (Python):
n = int(input())
s = {}
for i in range(n):
  t = input()
  if t in s:
    s[t] += 1
  else:
    s[t] = 1
s = sorted(s.items(), key=lambda x:x[1], reverse=True)
vmax = s[0][1]
ans = []
for si in s:
  if si[1] == vmax:
    ans.append(si[0])
  else:
    break
ans.sort()
for a in ans:
  print(a)

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

maxi = 0
for _ in range(N):
    s=input()
    if s in dic.keys():
        dic[s] += 1
    else:
        dic[s] = 1
    maxi = max(maxi, dic[s])

keys = sorted(dic.keys())
for k in keys:
    if dic[k] == maxi:
        print(k)

Solution (Python):
from collections import defaultdict

def main():
    N = int(input())
    S = defaultdict(int)
    for i in range(N):
        s = input()
        S[s] += 1
    max_cnt = max(S.values())
    ans = []
    for k,v in sorted(S.items(), key=lambda x:x[1], reverse=True):
        if v == max_cnt:
            ans.append(k)
        else:
            break
    for a in sorted(ans):
        print(a)

if __name__ == '__main__':
    main()

Solution (Python):
from collections import defaultdict
def main():
    N = int(input())
    dd=defaultdict(int)
    for _ in range(N):
        dd[input()]+=1
    dd = sorted(dd.items())
    dd = sorted(dd, reverse=True, key=lambda x: x[1])
    cnt = 0
    while len(dd) > cnt and dd[0][1] == dd[cnt][1] :
        print(dd[cnt][0])
        cnt +=1




if __name__ == '__main__':
    main()