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):
def resolve():
    N = int(input())
    from collections import defaultdict
    cnt = defaultdict(int)
    for _ in range(N):
        cnt[input()] += 1
    items = sorted(cnt.items(), key=lambda x: (-x[1], x[0]))
    max_v = items[0][1]
    for item in items:
        if max_v != item[1]:
            break
        print(item[0])

resolve()

Solution (Python):
from collections import defaultdict
from collections import OrderedDict

N = int(input())

words = dict()
wordsFromValue = defaultdict(list)

for idx in range(N) :
  word = str(input())
  
  if word in words :
    words[word] += 1
  else :
    words[word] = 1
  
for key, value in sorted(words.items()) :
  wordsFromValue[value].append(key)
  
for val in wordsFromValue[max(wordsFromValue)] : 
  print(val)

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


s=collections.Counter(S).most_common()
s.sort(key=lambda x: x[0])
s.sort(key=lambda x: x[1], reverse=True)
for k, v in s:
    if v==s[0][1]:
        print(k)
    else:
        break

Solution (Python):
N=int(input())
S=[input() for i in range(N)]
cnt={}
maxCnt=0
for s in S:
    if s in cnt:
        cnt[s]+=1
    else:
        cnt[s]=1
    if(cnt[s]>maxCnt):
        maxCnt=cnt[s]
for s in sorted(cnt.keys()):
    if cnt[s]==maxCnt:
        print(s)

Solution (Python):

import collections

n = int(input())

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

c = collections.Counter(S)
m = c.most_common()[0][1]
ans = []
for _c in c.items():
    if _c[1] == m:
        ans.append(_c[0])

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

Solution (Python):
from collections import Counter

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

c = Counter(s)
c = c.most_common()
c.sort(key=lambda x: x[0])
c.sort(key=lambda x: x[1], reverse=True)

most_cnt = c[0][1]
for key, cnt in c:
    if cnt == most_cnt:
        print(key)
    else:
        break

Solution (Python):
str_list = []
n = int(input())
a = {}
name_list = []
for i in range(n):
    name = input()
    a[name] = 0
    name_list.append(name)
    
    

for i in name_list:
    a[i] += 1
    
    
max_val = max(a.values())
a = sorted(a.items())
for i in range(len(a)):
    if a[i][1] == max_val:
        print(a[i][0])

Solution (Python):
from collections import Counter
N = int(input())
S = []
for _ in range(N):
  S.append(input())
C = Counter(S).most_common()
_,M = C[0]
L = []
for a,b in C:
  if b == M:
    L.append(a)
print(*sorted(L) ,sep = "\n")

Solution (Python):
from collections import defaultdict
from collections import OrderedDict

N = int(input())

words = dict()
wordsFromValue = defaultdict(list)

for idx in range(N) :
  word = str(input())
  
  if word in words :
    words[word] += 1
  else :
    words[word] = 1
  
for key, value in sorted(words.items()) :
  wordsFromValue[value].append(key)
  

for val in wordsFromValue[max(wordsFromValue)] : 
  print(val)

Solution (Python):
n=int(input())
s=[input() for i in range(n)]
s=sorted(s)
poll=[s[0]]
counta=[1]
kind=0
for i in range(1,n):
  if s[i]==s[i-1]:
    counta[kind]+=1
  else:
    kind+=1
    poll.append(s[i])
    counta.append(1)
m=max(counta)
for i in range(kind+1):
  if counta[i]==m:
    print(poll[i])

Solution (Python):
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

n=ni()
dic= {}
for i in range(n):
    s=ns()
    if s in dic:
        dic[s]+=1
    else:
        dic[s]=1
maxnum=0
for i in dic.items():
    if maxnum<i[1]:
        maxnum=i[1]
ans=[]
for i in dic.items():
    if maxnum==i[1]:
        ans.append(i[0])
ans.sort()

for i in ans:
    print(i)

Solution (Python):
import collections

N=int(input())
S=[]
for i in range(N):
	S.append(input())
M=collections.Counter(S)
A=max(M.values())
tmp=[]
for i,j in M.items():
	if j==A:
		tmp.append(i)
ans=sorted(tmp)
for i in range(len(ans)):
	print(ans[i])

Solution (Python):
import collections
n = int(input())
c = [0 for _ in range(n)]
for i in range(n):
    c[i] = input()
c = collections.Counter(c).most_common()
ans = []
first = c[0][1]
for i in c:
    if i[1] == first:
        ans.append(i[0])

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

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

max=max(c.values())

ans=[]
for i,j in c.items():
    if j == max:
        ans.append(i)
ans=sorted(ans)
print('\n'.join(ans))

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

counts = [val for (key, val) in word_count.items()]
max_count = max(counts)
words = sorted([key for (key, val) in word_count.items() if val == max_count])
for word in words:
    print(word)

Solution (Python):
import sys

from collections import defaultdict
from operator import itemgetter

def main():
    N = int(input())
    d = defaultdict(int)
    for _ in range(N):
        s = input()
        d[s] -= 1

    cnt = list(d.items())
    cnt.sort(key=itemgetter(1,0))
    
    mc = cnt[0][1]
    for x,y in cnt:
        if y == mc:
            print(x)
        else:
            break
    
if __name__ == "__main__":
    main()

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

x = set(S)
d = {}
for i in x:
    d[i] = 0
for s in S:
    d[s]+=1

y = 0
for key, value in d.items():
    y = max(y, value)
name = []
for key, value in d.items():
    if value==y:
        name.append(key)
name.sort()
for n in name:
    print(n)

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

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

a=max(x.values())
keys=[k for k,v in x.items() if v==a]
answer=sorted(keys)
  
for a in answer:
  print(a)

Solution (Python):
from collections import defaultdict
dd = defaultdict(int)
a=int(input())
li =[]
for i in range(a):
    b=input()
    li.append(b)
for b in li:
    dd[b] += 1
M = 1
l=[]
for i in dd.keys():
    if dd[i] > M:
        M = dd[i]
        l = []
        l.append(i)
    elif dd[i] == M:
        l.append(i)
    else:
        continue
l.sort()
for i in range(len(l)):
    print(l[i])

Solution (Python):
import collections


def main():
    n = int(input())
    word_list = [input() for _ in range(n)]
    
    c = collections.Counter(word_list)
    max_freq = max(c.values())
    most_freq_word = sorted([i for i in c if c[i] == max_freq])
    print('\n'.join(most_freq_word))


if __name__ == '__main__':
    main()

Solution (Python):
import collections


def main():
    n = int(input())
    word_list = []

    for _ in range(n):
        word_list.append(input())

    c = collections.Counter(word_list)
    max_freq = max(c.values())
    most_freq_word = sorted([i for i in c if c[i] == max_freq])
    print('\n'.join(most_freq_word))


if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter

n = int(input())
ss = []
for _ in range(n):
    ss.append(input().rstrip())
ctr = Counter(ss)

a = sorted([(-v, k) for k, v in ctr.items()])
maxv = a[0][0]
for i in range(len(a)):
    if a[i][0] != maxv:
        break
    print(a[i][1])

Solution (Python):
from collections import Counter
import heapq

n = int(input())
ss = []
for _ in range(n):
    ss.append(input().rstrip())
ctr = Counter(ss)
heap = [(-v, k) for k, v in ctr.items()]
heapq.heapify(heap)
maxv = heap[0][0]
while heap:
    c = heapq.heappop(heap)
    if c[0] != maxv:
        break
    print(c[1])

Solution (Python):





import collections

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

c = collections.Counter(l)
number_of_words = len(c)
counted_list = c.most_common()
ans_before_sort = [counted_list[0][0]]

for i in range(number_of_words-1):
    if counted_list[i][1] == counted_list[i+1][1]:
        ans_before_sort.append(counted_list[i+1][0])
    else:
        break

ans_after_sort = sorted(ans_before_sort)
print('\n'.join(ans_after_sort))

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

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

import collections

c = collections.Counter(str_list)

x = c.most_common()
str_list_2 = []

num = x[0][1]
for i in x:
    if i[1] != num:
        break
    else:
        str_list_2.append(i[0])

str_list_2.sort()

for i in str_list_2:
    print(i)

Solution (Python):
from collections import Counter

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

sorted_si = Counter(si).most_common()
last = -1
names = []
for s in sorted_si:
    if last <= s[1]:
        names.append(s[0])
        last = s[1]

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

Solution (Python):
import collections

N=int(input())
S=[]
for i in range(N):
	S.append(input())
M=collections.Counter(S)
A=max(M.values())
tmp=[]
for i,j in M.items():
	if j==A:
		tmp.append(i)
ans=sorted(tmp)
for i in range(len(ans)):
	print(ans[i])

Solution (Python):
import collections                                                              
                                                                                
N = int(input())                                                                
S = []                                                                          
for i in range(N):                                                              
    S.append(input().strip())                                                   
counter = collections.Counter(S)                                                
common_word_num = counter.most_common()[0][1]                                   
                                                                                
ans = [i[0] for i in counter.items() if i[1] == common_word_num]                
ans.sort()                                                                      
for w in ans:                                                                   
    print(w)

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

a = Counter(s)

b = a.most_common()[0][1]

s = list(set(s)) 
s.sort()

for i in s:
    if a[i] == b:
        print(i)

Solution (Python):
import collections
n = int(input())
a = [input() for _ in range(n)]
c = collections.Counter(a).most_common()
m = []
saidai = c[0][1]
for i in c:
  if saidai <= i[1]:
    m += [i[0]]
m.sort()
print('\n'.join(m))

Solution (Python):
import collections

n = int(input())
s = [input() for i in range(n)]
c = collections.Counter(s)
x = c.most_common()[0][1]

s = list(set(s))
s.sort()

for item in s:
  if c[item] == x:
  	print(item)

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

s.sort()
count=1
maximum=0

for j in range (N-1):
  if s[j]==s[j+1]:
    count+=1
    if j==N-2:
      if count>maximum:
        a=[]
        a.clear()
        a.append(s[j])
        maximum=count
        number=1
      elif count==maximum:
        a.append(s[j])
        number+=1
  else:
    if count>maximum:
      a=[]
      a.clear()
      a.append(s[j])
      maximum=count
      number=1
    elif count==maximum:
      a.append(s[j])
      number+=1
    count=1   
  if maximum==1 and j==N-2:
    a.append(s[N-1])
    number+=1
for p in range (number):
  print(a[p])

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


ans = []
max = 0
tmp = 1

for i in range(1,n):
  if s[i] == s[i-1]:
    tmp += 1
  if s[i] != s[i-1]:
    if max == tmp:
      ans.append(s[i-1])
    if max < tmp:
      ans = [s[i-1]]
      max = tmp
    tmp = 1

if max == tmp:
  ans.append(s[n-1])
if max < tmp:
  ans = [s[n-1]]
  
for i in ans:
  print(i)

Solution (Python):
import collections
N = int(input())
arr = [input() for i in range(N)]
c = collections.Counter(arr)


MAX = max(c.values())
ans = sorted([x for x in c if c[x] == MAX])

for i in ans:
    print(i)

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

l=[]
x = [input() for _ in range(a)]
count=Counter(x)
x=count.most_common()
x.sort()
y=x.copy()
y.sort(key=lambda x:x[1],reverse=True)
tmp=y[0][1]
for i in x:
    if tmp <= i[1]:
        l.append(i[0])
        tmp=i[1]

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

Solution (Python):
import collections
N=int(input())
S=list(input() for i in range(N))
S=collections.Counter(S)
S=S.most_common()
if len(S)==1:
  print(S[0][0])
elif S[0][1]>S[1][1]:
  print(S[0][0])
else:
  s=[i for i in S if i[1]==S[0][1]]
  s=dict(s)
  s=list(s.keys())
  s=sorted(s)
  for i in s:
    print(i)

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

dict=collections.Counter(S)

std=sorted(dict)

M=max(dict.values())
for el in std:
   if dict[el]==M:
       print(el)

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
Max = max(d.values())
keys = [k for k, v in d.items() if v == Max]
keys.sort()
for k in keys:
    print(k)

Solution (Python):
n = int(input())
cnt = {}
mx = 0
for i in range(n):
  s = input()
  if s not in cnt:
    cnt[s] = 0
  cnt[s] += 1
  mx = max(mx,cnt[s])
ans = []
for s in cnt:
  if cnt[s] == mx:
    ans.append(s)
ans.sort()
for i in ans:
  print(i)

Solution (Python):


n = int(input())



dictionary = dict()


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

    
    if data in dictionary:
        dictionary[data] += 1
    else:
        dictionary[data] = 0





data_sorted = sorted(dictionary.items(), key=lambda x: x[0])

data_sorted = sorted(data_sorted, key=lambda x: x[1], reverse=True)


count = data_sorted[0][1]
for key, val in data_sorted:
    if count == val:
        print(key)
    else:
        exit

Solution (Python):
n = int(input())
d = {}
for i in range(n):
    s = str(input())
    if s in d.keys():
        d[s] += 1
    else:
        d[s] = 1
max = max(d.values())
k = [x for x, y in d.items() if y ==max]
k.sort()
for i in k:
    print(i)

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):
n=int(input())
s=[""]*n
dic={}
for i in range(n):
  a=input()
  if (a in dic):
    dic[a]+=1
  else:
    dic[a]=1

v_max=max(dic.values())
keys=[k for k,v in dic.items() if v==v_max ]
keys=sorted(keys)
for i in range(len(keys)):
  print(keys[i])

Solution (Python):
from collections import deque, Counter
n = int(input())
s = deque([])
for i in range(n):
    s.append(input())
s_count = Counter(s).most_common()
s_count.sort()
s_count.sort(key=lambda x: x[1], reverse=True)
cnt_max = -1
for word, cnt in s_count:
    if cnt_max == -1:
        cnt_max = cnt
    if cnt_max == cnt:
        print(word)
    else:
        break

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

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

max_count = max(count_list.values())
key = [k for k, v in count_list.items() if v == max_count]
key.sort()
for k in key:
    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):
N = int(input())
dic = {}

for i in range(N):
  S = input()
  if S in dic:
    dic[S] += 1
  else:
    dic[S] = 1
    
max_N = max(list(dic.values()))
keys = sorted([k for k, v in dic.items() if v == max_N])

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

Solution (Python):

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


from collections import Counter
kazu_word = Counter(word)


kazu_word_a = max(kazu_word.values()) 
kazu_word_max =[i for i,v in kazu_word.items() if v == kazu_word_a ]
kazu_word_max_sorted = sorted(kazu_word_max)
"""
print(kazu_word)
print(kazu_word_max)
"""
print(*kazu_word_max_sorted,sep="\n")

Solution (Python):
n = int(input())
l =[input() for i in range(n)]
r=[]
d={}
for i in l:
    if i in d:
        d[i]+=1
    else:
        d[i]=1
m = max(d.values())
for key,value in d.items():
    if value==m:
        r.append(key)
sorted_r = sorted(r)
print(*sorted_r,sep='\n')

Solution (Python):
n = int(input())
d = dict()
m = 0
for _ in range(n):
    x = input()
    if x in d:
        d[x] += 1
    else:
        d[x] = 1
    if m < d[x]:
        m = d[x]
for p in sorted([e for e in iter(d) if d[e] == m]):
    print(p)

Solution (Python):
n=int(input())
D={}
ma=1
for i in range(n):
    s=input()
    if s in D:
        D[s]+=1
        ma=max(ma,D[s])
    else:
        D[s]=1

L=[]
for i in D:
    if D[i]==ma:
        L.append(i)
L.sort()
for i in L:
    print(i)

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

n_dict = {}

for i in S:
    if i not in n_dict:
        n_dict[i] = 1
    else:
        n_dict[i] +=1
    
m = max(n_dict.values())
ans =[]
for k, v in n_dict.items():
    if v == m:
        ans.append(k)

ans.sort()

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

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

S.sort()
S_dict = {}
for key in S:
    S_dict[key] = 0

for key in S:
    S_dict[key] += 1

max_value = max(S_dict.values())

ans = []
for key in S_dict:
    if S_dict[key] == max_value:
        ans.append(key)
ans.sort()

for i in ans:
    print(i)

Solution (Python):
'''
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineerin College
    Date:24/03/2020
'''

def main():
    
    
    n=int(input())
    m={}
    for i in range(n):
        s=input()
        if s not in m:
            m[s]=1
        else:
            m[s]+=1
    maxv=0
    a=[]
    for i in m.keys():
        maxv=max(maxv,m[i])
    for i in m.keys():
        if(m[i]==maxv):
            a.append(i)
    a.sort()
    for i in a:
        print(i)
        
















    
    
if __name__ =="__main__":
    main()

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

Solution (Python):
N = int(input())
result = {}
maximum = 1
for i in range(N):
    S = input()
    if S in result:
        result[S] += 1
        maximum = max(maximum, result[S])
    else:
        result[S] = 1
for name in sorted(result):
    if result[name] == maximum:
        print(name)

Solution (Python):
from collections import Counter

N, *S = open(0).read().split()
count = Counter(S)
max_value = max(count.values())
ans_list = [i for i, j in count.items() if j == max_value]
ans_list.sort()
print("\n".join(ans_list))

Solution (Python):
from collections import Counter

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

count = Counter(S).most_common()
mode = count[0][1]
count.sort()

for i in range(len(count)):
    if count[i][1] == mode:
        print(count[i][0])

Solution (Python):
from collections import Counter

N = int(input())
S = []
for i in range(N):
  S.append(input())
S.sort()
c = Counter(S).most_common()
m = c[0][1]
c.sort()
for i in range(len(c)):
    if c[i][1] == m:
      print(c[i][0])

Solution (Python):
import collections
import itertools

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

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

ans = []
ans.append(l[0][0])
for i in range(len(l)-1):
    if l[i+1][1] == x:
        ans.append(l[i+1][0])
    else:
        break

ans.sort()

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

Solution (Python):
N = int(input())
S = [input() for _ in range(N)]
from collections import Counter
C = Counter(S)
kv = [(k,v) for k,v in C.items()]

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

for k in ans: print(k)

Solution (Python):
from collections import Counter
N = int(input())
S = [input() for i in range(N)]
C = Counter(S)
freq = max(C.values())
M = [kv[0] for kv in C.items() if kv[1] == freq]
M.sort()
A = '\n'.join(M)
print(A)

Solution (Python):
from collections import Counter
N = int(input())
S = [input() for i in range(N)]
C = Counter(S)
dekai = max(C.values())
M = [kv[0] for kv in C.items() if kv[1] == dekai]
M.sort()
A = '\n'.join(M)
print(A)

Solution (Python):
import collections
n = int(input())
s = []
for _ in range(n):
    s.append(input())
ss = collections.Counter(s)
s_most = ss.most_common()

ans = []

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

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

S = {}

A = [""]*N
for i in range(0, N):
    A[i] = A[i] + input()

for i in range(0, N):
    if not (A[i] in S.keys()):
        S[A[i]] = 1
    else:
        S[A[i]] = S[A[i]] + 1

max = 0
for value in S.values():
    if value > max:
        max = value

S0 = {}
n = 0
for key, value in S.items():
    if value == max:
        S0[key] = 0
        n += 1

T = [""]*n
i = 0
for key in S0.keys():
    T[i] = key
    i += 1

T.sort()
for p in range(0, n):
    print(T[p])

Solution (Python):
import collections

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

lis=collections.Counter(S)

max_lis_v=sorted(list(lis.values()))[-1]
lis_i=sorted(list(lis.items()))

for i in lis_i:
    if i[1]==max_lis_v:
        print(i[0])

Solution (Python):
from collections import Counter
import sys
n = int(sys.stdin.readline())
sn = sys.stdin.read().split()
c = Counter(sn)
num = max(c.values())
ans = [i for i, j in c.items() if j == num]
ans.sort()
print('\n'.join(ans))

Solution (Python):
l =[]
r=[]
n = int(input())
for i in range(n):
    l.append(input())
d={}
for i in l:
    if i in d:
        d[i]+=1
    else:
        d[i]=1
print()
m = max(d.values())
for key,value in d.items():
    if value==m:
        r.append(key)
sorted_r = sorted(r)
print(*sorted_r,sep='\n')

Solution (Python):
from collections import Counter
n = int(input())
s = []
for i in range(n):
  si = input()
  s.append(si)
  
C = Counter(s)
s_num = C.values()
m = max(s_num)
s_max = []
for k, v in C.items():
  if v == m:
    s_max.append(k)
s_max = sorted(s_max)
for sj in s_max:
  print(sj)

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

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

ans = [s[0][0]]
v = s[0][1]
for i in range(1,len(s)) :
  if s[i][1] != v :
    break
  ans.append(s[i][0])
ans.sort()

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

Solution (Python):

''' ===========================================



=========================================== '''
import sys
from sys import stdin 
input = stdin.readline
import heapq 
import collections 
sys.setrecursionlimit(10**6)
INF = 1<<50

if __name__ == '__main__':
    n = int(input())
    
    sip = []
    for i in range(n):
        sip.append(input().replace("\n",""))
    cnt = collections.Counter(sip)
    
    num_max = max(cnt.values())
    ans = [i for i, j in cnt.items() if j == num_max]
    ans.sort()
    
    print('\n'.join(ans))

Solution (Python):
N = int(input())
ls = [input() for _ in range(N)]
ans_ls = []
from collections import Counter
c = Counter(ls)
m = sorted(c.values())[-1]
for k,v in c.items():
    if v == m:
        ans_ls.append(k)
ans_ls.sort()
print(*ans_ls,sep="\n")

Solution (Python):


import collections

N = int(input())
S = [""] * N
dic = {}
for i in range(N):
    S = input()
    if S in dic:
        dic[S] += 1
    else:
        dic[S] = 1

maxs = max(list(dic.values()))
ans = []
for i in dic:
    if dic[i] == maxs:
        ans.append(i)
ans = sorted(ans)
for i in ans:
    print(i,end=" ")
print("")

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_N = max(list(dic.values()))
keys = sorted([k for k, v in dic.items() if v == max_N])

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

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

C = collections.Counter(A).most_common()
ans = []
for k, v in C:
    if v == C[0][1]:
        ans.append(k)

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

Solution (Python):
from collections import Counter

n = int(input())

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

c = Counter(strings)

times = 0
ans_list = []
for item in c.most_common():
    if not times:
        times = item[1]
    elif times != item[1]:
        break

    ans_list.append(item[0])

ans_list.sort()

for ans in ans_list:
    print(ans)

Solution (Python):
from collections import Counter

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

c = Counter(s)
max_count = max(c.values())

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

ans.sort()

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

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

c = Counter(s)
max_count = max(c.values())

for k, v in c.items():
    if v == max_count:
        ans.append(k)
ans.sort()
print('\n'.join(ans))

Solution (Python):

from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
s = Counter(s).most_common()

x0 = s[0][1]
ans = []
for t, x in s:
    if x == x0:
        ans.append(t)
ans.sort()
print('\n'.join(ans))

Solution (Python):
import collections as co
N = int(input())
names = [input() for _ in range(N)]
names = co.Counter(names)
maxval = max(names.values())
for ans in sorted(names):
    if names[ans] == maxval:
        print(ans)

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

word = {}
ans={}
for i in range(N):
    s=input()
    if s in word:
        word[s]+=1
    else:
        word[s]=1
    

M=max(word.values())


for key in word:
    if word[key] == M:
        cnt=0
        for i in range(len(key)):
            cnt+=ord(key[i])-ord('a')
        ans.setdefault(key, cnt)
        
        
for value in sorted(ans.keys()):
    print(value)

Solution (Python):
from collections import*
n,*s=open(0)
cnt=Counter(s).most_common()
ans=sorted(a*(b==cnt[0][1])for a,b in cnt)
for i in ans:
    print(i,end="")

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


m = max(D.values())

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

Y = []
for i in D:
    if i[1] == m:
        Y.append(i[0])
        
Y.sort()

for i in Y:
    print(i)

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


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

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

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

Solution (Python):
import collections
N=int(input())
S=list(input() for _ in range(N))
S=collections.Counter(S)
maxnum=max(S.values())
[print(res) for res in sorted([s for s in S if S[s]==maxnum])]

Solution (Python):
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
ans = []
charctor_count = Counter(s)
max_count = max(charctor_count.values())
for k, v in charctor_count.items():
  if v == max_count:
    ans.append( k)
print("\n".join(sorted(ans)))

Solution (Python):
N = int(input())
Si = [""] * N

for n in range(N):
  Si[n] = input()
Si = sorted(Si)

newSi = ["",0]*N
cnt = 0
newSi[0] = [Si[0],1]
maxnum = 1
for n in range(1,N):
  if Si[n] == newSi[cnt][0]:
    newSi[cnt][1] = newSi[cnt][1] + 1
    if newSi[cnt][1] > maxnum: maxnum = newSi[cnt][1]
  else:
    cnt = cnt+1
    newSi[cnt] = [Si[n],1]

for c in range(cnt+1):
  if newSi[c][1] == maxnum: print(newSi[c][0])

Solution (Python):
from sys import stdin
from collections import defaultdict

N = int(stdin.readline().rstrip())
S = [stdin.readline().rstrip() for i in range(N)]

D = defaultdict(int)

for s in S:
    D[s] += 1

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

for a in ans:
    if a[1] < ans[0][1]:
        break
    print(a[0])

Solution (Python):
n = int(input())
name = {}
for i in range(n):
    st = str(input())
    if st in name:
        tmp = name[st] + 1
        name[st] = tmp
    else:
        name[st] = 1

max_val = max(name.values())
max_name = [k for k, v in name.items() if v==max_val]
max_name = sorted(max_name)

for n in max_name:
    print(n)

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 = sorted(dic.items(), key=lambda x:x[1], reverse=True)
ans = []
s = []
for k, v in dic_sorted:
    s.append(v)
pre = s[0]
for k, v in dic_sorted:
    if v == pre:
        ans.append(k)
    else:
        break
ans.sort()
for i in ans:
    print(i)

Solution (Python):
n=int(input())
A=[]
for i in range(n):
  A.append(input())
from collections import Counter
C=Counter(A)
qq=max(C.values())
ans=[]
for word,times in C.items():
  if times==qq:
    ans.append(word)
ans.sort()
for i in range(len(ans)):
  print(ans[i])

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

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

s_c = Counter(s).most_common()
m = s_c[0][1]

ans = []

for j in range(len(s_c)):
    if s_c[j][1] != m:
        break
    else:
        ans.append(s_c[j][0])
        
ans.sort()

for k in ans:
    print(k)

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

def main():
    N = int(input())
    dic = {}
    for i in range(N):
        s = input().strip()
        if s in dic:
            dic[s] += 1
        else:
            dic[s] = 1
    
    dic = sorted(dic.items(), key=lambda x: (-x[1], x[0]))
    n = dic[0][1]
    for i in range(len(dic)):
        if dic[i][1] == n:
            print(dic[i][0])
        else:
            break


if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
from collections import defaultdict
d = defaultdict(int)
for i in range(N):
  d[input()] += 1

max_cnt = max(d.values())
for v in sorted([key for key,value in d.items() if value == max_cnt]):
  print(v)