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())

words = {}
for i in range(n):
    str = input()
    if words.get(str) is None:
        words[str] = 1
    else:
        words[str] += 1
        
max_num = max(words.values())
max_items = []

for x in words.items():
    if x[1] >= max_num:
        max_items.append(x[0])

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

Solution (Python):


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





dic = {}

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

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

for s in dic:
    if dic[s] == maxValue:
        ans.append(s)

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

Solution (Python):
from collections import Counter
n=int(input())
a=[]
for _ in range(n):
  a.append(input())
x=Counter()
for i in a:
  x[i]+=1
maxi=0
for i in x.keys():
  maxi=max(maxi,x[i])
ans=[]
for i in x.keys():
  if maxi==x[i]:
    ans.append(i)

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

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

Solution (Python):
N = int(input())
S = []
for i in range(N):
    S.append(input())
S.sort()
MAX = 0
cnt = 0
WORD = []
for i in range(N):
    if i == 0:
        cnt = 1
        MAX = 1
        WORD.append(S[i])
    elif S[i] == S[i-1]:
        cnt+=1
        if cnt == MAX:
            WORD.append(S[i])
        if cnt > MAX:
            MAX = cnt
            WORD.clear()
            WORD.append(S[i])
    else:
        cnt = 1
        if cnt == MAX:
            WORD.append(S[i])

for ans in WORD:
    print(ans)

Solution (Python):
from collections import Counter

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

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

for name in counter.keys():
    if m==counter[name]:
        result.append(name)

result_sort=sorted(result)

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

Solution (Python):

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

c = collections.Counter(S)
mx = max(c.values())

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

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

Solution (Python):
import collections

ans = []
n = int(input())
s = [input() for _ in range(n)]
dic = collections.Counter(s).most_common()
max_num = dic[0][1]
for k, v in dic:
    if v == max_num:
        ans.append(k)
    else:
        break
ans.sort()
print("\n".join(ans))

Solution (Python):
import collections
n = int(input())
s = [input() for _ in range(n)]
c = collections.Counter(s)
C = c.most_common()
most_count = C[0][1]
answer = []

for i in range(len(C)):
  if most_count == C[i][1]:
    answer.append(C[i][0])

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

Solution (Python):
from collections import Counter

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

s = Counter(S)
max_cnt = s.most_common()[0][1]
names = [name for name, cnt in s.items() if cnt == max_cnt]
names.sort()

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

Solution (Python):
from collections import Counter

n = int(input())
s = [input() for i in range(n)]
c = Counter(s)
c.most_common()
ans = []
m = -1
for i, item in enumerate(c.most_common()):
    if i == 0:
        m = item[1]
        ans.append(item[0])
    elif item[1] == m:
        ans.append(item[0])
    else:
        break
ans.sort()
print(*ans, sep='\n')

Solution (Python):
from collections import Counter

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

s = Counter(S)
max_cnt = max(s.values())
names = [name for name, cnt in s.items() if cnt == max_cnt]
names.sort()

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

Solution (Python):
N=int(input())
S = {}
for i in range(N):
    let = input()
    try:
        S[let] += 1
    except:
        S[let] = 1
max_val = max(S.values())
answers = []
for k,v in S.items():
    if v == max_val:
        answers.append(k)
answers.sort()
for ans in answers:
    print(ans)

Solution (Python):
def list_count(my_list):
    dic={} 
    for num in my_list:
        if num in dic: 
            dic[num]+=1 
        else: 
            dic[num]=1 
    return dic
n=int(input())
a=[input() for i in range(n)]
b=list_count(a)
m=max(b.values())
c=[]

for i in range(n):
    
    if b[a[i]]==m:
        c.append(a[i])
c=sorted(list(set(c)))
for s in c:
    print(s)

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

_dict = {}
max_cnt = 0
for n in range(N):
  _ = input()
  if _ not in _dict:
    _dict[_] = 1
  else:
    _dict[_] += 1
    
  if _dict[_] > max_cnt:
    max_cnt = _dict[_]


ans = [k for k, v in _dict.items() if v == max_cnt]
ans.sort()
for _ in ans:
  print(_)

Solution (Python):
import collections

n = int(input())

S = []
ans = []
key = []
max = 0
for i in range(n):
    s = input('')
    S.append(s)
c = collections.Counter(S)
C = sorted(c.items(), key = lambda x:x[1],reverse = True)

for k in c.keys():
    key.append(k)
for i in range(len(C)):
    max = C[0][1]
    if c[key[i]] == max:
        ans.append(key[i])
ans = sorted(set(ans))
for i in ans:
    print(i)

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

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

mx=0
result=[]
for key,value in d.items():
  if mx < value:
    mx = value
    result=[key]
  elif mx == value:
    result.append(key)

result.sort()

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

Solution (Python):
import collections
N = int(input())
S = [input() for _ in range(N)]
c = collections.Counter(S)
C=c.most_common()
result = []
for i in range(len(C)):
  if C[i][1] == C[0][1]:
    result.append(C[i][0])
  else:
    break
result.sort()
for j in range(len(result)):
  print(result[j])

Solution (Python):
import collections

def solve(N, Ss):
    counter = collections.Counter()
    counter.update(Ss)
    max_count = counter.most_common()[0][1]
    ans = []
    for s, count in counter.most_common():
        if count == max_count:
            ans.append(s)

    return "\n".join(sorted(ans))

if __name__ == "__main__":
    N = int(input())
    Ss = []
    for _ in range(N):
        Ss.append(input())
    print(solve(N, Ss))

Solution (Python):
import collections
n = int(input())
s_list = [input() for i in range(n)]
c_dict = collections.Counter(s_list).most_common()
ans_list = [c[0] for c in c_dict if c[1] == c_dict[0][1]]
print(*sorted(ans_list), sep="\n")

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

s = {}

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

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

Solution (Python):
from sys import stdin, stdout
from collections import defaultdict
n = int(stdin.readline().strip())
word_map = defaultdict(lambda: 0)
maxi = 0
for i in range(n):
  word = stdin.readline().strip()
  x = word_map[word]
  word_map[word] = x + 1
  maxi = max(maxi, x+1)
  
word_list = []
for key, value in word_map.items():
  if value == maxi:
    word_list.append(key)
word_list.sort()
for word in word_list:
  stdout.write(word+'\n')

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

s_cnt = {}
for _ in range(n):
    s = input()
    if s in s_cnt.keys():
        s_cnt[s] += 1
    else:
        s_cnt[s] = 1

data = sorted(s_cnt.items(),
              key=lambda item: (-item[1], item[0]), reverse=True)

val = data[-1][1]
for item in reversed(data):
    if item[1] != val:
        break
    print(item[0])

Solution (Python):
import collections

N = int(input())
A =[]
for i in range(N):
    A.append(input())
    
ans =[]
c = collections.Counter(A)
m = c.most_common()
ma = m[0][1]

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

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

Solution (Python):
import collections

N = int(input())
A =[]
for i in range(N):
    A.append(input())
    
ans =[]
c = collections.Counter(A)
m = c.most_common()
ma = m[0][1]

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

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

Solution (Python):
d = {}
n = int(input())
for _ in range(n):
    let = input()
    try:
        d[let] += 1
    except:
        d[let] = 1
max_val = max(d.values())
print('\n'.join(sorted(key for key in d if d[key] == max_val)))

Solution (Python):
import collections

n = int(input())
strings = list()
for line in range(0,n):
    strings.append(str(input()))

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

outputs = list()
for key , val in c.items():
    if val == most_common:
        outputs.append(key)

outputs = sorted(outputs)
for line in outputs:
    print(line)

Solution (Python):


from fractions import gcd
import math

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

yes = 'APPROVED'
no = 'DENIED'

def main():
    n = ii()
    s = []
    for i in range(n):
        tmp = input()
        s.append(tmp)
    
    s = sorted(s)

    anslist = []

    cnt = 0
    cntmax = 0
    tmp = ""
    for i in range(n):
        if cntmax == 0:
            anslist.append(s[i])
        if s[i] == tmp:
            cnt+=1
            if cntmax == cnt:
                anslist.append(s[i])
            if cntmax < cnt:
                cntmax = cnt
                anslist = [s[i]]
        else:
            cnt = 0
            tmp = s[i]
    for i in range(len(anslist)):
        print(anslist[i])



main()

Solution (Python):
N = int(input())
s = [input() for i in range(N)]
import collections
s1 = sorted(s)
 
c = collections.Counter(s1)
s2 = c.most_common()
 
s3 = []
a = 0
for i in range(len(s2)):
    if s2[0][1] == s2[i][1]:
        s3.append(s2[i][0])
s4 = sorted(s3)
for i in range(len(s4)):
    print(s4[i])

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

count = collections.Counter(temp)
counter = 1
ll = count.most_common()
for i in range(len(ll) -1):
    if ll[i][1] == ll[i + 1][1]:
        counter += 1
    else:
        break

l = count.most_common(counter)
l.sort()
for i in range(len(l)):
    print(l[i][0])

Solution (Python):
import collections
n = int(input())
S = [input() for i in range(n)]
c = collections.Counter(S)
li = c.most_common()
M = li[0][1]
ans = []
for x in li:
    if x[1] == M:
        ans.append(x[0])
    else:
        break
ans.sort()
for x in ans:
    print(x)

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 = [name for name, cnt in counter.items() if cnt == max_cnt]
names.sort()
 
print(*names, sep='\n')

Solution (Python):
from collections import Counter


def main():
    N = int(input())
    A = [input() for _ in range(N)]

    C = Counter(A)
    most_c = C.most_common()
    max_num = most_c[0][1]
    ANS = []
    for c in most_c:
        if c[1] < max_num:
            break
        ANS.append(c[0])
    ANS.sort()
    for ans in ANS:
        print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter


def main():
    N = int(input())
    A = [input() for _ in range(N)]

    c = Counter(A)
    max_num = c.most_common()[0][1]
    ANS = [i[0] for i in c.items() if i[1] == max_num]
    ANS.sort()
    for ans in ANS:
        print(ans)


if __name__ == '__main__':
    main()

Solution (Python):


n = input()
ss = [raw_input() for _ in xrange(n)]

ws = {}
for s in ss:
    if s not in ws:
        ws[s] = 1
    else:
        ws[s] += 1

m = max(ws[k] for k in ws)
for x in sorted(k for k in ws if ws[k] == m):
    print x

Solution (Python):
from collections import Counter


def main():
    N = int(input())
    A = [input() for _ in range(N)]

    C = Counter(A)
    most_c = C.most_common()
    max_num = most_c[0][1]
    ANS = []
    for c in most_c:
        if c[1] < max_num:
            break
        ANS.append(c[0])
    for ans in sorted(ANS):
        print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter


def main():
    N = int(input())
    A = [input() for _ in range(N)]

    c = Counter(A)
    d = c.most_common()
    ans = [i[0] for i in c.items() if i[1] == d[0][1]]
    for i in sorted(ans):
        print(i)


if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter


def main():
    N = int(input())
    A = [input() for _ in range(N)]

    c = Counter(A)
    d = c.most_common()
    ans = []
    for i in c.items():
        if i[1] == d[0][1]:
            ans.append(i[0])
    for i in sorted(ans):
        print(i)


if __name__ == '__main__':
    main()

Solution (Python):
import collections
from sys import stdin
N = int(stdin.readline().rstrip())
data = []
for i in range(N):
    s = (stdin.readline().rstrip())
    data.append(s)
c = collections.Counter(data)
maxc = max(c.values())
for j in sorted(c.keys()):
    if c[j] == maxc:
        print(j)

Solution (Python):

import collections

N = int(input())
S=[]
l=[]

for i in range(N):
    S.append(input())
c=collections.Counter(S)

m=max(c.values())

for i in c:
    if c[i]==m:
        l.append(i)

l.sort()

for i in l:
    print(i)

Solution (Python):
N=int(input())
dc={}
for i in range(N):
    key=input()
    if key not in dc:
        dc[key]=1
    else:
        dc[key]+=1
max=0
lst=[]
for i in dc:
  if dc[i]>max:
    max=dc[i]
    lst.clear()
    lst.append(i)
  elif dc[i]==max:
    lst.append(i)
lst.sort()
for i in lst:
  print(i)

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

c = collections.Counter(strs)
maxv = -1
ans = []
for k , v in c.most_common():
  if v != maxv and maxv != -1:
    break
  ans.append(k)
  maxv = v
for a in sorted(ans):
  print(a)

Solution (Python):
def calc(N, S):
    d = {}
    n_max = 0
    for s in S:
        d[s] = 1 + (d[s] if s in d else 0)
        n_max = max(n_max, d[s])
    result = [s for s in d.keys() if d[s] == n_max]
    result.sort()
    return '\n'.join(result)


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

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

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

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

max = S[0][1]
for k, v in S:
    if max != v:
        sys.exit()
    print(k)

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

T = [[S[0]]]
for i in S[1:N]:
  if i == T[-1][-1]:
    T[-1].append(i)
  else:
    T.append([i])
T.sort(key=lambda x: len(x))
U = []

for i in T[::-1]:
  if len(i) == len(T[-1]):
    U.append(i[0])
  else:
    break

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

Solution (Python):
import collections
from collections import OrderedDict


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


c = OrderedDict(collections.Counter(S))
ln = len(c.values())


d = OrderedDict(sorted(c.items(), key = lambda x : x[1], reverse=True))
dval = list(d.values())
dkey = list(d.keys())


word = list()
word.append(dkey[0])
i=1
if ln>1:
    while dval[i-1]==dval[i]:
        word.append(dkey[i])
        i+=1
        if i==ln:
            break


dic = sorted(word)


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

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

from collections import Counter
dict_C = Counter(list_S)
max = max(dict_C.values())

keys = [k for k,v in dict_C.items() if v == max]
keys.sort()

for ans in keys :
    print(ans)

Solution (Python):
N = int(input())
ans = {}
for i in range(N):
    a = input()
    ans[a] = ans.get(a,0) + 1

t = max(ans.values())
ans2 = [k for k, v in ans.items() if v ==t ]
ans2.sort()
[print(i) for i in ans2]

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())
s = {}
m = 1
for _ in range(n):
    t = input()
    if t in s:
        s[t] += 1
        if s[t] > m:
            m = s[t]
    else:
        s.update({t : 1})
ans = [i for i, j in s.items() if j == m]
ans.sort()
for i in ans:
    print(i)

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

votes = {}
for i in range(n):
  s = input()
  votes[s] = votes.get(s,0) + 1

max_v = max(list(votes.values()))
res = [k for k,v in votes.items() if v == max_v]

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

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

for n in range(N):
    S = input()

    if S in S_dic:
        S_dic[S] += 1
    else:
        S_dic[S] = 1



max_value = max(S_dic.values())

max_S_list = [k for k, v in S_dic.items() if v == max_value]
max_S_list = sorted(max_S_list)

for max_S in max_S_list:
    print(max_S)

Solution (Python):
from collections import Counter
def main(n,s):
    c = Counter(s)
    maxVal = max(c.values())
    res = sorted([k for k,v in c.items() if v == maxVal])
    return res

n = int(input())
s = [input() for _ in range(n)]
for i in main(n,s):
    print(i)

Solution (Python):
import collections
import heapq

n = int(input())
l = [input() for _ in range(n)]
c = collections.Counter(l)
max_count = 0
ans = []
for word, count in c.most_common():
  if(max_count <= count):
    heapq.heappush(ans, word)
    max_count = count
  else:
    break
for _ in range(len(ans)):
  print(heapq.heappop(ans))

Solution (Python):
import collections
strlist = []
answer = []
N = int(input())
for i in range(N):
    strlist.append(str(input()))
    
c = collections.Counter(strlist)
p = max(c.values())
ans = sorted([k for k,v in c.items() if p==v])
print('\n'.join(ans))

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

maxnum=0

for i in range(0,n,1):
	name = input()
	
	if name in dic:
		dic[name] = dic[name]+1
	else:
		dic[name] = 1
	
	if dic[name] > maxnum:
		maxnum = dic[name]

for name in dic.keys():
	if dic[name] == maxnum:
		list.append(name)
		
for i in sorted(list):
	print(i)

Solution (Python):
from collections import Counter

N = int(input())
S = [input() for _ in range(N)]
c = Counter(S)
m = max(c.values())
ans = sorted([k for k,v in c.items() if m==v])
print('\n'.join(ans))

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

cdic = {}
for i in range(N):
    si = input()
    if si not in cdic.keys():
        cdic[si] = 1
    else:
        cdic[si] += 1
        
spair = sorted(cdic.items(), key=lambda x:x[1], reverse=True)






vmax = -1
maxes = []
for pair in spair:
    if pair[1] >= vmax:
        maxes.append(pair[0])
        vmax = pair[1]
    else:
        break
        

smaxes = sorted(maxes)



for s in smaxes:
    print(s)

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

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

maxi = 0
lst = []
for key in dic.keys():
    if dic[key] > maxi:
        maxi = dic[key]
        lst = [key]
    elif dic[key] == maxi:
        lst.append(key)

lst = sorted(lst)
for i in lst:
    print(i)

Solution (Python):

import collections
n=int(input())
words = [input() for _ in range(n)]
count = collections.Counter(words)
leng = len(count)
ansallay = []

record = count.most_common()[0][1]
ms=count.most_common()
for num in range(leng):
    if(ms[num][1] == record):
        ansallay.append(ms[num][0])
    else:
        break
ansallay.sort()
for word in ansallay:
    print(word)

Solution (Python):
import math
import sys

max=0
N = int(input())
dict = {}
for _ in range(N):
    S = input()
    
    if S in dict:
        dict[S] = dict[S] + 1
    else:
        dict[S] = 1

    if max < dict[S]:
        max = dict[S]

    

lists = []
for s, n in dict.items():
    if n == max:
        lists.append(s)

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

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


M = max(Sdict.values())
ans = []
for k in Sdict.keys():
    if Sdict[k] == M:
        ans.append(k)

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

Solution (Python):
N = int(input())
S = {}
name_list = []
for i in range(N):
  name = input()
  if name not in S:
    S[name] = 1
    name_list.append(name)
  else:
    S[name] += 1
name_list = sorted(name_list)
max_vote_name = []
max_vote = -float('inf')
for name in name_list:
  if S[name] > max_vote:
    max_vote = S[name]
    max_vote_list = [name]
  elif S[name] == max_vote:
    max_vote_list.append(name)
for name in max_vote_list:
  print (name)

Solution (Python):
def main():
  n = int(input())
  dict = {}
  for i in range(n):
    s = input()
    dict.setdefault(s, 0)
    dict[s] += 1
  max_val = 0
  ans_ls = []
  for kv in dict.items():
    if kv[1] > max_val:
      max_val = kv[1]
      ans_ls = [kv[0]]    
    elif kv[1] == max_val:
      ans_ls.append(kv[0])
  ans_ls = sorted(ans_ls)
  for name in ans_ls:
    print(name)
 
 
if __name__ == '__main__':
  main()

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

set_key = list(set(s))
set_key.sort()
dic = dict(zip(set_key, [0]*len(set_key)))

for c in s:
  dic[c] += 1

n_max = max(dic.values())

for c in set_key:
  if dic[c] == n_max:
    print(c)

Solution (Python):
a = {}

for s in [input() for _ in range(int(input()))]:
  if s in a: a[s] += 1
  else: a[s] = 1

a = sorted(a.items(), key=lambda x:x[1], reverse=True)
n = a[0][1]
i = 1
while i < len(a) and a[i][1] == n: i += 1
a = a[:i]
a = sorted(a, key=lambda x:x[0])

for s,t in a:
  print(s)

Solution (Python):
n = int(input())
s = sorted([input() for i in range(n)])
s_ = sorted(list(set(s)))
if len(s_) != n:
    s.append(0)
    co = [1] + [0 for i in range(len(s_)-1)]
    ind = 0
    for i in range(1, n):
        if s[i-1] == s[i]:
            co[ind] += 1
        else:
            ind += 1
            co[ind] += 1
    ma = max(co)
    arg = [i for i in range(len(s_)) if co[i]==ma]
    ans = [s_[i] for i in arg]
    print("\n".join(sorted(ans)))
    
else:
    print("\n".join(s))

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

max_num = max(c.values())

result = [i[0] for i in c.items() if i[1]==max_num]
result.sort()
 
for i in range(len(result)):
    print(result[i])

Solution (Python):
from collections import Counter
N=int(input())
lis=list(input() for _ in range(N))
ans=[]

counter=Counter(lis)
high=counter.most_common()[0][1]

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

Solution (Python):
N = int(input())
S_dict = {}
for i in range(0, N):
  char = input()

  if char in S_dict:
    S_dict[char] += 1
  else:
    S_dict[char] = 1

S_dict_sorted = sorted(S_dict.items(), key=lambda x: -x[1])
_, value = S_dict_sorted[0]
ans_list = []
for k, v in S_dict_sorted:
  if value == v:
    ans_list.append(k)

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

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

counter = {}
max_count = 0
for _ in range(N):
    s = input()
    n = counter.get(s, 0) + 1
    max_count = max(max_count, n)
    counter[s] = n

most_common = (k for k, v in counter.items() if v == max_count)
for s in sorted(most_common):
    print(s)

Solution (Python):
from collections import Counter
n = int(input())
prev = -1
for k, v in sorted(Counter(input() for _ in range(n)).most_common(), key=lambda kv: (-kv[1], kv[0])):
    if prev > 0 and prev != v:
        break
    print(k)
    prev = v

Solution (Python):
n=int(input())
dic = {}
for i in range(n):
    st=input()
    dic.setdefault(st,0)
    dic[st]+=1
ans=0
answers=[]
for k,v in dic.items():
    if v==ans:
        ans=v
        answers.append(k)
    elif v>ans:
        ans=v
        answers=[k]
answers.sort()
for ans in answers:
    print(ans)

Solution (Python):
def main():
    import sys
    from collections import Counter

    N = int(input())
    S = [sys.stdin.readline().rstrip('\n') for _ in range(N)]
    c = Counter(S)
    _max = max(c.values())
    keys = [k for k, v in c.items() if v == _max]
    print('\n'.join(sorted(keys)))

if __name__ == '__main__':
    main()

Solution (Python):
num = input()

strs = []

for i in range(int(num)):
  strs.append(input())

strs.sort()

b = ""
cnt = 0
max = -1
maxstr = set()

for s in strs:
  if b == s:
    cnt += 1
  else:
    cnt = 0
  if cnt > max:
    max = cnt
    maxstr.clear()
    maxstr.add(s)
  elif cnt == max:
    maxstr.add(s)
  b = s

ls = list(maxstr)
ls.sort()
for m in ls:
  print(m)

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

dic = {}
for j in range(i):
    word = input()
    if word in dic:
        dic[word] += 1
    else:
        dic[word] = 1


dic2 = sorted(dic.items(), key=lambda x:x[1])
k = len(dic2)-1
s = 0
ans = []
for p in range(len(dic2)):
    t = dic2[k][1]
    ans.append(dic2[k][0])
    k -= 1
    if t == dic2[k][1]:
        s = 1
    else:
        break
ans.sort()
for ak in ans:
    print(ak)

Solution (Python):
n = int(input())
dic = {}
for i in range(n):
    string = input()

    if string in dic:
        dic[string] += 1
    else:
        dic[string] = 0

answers = []
app = 0

for key, value in dic.items():
    if value > app:
        answers.clear()
        answers.append(key)
        app = value
    elif value == app:
        answers.append(key)

answers.sort()
for ans in answers:
    print(ans, sep="\n")

Solution (Python):
def main():
    from collections import Counter

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

    c = Counter(S)
    _max = max(c.values())

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

if __name__ == '__main__':
    main()

Solution (Python):
def main():
    from collections import Counter

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

    c = Counter(S)
    _max = max(c.values())

    keys = [k for k, v in c.items() if v == _max]

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


if __name__ == '__main__':
    main()

Solution (Python):

def main():
    from collections import Counter
    
    N = int(input())
    S = [input() for _ in range(N)]
    
    c = Counter(S)
    _max = max(c.values())
    
    ans = []
    for k, v in c.items():
        if v == _max:
           ans += [k]
    
    for a in sorted(ans):
        print(a)


if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter

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

c = Counter(S)
_max = max(c.values())

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

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

Solution (Python):
import collections

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

c = collections.Counter(s)
common = c.most_common()

count = common[0][1]
ans = []
for i in common:
  if i[1] == count:
    ans.append(i[0])
  else:
    break
ans.sort()
print(*ans,sep='\n')

Solution (Python):
dic = {}
N = int(input())
for i in range(N):
    tmp = input()
    if tmp in dic:
        dic[tmp] += 1
    else:
        dic[tmp] = 1
m = max(sorted(dic.values()))
ans = []
for i in dic.items():
    if i[1] == m:
        ans.append(i[0])
for i in sorted(ans):
    print(i)

Solution (Python):
N = int(input())
lis = []
indexes = []
cou = 1
ans = []
c_p = 0
for _ in range(N):
  lis.append(input())
lis.sort()
if len(lis) != len(set(lis)):
  lis.append("zzzzzzzzzzzzzz")
  for i in range(N):
    if lis[i] == lis[i+1]:
      cou += 1
    else:
      indexes.append(cou)
      cou = 1
  L = len(indexes)
  M = max(indexes)
  for k in range(L):
    if indexes[k] == M:
      ans.append(lis[c_p])
    c_p += indexes[k]
  print(*ans)
else:
  print(*lis)

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

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

dict_sorted = sorted(list(dict1.items()), key = lambda x: x[0])
dict_sorted.sort(key = lambda x: x[1], reverse = True)

max1 = dict_sorted[0][1]

for i in range(len(dict_sorted)):
    if dict_sorted[i][1] == max1:
        print(dict_sorted[i][0])
    else:
        break

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

Di={"":0}

for i in range(N):
    poll=str(input())
    
    if poll in Di.keys():
        Di[poll] += 1
    else:
        Di[poll] = 1


Di=sorted(Di.items())
Di.remove(("",0))

maxvalue=0
maxkey=[]


for k in Di:
    if k[1] > maxvalue:
        maxvalue=k[1]
        maxkey=[]
        maxkey.append(k[0])
    elif k[1] == maxvalue:
        maxkey.append(k[0])

for m in maxkey:
    print(m)

Solution (Python):
import collections
N = int(input())
s = []
for _ in range(N):
    s.append(input())
word_nums = collections.OrderedDict(sorted(collections.Counter(s).items(), key=lambda x: x[1], reverse=True))
max_num = max(list(word_nums.values()))
output = []
for i, j in word_nums.items():
    if max_num == j:
        output.append(i)
    else:
        break
for i in sorted(output):
    print(i)

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

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

ans=[]
for word,c in counter.most_common():
    if c==m:
        ans.append(word)
    else:
        break

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

Solution (Python):
import collections

n = int(input())
li = list()

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

key = list(collections.Counter(li).keys())
value = list(collections.Counter(li).values())
ans = list()
maxValue = max(value)

for i in range(len(value)):
    if maxValue == value[i]:
        ans.append(key[i])

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

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)