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):
dic={}

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



maxa=0
for val in dic:
    maxa=max(dic[val],maxa)
ans=[]
for val in dic:
    if dic[val]==maxa:
        ans.append(val)
print("\n".join(sorted(ans)))

Solution (Python):
n = int(input())
dicts = {}
for i in range(n):
    k = input()
    try:dicts[k] += 1
    except:dicts.setdefault(k, 1)
s = sorted(dicts.values(), reverse=True)
m = 0
for i in dicts:m = max(m, dicts[i])

ans = []
for i in dicts:
    if(dicts[i] == m):ans.append(i)

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

Solution (Python):
from collections import defaultdict


def solve():
    N = int(input())
    S_dict = defaultdict(int)
    S = ['' for _ in range(N)]
    for i in range(N):
        si = input()
        S[i] = si
        S_dict[si] += 1
    
    max_v = max(S_dict.values())
    tmp = [s for s in S if S_dict[s] == max_v]
    tmp.sort()
    p_ans = ''
    for ans in tmp:
        if p_ans != ans:
            print(ans)
            p_ans = ans


if __name__ == '__main__':
    solve()

Solution (Python):
from collections import Counter

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

C = Counter(Sn)
most = C.most_common()
max = most[0][1]
ans = []
for i in most:
    if max == i[1]:
        ans.append(i[0])
    else:
        break

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

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

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

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


ans =[ [ls[0],1] ]
tmp = ls[0]
for i in range(1,n):
  if ls[i] == tmp:
    ans[-1][1] += 1
  else:
    ans.append( [ls[i],1] )
    tmp = ls[i]
ans = sorted(ans, key = lambda x: (-1*x[1],x[0]))

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

Solution (Python):

import sys

N = int(input())
S_count = {}
for n in range(N):
    s = input()
    if s not in S_count:
        S_count[s] = 0
    S_count[s] += 1

max_count = 0
max_strings = []
for k, v in S_count.items():
    if v > max_count:
        max_strings = []
        max_strings.append(k)
        max_count = v
    elif v == max_count:
        max_strings.append(k)




sorted_strings = sorted(max_strings)


for s in sorted_strings:
    print(s)

Solution (Python):
import sys
import math
import collections
n = int(input())




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

c = collections.Counter(l)
x = c.most_common()
y = x[0][1]
ans = []
for i in range(len(x)):
  if x[i][1] != y:
    break

  ans.append(x[i][0])


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

Solution (Python):

n = int(input())

from collections import defaultdict
d = defaultdict(int)
maxnum = 0
maxli = []

for _ in range(n):
    s = input()
    d[s] += 1
    if d[s] > maxnum:
        maxnum += 1
        maxli = [s]
    elif d[s] == maxnum:
        maxli.append(s)
    
maxli.sort()

for l in maxli:
    print(l)

Solution (Python):
dic = {}
N = int(input())
for _ in range(N):
  s = input()
  if s not in dic:
    dic[s] = 0
  else:
    dic[s] += 1
max_val = max(dic.values())
keys_of_max_val = [key for key in dic if dic[key] == max_val]
keys_of_max_val.sort()
for item in keys_of_max_val:
  print(item)

Solution (Python):
import collections


def main():
    n = int(input())
    s = collections.defaultdict(int)
    m = -1
    for i in range(n):
        t = input()
        s[t] += 1
        if m < s[t]:
            m = s[t]

    f = sorted(filter(lambda x: s[x] == m, s.keys()))
    for e in f:
        print(e)


if __name__ == '__main__':
    main()

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

def main():
    N = int(input())
    S = [input().strip() for _ in range(N)]
    c = collections.Counter(S)
    l = c.most_common()

    ans = []
    tmp = 0

    for i, x in enumerate(l):
        if i == 0:
            tmp = x[1]

        if x[1] == tmp:
            ans.append(x[0])
        else:
            break
    
    ans.sort()

    for x in ans:
        print(x)


if __name__ == "__main__":
    main()

Solution (Python):
import collections

n=int(input())
s=[]

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

d=collections.Counter(s).most_common()

ans=[]
past=d[0][1]

for i,m in d:
    if past==m:
        ans.append(i)
        past=m
    else:
        break

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

Solution (Python):
n=int(input())
dic={}
maxx=-1
for _ in range(n):
    s=input()
    if s in dic:
        dic[s]+=1
        
    else:
        dic[s]=1
    maxx=max(maxx,dic[s])
for i in sorted(dic.keys()):
    if dic[i]==maxx:
        print(i)

Solution (Python):
read = input 
rn = lambda :list(map(int, read().split()))
d = {}
n, = rn()
for i in range(n):
    s = read()

    if s not in d: d[s] = 0
    d[s] += 1
max_cnt = sorted(d.items(), key=lambda tp:tp[1])[-1][1] 
a1 = filter(lambda tp:tp[1] == max_cnt, d.items())
a2 = map(lambda tp:tp[0], a1)
for s in sorted(a2):
    print(s)

Solution (Python):
def num():
    return int(input())
def nums():
    return list(map(int,input().split()))

N = num()
used = {}
for _  in range(N):
    si = input()
    if si in used.keys():
        used[si] += 1
    else:
        used[si] = 0
l = sorted(used.items(),key=lambda x: x[1],reverse=True)
maxl = max([i[1] for i in l])
ans = []
for _,e in l:
    if e == maxl:
        ans.append(_)
    else:
        break
ans.sort()
for a in ans:
    print(a)

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

n = int(input())

s = [0] * n
for i in range(n):
    s[i] = input().strip()

import collections

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

first = counter.pop(0)
answers = [first[0]]
value = first[1]

for c in counter:
    if c[1] != value:
        break
    answers.append(c[0])

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

Solution (Python):
from sys import stdin

if __name__ == '__main__':
    N = int(stdin.readline().rstrip())
    d = {}
    for i in range(N):
        poll = stdin.readline().rstrip()
        if not poll in d:
            d[poll] = 1
        else:
            d[poll] += 1
    maxv = max(d.values())
    max_k_list = [kv[0] for kv in d.items() if kv[1] == maxv]
    for key in sorted(max_k_list):
        print(key)

Solution (Python):
import sys
from collections import Counter

n = int(input())
s = [sys.stdin.readline().strip() for _ in range(n)]

c = Counter(s)
kaisuu = c.most_common(1)[0][1]
kosuu = Counter([x[1] for x in c.most_common()])[kaisuu]

for label in sorted([x[0] for x in c.most_common(kosuu)]):
  print(label)

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

d = {}
m = 0
T = []
for i in range(n):
    s = input()
    if s not in d:
        d[s] = 1
    else:
        d[s] += 1
    m = max(m, d[s])

for key in d:
    if d[key] == m:
        T.append(key)

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

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

c = collections.Counter(s)
arr=c.most_common()
num=arr[0][1]
tmp=[]
for i in arr:
  if i[1]==num:
    tmp+=[i[0]]

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

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

dic = {}

print()

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

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

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

max_num = dic2[0][1]

l = [p[0] for p in dic2 if p[1] == max_num]

l2 = sorted(l)

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

Solution (Python):
N = int(input())
C = {}
for _ in range(N):
    s = input().strip()
    if s not in C:
        C[s] = 0
    C[s] += 1
C = sorted(list(C.items()),key=lambda x:x[0])
C = sorted(C,key=lambda x:x[1],reverse=True)
k = C[0][1]
for i in range(len(C)):
    if C[i][1]==k:
        print(C[i][0])
    else:break

Solution (Python):
n = int(input())
a = {}
for i in range(n):
    s = input()
    if s not in a.keys():
        a[s] = 1
    else:
        a[s] += 1
mx = 0
for i in a.keys():
    if a[i] >= mx:
        mx = a[i]

l = []
for i in a.keys():
    if a[i] == mx :
        l.append(i)
l = sorted(l)
for i in l:
    print(i)

Solution (Python):
from collections import Counter
n = int(input())
l = []
for i in range(n):
    l.append(input())
c = Counter(l)
cm = c.most_common()
m = cm[0][1]
r = [x for x,i in cm if i==m]
r.sort()
for x in r:
    print(x)

Solution (Python):










import math
import string

def intinput():
    return int(input())

def listintinput():
    return list(map(int,input().split()))

def splitintinput():
    return map(int,input().split())

N = intinput()
A = {}

for i in range(N):
    s = input()
    if s in A:
        A[s] += 1
    else:
        A[s] = 1
        
j = max(A.values())

maxalist = [kv[0] for kv in A.items() if kv[1] == j]
maxalist.sort()
for i in maxalist:
    print(i)

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

sc = Counter(s).most_common()

ans = [sc[0]]

if len(sc) == 1:
    pass
else:
    for i in range(1, n):
        if sc[i][1] == sc[0][1]:
            ans.append(sc[i])
        else:
            break

ans.sort()
for x in ans:
    print(x[0])

Solution (Python):

from collections import Counter
N = int(input())
S = []
for i in range(N):
    S.append(input())
s = Counter(S).most_common()
maximum = s[0][1]
tmp = []
for i in s:
    if i[1] == maximum:
        tmp.append(i[0])
    else:
        break
for i in sorted(tmp):
    print(i)

Solution (Python):
import collections
import itertools

n = int(input())
s = [0] * n
for i in range(n):
    s[i] = input()
c = collections.Counter(s)
cc = c.most_common()

ans = []

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

ans = sorted(ans)

for i in ans:
    print(i)

Solution (Python):
import sys
from collections import defaultdict

def solve(n, s):
    s_sorted = sorted(s.items(), key=lambda x: -x[1])
    pre = s_sorted[0][1]
    ans = []
    for word, count in s_sorted:
        if count != pre:
             break
        ans.append(word)
    for a in sorted(ans):
        print(a)
        

if __name__ == "__main__":
    n = int(sys.stdin.readline().strip())
    s = defaultdict(int)
    for _ in range(n):
        s_i = sys.stdin.readline().strip()
        s[s_i] += 1
    solve(n, s)

Solution (Python):

def main():
    d = dict()
    mx = 0
    n = int(input())
    for _ in range(n):
        s = input()
        if not s in d:
            d[s] = 1
        else:
            d[s] += 1

        if d[s] > mx:
            mx = d[s]
    lst = [s for s in d.keys() if d[s] == mx]
    lst.sort()
    for s in lst:
        print(s)



if __name__ == '__main__':
    main()

Solution (Python):

import sys
from collections import Counter


def solve(N: int, S: "List[str]"):
    cnt = Counter()
    for s in S:
        cnt[s] += 1
    
    lst = []
    mx = max(cnt.values())
    for key, val in cnt.items():
        if val == mx:
            lst += [key]

    for word in sorted(lst):
        print(word)
    
    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):
N=int(input())
d={}
for i in range(N):
  S=input()
  if S in d:
    d[S]+=1
  else:
    d[S]=1
l = sorted(d.items(), key=lambda x:x[1], reverse=True)
n=l[0][1]
s_list=[]
for c in l:
  if c[1] != n:
    break
  s_list.append(c[0])
s_list.sort()
for s in s_list:
  print(s)

Solution (Python):
from collections import defaultdict

N = int(input())
m = 0
d = defaultdict(int)
for i in range(N):
    S = input()
    d[S] += 1
    m = max(m, d[S])

X = []
for s in d:
    if d[s] == m:
        X.append(s)
X.sort()
for s in X:
    print(s)

Solution (Python):
if __name__ == "__main__":
    n = int(input())
    s = {}
    o = []
    for i in range(n):
        tmp = input()
        if tmp not in s.keys():
            s[tmp] = 1
        else:
            s[tmp] += 1
    s_sorted = sorted(s.items(), key=lambda x:x[1], reverse = True)
    
    l = s_sorted[0][1]
    for i in s_sorted:
        if i[1] == l:
            o.append(i[0])
        else:
            break
    
    for i in sorted(o):
        print(i)

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

import collections

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

sc = collections.Counter(s)
m = sc.most_common()

cc = m[0][1]
r = []
for v, c in m:
  if c != cc:
    continue
  r.append(v)
  
for v in sorted(r):
  print(v)

Solution (Python):
def A():
    A, B, C = map(int, input().split())
    if A == B or B == C or A == C:
        if (A+B+C) != A*3:
            print('Yes')
            return
    print('No')

def B():
    N = int(input())
    A = [int(i) for i in input().split()]
    for i in A:
        if i%2==0 and not (i%3==0 or i%5==0):
            print('DENIED')
            return
    print('APPROVED')

from collections import Counter
from itertools import takewhile
def C():
    N = int(input())
    lst = []
    for i in range(N):
        lst.append(input())

    c = Counter(lst)
    m = max(c.values())
    r = [x for x, _ in takewhile(lambda x: x[1]==m, c.most_common())] 
    for s in sorted(r):
        print(s)
C()

Solution (Python):
N = int(input())
s_list = {}
already = set()
for _ in range(N):
    s = input()
    if s in already:
        s_list[s] += 1
    else:
        s_list[s] = 0
    already.add(s)

max_value = max(s_list.values())
max_kv_list = [kv for kv in s_list.items() if kv[1] == max_value]
kv_list = []
for kv in max_kv_list:
    kv_list.append(kv[0])
kv_list.sort()
for kv in kv_list:
    print(kv)

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

s.sort()
ac = 0
ans = []
i = 0
while i < n:
  temp = s[i]
  j = i + 1
  while j < n:
    if s[j] == temp:
      j += 1
    else:
      j -= 1
      break
  if j == n:
    j -= 1
  c = j - i + 1
  if c > ac:
    ans = [temp]
    ac = c
  elif c == ac:
    ans.append(temp)
  i = j + 1

for x in ans:
  print(x)

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

for i in range(N):
  tmp = input()
  
  d[tmp] = d.get(tmp,0) + 1
  
m = max(d[i] for i in d)
max_list = [i for i in d if d[i] == m]

print("\n".join(sorted(max_list)))

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

Solution (Python):
import collections

n = int(input())
s = list(input() for i in range(n))


c = collections.Counter(s)

cm = c.most_common()

ans = []


max_num = cm[0][1]
for string, num in cm:
    if max_num == num:
        ans.append(string)

ans.sort()

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

Solution (Python):
n = int(input())
l = []
ll = [0] * n

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

l.sort()

i = 0

while i < n:
    cnt = 1

    while i + cnt < n and l[i] == l[i + cnt]:
        cnt += 1

    ll[i] = cnt
    i += cnt

m = max(ll)

for x in range(n):
    if ll[x] == m:
        print(l[x])

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

for i in range(N):
  if S[i] not in str_dict.keys():
    str_dict[S[i]] = 1
  else:
    str_dict[S[i]] += 1
else:
  max_val = max(str_dict.values())
  for i in str_dict:
    if str_dict[i] == max_val:
      answer.append(i)
  else:
    answer.sort()
    for i in range(len(answer)):
      print(answer[i])

Solution (Python):

n = int(input())
s = [ str(input()) for _ in range(n)]
d = {}
for i in range(n):
      if s[i] in d:
            d[s[i]] +=1
      else:
            d[s[i]] = 1
d = sorted(d.items(),key=lambda x: x[1],reverse=True)
m = d[0][1]
ans = []
for i in range(len(d)):
      if d[i][1]==m:
            ans.append(d[i][0])
      else:
            break
ans.sort()
for i in range(len(ans)):
      print(ans[i])

Solution (Python):


N = int(input())

X = {}
M = 0

for i in range(N):
    S = input()
    if not (S in X):
        X[S] = 0

    X[S] += 1
    M = max(M, X[S])

Y = sorted(map(lambda item:item[0],
               filter(lambda item:item[1] == M, X.items())))

for y in Y:
    print(y)

Solution (Python):



from collections import Counter

def main():
  n = int(input())
  Ss = [input().strip() for _ in range(n)]
  counts = sorted(Counter(Ss).items(), key=lambda x:x[1], reverse=True)
  max = counts[0][1]
  Ss_max = []
  for S, count in counts:
    if count != max:
      break
    Ss_max.append(S)
  print('\n'.join(sorted(Ss_max)))



if __name__=='__main__':
  main()

Solution (Python):
N = int(input())
S = [input() for _ in range(N)]
from itertools import groupby
S = sorted(S)
g = groupby(S)
ans = []
j = 0
for key,group in g:
  i = len(list(group))
  if i>j:
    ans = [key]
    j = i
  elif i==j:
    ans.append(key)
  else:
    continue

for a in ans:
  print(a)

Solution (Python):
from collections import Counter

def readlines(n):
    for _ in range(n):
        yield input()

def main():
    N = int(input())
    c = Counter(readlines(N))
    maxi = max(c.values())
    for k, v in sorted(c.items(), key=lambda x: x[0]):
        if v == maxi:
            print(k)




main()

Solution (Python):
import collections
n = int(input())
s = [input() for _ in range(n)]
c = collections.Counter(s)
a = c.most_common()
max = a[0][1]
a.sort(key=lambda x: x[0])
for i in range(len(a)):
    if a[i][1]==max:
        print(a[i][0])

Solution (Python):
import collections

n=int(input())

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

scount=collections.Counter(s)

maxc=scount.most_common()[0][1]

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


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

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

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

mx = max(cnt.values())
ans = sorted([v for v,c in cnt.items() if mx == c])
for v in ans:
    print(v)

Solution (Python):
n = int(input())
s = {}
for _ in range(n):
    s_i = input()
    if s_i not in s:
        s[s_i] = 0
    s[s_i] += 1
s = sorted(s.items(), key=lambda x:x[1])
m = s[-1][1]
ans = []
for i in reversed(range(len(s))):
    if s[i][1] == m: ans.append(s[i][0])
    else: break
ans.sort()
for i in range(len(ans)): print(ans[i])

Solution (Python):
import itertools
import sys
import math
import numpy as np
from collections import deque
from itertools import combinations
from functools import lru_cache
sys.setrecursionlimit(10**9)

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

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

    max = 0
    ans = []
    for s, count in dic.items():
        if count > max:
            ans = [s]
            max = count
        elif count == max:
            ans.append(s)

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



if __name__ == "__main__":
  main()

Solution (Python):



def solve(*args: str) -> str:
    n = int(args[0])
    S = args[1:]
    D = {}
    for s in S:
        if s not in D:
            D[s] = 1
        else:
            D[s] += 1
    m = max(D.values())
    A = [a[0] for a in sorted(D.items(), key=lambda x: (
        -x[1], x[0])) if a[1] == m]

    return '\n'.join(A)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

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

result = []
for k, v in D.items():
    if v == max_num:
        result.append(k)

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

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

c = collections.Counter(s)

ans = []
most = c.most_common()
max_size = most[0][1]
for i in range(len(most)):
    if max_size != most[i][1]:
        break
    else:
        ans.append(most[i][0])

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

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

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

n = ni()
d = defaultdict(int)
for _ in range(n):
    s = ns()
    d[s] += 1
d = sorted(d.items(), key = lambda x:x[1], reverse=True)
ki, vi = d[0]
k = [ki]
for ki, v in d[1:]:
    if v == vi:
        k.append(ki)
k.sort()
for ki in k:
    print(ki)

Solution (Python):
from collections import Counter


N = int(input())

str_list = []

ctr_list = Counter()

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

sort_list = []
max_value = 0
for each_str in ctr_list.most_common():
    if max_value <= each_str[1]:
        max_value = each_str[1]
        sort_list.append(each_str[0])

for each_str in sorted(sort_list):
    print(each_str)

Solution (Python):


N = int(input().split()[0])
c_list = []
c_dict = {}
cc_dict = {}
max_v = -float("inf")

for _ in range(N):
    c = input()
    c_list.append(c)
    if c in c_dict:
        v = c_dict[c] + 1
        c_dict[c] = v
    else:
        v = 0
        c_dict[c] = 0
        
    if v in cc_dict:
        cc_dict[v].append(c)
    else:
        cc_dict[v] = [c]

    if max_v < v:
        max_v = v

k_list = cc_dict[max_v]
k_list = list(sorted(k_list))
ans = "\n".join(k_list)

print(ans)

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

result = []
max_num = max(S.values())
for item in S:
    if S[item] == max_num:
        result.append(item)

result = set(result)
result = sorted(result)
for r in result:
    print(r)

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

dict = dict()

written_max = 0

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

dict_sorted = sorted(dict.items(), key=lambda x:x[0])

for item in dict_sorted:
	if item[1] == written_max:
		print(item[0])

Solution (Python):

import sys
import collections
import heapq

def solve(N: int, S: "List[str]"):
    count_dict = collections.defaultdict(int)
    for s in S:
        count_dict[s] += 1
    
    largest = heapq.nlargest(1, [y for x, y in count_dict.items()])[0]
    answer_list = []
    for k, v in count_dict.items():
        if v == largest:
            answer_list.append(k)
    answer_list = sorted(answer_list)
    for ans in answer_list:
        print(ans)
    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 = [input() for _ in range(n)]

counter = Counter(s)
index = 0
ans = []
for k, v in counter.most_common():
    if index == 0:
        max_v = v
        ans.append(k)
    else:
        if v == max_v:
            ans.append(k)
        else:
            break
    index += 1
ans = sorted(ans)
for i in range(len(ans)):
    print(ans[i])

Solution (Python):
from collections import defaultdict

n = int(input())
counts = defaultdict(int)

for _ in range(n):
    counts[input().strip()] += 1

vec = sorted([(value, key) for key, value in counts.items()])
best = vec[-1][0]
keys = sorted([key for value, key in vec if value == best])
for key in keys:
    print(key)

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

current_max = 0
current = []
table = {}

for i in range(n):
    s = input().rstrip()
    table[s] = table[s] + 1 if table.get(s) is not None else 0
    if table[s] > current_max:
        current = [s]
        current_max = table[s]
    elif table[s] == current_max:
        current.append(s)
    else:
        continue

current.sort()

for word in current:
    print(word)

Solution (Python):
import collections

n = int(input())
lst = []
for _ in range(n):
    lst.append(input())
ans = []

cnt = collections.Counter(lst).most_common()

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

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

Solution (Python):
import sys
input=sys.stdin.readline
n=int(input())
p=[]
for i in range(n):
	s=input().rstrip()
	p.append(s)
p.sort()
ans=0
cnt=1
for i in range(n-1):
	if p[i]==p[i+1]:
		cnt+=1
	else:
		ans=max(ans,cnt)
		cnt=1
ans=max(ans,cnt)
q=[]
for i in range(n-ans+1):
	if p[i]==p[i+ans-1]:
		q.append(p[i])
q.sort()
for i in range(len(q)):
	print(q[i])

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

sl=[]
for i in range(n):
    s=input()
    sl.append(s)
    
import collections

c=collections.Counter(sl)

d=(c.most_common())

e=[d[0][0]]
tmp=d[0][1]
for i,j in d:
    if tmp==j:
        e.append(i)
    else:
        break
e=list(set(e))
e.sort()
for i in e:
    print(i)

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

S = {}

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

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

t = []
max_v = 0
for k, v in SS:
    if v < max_v:
        break

    t.append(k)
    max_v = v 

print("\n".join(sorted(t)))

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

li = []
a = L[0][1]
for i in range(len(L)):
    if L[i][1] == a:
        li.append(L[i][0])
li.sort()
for i in range(len(li)):
    print(li[i])

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

d = dict()
m = 0
for i in range(N):
    s = input()
    if s not in d:
        d[s] = 0
    d[s] += 1
    if m < d[s]:
        m = d[s]

result = list()
for x in d:
    if d[x] == m:
        result.append(x)

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

Solution (Python):
n = int(input())
s = []
for _ in range(n):
    s.append(input())
d = {}
name = set(s)
for a in name:
    d.update({a:0})
for x in s:
    d[x] += 1
ds = sorted(d.items(), key=lambda x:x[1])
max = ds[-1][1]
ans = []
for x in reversed(ds):
    if x[1]==max:
        ans.append(x[0])
    else:
        break
ans.sort()
for x in ans:
    print(x)

Solution (Python):

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

poll = dict()

for key in S:
    poll[key] = poll.get(key, 0) + 1

max_num = max(poll.values())
results = [key for key in poll if poll[key] == max_num]
results.sort()

for s in results:
    print(s)

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

m = 0
for key,value in s.items():
    if value > m:
        m = value
        ans = [key]
    elif value == m:
        ans.append(key)
ans.sort()
print(*ans,sep='\n')

Solution (Python):
from collections import Counter



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

Ss_cnt = Counter(Ss)
common = Ss_cnt.most_common()
most = common[0][1]
cand = []
for e in common:
    if e[1] == most:
        cand.append(e[0])
    else:
        break

cand.sort()


for c in cand:
    print(c)

Solution (Python):

def main():
    from sys import stdin, setrecursionlimit
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

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

    from collections import Counter
    S=Counter(a)
    b = sorted(S.items(), key=lambda x:(-x[1],x[0])) 
    m = b[0][1]
    for i in b:
        if i[1] == m:
            print(i[0])
        else:
            break

if __name__ == '__main__':
    main()

Solution (Python):
from collections import defaultdict
import sys
N = int(input())
input = sys.stdin.readline

c = defaultdict(int)

maxC = 0

for _ in range(N):
    s = input().strip()
    c[s] += 1
    tmp = c[s]
    if tmp > maxC:
        maxC = tmp

ans = []

for k in c:
    if c[k] == maxC:
        ans.append(k)

ans.sort()

for a in ans:
    print(a)

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

count = dict()
for _ in range(N):
    x = input()
    count[x] = count.get(x, 0) + 1

max_val = -float("infinity")
for k, v in sorted(count.items(), key=lambda x: (-x[1], x[0])):
    max_val = max(v, max_val)
    if v == max_val:
        print(k)
    else:
        break

Solution (Python):
import collections

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

counter =  collections.Counter(arr).most_common()

res = []
temp = 0
for x, y in counter:
    if y < temp:
        break
    temp = y
    res.append(x)

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

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

dd = []
for k,v in d.items():
  if v == dmax:
    dd.append(k)

dd.sort()
for dv in dd:
  print(dv)

Solution (Python):
n=int(input())
dic={}
m=0
li=[]

for _ in range(n):
    w=input()
    dic[w]=dic.get(w, 0)+1
    if dic[w]==m:
        li.append(w)
    elif dic[w]>m:
        li=[w]
        m+=1

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

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

s.sort()

l = []
ans_count = 0
count = 1
S = s[0]
for i in range(1,n):
    if S == s[i]:
        count += 1
        if i == n-1:
            l.append([S,count])
            ans_count = max(ans_count,count)
    else:
        l.append([S,count])
        S = s[i]
        ans_count = max(ans_count,count)
        count = 1
        if i == n-1:
            l.append([S,count])
            ans_count = max(ans_count,count)


ans = []
for i in l:
    if i[1] == ans_count:
        ans.append(i[0])
ans.sort()
for i in ans:
    print(i)

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

from collections import defaultdict
d = defaultdict(int)

for i in range(n):
  k = input()
  d[k] += 1

m = max(d.values())
ans = []
for k,v in d.items():
  if v == m:
    ans.append(k)
for i in sorted(ans):
  print(i)

Solution (Python):
n = int(input())
dic = {}
for _ in range(n):
  s = input()
  if s in dic.keys():
    dic[s] += 1
  else:
    dic[s] = 1
    
dic = [[k,v] for (k, v) in dic.items()]
dic.sort(key=lambda x:x[1], reverse=True)

n = dic[0][1]
dic = [k for (k,v) in dic if v == n]
dic.sort()
for s in dic:
  print(s)