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


N = int(input())
S = [input() for _ in range(N)]
c = collections.Counter(S)
values, counts = zip(*c.most_common())
ans = []
if len(values) == 1:
    ans.append(values[0])
else:
    for i in range(N):
        if counts[i] == counts[0]:
            ans.append(values[i])
        else:
            break
ans.sort()
for i in range(len(ans)):
    print(ans[i])

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

for i in range(N):
    s = input()
    if s not in d:
        d[s] = 1
    else:
        d[s] += 1

maxi = 0
ans = []
for key, val in d.items():
    if val > maxi:
        maxi = val
        ans = [key]
    elif val == maxi:
        ans.append(key)

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

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

def main():
    n=int(input())
    S=[input().strip() for _ in range(n)]
    C=Counter(S)
    cnt=C.most_common()[0][1]
    Ans=[]
    for key,val in C.items():
        if val==cnt:
            Ans.append(key)
    Ans.sort()
    print(*Ans,sep='\n')
    
if __name__=='__main__':
    main()

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

Solution (Python):
n = int(input())
dict = {}
mx = 0
for i in range(n):
    s = input()
    if s not in dict:
        dict[s] = 0
    dict[s] += 1
    mx = max(mx, dict[s])
ans = []
for s in dict:
    if dict[s] == mx:
        ans.append(s)
ans.sort()
for s in ans:
    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
d_max = max(d.values())
ans = [k for k, v in d.items() if v == d_max]
for a in sorted(ans):
    print (a)

Solution (Python):
n = int(input())
l = [input() for i in range(n)]
l.sort()
c = 1
ans = []
m = 0
for i in range(n-1):
    if l[i] == l[i+1]:
        c += 1
    else:
        if c > m:
            ans.clear()
            ans.append(l[i])
            m = c
        elif c == m:
            ans.append(l[i])
        c = 1
if m == 1:
    ans.append(l[-1])
elif c > m:
    ans.clear()
    ans.append(l[-1])
    m = c
elif c == m:
    ans.append(l[-1])
for i in ans:
    print(i)

Solution (Python):
import collections
c = collections.Counter([input() for i in range(int(input()))])
c = c.most_common()
pre = c[0][1]
ans = []
for key,val in c:
  if val < pre:
    break
  ans.append(key)
for i in sorted(ans):
  print(i)

Solution (Python):
from collections import Counter

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

mx=max(c.values())
ans=[]
for i in c:
  if c[i]==mx:
    ans.append(i)
ans.sort()
for i in ans:
  print(i)

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

Solution (Python):



from collections import defaultdict
import sys
input = sys.stdin.readline
N = int(input())
D = defaultdict(int)
for i in range(N):
    D[input().rstrip()] += 1
A = []
maxv = 0
for k,v in sorted(D.items(),key=lambda x:x[1],reverse=True):
    if maxv > v:
        break
    maxv = v
    A.append(k)
A.sort()
print('\n'.join(A))

Solution (Python):
from collections import Counter
c=Counter()
n=int(input())
lis=[]
for _ in range(n):
    lis.append(input())
for x in lis:
    c[x]+=1

max=0
for k,v in c.items():
    if max<v:
        max=v

lis=[]
for k,v in c.items():
    if max==v:
        lis.append(k)
lis.sort()
for x in lis:
    print(x)

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

Solution (Python):
from sys import stdin

import collections

def main():

    input = stdin.readline

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

    for _ in range(A):
        S.append(input()[:-1])

    c = collections.Counter(S)

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

    S_ans = []
    for value,key in c.most_common():
        if(key == maxnum):
            S_ans.append(value)
        else:
            break

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


if __name__ == "__main__":
    main()

Solution (Python):
n=int(input())
s={}
for i in range(n):
  wd=input()
  if wd in s:
    s[wd]+=1
  else:
    s[wd]=1
mx=max(s.values())

ans=[]
for i in s.keys():
  if s[i]==mx:
    ans.append(i)
ans.sort()
for i in ans:
  print(i)

Solution (Python):
import collections

n = int(input())
s = [str(input()) for _ in range(n)]
word_dict = collections.Counter(s)
maxVal = max(word_dict.values())
max_list = [key for key, value in word_dict.items() if value == maxVal]
max_list.sort()
for item in max_list:
    print(item)

Solution (Python):
from collections import Counter

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

S_Counter=Counter(S)
Max=max(set(S_Counter.values()))

print('\n'.join(sorted(s for s,v in S_Counter.items() if v==Max)))

Solution (Python):
from collections import Counter

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

S_Counter=Counter(S)
Max=max(S_Counter.values())

print('\n'.join(sorted(s for s,v in S_Counter.items() if v==Max)))

Solution (Python):
from collections import Counter

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

counter = Counter(S)
count = counter.most_common()
most = count[0][1]
c = []

for i in range(len(counter)):
    if count[i][1] == most:
        c.append(count[i][0])

c.sort()
print(*c, sep='\n')

Solution (Python):
import unittest


class TestC(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think(['beat', 'vet', 'beet', 'bed', 'vet', 'bet', 'beet']), ['beet', 'vet'])

    def test_2(self):
        self.assertEqual(think(['buffalo', 'buffalo', 'buffalo', 'buffalo', 'buffalo', 'buffalo', 'buffalo', 'buffalo']), ['buffalo'])

    def test_3(self):
        self.assertEqual(think(['bass', 'bass', 'kick', 'kick', 'bass', 'kick', 'kick']), ['kick'])

    def test_4(self):
        self.assertEqual(think(['ushi', 'tapu', 'nichia', 'kun']), ['kun', 'nichia', 'tapu', 'ushi'])


def solve():
    s = read()
    result = think(s)
    write(result)


def read():
    n = read_int(1)[0]
    s = []
    for _ in range(n):
        s.append(read_line())
    return s


def read_int(n):
    return read_type(int, n, sep=' ')


def read_float(n):
    return read_type(float, n, sep=' ')


def read_type(t, n, sep):
    return list(map(lambda x: t(x), read_line().split(sep)))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(s):
    d = {}
    for e in s:
        d[e] = d.get(e, 0) + 1
    maximum = 0
    for key, value in d.items():
        maximum = max(maximum, value)
    result = []
    for key, value in d.items():
        if value == maximum:
            result.append(key)
    result.sort()
    return result


def write(result):
    for r in result:
        print(r)


if __name__ == '__main__':
    
    solve()

Solution (Python):

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

import collections

c = collections.Counter(S).most_common()
a,b = c[0]
ans = list()
for j,k in c:
    if k == b:
        ans.append(j)
    else:
        break
        
ans.sort()
for l in ans:
    print(l)

Solution (Python):
from collections import Counter

n = int(input())

l = [input() for i in range(n)]

c = Counter(l)

ml = c.most_common()
mc = ml[0][1]

ml.sort()

for i in ml:
    if i[1] == mc:
        print(i[0])

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

c = Counter(S)
max_c = max(c.values())
names = [name for name, cnt in c.items() if cnt == max_c]
names.sort()
print(*names, sep='\n')

Solution (Python):
n = int(input())
l = dict()
for i in range(n):
    s = input()
    if s not in l:
        l[s]=1
    else:
        l[s]+=1
l1 = []
for i in l:
    l1.append((l[i],i))
l1.sort()
l1 = l1[::-1]
p=0

l2 = []
l2.append(l1[0][1])
for i in range(len(l1)-1):
    if l1[i][0]==l1[i+1][0]:
        l2.append(l1[i+1][1])
        p=i
    else:
        break
l2.sort()

for i in l2:
    print(i)

Solution (Python):
import collections
N=int(input())
L=[input() for _ in range(N)]
K=collections.Counter(L).most_common()
bv, bk=K[0]

ANS=[]
for v,k in K:
  if bk == k:
    ANS.append(v)
  else:
    break
S=sorted(ANS)
[print(s) for s in S]

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

M = max(d.values())
for j,k in sorted(d.items()):
  if k == M:
    print(j)

Solution (Python):
from collections import Counter
N=int(input())
Ss=[input() for i in range(N)]
Ss=Counter(Ss).most_common()
mincount=Ss[0][1]
ans=[]
for s in Ss:
    if s[1]==mincount:
        ans.append(s[0])
for a in sorted(ans):
    print(a)

Solution (Python):
n = int(input())
data_list = []
for _ in range(n):
    data_list.append(input(""))

data_list_a = set(data_list)
data_list_a = list(data_list_a)
m = len(data_list_a)

data_a = [0 for _ in range(m)]

data_dic = dict(zip(data_list_a, data_a))

for i in range(n):
    data_dic[data_list[i]] += 1

data_score = data_dic.values()
max_value = max(data_score)
ans = []


for i in range(m):
    if data_dic[data_list_a[i]] == max_value:
        ans.append(data_list_a[i])


ans.sort()

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

Solution (Python):
import sys
input_first = input()
N= int(input_first)

worddic={}

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



maxval = 0
for i in worddic.items():
    if i[1] > maxval :
        maxval = i[1]
        result=[]
        result.append(i[0])
    elif i[1] == maxval:
        result.append(i[0])
    else:
        pass

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

Solution (Python):
n = int(input())
dic = {}
for _ in range(n):
    s = input()
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 0
top = []
laeger = 0
for v in dic.values():
    if v >= laeger:
        laeger = v

for k, v in dic.items():
    if v == laeger:
        top.append(k)
for i in sorted(top):
    print(i)

Solution (Python):
N=int(input())
S = []
for j in range(N):
    S.append(input())
import collections
S2=collections.Counter(S)
S1=S2.most_common()

S3=[]
S3.append(S1[0][0])
for i in range(1,len(S1)):
    if S1[i][1]==S1[0][1]:
        S3.append(S1[i][0])
    else:
        break
S3=sorted(S3)
for i in range(0, len(S3)):
    print(S3[i])

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

def main():
    N = int(input())
    c = Counter()
    m = 0
    S = [input() for i in range(N)]
    for s in S:
        c[s] += 1
        m = max(m, c[s])

    ans = sorted([k for k, v in c.items() if v == m])
    print('\n'.join(ans))
if __name__ == '__main__':
    main()

Solution (Python):
from collections import *
N = int(input())
c = Counter()
m = 0

for i in range(N):
    S = input()
    c[S] += 1
    m = max(m, c[S])

ans = sorted([k for k, v in c.items() if v == m])
print('\n'.join(ans))

Solution (Python):
from collections import Counter

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

cnt = Counter(sl)

maxNum = max(cnt.values())


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

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

Solution (Python):
n,*s=map(str,open(0).read().split())
from collections import*
c=Counter(s).most_common()
maxm=c[0][1]
ans=[]
for i,j in c:
  if maxm==j:
    ans+=i,
for b in sorted(ans):
  print(b)

Solution (Python):



def main():
    from collections import Counter

    n = int(input())
    s = [input() for _ in range(n)]
    c = Counter(s)
    max_value = max(c.values())
    ans = list()

    for key, value in c.items():
        if value == max_value:
            ans.append(key)

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


if __name__ == '__main__':
    main()

Solution (Python):
N=int(input())
S={}
for i in range(N):
    s=input()
    if s in S:
        S[s]+=1
    else:
        S[s]=1
S=sorted(S.items(),key=lambda x:(-x[1],x[0]))
Max=S[0][1]
for k,v in S:
    if v!=Max:
        break
    print(k)

Solution (Python):



def main():
    from collections import Counter

    n = int(input())
    s = [input() for _ in range(n)]
    c = sorted(Counter(s).items(), key=lambda x: x[1], reverse=True)
    max_value = c[0][1]
    ans = list()

    for key, value in c:
        if value == max_value:
            ans.append(key)

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


if __name__ == '__main__':
    main()

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

Solution (Python):
n=int(input())
a=[]
for i in range(n):
   a.append(input())
a.sort()
d={}
for i in range(n):
    if a[i] not in d:
        d[a[i]]=1
    else:
        d[a[i]]+=1
all_values=d.values()
m=max(all_values)
l=[]
for i in d:
    if d[i]==m:
        l.append(i)
l.sort()
for i in l:
    print(i)

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

Solution (Python):
n = int(input())
s = [input() for _ in range(n)]
d = {}
for w in s:
    if w not in d:
        d[w] = 0
    d[w] += 1
d2 = sorted(d.items(), key=lambda x:x[1], reverse=True)
maxcnts = [w[0] for w in d2 if w[1] == d2[0][1]]
maxcnts.sort()
for ans in maxcnts:
    print(ans)

Solution (Python):
N = int(input())
S = []
maxnum = 0
maxyouso = {}
anslist = []
for kai in range (N):
    S.append(input())
for moji in S:
    if moji not in maxyouso:
        maxyouso[moji] = 1
    else:
        maxyouso[moji] = maxyouso[moji] + 1
for num in maxyouso:
    if maxyouso[num] > maxnum:
        maxnum = maxyouso[num]
for num in maxyouso:
    if maxyouso[num] == maxnum:
        anslist.append(num)
anslist.sort()
for k in anslist:
    print(k)

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

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

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

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
input = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines  

from collections import Counter

N = int(input())
S = [input().rstrip().decode() for _ in range(N)]
S = Counter(S)
max_S = max(S.values())

name = sorted([k for k, v in S.items() if v == max_S])
print(*name, sep="\n")

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
m = max(d.values())
ans = []
for i in d :
    if d[i] == m :
        ans.append(i)
ans.sort()
for i in ans:
    print(i)

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

dict_maxval=max(dict.values())
    
res = [k for k, v in dict.items() if v == dict_maxval]
res.sort()
for word in res:
  print(word)

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

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

Solution (Python):
from collections import Counter

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

c = Counter(a)
list = c.most_common()
max = list[0][1]

ans = []
for i, j in list:
    if j == max:
        ans.append(i)
    else:
        break

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

Solution (Python):
import collections

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

c=collections.Counter(S)
tmp=c.most_common()[0][1]
m=sorted(c.most_common())
for i in m:
    if(i[1]==tmp):
        print(i[0])

Solution (Python):
n = int(input())
d = {}
for _ in range(n):
  s = input()
  if s in d:
    d[s] += 1
  else:
    d[s] = 1
maximum = 0
s_list = None
for s, t in d.items():
  if maximum < t:
    maximum = t
    s_list = [s]
  elif maximum == t:
    s_list.append(s)
s_list.sort()
for s in s_list:
  print(s)

Solution (Python):
from collections import defaultdict

N = int(input())
S = defaultdict(int)

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

poll = defaultdict(list)
for k, v in S.items():
    poll[v].append(k)

ans = sorted(poll[max(poll.keys())])

for a in ans:
    print(a)

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

m=0
for i in cal.keys():
    val=cal[i]
    m=max(m,val)

ans=[]
for i in cal.keys():
    val=cal[i]
    if val==m:
        ans.append(i)
ans.sort()
for i in ans:
    print(i)

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

for x in s:
    dd[x] += 1
mx = max(dd.values())

for k in sorted(j for j,y in dd.items() if y == mx):
    print(k)

Solution (Python):
N=int(input())
S=[]
for i in range(N):
    s=input()
    S.append(s)
m=1
x=dict()
for i in range(N):
    if S[i] in x:
        x[S[i]]+=1
        m=max(m,x[S[i]])
    else:
        x[S[i]]=1
l=[]
for idx in x:
    if x[idx]==m:
        l.append(idx)
l.sort()
for i in range(len(l)):
    print(l[i])

Solution (Python):
poll_table = {}

poll_times = int(input())

max_poll = 0

for i in range(poll_times):
  polled = input()
  if polled in poll_table.keys():
    poll_table[polled] += 1
  else:
    poll_table[polled] = 1

  if max_poll < poll_table[polled]:
    max_poll = poll_table[polled]

max_list = []
for key in poll_table.keys():
  if poll_table[key] == max_poll:
    max_list.append(key)

max_list.sort()

for polled in max_list:
  print(polled)

Solution (Python):
from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
CS = Counter(S)
v = 0
ans = []
for i  in CS.values():
  v = max(v,i)
for j,k in CS.items():
  if v == k:
    ans.append(j)
ans.sort()
print(*ans,sep="\n")

Solution (Python):

if __name__ == '__main__':
    dic = dict()
    n = int(input())
    for i in range(n):
        val = input()
        if val in dic.keys():
            dic[val]+=1
        else:
            dic[val]=1
    max_keys = max(dic.values())
    values_of_max_key = [val for val in dic if dic[val] == max_keys]
    sorted_values_of_max_key = sorted(values_of_max_key)
    for s in sorted_values_of_max_key:
        print(s)

Solution (Python):
n = int(input())
d = {}
for i in range(n):
    s = input()
    d[s] = d[s]+1 if (s in d) else 1
d_sorted = sorted(d.items(), key=lambda x:x[1], reverse=True)
m = d_sorted[0][1]
result = []
for i in d_sorted:
    if i[1]!=m:
        break
    result.append(i[0])
print(*sorted(result), sep='\n')

Solution (Python):
N = int(input())
d = {}
for _ in range(N):
  s = input()
  if(s not in d):
    d[s] = 1
  else:
    d[s] += 1
d2 = sorted(d.items(),key=lambda x:x[1], reverse=True)
s1=[]
s1.append(d2[0][0])
p=d2[0][1]
for t in d2[1:]:
  q=t[1]
  if(q==p):
    s1.append(t[0])
  else:
    break
s1=sorted(s1)
for i in s1:
  print(i)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
S = read().split()

S = sorted(S)
ls = [[] for i in range(N + 1)]
max_num = 0
left = 0
right = 0
while right < N:
    while right < N and S[left] == S[right]:
        right += 1
    if (right  - left) >= max_num:
        ls[right - left].append(S[left].decode())
        max_num = right - left
    left = right
    
print('\n'.join(ls[max_num]))

Solution (Python):
import collections 

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

b=collections.Counter(a) 
mx=max(b.values())
ans=[]

for word,counts in b.items():
    if counts==mx:
        ans.append(word)
        
ans=sorted(ans)
for i in ans:
    print(i)

Solution (Python):
N = int(input())
d = {}
for i in range(N):
  s = input()
  if s not in d.keys():
    d[s] = 1
  else:
    d[s] += 1
a = max(d.values())
d = sorted(d.items(), key=lambda x: x[1])
l = []
for i, j in d:
  if j == a:
    l.append(i)
l = sorted(l)
for i in range(len(l)):
  print(l[i])

Solution (Python):
import collections

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

c = collections.Counter(S)

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

a=sorted([i[0] for i in c.items() if i[1] == ans])
            
for i in a:
    print(i)

Solution (Python):

import sys
from collections import defaultdict

def main():
    N = int(input())
    S = defaultdict(int)
    for _ in range(N):
        S[input()] += 1
    S = sorted(S.items(), key=lambda x:x[1])

    ans = []
    cnt = S[-1][1]
    for i in range(len(S)-1, -1, -1):
        if cnt == S[i][1]:
            ans.append(S[i][0])
        else:
            break

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

if __name__ == "__main__":
    main()

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

s = Counter([input() for _ in range(n)])
mx = max(s.values())
ans = []
for k,v in s.items():
    if v==mx:
        ans.append(k)
for i in sorted(ans):
    print(i)

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

s = Counter([input() for _ in range(n)])
mx = max(s.values())

for k in sorted(x for x,y in s.items() if y == mx) :
    print(k)

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

s = Counter([input() for _ in range(n)])
mx = max(s.values())
ans = []
for k,v in s.items():
    if v==mx:
        ans.append(k)
for i in sorted(ans):
    print(i)

Solution (Python):
from collections import Counter
C=Counter()
for _ in range(int(input())):
  C[input()]+=1
m=max(C.values())
ans=[]
for key,val in C.items():
  if val==m:
    ans.append(key)
ans.sort()
print(*ans)

Solution (Python):
import collections

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

c = collections.Counter(polls)
maxval = c.most_common()[0][1]

values, counts = zip(*c.most_common())

ans = []

for i in c.most_common():
    if i[1] == maxval:
        ans.append(i[0])
    else:
        break

ans.sort()

for i in ans:
    print(i)

Solution (Python):
import collections

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

dic = collections.Counter(S)
max_value = max(dic.values())

A = []

for k, v in dic.items():
  if v == max_value:
    A.append(k)

A = sorted(A)

for i in A:
  print(i)

Solution (Python):
from collections import Counter
N = int(input())
S = Counter(input() for _ in range(N))
m = max(S.values())
for v in sorted(k for k, v in S.items() if v == m):
	print(v)

Solution (Python):
from collections import Counter
N = int(input())
S = Counter(input() for _ in range(N))
m = max(S.values())
for v in sorted(k for k, v in S.items() if v == m):
	print(v)

Solution (Python):
n=int(input())
list_ = [input() for i in range(n)]
dic = {}
for a in list_:
    if a in dic:
        dic[a] += 1
    else:
        dic[a]   = 1
maxa = max(dic.values())
ans = [x for x, y in dic.items() if y == maxa]
for A in sorted(ans):
    print(A)

Solution (Python):
n = int(input())
dic ={}
for i in range(n):
    key = input()
    if key not in dic:
        dic[key] = 1
    if key in dic:
        dic[key] += 1
max_v = max(dic.values())
res = sorted(list(filter(lambda key:dic[key]==max_v,list(dic))))
for key in res:
    print(key)

Solution (Python):
def readints():
    return list(map(int, input().split()))


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

s.sort()

L = []
M = -1
i = 0
while i < n:
    j = i
    while j < n and s[i] == s[j]:
        j += 1
    l = j-i
    L.append(l)
    i = j
for i in L:
    if i > M:
        M = i

index = 0
for i in L:
    
    if i == M:
        print(s[index])
    index += i

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return input().rstrip()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def solve():
    n = II()
    s = SR(n)
    d = defaultdict(int)
    for si in s:
        d[si] += 1
    item = list(d.items())
    item.sort(key=lambda x: x[1], reverse=True)
    m = item[0][1]
    ans = []
    for i, v in item:
        if v == m:
            ans.append(i)
        else:
            break
    ans.sort()
    print("\n".join(ans))
    return



if __name__ == '__main__':
    solve()

Solution (Python):
import numpy as np
from collections import Counter

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

counter = Counter(S)
m = max(counter.values())

most_common_let = [i for i in counter.keys() if counter[i] == m]
sorted_list = sorted(most_common_let)
for i in sorted_list:
    print(i)

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

dict = {}
L = []

for i in range(N):
  s = input()
  if s in dict:
    dict[s] = dict[s] + 1
  else:
    dict[s]=1
    L.append(s)

L.sort()

M = 0
for i in dict:
  M = max(M, dict[i])

for i in L:
  if dict[i] == M:
    print(i)

Solution (Python):
N=int(input())
d={}
for _ in range(N):
    x=input()
    if x in d.keys():
        d[x]+=1
    else:
        d.update({x:1})
        
s=max(d.values())
moji=[]
for i in d.items():
    if i[1]==s:
        moji.append(i[0])
for i in sorted(moji):
    print(i)

Solution (Python):
from collections import Counter

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

c = Counter(s)
c2 = c.most_common()
m = c2[0][1]
ans = [i[0] for i in c2 if i[1] == m]
ans.sort()
print(*ans)

Solution (Python):
from collections import Counter

n = int(input())

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

count = Counter(a)
most = count.most_common()
tmp = []
mostidx = most[0][1]
for ss, ii in most:
    if ii == mostidx:
        tmp.append(ss)
tmp.sort()
for t in tmp:
    print(t)

Solution (Python):
dict = {}
for i in range(int(input())):
    a = input()
    if dict.get(a):
        dict[a] += 1
    else:
        dict[a] = 1

max_v = max(dict.values())


ans = [key for key, value in dict.items() if value == max_v]
ans.sort()
for i in ans:
    print(i)

Solution (Python):
from collections import Counter
 
N = int(input())
A = [input() for i in range(N)]
 
c = Counter(A).most_common()
k, v = zip(*c)
 
[print(s) for s in sorted(k[:v.count(v[0])])]

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

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

N = int(input().strip())
S_list = [input().strip() for _ in range(N)]

c = cl.Counter(S_list)

max_num = max(c.values())

max_list = sorted([kv[0] for kv in c.items() if kv[1] == max_num])
print(*max_list)

Solution (Python):
N=int(input())
S=[input() for i in range(N)]
D=dict()
k=0
for i in range(N):
    if S[i] in D:
        D[S[i]]+=1
    else:
        D[S[i]]=1
    k=max(D[S[i]],k)
X=[]
for i in D:
    if D[i]==k:
        X.append(i)
for line in sorted(X):
    print(line)

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

ans = {}
for i in S:
  if i in ans:
    ans[i] += 1
  else:
    ans[i] = 1

max_value = max(ans.values())
ANS = []
for key, value in ans.items():
  if ans[key] == max_value:
    ANS.append(key)
    
for i in sorted(ANS):
  print(i)

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

words_sorted = sorted(words.items(), key=lambda x: x[1], reverse=True)
max_keys = [words_sorted[0][0]]
init = words_sorted[0][1]
for word in words_sorted[1:]:
    if word[1] == init:
        max_keys.append(word[0])
    else:
        break
max_keys.sort()
for i in max_keys:
    print(i)

Solution (Python):
import sys
readline = sys.stdin.readline
from collections import Counter
N = int(readline())
C = Counter()

for _ in range(N):
    S = readline().strip()
    C[S] += 1

ma = max(C.values())
K = [k for k, v in C.items() if v == ma]
K.sort()
print('\n'.join(K))

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

ans = {}
for i in S:
    if i in ans:
        ans[i] += 1
    else:
        ans[i] = 1

max_v = max(ans.values())        
ANS = []
for key, value in ans.items():
    if ans[key] == max_v:
        ANS.append(key)

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

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

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

word_buf = {}

for i in s:
    if i in word_buf.keys():
        word_buf[i] += 1
    else:
        word_buf[i] = 1

max_cnt = max(word_buf.values())
max_word = [i[0] for i in word_buf.items() if i[1] == max_cnt]
max_word.sort()

for i in max_word:
    print(i)

Solution (Python):
from collections import Counter

n = int(input())

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

tmp = cnt.most_common()

ans = [name for name,cnt in tmp if cnt==tmp[0][1]]

ans = sorted(ans)

for a in ans:
    print(a)