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())
sub = dict()
ans = 0
for i in range(n):
  key = input()
  if key in sub:
    sub[key] = sub[key] + 1
    if ans < sub[key]:
      ans = sub[key]
  else:
    sub[key] = 1
    if ans < sub[key]:
      ans = sub[key]
      
sub = sorted(sub.items())

for i in range(len(sub)):
  if sub[i][1] == ans:
    print(sub[i][0])

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 6)
MOD = 10**9+7
 

def main():
    n = int(input())
    d = dict()
    for _ in range(n):
        s = input()
        d.setdefault(s, 0)
        d[s] += 1
    d = sorted(d.items(), key=lambda x: (-x[1], x[0]))
    maxc = d[0][1]
    for row in d:
        if row[1]<maxc:
            exit()
        print(row[0])
 
if __name__ == "__main__":
    main()

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

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

result = sorted(result.items(), key = lambda x:x[1])[::-1]
output, i, highest = [result[0][0]], 1, result[0][1]

if len(result) != 1:
    while result[i][1] == highest:
        output.append(result[i][0])
        i += 1
        if i == N:
            break

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

Solution (Python):
N = int(input())
S = [0]*N

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

S = sorted(S)
S.append(-1)



counta = []

times = 1
for i in range(1, N+1):
    if S[i-1] == S[i]:
        times += 1
    else:
        counta.append((times, i-1))
        times = 1



M = max(counta, key=lambda x: x[0])[0]



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

Solution (Python):
N = int(input())
d = {}
for _ in range(N):
  s = input()
  if not s in d:
    d[s] = 1
  else:
    d[s] += 1
x = sorted(list(d.items()), key=lambda x:x[1], reverse=True)
n = 0
l = []
for k, v in x:
  if v >= n:
    n = v
    l.append(k)
for y in sorted(l):
  print(y)

Solution (Python):

import sys
import collections
import heapq

def solve(N: int, S: "List[str]"):
    count_dict = collections.defaultdict(int)
    for s in S:
        count_dict[s] += 1
    

    largest = heapq.nlargest(1, [y for x, y in count_dict.items()])[0]
    list = []
    for k, v in count_dict.items():
        if v == largest:
            list.append(k)
    answer_list = sorted(list)
    for ans in answer_list:
        print(ans)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    S = [next(tokens) for _ in range(N)]  
    solve(N, S)

if __name__ == '__main__':
    main()

Solution (Python):


from collections import defaultdict

con = 10 ** 9 + 7

def getlist():
	return list(map(int, input().split()))


def main():
	N = int(input())
	D = defaultdict(int)
	for i in range(N):
		S = input()
		D[S] += 1

	L = []
	for i in D:
		L.append([D[i], i])
	L = sorted(L)
	X = len(L)
	c = L[-1][0]
	ans = []
	for i in range(X):
		if L[-1 - i][0] == c:
			ans.append(L[-1 - i][1])
		else:
			break

	M = len(ans)
	for i in range(M):
		print(ans[-1 - i])


if __name__ == '__main__':
	main()

Solution (Python):

n=int(input())
s=[]
for i in range(n):
    s.append(input())
s.sort()
g=[]
buf=s[0]
count=0
for i in range(n):
    if buf==s[i]:
        count+=1
    else:
        g.append((count,buf))
        buf=s[i]
        count=1
g.append((count,buf))
g.sort(reverse=True)
idx=g[0][0]
h=[]
import sys
for i,j in g:
    if i==idx:
        h.append(j)
h.sort()
for j in h:
    print(j)

Solution (Python):
N = int(input())
S = {}
for _ in range(N):
    s = input()
    if s in S.keys():
        S[s] += 1
    else:
        S[s] = 1
S = sorted(S.items(), key=lambda x:x[1])
maxi = S[-1][1]
ans = []
for s in reversed(S):
    if s[1] == maxi:
        ans.append(s[0])
ans.sort()
for a in ans:
    print(a)

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

C = collections.Counter(S)
max_c=C.most_common()[0][1]

values, counts = zip(*C.most_common())
min_i=len(counts)
for i in range(len(counts)):
    if counts[i]<max_c:
        min_i = i
        break
ans = sorted(list(values)[:min_i])

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

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

S=[]
C={}
for a in range(n):
    s=input()
    if not s in C:
        C[s]=1
    else:
        C[s]+=1
A=[]
for a,b in C.items():
    A.append([b,a])
A.sort(key=lambda x:(-x[0],x[1]))
max_=A[0][0]
for a in A:
    if(a[0]!=max_):break
    print(a[1])

Solution (Python):
import sys
from collections import defaultdict

n = int(input())
l = [input() for _ in range(n)]
d = defaultdict(int)
for i in range(len(l)):
    d[l[i]] += 1
d = sorted(d.items(), key=lambda x:-x[1])
ans = []
num = d[0][1]
for i in range(len(d)):
    if d[i][1] != num:
        break
    ans.append(d[i][0])
ans.sort()
for i in range(len(ans)):
    print(ans[i])

Solution (Python):
n = int(input())
s = {}
max = 1

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

result = []
for k, v in s.items():
    if v == max:
        result.append(k)
result.sort()
for v in result:
    print(v)

Solution (Python):
from collections import Counter

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

c = Counter(S)

target = c.most_common()[0][1]

ans_list = []

for item in c.most_common():
    if target == item[1]:
        ans_list.append(item[0])
    else:
        break

ans_list.sort()

for s in ans_list:
    print(s)

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

for c in range(n):
    s = input()
    if s not in s_count:
        s_count[s] = 0
    s_count[s] += 1



max_count = 0

for word, count in s_count.items():
    max_count = max(count, max_count)


res = []
for word, count in s_count.items():
    if count == max_count:
        res.append(word)

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

Solution (Python):
n=int(input())
l=[input() for i in range(n)]
from collections import Counter as co
k=co(l).most_common()
d=k[0][1]
print(*sorted([a for a,s in k if s==d]),sep="\n")

Solution (Python):
from collections import Counter

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

C = Counter(S)

max_v = max(v for k, v in C.items())

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

ans.sort()

for a in ans:
  print(a)

Solution (Python):
if __name__ == '__main__':
    n = int(input())
    voted = {}
    for i in range(n):
        s = input()
        if s in voted:
            voted[s] += 1
        else:
            voted[s] = 1

    

    max_count = 0
    max_list = []
    for k, v in voted.items():
        if max_count == v:
            max_list.append(k)
        elif max_count < v:
            max_list = [k]
            max_count = v

    

    for j in sorted(max_list):
        print(j)

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

for i in range(n):
    ss = input()

    if ss in s:
        s[ss] += 1
    else:
        s[ss] = 1

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

s2.reverse()

max_value = s2[0][1]
ret = []

for sss in s2:
    if sss[1] == max_value:
        ret.append(sss[0])
    else:
        break

ret2 = sorted(ret)
for r in ret2:
    print(r)

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

B = [(a, A[a]) for a in A]

B.sort(reverse=True, key=lambda x: x[1])

count = B[0][1]
ans = []
for b in B:
    if b[1] == count:
        ans.append(b[0])

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

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

from collections import Counter
c = Counter()

for si in S:
    c[si] += 1

a = []

for k, v in c.items():
    a.append([v, k])

from operator import itemgetter
a.sort(key=itemgetter(1))
a.sort(key=itemgetter(0), reverse=True)


for ai in a:
    if ai[0] == a[0][0]:
        print(ai[1])

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

mm = sorted(dd, key=lambda s: -dd[s])

ll = [mm[0]]
i = 1
while i < len(mm) and dd[mm[0]] == dd[mm[i]]:
    ll.append(mm[i])
    i += 1
ll.sort()
for l in ll:
    print(l)

Solution (Python):
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy




def main():
    N = int(input())
    nums = defaultdict(int)
    for _ in range(N):
        s = input()
        nums[s] += 1
    mmax = max(nums.values())
    nums = dict(nums)
    keys = sorted(nums.keys())
    for s in keys:
        if mmax == nums[s]:
            print(s)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
def input():
    return sys.stdin.readline()[:-1]
N=int(input())
S=[input() for i in range(N)]
S.sort()
M=[]
c=1
m=0
s=S[0]
for i in range(1,N):
    if S[i]==s:
        c+=1
    else:
        if c>m:
            M=[s]
            m=c
        elif c==m:
            M.append(s)
        c=1
        s=S[i]
if c>m:
    M=[s]
elif c==m:
    M.append(s)
print(*M,sep="\n")

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

d_sorted = sorted(d.items(), key=lambda x: x[1], reverse=True)
maxNum = d_sorted[0][1]
ans = [] 
for i in d_sorted:
    if i[1] == maxNum:
        ans.append(i[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 not in dic:
        dic[s] = 1
    else:
        dic[s] += 1

dictlist = []
for key, value in dic.items():
    temp = [key,value]
    dictlist.append(temp)
dictlist.sort(key=lambda x:(-x[1], x[0]))

top = dictlist[0][1]
for i in range(len(dictlist)):
    if dictlist[i][1] == top:
        print(dictlist[i][0])

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

dic = {}
for s in S:
    dic.setdefault(s, 0)
    dic[s] += 1

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

for w in dic_sorted:
    if w[1] == max_cnt:
        print(w[0])
    else:
        break

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

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

c = Counter(l)
maxcnt = c.most_common()[0][1]

l1 = []
for e,n in c.most_common():
    if n == maxcnt:
        l1.append(e)
l1.sort()
for w in l1:
    print(w)

Solution (Python):
n=int(input())
l=[input() for _ in range(n)]
from collections import Counter as co
d=co(l)
k=max(d.values())
x=[]
for i,j in d.items():
  if j==k:
    x.append(i)
x.sort()
for i in x:
  print(i)

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

A=[]
for v,m in S.items():
    A.append((m,v))

A=sorted(A)[::-1]
num=A[0][0]

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

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

Solution (Python):
import collections

n = int(input())

ss = []
for _ in range(n):
	ss.append(input())

c = collections.Counter(ss)

mc = c.most_common()
max_cnt = max([x[1] for x in mc])
ans = [x[0] for x in mc if x[1] == max_cnt]

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

Solution (Python):
from collections import defaultdict, Counter, namedtuple, deque
from bisect import bisect_left
from functools import reduce
import math

NN = 2020202
MOD = 10**9+7
INF = float("inf")

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

count = Counter(A)
count2 = [(c, s) for s, c in count.items()]
count2.sort(key=lambda x: (-x[0], x[1]))


for elem in count2:
    if elem[0] == count2[0][0]:
        print(elem[1])
    else:
        break

Solution (Python):
n = int(input())
w_dict = {}
max_c = 1
for i in range(n):
  w = input()
  if w in w_dict.keys():
    count = w_dict[w] + 1
    w_dict[w] = count
    if count > max_c:
      max_c = count
  else:
    w_dict[w] = 1

print_list = []
for k,v in w_dict.items():
  if v == max_c:
    print_list.append(k)
    
for p in sorted(print_list):
  print(p)

Solution (Python):
import sys
from collections import defaultdict
from collections import deque
sys.setrecursionlimit(10 ** 7)

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

cnt = defaultdict(int)

for s in SS:
    cnt[s] += 1

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

ans = deque([])
mx = -1
for i, x in cnt:
    if mx == -1:
        mx = x
    elif mx != x:
        break
    ans.appendleft(i)

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

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
S = [input() for i in range(N)]
S.sort()
c = Counter(S)
m = 0
for word,num in c.items():
    m = max(m, num)
W = []
for word, num in c.items():
    if num == m:
        W.append(word)
W.sort()
print(*W, sep="\n")

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

max = 0
maxs = []
for i in dic.keys():
    if dic[i] > max:
        max = dic[i]
        maxs = [i]
    elif dic[i] == max:
        maxs.append(i)
maxs.sort()
for i in maxs:
    print(i)

Solution (Python):
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30
from collections import Counter

def main():
    n = int(input().strip())
    v = []
    for i in range(n):
        v.append(input().strip())
    v2 = dict(Counter(v))
    q = []
    for k, w in v2.items():
        q.append([k, w])
    q = sorted(q, key=itemgetter(1), reverse=True)
    
    ans = []
    ans.append(q[0][0])
    prev = q[0][1]
    for t in q[1:]:
        if t[1] == prev:
            ans.append(t[0])
    ans = sorted(ans)
    for a in ans:
        print(a)

if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter

N = int(input())
S = Counter()
for _ in range(N):
    S[input()] += 1


maxCnt = 0
for key in list(S.keys()):
    cnt = S[key]
    if cnt > maxCnt:
        ans = [key]
        maxCnt = cnt
    elif cnt == maxCnt:
        ans.append(key)

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

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

num_max = 0
words = []
for k in dic.keys():
    num = dic[k]
    if num_max == num:
        words.append(k)
    elif num_max < num:
        words = [k]
        num_max = num
    

words = sorted(words)
for w in words:
    print(w)

Solution (Python):
from collections import Counter
N = int(input())
counter = Counter()
for i in range(N):
    s = input()
    counter[s] += 1
most_common = counter.most_common(1)
most_count = most_common[0][1]
for k, v in sorted(counter.items(), key=lambda x: x[0]):
    if v == most_count:
        print(k)

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

P = sorted(P.items(), key=lambda x: [-x[1], x[0]])
max_n = P[0][1]
for p in P:
    if p[1] == max_n:
        print(p[0])

Solution (Python):
from collections import Counter

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

c = Counter(S)
P = c.most_common()[0][1]

o = []
for k,v in c.most_common():
    if v != P:
        break
    o.append(k)

print(*sorted(o),sep="\n")

Solution (Python):
n=int(input())
vote={}
for i in range(n):
    si=input()
    vi=vote.get(si, 0)
    vote[si]=vi+1

max_v=max(vote.values())

ans=[]
for k,v in vote.items():
    if(v==max_v):
        ans.append(k)
ans.sort()
for i in range(len(ans)):
    print(ans[i])

Solution (Python):
import sys
from collections import Counter

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
S = [sr() for _ in range(N)]
c = Counter(S)
l = c.most_common()
max = l[0][1]
answer = []
for k, v in l:
    if v == max:
        answer.append(k)

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

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

answer = []
for k in h.keys():
    if h[k] == max_num:
        answer.append(k)

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

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

dict = {}
for s in S:
    dict[s] = dict.get(s, 0)+1
max_val = max(dict.values())
keys_of_max_val = [key for key in dict if dict[key] == max_val]
keys_of_max_val.sort()
for k in keys_of_max_val:
    print(k)

Solution (Python):
n = int(input())
ans = {}
li = []
for _ in range(n):
    li.append(input())

ma = 0

for i in li:
    if i in ans:
        ans[i] += 1
    else:
        ans[i] = 1
    if ma < ans[i]:
        ma = ans[i]

ans = [i for i, j in ans.items() if j==ma]
ans.sort()
for i in ans:
    print(i)

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

s_dict = dict()
s_max = 0

for i in s:
    if i not in s_dict:
        s_dict[i] = 1
        s_max = max(s_max, s_dict[i])
    else:
        s_dict[i] += 1
        s_max = max(s_max, s_dict[i])

ans = list()
for k, v in s_dict.items():
    if v == s_max:
        ans.append(k)

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

Solution (Python):
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines

from collections import defaultdict





def main():
	n=int(input())
	
	d=defaultdict(int)
	
	li=[]
	
	for i in range(n):
		s=input().rstrip().decode('utf-8')
		d[s]+=1
	for k,v in d.items():
		li.append((v,k))
	li.sort(reverse=True)
	
	cnt=li[0][0]
	
	li2=[]
	
	for v,k in li:
		if v==cnt:
			li2.append(k)
	li2.sort()
	
	for i in li2:
		print(i)
	
if __name__ == "__main__":
	main()

Solution (Python):

import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

























def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

inf = float('inf')

def main():
	N = inputInt()
	S = {}
	for i in range(N):
		inp = input()
		inp = inp[:-1]
		if inp in S:
			S[inp] += 1
		else:
			S[inp] = 1

	score_sorted = sorted(S.items(), key=lambda x:-x[1])
	ans = []
	mx = 0
	for i in score_sorted:
		str,inin = i
		if mx == 0:
			mx = inin
		if mx != inin:
			break
		ans.append(str)

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

	

if __name__ == "__main__":
	main()

Solution (Python):
import copy
n=int(input())
s=[]
for i in range(n):
    s.append(input())
t=copy.deepcopy(s)
s=list(set(s))
s.sort()
t.sort()

ans=[0]*len(s)
cnt=0
c=0
for i in range(n):
    if i==0:
        cnt+=1
        continue
    if t[i]!=t[i-1]:
        ans[c]=cnt
        cnt=1
        c+=1
    else:
        cnt+=1
if c!=len(s)-1:
    c+=1
    ans[c]=cnt
elif ans[len(s)-1]==0:
    ans[c]=cnt

ma=max(ans)
for i in range(len(s)):
    if ans[i]==ma:
        print(s[i])

Solution (Python):
import sys
import itertools
import collections
t = sys.stdin.read()
a = t.split("\n")[1:-1]
counter = collections.Counter(a)

for s in sorted([x[0]  for x in list(itertools.groupby(counter.most_common(), lambda x: x[1]).next()[1])]):
    print s

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

for s in sorted([k for k, v in S_dir.items() if v == max_count]):
    print(s)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N = II()
	d = {}
	ansl=[]
	max_c = 0
	for _ in range(N):
		s = IS()
		if not s in d:
			d[s]=1
		else:
			d[s]+=1

		if(d[s]>max_c):
				max_c=d[s]
				ansl=[]
				ansl.append(s)
		elif(d[s]==max_c):
			ansl.append(s)
	ansl.sort()
	printV(ansl)


if __name__ == '__main__':
	main()

Solution (Python):
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda x: [ns() for _ in range(x)]
nas = lambda: stdin.readline().split()

from collections import defaultdict

n = ni()
ss = nsn(n)

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

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

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

Solution (Python):
from collections import defaultdict

N = int(input())

d = defaultdict(int)

for i in range(0, N):
    s = input().strip()
    d[s] = d[s] + 1

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

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

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

count = Counter(stri)
max_val = max(count.values())
sortedcount = sorted(count.items(), key=lambda x:x[0])
for s, cnt in sortedcount:
    if cnt == max_val:
        print(s)

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

    c = Counter()
    M = 0
    for i in range(N):
        s = input()
        n = c[s] + 1
        c[s] = n
        M = max(M, n)

    for s in sorted((s for s, c in c.items() if c == M)):
        print(s)
main()

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

max_vote_count = max(polls.values())

results = []

for poll in polls:
  if polls[poll] == max_vote_count:
    results.append(poll)

results.sort()
for res in results:
  print(res)

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

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

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

mx = dic[0][1]
for i in dic:
    if i[1]==mx: print(i[0])
    else: break

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

L=list(D.items())

ANS=[]
NUM=0
for i in range(len(L)):
    if L[i][1]<NUM:
        continue
    elif L[i][1]==NUM:
        ANS.append(L[i][0])
    elif L[i][1]>NUM:
        ANS=[L[i][0]]
        NUM=L[i][1]
ANS.sort()
for i in ANS:
    print(i)

Solution (Python):

si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(str, input().split())
nl = lambda: list(map(int, input().split()))
from collections import defaultdict as dd
from operator import itemgetter
n=ni()
d=dd(int)

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

mv=0
for k,v in d.items():
    mv=max(mv,v)
ans=set()
for k,v in d.items():
    if mv==v:
        ans.add(k)
ans=list(ans)
ans.sort()
for aaa in ans:
    print(aaa)

Solution (Python):
n=int(input())
s=[]
for i in range(n):
    s.append(input())
s2=sorted(s)
now=s2[0]
ren=1
kind=[]
for i in range(1,n):
    if now!=s2[i]:
        kind.append([ren,now])
        now=s2[i]
        ren=1
    else:
        ren+=1
kind.append([ren,now])
kind2=sorted(kind,reverse=True)
max_=kind2[0][0]
ans=[]
ans.append(kind2[0][1])
for i in range(1,len(kind2)):
    if max_==kind2[i][0]:
        ans.append(kind2[i][1])
    else:
        break

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

Solution (Python):
from collections import defaultdict


def resolve():
    n = int(input())
    d = defaultdict(int)
    for _ in range(n):
        d[input()] += 1
    m = max(d.values())
    l = sorted(x[0] for x in d.items() if x[1] == m)
    for i in l:
        print(i)


if __name__ == '__main__':
    resolve()

Solution (Python):
from collections import Counter

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

counter = Counter(S)
counts = counter.most_common()
maxcnt = counts[0][1]
ans = []
for count in counts:
    if count[1] != maxcnt:
        break
    else:
        ans.append(count[0])
ans.sort()
for a in ans:
    print(a)

Solution (Python):
from collections import defaultdict

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

cnt = defaultdict(int)
for s in S:
    cnt[s] += 1

cnt = list(cnt.items())
cnt.sort(key = lambda x: x[0])
cnt.sort(key = lambda x: -x[1])

tmp = cnt[0][1]
for c in cnt:
    if tmp == c[1]:
        print(c[0])

Solution (Python):
from collections import Counter

N = int(input())
S = [0]*N
ht = Counter()
for i in range(N):
    S[i] = input()
    ht[S[i]] += 1
l = []
bc = -1
for kw, count in ht.most_common():
    if (bc != -1)and(bc != count):
        break
    l.append(kw)
    bc = count

l.sort()

for i in l:
    print(i)

Solution (Python):
from math import factorial
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


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


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


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


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


def MS(): return map(str, input().split())


YN = {False: 'No', True: 'Yes'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']



show_flg = True


def main():
    N = I()
    s = [None] * N
    m = {}

    for i in range(N):
        s[i] = S()
        m[s[i]] = 0

    for i in range(N):
        m[s[i]] += 1

    arr = []
    for (key, v) in m.items():
        arr.append((v, key))

    arr.sort(reverse=True)

    m = arr[0][0]
    ans = []
    for i in range(len(arr)):
        if m == arr[i][0]:
            ans.append(arr[i][1])

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


if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter

n = int(input())
scnt = Counter([input() for _ in range(n)])
x = scnt.most_common(1)[0][1]

ans = sorted([k for k, v in scnt.most_common() if v == x])
for s in ans:
    print(s)

Solution (Python):
n=int(input())
mx = 0
t=[]
d={}
for i in range(n):
	s=input()
	t+=[s]
	d[s] = d.get(s,0)+1
	mx = max(mx,d[s])
	
v=[]
d2={}
for s in t:
	if(d[s]==mx and d2.get(s,0)==0):
		v+=[s]
		d2[s] = d2.get(s,0)+1
	
v.sort()
for s in v:
	print(s)

Solution (Python):
N=int(input())
S=[input() for _ in range(N)]
import collections
C=collections.Counter(S)
Ca=list(sorted(C.items(), key=lambda x:x[1], reverse=True))
ca=Ca[0][1]
ans=[]
for c in Ca:
    if c[1]==ca: ans.append(c[0])
    else: break
ans.sort()
for a in ans:
    print(a)

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

for _ in range(N):
    s = input()
    if s not in dic:
        dic[s] = 0
    dic[s]+=1
    if dic[s]>m:
        m = dic[s]

re = {}
for key in dic:
    if dic[key] not in re:
        re[dic[key]] = []
    re[dic[key]].append(key)
    
for one in sorted(re[m]):
    print(one)

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

N = int(input())
for n in range(N):
  string = input()
  count[string] += 1
sore = sorted(count.items(), key=lambda x: x[1], reverse=True)
item = []
max = 0
max = sore[0][1]
for s in sore:
  if s[1] != max:
    break
  item.append(s[0])

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

Solution (Python):

import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

























def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

inf = float('inf')

def main():
	N = inputInt()
	S = {}
	for i in range(N):
		inp = input()
		inp = inp[:-1]
		if inp in S:
			S[inp] += 1
		else:
			S[inp] = 1

	score_sorted = sorted(S.items(), key=lambda x:-x[1])
	ans = []
	mx = 0
	for i in score_sorted:
		str,inin = i
		if mx == 0:
			mx = inin
		if mx != inin:
			break
		ans.append(str)

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

	

if __name__ == "__main__":
	main()

Solution (Python):
from collections import Counter
n,*s = open(0).read().split()
s_count = Counter(s).most_common()
long_word=[]
max_count = s_count[0][1]
for word,count in s_count:
    if count < max_count: break
    long_word.append(word)

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

Solution (Python):
import collections
N = int(input())
S = [input() for _ in range(N)]
C = collections.Counter(S)
now = -1
ans = []
for v, i in C.most_common():
    if now == -1:
        now = i
    if now != i:
        break
    ans += [v]
print(*sorted(ans), sep='\n')