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

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

dict_sorted = sorted(dict1.items(), key = lambda x: x[0])
dict_sorted.sort(key = lambda x: x[1], reverse = True)

max1 = dict_sorted[0][1]

for i in range(len(dict_sorted)):
    if dict_sorted[i][1] == max1:
        print(dict_sorted[i][0])
    else:
        break

Solution (Python):
Nu=int(input())
dic={}
ls=[]
maxd=0
for i in range(Nu):
  tmp=input()
  if tmp in dic:
    dic[tmp]=dic[tmp]+1
    maxd=max(dic[tmp],maxd)
  else:
    dic[tmp]=0
for k,v in dic.items():
  if v==maxd:
    ls.append(k)
ls.sort()
for x in ls:
  print(x)

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

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

s.sort()

max1 = 0
ans = []
tmp = ''
count = 0

for i in s:
    if tmp == i:
        count += 1
    else:
        if max1 > count:
            count = 1
            tmp = i
        elif max1 == count:
            ans.append(tmp)
            count = 1
            tmp = i
        else:
            ans = [tmp]
            max1 = count
            count = 1
            tmp = i

if max1 > count:
    count = 1
    tmp = i
elif max1 == count:
    ans.append(tmp)
    count = 1
    tmp = i
else:
    ans = [tmp]
    max1 = count
    count = 1
    tmp = i

for i in ans:
    print(i)

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

Solution (Python):
input = open(0).readline
n = int(input())
array = []

for i in range(n):
    x = input().rstrip('\n')
    array.append(x)
    
d = {}

for s in array:
    if s in d.keys():
        d[s] +=1
    else:
        d[s] = 1

max_val = max(d.values())
array2 = [key for key in d if d[key] == max_val]
array2 = sorted(array2)

for s in array2:
    print(s)

Solution (Python):
import collections


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

dic = collections.Counter(s)
k = dic.most_common()
m = k[0][1]
mx = m
i = 0
ans = []
while m == mx: 
    ans.append(k[i][0])
    i += 1
    if i > len(k)-1:
        break
    m = k[i][1]

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

Solution (Python):
from collections import Counter
N = int(input())
S = [input() for i in range(N)]
c = Counter(S)
ans = c.most_common()
ans = [i[0] for i in ans if i[1] == ans[0][1]]
for i in sorted(ans):
    print(i)

Solution (Python):
from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
c = Counter(S)
ans = c.most_common()
ans = [i[0] for i in ans if i[1] == ans[0][1]]
for i in sorted(ans):
    print(i)

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

M = max(D.values())
for S in sorted(list(D)):
    if D[S]==M:
      print(S)

Solution (Python):
import collections

N = int(input())

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

l_dict = collections.Counter(l)

max_n = max(l_dict.values())

l_max = sorted([x[0] for x in l_dict.items() if x[1] == max_n])

for a in l_max:
    print(a)

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

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

dic = {}
for i in data:
  dic[i] = dic.get(i, 0) + 1

data = []
for i in dic.keys():
  data.append((-dic[i], i))

data.sort()

thresh = data[0][0]
for i in data:
  if i[0] == thresh:
    print(i[1])

Solution (Python):
import sys

lines = [l.rstrip() for l in sys.stdin.readlines()]
d = {}

n = int(lines[0])
for l in lines[1:]:
    if l in d.keys():
        d[l] += 1
    else:
        d[l] = 1

s = sorted(d.items(), key=lambda x: -x[1])
l = sorted([e for e in s if e[1] == s[0][1]], key=lambda x: x[0])

for k, _ in l:
    print(k)

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

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

max_s = max(dic.values())
max_s_list = []


for k,v in dic.items():
    if v == max_s:
        max_s_list.append(k)

max_s_list = sorted(max_s_list)

for j in max_s_list:
    print(j)

Solution (Python):
import collections

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

c = collections.Counter(s)
max_num = max(c.values())
d = []
for key,value in c.items():
  if value == max_num:
    d.append(key)

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

Solution (Python):
from collections import Counter

N = int(input())
cnt = Counter()
for i in range(N):
  cnt[input()] += 1

mc = cnt.most_common(1)[0][1]
ms = []
for kw, count in cnt.most_common():
  if(count<mc):
    break
  ms.append(kw)
  
ms.sort()
for s in ms:
  print(s)

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

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):
N = int(input())
d = {}
for i in range(N):
    s = input()
    if s not in d:
        d[s] = 1
    else:
        d[s] += 1

list = sorted(d.values())
max_value = max(list)
sorted_list = sorted(d.items(), key=lambda x: x[0])

for i, j in sorted_list:
    if j == max_value:
        print(i)

Solution (Python):
N = int(input())
l = {}
for _ in range(N):
  s = input()
  l.setdefault(s, 0)
  l[s] += 1
l = sorted([(v, k) for k, v in l.items()])
c = l[-1][0]
r = []
for i in range(-1, -len(l)-1, -1):
  if l[i][0] < c:
    break
  r.append(l[i][1])
for x in reversed(r):
  print(x)

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

list1 = sorted(b.items(), key=lambda x: x[1])

a = len(list1)-1
temp = len(list1)-1
list2 = []
while a >= 0 and list1[temp][1] == list1[a][1]:
    list2.append(list1[a][0])
    a -= 1
list2.sort()

for a in list2:
    print(a)

Solution (Python):
n = int(input())
Dict = {}
for i in range(n):
  Str = input()
  if Str in Dict:
    Dict[Str]+=1
  else:
  	Dict[Str] = 0 
List = list(Dict.values())
Max = max(List)
Dict_sorted = sorted(Dict.items(), key=lambda x:x[0])
for i,j in Dict_sorted:
  if j ==Max:
    print(i)

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

strs = []
dicts = {}
for i in range(N):
    s = input()
    if dicts.get(s) is not None:
        dicts[s] += 1
    else:
        dicts[s] = 1

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

i = 0
sts = []
for s in dict_sorted:
    if dicts[s[0]] == dicts[dict_sorted[0][0]]:
        sts.append(s[0])
    i = dicts[s[0]]

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

Solution (Python):
from collections import defaultdict

N = int(input())
A = [input() for _ in range(N)]
A.sort()
d = defaultdict(int)
for a in A:
    d[a] += 1

l = sorted(d.items())
max_v = 0

for _, v in l:
    if v > max_v:
        max_v = v
    
for k, v in l:
    if v == max_v:
        print(k)
    else:
        continue

Solution (Python):
import sys

ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: [int(x) for x in ns().split()]
nall = lambda: [int(x) for x in sys.stdin.readlines()]
sall = lambda: [x.strip() for x in sys.stdin.readlines()]

def main():
    _ = ni()
    xs = sall()
    d = {}
    for x in xs:
        if x in d:
            d[x] = d[x] + 1
        else:
            d[x] = 1

    r = []
    m = 0
    for k, v in d.items():
        if v > m:
            r = [k]
            m = v
        elif v == m:
            r.append(k)

    r.sort()
    for v in r:
        print(v)


main()

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

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

s.sort()

count_ = 0
max_ = 0
tmp = 'DUMMY'
ans = []
for i in range(n):
    if(tmp == s[i]):
        count_ += 1
    else:
        if(max_ < count_):
            max_ = count_
            ans = [tmp]
        elif(max_ == count_):
            ans.append(tmp)
        count_ = 1
        tmp = s[i]

if(max_ < count_):
    max_ = count_
    ans = [tmp]
elif(max_ == count_):
    ans.append(tmp)

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

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

d=Counter(S)
maxi=0
for i in d.keys():
    maxi=max(maxi,d[i])

ans=[]
for i in d.keys():
    if d[i]==maxi:
        ans.append(i)
ans=sorted(ans)
print('\n'.join(ans))

Solution (Python):
n = int(input())
wk = wkmax = 0
si = {}
for i in range(n):
    st = input()
    if st in si:
        si[st] = si[st] + 1
    else:
        si[st] = 1
    wk = si[st]
    wkmax = max(wk,wkmax)
sl = sorted(si.items())
for i in range(len(sl)):
    if wkmax == sl[i][1]:
        print(sl[i][0])

Solution (Python):
import collections
n=int(input())
s=[]
num=[]
ans=[]
for i in range(n):
    s.append(input())
c = collections.Counter(s)
v=(c.most_common())
num=v[0][1]
for j in v:
    if (j[1]==num):
        ans.append(j[0])
    else:
        break
for k in sorted(ans):
	print(k)

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

ans_n = max(s.values())

sorted_s = sorted(s.items())

for i in range(len(sorted_s)):
    if sorted_s[i][1] == ans_n:
        print(sorted_s[i][0])

Solution (Python):
from collections import Counter

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

c = Counter(S)
c_max = max(c.values())
[print(x) for x in sorted([s for s in set(S) if c[s] == c_max])]

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

S_dict = dict()

for i in range(N):
    S = str(input())
    if S not in S_dict:
        S_dict[S] = 1
    else:
        S_dict[S] += 1

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

max_polled = score_S_list[0][1]

max_polled_S = list()

for S in score_S_list:
    if S[1] == max_polled:
        max_polled_S.append(S[0])
    else:
        break
        
max_polled_S.sort()

for S in max_polled_S:
    print(S)

Solution (Python):
from collections import Counter

votes = Counter([input() for _ in range(int(input()))])

v = votes.most_common()
num = v[0][1]


ans_list = []
for i in  v:
	if(i[1] == num):
		 ans_list.append(i[0])
	else:
		break

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

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

dic = {}

for i in range(N):
    S = input()
    
    if (S in dic) == False:
        dic[S] = 1
    else:
        dic[S] += 1
        
keys = []
maxv = max(dic.values())
for key , value in dic.items():
    if value == maxv:
        keys.append(key)
k = keys.sort()
for i in keys:
    print(i)

Solution (Python):
N = int(input())
dc={}
for i in range(N):
  s=input()
  if s in dc:
    dc[s]+=1
  else:
    dc[s]=1
m=max(dc.values())
w = [kv[0] for kv in dc.items() if kv[1] == m]
w.sort()
for p in w:
  print(p)

Solution (Python):
import sys

lines = [l for l in sys.stdin]
length = int(lines[0])
words = lines[1:]
counter = {w: 0 for w in words}

for w in words:
  counter[w] += 1
  
max_count = max(counter.values())

ret = [w for w, v in counter.items() if v == max_count]
ret.sort()
for w in ret:
  print(w)

Solution (Python):
from collections import Counter


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


c = sorted([k for k, v in c.items() if v == max_])
for j in c :
    print(j)

Solution (Python):
import collections

number = int(input())

array = []

for i in range(number):
    array.append(input())

dic = collections.Counter(array).most_common()

max_dic = [dic[0][0]]

for i in range(len(dic) - 1):
    if dic[i + 1][1] == dic[0][1]:
        max_dic.append(dic[i + 1][0])
        
max_dic.sort()

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

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

d = {}
for i in range(n):
  t = input()
  if t in d.keys():
    d[t] += 1
  else:
    d[t] = 0

s = sorted(list(set(d.keys())))
m = max(d.values())

for s in s:
  if d[s] == 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())
      


s = sorted(k for k in d if d[k] == m)

for i in s:
  print(i)

Solution (Python):
from collections import Counter

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

d = Counter(s)
m = max(d.values())
ans = [i for i in d if d[i] == m]
ans = sorted(ans)

for i in ans:
    print(i)

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

count = {}
for s in S:
    count[s] = count.get(s, 0) + 1
max_count = max(count.values())
ret = []
for k in count.keys():
    if count[k] == max_count:
        ret.append(k)
ret = sorted(ret)
for r in ret:
    print(r)

Solution (Python):

from collections import Counter


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

C=Counter(S).most_common()
L=len(C)

D=[]

D.append(C[0][0])

for i in range(1,L):
    if C[0][1]==C[i][1]:
        D.append(C[i][0])
D.sort()
M=len(D)

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

Solution (Python):
import collections
n = int(input())
arr = []
ans = []
for i in range(n):
    s = input()
    arr.append(s)
c = collections.Counter(arr)
max_s = c.most_common()[0][1]
for j, k in c.items():
    if k == max_s:
        ans.append(j)
s_ans = sorted(ans)
for l in s_ans:
    print(l)

Solution (Python):
from collections import Counter
import sys
input=sys.stdin.readline
n=int(input())
s=[input().rstrip() for _ in range(n)]
C=Counter(s).most_common()
f=C[0][1]
t=[]
for k,v in C:
	if v<f:
		break
	t.append(k)
print(*sorted(t),sep="\n")

Solution (Python):
import sys

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

dicstok = {}
dicktos = {}

for i in range(n):
  k = s[i]
  v = dicstok.get(k, 0)
  dicstok[k] = v+1

  if(dicktos.get(v+1) == None):
    dicktos[v+1] = set([])
  dicktos[v+1].add(k)
  
  if(v>=1):
    dicktos[v].discard(k)


ls = len(dicktos)
l = list(sorted(list(dicktos[ls])))

for k in l:
  print(k)

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

Solution (Python):
from collections import defaultdict

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

d = defaultdict(int)
for key in S:
    d[key] += 1
    
dl = sorted(d.items(), key=lambda x: x[0], reverse=False)
Max = max(d.values())

for i in range(len(dl)):
  if dl[i][1] == Max:
    print(dl[i][0])

Solution (Python):
import collections

N = int(input())
list_1 = [input() for i in range(N)]
list_2 = collections.Counter(list_1)

m = max(list_2.values())

ans = [k for k in list_2 if list_2[k] == m]

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

Solution (Python):
import collections
n = int(input())
lst = [input() for i in range(n)]
c = collections.Counter(lst)
num = max(c.values())
lst = []
for k,v in c.items():
    if v==num:
        lst.append(k)
lst.sort()
for l in lst:
    print(l)

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

counted = collections.Counter(s)

m = max(counted.values())

chars = []
for key, value in counted.items():
    if value == m:
        chars.append(key)
chars=sorted(chars)

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

Solution (Python):
import collections

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

maxn = m[0][1]
ans = []

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

Solution (Python):
import collections

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

maxn = m[0][1]
ans = []

ans.append(m[0][0])
for i in range(len(m)-1):
    if m[i+1][1] == maxn:
        ans.append(m[i+1][0])
    else:
        break
for i in sorted(ans):
    print(i)

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

Solution (Python):
import sys

n = int(input())
s_di = dict()

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

s_di = sorted(tuple(s_di.items()))
s_di = sorted(s_di, key=lambda s: s[1])


n_max = s_di[-1][1]

for s in s_di:
    if s[1] == n_max:
        print(s[0])

Solution (Python):
n = int(input())
d = dict()
max_value = 0
for i in range(n):
  x = input()
  if x in d:
    d[x] += 1
  else:
    d[x] = 1
  max_value = max([max_value, d[x]])

d = sorted([(key, value) for key, value in d.items()], key = lambda x: x[0])
for key, value in d:
  if value == max_value:
    print(key)

Solution (Python):
n = int(input())
mymap = {}
maxi = 0
for i in range(n):
	s = str(input())
	if (s in mymap):
		mymap[s] += 1
	else:
		mymap[s] = 1
	maxi = max(maxi, mymap[s])
	
ans = []

for key in mymap:
	if (mymap[key] == maxi):
		ans.append(key)
		
ans.sort()

for s in ans:
	print(s)

Solution (Python):
n = int(input())
s_dic = {}
count = 0
for i in range(n):
    tmp = input()
    s_dic.setdefault(tmp, 0)
    s_dic[tmp] += 1
    if count < s_dic[tmp]:
        count = s_dic[tmp]
ans = [k for k, v in s_dic.items() if v == count]
ans.sort()
for a in ans:
    print(a)

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

c=collections.Counter(a)
m=c.most_common()
most=m[0][1]
ans=[]
ans.append(m[0][0])
for i in range(len(m)-1):
  if m[i+1][1]==most:
       ans.append(m[i+1][0])
  else:
       break
for out in sorted(ans):
       print(out)

Solution (Python):
import collections

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

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

candidates = [cand for cand in common if cand[1] == N_common]

for i in sorted(candidates):
    print(i[0])

Solution (Python):
import collections

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

c = collections.Counter(p)
m = c.most_common()
most = m[0][1]

answer = []

answer.append(m[0][0])

for i in range(len(m)-1):
    if m[i+1][1] == most:
        answer.append(m[i+1][0])
    else:
        break

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

Solution (Python):
import collections

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

    c = collections.Counter(p)
    m = c.most_common()
    most = m[0][1]

    answer = []

    answer.append(m[0][0])

    for i in range(len(m)-1):
        if m[i+1][1] == most:
            answer.append(m[i+1][0])
        else:
            break

    for output in sorted(answer):
        print(output)
    return


main()

Solution (Python):
from collections import Counter

n = int(input())
s = [input() for i in range(n)]
c = Counter(s)
max_ = max(c.values())
c = sorted([k for k, v in c.items() if v == max_])
for a in c:
    print(a)

Solution (Python):

def main():
    N = int(input())
    dict = {}

    for _ in range(N):
        word = input()
        if word in dict:
            dict[word] += 1
        else:
            dict[word] = 0

    m = max(dict.values())
    dict = sorted(dict.items(), key=lambda x: x[0])

    for d in dict:
        if d[1] == m:
            print(d[0])
    return 0


if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
s=[]
for i in range(n):
    x=input()
    s.append(x)
a={}
for i in range(n):
    
    if not s[i] in a:
        a[s[i]]=1
    else:
        a[s[i]]+=1
a=sorted(a.items(), key=lambda x:x[1],reverse=True)
maxv=a[0][1]
ans=[]
for i in a:
    if i[1]==maxv:
        ans.append(i[0])
ans.sort()
for i in ans:
    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

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

list = []
list.append(sortDic[0][0])
j = 0

if len(sortDic) != 1:
    while j < len(sortDic)-1 and sortDic[j][1] == sortDic[j+1][1]:
        list.append(sortDic[j+1][0])
        j += 1

list = sorted(list)

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

Solution (Python):
import collections

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

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

candidates = [cand for cand in common if cand[1] == N_common]

for i in sorted(candidates):
    print(i[0])

Solution (Python):
n = int(input())
from collections import defaultdict as dd
Dic = dd(lambda: 0)
for i in range(n):
  Dic[input()] += 1



max_val = max(Dic.values())
Cands = [key for key, value in zip(Dic.keys(), Dic.values()) if value == max_val]
Cands.sort()
print(*Cands, sep="\n")

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

Solution (Python):
n = int(input())
d = dict()
for _ in range(n):
    x = str(input())
    if x in d:
        d[x] += 1
        continue
    else:
        d[x] = 0

d_sort = sorted(d.items(), key=lambda d:d[1], reverse = True)
d_max = d_sort[0][1]

ans = []
for i in d_sort:
    if d_max == i[1]:
        ans.append(i[0])
    else:
        break

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

Solution (Python):
from collections import Counter

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

c = Counter(S)
max_c = max(c.values())

c_sorted = sorted(c.items(), key = lambda x:x[0])
for v in c_sorted:
    if v[1] == max_c:
        print(v[0])

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    c = collections.Counter([S() for _ in range(n)])
    mv = max(c.values())

    return JA(sorted([k for k,v in c.items() if v == mv]), "\n")


print(main())

Solution (Python):
N = int(input())
d = {}
for i in range(N):
  s = input()
  d[s] = d.get(s, 0) + 1
base = sorted(d.items(), key=lambda x: x[1], reverse=True)[0][1]
items = [k for k, v in d.items() if v==base]
for item in sorted(items):
  print(item)

Solution (Python):
from collections import Counter
n = int(input())
S = [input() for _ in range(n)]
c = Counter(S)
max = 0
for s in set(S):
  if max < c[s]:
    max_words = [s]
    max = c[s]
  elif max == c[s]:
    max_words.append(s)
max_words.sort()
print("\n".join(max_words))

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

for name in S:
    if name in dic.keys():
        dic[name] += 1
        if dic[name] > max:
            max = dic[name]
    else:
        dic[name] = 1

keys = [k for k, v in dic.items() if v == max]
keys.sort()

for key in keys:
    print(key)

Solution (Python):
from collections import Counter

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


ans = []
ans.append(s[0][0])
cnt = s[0][1]

if (len(s) != 1):
  for i in range(1, n):
    if (s[i][1] < cnt):
      break
    else:
      ans.append(s[i][0])

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

Solution (Python):
n=int(input())
L={}
c=0
for i in range (n):
    s=input()
    if s in L:
        L[s]+=1
    else:
        L.update({s:1})
        c+=1
M=list(L.values())
C=list(L.keys())
b=max(M)
F=[]
for i in range(c):
    if M[i]==b:
        F+=[C[i]]
F.sort()
for i in F:
    print(i)

Solution (Python):
import math
from collections import Counter


n = int(input())
votes = []

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

counter = Counter(votes).most_common()
max_votes = counter[0][1]

candidates = [cand for cand in counter if cand[1] == max_votes]

for candidate in sorted(candidates):
    print(candidate[0])

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

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

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

v = dic[-1][1]
ans = []

for d in dic:
    if d[1] == v:
        ans.append(d[0])

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

Solution (Python):



import collections
a = int(input())
li1 = []
 
for i in range(a):
    li1.append(str(input()))
 
c = collections.Counter(li1)
 
sorted_items = sorted(
  c.most_common(),
  key = lambda x:(x[1],x[0]), reverse=True)
 
key, value = zip(*sorted_items)
li2 = []
li2.append(key[0])
for i in range(1,len(key)):
    if(value[0] == value[i]):
        li2.append(key[i])
    else:
        break;

list.sort(li2)

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

Solution (Python):
from collections import defaultdict

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

for s in S:
  D[s] += 1

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

Solution (Python):
n=int(input())
mp={}
for i in range(n):
    s=input()
    if s in mp:
        mp[s]+=1
    else:
        mp[s]=1
_max=0
for x,y in mp.items():
    _max=max(_max,y)
ans=[]
for x,y in mp.items():
    if y==_max:
        ans.append(x)
ans.sort()
for x in ans:
    print(x)

Solution (Python):
import collections
n = int(input())
si = []

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

ss = collections.Counter(si)
n_ma = max(ss.values())

ans = []
for i in ss.keys():
    if ss[i] == n_ma:
        ans.append(i)

ans.sort()

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

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

N = int(input())
count = defaultdict(int)
for _ in range(N):
    S = input().rstrip()
    count[S] += 1
ans = []
for k, v in count.items():
    ans.append((v, k))
ans.sort(key=lambda x: (-x[0], x[1]))
ans = deque(ans)
m = ans[0][0]
while ans:
    v, k = ans.popleft()
    if v == m:
        print(k)
    else:
        break

Solution (Python):
from collections import Counter

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

dic = Counter(S)

tmp = max(dic.values()) 
ans = [key for key, value in dic.items() if value == tmp]


"""
for key in sorted(ans):
    print(key, end="")
    print("")
"""


ans.sort()
print(*ans, sep="\n")

Solution (Python):
from collections import Counter

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

dic = Counter(S)

tmp = max(dic.values())
ans = [key for key, value in dic.items() if value == tmp]


for key in sorted(ans):
    print(key, end="")
    print("")

Solution (Python):
def maximum_values(d):
    retval = []
    maxval = max(d.values())

    for k, v in d.items():
        if v == maxval:
            retval.append(k)

    return retval

num = int(input())
strings = {}

for i in range(num):
    string = input()
    if string in strings.keys():
        strings[string] += 1
    else:
        strings[string] = 1

maximums = maximum_values(strings)
maximums = sorted(maximums)
print("\n".join(maximums))

Solution (Python):
n = int(input())
ma = 0
str1 = {}
ans=[]
for i in range(n):
	s = str(input())
	try:
		str1[s]+=1
	except:
		str1[s]=1
	if ma < str1[s]:
		ma=str1[s]
sorted(str1.items(),key=lambda x: x[1],reverse=True)
for item,val in str1.items():
	if ma==val:
		ans.append(item)
for i in sorted(ans):
	print(i)

Solution (Python):
from collections import Counter
def solve(n, s):
    D = Counter(s)
    best = max(D.values())
    S = filter(lambda k: D[k] == best, D.keys())
    return "\n".join(sorted(list(S)))

n = int(input())
s = [input() for i in range(n)]
print(solve(n, s))

Solution (Python):
from collections import Counter
n = int(input())
input_list = [input() for i in range(n)]
cnt = Counter()
for word in input_list:
  cnt[word] += 1
max_value = max(cnt.values())
answer = [i for i, j in cnt.items() if j == max_value]
answer.sort()
for i in answer:
  print(i)

Solution (Python):
from collections import Counter
import sys
n = int(sys.stdin.readline())
sn = sys.stdin.read().split()
c = Counter(sn)
num = max(c.values())
ans = [i for i, j in c.items() if j == num]
ans.sort()
print('\n'.join(ans))

Solution (Python):
from collections import Counter
import sys
n = int(sys.stdin.readline())
sn = sys.stdin.read().split()
c = Counter(sn)
c = sorted(c.items(), key=lambda x: (-x[1], x[0]))
num = c[0][1]
for i, j in c:
  if j == num:
    print(i)
  else:
    quit()