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 Counter

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):
from collections import Counter

N = int(input())
S = []
for _ in range(N):
    S.append(input())
counter = Counter(S)
sorted_S = list(sorted(set(S)))
maxcnt = max(counter.values())
for Si in sorted_S:
    if counter[Si] == maxcnt:
        print(Si)

Solution (Python):
import collections

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

v_coll = collections.Counter(votes).most_common()

most = v_coll[0][1]
mosts = []

for v, i in v_coll:
    if i == most:
        mosts.append(v)
    else:
        break

mosts.sort()

[print(m) for m in mosts]

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

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

if len(sorted_Dic)==1:
  print(sorted_Dic[0][0])
else:
  ans_list = []
  for i in range(N):
      if sorted_Dic[i][1]==sorted_Dic[0][1]:
          ans_list.append(sorted_Dic[i][0])
      else:
          break;
  for item in sorted(ans_list):
    print(item)

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 k, v in sorted(D.items()):
  if v==m:
    print(k)

Solution (Python):
n=int(input(""))
a={}
for i in range(n):
    s=input("")
    if (s in a):
        a[s]+=1
    else:
        a[s]=1
maxs=0
lists=[]
for i in a:
    t=a[i]
    if(t>maxs):
        lists=[i]
        maxs=t
    elif(t==maxs):
        lists+=[i]
lists.sort()
for i in lists:
    print(i)

Solution (Python):
from collections import defaultdict

dic = defaultdict(int)

N = int(input())
for _ in range(N):
  dic[input()] += 1
  
mmax = max(dic.values())
for k, v in sorted(dic.items(), key=lambda x:x[0]):
  if v == mmax:
    print(k)
  else:
    continue

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

mx = max(d.values())
for s in sorted(k for k in d if d[k] == mx) :
    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

mx = max(d.values())
for s in sorted(k for k in d if d[k] == mx) :
    print(s)

Solution (Python):
N = int(input())
dic = {}
for _ in range(N):
    s = input()
    dic.setdefault(s, 0)
    dic[s] += 1
ans = list(dic.items())
ans.sort(key=lambda x: (-x[1], x[0]))
m = ans[0][1]
print("\n".join(i[0] for i in ans if i[1] == m))

Solution (Python):
from collections import Counter
import sys
n=int(sys.stdin.readline().rstrip())
S=[sys.stdin.readline().rstrip() for _ in range(n)]
    
cnt=Counter(S)
ma = max(cnt.values())
list=[]
for k in cnt.keys():
    if cnt[k] == ma:
      list.append(k)

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

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

a = {}
ans = []

for i in s:
	if i in a:
		a[i] 	+= 1
	else:
		a[i] = 1

leargest = max(a.values())
for k in a.keys():
	if a[k] == leargest:
 		ans.append(k)

[print(i) for i in ans]

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

Solution (Python):


import collections

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

S = collections.Counter(s)
M = S.most_common()[0][1]
S = sorted(S.most_common())

for i in range(len(S)):
    if S[i][1] == M:
        print(S[i][0])

Solution (Python):
box={}
n=int(input())
for i in range(n):
    v=input()
    if v in box:
        box[v]+=1
    else:
        box[v]=1
m=max(box.values())
f=[k for k,v in box.items() if v==m]
f.sort()
print('\n'.join(f))

Solution (Python):
import sys
import itertools

import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines



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

mx = 0
for k, v in count.items():
    if v > mx:
        mx = v

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


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

Solution (Python):
import numpy as np
N = int(input())
S = np.array([input() for _ in range(N)], dtype=str)
keys, values = np.unique(S, return_counts=True)
cnt = []
for k, v in zip(keys, values):
    cnt.append([k, v])
cnt.sort(reverse=True, key=lambda x: x[1])
a = cnt[0][1]
ans = []
for k, v in cnt:
    if v < a:
        break
    ans.append(k)
ans.sort()
for a in ans:
    print(a)

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

poll = []
count = []
pre_poll = ''
for i in range(n):
    if pre_poll == s[i]:
        count[-1] += 1
    else:
        poll.append(s[i])
        count.append(1)
        pre_poll = s[i]
        
poll_dict = dict(zip(poll, count))
poll_dict = dict(sorted(poll_dict.items(), key=lambda x:x[1], reverse=True))

val = next(iter(poll_dict.values()))
for t in poll_dict.items():
    if val == t[1]:
        print(t[0])
    else:
        break

Solution (Python):
n = int(input())
d = { }
for _ in range(n):
  s = input()
  if s not in d:
    d[s] = 0
  d[s] += 1

  
max_cnt = max(d.values())

max_keys = [s for s, i in d.items() if i == max_cnt]

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

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

m = max(S.values())
for i in sorted(S.items()):
    
    
    if i[1] == m:
        print(i[0])

Solution (Python):
from collections import Counter
a = []
for i in range(int(input())):
    a.append(input())
a = Counter(a)
m = a.most_common()[0][1]
for i, j in sorted(a.most_common()):
    if j ==m: print(i)

Solution (Python):
import collections
n=int(input())
s=[]
for i in range(n):
  s.append(input())
s_cnt=collections.Counter(s)
m=max(s_cnt.values())
ans=[]
cnt=0
for i,v in s_cnt.items():
  if v==m:
    ans.append(i)
    cnt+=1
ans.sort()
for i in range(cnt):
  print(ans[i])

Solution (Python):
from collections import Counter
 
_, *s = open(0).read().split()
 
c = Counter(s).most_common()
 
a = []
 
p = 0
for i, j in c:
    if p > j:
        break
    p = j
    a.append(i)
print(*sorted(a), sep="\n")

Solution (Python):
from collections import Counter

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

common = S.most_common()
keys = []
for i, pair in enumerate(common):
  key, val = pair
  if i == 0:
    MAX = val
  else:
    if val < MAX:break
  keys.append(key)
keys = sorted(keys)
for i in range(len(keys)):
  print(keys[i])

Solution (Python):
import collections
n=int(input())
s=[]
for i in range(n):
  s.append(input())
dict=collections.Counter(s)
dict_sorted=sorted(dict.items())
maximum=max(dict.values())
for key,value in dict_sorted:
  if value==maximum:
    print(key)

Solution (Python):
n=int(input())
dict={}
cnt=1
for i in range(n):
  s=input()
  if s in dict:
    dict[s]+=1
    cnt=max(cnt,dict[s])
  else:
    dict[s]=1
dict_sorted=sorted(dict.items())
for j in range(len(dict_sorted)):
  if dict_sorted[j][1]==cnt:
    print(dict_sorted[j][0])

Solution (Python):
def main():

    N = int(input())
    d = dict()
    cnt = 0
    for _ in range(N):
        s = input()
        d[s] = d.get(s, 0) + 1
        cnt = max(cnt, d[s])
    ans = []
    for s in d:
        if d[s] == cnt: ans.append(s)
    ans = sorted(ans)
    for s in ans:
        print(s)

    

if __name__ == '__main__':
    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
x = 0
for i in d.keys():
    x = max(x,d[i])
d = sorted(d.items())
for i in d:
    if i[1] == x:
        print(i[0])

Solution (Python):
from collections import Counter
N = int(input())
C = Counter()
for i in range(N):
    C[input()] += 1
n = C.most_common(1)[0][1]
c = [k for k, v in C.items() if v == n]
c.sort()
for _c in c:
    print(_c)

Solution (Python):
import sys



from collections import deque





from collections import Counter


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    A = []
    for i in range(N):
        S = input()
        A.append(S)
    c = Counter(A)
    maxc = max(c, key=c.get)
    maxc = max(c.values())
    aa = []
    for key, val in c.items():
        if val ==maxc:
            aa.append(key)
    aa.sort()
    print("\n".join(aa))

if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
s = list(input() for _ in range(n))
s.sort()
now = s[0]
ans = [s[0],]
cnt = 0
m_cnt = 0

for i in range(n):
    word = s[i]
    if word == now:
        cnt +=1
        if cnt > m_cnt:
            ans = [word,]
            m_cnt = cnt
        elif cnt == m_cnt:
            ans.append(word)
    else:
        cnt = 1
        now = word
        if cnt > m_cnt:
            ans = [word,]
            m_cnt = cnt
        elif cnt == m_cnt:
            ans.append(word)

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

Solution (Python):
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n = i()


a = {}
for i in range(n):
	s = input()
	try:
		a[s] += 1
	except KeyError:
		a[s] = 1
b = sorted(a.items(),key = lambda x:x[0])

memo = max([i[1] for i in a.items()])
for i in b:
	"""print(i,"i")
	print(i[0],"i[0]")
	print(i[1],"i[1]")
	print(max(b)[0],"max(b)[0]")"""
	if i[1] == memo:
		print(i[0])

Solution (Python):
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n = i()


a = {}
for i in range(n):
	s = input()
	try:
		a[s] += 1
	except KeyError:
		a[s] = 1
b = sorted(a.items(),key = lambda x:x[0])

memo = max([i[1] for i in a.items()])
for i in b:
	"""print(i,"i")
	print(i[0],"i[0]")
	print(i[1],"i[1]")
	print(max(b)[0],"max(b)[0]")"""
	if i[1] == memo:
		print(i[0])

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

vote = dict()
maxv = 0
for i in range(n):
  s = input()
  if not s in vote:
    vote[s] = 1
  else:
    vote[s] += 1
  maxv = max(maxv, vote[s])

candidates = list()

for k, v in vote.items():
  if int(v) == maxv:
    candidates.append(k)

candidates.sort()

for candidate in candidates:
  print(candidate)

Solution (Python):
from sys import stdin

n = int(stdin.readline().strip())
count_dict = {}

for _ in range(n):
  s = stdin.readline().strip()
  count_dict[s] = count_dict.get(s, 0) + 1

max_count = max(count_dict.values())
freq_s_lst = [k for k, v in count_dict.items() if v == max_count]

print('\n'.join(sorted(freq_s_lst)))

Solution (Python):
import collections
N = int(input())
S= [ input() for _ in range(N)]
Sc = collections.Counter(S)
mv = max(Sc.values())
km = []
for key,val in Sc.items():
    if val == mv:
        km.append(key)
kms = sorted(km)
for k in kms:
    print(k)

Solution (Python):
if __name__ == '__main__':

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

	mval = max(d.values())
	A = [kv[0] for kv in d.items() if kv[1] == mval]

	B = sorted(A)
	for b in B:
		print(b)

Solution (Python):
from collections import Counter

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

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

Solution (Python):
from collections import Counter
n = int(input())
list_S = []
ans = []
for _ in range(n):
    list_S.append(str(input()))

list_S = Counter(list_S)
list_S = list(list_S.items())
list_S.sort(key=lambda x:x[1], reverse=True)

for l in list_S:
    if list_S[0][1] == l[1]:
        ans.append(l[0])
ans.sort()
for s in ans:
    print(s)

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

N = int(input())
dic = {}
for i in range(N):
    S = input().rstrip('\n')
    if S in dic:
        dic[S] += 1
    else:
        dic[S] = 1


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


nn = D[0][1]

for k, v in D:
    if v == nn:
        print(k)
    else:
        break

Solution (Python):
k=int(input())
d=dict()
for i in range(k):
    x=input()
    d[x]=d.get(x,0)+1
q=list()
for k,v in d.items():
    q.append( (v,k) )
bigV=0
for (v,k) in sorted(q,reverse=True):
    if(v>bigV):
        bigV=v
for (v,k) in sorted(q):
    if(v==bigV):
        print(k)

Solution (Python):
k=int(input())
d=dict()
for i in range(k):
    x=input()
    d[x]=d.get(x,0)+1
q=list()
for k,v in d.items():
    q.append( (v,k) )
bigV=0
for (v,k) in sorted(q,reverse=True):
    if(v>bigV):
        bigV=v
for (v,k) in sorted(q):
    if(v==bigV):
        print(k)

Solution (Python):

import sys
from collections import deque, defaultdict
from math import sqrt, factorial





def solve():
    n = int(input())
    d = defaultdict(int)
    mx = 0
    for _ in range(n):
        s = input()
        d[s] += 1
        mx = max(mx, d[s])
    a = []
    for k in d:
        if d[k] == mx:
            a.append(k)
    a.sort()
    for e in a:
        print(e)
    



t = 1

for case in range(1,t+1):
    ans = solve()




"""

"""

Solution (Python):
def resolve():
    n = int(input())
    d = {}
    for _ in range(n):
        s = input()
        if s not in d:
            d[s] = 1
        else:
            d[s] += 1
    d = sorted(d.items(), key=lambda x:x[1], reverse=True)
    ans = []
    before = d[0][1]
    for t in d:
        if t[1] != before:
            break
        else:
            ans.append(t[0])
    ans = list(sorted(ans))
    print(*ans, sep="\n")
resolve()

Solution (Python):
def resolve():
    n = int(input())
    d = {}
    for _ in range(n):
        s = input()
        if s not in d:
            d[s] = 1
        else:
            d[s] += 1
    d = sorted(d.items(), key=lambda x:x[1], reverse=True)
    ans = []
    before = d[0][1]
    for t in d:
        if t[1] != before:
            break
        else:
            ans.append(t[0])
    ans = list(sorted(ans))
    for a in ans:
        print(a)
resolve()

Solution (Python):
import collections
N = int(input())
S = [str(input()) for i in range(N)]
c = collections.Counter(S)
l = c.most_common()
dict = [l[0][0]]
if l[0][1] == N:
    print(*dict)
    exit()
for i in range(N - 1):
    if l[i][1] == l[i + 1][1]:
        dict.append(l[i + 1][0])
        continue
    break
a = sorted(dict)
for x in a:
    print(x)

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

n, d = int(input()), defaultdict(int)
for i in range(n): d[input()[:-1]] += 1
m = max(d.values())
print('\n'.join(sorted([k for k, v in d.items() if v == m])))

Solution (Python):
import sys
import time
import math
st = time.perf_counter()
def inpl():
    return list(map(int, input().split()))



N = int(input())
S = [input() for _ in range(N)]
d = dict()
mx = 0
for s in S:
	if s not in d:
		d[s] = 0
	d[s] += 1
	mx = max(d[s], mx)
ans = []
for k,v in d.items():
	if v == mx:
		ans.append(k)
ans.sort()
for a in ans:
	print(a)


ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)

Solution (Python):

import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n =INT()

dd = defaultdict(int)

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

mx = max(dd.values())
zz=  []
for k in dd:
    if(dd[k]==mx):
        zz.append(k)
zz.sort()

for _ in range(len(zz)):
    print(zz[_])

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

S = [input() for _ in range(N)]
SC = Counter(S)
Ans = []
num = -1
for ans, value in SC.most_common():
    if num == -1:
        num = value
        Ans.append(ans)
    else:
        if num != value:
            break
        else:
            Ans.append(ans)
Ans.sort()

for a in Ans:
    print(a)

Solution (Python):

from collections import Counter

def solve(l):
    d = Counter(l)
    d_max = max(d.values())
    max_d_list = sorted([k[0] for k in d.items() if k[1] == d_max])
    return max_d_list



def main():
    N = int(input())
    l = [input() for _ in range(N)]
    d = solve(l)
    for a in d:
        print(a)
    return

if __name__ == '__main__':
    main()

Solution (Python):
import sys
from collections import Counter

sys.setrecursionlimit(10**7)
input = sys.stdin.readline

n = int(input())
cnt = Counter(input() for _ in range(n))
macnt = max(cnt.values())
names = [k for k, v in cnt.items() if v == macnt]
names.sort()
print(*names, sep='\n')

Solution (Python):
import sys
from collections import defaultdict

sys.setrecursionlimit(10**7)
input = sys.stdin.readline

n = int(input())

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

ma = 0
for v in d.values():
    ma = max(ma, v)

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

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

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

cnt_max = max(dic.values()) 
ans = []
for j in dic.keys():
	if dic[j] == cnt_max:
		ans.append(j)

ans.sort()

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

Solution (Python):
from collections import Counter

N = int(input())
counter = Counter([input() for _ in range(N)])
max_cnt = max(counter.values())
names = [name for name, cnt in counter.items() if cnt == max_cnt]
names.sort()

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

Solution (Python):
from collections import defaultdict

N = int(input())
s_counter = defaultdict(int)
for _ in range(N):
    S = input()
    s_counter[S] += 1
S_list = sorted(s_counter.items(), key=lambda x: x[1], reverse=True)
answer = []
for i in range(len(S_list)):
    if S_list[0][1] != S_list[i][1]:
        break
    answer.append(S_list[i][0])
answer.sort()
[print(a) for a in answer]

Solution (Python):
n = int(input())
s = [""]+ [input() for _ in range(n)]
sl  = sorted(s)
count = 1
tl = []
for i in range(1,n+1):
    if sl[i-1] == sl[i]:
        count += 1
        tl.append(count)
    else:
        count = 1
        tl.append(count)

a_c = max(tl)
count = 0
for t in tl:
    if t == a_c:
        print(sl[count+1])
        count += 1
    else:
        count += 1

Solution (Python):
'''

                            Online Python Compiler.
                Code, Compile, Run and Debug python program online.
Write your code in this editor and press "Run" button to execute it.

'''
from sys import stdin
def read():
    return stdin.readline().strip()

dict={}
output=[]

iteration=int(read())

max_val=-1

for _ in range(iteration):
    item=read()
    
    if dict.get(item) is None:
        dict[item]=0 
    dict[item]+=1 
    max_val = max(dict[item],max_val)

for k,v in dict.items():
    
    if(max_val==v):
        output.append(k)
    
    
output.sort()
print('\n'.join(output))

Solution (Python):

from sys import stdin
def read():
    return stdin.readline().strip()

dict={}
output=[]

iteration=int(read())

max_val=-1

for _ in range(iteration):
    item=read()
    
    if dict.get(item) is None:
        dict[item]=0 
    dict[item]+=1 
    max_val = max(dict[item],max_val)

for k,v in dict.items():
    
    if(max_val==v):
        output.append(k)
    
    
output.sort()
print('\n'.join(output))

Solution (Python):
import numpy as np

N = int(input())

l = []

for _ in range(N):
    l.append(input())

result, counts = np.unique(np.array(l), return_counts=True)
result = result[counts == max(counts)]

for x in np.sort(result):
    print(x)

Solution (Python):
N = int(input())
votedict = {}
Max = -1
for _ in range(N):
    S = input()
    if S in votedict:
        votedict[S] += 1
        Max = max(votedict[S],Max)
    else:
        votedict[S] = 1

if Max == -1:
    Max = 1

maxvote = []

for k,v in votedict.items():
    if v == Max:
        maxvote.append(k)

maxvote.sort()

for i in maxvote:
    print(i)

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

    S_dict = {}
    for s in S_list:
        S_dict[s]=0
    for s in S_list:
        S_dict[s]+=1

    max_v = max(S_dict.values())

    max_k_list = [kv[0] for kv in S_dict.items() if kv[1] == max_v]
    max_k_list.sort()
    for k in max_k_list:
        print(k)

if __name__ == '__main__':
     main()

Solution (Python):
import sys
from collections import Counter

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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

    c = Counter(S)
    max_freq = max(c.values())
    ans = [s for s, v in c.items() if v == max_freq]
    ans.sort()

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

    return


if __name__ == '__main__':
    main()

Solution (Python):

from collections import Counter

_, *s = open(0).read().split()

c = Counter(s).most_common()

a = []

p = 0
for i, j in c:
    if p > j:
        break
    p = j
    a.append(i)
print(*sorted(a), sep="\n")

Solution (Python):


import sys
from bisect import bisect, bisect_left
input=sys.stdin.readline

def main():
    N=int(input())
    S=[input().strip("\n") for i in range(N)]
    S.sort()
    Ss=set(S)
    ooi=[]
    maxc=0
    for s in Ss:
        c=bisect(S,s)-bisect_left(S,s)
        if maxc<c:
            ooi=[s]
            maxc=c
        elif maxc==c:
            ooi.append(s)
    print("\n".join(sorted(ooi)))
        
        
    
    
if __name__=="__main__":
    main()

Solution (Python):



from collections import Counter

n = int(input())
s = [input() for i in range(n)]
c = Counter(s)
c_max = max(c.values())
ans = [j[0] for j in c.items() if j[1] == c_max]
ans = sorted(ans)
for f in ans:
    print(f)

Solution (Python):
from collections import Counter

N=int(input())
S=[input() for i in range(N)]
s=Counter(S)
max_val=max(s.values())
ans=[k for k,v in s.items() if v==max_val]
ans.sort()
for x in ans:
  print(x)

Solution (Python):
import collections
import sys

N=int(input())
S = []
for i in range(N):
  S.append(input())
S.sort()
c = collections.Counter(S)
ans = c.most_common()

if len(ans)==1:
  print(ans[0][0])
  sys.exit(0)
  
print(ans[0][0],sep=" ")
for i in range(N-1):
  if ans[i][1]==ans[i+1][1]:
    print(ans[i+1][0],sep=" ")
  else:
    sys.exit(0)

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

max_ = max(dict.values())
A = [k for k,v in dict.items() if v == max_]
A.sort()

for a in A:
    print(a)

Solution (Python):
from collections import Counter
n=int(input())
S=[]
for i in range(n):
    S.append(input())
T=Counter(S)
S=list(set(S))
M=max(T.values())
U=[]
j=0
for i in S:
    if T[i]==M:
        U.append(S[j])
    j+=1
U.sort()
for i in U:
    print(i)

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

n = max(x.values())
for xi in x.keys():
  if x[xi] == n:
    print(xi)

Solution (Python):
from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
S = Counter(S)
Smax = max(S.values())
ans = []
for k, v in S.items():
    if Smax == v:
        ans.append(k)

ans = sorted(ans)

for i in ans:
    print(i)

Solution (Python):

import math
import collections

def main():
  N = int(input())
  S = list()
  S = [input() for _ in range(N)]
  
  s = collections.Counter(S)
  
  MaxCount = max(s.values())
  
  ans = []
  
  for key, value in s.items():
    if value == MaxCount:
      ans.append(key)
                 
  ans.sort()
  
  for i in ans:
    print(i)
  
  
  
  
main()

Solution (Python):
import collections

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

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

s = collections.Counter(S)

count_max = max(s.values())

ans =[]
for key,value in s.items():
    if value == count_max:
        ans.append(key)
        
ans.sort()

for i in ans:
    print(i)

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

word_count = {}
for _ in range(N):
    s = input()
    if s in word_count:
        word_count[s] += 1
    else:
        word_count[s] = 1

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

words = []
count = ""
for val in word_count_sorted:
    if not count:
        count = val[1]
    if count == val[1]:
        words.append(val[0])

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

Solution (Python):
from collections import Counter

N = int(input())
count = Counter([input() for _ in range(N)])
ans = []

count_max = max(count.values())

for key, value in count.items():
  if value == count_max:
    ans.append(key)
    
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 
maxD = max(D.values())
poll = [k for k,v in D.items() if v == maxD]
poll.sort()
for j in range(len(poll)):
    print(poll[j])

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 
maxD = max(D.values())
poll = [k for k,v in D.items() if v == maxD]
print('\n'.join(sorted(poll)))

Solution (Python):
import collections

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

s_count = collections.Counter(s)
largest = max(list(s_count.values()))
ans = []

for key in list(s_count.keys()):
    if s_count.get(key) == largest:
        ans.append(key)

ans.sort()

for word in ans:
    print(word)

Solution (Python):
n=int(input())
s=[input() for _ in range(n)]
from collections import Counter
c=Counter(s)
l=c.most_common()
a=[l[0][0]]
for i in range(1,len(l)):
  if l[i][1]==l[0][1]:
    a.append(l[i][0])
  else:
    break
a.sort()
for j in range(len(a)):
  print(a[j])

Solution (Python):
import collections


n = int(input())
s = [input() for i in range(n)]
cnt = collections.Counter(s)
largest= max(list(cnt.values()))
l = []

for k in cnt.keys():
  if cnt[k] == largest:
    l.append(k)

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

Solution (Python):
import sys 
from collections import Counter
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
l = read().decode().split()
c = Counter(l)
max = c.most_common()[0][1]
ans = [i[0] for i in c.items() if i[1] >= max]
print('\n'.join(sorted(ans)))

Solution (Python):
import itertools
import functools
import math
from collections import Counter
from itertools import combinations
import re


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


C = Counter(S)
D = list(set(S))
D.sort()


max = 0
for i in range(len(D)):
    chk = C[D[i]]
    if max < chk:
        max = chk

for i in range(len(D)):
    chk = C[D[i]]
    if max == chk:
        print(D[i])

Solution (Python):
N = int(input())
word_count = {}
for i in range(N):
  word = input()
  if word in word_count.keys():
    word_count[word] += 1
  else: 
    word_count[word] = 1
sorted_word_count = sorted(word_count.items(), key=lambda x:x[1], reverse=True)
answer = []
first = True
max_count = 0
for word in sorted_word_count:
  if (first):
    answer.append(word[0])
    max_count = word[1]
    first = False
  else:
    if (max_count == word[1]):
      answer.append(word[0])
    else:
      break
sorted_answer = sorted(answer)
for a in sorted_answer:
  print(a)

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

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

N = int(input())
Sss = [input().rstrip() for _ in range(N)]

cnt = Counter(Sss)

num = max(cnt.values())

anss = []
for key in sorted(cnt.keys()):
    if cnt[key] == num:
        anss.append(key)

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

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

dic = {}
for _ in range(n):

    s =input()
    if s in dic:
        dic[s] += 1
    else:
        dic[s]=1

maxdic = max(dic.values())

ans = [i for i in dic if dic[i]==maxdic]
print('\n'.join(sorted(ans)))

Solution (Python):
from collections import defaultdict

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

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

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

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

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

K=[a for a in D if D[a]==M]
K.sort()
for a in K:
    print(a)