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):
from collections import Counter
def solve(N, S):
    c = Counter(S)
    m = max(c.values())
    ans = []
    for x, y in c.items():
        if y == m:
            ans.append(x)
    ans.sort()
    for i in ans:
        print(i)


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

if __name__ == "__main__":
    main()

Solution (Python):
from collections import defaultdict
d = defaultdict(int)

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

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

li = []
ma = 0

for s in d:
  if ma == d[s]:
    li.append(s)
    ma = d[s]
    
  if ma < d[s]:
    li = []
    li.append(s)
    ma = d[s]

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

Solution (Python):
n=int(input())
dic={}
for _ in range(n):
  inp=input()
  dic.setdefault(inp,0)
  dic[inp]+=1
maxval=0
maxkey=[]
for key,val in dic.items():
  if maxval==val:
    maxkey.append(key)
  elif val>maxval:
    maxkey=[key]
    maxval=val
maxkey.sort()
for i in maxkey:
  print(i)

Solution (Python):


import sys
import math

from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint

INF = float('inf')

ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
sys.setrecursionlimit(1000000000)


def lcm(a, b):
    return (a * b) // gcd(a, b)



N = ii()
slist = {}
maxvalue = 0

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

    if maxvalue < slist[S]:
        maxvalue = slist[S]

maxs = []
for s in slist:
    if slist[s] == maxvalue:
        maxs.append(s)


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

Solution (Python):
from collections import Counter

N = int(input())
S = [input() for _ in range(N)]
c = Counter(S)
ma = 0
ans = []
for k, v in c.most_common():
    if v >= ma:
        ma = v
        ans.append(k)
    else:
        break
ans.sort()
print(*ans, sep='\n')

Solution (Python):
import collections

n = int(input())


d = collections.defaultdict(lambda:0)

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

d = dict(d)

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

most = a[0][1]
ans = []

for k, v in a:
    if v == most:
        ans.append(k)
    else:
        break

ans.sort()

for i in ans:
    print(i)

Solution (Python):
n = int(input())
a = []
for i in range(n):
  si = str(input())
  a.append(si)
a.sort()
mx = 1
w = []
j = 1
for i in range(1,n):
  if a[i] == a[i-1]:
    j += 1
  else:
    if j > mx:
      w = [a[i-1]]
      mx = j
    elif j == mx:
      w.append(a[i-1])
    j = 1
if j > mx:
  w = [a[n-1]]
elif j == mx:
  w.append(a[n-1])
for wi in w:
  print(wi)

Solution (Python):
N = int(input())
D = {}
ans = []
ansval = 0
for _ in range(N):
    s = input()
    if s not in D:
        D[s] = 1
    else:
        D[s] += 1
    if ansval == D[s]:
        ans.append(s)
    elif ansval < D[s]:
        ans = [s]
        ansval = D[s]
ans.sort()
for a in ans:
    print(a)

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

lst = [input() for i in range(N)]

import collections

c = dict(collections.Counter(lst))
c_s = sorted(c.items(), key=lambda x:-x[1])
ma = c_s[0][1]
ans = []
for i in c_s:
  if (i[1] == ma):
    ans.append(i[0])
s_ans = sorted(ans)
for i in s_ans:
  print(i)

Solution (Python):
n = int(input())
L = []
anslist = []
for i in range(n):
  s = input()
  L.append(s)
L.sort()
L.append('zzzzzzzzzzzzz')
cntmax = 1
cur = L[0]
temp = 1
for i in range(1,n+1):
  if L[i] == cur:
    temp += 1
  else:
    cur = L[i]
    cntmax = max(cntmax,temp)
    temp = 1
cur = L[0]
temp = 1
for i in range(1,n+1):
  if L[i] == cur:
    temp += 1
  else:
    cur = L[i]
    if temp == cntmax:
      anslist.append(L[i-1])
    temp = 1
anslist.sort()
for i in range(len(anslist)):
  if anslist[i] != 'zzzzzzzzzzzzz':
    print(anslist[i])

Solution (Python):
import collections
n = int(input())
dd = collections.defaultdict(int)
for _ in range(n):
    dd[input()] += 1
ans = []
for key in dd.keys():
    ans.append((dd[key], key))
ans.sort(reverse=True)
ans2 = [ans[0][1]]
for i in range(1, len(ans)):
    if ans[i - 1][0] != ans[i][0]:
        break
    ans2.append(ans[i][1])
ans2.sort()
print(*ans2, sep='\n')

Solution (Python):
from collections import Counter
N=int(input())
S=sorted([input() for _ in range(N)])
S=Counter(S).most_common()
m=S[0][1]

ans=[]
for i in S:
  if i[1]==m:
    ans.append(i[0])
  else:
    break

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

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


def get_nums_l():
    return [ int(s) for s in input().split(" ")]


def get_nums_n(n):
    return [ int(input()) for _ in range(n)]


def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

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

m = {}
for s in sss:
    if s in m:
        m[s] += 1
    else:
        m[s] = 1

items = m.items()
items = list(sorted(items, key=lambda i:i[0]))
items = list(sorted(items, key=lambda i: i[1], reverse=True))

max_ = items[0][1]
i = 0
while i<len(items) and items[i][1] == max_:
    print(items[i][0])
    i+=1

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

for row in r:
  max = row
  break
for row in r:
  if r[row] > r[max]:
    max = row

ans = []
for row in r:
  if r[row] == r[max]:
    ans.append(row)
A = sorted(ans)
for a in A:
  print(a)

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

dic = Counter(strs)
max_count = max(dic.values())

results = []
for k, v in dic.items():
  if v == max_count:
    results.append(k)
      
for s in sorted(results):
  print(s)

Solution (Python):
from collections import defaultdict
from collections import deque
from string import ascii_uppercase
import sys, bisect, math, heapq

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N = read_int()[0]
S_array = [list(read_str().split())[0] for _ in range(N)]

dic = defaultdict(lambda: int())
def solve():
    ans = 0
    res = []
    for s in S_array:
        dic[s] += 1
    for _, v in dic.items():
        ans = max(ans, v)
    for k, v in dic.items():
        if v == ans:
            res.append(k)
    res.sort()
    for r in res:
        print(r)

if __name__ == "__main__":
    solve()

Solution (Python):
import collections

N = int(raw_input())

l = []

for i in range(N):
    l.append(raw_input())

c = collections.Counter(l)

values, counts = zip(*c.most_common())

num_max = counts[0]
index_list = []

for i in range(len(counts)):
    if counts[i] == num_max:
        index_list.append(i)

ans_list = []
for item in index_list:
    ans_list.append(values[item])

for item in sorted(ans_list):
    print item

Solution (Python):
import collections

n = int(input())

s=[]
for i in range(n):
    s.append(input())
    
c = collections.Counter(s)
c = sorted(c.items())
c_sorted = sorted(c, key=lambda x:x[1],reverse=True)

num=c_sorted[0][1]
for i in c_sorted:
    if num==i[1]:
        print(i[0])
    else:
        break

Solution (Python):
n=int(input())
d=dict()
for _ in range(n):
    s=input()
    if s in d:
        d[s]+=1
    else:
        d[s]=1
keys=d.keys()
values=d.values()
m=max(values)
ans=[]
for k,v in zip(keys,values):
    if v==m:
        ans.append(k)
ans.sort()
for a in ans:
    print(a)

Solution (Python):
from collections import defaultdict
d = defaultdict(int)

n = int(input())
maximum = 0
for _ in range(n):
    s = input()
    d[s] += 1
    maximum = max(maximum, d[s])
    
sorted_d = sorted(d.items())
for k, v in sorted_d:
    if v == maximum:
        print(k)

Solution (Python):
import collections as c
import sys
input = sys.stdin.readline
ip = lambda : map(int, input().split())
mod = 10**9+7

N = int(input())
dic = {}
for i in range(N):
    s = input()
    s = s[:-1]
    dic[s] = dic.get(s,0) + 1
m = max(dic.values())
ans = []
for i in dic:
    if dic[i]==m:
        ans.append(i)
ans.sort()
for i in ans:
    print(i)

Solution (Python):
n = int(input())
a = [""] * n
for i in range(n):
    a[i] = input()

a.sort()

ans = []
count = 1
for i in range(n-1):
    if a[i] != a[i+1]:
        ans.append((-count, a[i]))
        count = 1
    else:
        count += 1

ans.append((-count, a[-1]))

ans.sort()
mx, _ = ans[0]
for c, s in ans:
    if c == mx:
        print(s)
    else:
        break

Solution (Python):

N = int(input())

S_dict = {}
max_num = 0
for i in range(N):
    S = str(input())
    now_num = S_dict.get(S, 0) + 1
    S_dict[S] = now_num
    max_num = max(max_num, now_num)

ans_list = [k for k, v in S_dict.items() if v == max_num]
ans_list.sort()

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

Solution (Python):
n = int(input())
mx = 1
d = {}
for i in range(n):
    s = input()
    if s not in d:
        d[s] = 1
    else:
        d[s] += 1
    mx = max(mx, d[s])
spis = []
for k, z in d.items():
    if z == mx:
        spis.append(k)
spis.sort()
for a in spis:
    print(a)

Solution (Python):
from sys import stdin
n = int(stdin.readline().rstrip())
st = [stdin.readline().rstrip() for _ in range(n)]
dic = {}
for s in st:
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1

dic = sorted(dic.items(), key=lambda x: -x[1])
vmax = 0
res = []
for k, v in dic:
    vmax = max(vmax, v)
    if vmax == v:
        res.append(k)
    else:
        break
for s in sorted(res):
    print(s)

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

from collections import Counter
def main():
    n = ii()
    S = []
    for _ in range(n):
        S.append(input())
    c = Counter(S)
    d = c.most_common()
    ans = []
    mm = 0
    for i in range(len(c)):
        if mm > d[i][1]:
            break
        ans.append(d[i][0])
        mm = d[i][1]
    ans.sort()
    for i in range(len(ans)):
        print(ans[i])

main()

Solution (Python):
N = int(input())
S = dict()
for i in range(N):
    s = input()
    if s not in S:
        S[s] = 1
    else:
        S[s] += 1
S = sorted(S.items(), key=lambda x:(x[1],x[0]))
m = S[-1][1]
for i in range(len(S)):
    s = S[i][0]
    if S[i][1] == m:
        print(s)

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

d = dict()

for i in range(N):
    s = input()
    try:
        d[s] += 1
    except KeyError:
        d[s] = 1

max_value = max(d.values())


res_ls = []

for k, v in d.items():
    if v == max_value:
        res_ls.append(k)
        
for r in sorted(res_ls):
    print(r)

Solution (Python):
import collections

n = int(input())

res = []

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

c = collections.Counter(res)
aa = c.most_common()

ss = aa[0][1]
res2 = []

aa.sort()
for i in aa:
  if i[1] == ss:
    res2.append(i[0])

for i in res2:
  print(i)

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

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

c = Counter(S)

maxc = max(c.values())

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

a.sort()

for s in a:
    print(s)

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

c = collections.Counter(l)
cc = c.most_common()
cc.sort(key=lambda x: x[1],reverse=True)
ll = []
m = 0
for k,v in cc:
    if v >= m:
        m = v
        ll.append((k))
ll = sorted(ll)
for a in ll:
    print(a)

Solution (Python):
import sys 
import heapq 
from collections import defaultdict
fastinp = lambda: sys.stdin.readline().split(' ')[0].split('\n')
inp = lambda: input().split(' ')
ml = lambda x, y=int: list(map(y, x))
debug = lambda *args: print(*args, sep=' | ')
n = int(fastinp()[0])
hmap = defaultdict(int)
for i in range(n):
    hmap[fastinp()[0]] += 1
m = 0
for k, v in hmap.items():
    m = max(m, v)
list = []
for k, v in hmap.items():
    if v == m:
        list.append(k)
print(*sorted(list), sep='\n')

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

m = max(d.values())

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

for a in ans:
    print(a)

Solution (Python):
import sys
inputs = sys.stdin.readlines()
from collections import Counter

n = int(inputs[0])
S = [s.strip() for s in inputs[1:]]
counter = Counter(S)
m = max(counter.values())
print(*sorted([k for k, v in counter.items() if v == m]), sep='\n')

Solution (Python):
from itertools import groupby

N=int(input())
S=['a' for i in range(0,N)]
for i in range(0,N):
    S[i]=input()
S.sort()
X=groupby(S)
data=[]
for key,group in X:
    g=len(list(group))
    data.append([g,key])
data.sort()
m=data[len(data)-1][0]
for i in range(0,len(data)):
    if data[i][0]==m:
        print(data[i][1])

Solution (Python):
n= int(input())
s = [input() for _ in range(n)]
r = {}
g=0
for c in s:
    r[c] = r.get(c,0) + 1
    g = max(g,r[c])
word = []
for c in r.keys():
    if r[c]==g:word.append(c)
word.sort()
for c in word:print(c)

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

import collections
c = collections.Counter(S).most_common()

m = c[0][1]
ans = []
for a, b in c:
    if b == m:
        ans.append(a)

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

Solution (Python):
from collections import Counter
n = int(input())
s = [input() for _ in [0] * n]
s = Counter(s)
a = max(s.values())
b = s.most_common()[:list(s.values()).count(a)]
b = sorted(b, key=lambda x: x[0])
for i in b:
    print(i[0])

Solution (Python):
import collections
n=int(input())
a=list(input() for i in range(n))

a = collections.Counter(a)
a= a.most_common()
b=[]
b.append(a[0][0])
for i in range(len(a)-1):
    if a[i][1]==a[i+1][1]:
        b.append(a[i+1][0])
    else:
        break

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

Solution (Python):
def main():
    n = int(input())
    table = {}
    m = 0
    for i in range(n):
        s = input()
        if s not in table:
            table[s] = 0
        table[s] += 1
        m = max(m, table[s])

    table = dict(filter(lambda x: x[1] == m, table.items()))
    table = sorted(table.items(), key=lambda x: x[0])

    for t in table:
        print(t[0])


main()

Solution (Python):
n = int(input())
s = []
for i in range(n):
    s.append(input())
s.sort()
s.append('
x = 1
ls = []
for i in range(n):
    if s[i] == s[i+1]:
        x += 1
    else:
        ls.append((x,s[i]))
        x = 1
ls.sort()
ls.reverse()
ls.append((0,'
ans = []
ans.append(ls[0][1])
for i in range(1,n):
    if ls[i-1][0] == ls[i][0]:
        ans.append(ls[i][1])
    else:
        break
ans.sort()
for x in ans:
    print(x)

Solution (Python):
def get_keys_from_value(d_, val_):
    return [k for k, v in d_.items() if v == val_]
import collections

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

for i in range(n):
    s.append(input())
c = collections.Counter(s)

max_val = max(c.values())
ans = sorted(get_keys_from_value(c, max_val))

for i in ans:
    print(i)

Solution (Python):


n=int(input())

s={}
cnt=0
result=[]

for _ in range(n):
    temp = input()
    if temp in s:
        s[temp]+=1
        if s[temp]>cnt:
            cnt=s[temp]
            result=[temp]
        elif s[temp]==cnt:
            result.append(temp)
    else:
        s[temp]=1
        if s[temp]>cnt:
            cnt=s[temp]
            result=[temp]
        elif s[temp]==cnt:
            result.append(temp)
result.sort()
for item in result:
    print(item)

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




l_ = []
max_ = max(d.values())

for k, v in d.items():
    if v == max_:
        l_.append(k)

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

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
import pprint
sys.setrecursionlimit(10 ** 9)


INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
cnt = Counter(SR(n))
L = [(k, v) for k, v in cnt.items()]
L.sort()
L.sort(key=lambda x:x[1], reverse=True)
pre_v = L[0][1]
for k, v in L:
    if v != pre_v:
        break
    print(k)

Solution (Python):
from collections import Counter
N = int(input())
Sl = [input() for _ in range(N)]
cSl = Counter(Sl).most_common()
pre = ""
maxl = []
for k, v in cSl:
    if pre != "" and pre != v:
        break
    maxl.append(k)
    pre = v
for e in sorted(maxl):
    print(e)

Solution (Python):
import collections

N = int(input())
table = []
ans = []

for i in range(N):
    s = input()
    table.append(s)

c = collections.Counter(table).most_common()

pre_x = c[0][1]
for s,x in c:
    if pre_x != x:
        break
    ans.append(s)
    pre_x = x

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

Solution (Python):
import collections
n = int(input())
s = list()
for i in range(n):
    s.append(input())
l = collections.Counter(s)
count = list(l.items())
count.sort(key=lambda x: x[1], reverse=True)
ind, x = 0, count[0][1]
for i in range(len(count)):
    if count[i][1] != x:
        ind = i-1
        break
    else:
        ind = i
x = count[:ind+1]
x.sort()
for i in range(ind+1):
    print(x[i][0])

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

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

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

maxV = 0
maxK = []

for key, val in nums.items():
    maxV = max(maxV, val)

for key, val in nums.items():
    if val == maxV:
        maxK.append(key)




maxK.sort()

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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

dic = defaultdict(int)

for x in S:
	dic[x] += 1

ma = max(dic.values())

a = []
for i in dic.items():
	if i[1] == ma:
		a.append(i[0])

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

Solution (Python):
import collections

n = int(input())
s = [input() for i in range(n)]
c = collections.Counter(s)
z = c.most_common()[0][1]
ans = []
for i in c.most_common():
    if i[1] == z:
        ans.append(i[0])
    else:
        break
ans.sort()
for j in ans:
    print(j)

Solution (Python):
import collections
n = int(input())
s = []
for i in range(n):
    S = str(input())
    s.append(S)
c = collections.Counter(s)
jud = c.most_common()[0][1]
set_s = set(s)
lists = []
for i in set_s:
    if jud == int(c[i]):
        lists.append(i)
lists.sort()
for i in range(len(lists)):
    print(lists[i])

Solution (Python):
n = int(input())
dic = {}
for i in range(n):
	s = input()
	if s in dic:
		dic[s] += 1
	else:
		dic[s] = 1
dic2 = sorted(dic.items(), key=lambda x:x[1],reverse=True)
x = dic2[0][1]
b = []

for i in dic2:
	if i[1] == x:
		b.append(i[0])
b.sort()
for i in b:
	print (i)

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

S_dic = {}
maximum = 0
for n in range(N):
    S = input()
    if S not in S_dic:
        S_dic[S] = 1
    else:
        S_dic[S] += 1
    if maximum < S_dic[S]:
        maximum = S_dic[S]


for key, value in sorted(S_dic.items(), key=lambda x: x[0]):
    if value == maximum:
        print(key)

Solution (Python):
N = int(input())
S = [input() for i in range(N)]
d = dict()
for s in S:
    if s in d:
        d[s] += 1
    else:
        d[s] = 1
l = sorted(d.items(), key=lambda x: x[1], reverse=True)
maxv = l[0][1]
res = []
for x in l:
    if x[1] == maxv:
        res.append(x[0])
for x in sorted(res):
    print(x)

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

maxw = max(d.values())

ans = [k for k, v in d.items() if v == maxw]
ans.sort()
for i in ans:
    print(i)

Solution (Python):
from collections import Counter

n=int(input())
l=[]
for i in range(n):
    l.append(input())
l=Counter(l).most_common()
Max=l[0][1]
ans=[]
for i,j in l:
    if j==Max:
        ans.append(i)
for i in sorted(ans):
    print(i)

Solution (Python):
if __name__ == '__main__':
    n = int(input())
    d = {}
    max = 1


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

    dict2 = sorted(d.items())
    for i in dict2:
        if i[1] == max:
            print(i[0])

Solution (Python):
import collections

N=int(input())
S=[]
for i in range(N):
  S.append(input())
c = collections.Counter(S)
d = c.most_common()

ans_list=[]
maxi=d[0][-1]
for i,item in enumerate(d):
  if d[i][-1] == maxi:
    ans_list.append(item[0])
    
ans_list.sort()
for item2 in ans_list:
  print(item2)

Solution (Python):
n = int(input())
s = [input() for _ in range(n)]
d = {}
for i in range(n):
    d[s[i]] = d.get(s[i],0)+1

m = max(d.values())
lst = []
for key in d:
    if d[key] == m:
        lst.append(key)

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

Solution (Python):
from collections import Counter
N = int(input())
S = Counter(input() for _ in range(N))
S = S.most_common()
most_count = S[0][1]
S.sort()
for i in range(len(S)):
    if S[i][1] == most_count:
        print(S[i][0])

Solution (Python):
from collections import Counter

n = int(input())
c = Counter()
for i in range(n):
  s = input()
  c[s] += 1

_, maxi = c.most_common()[0]
ans = []
for s, i in c.most_common():
  if i != maxi:
    break
  ans.append(s)
  
for s in sorted(ans):
  print(s)

Solution (Python):
from collections import Counter


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

c = Counter(S)

max_ = 0

x = []
for k, v in c.items():
    max_ = max(max_, v)
    x.append([k, v])

x.sort(key=lambda x: (-x[1], x[0]))


for k, v in x:
    if v == max_:
        print(k)

    if v != max_:
        exit()

Solution (Python):
N = int(input())
dic = {}
maxi = 0
res = []
for _ in range(N):
    s = input()
    if s in dic.keys():
        dic[s] += 1
    else:
        dic[s] = 1
    if dic[s] > maxi:
        maxi = dic[s]
for key in dic.keys():
    if dic[key] == maxi:
        res.append(key)

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

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

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

m = 0
for k in dict:
  m = max(dict[k], m)

arr = []

for k in dict:
  if dict[k] == m:
    arr.append(k)

arr.sort()

for k in arr:
  print(k)

Solution (Python):
import collections
L = [input() for x in range(int(input()))]
L = collections.Counter(L)
LMC = L.most_common()
max_N = L.most_common()[0][1]
R = []
for x in LMC:
    if x[1] == max_N:
        R.append(x[0])
R.sort()
print("\n".join(R))

Solution (Python):
N=int(input())
d={}
cnt=0
for i in range(N):
  s=input()
  if s not in d:
    d[s]=1
  else:
    d[s]+=1
  if cnt<d[s]:
    cnt=d[s]
ans=[]
for k in d:
  if d[k]==cnt:
    ans.append(k)
ans=sorted(ans)
for i in ans:
  print(i)

Solution (Python):
import collections

n = int(input())

s = []

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

c = collections.Counter(s)
cc = c.most_common()
mx = cc[0][1]
cc.sort(key = lambda x:x[0])

for i in range(len(cc)):
    if cc[i][1] == mx:
        print(cc[i][0])

Solution (Python):
from operator import itemgetter
n=int(input())
s=[input() for i in range(n)]
d=dict()
for i in range(n):
  if s[i] not in d:
    d[s[i]]=1
  else:
    d[s[i]]+=1
d=list(d.items())
d.sort()
d.sort(key=itemgetter(1),reverse=True)
maxi=d[0][1]
for i in range(len(d)):
  if d[i][1]==maxi:
    print(d[i][0])
  else:
    exit()

Solution (Python):
from collections import defaultdict
N = int(input())
S = [input() for _ in range(N)]
d = defaultdict(int)
maxn = 0

for i in range(N):
    d[S[i]] += 1
    maxn = max(maxn, d[S[i]])

ans = []
for k, v in d.items():
    if v == maxn:
        ans.append(k)
ans.sort()
for s in ans:
    print(s)

Solution (Python):



from fractions import gcd
import math

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

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

yes = 'APPROVED'
no = 'DENIED'

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

    anslist = []

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



main()

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

from collections import Counter

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

C = Counter(S)

lst = [[] for _ in range(N + 1)]

saidai = 0
for c in C:
    lst[C[c]].append(c)
    saidai = max(saidai, C[c])

ans = lst[saidai]
ans.sort()

for tmp in ans:
    print (tmp, end = '')

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

M = []
C = collections.Counter(S)
max = C.most_common()[0][1]
for c in C.most_common():
    if c[1] == max:
        M.append(c[0])
M.sort()
for m in M:
    print(m)

Solution (Python):


import sys
import math
import itertools

def main():
    n = int(sys.stdin.readline())
    ss = [sys.stdin.readline().strip() for _ in range(n)]

    ss.sort()
    votes = [(-sum(1 for _ in g), k) for k, g in itertools.groupby(ss)]
    votes.sort()

    for v, k in votes:
        if v != votes[0][0]:
            break
        print(k)

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
words = []
for _ in range(N):
    words.append(input())
count_table = {}
for w in words:
    if w in count_table:
        count_table[w] += 1
    else:
        count_table[w] = 0
best_count = 0
best_words = []
for w in count_table:
    if best_count < count_table[w]:
        best_count = count_table[w]
        best_words = [w]
    elif best_count == count_table[w]:
        best_words.append(w)
for w in sorted(best_words):
    print(w)

Solution (Python):
from collections import defaultdict

N = int(input())

dic = defaultdict(lambda :0)

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

m = max(dic.values())

D = [k for k, v in dic.items() if v == m]
D.sort()
for s in D:
    print(s)

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

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))



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

d = defaultdict(int)
for i in range(N):
    d[S[i]] += 1

k = 0
ans = []
for x in d.items():
    if x[1] > k:
        k = x[1]
        ans = [x[0]]
    elif x[1] == k:
        ans.append(x[0])
    else:
        pass

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

Solution (Python):
from collections import defaultdict

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

    max_d = max(d.values())
    ans = []
    for key, value in d.items():
        if value == max_d:
            ans.append(key)
    ans.sort()
    for a in ans:
        print(a)
    
    



if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
dic = {}
for i in range(n):
    word = input()
    if word in dic:
        dic[word] += 1
    else:
        dic[word] = 1
answer = []
max_dic = 0
for word, cnt in dic.items():
    if cnt > max_dic:
        max_dic = cnt
for word, cnt in dic.items():
    if cnt == max_dic:
        answer.append(word)
answer.sort()
for ans in answer:
    print(ans)

Solution (Python):
import collections

N = int(input())
S = [input() for _ in range(N)]
S_count = collections.Counter(S)
S_count_sort = sorted(S_count.items(), key=lambda x: x[1], reverse=True)

ans_list = []
for i, k in enumerate(S_count_sort):
    if i == 0:
        before_v = k[1]
        ans_list.append(k[0])
    else:
        if k[1] != before_v:
            break
        else:
            ans_list.append(k[0])
ans_list.sort()
for ans in ans_list:
    print(ans)

Solution (Python):
import collections 

N = int(input())
string = [""] * N

for i in range(N):
  s = input()
  string[i] = s

freq = collections.Counter(string)
mfreq = freq.most_common()
mtime = mfreq[0][1]

mosts = sorted([mfreq[i][0] for i in range(len(mfreq)) if mfreq[i][1] == mtime])

for s in mosts:
  print(s)