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 sys
sys.setrecursionlimit(4100000)
import math
import collections
INF = 10**9


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

    count = 0
    c = collections.Counter(S)
    for _, val in c.items():
        count = max(count, val)
    array = []
    for key, val in c.items():
        if val == count:
            array.append(key)
    array.sort()
    for val in array:
        print(val)


if __name__ == '__main__':
    main()

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

count = {}

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

max_count = max(count.values())

ans = []

for k, v in count.items():
    if v == max_count:
        ans.append(k)

ans = sorted(ans)

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

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

Solution (Python):
S = []

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

S.sort()
count = 0
max_count=0
s_max=[]
for i in range(N):
	if i==0:
		s_0 = S[i]
		s_max.append(s_0)
		continue
	s_1 = S[i]
    
	if s_0 == s_1:
		count += 1
	else:
		count = 0
      
	if max_count==count:
		max_count = count
		s_max.append(s_1)
	elif max_count < count:
		max_count = count
		s_max=[]
		s_max.append(s_1)
      
	s_0 = s_1
    

for i in s_max:
  print(i)

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

c=collections.Counter(S)
vl=list(c.values())

mv=max(vl) 

ans=[]
cc=list(c.items()) 
cc.sort(key=lambda x:x[1], reverse=True) 

for k, v in cc:
  if v==mv: 
    ans.append(k)
  else:
    break
ans.sort()
[print(a) for a in ans]

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

c=collections.Counter(S)
vl=list(c.values())
mv=max(vl)

ans=[]
cc=list(c.items())
cc.sort(key=lambda x:x[1], reverse=True)

for k, v in cc:
  if v==mv:
    ans.append(k)
  else:
    break
ans.sort()
[print(a) for a in ans]

Solution (Python):
import collections
import sys
N=int(input())
S=[input() for i in range(N)]
c = collections.Counter(S).most_common()
c.sort()
c.sort(key=lambda c:c[1],reverse=True)
max_count=c[0][1]
for _ in c:
  if _[1]==max_count:
    print(_[0])
  else:
    sys.exit()

Solution (Python):
n=int(input())
a={}
for _ in range(n):
  m=input()
  if m in a:
    a[m]+=1
  else:
    a[m]=1
b=[]
v=max(a.values())
for k in a.items() :
     if k[1] == v:
      b.append(k[0])
b.sort()
for l in b:
  print(l)

Solution (Python):
n = int(input())
s = [input() for i in range(n)]
from collections import Counter
cnter = Counter(s)
lis = cnter.most_common()
maxi = lis[0][1]
i = 0
string = []
for i in range(len(lis)):
    if maxi != lis[i][1]:
        break
    string.append(lis[i][0])
string.sort()
for i in range(len(string)):
    print(string[i])

Solution (Python):
line = int(input())
words =[input() for i in range(line)]

import collections

output = []
words_col = collections.Counter(words).most_common()
max_num = words_col[0][1]
for most_word in words_col:
  if max_num != most_word[1]: 
    break
  output.append(most_word[0])

output.sort()
print("\n".join(output))

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


m = max(D.values())
count = []
for key in D:
    if D[key] == m:
        count.append(key)

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

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

S=collections.Counter(S)
S=S.most_common()
result = []
result.append(S[0][0])
i=1
while i <len(S):
    if S[0][1] == S[i][1]:
        result.append(S[i][0])
    
    elif S[0][1] < S[i][1]:
        break
    i+=1
result.sort()
[print(i) for i in result]

Solution (Python):
import collections
n = int(input())
a=[input() for _ in range(n)]
anslist=[]
b=collections.Counter(a)
c=max(list(b.values()))
for i in b:
    if b[i]==c:
        anslist.append(i)
d=sorted(anslist)
for i in tuple(d):
    print(i)

Solution (Python):
n = int(input())
countmax=0
anslist=[]
dic={}
for i in range(n):
    a=input()
    if a in dic:
        dic[a]+=1
    else:
        dic[a]=1
    if dic[a]>countmax:
        countmax=dic[a]
for j in dic.keys():
    if dic[j]==countmax:
        anslist.append(j)
b=sorted(anslist)
for i in b:
    print(i)

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

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


max_value = max(S.values())

key_li = [key for key,value in S.items() if value==max_value]

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

Solution (Python):
N=int(input())
dic={}
Mcount=1
for i in range(N):
    tmp=input()
    if tmp in dic:
        dic[tmp]+=1
        if Mcount<dic[tmp]:
            Mcount=dic[tmp]
    else:    
        dic[tmp]=1
a = sorted(dic.items(), key=lambda x: x[0])

keys = [k for k, v in dic.items() if v == Mcount]
keys.sort()
for i in keys:
    print(i)

Solution (Python):
from collections import Counter

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

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

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

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

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

max_val = max(S.values())
max_key = [key for key in S if S[key] == max_val]
print("\n".join(sorted(max_key)))

Solution (Python):
from collections import Counter

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


p=dick[0][1]

s=[]
for k,i in dick:
  if i==p:
    s.append(k)
  else:
    break
ss=sorted(s)
for i in ss:
  print(i)

Solution (Python):
import collections

n = int(input())
l = [input() for _ in [0] * n]

counted = collections.Counter(l)


m = max(counted.values()) 

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

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

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

Solution (Python):
n=int(input())
s=[input()for _ in range(n)]
from collections import Counter
cs=Counter(s)
d=dict(cs)
a=list(d.items())
a.sort(key=lambda x:x[1])
ansc=a[-1][1]
ans=[]
while a and ansc==a[-1][1]:
    b,c=a.pop()
    ans.append(b)
ans.sort()
print(*ans,sep='\n')

Solution (Python):

from collections import Counter
n = int(input())
s = []
for _ in range(n):
    s.append(input())
a = Counter(s).most_common()
c = a[0][1]
ans = []
for i in a:
    if i[1] == c:
        ans.append(i[0])
ans = sorted(ans)
for j in ans:
    print(j)

Solution (Python):
from collections import Counter
n = int(input())
S = []
for i in range(n):
  S.append(input())
S = sorted(S)
c = Counter(S)
X = c.most_common()
A = []
for i in range(len(X)):
  if X[0][1] == X[i][1]:
    A.append(X[i][0])
  else:
    break
A = sorted(A)
for i in range(len(A)):
  print(A[i])

Solution (Python):
N = int(input())
S =  {}
count_max = 0
for i in range(0, N):
  si = input()
  if si in S:
    S[si] = S[si] + 1
  else:
    S[si] = 1
  if S[si] > count_max:
    count_max = S[si]

arr = []
for k in S:
  if S[k] == count_max:
    arr.append(k)
    
arr.sort()
print(*arr, sep='\n')

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

def main():
    n = int(input())
    s = [input() for _ in range(n)]
    cnt = collections.Counter(s)
    cnt_max = max(cnt.values())
    d = [k for k, v in cnt.items() if v == cnt_max]
    d = sorted(d)
    print(*d, sep='\n')

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
A = {}
B = []
for n in range(N):
    a = input()
    B.append(a)
    A[a] = 0
for n in range(N):
    A[B[n]] += 1
res = 0
C = []
for key, value in A.items():
    if res < value:
        res = value
for key, value, in A.items():
    if res <= value:
        C.append(key)
C.sort()
for c in C:
    print(c)

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

def main():
    n = int(input())
    s = [input() for _ in range(n)]
    cnt = collections.Counter(s)
    values, counts = zip(*cnt.most_common())
    d = sorted(values[:counts.count(counts[0])])
    print(*d, sep='\n')

if __name__ == '__main__':
    main()

Solution (Python):
from collections import defaultdict

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

dic = defaultdict(int)
for each in li:
    dic[each] += 1

res = sorted(dic.items(), key=lambda x:x[1], reverse=True)
max_val = 0
res_li = []
for name, val in res:
    if val >= max_val:
        max_val = val
    if max_val == val:
        res_li.append(name)

res_li.sort()
for each in res_li:
    print(each)

Solution (Python):
import collections

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

a = collections.Counter(s)
b = a.most_common()
c = 0

for i in range(len(b)):
	if b[i][1] == b[0][1]:
		c += 1
	else:
		break

d = sorted(b[:c])

for j in range(c):
	print(d[j][0])

Solution (Python):
from collections import Counter

N = int(input())
S = sorted(Counter([input() for _ in range(N)]).items(), key=lambda x: x[0])
S = sorted(S, key=lambda x: x[1], reverse=1)
cnt_max = S[0][1]

for i, v in S:
    if v == cnt_max:
        print(i)

Solution (Python):
d=dict()
n=int(input())
for i in range(n):
    s=input()
    if s in d:
        
        d[s]+=1
    else:
        d[s]=1
d=list(d.items())

d.sort(key=lambda x:x[0])

d.sort(key=lambda x:x[1],reverse=True)
m=len(d)
for i in range(m):
    
    if d[i][1]==d[0][1]:
        print(d[i][0])
    else:
        break

Solution (Python):

n = int(input())
polls = {}


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

ans = max(polls.values())
result = list(polls.items())
result.sort(key=lambda x: x[0])


for d in result:
  if d[1] == ans:
    print(d[0])

Solution (Python):
N=int(input())
A=[]
Q={}
for i in range(N):
    B=input()
    A.append(B)
    Q[B]=0
    
for i in A:
    Q[i]+=1
    
a=max(Q.values())
ans=[]
for i in Q:
    if Q[i]==a:
        ans.append(i)
ans.sort()
for i in ans:
    print(i)

Solution (Python):
n=int(input())
s=[]
for i in range(n):
  s.append(input())
from collections import Counter
zisyo=Counter(s)
ans=[]
a=max(zisyo.values())
for i in zisyo:
  if zisyo[i]==a:
    ans.append(i)

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

Solution (Python):
import collections
import sys

input = sys.stdin.readline
N = int(input())
candidate = [input().strip("\n") for _ in range(N)]

candidate.sort()
c = collections.Counter(candidate)

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

l = sorted([k for k, v in c.items() if v == MAX])

for i in l:
    print(i)

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

d = {}

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

hoge = max(d.values())

max_kv_list = [kv[0] for kv in d.items() if kv[1] == hoge]

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

Solution (Python):
from collections import defaultdict
N = int(input())
word_count = defaultdict(int)
for _ in range(N): 
    word_count[input()] += 1
max_amount = sorted(word_count.items(), key=lambda x:x[1],  reverse=True)[0][1]
max_amount_words = sorted([k for k, v in word_count.items() if v == max_amount])
print('\n'.join(max_amount_words))

Solution (Python):
import collections

def count(s):
    return collections.Counter(s).most_common()

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

ret = count(S)

max_ = 0
for i in ret:
    max_ = max(i[1], max_)
    
ans = []
for i in ret:
    if i[1] == max_:
        ans.append(i[0])
        
ans = sorted(ans)
for i in ans:
    print(i)

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

c = collections.Counter(s)
values, counts = zip(*c.most_common())

ss = []
for i in range(counts.count(max(counts))):
	ss.append(values[i])

ss.sort()

for sss in ss:
	print(sss)

Solution (Python):
from collections import Counter

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
s = list(read().decode().rstrip().split())

c = Counter(s)
m = max(c.values())
l = sorted([k for k, v in c.items() if v == m])
print(*l)

Solution (Python):
def main():
    n = int(input())
    indic = {}
    for _ in range(n):
        s = input()
        if s in indic:
            indic[s] += 1
        else:
            indic[s] = 1
    
    max_v = max(indic.values())

    ans = []
    for key in indic:
        if indic[key] == max_v:
            ans.append(key)

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

if __name__ == "__main__":
    main()

Solution (Python):
import collections
n = int(input())
ls = [input() for i in range(n)]
c = collections.Counter(ls)
mx = max(c.values())
A = [e for e,j in c.items() if j == mx]
A.sort()
for p in A:
  print(p)

Solution (Python):
import collections as clcts

N = int(input())

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

P = clcts.Counter(V)

W = max(P.values())
A = [i for i, j in P.items() if j == W]
A.sort()

for i in A:
    print(i)

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

calc=Counter(s)


m=0

for v in calc.values():
  m=max(m,v)
ans = []
for k, v in calc.items():
  if v==m:
    ans.append(k)
ans.sort()

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

Solution (Python):
from sys import stdin
input = stdin.readline
N = int(input())
S = {}
for n in range(N):
    s = input()
    if S.get(s) == None:
        S[s] = 1
    else:
        S[s] += 1
m = max(S.values())
A = [k for k,v in S.items() if v == m]
A = sorted(A)
for a in A:
    print(a.rstrip('\n'))

Solution (Python):
import collections

num_of_papers = int(input())
names = []

for _ in range(num_of_papers):
    names.append(input())

cnt = collections.defaultdict(int)
max_appearance = 0
for _ in names:
    cnt[_] = cnt[_] + 1

    if max_appearance < cnt[_]:
        max_appearance = cnt[_]

max_names = [key for key, value in cnt.items() if value == max_appearance]

max_names.sort()

for _ in max_names:
    print(_)

Solution (Python):
from collections import Counter
N=int(input())
S=[input() for i in range(N)]
s=Counter(S)
m=max(s.values())
s=sorted(s.items() ,key=lambda s:s[0])
for a in s:
    if a[1]==m:
        print(a[0])

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

def poll(N):
    memo = {}
    max_votes = 1
    for i in range(N):
        Si = input()
        try:
            memo[Si] += 1
            max_votes = max(max_votes, memo[Si])
        except:
            memo[Si] = 1
    max_list = [key for key, value in memo.items() if value == max_votes]
    return max_list

max_list = poll(N)
max_list.sort()
for item in max_list:
    print(item)

Solution (Python):
from collections import Counter
N=int(input())
S=[input() for i in range(N)]
s=Counter(S)
m=max(s.values())
s=sorted(s.items() ,key=lambda s:s[0])
for a in s:
    if a[1]==m:
        print(a[0])

Solution (Python):
N=int(input())
S=[input() for i in range(N)]
dictionary={}
for word in S:
    if word in dictionary:
        dictionary[word]+=1
    else:
        dictionary[word]=1
maximum=max(dictionary.values())
for key,value in sorted(dictionary.items()):
    if value==maximum:
        print(key)

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

cc=collections.Counter(X)
maximum=max(cc.values())

ans=sorted([ss[0] for ss in cc.items() if ss[1]==maximum])
print(*ans)

Solution (Python):
from collections import Counter

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

count = Counter(s)
l = count.most_common()

for i, j in l:
    if j == l[0][1]:
        a.append(i)

a.sort()

for k in a:
    print(k)

Solution (Python):
import sys
from collections import Counter

input = sys.stdin.readline


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

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

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


if __name__ == "__main__":
    main()

Solution (Python):
import sys
from collections import Counter

input = sys.stdin.readline


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

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

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


if __name__ == "__main__":
    main()

Solution (Python):
import sys
from collections import Counter

input = sys.stdin.readline


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

    c = Counter(S)
    ans = []
    max_v = max(c.values())
    for k, v in c.items():
        if v == max_v:
            ans.append(k)

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


if __name__ == "__main__":
    main()

Solution (Python):
import sys
from collections import Counter

input = sys.stdin.readline


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

    c = Counter(S)
    ans = []
    prev_v = 0
    for k, v in c.most_common():
        if prev_v == 0:
            prev_v = v
        else:
            if prev_v != v:
                break
        ans.append(k)

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


if __name__ == "__main__":
    main()

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

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

m = max(dic.values())
arr = []

for j in dic:
    if dic[j] == m:
        arr.append(j)

arr.sort()

for k in arr:
    print(k)

Solution (Python):


N = int(input())
S=[]
for _ in range(N):
    S.append(input())
dic = {}
for s in S:
    if not s in dic:
        dic[s] = [s,0]
    dic[s][1] += 1


dic_swap = {}
for k,v in dic.values():
    if not v in dic_swap :
        dic_swap[v] = [k]
        continue
    dic_swap[v].append(k)

key_sorted = list(dic_swap.keys())
key_sorted.sort()

v = dic_swap[key_sorted[-1]]
v = list(v)
v.sort()
for vi in v:
    print(vi)

Solution (Python):
import collections
N=int(input())
S=[input() for i in range(N)]
cnt=collections.Counter(S)
cnt=cnt.most_common()
ans=[]
cnt=sorted(cnt,key=lambda x :x[1],reverse=True)
max=cnt[0][1]
num=len(cnt)
for i in range(num):
  if cnt[i][1]==max:
    ans.append(cnt[i][0])
ans=sorted(ans)
for i in ans:
  print(i)

Solution (Python):
n = int(input())
v_list = []
dict = {}

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

max_id = max(dict.values())
ans_list = []

for i in dict:
    if dict[i] == max_id:
        ans_list.append(i)

ans_list = sorted(ans_list)

for i in ans_list:
    print(i)

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

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

Solution (Python):
def solve(N, Ss):
    d = {}
    _max = 0
    for s in Ss:
        d.setdefault(s, 0)
        d[s] += 1
        _max = max(_max, d[s])

    d = [x[0] for x in d.items() if x[1] == _max]
    d.sort()
    for s in d:
        print(s)


if __name__ == '__main__':
    N = int(input())
    Ss = [input() for _ in range(N)]
    solve(N, Ss)

Solution (Python):
from collections import Counter
N = int(input())
A = [None for i in range(N)]
for i in range(N):
  A[i] = input()
A = Counter(A)
keyA = list(A.keys())
valuesA = list(A.values())
most = max(valuesA)

ans = [None for _ in range(N)]
for i in range(len(valuesA)):
  if valuesA[i] == most:
    ans[i] = keyA[i]
ans = [a for a in ans if type(a) == str]
ans = sorted(ans)
for i in range(len(ans)):
  print(ans[i])

Solution (Python):
N=int(input())
S =[]
for n in range(N):
    S.append(input())
from collections import Counter
S_C = Counter(S)
S_C =sorted(S_C.items(),key = lambda x:(-x[1],x[0]) )
m = S_C[0][1]
for s in S_C:
    if m==s[1]:
        print(s[0])

Solution (Python):
from collections import Counter
n = int(input())
s = list(input() for _ in range(n))
ls = Counter(s).most_common()
a = []
a.append(ls[0][0])
for i in range(1, len(ls)):
    if ls[i][1] == ls[0][1]:
        a.append(ls[i][0])
for i in sorted(a):
    print(i)

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

c = collections.Counter(s)

a = []
b = (c.most_common())

a.append(b[0][0])
for i in range(1,len(b)):
    if b[0][1] == b[i][1]:
        a.append(b[i][0])
print(*sorted(a))

Solution (Python):
from collections import Counter

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

counter = Counter(S)

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

ans = sorted(ans)

for s in ans:
    print(s)

Solution (Python):
from collections import Counter

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

counter = Counter(S)

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

ans = sorted(ans)

for s in ans:
    print(s)

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

from collections import Counter
ls = Counter(S).most_common()
MAX = ls[0][1]
ans = []
for s,length in ls:
    if MAX == length:
        ans.append(s)
    else:
        break;

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

Solution (Python):
N = int(input())
word_cnts = {}
curr_max = 0
for _ in range(N):
    word = input()
    if word in word_cnts:
        word_cnts[word] += 1
    else:
        word_cnts[word] = 1
    curr_max = max(curr_max, word_cnts[word])

for word in sorted(k for k in word_cnts if word_cnts[k] == curr_max):
    print(word)

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

D={}
for i in range(N):
    try:
        if D[S[i]]>=1:
            D[S[i]]+=1
    except:
        D[S[i]]=1
E=sorted(D.items(),key=lambda x:x[1])
m=E[-1][1]
ans=[]
for i in E:
    if i[1]==m:
        ans.append(i[0])
for i in sorted(ans):
    print(i)

Solution (Python):
n = int(input())
s = [str(input()) for i in range(n)]
dic = {}
m = 1
for a in s:
    if not a in dic:
        dic[a] = 1
    else:
        dic[a] += 1
        cnt = dic[a]
        m = max(m, cnt)
se = set()
for a in s:
    if dic[a] == m:
        se.add(a)
l = ['a'] * len(se)
for i in range(len(se)):
    l[i] = se.pop()
l.sort()
for i in range(len(l)):
    print(l[i])

Solution (Python):
dic = {}
for i in range(int(input())):
    s = input()
    if s in dic:
        dic[s] = dic[s] + 1
    else:
        dic[s] = 1
max_v = max(dic.values())
ret = [k for k, v in dic.items() if v == max_v]

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

Solution (Python):

import sys
import collections

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


def main():
    _ = readline()
    Ss = [s.rstrip().decode() for s in readlines()]
    counter = collections.Counter(Ss)
    mc = counter.most_common()
    ans = [mc[0][0]]
    max_v = mc[0][1]
    for key, value in mc[1:]:
        if value == max_v:
            ans.append(key)
        else:
            break
    ans.sort()
    for a in ans:
        print(a)


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
string = {}
ans = []

for _ in range(N):
    S = input()
    try:
        string[S] += 1
    except KeyError:
        string[S] = 1

most_frequent = max(string.values())

for s,num in string.items():
    if num == most_frequent:
        ans.append(s)

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

Solution (Python):
N=int(input())
s={}
maxs=0
for i in range(N):
  S=input()
  if S not in s:
    s[S]=0
  else:
    s[S]+=1
    maxs=max(maxs,s[S])
s=sorted(s.items(), key=lambda x:x[0])

ans= [S for S, i in s if i == maxs]
for A in ans:
  print(A)

Solution (Python):
import sys

import math


from collections import deque

from fractions  import gcd


n=int(input())
dic={}
for i in range(n):
    s=input()
    if s not in dic:
        dic[s]=1
    else:
        dic[s]+=1
m=max(dic.values())
dic=sorted(dic.items(),key=lambda x: x[0])
for i in range(len(dic)):
    if dic[i][1]==m:
        print(dic[i][0])

Solution (Python):
n = int(input())
S = [input() for i in range(n)]
from collections import Counter
C = Counter(S)
n = C.most_common()[0][1]
L = []
for k in C.keys():
	if C[k] == n:
		L.append(k)
print(*sorted(L), sep='\n')

Solution (Python):
N = int(input())
count = {}
for i in range(N):
    s = input()
    count.setdefault(s, 0)
    count[s] += 1
p = max(count.values())
ans = []
for k in count.keys():
    if count[k] == p:
        ans.append(k)
ans.sort()
for a in ans:
    print(a)

Solution (Python):
def main():
    n = int(input())
    ss = {}
    max_s = 0
    for _ in range(n):
        s = input()
        if s not in ss:
            ss[s] = 0
        else:
            ss[s] += 1
            max_s = max(max_s, ss[s])

    ss = sorted(ss.items(), key=lambda x: x[0])
    anss = [s for s, i in ss if i == max_s]
    for ans in anss:
        print(ans)


if __name__ == "__main__":
    main()

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



c ={}
for i in s :
  if i in c :
    c[i] += 1
  else :
    c[i] = 1

x = max(c.values())

ans = []
for i in c.items(): 
  if i[1] == x :
    ans.append(i[0])

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

Solution (Python):

import sys
from collections import Counter, defaultdict

def main():
    N = int(input())
    names = [input() for _ in range(N)]
    c = Counter(names)

    ans_name = c.most_common(1)[0][0]
    ans_val = c.most_common(1)[0][1]
    
    ans_set = set()
    ans_set.add(ans_name)

    for key in c:
        if key not in ans_set and c[key] == ans_val:
            ans_set.add(key)


    ans = list(ans_set)
    ans.sort()
    print(*ans, sep='\n')


if __name__ == '__main__':
    main()

Solution (Python):
import collections

n = int(input())
d = {}
for _ in range(n):
    s = input()
    if d.get(s):
        d[s] += 1
    else:
        d[s] = 1
m = 0
ans = []
for k, v in d.items():
    if m < v:
        m = v
        ans = [k]
    elif m == v:
        ans.append(k)
for i in sorted(ans):
    print(i)

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

max_cnt=-1
for _ in range(n):
    s=input()
    d[s]+=1
    max_cnt=max(max_cnt, d[s])


ans=sorted([k for (k,v) in d.items() if v==max_cnt])
    
for a in ans:
    print(a)

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

if len(S) == len(set(S)):
  ans = S
else:
  ans = []
  c = collections.Counter(S)
  c_common = c.most_common()
  max_vote = c_common[0][1]
  for k in range(len(set(S))):
    if c_common[k][1]== max_vote:
      ans.append(c_common[k][0])
    else:
      break
[print(a) for a in sorted(ans)]

Solution (Python):
from collections import Counter

n = int(input())

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

c = Counter(s).most_common()


m = c[0][1]

ans = []

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

ans.sort()

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

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

dic = {}

for x in s:
    if x in dic.keys():
        dic[x] += 1
    else:
        dic[x] = 1

max_v = max(dic.values())
a = []
for k, v in dic.items():
    if v == max_v:
        a.append(k)

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

Solution (Python):
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
cnt = Counter(s)
max_v = max(cnt.values())
ans = [s for s,c in cnt.items() if c==max_v]
ans.sort()
print('\n'.join(ans))

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

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

dict = sorted(d.items(), key=lambda x:x[1], reverse=True)
max_v = max(d.values())

dict_li = []
for a in dict:
    if a[1]==max_v:
        dict_li.append(a[0])

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

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

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

dict = sorted(d.items(), key=lambda x:x[1], reverse=True)
max_v = max(d.values())

dict_li = []
for a in dict:
    if a[1]==max_v:
        dict_li.append(a[0])

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

Solution (Python):
n=int(input())
dict = {}
mx=1
for i in range(n):
  s=input()
  if s in dict:
    dict[s]+=1
    mx=max(dict[s],mx)
  else:
    dict[s]=1
v=[]
for s,i in dict.items():
  if i==mx:
    v.append(s)
print(*sorted(v))

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

import collections

counter = collections.Counter(S)

max_cnt = max(counter.values())

names = [n for n,c in counter.items() if c==max_cnt]
names.sort()
print(*names, sep='\n')

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

x = {}
a = [0]*n
c = []
ans = []

for i in range(0,n):
  tmp = input()
  if(tmp in x):
    valu = x.get(tmp)
    x[tmp] = valu + 1
    
  else:
    x[tmp] = 1
    



ma = max(x.values())


i=0
for key, value in x.items():
  
  if(value == ma):
    c.append(key)
    

c.sort()

for i in c:
  print(i)

Solution (Python):
from collections import Counter

stdin = open(0)
N = int(stdin.readline())
S = stdin.read().split()

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

Solution (Python):

from collections import Counter

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

l = Counter(S)
m = l.most_common()[0][1]
values, counts = zip(*l.most_common())
c = counts.count(m)
v = values[:c]
for vv in sorted(v):
    print(vv)

Solution (Python):
N,*S=open(0).read().split()
import collections

C=collections.Counter(S)
M=max(C.values())
keys = [k for k, v in C.items() if v == M]
keys.sort()

for i in keys:
    print(i)

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

for keys in d.keys():
  if d[keys]==m:
    a.append(keys)
a=sorted(a)

for word in a:
  print(word)