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


max_value = sorted(str_fq_dic.values(), reverse=True)[0]

ans_list = []
for s in str_fq_dic:
    if str_fq_dic[s]==max_value:
        ans_list.append(s)



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

Solution (Python):
N = int(input())
S = []
for _ in range(N):
    S.append(input())
T = sorted(S)
T.append("uuuuuuuuuuuuu")
s = 0
t = 0
u = 0
d = []
for i in range(0,N):
    if T[i] != T[i+1]:
        s = i + 1 -t
        t = i + 1
        if s > u:
            d = [T[i]]
            u = s
        elif s == u:
            d.append(T[i])
            u = s
s_n = '\n'.join(d)
print(s_n)

Solution (Python):
from collections import defaultdict
from collections import OrderedDict
N = int(input())
ans = dict()
for _ in range(N):
    k = str(input())
    if k in ans:
        ans[k]+=1
    else:
        ans.update({k:1})
groupedByValue = defaultdict(list)
for key, value in sorted(ans.items()):
    groupedByValue[value].append(key)
l = groupedByValue[max(groupedByValue)]
for i in l:
    print(i)

Solution (Python):
N = int(input())
tmps = input()
max_val = 1
Sdic = {tmps:1}
max_string = [tmps]
for i in range(1, N):
    tmps = input()
    if tmps in Sdic:
        Sdic[tmps] += 1
    else:
        Sdic[tmps] = 1

    if Sdic[tmps] > max_val:
        max_val = Sdic[tmps]
        max_string = [tmps]
    elif Sdic[tmps] == max_val:
        max_string.append(tmps)
max_string.sort()
for string in max_string:
    print(string)

Solution (Python):
from collections import defaultdict
from collections import OrderedDict
N = int(input())
ans = dict()
for _ in range(N):
    k = str(input())
    if k in ans:
        ans[k]+=1
    else:
        ans.update({k:1})
groupedByValue = defaultdict(list)
for key, value in sorted(ans.items()):
    groupedByValue[value].append(key)
l = groupedByValue[max(groupedByValue)]
for i in l:
    print(i)

Solution (Python):
N = int(input())
S = [input() for i in range(N)]
s = sorted(S)
import collections
c = collections.Counter(s)
C = c.most_common()
 
a = C[0][1]
b = []
for i in range(len(C)):
  if a == C[i][1]:
    b.append(C[i][0])
  else:
    break
B = sorted(b)
 
for i in B:
  print(i)

Solution (Python):
import collections

N = int(input())
area = []
for i in range(N):
    area.append(input())
c = collections.Counter(area)
max_val = max(c.values())
keys_of_max_val = [key for key in c if c[key] == max_val]
keys_of_max_val.sort()
for i in keys_of_max_val:
    print(i)

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

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

s.sort()

tmp = -1
kouho = []



for i in range(n-1):
    
    if s[i] == s[i+1]:
       tmp -= 1
       if i+1 == n-1:
           kouho.append([tmp,s[i]])
    else:
        kouho.append([tmp,s[i]])
        tmp = -1
        if i+1 == n-1:
            kouho.append([tmp,s[i+1]])

kouho.sort()

num = 0
print(kouho[0][1])


if len(kouho) == 1:
    exit()

for i in range(n-1):
    if kouho[0][0] == kouho[i+1][0]:
        print(kouho[i+1][1])
    else:
        exit()

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

S.sort()

dic = list((set(S)))
dic.sort()
times = [0] * len(dic)
aa=0

for s in S :
    if dic[aa] == s:
        times[aa] += 1
    else:
        aa += 1
        times[aa] += 1

ans = [0] * len(dic)
ma = max(times)

s_ans = []

for a in range(len(dic)):
    if times[a] == ma:
        s_ans.append(dic[a])

s_ans.sort()

for j in range(len(s_ans)):
    print(s_ans[j])

Solution (Python):
import collections

n = int(input())
s =[]
for i in range(n):
    s.append(input())
ans = collections.Counter(s)
temp = ans.values()
temp2 = max(temp)


temp3 = [k for k ,v in ans.items() if v == temp2]

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

Solution (Python):
import collections
n = int(input())
moji = []
for i in range(n):
    moji.append(input())
ans = dict(collections.Counter(moji))
mx = max(ans.values())
ans = sorted(ans.items(),key=lambda x:x[0])
mx = [kv[0] for kv in ans if kv[1]==mx]
for i in mx:
    print(i)

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

S.sort()

max = 0
Output = []
pt = 0
while pt < N:
    st,tmp = S[pt],0
    while pt < N and st == S[pt]:
        pt += 1
        tmp += 1
        if max == tmp:
            Output.append(st)
        if max < tmp:
            max = tmp
            Output.clear()
            Output.append(st)

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

Solution (Python):
from collections import Counter
N = int(input())
ele_l = [input() for _ in range(N)]
ans = sorted(Counter(ele_l).items(),key=lambda x:-x[1])
maxnum = ans[0][1]
ans = sorted(list(map(lambda x:x[0],list(filter(lambda x:x[1]==maxnum,ans)))))
for a in ans:
    print(a)

Solution (Python):
from collections import Counter

N = int(input())
c = Counter()
l = 0
for i in range(N):
    k = input()
    v = c.setdefault(k, 0)
    c[k] = v + 1
    if l < c[k]:
        l = c[k]
ans = sorted([k for k, n in c.items() if n==l])
[print(k) for k in ans]

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

def main(lst_S):
    
    lst_S = sorted(lst_S)

    prev_S = lst_S[0]
    count  = 1
    S_with_count = {}
    for S in lst_S[1:]:

        if S == prev_S:
            count += 1
        else:
            S_with_count[prev_S] = count
            count = 1

        prev_S = S

    else:
        S_with_count[S] = count
    
    max_count = max(list(S_with_count.values()))
    answer_S  = []
    for key, value in sorted(
        S_with_count.items(), key=lambda x: x[1], reverse=True
        ):
        if value == max_count:
            answer_S.append(key)
        
    return sorted(answer_S)
        
if __name__ == "__main__":

    lst_answer = main(lst_S)
    for answer in lst_answer:
        print(answer)

Solution (Python):
import collections
N = int(input())
A=[input() for i in range(N)]
c = collections.Counter(A)
values, counts = zip(*c.most_common())
k = max (counts)
l =counts.count(k)
V = []
for i in range(l):
  V.append(values[i])
L = sorted(V)
for j in range(len(L)):
  print(L[j])

Solution (Python):
import collections

N = int(input())
S = [input() for _ in range(0, N)]
mc = collections.Counter(S).most_common()
c = mc[0][1]

s = map(lambda x: x[0], filter(lambda x: x[1] == c, mc))
s = list(s)
s.sort()

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

Solution (Python):
if __name__ == "__main__":
    n = int(input())
    s = dict()
    for i in range(n):
        tmp = input()
        if tmp not in s:
            s[tmp] = [tmp]
        else:
            s[tmp].append(tmp)

    ls = sorted(s)

    maxvote = 0
    for ss in s:
        if len(s[ss]) > maxvote:
            maxvote = len(s[ss])

    for l in ls:
        if len(s[l]) == maxvote:
            print(l)

Solution (Python):
N = int(input())
dic = {}
for i in range(N):
    si = input()
    if si in dic.keys(): dic[si] += 1
    else: dic[si] = 1
n = max(dic.values())
for k,v in sorted(dic.items()):
  if v == n: print(k)

Solution (Python):


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

d = {}
for s in S:
    d.setdefault(s, 0)
    d[s] += 1

dmax = max(d.values())

dmax_list = [k for k, v in d.items() if v == dmax]
for d in sorted(dmax_list):
    print(d)

Solution (Python):
n = int(input())
s = [input() for _ in range(n)]
s.sort()
se = sorted(set(s))
j = 0
count = 0
l = [0] * len(se)
for i in s:
    if i == se[j]:
        count += 1
    else:
        l[j] = count
        j += 1
        count = 1
l[j] = count
ma = max(l)
ans = [i for i, x in enumerate(l) if x == ma]
for i in ans:
    print(se[i])

Solution (Python):
from collections import Counter

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

cnt = Counter(S)

most = 0
for i in cnt.values():
    most = max(most, i)

ans = []
for i in cnt:
    if cnt[i] == most:
        ans.append(i)

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

Solution (Python):
N = int(input())
S = []
for _ in range(N):
    S.append(input())
word_dict = {}
for word in S:
    if word in word_dict:
        word_dict[word] += 1
    else:
        word_dict[word] = 1

max_v = max(word_dict.values())

for key in sorted(word_dict):
    if word_dict[key] == max_v:
        print(key)

Solution (Python):
import collections

N = int(input())

S_list = []

for i in range(N):
    tmp = str(input())
    S_list.append(tmp)

c = collections.Counter(S_list)

appear = max(list(c.values()))

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

keys_sorted = sorted(keys)

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

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

ma = 0
for i in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1
    if d[s] > ma:
        ma = d[s]

res = []
for e in d:
    if d[e] == ma:
        res.append(e)

res.sort()
for e in res:
    print(e)

Solution (Python):
import numpy as np

N=int(input())

S=[]
count_S={}
for i in range(N):
    s=input()
    S.append(s)
    count_S[s]=0

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

keys=np.array(list(count_S.keys()))
values=np.array(list(count_S.values()),dtype=np.int32)
out=np.where(values==np.max(values))
result=np.sort(keys[out])

for r in result:
    print(r)

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

d = dict()
for i in range(N):
    key = input()
    if key not in d:
        d[key] = 1
    else:
        d[key] += 1
val_max = 1
for key in d.keys():
    val_max = max(val_max, d[key])
ans = []
for key in d.keys():
    if d[key] == val_max:
        ans.append(key)
ans.sort()
for a in ans:
    print(a)

Solution (Python):

import sys


def solve(N: int, S: "List[str]"):
    d = sorted(set(S))
    cnt = {}
    m = 0
    for w in S:
        if not cnt.get(w):
            cnt[w] = 0
        cnt[w] += 1
        m = max(m, cnt[w])
    for w in d:
        if cnt[w] == m:
            print(w)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    S = [next(tokens) for _ in range(N)]  
    solve(N, S)

if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter

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

keys, values = zip(*S.most_common())

v_pre = values[0]
end_idx = None
for i in range(1, len(values)):
    if v_pre == values[i]:
        continue
    else:
        end_idx = i
        break

if end_idx is None:
    answer = keys
else:
    answer = keys[:end_idx]

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

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

l=sorted(l)
ll=[]
k=1
for i in range(n-1):
    if l[i]==l[i+1]:
        ll.append(k)
        k+=1
    else:
        ll.append(k)
        k=1
ll.append(k)
c=max(ll)
lll=[]
for i in range(n):
    if ll[i]==c:
        lll.append(l[i])

lll=sorted(set(lll))
for i in lll:
    print(i)

Solution (Python):
from collections import Counter

n = int(input())
s = list(str(input()) for _ in range(n))
c = Counter(s)

m = 0
for k, v in c.items():
    if m <= v:
        m = v

keys = [k for k, v in c.items() if v >= m]
for ans in sorted(keys):
    print(ans)

Solution (Python):
import collections

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

c = collections.Counter(l).most_common()[::1]
res = sorted([i[0] for i in c if i[1] == c[0][1]])
[print(i) for i in res]

Solution (Python):
from sys import stdin,stdout
def f(A):
	for i in A:
		if i%2==0:
			if i%3!=0 and i%5!=0:
				return 'DENIED'
	return 'APPROVED'

def main():  	
	for x in stdin:
		n = int(x)
		mx = 0
		dic = {}
		for i in range(n):
			s = input().strip('\n')
			if s in dic:dic[s] += 1
			else:dic[s] = 1
			mx = max(dic[s],mx)
		A = []
		for x in dic:
			if dic[x]==mx:A.append(x)
		A.sort()
		print('\n'.join(A))
if __name__ == "__main__":
    main()

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

sd = {}
for s in strings:
  if s in sd:
    sd[s] += 1
  else:
    sd[s] = 1

sorted_sd = sorted(sd.items(), key=lambda x:x[1], reverse=True)
pre_c = 0
ans = []
for s, c in sorted_sd:
  if c < pre_c:
    break
  ans.append(s)
  pre_c = c
for a in sorted(ans):
  print(a)

Solution (Python):
from collections import Counter

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

counter = Counter(ss)

num = counter.most_common(1)[0][1]

ans = sorted([k for k in counter.keys() if counter[k] == num])
print(*ans, sep= '\n')

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

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

sorted_s = sorted(s, key=s.__getitem__, reverse=True)

print_list = []

for k in s:
    if s[k] == s[sorted_s[0]]:
        print_list.append(k)

for p in sorted(print_list):
    print(p)

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

cnt={}
ans=[]

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

m=max(cnt.values())
key = sorted(cnt.keys())

for a in key:
    if cnt[a] == m:
        print(a)

Solution (Python):
from collections import Counter

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

counter = Counter(S)
c_most = counter.most_common()





maxval = c_most[0][1]

anss = []

for s in c_most:
    if s[1] == maxval:
        anss.append(s[0])
    else:
        break

anss = sorted(anss)

for a in anss:
    print(a)

Solution (Python):
n_paper = int(input())
vote_data = {}
for _ in range(n_paper):
    votename = input()
    if votename in vote_data:
        vote_data[votename] += 1
    else:
        vote_data[votename] = 1

max_n_vote = max(vote_data.values())
winners = [x for x in vote_data.keys() if vote_data[x] == max_n_vote]
winners.sort()
for winner in winners:
    print(winner)

Solution (Python):
import collections

N = int(input())
c = collections.Counter(input() for _ in range(N))

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

a = []
for i in c:
    if c[0][1] != i[1]: break
    a.append(i)

a = sorted(a)
for i in a:
    print(i[0])

Solution (Python):
def poll(n , s):

    ss = {}
    maxint = 0
    ans = []

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

    maxint = max(ss.values())

    ans = [k for k, v in ss.items() if v == maxint]

    ans.sort()
    return ans

def main():
    n = int(input())
    s =[str(input()) for i in range(n)]
    ans = poll(n , s)

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

if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
a=[input() for i in range(n)]
a.sort()
a+="zzzzzzzzzzzzzzzzzzz"
m=[]
st=a[0];cnt=1
for i in range(1,n+1):
    if st!= a[i]:
        m.append((st,cnt))
        st=a[i]
        cnt=1
    else:
        cnt+=1
m.sort(key=lambda x:x[0])
m.sort(key=lambda x:x[1],reverse=True)
cnnnk=m[0][1]
for i in m:
    if i[1]==cnnnk:
        print(i[0])
    else:
        break

Solution (Python):
from collections import Counter
N = int(input())
L = [str(input()) for _ in range(N)]
c = Counter(L)
ans = []
for i, x in enumerate(c.most_common()):
  if i>0 and x[1]!=m:
    break
  ans.append(x[0])
  m = x[1]
for x in sorted(ans):
  print(x)

Solution (Python):
n = int(input())
a = {}
for _ in range(n):
    c = input()
    if c not in a:
        a[c] = 0
    a[c] += 1

v0 = -1
b = []
for k, v in sorted(a.items(), key=lambda x: -x[1]):
    if v0 < v:
        v0 = v
    if v0 == v:
        b.append(k)

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

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

mx = max(S_dict.values()); ans = []
for st in S_dict.keys():
    if S_dict[st] == mx:
        ans.append(st)

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

Solution (Python):
import sys
N = int(input())
S = (str(x) for x in sys.stdin.read().split())
cnt = {}
for s in S:
  if cnt.get(s):
    cnt[s] = cnt[s] + 1
  else:
    cnt[s] = 1
max_cnt = max(cnt.values())
keys = [k for k, v in cnt.items() if v == max_cnt]
for k in sorted(keys):
  print(k)

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

li2 = collections.Counter(li)
li3 = li2.most_common()

li4 = []
for i in range(len(li3)):
    if li3[0][1] == li3[i][1]:
        li4.append(li3[i][0])
li4.sort()

for j in range(len(li4)):
    print(li4[j])

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

d = sorted(d.items(), key = lambda x:x[1])
if len(d) <= 1:
    print(d[0][0])
    exit()

tmp, max_value = d.pop()
res = [tmp]

for i in range(len(d)):
    temp_name,temp_value = d.pop()
    if max_value == temp_value:
        res.append(temp_name)
    else:
        break

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

Solution (Python):
N = int(input())
now = 0
temp = {}
ans = []
for _ in range(N):
    a = input()
    if now == 1 or now == 0:
        ans.append(a)
    try:
        temp[a] += 1
        if temp[a] > now:
            ans = [a]
            now = temp[a]
        elif temp[a] == now:
            ans.append(a)
    except:
        temp[a] = 1

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

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

max_count = max(list(S.values()))


S_sorted = sorted(S.items(), key=lambda x: x[0])


for kv in S_sorted:
  if kv[1] == max_count:
    print(kv[0])

Solution (Python):
N = int(input())
L = {}
for i in range(N):
  A = input()
  if not A in L:
    L[A] = 1
  else:
    L[A] += 1
S = []
maxv = 0
for i in L.keys():
  if L[i] == maxv:
    S.append(i)
  elif L[i] > maxv:
    S = [str(i)]
    maxv = L[i]
S.sort()
print("\n".join(S))

Solution (Python):
import collections
n=int(input())
l=[input() for i in range(n)]
c=collections.Counter(l)
k=c.most_common()
s=k[0][1]
b=[]
for i in k:
  if s==i[1]:
    b.append(i[0])
  else:
    break
m=sorted(b)
for o in m:
  print(o)

Solution (Python):
from collections import Counter

n = int(input())
c = Counter()
for i in range(n):
    c.update([input()])
    
times = c.most_common(1)[0][1]
res = [x[0] for x in c.items() if x[1]==times]
res.sort()

for i in res:
    print(i)

Solution (Python):



import sys

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

mx = 0
d = {}
r = []

for a in A:
    if not a in d:
        d[a] = 0
    d[a] += 1
    if d[a] > mx:
        r = [a]
        mx = d[a]
    elif d[a] == mx:
        r.append(a)

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

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

S_list = {}
ans = set()

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

M = max(S_list.values())
S_list = sorted(S_list.items(), key = lambda x: x[0])

for s, v in S_list:
    if v == M:
        print(s)

Solution (Python):
import sys

num = input()
strings = []
for _ in range(int(num)):
    strings.append(input())

count_up = {}
for str in strings:
    if str in count_up:
        count_up[str] += 1
    else:
        count_up[str] = 1


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

greaters = []
for value in count_up_sorted:
    if value[1] != a:
        break
    else:
        greaters.append(value[0])

greaters_sorted = sorted(greaters)
for value in greaters_sorted:
    print(value)

Solution (Python):
N = int(input())
dict_names = dict()
for i in range(N):
  new_name = input()
  if new_name not in dict_names.keys():
    dict_names[new_name] = 1
  else:
    dict_names[new_name] += 1
max_count = max(count for count in dict_names.values())
list_of_max_counted_names = [name for name in dict_names if dict_names[name]==max_count]
list_of_max_counted_names.sort()
[print(name) for name in list_of_max_counted_names]

Solution (Python):
import collections

N = int(input())
s = []
for i in range(0, N):
  s.append(input())

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

max_count = counter[0][1]
max_counter = 0

for order in counter:
  if max_count == order[1]:
    max_counter += 1
  else:
    break;

counter = counter[:max_counter]

for s in sorted(counter):
  print(s[0]);

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

d_count = {}
for i in range(N):
    S = str(input())
    d_count.setdefault(S, 0)
    d_count[S] = d_count[S] + 1

max = 0
maxlist = []
for S in d_count:
    if(max < d_count[S] ):
        max = d_count[S]
        maxlist = [S]
    if(max == d_count[S]):
        maxlist.append(S)

maxlist_set = list(set(maxlist))
maxlist_set.sort()
for a in maxlist_set:
    print(a)

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

check_list = collections.Counter(text_list).most_common()
max_val = max([i[1] for i in check_list])
for i in sorted([i[0] for i in check_list if i[1] == max_val]):
    print(i)

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

arr = []
for i in range(n) :
	
    arr.append(input())
    
c = Counter(arr).most_common()

max = 0

arr2 = []

for item in c :
  
  if max == 0 :
    
    max = item[1]
    
  if max == item[1] :
    
    arr2.append(item[0])
    
  else :
    
    break
    
arr2.sort()

for item in arr2 :
  
  print(item)

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

from collections import Counter
checked =  Counter(num_list)
before_count = 0
check_count = 0
result = []
for keyword, count in sorted(checked.items(), key=lambda x: -x[1]):
    if check_count == 0:
        check_count += 1
        result.append(keyword)
        before_count = count
    else:
        if count != before_count:
            break
        else:
            check_count += 1
            result.append(keyword)
            before_count = count

for st in sorted(result):
    print(st)

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

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

sortedd = sorted(dic.items(), key=lambda x:x[1])


maxc=sortedd[-1][1]




sol=[]
for key in dic.keys():
  if dic[key] == maxc:
    sol+=[str(key)]

for x in sorted(sol):
  print(x)

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

for i in range(n):
  s=input()
  if s in d:
    d[s]=d[s]+1
  else:
    d[s]=1
    
maxno=0
z=[]
for k,v in d.items():
  if maxno<v:
    maxno=v
    z=[k,]
  elif maxno==v:
    z.append(k)
z.sort()
for i in z:
  print(i)

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

import collections

for n in range(N):
  S.append(input())

C = collections.Counter(S)
C = C.most_common()

c_max = C[0][1]
ans = []
for i, c in enumerate(C):
  if c[1] == c_max:
    ans.append(c[0])
  else:
    break

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

Solution (Python):
import collections
n=int(input())
s=[]
ans=[]
for i in range(n):
    si=input()
    s.append(si)
s_new=collections.Counter(s)
s_most=s_new.most_common()
buf=s_most[0][1]
cnt=0
for i in range(len(s_new)):
    if s_most[i][1]==buf:
        ans.append(s_most[i][0])
        cnt+=1
    elif s_most[i][1]<buf:
        break
ans_sorted=sorted(ans)
for i in range(cnt):
    print(ans_sorted[i])

Solution (Python):
import collections

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

c = collections.Counter(S)
cnt = c.most_common()
num = cnt[0][1]

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

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

Solution (Python):
import collections
N = int(input())
s = [input() for i in range(N)]
counter = collections.Counter(s)
max = max(dict(counter).values())
keys = [k for k, v in dict(counter).items() if v == max]
ans = sorted(keys)
for i in range (len(keys)):
  print(ans[i])

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

count = 0
l = []

for s in Counter(S).most_common():
    if count <= s[1]:
        l.append(s[0])
        count = s[1]
    else:
        break

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

Solution (Python):

MOD = 10 ** 9 + 7
INFI = 10**10

import math

import itertools



import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default






def main():
    n=int(input())
    s=[input() for i in range(n)]
    s=sorted(s)
    s.append("")
    tempn=0
    temp=s[0]
    maxn=0
    aa=[]
    for i in range(n+1):
        if temp==s[i]:
            tempn+=1
        else:

            aa.append([s[i-1],tempn])
            maxn=max(maxn,tempn)
            tempn=1
            temp=s[i]
    aa=sorted(aa)

    for a,b in aa:
        if b==maxn:
            print(a)



if __name__ == "__main__":
    main()

Solution (Python):
loopcnt = int(input())
dic = {}
for i in range(0, loopcnt):
    tmp = input()
    
    if tmp in dic:
        dic[tmp] += 1
    else:
        dic[tmp] = 1

dic_sorted = sorted(dic.items(),key=lambda x:(-x[1],x[0]))
limit = dic_sorted[0][1]


for nametpl in dic_sorted:
    if nametpl[1] == limit:
        print(nametpl[0])
    else:
        break

Solution (Python):
from collections import defaultdict
from collections import OrderedDict
N = int(input())
ans = dict()
for _ in range(N):
    k = str(input())
    if k in ans:
        ans[k]+=1
    else:
        ans.update({k:1})
groupedByValue = defaultdict(list)
for key, value in sorted(ans.items()):
    groupedByValue[value].append(key)
l = groupedByValue[max(groupedByValue)]
for i in l:
    print(i)

Solution (Python):
import collections
n = int(input())
ans = [input() for i in range(n)]
a = collections.Counter(ans)
b = a.most_common()
count = 1
if b[0][1]==1:
    ans.sort()
    for i in ans:
        print(i)
else:
    key = b[0][1]
    for i,j in enumerate(b):
        if j[1] < key:
            count = i
            break
    c = b[:count]
    d = [i[0] for i in c]
    d.sort()
    for i in d:
        print(i)

Solution (Python):
n = int(input())
list1 = []
for x in range(n):
    list1.append(input())
list1.sort()
cnts = [1]
vals = [list1[0]]
pos = 1
max_cnt = 0
max_val = []
while pos<n:
    if cnts[-1]>max_cnt:
        max_cnt = cnts[-1]
        max_val = [vals[-1]]
    elif cnts[-1]==max_cnt:
        max_val.append(vals[-1])
    if list1[pos]==vals[-1]:
        cnts[-1]+=1
    else:
        cnts.append(1)
        vals.append(list1[pos])
    pos+=1
if cnts[-1]>max_cnt:
        max_cnt = cnts[-1]
        max_val = [vals[-1]]
elif cnts[-1]==max_cnt:
        max_val.append(vals[-1])
max_val.sort()
for item in max_val:
    print(item)

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

Solution (Python):
n = int(input())
lis=[input() for i in range(n)]
import collections
ans = []
c = collections.Counter(lis)
clis = c.most_common()
for i in range(len(clis)):
    if clis[i][1] == clis [0][1]:
        ans.append(clis[i][0])
ans.sort()
for j in ans:
    print(j)

Solution (Python):
from collections import defaultdict
from collections import OrderedDict
N = int(input())
s = [input()for i in range(N)]
k = {}
for w in s:
    k[w] = 1 if k.get(w) == None else k[w] + 1
groupedByValue = defaultdict(list)
for key, value in sorted(k.items()):
    groupedByValue[value].append(key)
l = groupedByValue[max(groupedByValue)]
for i in l:
    print(i)

Solution (Python):
import collections

n = int(input())

l = []

for i in range(n):
    l.append(input())
c = collections.Counter(l)
cx = c.most_common()
nm = cx[0][1]
ans = []
ans.append(cx[0][0])
for i in range(1, len(cx)):
    if (nm == cx[i][1]):
        ans.append(cx[i][0])
    else:
        break

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

Solution (Python):
n = int(input())
ans = []
for i in range(n):
    if i == 0:
        s = input()
        S = {s: 1}
        ans.append(s)
        mx = 1
    else:
        s = input()
        if s in S:
            S[s] += 1
            if S[s] > mx:
                ans = [s]
                mx = S[s]
            elif S[s] == mx:
                ans.append(s)
        else:
            S[s] = 1
            if S[s] == mx:
                ans.append(s)
ans = sorted(ans)
for a in ans:
    print(a, sep="\n")

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

for i in range(N):
  S.append(input())
  
import collections
c = collections.Counter(S).most_common()
a=c[0][1]
ans=[]
for i in range(len(c)):
  if a==c[i][1]:
    ans.append(c[i][0])
  else:
    break
ans.sort()
for i in range(len(ans)):
  print(ans[i])

Solution (Python):
dic = {}

def inn(s):
  if s in dic:
    dic[s] += 1
  else:
    dic[s] = 1

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

m = max(dic.values())
s = list(filter(lambda n:dic[n]==m, dic))

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

Solution (Python):


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

max_ = max(s_dict.values())
result = [key for key in s_dict if s_dict[key] == max_]
result = sorted(result)

for i in result:
    print(i)