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

count = 1
ans = []
dict = {}

for i in range(n):
    s = input()
    if s in dict:
        dict[s] += 1
        count = max([count,dict[s]])
    else:
        dict[s] = 1

for k in dict:
    if dict[k]==count:
        ans.append(k)

ans.sort()

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

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

dic = {}
for i in range(n):
  str = input()
  if str in dic:
    nowNum = dic.get(str)
    dic[str] = nowNum+1
  else:
    dic[str] = 1

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

answerString = []
answerString.append(dic_sorted[0][0])
nowCnt = dic_sorted[0][1]

for i in range(len(dic_sorted)-1):
  if dic_sorted[i+1][1] == nowCnt:
    answerString.append(dic_sorted[i+1][0])
  else:
    break

last = sorted(answerString)

for result in last:
  print(result)

Solution (Python):


def solve():
    N = int(input())
    dic = {}

    max_num = -1
    for i in range(N):
        S = input()
        if not S in dic: dic[S] = 0
        dic[S] += 1

        if dic[S] > max_num:
            max_num = dic[S]

    anss = []
    for key, value in dic.items():
        if value == max_num:
            anss.append(key)

    anss.sort()

    for ans in anss:
        print(ans)


if __name__ == "__main__":
    solve()

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
max_v = max(dic.values())
mv_str = []
for k, v in dic.items():
    if v == max_v:
        mv_str.append(k)
ans = sorted(mv_str)
print('\n'.join(map(str,ans)))

Solution (Python):
from collections import Counter

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

c = Counter(x)
y = c.most_common()
c_m = (c.most_common(1))[0][1]
z = []
for j in range(len(y)):
    if y[j][1] == c_m:
        z.append(y[j][0])
z.sort()
for result in z:
    print(result)

Solution (Python):
import collections

N = int(input())
S = [input() for i in range(N)]
c =collections.Counter(S)
C = c.most_common()
list_C = []
for i in range(len(c)):
    list_C.append(C[i][1])
m = 1
for i in range(len(list_C)-1):
    if list_C[i]==list_C[i+1]:
        m += 1
    else:
        break
ans= []
for i in range(m):
    ans.append(C[i][0])
ans = sorted(ans)
for i in range(len(ans)):
    print(ans[i])

Solution (Python):
from collections import defaultdict

def solve():
    N = int(input())
    d = defaultdict(int)
    m = 0
    for _ in range(N):
        a = input()
        d[a] += 1
        m = max(d[a], m)

    l = []
    for k, v in d.items():
        if m == v:
            l.append(k)
    l.sort()
    for ans in l:
        print(ans)
    
solve()

Solution (Python):
from collections import defaultdict

def solve():
    N = int(input())
    d = defaultdict(int)
    for _ in range(N):
        a = input()
        d[a] += 1

    m = 0
    for k, v in d.items():
        m = max(m, v)
    
    l = []
    for k, v in d.items():
        if m == v:
            l.append(k)
    l.sort()
    for ans in l:
        print(ans)
    
solve()

Solution (Python):
dic = {}
max_v = 0
for _ in range(int(input())):
    k = input()
    v = dic.get(k, 0) + 1
    max_v = max(max_v, v)
    dic[k] = v

lst = sorted([k for k, v in dic.items() if v == max_v])
print("\n".join(lst))

Solution (Python):
n=int(input())
S=[]
ans=0
import collections
for i in range(n):
    s=input()
    S.append(s)
S=sorted(S)
c=collections.Counter(S)
ANS=[]
for i in range(n-1):
    if (S[i]!=S[i+1] and ans<c[S[i]]) or i==n-2:
        ans=c[S[i]]
        ANS.append(ans)
inko=""
ans=max(ANS)
for i in range(n):
    if c[S[i]]==ans and S[i]!=inko:
        print(S[i])
        inko=S[i]

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

value_dict = {}

for x in range(N):
    value = input()
    if value not in value_dict.keys():
        value_dict[value] = 1
        continue
    value_dict[value] += 1

max_count = max(value_dict.values())
max_values = [k for k, v in value_dict.items() if v == max_count]
max_values.sort()


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

Solution (Python):
N = int(input())
S = [input() for _ in range(0, N)]
t = {}
for i in range(0, N):
    if S[i] in t:
        t[S[i]] += 1
    else:
        t[S[i]] = 1
vmax = max(t.values())
ans = []
for key in t.keys():
    if t[key] == vmax:
        ans.append(key)
ans.sort()
for i in ans:
    print (i)

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

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

Solution (Python):
import collections as cl

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

c = cl.Counter(S_list)
most_common = c.most_common()

max_count = most_common[0][1]
key_list = []
for item in most_common :
    if (item[1] == max_count) :
        key_list.append(item[0])
        continue
    
    break

key_list.sort()
for key in key_list :
    print(key)

Solution (Python):
from collections import defaultdict
from operator import itemgetter
d = defaultdict(int)
n = int(input())
for i in range(n):
  d[input()] += 1
m = max(d.values())
l = [i for i in d.keys() if d[i] == m]
l.sort()
print(*l,sep='\n')

Solution (Python):
n = int(input())
dct = {}
for _ in range(n):
    s = input()
    if s in dct:
        dct[s] += 1
    else:
        dct[s] = 1
m = max(dct.values())
ans = []
for a, v in dct.items():
    if v == m:
        ans.append(a)
ans.sort()
for a in ans:
    print(a)

Solution (Python):
import collections
N = int(input())
S = [str(input()) for i in range(N)]
li = collections.Counter(S)
MAX = li.most_common()[0][1]
li = li.most_common()
li.sort(key=lambda x:x[0])

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

Solution (Python):
n=int(input())
seq=[]
for i in range(n):
    seq.append(input())
dic={}
for i in range(n):
    if seq[i] in dic:
        dic[seq[i]]+=1
    else:
        dic[seq[i]]=1
M=0
for i in dic.values():
    M=max(M,i)
l=[]
for i in dic.keys():
    if dic[i]==M:
        l.append(i)
for i in sorted(l):
    print(i)

Solution (Python):
N = int(input())
d = {}
for i in range(N):
    s = input()
    if s in d:
        d[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]

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

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

for i in range(n):
  word = input()
  if word in words_dic.keys():
    words_dic[word] += 1
  else:
    words_dic[word] = 0

max_num = max(words_dic.values())

for word, i in sorted(words_dic.items(), key=lambda x:x[0]):
  if i == max_num:
    print(word)

Solution (Python):
n = int(input())
data = {}
max_poll = 1

for i in range(n):
    s = input()
    try:
        data[s] += 1
    except:
        data[s] = 1
    if max_poll < data[s]:
        max_poll = data[s]

winner = []
for key, value in data.items():
    if max_poll == value:
        winner.append(key)

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

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

data = {}
names = []
max_poll = 1

for i in range(n):
    s = input()
    try:
        data[s] += 1
    except:
        data[s] = 1
        names.append(s)
    if max_poll < data[s]:
        max_poll = data[s]

winner = []
for key, value in data.items():
    if max_poll == value:
        winner.append(key)

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

Solution (Python):
from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
C = Counter(S)
l = []
max = C.most_common(1)[0][1]
for c in C.most_common():
    if max == c[1]:
        l.append(c[0])
    else:
        break
l.sort()
print("\n".join(l))

Solution (Python):
from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
C = Counter(S)
l = []
max = C.most_common(1)[0][1]
for c in C.most_common():
    if max == c[1]:
        l.append(c[0])
    else:
        break
l.sort()
for x in l:
    print(x)

Solution (Python):
def resolve():
    import sys
    from collections import Counter
    n = int(input())
    s = [sys.stdin.readline().rstrip() for i in range(n)]
    d = Counter(s).most_common()
    e = d[0][1]
    ans = []
    for i in range(len(d)):
        if d[i][1] != e:
            break
        else:
            ans.append(d[i][0])
    for j in sorted(ans):
        print(j)
resolve()

Solution (Python):
n=int(input())
D={}
for i in range(n):
    s=input()
    if s in D:
        D[s]+=1
    else:
        D[s]=1
M=max(D.values())
ans=[]
for d in D:
    if D[d]==M:
        ans.append(d)
print(*sorted(ans),sep="\n")

Solution (Python):
import collections

N=int(input())
C=collections.Counter([input() for _ in range(N)])
v,c=zip(*C.most_common())
[print(x) for x in sorted([v[i] for i in range(len(c)) if c[i]==c[0]])]

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

vote = {}

for i in range(n):
  s = input()
  if s in vote.keys():
    vote[s] += 1
  else:
    vote[s] = 1
m = max(vote.values())
vote=sorted(vote.items() , key = lambda x:x[0])
for i in vote:
  if i[1] == m:
    print(i[0])

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

key = list(S.keys())
value = list(S.values())
m = max(value)

Ans = []
for i in range(len(key)):
    Ans.append([value[i],key[i]])
Ans.sort()
for i in range(len(key)):
    if Ans[i][0] == m:
        print(Ans[i][1])

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

l = sorted(m.items(), key=lambda x: x[1], reverse=True)
cnt = l[0][1]
p = []
for i in l:
    if i[1] == cnt:
        p.append(i[0])

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

Solution (Python):
from collections import Counter
from sys import stdin
N = int(stdin.readline().rstrip())
S = Counter([stdin.readline().rstrip() for _ in range(N)])
max_c = S.most_common()[0][1]
print(*sorted([k for k, v in S.items() if v == max_c]), sep='\n')

Solution (Python):
from collections import Counter 

n = int(input())
li = list()
for _ in range(n):
    li.append(input())
a = Counter(li)
b = max(a.values())
m = [x[0] for x in a.items() if x[1] == b]
m.sort()
for i in m:
    print(i)

Solution (Python):
import math
import sys

m=10**9 + 7 
sys.setrecursionlimit(1000010)
N = int(input())
dict = {}
max = 0 
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] 
       
for x in sorted(dict.keys()):
    if dict[x] == max:
        print(x)

Solution (Python):
import collections
n = int(input())
s = [input() for i in range(n)]
d = collections.Counter(s)
maxd = max(d.values())
li = []
for a,b in d.items():
    li.append([a,b])
ans = []
for i in range(len(li)):
    if li[i][1] == maxd:
        ans.append(li[i][0])
ans.sort()
for i in range(len(ans)):
    print(ans[i])

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

c = Counter(S)
max_num = max(c.values())
max_list = [i for i,j in c.items() if j==max_num]
max_list.sort()
print('\n'.join(max_list))

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

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

a = {}
b = []
for i in range(n):
  s = input()
  b.append(s)
  if s in a:
    a[s] += 1
  else:
    a[s] = 1

b = sorted(list(set(b)))
p = max(a.values())

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

Solution (Python):
n=int(input())
l=[input() for i in range(n)]
import collections
c=collections.Counter(l)
ll=c.most_common()
tmp=ll[0][1]
ans=[]
for i,j in ll:
    if tmp==j:
        ans.append(i)
    else:
        break
ans.sort()
print('\n'.join(map(str,ans)))

Solution (Python):
from collections import Counter
n = int(input())
l = [input() for i in range(n)]
ls = Counter(l)
most_num = ls.most_common()[0][1]
keymost = [i for i, j in ls.items() if j == most_num]
keymost.sort()
for k in keymost:
    print(k)

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

sn = []
for i in range(n):
    sn.append(input())
    
import collections
c = collections.Counter(sn)

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

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

keys.sort()
for k in keys:
    print(k)

Solution (Python):
from collections import Counter
def main():
    n = int(input())
    
    s = [str(input()) for i in range(n)]
    
    count = Counter(s)
    max_num = max(count.values())
    max_list = [key for key,value in count.items() if value == max_num]
    max_list.sort()

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





    '''
    new_s = sorted(s)
    index = [0]*n
    str_count = [0]*n
    count = 1
    for i in range(n-1):
        if new_s[i] == new_s[i+1]:
            count += 1
        else:
            index[i] = i
            str_count[i] = count
            count = 1
    print(new_s)
    print(str_count)
  '''

if __name__ == '__main__':
    main()

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

for i in range(n):
  if s[i] in d:
    d[s[i]] += 1
  elif not(s[i] in d):
    d[s[i]] =1
    
sort_d = sorted(d.values(),reverse=True)
max = sort_d[0]

ans =[]

for j in d:
  if d[j] == max:
    ans.append(j)

ans.sort()

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

Solution (Python):
import sys
from collections import Counter
N = int(sys.stdin.readline())
S = sys.stdin.read().split()
 
count = Counter(S)
max_num = max(count.values())

max_list = [i for i,j in count.items() if j==max_num]
 
max_list.sort()
print('\n'.join(max_list))

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

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

flag = d[0][1]
for i in d:
    if i[1] == d[0][1]:
        print(i[0])
    else:
        exit()

Solution (Python):
import sys
n=int(input())
s=sorted([input() for i in range(n)])
ct=0
tmp=1
for i in range(n-1):
    if s[i] ==s[i+1]:
        tmp+=1
    else:
        if tmp>ct:
            ct=tmp
        tmp=1
if tmp > ct:
    ct = tmp
    
if tmp == 1:
    for i in range(n):
        print(s[i])
    sys.exit()

tmp=1
for i in range(n-1):
    if s[i] ==s[i+1]:
        tmp+=1
        if tmp == ct:
            print(s[i])
    else:
        tmp=1

Solution (Python):
N = int(input())
str = {}
for i in range(N):
    key = input()
    if(key in str.keys()):
        str[key] += 1
    else:
        str[key] = 1
m = max(str.values())
str = sorted(str.items(),key=lambda x:x[1],reverse=True)
z = []
for i in range(len(str)):
    if(str[i][1] == m):
        z.append(str[i][0])
z.sort()
for i in z:print(i)

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

def count(s, word_list, max_count, word_count):
    if s not in word_count:
        word_count[s] = 0
    word_count[s] += 1

    if word_count[s] >= max_count:
        if word_count[s] > max_count:
            word_list = []
            max_count = word_count[s]
        word_list.append(s)
    else:
        pass

    return word_list, max_count, word_count

        
word_list = []
max_count = 0
word_count = {}
for _ in range(N):
    s = input()
    word_list, max_count, word_count = count(s, word_list, max_count, word_count)

for w in sorted(word_list):
    print(w)

Solution (Python):
import sys
input = sys.stdin.readline
N = int(input())
dictS = {}
for x in range(N):
    tmp = input().rstrip()
    if tmp in dictS:
        dictS[tmp] = dictS[tmp]+1
    else:
        dictS[tmp]=1
        
max_n =max(dictS.values())
maxIndex = [x for x in dictS.items() if x[1] ==max_n ]
ans_list = []
for x in maxIndex:
    ans_list.append(x[0])
ans_list.sort()
for x in ans_list:
    print(x)

Solution (Python):
import collections
N = int(input())
S = []

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

SS = collections.Counter(S)
m = max(SS.values())
for i in SS.keys():
    if(SS[i]== m):
        res.append(i)
res.sort()
for i in range(len(res)):
    print(res[i])

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

dictA={}

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

maxnum=0
candlist=list(dictA.keys())
candlist.sort()
maxlist=[]

for i in candlist:
	if dictA[i]>maxnum:
		maxlist.clear()
		maxlist=[i]
		maxnum=dictA[i]
	elif dictA[i] == maxnum:
		maxlist.append(i)



for i in maxlist:
	print(i)

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

count = Counter(S)
max_num = max(count.values())
max_list = [i for i,j in count.items() if j==max_num]
 
max_list.sort()
print('\n'.join(max_list))

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

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

s_dict = dict()
for _s in s:
    s_dict[_s] = 0

for _s in s:
    s_dict[_s] += 1

max_frequency = max(s_dict.values())

s_ans_list = [_s for _s, i in zip(s_dict.keys(), s_dict.values()) if i >= max_frequency]
s_ans_list = sorted(s_ans_list)

for _s in s_ans_list:
    print(_s)

Solution (Python):
from collections import Counter

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

c = list(Counter(s).items())
c.sort()
c.sort(key=lambda x: x[1], reverse=True)
num = c[0][1]
for k, v in c:
    if v == num:
        print(k)

Solution (Python):
import sys; sys.setrecursionlimit(2147483647); input = sys.stdin.readline
from math import floor, ceil, sqrt, factorial, log
from collections import Counter, defaultdict
from operator import itemgetter
INF = float('inf'); MOD = 10**9+7
def I(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(MI())
def LIR(n): return [LI() for i in range(n)]
def S(): return input().rstrip()

def main():
    N = I()
    s = [S() for i in range(N)]    
    c = Counter(s).most_common()
    max_n = c[0][1]
    l = []
    for i in c:
        if i[1] == max_n:
            l.append(i[0])
    for i in sorted(l):
        print(i)
if __name__ == '__main__':
    main()

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

r = {}
c = 0
for s in Si:
    if not s in r:
        r[s] = 0
    r[s] += 1 
    if r[s] > c:
        c = r[s]

aa = [k for k, u in r.items() if u == c] 
aa.sort()
for a in aa :
    print(a)

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

count=Counter(s)

max=max(count.values())

ans=[key for key in count if count[key]==max]
ans.sort()
print(*ans,sep='\n')

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

cnt_dict = defaultdict(int)
cnt_max = 0
for si in s:
    cnt_dict[si] += 1
    cnt_max = max(cnt_max, cnt_dict[si])

ans = [key for key in cnt_dict if cnt_dict[key] == cnt_max]
ans.sort()
print(*ans, sep='\n')

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

counter = Counter(s)
cnt_max = max(counter.values())

ans = [key for key in counter if counter[key] == cnt_max]
ans.sort()
print(*ans, sep='\n')

Solution (Python):

"""
Created on Wed Mar  4 16:16:18 2020

@author: Kanaru Sato
"""

N = int(input())
D = {}

for i in range(0,N):
    S = input()
    if S not in D:
        D[S] = 1
    if S in D:
        D[S] += 1

Mvalue = max(D.values())

List = []
[List.append(i) for i in D if D[i]==Mvalue]

List.sort()

for i in range(0,len(List)):
    print(List[i])

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

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

dic_sorted = sorted(dic.items(), key=lambda x:x[1], reverse = True)
ans = []
flag = 0
for i in range(len(dic_sorted)):
    if dic_sorted[i][1] < flag:
        break
    else:
        flag = dic_sorted[i][1]
        ans.append(dic_sorted[i][0])

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

Solution (Python):
from collections import defaultdict

n = int(input())
dd = defaultdict(int)

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

maxnum = max(dd.values())

arr=[]

for k in dd:
    if dd[k]==maxnum:
        arr.append(k)

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

Solution (Python):




def judge(leet_num):
    leet_list = []
    for num in range(leet_num):
        leet_list.append(input())
    
    leet_dict = {}
    
    for leet in leet_list:
        if not leet in leet_dict:
            leet_dict[leet] = 1
        else:
            leet_dict[leet] = leet_dict[leet] + 1
    
    max_leet = max(leet_dict.values())
    result_list = []
    
    for num in leet_dict:
        if leet_dict[num] == max_leet:
            result_list.append(num)
    result_list = sorted(result_list)
    
    return result_list
    
    
    
def main():
    num = int(input())
    answear = judge(num)
    for num in answear:
        print(num)
    

if __name__ == "__main__":
    main()

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

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


wordCount = defaultdict(int)
wordList = []

for _ in range(N):
    wordList.append(input())

for _ in wordList:
    wordCount[_]+=1

maxValue = 0
maxKey = ""
for _ in wordCount:
    if (wordCount[_] >maxValue):
        maxValue = wordCount[_]

maxWords = []
for _ in wordCount:
    if (wordCount[_] ==maxValue):
        maxWords.append(_)

maxWords.sort()
for _ in maxWords:
    print(_)

Solution (Python):
import collections
num = int(input())
hm = collections.Counter()
for _ in range(num):
  temp = input()
  hm[temp] += 1
most = hm.most_common(1)[0][1]
ret = []
for k, v in hm.items():
  if v == most:
    ret.append(k)
ret.sort()
for i in ret:
  print(i)

Solution (Python):
N = int(input())
d = dict()
for _ in range(N):
  s = input()
  if s in d:
    d[s] += 1
  else:
    d[s] = 1
max = max(d.values())
f = filter(lambda x:x[1] == max, d.items())
for p in sorted(f):
  print(p[0])

Solution (Python):
from collections import Counter
n=int(input())
s=[input() for i in range(n)]
c=Counter(s)
l=c.most_common()
l.sort(key=lambda x:x[1],reverse=True)
a=l[0][1]
i=0
ans=[]
while i<len(l) and l[i][1]==a:
  ans.append(l[i][0])
  i+=1
ans.sort()
for j in ans:
  print(j)

Solution (Python):
from collections import Counter

N = int(input())
c = Counter()
for _ in range(N):
    c[input()] += 1

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

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

dic = {}

for word in s:
	if word not in dic:
		dic[word] = 1
	else:
		dic[word] += 1


value_max = max(dic.values())



ans = [k for k, v in dic.items() if v==value_max]
ans = sorted(ans)

for a in ans:
	print(a)

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

ans = {}
for t in s:
    if t in ans:
        ans[t] += 1
    else:
        ans[t] = 1

max_cnt = max(ans.values())

for t in sorted(ans):
    if ans[t] == max_cnt:
        print(t)

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

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

max_v = max(dicts.values())
a = [k for k, v in dicts.items() if v == max_v]
b = sorted(a)
[print(i) for i in b]

Solution (Python):

from collections import Counter
import numpy as np
N = int(input())
S = [str(input()) for i in range(N)]
S = np.array(S)

count = Counter(S)
max_num = max(count.values())
max_list = [i for i,j in count.items() if j==max_num]

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

Solution (Python):
n = int(input())
mp = dict()
maxi = 0
for _ in range(n):
    s = input()
    if s in mp:
        mp[s] += 1
    else:
        mp[s] = 1
    maxi = max(maxi, mp[s])

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

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

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


counter=Counter(S)
L=[]
t=0
for j in range(N):
    value=counter[S[j]]
    if t<value:
        t=value
        L=[]
        L.append(S[j])
    
    elif t==value:
        L.append(S[j])
    
    elif t>value:
        pass

L=list(set(L))
L.sort()
for k in range(len(L)):
    print(L[k])

Solution (Python):
from collections import defaultdict
N = int(input())
S = [input() for _ in range(N)]
dic = defaultdict(int)
for i in range(N):
        dic[S[i]] += 1
dic = dict(dic)
dic = sorted(dic.items(),key = lambda x:-x[1])
n = len(dic)
max = dic[0][1]
d = 0
for i in range(n):
  if dic[i][1] == max:
    d += 1
  else:
    d = i
    break
dic = sorted(dic[0:d],key = lambda x:x[0])
for i in range(len(dic)):
  print(dic[i][0])

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

ans_list = []

for k in dic:
  ans_list.append(dic[k])

list.sort(ans_list, reverse = True)
max = ans_list[0]

ans = []
for k in dic:
  if dic[k] == max:
    ans.append(k)
ans.sort()
for i in range(len(ans)):
  print(ans[i])

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

cs = Counter(s).most_common()
m = cs[0][1]
ms = ([i for i in cs if i[1] == m])

for i in sorted(ms):
    print(i[0])

Solution (Python):


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

dict = {}
max_n = 0
for i in range(n):
    if dict.get(s[i]) == None:
        dict[s[i]] = 1
        max_n = max(max_n, dict[s[i]])
    else:
        dict[s[i]] += 1
        max_n = max(max_n, dict[s[i]])


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

ans = sorted(ans)

for output in ans:
    print(output)

Solution (Python):
n=int(input())
S=[input() for _ in range(n)]
from collections import Counter
d=Counter(S)
e=[]
c=d.most_common()[0][1]
for i in d.keys():
  if d[i]==c:
    e.append(i)
e.sort()
print(*e,sep="\n")

Solution (Python):
n=int(input())
S=[input() for _ in range(n)]
from collections import Counter
d=Counter(S)
e=[]
c=d.most_common()[0][1]
for i in d.keys():
  if d[i]==c:
    e.append(i)
e.sort()
print(*e,sep="\n")

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

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

d = {}

for i in range(n):
    if words[i] not in d:
        d[words[i]] = 1
    else:
        d[words[i]] += 1

m = max(d.values())
ANS = []

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

ANS = sorted(ANS)

for i in ANS:
    print(i)

Solution (Python):
from collections import Counter


def solve(string):
    n, *s = string.split()
    c = Counter(s)
    _, v = c.most_common(1)[0]
    l = sorted([k for k, _v in c.items() if _v == v])
    return "\n".join(l)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

Solution (Python):
from collections import Counter
N = int(input())
l=[input() for i in range(N)]
count=Counter(l).most_common()
d = []
most = count[0][1]
for si,c in count:
  if c==most:
    d.append(si)
d.sort()
for i in d:
  print(i)

Solution (Python):
from collections import Counter
n=int(input())
l=[input() for i in range(n)]
count=Counter(l).most_common()
d,most=[],count[0][1]
for si,c in count:
  if c==most:
    d.append(si)
d.sort()
for i in sorted(d):
  print(i)

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

c = Counter(A)
maxcnt = c.most_common()[0][1]
l = []
for i in c.most_common():
  if i[1] != maxcnt:
    break
  l.append(i[0])

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

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

c = Counter(A)
maxcnt = c.most_common()[0][1]
l = []
for i in c.most_common():
  if i[1] != maxcnt:
    break
  l.append(i[0])

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

Solution (Python):
from collections import Counter

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

words = Counter(s).most_common()
d, most = [], words[0][1]
for si, c in words:
    if c == most:
        d.append(si)

for si in sorted(d):
    print(si)

Solution (Python):

from collections import Counter
def main():
    N = int(input())
    S = [input() for i in range(N)]
    c = Counter(S)
    ans = []
    tmp = []
    tmp = c.most_common()
    cmax = c.most_common()[0][1]
    ans = [k for k , j in c.items() if j == cmax]
    ans.sort()
    print('\n'.join(ans))
if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter

n = int(input())
A = [input() for _ in range(n)]
A = Counter(A)
maxw = []

v, i = zip(*A.most_common())
wordcnt = i.count(max(i))
for j in range(wordcnt):
    maxw.append(v[j])
maxw.sort()

for k in maxw:
    print(k)

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

value_dict = {}

for x in range(N):
    value = input()
    if value not in value_dict.keys():
        value_dict[value] = 1
        continue
    value_dict[value] += 1

max_count = max(value_dict.values())
max_values = [k for k, v in value_dict.items() if v == max_count]
max_values.sort()


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

Solution (Python):
from collections import Counter
k=int(input())
p=Counter(input() for f in range(k))
j=sorted(p.most_common(), key=lambda a:1-a[1])
j=[m[0] for m in j if m[1]==j[0][1]]
print("\n".join(sorted(j)))

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

c = collections.Counter(s)
m = c.most_common()[0]

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

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

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

c = collections.Counter(s)
m = c.most_common()[0]

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

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