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):
from collections import defaultdict
d=defaultdict(int)
for i in range(int(input())):
    d[input()]+=1
ans=[]
d=list(d.items())
d.sort(key=lambda x:-x[1])

m=d[0][1]
for i,j in d:
    if m==j:
        ans+=[i]
    else:
        break

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

Solution (Python):
from collections import defaultdict
d=defaultdict(int)
for i in range(int(input())):
    d[input()]+=1
ans=[]
d=list(d.items())
d.sort(key=lambda x:-x[1])

m=d[0][1]
for i,j in d:
    if m==j:
        ans+=[i]

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

Solution (Python):
import collections

N = int(input())

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

c = collections.Counter(S)
max = max(c.values())
answerlist = [key for key, v in c.items() if v == max]
answerlist.sort()
for answer in answerlist:
    print(answer)

Solution (Python):
from collections import Counter

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

Sc = Counter(S).most_common()
m = Sc[0][1]
ans = []
for s in Sc:
    if s[1] == m:
        ans.append(s[0])
    else:
        break
ans.sort()
for a in ans:
    print(a)

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

dic = {}

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

d = max(dic.values())
max_k_list = [kv[0] for kv in dic.items() if kv[1] == d]
max_k_list.sort()

for s in max_k_list:
    print(s)

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


sdic = {}

nMax = 1

for i in range(N):
    s = str(input())
    if s in sdic:
        sdic[s] += 1
        nMax = max(nMax,sdic[s])
    else:
        sdic[s] = 1

slist = []
for k in sdic:
    if sdic[k] == nMax:
        slist.append(k)

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

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

l=[]
for _ in range(n):
  s=input()
  l.append(s)
c = Counter(l).most_common()
max_ = c[0][1]
ans=[]
for tup in c:
  p,q = tup
  if q != max_:
    break
  else:
    ans.append(p)
ans.sort()
for a in ans:
  print(a)

Solution (Python):
from collections import Counter
n=int(input())
string_list = [input() for i in range(n)]
str_count = Counter(string_list).most_common()
max = []
for i in str_count:
    if i[1] == str_count[0][1]:
        max.append(i[0])
    else:
        break
max.sort()
for w in max:
    print(w)

Solution (Python):
N = int(input())
L = []
D = {}
for _ in range(N):
    x = input()
    L.append(x)

for x in L:
    D[x] = 0
    
for x in L:
    D[x] += 1

SortD = sorted(D.items(), key=lambda x:x[1])
maxD = SortD[-1][1]
ans = []
for x in reversed(SortD):
    if x[1] == maxD:
        ans.append(x[0])
    else:
        break
for x in sorted(ans):
    print(x)

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


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

maxim = max(dict.values())

candidates = []

for key, count in dict.items():
    if count == maxim:
        candidates.append(key)

candidates.sort()

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

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

a = []
for d in s.items():
    if d[1] == m:
        a.append(d[0])
for s in sorted(a):
    print(s)

Solution (Python):
N = int(input())
S = []
for i in range(N):
    S.append(input())
A = []
from collections import Counter
d = Counter(S)
md = d.most_common(1)[0][1]
for key, value in d.items():
    if value == md:
        A.append(key)
As = sorted(A)
for a in As:
    print(a)

Solution (Python):

N = int(input())

d = {}

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]

ans_l = []

for k, v in d.items():
    if v==m: ans_l.append(k)

ans_l = sorted(ans_l)

for ans in ans_l:
    print(ans)

Solution (Python):
N = int(input())
S = []
for n in range(N):
    S.append(input())
dic = {}


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

max = max(dic.values())
out = []

for key,val in dic.items():
    if val == max:
        out.append(key)

out.sort()
for key in out:
    print(key)

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

max_count = max(polls.values())

results = []

for s in polls:
  if polls[s] == max_count:
    results.append(s)

results.sort()

for res in results:
  print(res)

Solution (Python):
from bisect import *
from collections import *
from itertools import *
import functools
import sys
import math
from decimal import *
from copy import *
from heapq import *
from fractions import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = 1000010
MOD = 10**9+7
spf = [i for i in range(MAXN)]
spf[0]=spf[1] = -1
def sieve():
    for i in range(2,MAXN,2):
        spf[i] = 2
    for i in range(3,int(MAXN**0.5)+1):
        if spf[i]==i:
            for j in range(i*i,MAXN,i):
                if spf[j]==j:
                    spf[j]=i
def fib(n,m):
    if n == 0:
        return [0, 1]
    else:
        a, b = fib(n // 2)
        c = ((a%m) * ((b%m) * 2 - (a%m)))%m
        d = ((a%m) * (a%m))%m + ((b)%m * (b)%m)%m
        if n % 2 == 0:
            return [c, d]
        else:
            return [d, c + d]

def charIN(x= ' '):
    return(sys.stdin.readline().strip().split(x))

def arrIN(x = ' '):
    return list(map(int,sys.stdin.readline().strip().split(x)))

def ncr(n,r):
    num=den=1
    for i in range(r):
        num = (num*(n-i))%MOD
        den = (den*(i+1))%MOD

    return (num*(pow(den,MOD-2,MOD)))%MOD

def flush():
    return sys.stdout.flush()

'''*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*'''
x = [input() for _ in range(int(input()))]
c = Counter(x)
mx = max(c.values())
ans = []
for i,j in c.items():
    if j==mx:
        ans.append(i)

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

Solution (Python):
from collections import defaultdict
n = int(input())
d = defaultdict(lambda: 0)
for i in range(n):
    s = input()
    d[s] += 1
k = max(d.values())
ansl = []
for key, value in d.items():
    if value == k:
        ansl.append(key)
ansl = sorted(ansl)
print(*ansl)

Solution (Python):
from itertools import groupby
N =int(input())
d = [input() for i in range(N)]

d.sort()

p=-1
b=[]
for key, value in groupby(d):
  a = len(list(value))
  if p<a:
    
    b=[]
    b.append(key)
    p=a
  elif p==a:
    
    b.append(key)
for i in b:
  print(i)

Solution (Python):
N = int(input())
Dic = {}
for n in range(N):
    S = input()
    if S in Dic.keys():
        Dic[S] = Dic[S] + 1
    else:
        Dic[S] = 1

max_val = max(Dic.values())
max_k_list = [kv[0] for kv in Dic.items() if kv[1] == max_val]
max_k_list = sorted(max_k_list)


   
print(*max_k_list, sep="\n")

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



    
    

Dic = Counter(L)
max_value = max(Dic.values())
max_k_list = [i for i, j in Dic.items() if j == max_value]
max_k_list = sorted(max_k_list)
 
print(*max_k_list , sep="\n")

Solution (Python):
import sys
from collections import Counter

input = sys.stdin.readline

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

c = Counter(l)
m = max(c.values())
c2 = [k for k, v in c.items() if v == m]

for x in sorted(c2):
    print(x)

Solution (Python):
from collections import defaultdict

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

mx = 0
for key, val in sdict.items():
  mx = max(mx, val)

ls = []
for key, val in sdict.items():
  if val == mx:
    ls.append(key)

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

Solution (Python):
S = [input() for _ in range(int(input()))]
from collections import Counter
ctr = Counter(S)
n = ctr.most_common()[0][1]
ans = []

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

Solution (Python):
import collections
n = int(input())
s = [input() for _ in range(n)]
s = collections.Counter(s).most_common()
ans = []
for i in range(1, len(s) + 1):
    ans.append(s[i - 1][0])
    if i == len(s):
        break
    if s[i - 1][1] != s[i][1]:
        break
ans.sort()
print(*ans, sep='\n')

Solution (Python):
from collections import defaultdict
n=int(input())
dic=defaultdict(int)
for _ in range(n):
    s = input()
    dic[s]+=1
L=list(dic.items())
L.sort(key=lambda x:x[0])
c=L[0][1]
for a,b in L:
    c=max(c,b)
for a,b in L:
    if b == c:
        print(a)

Solution (Python):
from collections import Counter
N = int(input())

L = []
for n in range(N):
    S = input()
    L.append(S)
Dic = Counter(L)
max_value = max(Dic.values())
max_k_list = [i for i, j in Dic.items() if j == max_value]
max_k_list = sorted(max_k_list)

print(*max_k_list , sep="\n")

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

Solution (Python):
N = int(input())
Dic = {}
for n in range(N):
    S = input()
    if S in Dic.keys():
        Dic[S] = Dic[S] + 1
    else:
        Dic[S] = 1

max_val = max(Dic.values())
max_k_list = [kv[0] for kv in Dic.items() if kv[1] == max_val]
max_k_list = sorted(max_k_list)
for t in max_k_list:
    print(t)

Solution (Python):
import sys
from collections import Counter
n = int(input())
s_ls = []
ct = Counter()
for i in range(n):
    s = sys.stdin.readline().strip()
    ct.update([s])
_max = max(ct.values())
for k, v in sorted([(k, v) for k, v in ct.items() if v == _max], key=lambda x:x[0]):
    print(k)

Solution (Python):
N = int(input())
Dic = {}
for n in range(N):
    S = input()
    if S in Dic.keys():
        Dic[S] = Dic[S] + 1
    else:
        Dic[S] = 1
        
max_value = max(Dic.values())

max_k_list = [kv[0] for kv in Dic.items() if kv[1] == max_value]
max_k_list = sorted(max_k_list)

print(*max_k_list, sep="\n")

Solution (Python):
import collections

n = int(input())
s = list(input() for _ in range(n))

c = dict(collections.Counter(s))
m = max(c.values())
ans = [k for k, v in c.items() if v == m]

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

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

    
    
Dic = Counter(L)
max_value = max(Dic.values())
max_k_list = [i for i, j in Dic.items() if j == max_value]
max_k_list = sorted(max_k_list)

print(*max_k_list , sep="\n")

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

    
    
Dic = Counter(L)
max_value = max(Dic.values())
max_k_list = [i for i, j in Dic.items() if j == max_value]
max_k_list = sorted(max_k_list)
for t in max_k_list:
    print(t)

Solution (Python):
import collections
s = collections.Counter([input() for s in range(int(input()))])
m = max(s.values())

a = []
for d in s.items():
  if d[1] == m:
    a.append(d[0])
for s in sorted(a):
  print(s)

Solution (Python):
from collections import Counter

N, *S = open(0).read().split()

C = Counter(S)

ma = max(C.values())
ans = sorted(k for k, v in C.items() if v == ma)

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

Solution (Python):
from bisect import *
from collections import *
from fractions import gcd
from math import factorial
from itertools import *
from heapq import *
import copy




N=int(input())
S=Counter([input() for i in range(N)]).most_common()
S=[i[0] for i in S if i[1]==S[0][1]]
for i in sorted(S):
    print(i)

Solution (Python):
from collections import Counter

N, *S = open(0).read().split()

C = Counter(S)

ma = max(C.values())
ans = sorted(k for k, v in C.items() if v == ma)

for a in ans:
    print(a)

Solution (Python):
import collections
 
n = int(input())
s = [input() for i in range(n)]
 
count = collections.Counter(s)
 
max_v = max(count.values())
 
result = [key for key, val in count.items() if val == max_v]

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

Solution (Python):
from collections import Counter

N, *S = open(0).read().split()

C = Counter(S).most_common()

ma = C[0][1]
ans = sorted(k for k, v in C if v == ma)

for a in ans:
    print(a)

Solution (Python):
from collections import Counter

def main():
  n = int(input())
  l = [input() for _ in range(n)]
  s = Counter(l)
  ans = []
  max_value = max(s.values())
  for x in s:
    if s[x] == max_value:
      ans.append(x)
  ans.sort()
  for x in ans:
    print(x)
  

if __name__ == '__main__':
  main()

Solution (Python):
import collections

n, *s_n = open(0).read().split()
n = int(n)

dic = collections.Counter(s_n)

dic_values_max = max(list(dic.values()))

max_key = [i for i, j in dic.items() if j == dic_values_max]

max_key.sort()

for k in max_key:
    print(k)

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

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

for i in range(len(T)):
    l=T[0][1]
    if(l>T[i][1]):
        T=T[0:i]
        break

T=sorted(T,key=lambda x:x[0])
for i in range(len(T)):
    print(T[i][0])

Solution (Python):
import collections as col


n=int(input())
s=[input() for i in range(n)]
c = col.Counter(s)
max = max(c.values())
ans = []

for key,val in c.items():
    if val == max:
       ans.append(key)

ans.sort()

for i in ans:
    print(i)

Solution (Python):
import collections
def inverse_lookup(d, x):
    cList = []
    for k,v in d.items():
        if x == v:
            l = k
            cList.append(l) 
    return cList

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

n = max(c.values())
out=sorted(inverse_lookup(c,n))
for word in out:
    print(word)

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 accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop

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

N = INT()
s = [input() for _ in range(N)]

cnt_s = Counter(s)
tmp = cnt_s.most_common()[0][1]
for key, val in sorted(cnt_s.most_common(), key=lambda x:x[0]):
	if val == tmp:
		print(key)

Solution (Python):
import collections

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

tmp = collections.Counter(ss).most_common()
target = tmp[0][1]
anss = []
for i in tmp:
    if i[1] == target:
        anss.append(i[0])
    else:
        break
anss = sorted(anss, key=str.lower)
print(*anss)

Solution (Python):
def main():
    import sys
    import collections
    input = sys.stdin.readline
    N = int(input())
    S = [input() for i in range(N)]
    c = collections.Counter(S)
    max_num = c.most_common(1)[0][1]
    c_most = list(c.most_common())
    ss = [cc[0] for cc in c_most if cc[1] == max_num]
    ss.sort()
    print("".join(ss))

if __name__ == "__main__":
    main()

Solution (Python):
def main():
    import sys
    import collections
    input = sys.stdin.readline
    N = int(input())
    S = []
    for i in range(N):
        S.append(input())
    c = collections.Counter(S)
    max_num = c.most_common(1)[0][1]
    ss = []
    for cc in c.most_common():
        if cc[1] == max_num:
            ss.append(cc[0])
    ss.sort()
    print("".join(ss))

if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
dic = {}
maxi = 0
for _ in range(n):
  k = input()
  dic[k] = 1 if k not in dic else dic[k] + 1
  if dic[k] > maxi: maxi = dic[k]
result = []
for i,j in dic.items():
  if j == maxi:
    result.append(i)
result.sort()
for r in result:
  print(r)

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

Sdict = dict()
max = 0
for _ in range(N):
    s = input()
    if s in Sdict:
        Sdict[s] += 1
    else:
        Sdict[s] = 0
    
maxi = 0
lis = []
for k,v in Sdict.items():
    if v > maxi:
        lis = [k]
        maxi = v
    elif v == maxi:
        lis.append(k)
lis.sort()
for k in lis:
    print(k)

Solution (Python):
def main():
    import sys
    import collections
    input = sys.stdin.readline
    N = int(input())
    S = [input() for i in range(N)]
    c = collections.Counter(S)
    max_num = c.most_common(1)[0][1]
    ss = []
    for cc in c.most_common():
        if cc[1] == max_num:
            ss.append(cc[0])
    ss.sort()
    print("".join(ss))

if __name__ == "__main__":
    main()

Solution (Python):
import itertools
from collections import Counter

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

a = sorted(a)



counter = Counter(a)

mode_v = counter.most_common()[0][-1]
cmc= counter.most_common()

it = itertools.takewhile(
    lambda kv: kv[-1] == mode_v, cmc
)


f=list(it)

f = sorted(f)

for k in range(len(f)):
	print(f[k][0])

Solution (Python):
import collections
N=int(input())
S=[""]*N
ans=[]
for k in range(N):
    S[k]=input()
count = collections.Counter(S)
maximum = max(count.values())
for i,j in count.items():
    if j == maximum:
        ans.append(i)
ans.sort()
for j in range(len(ans)):
    print(ans[j])

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())
l = []
for k in d:
    v = d[k]
    if v != m:
        continue
    l.append(k)

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

Solution (Python):
from collections import Counter

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

c = Counter(s)
c = c.most_common()
ans_number = c[0][1]
c.sort()

for i in range(len(c)):
  if c[i][1] == ans_number:
    print(c[i][0])

Solution (Python):
n=int(input())
a=[]
b=[]
c=[]
for i in range(n):
    b=str(input())
    a.append(b)
freq = {}
for item in a:
        if (item in freq):
            freq[item] += 1
        else:
            freq[item] = 1

t=0
b=[]
for items in freq.values():
    if items>t:
        t=items

for key,val in freq.items():
    if val==t:
        b.append(key)
b.sort()
for i in range(len(b)):
    print(b[i])

Solution (Python):
from collections import Counter, deque, defaultdict
from functools import lru_cache

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

x = c.most_common()
pv = x[0][1]
arr=[]
for k,v in x:
	if v < pv:
		break
	arr.append(k)
arr.sort()
for k in arr:
	print(k)

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

for i in range(n): 
  s = input()
  a.setdefault(s, 0)
  a[s] += 1
  
ans = []
mx = 0
for key, value in a.items(): 
  if mx < value:
    mx = value
    ans = [key]
  elif mx == value:
    ans.append(key)

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

Solution (Python):
N=int(input())
S = [input() for i in range(N)]
S.sort()
import itertools
gr = itertools.groupby(S)
ans=[]
n=0
for key, group in gr:
  a=len(list(group))
  if a>n:
    ans=[]
    n=a
    ans.append(key)
  elif a==n:
    ans.append(key)
for a in ans:
  print(a)

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

cands = []
for j in ctr.keys():
    if ctr[j] == n:
        cands.append(j)
cands.sort()
print(*cands, sep='\n')

Solution (Python):
from collections import Counter

N = int(input())
counter = Counter()
for i in range(0, N):
    counter[str(input())] += 1
A = max(counter.values())
S = []
for a, b in counter.items():
    if A == b:
        S.append(a)
S.sort()
for s in S:
    print(s)

Solution (Python):
from collections import Counter
N=int(input())
C=sorted(Counter([input() for i in range(N)]).items(),key=lambda x:-x[1])
tmp=C[0][1]
ans = []
for i,j in C:
    if j==tmp:
        ans.append(i)
    else:
        break
for i in sorted(ans):
    print(i)

Solution (Python):
import sys
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    s = collections.Counter([str(readline().rstrip().decode('utf-8')) for _ in range(n)]).most_common()
    s.sort(key=lambda x: x[0])
    s.sort(key=lambda x: x[1], reverse=True)
    for k, v in s:
        if v == s[0][1]:
            print(k)
        else:
            break


if __name__ == '__main__':
    solve()

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

C=Counter(S)
A=[]
B=[]
T=[]

for i,j in C.most_common():
    A.append(i)
    B.append(j)
for k in range(len(A)):
    if B[k]==B[0]:
        T.append(A[k])
T=sorted(T)
for m in range(len(T)):
  print(T[m])

Solution (Python):
from collections import*
n,*s=open(0)
c=Counter(s).most_common()
print(*sorted(a*(b==c[0][1])for a,b in c))

Solution (Python):
from collections import Counter

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

C = Counter(S)
max_cnt = max(C.values())

names = [names for names, values in C.items() if values == max_cnt]
names.sort()

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

Solution (Python):
import collections

n = int(input())
List = [input() for i in range(n)]
res = []



c = {}

for i in range(n):
    if List[i] in c.keys():
        c[List[i]] += 1
    else:
        c[List[i]] = 1


m = 0
for v in c.values():
    m = max(m, v)

for k, v in c.items():
    if v == m:
        res.append(k)
    
res.sort()
for i in range(len(res)):
    print(res[i])

Solution (Python):
def contest(N, str):
    count = {}

    for s in str:
        if s not in count:
            count[s] = 1

        else:
            count[s] +=  1
    
    ret = sorted(count.items(),key=lambda count: count[1], reverse=True)
    maxnum = ret[0][1]
    
    retVal = []

    for r in ret:
        if r[1] == maxnum:
            retVal.append(r[0])
            
        else:
            break

    result = '\n'.join(sorted(retVal))

    return result


if __name__ == "__main__":
    N = int(input())
    S = []

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

    print(contest(N, S))

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

from collections import defaultdict
d = defaultdict(lambda:0)

for k in S:
    d[str(k)]+=1
    
ansn=max(d.values())
ans=[]
for i in set(S):
    if d[i]==ansn:
        ans.append(i)

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

Solution (Python):
import collections
n = int(input())
s = [input() for i in range(n)]
c = collections.Counter(s).most_common()
ans = [k for k, v in c if c[0][1] == v]
ans.sort()
for i in ans:
    print(i)

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

from collections import defaultdict
d = defaultdict(lambda:0)

for k in S:
    d[str(k)]+=1

ansn=0
ans=[]
for i in set(S):
    if d[i]>ansn:
        ansn=d[i]
        ans=[]
    if d[i]==ansn:
        ans.append(i)

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

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

M = max(a.values())
ans = []
for s in a:
    if a[s] == M:
        ans.append(s)
ans.sort()
for s in ans:
    print(s)

Solution (Python):
from collections import defaultdict

def I(): return int(input())
def MI(): return map(int, input().split())
def LMI(): return list(map(int, input().split()))


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

m = max(d.values())
ans = list()
for s, cnt in d.items():
    if cnt == m:
        ans.append(s)
ans.sort()
for x in ans:
    print(x)

Solution (Python):
def main():
    import sys
    import collections
    input = sys.stdin.readline
    N = int(input())
    S = [input() for i in range(N)]
    c = collections.Counter(S)
    max_num = c.most_common(1)[0][1]
    c_most = list(c.most_common())
    ss = [cc[0] for cc in c_most if cc[1] == max_num]
    ss.sort()
    print("".join(ss))


main()

Solution (Python):
from collections import Counter
int = int(input())
word = [input() for i in range(int)]
s = Counter(word).most_common()
u = s[0][1]
v = []
for i, j in s:
  if j == u:
    v.append(i)
v.sort()
print(*v)

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

q = int(input())
a = [input().rstrip() for _ in range(q)]

dic = collections.Counter(a)

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

Solution (Python):
def main():
    import sys
    import collections
    input = sys.stdin.readline
    N = int(input())
    S = [input() for i in range(N)]
    c = collections.Counter(S)
    max_num = c.most_common(1)[0][1]
    c_most = list(c.most_common())
    ss = [cc[0] for cc in c_most if cc[1] == max_num]
    ss.sort()
    print("".join(ss))

if __name__ == "__main__":
    main()

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

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

max_num = Sc[0][1]
ans = []
for key, val in Sc:
    if val == max_num:
        ans.append(key)
ans.sort()
for t in ans:
    print(t)

Solution (Python):
N=int(input(), 10)
cnt = dict()
for _ in range(N):
    s = input()
    if s in cnt:
        cnt[s] += 1
    else:
        cnt[s] = 0

max_cnt = max(cnt.values())
for word in sorted([key for key, value in cnt.items() if value == max_cnt]):
    print(word)

Solution (Python):
def main():
    import sys
    import collections
    input = sys.stdin.readline
    N = int(input())
    S = [input().rstrip() for i in range(N)]
    c = collections.Counter(S)
    max_num = c.most_common(1)[0][1]
    c_most = c.most_common()
    ss = [cc[0] for cc in c_most if cc[1] == max_num]
    ss.sort()
    print("\n".join(ss))

if __name__ == "__main__":
    main()

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

L = [(D[d], d) for d in D] + [(0, "*")]
L.sort(key=lambda x: x[1])
L.sort(key=lambda x: x[0], reverse=True)

i = 0
while L[0][0] == L[i][0]:
    print(L[i][1])
    i += 1

Solution (Python):

N = int(input())
S = list(input() for i in range(N))

import collections

c = collections.Counter(S)
max = max(c.values())
 
max_k_list = [kv[0] for kv in c.items() if kv[1] == max]
max_k_list.sort()
for l in max_k_list:
    print(l)

Solution (Python):
def main():
    import sys
    import collections
    input = sys.stdin.readline
    N = int(input())
    S = [input() for i in range(N)]
    c = collections.Counter(S)
    max_num = c.most_common(1)[0][1]
    ss = [cc[0] for cc in c.most_common() if cc[1] == max_num]
    ss.sort()
    print("\n".join(ss))

if __name__ == "__main__":
    main()

Solution (Python):
from collections import*
_,*s=open(0)
c=Counter(s).most_common()
print(*sorted(a*(b==c[0][1])for a,b in c))

Solution (Python):
import collections

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

count = c.most_common()[0][1]
ans = []
p = c.most_common()
for i in range(len(c)):
    if p[i][1] == count:
        ans.append(p[i][0])
    else:
        break   
ans = sorted(ans)
for i in ans:
    print(i)

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

s_list = [""]*n

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

s_list.sort()

ans_list = [s_list[0]]
pre_s = s_list[0]
count = 1
max_count = count

if len(s_list) == len(set(s_list)):
    ans_list = s_list
        
    ans_list.sort()

    for s in ans_list:
        print(s)

    exit()


for i in range(1,n):
    if pre_s == s_list[i]:
        count += 1
        if count == max_count:
            ans_list.append(s_list[i])
        if count > max_count:
            max_count = count
            ans_list = [s_list[i]]
    else:
        pre_s = s_list[i]
        count = 1

ans_list.sort()

for s in ans_list:
    print(s)

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

a=1
num=[]
st=[]
c = collections.Counter(s)

max_c = max(c.values())

st=[]
for k,v in c.items():
    if v==max_c:
        st.append(k)
st2=sorted(st)
[print(i) for i in st2]

Solution (Python):
import numpy as np

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

a = np.sort(np.array(a))

unique_elements, index_elements = np.unique(a, return_index = True)
l = []
for i in range(index_elements.size -1):
  m = index_elements[i + 1] - index_elements[i]
  l.append(m)
l.append(a.size - index_elements[-1])    
elements = unique_elements[l == max(l)]


for i in elements:
	print(i)

Solution (Python):
import collections
from collections import Counter

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

count = c[0][1]
ans = []

for i in range(len(c)):
    if c[i][1] == count:
        ans.append(c[i][0])
    else:
        break   
ans = sorted(ans)
for i in ans:
    print(i)

Solution (Python):
from collections import defaultdict

count = defaultdict(int)
n = int(input())
tmp_max=0
for i in range(n):
    s=input()
    tmp_cnt = count[s]
    tmp_max = max(tmp_max,tmp_cnt+1)
    count[s]+=1

ans=[]
for k,v in count.items():
    if v==tmp_max:
        ans.append(k)
ans=sorted(ans)
for s in ans:
    print(s)

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

def main():
	
	
	N=int(input())
	
	vS=[input().rstrip() for _ in [0,]*N]
	cS=col.Counter(vS)
	
	mcS=cS.most_common()
	mc = mcS[0][1]
	res = sorted([s for s,c in mcS if c==mc])
	
	print(*res, sep="\n")


main()

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

d = Counter(s).most_common()

s = d[0][1]
ans = []
for k, v in d:
    if s == v:
        ans.append(k)
    else:
        break
print(*sorted(ans), sep="\n")

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

M = max(S.values())

L = list(S)
L.sort()
for i in L:
    if S[i] == M:
        print(i)

Solution (Python):
import collections
import itertools

a = int(input())

s = [input() for i in range(a)]

counter = collections.Counter(s)

mode_v = counter.most_common()[0][-1]
it = itertools.takewhile(
    lambda kv: kv[-1] == mode_v, counter.most_common()
)

l = []

for k, v in it:
  l.append(k)

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