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

m = max(d.values())
l=[]
for i in d:
    if d[i] == m:
        l.append(i)
for i in sorted(l):
    print(i)

Solution (Python):
n = int(input())
s = list(input() for _ in range(n))
d = {}
for i in range(n):
    if s[i] in d:
        d[s[i]] += 1
    else:
        d[s[i]] = 1
m = max(d.values())
for s in sorted(k for k in d if d[k] == m):
    print(s)

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

d = {}
for _ 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 collections
def resolve():
    n = int(input())
    s = [input() for _ in range(n)]
    c = collections.Counter(s)
    max_count = c.most_common()[0][1]
    ans = [i[0] for i in c.items() if i[1]==max_count]
    for i in sorted(ans): print(i)
resolve()

Solution (Python):
n = int(input())
d = {}
m = 0
for i in range(n):
    s = input()
    d[s] = d.get(s, 0) + 1
    if m <= d[s]:
        m = d[s]
c = []
for i in d:
    if d[i]==m:
        c.append(i)
c.sort()
for x in c:
    print(x)

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

d = {}
ans = []

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

max = max(d.values())
for key in d.keys():
    if d[key] == max:
        ans.append(key)
        
ans = sorted(ans)

for word in ans:
    print(word)

Solution (Python):
n=int(input())
s={}
for i in range(n):
  si = input()
  if si not in s:
    s[si] = 1
  else:
    s[si]+=1
sa = sorted(s.items())
ma = max(s.values())
for a in sorted(a for a in s if s[a]==ma):
  print(a)

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

d = {}

for i in range(N):
  key = input()
  try:
    d[key] += 1
  except KeyError:
    d[key] = 1
    
d = sorted(d.items(), key=lambda x: x[1], reverse=True)

ans = []
max = 0
for i in d:
  if i[1] >= max:
    ans.append(i[0])
    max = i[1]
  else:
    break
    
for i in sorted(ans):
  print(i)

Solution (Python):
N = int(input())
dic = {}
for i in range(N):
    s = input()
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1
max_val = max(dic.values())
rst = [ key for key, val in dic.items() if val == max_val ]
[ print(i) for i in sorted(rst) ]

Solution (Python):
N = int(input())
dic = {}
for i in range(N):
    s = input()
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1
max_val = max(dic.values())
rst = [ key for key, val in dic.items() if val == max_val ]
[ print(i) for i in sorted(rst) ]

Solution (Python):
import collections

n = int(input())

li=[]


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

cnt = collections.Counter(li)
S = cnt.most_common()


C =len(cnt)

li_1 = [S[0][0]]

for i in range(C-1):
    if S[i][1] == S[i+1][1]:
        li_1.append(S[i+1][0])
    else:
        break

li_1.sort()

for i in li_1:
    print(i)

Solution (Python):
q=int(input())
dic={}
for i in range(q):
    s=input()
    if not s in dic:
        dic[s]=1
    else:
        dic[s]+=1
max_val=max(dic.values())
a=sorted([i for i, k in dic.items() if k == max_val])
for i in a:
    print(i)

Solution (Python):
from collections import defaultdict

n = int(input())
max_ = 0
dd = defaultdict(int)
for _ in range(n):
  s = input()
  dd[s] += 1
  max_ = max(max_, dd[s])
ans = []
for key, value in dd.items():
  if value == max_:
    ans.append(key)
ans.sort()
print(*ans, sep = "\n")

Solution (Python):
N = int(input())
dic = {}
for i in range(N):
    s = input()
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1
max_val = max(dic.values())
rst = [ key for key, val in dic.items() if val == max_val ]
[ print(i) for i in sorted(rst) ]

Solution (Python):

from collections import defaultdict


def main():
    N = int(input())
    dic = defaultdict(int)
    max_p = 0

    for i in range(N):
        dic[input()] += 1

    d = dict(dic)
    l = []

    for key, value in d.items():
        l.append([key, value])
        if max_p < value: max_p = value
    
    l.sort(key=lambda x: (-x[1], x[0]), reverse=False)

    for i, j in l:
        if j == max_p:
            print(i)
        else:
            break


if __name__ == "__main__":
    main()

Solution (Python):
from collections import defaultdict
n = int(input())
dic = defaultdict(int)
for i in range(n):
    dic[input()] += 1
tmp = [(key, value) for key, value in dic.items()]
tmp.sort(key=lambda x: (x[1], x[0]))
m = tmp[-1][1]
for i in range(len(dic)):
    if tmp[i][1] == m:
        print (tmp[i][0])

Solution (Python):
N = int(input())
dic = {}
for i in range(N):
    s = input()
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1
max_val = max(dic.values())
rst = [ key for key, val in dic.items() if val == max_val ]
[ print(i) for i in sorted(rst) ]

Solution (Python):
from collections import Counter
n=int(input())
s=Counter([input()for _ in[0]*n])
m=s.most_common(1)[0][1]
r=sorted((k for k,v in s.items() if v==m))
for a in r:print(a)

Solution (Python):
n = int(input())
L = list(input() for _ in range(n))
D = dict.fromkeys(set(L),0)

for l in L:
  D[l] += 1

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

for k, v in SD:
  if v == m:
    print(k)

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

for i in range(n):
    s = input()
    if s not in d:
        d.update({s: 1})
    else:
        d[s] += 1

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

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

from collections import Counter

cnt=Counter(S)
max_cnt=cnt.most_common()[0][1]
ans=[name for name, cnt in cnt.items() if cnt==max_cnt]
print(*sorted(ans), sep="\n")

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

from collections import Counter

cnt=Counter(S)
max_cnt=cnt.most_common()[0][1]
ans=[]
for k, v in cnt.items():
	if v!=max_cnt:
		continue
	ans.append(k)
print(*sorted(ans), sep="\n")

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

from collections import Counter

cnt=Counter(S)
max_cnt=cnt.most_common()[0][1]
ans=[]
for k, v in cnt.items():
	if v!=max_cnt:
		continue
	ans.append(k)

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

Solution (Python):
N = int(input())
dic, rst = {}, []
for i in range(N):
    s = input()
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1
max_val = max(dic.values())
rst = [ key for key, val in dic.items() if val == max_val ]
[ print(i) for i in sorted(rst) ]

Solution (Python):
n = int(input())
s = [input() for i in range(n)]
dic = {}
for i in range(n):
    if s[i] in dic.keys():
        dic[s[i]] += 1
    else:
        dic[s[i]] = 1
max1 = max(dic.values())
ans = []
for keys in dic.keys():
    if dic[keys] == max1:
        ans.append(keys)
ans.sort()
for i in ans:
    print(i)

Solution (Python):
n=int(input())
dic={}
for i in range(n):
    s=input()
    if not s in dic:
        dic[s]=1
    else:
        dic[s]+=1
max_val=max(dic.values())
a=sorted([i for i, k in dic.items() if k == max_val])
for i in a:
    print(i)

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

d = {}
for s in s_l:
    try:
        d[s] += 1
    except:
        d[s] = 1

max_c = max([ v for _,v in d.items() ])
ans = [ i for i, v in d.items() if v == max_c ]

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

Solution (Python):
N = int(input())
dic, rst = {}, []
for i in range(N):
    s = input()
    if not s in dic:
        dic[s] = 1
    else:
        dic[s] += 1
max_val = max(dic.values())
rst = [ key for key, val in dic.items() if val == max_val ]
[ print(i) for i in sorted(rst) ]

Solution (Python):
n = int(input())
d = {}
for i in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1
mx = max(d.values())
ans = ['']
for k, v in d.items():
    if v == mx:
        ans.append(k)
ans.sort()
print(*ans, sep='\n')

Solution (Python):
n = int(input())
d = {}
for i in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1
mx = max(d.values())
ans = ['']
for k, v in d.items():
    if v == mx:
        ans.append(k)
ans.sort()
print(*ans, sep='\n')

Solution (Python):
import collections
N=int(input())
s=[str(input()) for i in range(N)]
c=collections.Counter(s)
maximum =max(c.values()) 
max_c_list = sorted(key for key,value in c.items() if value == maximum)
for s in max_c_list:
  print(s)

Solution (Python):

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

def main():
    mod=10**9+7
    from collections import defaultdict
    dd = defaultdict(int)
    
    N=I()
    M=0
    for i in range(N):
        s=input()
        dd[s]+=1
        M=max(M,dd[s])
        
        
    ans=[]
    for k,v in dd.items():
        if v==M:
            ans.append(k)
            
    ans.sort()
    for k in ans:
        print(k)
        
    

main()

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


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

ma=dic[0][1]
for i,v in dic:
  if v!=ma:
    break
  else:
    print(i)

Solution (Python):
from collections import Counter

n = int(input())
s = Counter([str(input()) for _ in range(n)])
l = []
c = 1

for stri, count in s.items():
    if count == c:
        c = count
        l.append(stri)
    elif count > c:
        c = count
        l.clear()
        l.append(stri)


sort_l = sorted(l)

for i in sort_l:
    print(i)

Solution (Python):
N=int(input())
d=dict()
for _ in range(N):
    S=input()
    if S not in d:
        d[S]=0
    d[S]+=1
M=max(d.values())
ans=[]
for S in d.keys():
    if d[S]==M:
        ans.append(S)
ans.sort()
for S in ans:
    print(S)

Solution (Python):
N = int(input())
dic, rst = {}, []
for i in range(N):
    s = input()
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1
max_val = max(dic.values())
rst = [ key for key, val in dic.items() if val == max_val ]
[ print(i) for i in sorted(rst) ]

Solution (Python):
N = int(input())
S = [input() for i in range(N)]
ans = dict()
for i in range(N):
    if S[i] in ans:
        ans[S[i]] += 1
    else:
        ans[S[i]] = 1
ans = sorted(ans.items(), key=lambda x:x[1] , reverse = True)
i = 0
kotae = []
while i < len(ans) and ans[0][1] == ans[i][1]:
    kotae.append(ans[i][0])
    i += 1
kotae.sort()
for j in kotae:
    print(j)

Solution (Python):
N = int(input())
dic,rst = {}, []
for i in range(N):
    s = input()
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1
max_val = max(dic.values())
rst = [ key for key, val in dic.items() if val == max_val ]
[ print(i) for i in sorted(rst) ]

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

dct = {}

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

    else:
        dct[s] +=  1
    
m = max(dct.values())
for s in sorted(k for k in dct if dct[k] == m):
    print(s)

Solution (Python):
from collections import Counter

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

c = Counter(s)
m = c.most_common()[0][1]
k = list(c.keys())
v = list(c.values())

l = []
for i in range(len(c)):
  if v[i] == m:
    l.append(k[i])

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

Solution (Python):
n=int(input())
A=[]
for i in range(n):
    a=str(input())
    A.append(a)
import collections
c = collections.Counter(A)
ma= c.most_common()[0][1]
C=[i[0] for i in c.items() if i[1] >=ma ]
C.sort(reverse=False)
for j in range(len(C)):
    print(C[j])

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

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

Solution (Python):

from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
countS = Counter(S)
maxS = max(countS.values())
ans = []
for key,value in countS.items():
  if value == maxS:
    ans.append(key)

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

Solution (Python):
import collections
n = int(input())
l = []
for i in range(n):
  l.append(input())
c = collections.Counter(l)
m = max(c.values())
chars = [key for key, value in c.items() if value == m]
chars.sort()
for s in chars:
  print(s)

Solution (Python):
n = int(input())
s = [input() for _ in range(n)]
ans = []
d = {}
for i in s:
    try: d[i] += 1
    except KeyError: d[i] = 1
mx = 0
for value in d.values():
    if value > mx: mx = value
for key, value in d.items():
    if value == mx:
        ans.append(key)
for v in sorted(ans):
    print(v)

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

import collections
c = collections.Counter(s)
ans = []
most = c.most_common()
word,count = most[0]
ans.append(word)
for i in range(1,len(c)):
    wordi,counti = most[i]
    if counti == count:
        ans.append(wordi)
    else:
        break
ans.sort()
print(*ans, sep = "\n")

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

dic = {}

for x in range(n):
    a = input()
    dic.setdefault(a,0)
    dic[a] += 1

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

max_word = [k for k,v in dic2 if v == dic2[0][1] ]

max_word.sort()

for x in max_word:
    print(x)

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

S = sorted(dic.values())
t = S[-1]

X = []
for key in dic:
    if dic[key] == t:
        X.append(key)
x = sorted(X)

for i in range(len(X)):
    print(x[i])

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

maxI = max(dic.values())
ans = []

for keys in dic.keys():
    if dic[keys] == maxI:
        ans.append(keys)

ans.sort()

for i in ans:
    print(i)

Solution (Python):
from collections import Counter
import heapq

n = int(input())
sc = Counter()

for x in range(n):
  s = input()
  sc.update([s])

max_num = sc.most_common()[0][1]
q = []
for v in sc.items():
  if v[1] == max_num:
    heapq.heappush(q, v[0])

for _ in range(len(q)):
  print(heapq.heappop(q))

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

ss = dict()
for i in range(N):
    s = input()
    ss[s] = ss.get(s, 0) + 1
sss = [(-b, a) for a, b in ss.items()]
sss.sort()
maxa = sss[0][0]
for a, b in sss:
    if maxa != a:
        break
    print(b)

Solution (Python):
from collections import defaultdict

d = defaultdict(int)
for _ in range(int(input())):
    d[input()] += 1
mx = max(d.values())
print('\n'.join(sorted([k for k in d.keys() if d[k] == mx])))

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

dic = {}

for i in range(N):
  if S[i] not in dic.keys():
    dic[S[i]] = 1
    
  else:
    dic[S[i]] += 1
    
maxim = max(dic.values())
ans = []

for keys in dic.keys():
  if dic[keys] == maxim:
    ans.append(keys)
    
ans.sort()

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

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

for s in S:
    if c.get(s):
        c[s] += 1
    else:
        c[s] = 1


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

print('\n'.join(sorted(map(lambda x: x[0], filter(lambda x: x[1] == n_max, s_items)))))

Solution (Python):
n = int(input())
dd = {}
for i in range(n):
	s = input()
	if s in dd.keys():
		dd[s] += 1
	else:
		dd[s] = 1
ma = max(dd.values())
lst = []
for k, v in dd.items():
	if v == ma:
		lst.append(k)
for l in sorted(lst):
	print(l)

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

Solution (Python):
n = int(input())
d = {}
for i in range(n):
    s = input()
    d[s] = d.get(s, 0) + 1
m = max(d.values())
for s in sorted(s for s in d if d[s] == m):
    print(s)

Solution (Python):
from collections import defaultdict
charnums=defaultdict(int)
N=int(input())
for _ in range(N):
    charnums[input()]+=1
ans=[]
m=max(charnums.values())
for key,value in charnums.items():
    if value==m:
        ans.append(key)
for an in sorted(ans):
    print(an)

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

l=collections.Counter(S)
keys=l.keys()
k=max(l.values())
ans=[]
for i in keys:
  if l[i]==k:
    ans.append(i)

ans.sort()
n=len(ans)

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

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


def main():
    N = int(input())
    S = [input().rstrip() for _ in range(N)]
    c = collections.Counter(S).most_common()
    max_freq = None
    max_S = []
    for s, freq in c:
        if max_freq is None:
            max_freq = freq
            max_S.append(s)
        elif freq == max_freq:
            max_S.append(s)
        else:
            break
    print('\n'.join(sorted(max_S)))


if __name__ == "__main__":
    main()

Solution (Python):
import collections
N = int(input())
S = []
ans = []
for i in range(N):
  S.append(input())
d = collections.Counter(S)
ome = max(d.values())
for k, v in d.items():
  if v == ome:
    ans.append(k)
ans.sort()
for x in ans:
  print(x)

Solution (Python):
N = int(input())
S = [input() for i in range(N)]
d = {}
m = 0
for i in S:
    if i in d:
        d[i] += 1
        if d[i] > m:
            m = d[i]
    else:
        d[i] = 1
        
d = dict(sorted(d.items(), reverse=True))
a = {}
for i in d.keys():
    if m <= d[i]:
        a[i] = 0
a = sorted(a)
for i in a:
    print(i)

Solution (Python):
N = int(input())
S = [input() for i in range(N)]
d = {}
m = 0
for i in S:
    if i in d:
        d[i] += 1
        if d[i] > m:
            m = d[i]
    else:
        d[i] = 1
        
d = dict(sorted(d.items(), key = lambda x:x[1], reverse=True))
a = {}
for i in d.keys():
    if m <= d[i]:
        a[i] = 0
a = sorted(a)
for i in a:
    print(i)

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):
import collections
N = int(input())
S = [input() for i in range(N)]
S = sorted(S)


C = collections.Counter(S)

M = C.most_common()
V = C.values()
MAX = max(V)

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

Solution (Python):
import os, sys, re, math

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

d = {}
for s in S:
    if not s in d:
        d[s] = 0
    d[s] += 1

d = sorted(d.items(), key=lambda x:x[1], reverse=True)
names = [v[0] for v in d if v[1] == d[0][1]]

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

Solution (Python):
import math
import statistics
import collections
a=int(input())






g = [input() for _ in range(a)]




g.sort()

ma=0
count=1

for i in range(a-1):
    if g[i]==g[i+1]:
        count+=1
    else:
        ma=max(ma,count)
        count=1

ma=max(ma,count)
count=1
ans=[]

for i in range(a-1):
    if g[i]==g[i+1]:
        count+=1
    else:
        if count==ma:
            ans.append(g[i])
        count=1
if count==ma:
    ans.append(g[-1])

for i in ans:
    print(i)

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

res = 0
cnt = 1
for i in range(N-1):
    if S[i] == S[i+1]:
        cnt+=1
    else:
        res = max(res,cnt)
        cnt = 1

res = max(res,cnt)

cnt = 1
ans = []
for i in range(N-1):
    if S[i] == S[i+1]:
        cnt+=1
    else:
        if res == cnt:
            ans.append(S[i])
        cnt = 1

if cnt == res:
    ans.append(S[i+1])

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

Solution (Python):
import collections
n = int(input())
ans = list(input() for i in range(n))
ans = collections.Counter(ans)
m = max(ans.values())
keys = [k for k, v in ans.items() if v == m]
[print(j) for j in sorted(keys)]

Solution (Python):
from collections import defaultdict

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

l = [(-n, s) for s, n in counter.items()]
l.sort()
m = l[0][0]

for x, s in l:
    if x != m:
        break
    print(s)

Solution (Python):
from collections import Counter
n = int(input())
s = list(input() for i in range(n))
c = Counter(s)
m = max(c.values())
s = sorted(list(set(s)))
for i in range(len(s)):
    if c[s[i]] == m:
        print(s[i])

Solution (Python):
N = int(input())
A = {}
for i in range(N):
  s = input()
  if s in A:
    A[s] += 1
  else:
    A[s] = 1
s_max = max(A.values())
for j in sorted(k for k in A if A[k] == s_max):
  print(j)

Solution (Python):
N = int(input())
L = []
res = []

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

L.sort()

max_cnt = 0
cnt = 0

L.append(0)

for i in range(len(L) - 1):
    if L[i] == L[i+1]:
        cnt += 1
    else:
        if cnt > max_cnt:
            max_cnt = cnt
            res = []
            res.append(L[i])
        elif cnt == max_cnt:
            res.append(L[i])
        cnt = 0

for i in res:
    print(i)

Solution (Python):
N = int(input())
L = []
res = []

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

L.sort()

max_cnt = 0
cnt = 0

L.append(0)

for i in range(len(L) - 1):
    if L[i] == L[i+1]:
        cnt += 1
    else:
        if cnt > max_cnt:
            max_cnt = cnt
            res = []
            res.append(L[i])
        elif cnt == max_cnt:
            res.append(L[i])
        cnt = 0

for i in res:
    print(i)

Solution (Python):
n=int(input())
ans={"b":0}
ma=0
pr=[]
for i in range(n):
    name=input()
    if name in ans.keys():
        ans[name]=ans[name]+1
    else:
        ans[name]=1
for j,k in ans.items():
    if k>ma:
        ma=k 
        pr=[j]
    elif k==ma:
        pr.append(j)
pr.sort()
for l in pr:
    print(l)

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
d = []
s = set()
dd = {}
ind = 0
for i in range(n):
    x = input()
    if x in s:
        d[dd[x]][1] += 1
    else:
        dd[x] = ind
        d.append([x,1])
        ind += 1
        s.add(x)
d.sort(key = lambda x:x[1], reverse = True)

res = []
for key,va in d:
    if va < d[0][1]:
        break
    res.append(key)
res.sort()
for x in res:
    print(x)

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

from  collections import defaultdict
from collections import Counter
def main():
    N = I()
    s_list = []
    for i in range(N):
        s = S()
        s_list.append(s)
    c = Counter(s_list)
    a = max(c.values())
    ans_list = []
    for key in c.keys():
        if c[key] == a:
            ans_list.append(key)
    ans_list.sort()
    for ans in ans_list:
        print(ans)



if __name__ == "__main__":
    main()

Solution (Python):
from collections import defaultdict

def main():
    N = int(input())

    dd = defaultdict(int)

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

    maxv = max(dd.items(), key = lambda item: item[1])[-1]
    strings = [key for key, val in dd.items() if val == maxv]

    strings = sorted(strings)

    for string in strings:
        print(string)

if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter
n = int(input())
s = list(input() for i in range(n))
c = Counter(s)
m = max(c.values())
s = sorted(list(set(s)))
for i in range(len(s)):
    if c[s[i]] == m:
        print(s[i])

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

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

vmax=max(Sdict.values())




anskeys = [k for k, v in Sdict.items() if v == vmax]
for ans in sorted(anskeys):
	print(ans)

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

dic = dict()
count = 0
for i in range(N):
    t = input()
    if t not in dic:
        dic[t] = 1
        if count==0:
            count += 1
    if t in dic:
        dic[t] += 1
        if count < dic[t]:
            count = dic[t]

ans = list()
for s in dic.keys():
    if dic[s] == count:
        ans.append(s)

ans.sort()

[print(s) for s in ans]

Solution (Python):
N = int(input())
l = []
for i in range(N):
    l.append(input())
l.sort()
a = l[0]
k = [1]
n = [str(l[0])]
for i in range(1,N):
    if a == l[i]:
        k[-1] += 1
    else:
        a = l[i]
        k.append(1)
        n.append(l[i])
m = max(k)
ans = []
for i in range(len(k)):
    if k[i] == m:
        ans.append(n[i])

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

Solution (Python):
from collections import defaultdict
n = int(input())
dic = defaultdict(int)
for i in range(n):
  dic[input()] += 1
max_s = max(dic.values())
for k, v in sorted(dic.items()):
  if v == max_s:
    print(k)

Solution (Python):
import collections
n=int(input())
s = [(input()) for _ in range(n)]
c = collections.Counter(s)
b = max(c.values())
l = [key for key in c.keys() if c[key] == b]
l.sort()
for i in l:
    print(i)

Solution (Python):
from collections import Counter
n = int(input())
s = [input() for i in range(n)]
num = Counter(s)
mx = max(num.values())
for i in sorted(num):
    if num[i] == mx:
        print(i)

Solution (Python):
N = int(input())
dic, rst = {}, []
for i in range(N):
    S = input()
    if S in dic:
        dic[S] += 1
    else:
        dic[S] = 1
max_val = max(dic.values())
[ rst.append(key) for key, val in dic.items() if val == max_val ]
[ print(i) for i in sorted(rst) ]

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



 

dic = {}
for i in range(N):
  s = S[i]
  if s not in dic: dic[s] = 1
  else: dic[s] += 1

max_count = max(dic.values()) 
 

l = [key for key in dic.keys() if dic[key] == max_count]
 

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

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

 

dic = {}
for i in range(N):
  s = S[i]
  if s not in dic: dic[s] = 1
  else: dic[s] += 1

max_count = max(dic.values()) 
 

l = [key for key in dic.keys() if dic[key] == max_count]
 

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

Solution (Python):
from collections import defaultdict
def main():
    n = int(input())
    s =defaultdict(lambda:0)
    for i in range(n):
        s[input()] += 1
    max_s = max(s.values())
    for key, value in sorted(s.items()):
        if value == max_s:
            print(key)

if __name__ == "__main__":
    main()

Solution (Python):

def main():
    from collections import defaultdict

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

    d = defaultdict(int)
    for s in S:
        d[s] += 1
    
    
    d = sorted(d.items(), key=lambda d: d[1], reverse=True)
    res = d[0][1]
    lst = []
    for i in d:
        if res > i[1]:
            break
        lst.append(i[0])
        res = i[1]
    for i in sorted(lst):
        print(i)


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

sai = max(dic.values())

for j in sorted(k for k in dic if dic[k] == sai):
  print(j)

Solution (Python):
N = int(input())
words = {}
for _ in range(N):
  word = input()
  if word in words:
    words[word] += 1
  else:
    words[word] = 1
sorted_words = sorted(words.items(), key=lambda x: (-x[1], x[0]))
max_v = sorted_words[0][1]
for k, v in sorted_words:
  if v == max_v:
    print(k)
  else:
    exit()

Solution (Python):
import sys
mapin = lambda: map(int, sys.stdin.readline().split())
listin = lambda: list(map(int, sys.stdin.readline().split()))
inp = lambda: sys.stdin.readline()

N = int(inp())
mp = {}
for i in range(N):
    S = inp()
    S = S[:-1]
    if S in mp:
        mp[S] += 1
    else:
        mp[S] = 1
ans = 0
vec = []
for i in mp.values():
    if ans < i:
        ans = i
for i in mp.keys():
    if mp[i] == ans:
        vec.append(i)
vec.sort()
for i in vec:
    print(i)

Solution (Python):
N=int(input())
S=[]
for _ in range(N):
    _=input()
    S.append(_)
import collections
a=collections.Counter(S)
b=max(a.values())
new_a=[k for k, v in a.items() if v==b]
new_a.sort()
for i in range(len(new_a)):
    print(new_a[i])

Solution (Python):
N = int(input())
A1 = {}
for i in range(N):
  s = input()
  if s in A1:
    A1[s] += 1
  else:
    A1[s] = 1
sai = max(A1.values())
for j in sorted(k for k in A1 if A1[k] == sai):
  print(j)

Solution (Python):
from collections import Counter

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

c = Counter(s)
m = max(list(c.values()))
d = sorted(c.items(), key=lambda x: x[1], reverse=True)

t = set()
for i, j in d:
    if j == m:
        t.add(i)
    else:
        break
for i in sorted(t):
    print(i)

Solution (Python):
from collections import Counter

def solve():
    N = int(input())
    c = Counter([input() for _ in range(N)])
    cnt = -1
    ans = []
    for i in c.most_common():
        if cnt == -1:
            cnt = i[1]
            ans.append(i[0])
        elif cnt == i[1]:
            ans.append(i[0])
        else:
            break
    for a in sorted(ans):
        print(a)
    
if __name__ == "__main__":
    solve()

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

input = sys.stdin.readline
lis = {}
for i in range(N):
  s = input().rstrip()
  if s in lis:
    lis[s] += 1
  else:
    lis[s] = 1
lis2 = sorted(lis.items(), key=lambda x:x[1], reverse=True)
x = next(iter(lis2))
keys = []
for i in lis2:
  if i[1] == x[1]:
    keys.append(i[0])
ans = sorted(keys)
for i in ans:
  print(i)