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())
C = {}
for _ in range(N):
    s = input().strip()
    if s not in C:
        C[s]=0
    C[s] += 1
cmax = 0
for s in C:
    cmax = max(cmax,C[s])
A = []
for s in C:
    if C[s]==cmax:
        A.append(s)
A = sorted(A)
for i in range(len(A)):
    print(A[i])

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


t = []
for k,v in d.items():
    t.append((v,k))

t.sort()
num = t[0][0]
for v,s in t:
    if v == num:
        print(s)

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

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

MAX = max(dic.values())
ans = []
for x in dic.keys():
  if dic[x] == MAX:
    ans.append(x)
ans.sort()
print(*ans,sep="\n")

Solution (Python):
from collections import Counter

N = int(input())
S = [input() for _ in range(N)]
cnt = Counter(S)
M = max(list(cnt.values()))
ans = []

for k, v in cnt.items():
    if v==M:
        ans.append(k)

ans.sort()

for ans_i in ans:
    print(ans_i)

Solution (Python):
n = int(input())
dic = {}
for i in range(n):
    s = str(input())
    if s in dic.keys():
        dic[s] += 1
    else:
        dic.setdefault(s,1)
max_v = max(dic.values())
ans = []
for j in dic.items():
    if j[1] == max_v:
        ans.append(j[0])
ans.sort()
for i in ans:
    print(i)

Solution (Python):


from typing import *
import collections
import functools
import itertools
import math
import sys

INF = float('inf')


def solve(N: int, S: "List[str]"):
    c = collections.Counter(S).most_common()
    return "\n".join(sorted([i[0] for i in c if i[1] == c[0][1]]))


def main():

    sys.setrecursionlimit(10 ** 6)

    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)]  
    print(f'{solve(N, S)}')


if __name__ == '__main__':
    main()

Solution (Python):
import sys

input = sys.stdin.readline
d = {}
for _ in range(int(input())):
    s = input().replace("\n", "")
    if s in d:
        d[s] += 1
    else:
        d[s] = 1

x = max(d.values())
l = sorted(s for (s, i) in d.items() if i == x)
print(*l, sep="\n")

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

C = Counter(lst)
x = max(C.values())
anslst = []
for k,v in C.items():
    if v == x:
        anslst.append(k)
anslst.sort()
for v in anslst:
    print(v)

Solution (Python):
N = int(input())
count = {}
max_count = 0
for _ in range(N):
  s = input()
  if s not in count:
    count[s] = 0
  count[s] += 1
  max_count = max(max_count, count[s])

longest = []
for s, c in count.items():
  if c == max_count:
    longest.append(s)

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

Solution (Python):
import collections

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

ans = collections.Counter(S)
values, cnt = zip(*ans.most_common())


max_count = cnt[0]
for i in range(len(cnt)):
    if max_count > cnt[i]:
        break
    print(values[i])

Solution (Python):
from collections import defaultdict, Counter

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

a = Counter(lis)

tmp = 0
for key, value in a.items():
    tmp = max(value, tmp)

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

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

Solution (Python):
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd

sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = inp()

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

m = max(d.values())
for s in sorted(filter(lambda x: d[x] == m,d)):
    print(s)

Solution (Python):
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd

sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = inp()
s = sorted(inplL(n))

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

ans.sort(key=lambda x: x[1],reverse=True)

tmp = 0
ret = []
for i in range(len(ans)):
    if i == 0 or tmp == ans[i][1]:
        ret.append(''.join(ans[i][0]))
        tmp = ans[i][1]
    elif tmp != ans[i][1] :
        break

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

Solution (Python):
from collections import defaultdict

N = int(input())
S = defaultdict(int)
for i in range(N):
    S[input()] += 1
m = max(S.values())
for s in sorted(filter(lambda x: S[x] == m, S)):
    print(s)

Solution (Python):
n=int(input())
a=[]
b=[[] for _ in range(n)]
for i in range(n):
    s=input()
    a.append(s)
a=sorted(a)
d=0
b[0].append(a[0])
for i in range(1,n):
    if a[i]!=a[i-1]:
        d+=1
    b[d].append(a[i])
x=max(len(b[i]) for i in range(n))
for i in range(n):
    if len(b[i])==x:
        print(b[i][0])

Solution (Python):
from collections import Counter
n = int(input())
s = Counter([input() for i in range(n)])
max_s = max(s.values()) 
print(*sorted(k for k, v in s.items() if v == max_s), sep='\n')

Solution (Python):
from collections import Counter
n = int(input())
s = Counter([input() for i in range(n)])
max_s = max(s.values()) 
print(*sorted([k for k, v in s.items() if v == max_s]), sep='\n')

Solution (Python):
n = int(input())
c = {}
for i in range(n):
    s = input()
    if s in c:
        c[s] += 1
    else:
        c[s] = 1
max = 0
for k in c.keys():
    if c[k] > max:
        max = c[k]
hit = [k for k in c.keys() if c[k] == max]
hit.sort()
for i in range(len(hit)):
    print(hit[i])

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

num = 0
for key in dic:
    num = max(num, dic[key])

ans = []
for key in dic:
    if dic[key] == num:
        ans.append(key)

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

Solution (Python):
n=int(input())
dic=dict()
for i in range(n):
    s=input()
    if s in dic:
        dic[s]+=1
    else:
        dic[s]=1
ans=[]
val=max(dic.values())
for kv in dic.items():
    if kv[1]==val:
        ans.append(kv[0])
ans=sorted(ans)
for a in ans:
    print(a)

Solution (Python):
import collections

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

c = collections.Counter(words)

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

nums = counts.count(max(counts))
xs = (list(values))[:nums]
xs.sort()

for x in xs:
    print(x)

Solution (Python):
from collections import Counter
def main():
    n = int(input())
    s = [input() for _ in range(n)]
    s_c = Counter(s)
    s_c_max = s_c.most_common()[0][1]
    keys =[k for k, v in s_c.items() if v == s_c_max]
    keys_s = sorted(keys)
    print(*keys_s, sep='\n')

if __name__ == '__main__':
    main()

Solution (Python):
Row = int(input())
dictA= {}
a = ""
mid = 0
for i in range (Row):
  a = input()
  dictA.setdefault(a,0) 
  dictA[a] += 1
  mid = max(mid, dictA[a])
sDict = sorted(dictA.items())
for i in range(len(dictA)):
  if sDict[i][1]== mid:
    print(sDict[i][0])

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

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

ans = []
val = max(dic.values())
for kv in dic.items():
    if kv[1] == val:
        ans.append(kv[0])

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

Solution (Python):
n = int(input())
dic = {}
for _ in range(n):
    s = input()
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1
mv = max(dic.values())
for s, v in sorted(dic.items()):
    if v == mv:
        print(s)

Solution (Python):
from collections import Counter

n = int(input())
xc = Counter()
for _ in range(n):
    xc[input()] += 1

mx = xc.most_common(1)[0][1]
ans = []
for k, v in xc.items():
    if v == mx:
        ans.append(k)
ans.sort()
print(*ans, sep="\n")

Solution (Python):
from collections import Counter

n = int(input())
xc = Counter()
for _ in range(n):
    xc[input()] += 1

mx = xc.most_common(1)[0][1]
ans = []
for v in xc.items():
    if v[1] == mx:
        ans.append(v[0])
ans.sort()
print(*ans, sep="\n")

Solution (Python):
from collections import Counter
def main():
    n = int(input())
    S = [input() for _ in range(n)]
    c = Counter(S).most_common()
    V = c[0][1]
    ans = [k for k, v in c if v == V]
    [print(a) for a in sorted(ans)]

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
dic = {}
for _ in range(N):
    s = input()
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1
ma = max(dic.values())
for i,j in sorted(dic.items()):
    if j == ma:
        print(i)

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

Solution (Python):
def readinput():
    n=int(input())
    sList=[]
    for _ in range(n):
        sList.append(input())
    return n,sList

def main(n,sList):
    hist={}
    for s in sList:
        if s in hist.keys():
            hist[s]+=1
        else:
            hist[s]=1
    hList=sorted(list(hist.items()), key=lambda x:x[1], reverse=True)
    
    hvalue=hList[0][1]
    ss=[]
    i=0
    while(i<len(hList) and hList[i][1]==hvalue):
        ss.append(hList[i][0])
        i+=1
    ss.sort()
    for s in ss:
        print(s)    

if __name__=='__main__':
    n,sList=readinput()
    main(n,sList)

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

S = []

import collections

for i in range (0, N):
	S.append(str(input()))

S = sorted(S)
cnt = collections.Counter()

for word in S:
	cnt[word] += 1
    
mostCommon = cnt.most_common()

D = mostCommon[0][1]
print(mostCommon[0][0])
for i in range(1, len(set(S))):
	if mostCommon[i][1] == D:
		print(mostCommon[i][0])
	else:
		exit()

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

m = 1
cnt = [1]
ans = []
for i in range(1,n):
    if s[i] == s[i-1]:
        cnt[-1] += 1
    else:
        if cnt[-1] > m:
            ans = [s[i-1]]
        elif cnt[-1] == m:
            ans.append(s[i-1])
        m = max(m, cnt[-1])
        cnt.append(1)
    if i == n-1 and cnt[-1] > m:
        ans = [s[i]]
    elif i == n-1 and cnt[-1] == m:
        ans.append(s[i])
print('\n'.join(ans))

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

m = 1
cnt = [1]
ans = []
for i in range(1,n):
    if s[i] == s[i-1]:
        cnt[-1] += 1
    else:
        if cnt[-1] > m:
            ans = [s[i-1]]
        elif cnt[-1] == m:
            ans.append(s[i-1])
        m = max(m, cnt[-1])
        cnt.append(1)
    if i == n-1 and cnt[-1] > m:
        ans = [s[i]]
    elif i == n-1 and cnt[-1] == m:
        ans.append(s[i])
print('\n'.join(ans))

Solution (Python):
import collections

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

c = collections.Counter(S)

max_num = max(c.values())

l = []
for item in c.items():
    k = item[0]
    v = item[1]
    if v == max_num:
        l.append(k)

l.sort()

for li in l:
    print(li)

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


def main():
    n = int(readline().rstrip())
    S = [readline().rstrip() for _ in range(n)]
    c = collections.Counter(S)
    keys = sorted(c.keys())
    maxS = c.most_common()[0][1]
    for key in keys:
        if c[key] == maxS:
            print(key)


if __name__ == '__main__':
    main()

Solution (Python):



















































































global FLAG_LOG
FLAG_LOG = False


def log(value):
    
    
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    
    N = int(lines[0])
    
    
    
    values = list()
    for i in range(N):
        values.append(lines[i+1])
    
    
    

    dic = dict()
    for value in values:
        if value in dic:
            dic[value] += 1
        else:
            dic[value] = 1

    tmp = list()
    for key in dic:
        tmp.append(dic[key])
    ma = max(tmp)

    results = list()
    for key in dic:
        if dic[key] == ma:
            results.append(key)

    results.sort()

    return results



def get_input_lines():
    line = input()
    N = int(line)
    lines = list()
    lines.append(line)
    for _ in range(N):
        lines.append(input())
    return lines



def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['7', 'beat', 'vet', 'beet', 'bed', 'vet', 'bet', 'beet']
        lines_export = ['beet', 'vet']
    if pattern == 2:
        lines_input = ['8', 'buffalo', 'buffalo', 'buffalo', 'buffalo', 'buffalo', 'buffalo', 'buffalo', 'buffalo']
        lines_export = ['buffalo']
    if pattern == 3:
        lines_input = ['7', 'bass', 'bass', 'kick', 'kick', 'bass', 'kick', 'kick']
        lines_export = ['kick']
    if pattern == 4:
        lines_input = ['4', 'ushi', 'tapu', 'nichia', 'kun']
        lines_export = ['kun', 'nichia', 'tapu', 'ushi']
    return lines_input, lines_export



def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode



def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines()
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    
    
    
    
    
    
    
    
    
    
    



if __name__ == '__main__':
    main()

Solution (Python):
import collections

def poll():
    
    N = int(input())
    S = list()
    for _ in range(N):
        S.append(input())
    
    count_list = collections.Counter(S)
    
    max_count = max(count_list.values())
    max_count_str = list()
    for key, value in count_list.items():
        if value == max_count:
            max_count_str.append(key)
    
    return sorted(max_count_str)
           
result = poll()
for string in result:
    print(string)

Solution (Python):
from collections import defaultdict

n = int(input())
l = defaultdict(int)
m = 0
for _ in range(n):
    s = input()
    l[s] += 1
    m = max(m, l[s])

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

Solution (Python):
import collections
n = int(input())
s = [input() for l in range(n)]
word = collections.Counter(s)
ma = max(word.values())
z = [kv for kv in word.items() if kv[1] == ma]
z = sorted(z)
for c in z:
  print(c[0])

Solution (Python):
N = int(input())
a = []
for i in range(N):
  a.append(input())
a = sorted(a)
count = 0
count_list=[]
b = []
for i,k in enumerate(a):
  if i == 0:
    continue
  if k == a[i-1]:
    count+=1
  else:
    count_list.append(count)
    b.append(a[i-1])
    count = 0
  if i==N-1:
    count_list.append(count)
    b.append(a[i])
maxi = 0
maxi_list =[]
for i,k in enumerate(count_list):
  if maxi <k:
    maxi_list.clear()
    maxi_list.append(b[i])
    maxi = k
  elif maxi == k:
    maxi_list.append(b[i])
  else:
    continue
for i in maxi_list:
  print(i)

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

dic = {}
ma = 1

for i in range(n):
    wo = input()
    if(wo in dic):
        dic[wo] += 1
        if(dic[wo] > ma):
            ma = dic[wo]
    else:
        dic.update({wo:1})


ans = []
for i in dic.keys():
    if(dic[i] == ma):
        ans.append(i)
ans.sort()
for j in ans:
    print(j)

Solution (Python):
n = int(input())
d = {}
for _ in range(n):
  s = input()
  if s in d: d[s] += 1
  else: d[s] = 1
  
t = max(d.values())
for x,y in sorted(d.items()):
  if y == t: print(x)

Solution (Python):
from sys import stdin
import sys
import math
from functools import reduce
import itertools

n = int(stdin.readline().rstrip())

d = {}
for i in range(n):
    s = stdin.readline().rstrip()

    if s in d:
        d[s] += 1
    else:
        d[s] = 1

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

m = d[0][1]
a = []
i = 0
for i in range(len(d)):
    if d[i][1] == m:
        a.append(d[i][0])
    else:
        break

a.sort()

for aa in a:
    print(aa)

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])
i=0
ans=[]
while i<len(d):
  ans.append(d[i][0])
  if i<len(d)-1 and d[i+1][1]==d[i][1]:
      i+=1
  else:
    break

ans = sorted(ans)

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

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


def main():
  N = int(input())
  dic = defaultdict(int)
  for i in range(N):
    dic[input()[:-1]] += 1

  max_ = max(dic.values())
  out = []
  for key, val in dic.items():
    if val == max_:
      out.append(key)

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


if(__name__ == '__main__'):
  main()

Solution (Python):
N = int(input())
S = sorted([input() for x in range(N)])
word = [S[0]]+[""]*(N-1)    
kaisuu = [0]*N              
k = 0                       

for p in range(N):  

    if word[k] != S[p]:
        k += 1
        word[k] = S[p]
        kaisuu[k] += 1
    
    else:
        kaisuu[k] += 1

m = max(kaisuu)     
ansnum = []         
for q in range(N):      
    if kaisuu[q] == m:
        ansnum += [q]

for r in range(len(ansnum)):
    print(word[ansnum[r]])

Solution (Python):
from collections import Counter


def main():
    n = int(input())
    S = [input() for _ in range(n)]
    S_c = Counter(S)
    num = list(S_c.values()).count(max(list(S_c.values())))
    anss = S_c.most_common()[:num]
    for ans in sorted(anss):
        print(ans[0])


if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
dict={}
xs=[]
for i in range(n):
  s=input()
  xs+=[s]
  if s not in dict:
    dict[s]=1
  else:
    dict[s]+=1
pin=0
xs=list(set(xs))
for i in xs:
  pin=max(pin,dict[i])
ans=[]
for i in xs:
  if dict[i]==pin:
    ans+=[i]
ans.sort()
for i in ans:
  print(i)

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

count = collections.Counter(ls)
maxval = max(count.values())
K = [k for k, v in count.items() if v == maxval]
L = sorted(K)
for i in L:
    print(i)

Solution (Python):
from collections import Counter

N = int(input())

A = []
for _ in range(N):
    A.append(input().strip())

dic = Counter(A)

B = []
for a, c in dic.items():
    B.append((a,c))

B.sort(key=lambda x:x[0])
B.sort(key=lambda x:x[1],reverse=True)

r = B[0][1]
for b in B:
    p, q = b
    if q < r:
        exit()
    print(p)

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

memo = {}

for _ in range(n):
    s = input()
    try:
        memo[s] += 1
    except KeyError:
        memo[s] = 1

m = max(memo.values())

print(*sorted([ i for i, j in memo.items() if j == m]), sep='\n')

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

s_sort = sorted(s)

s_num = [1]*n

for i in range(1,n):
    if s_sort[i] == s_sort[i-1]:
        s_num[i] += s_num[i-1]

Maxnum = max(s_num)

index_num = [n for n, v in enumerate(s_num) if v == Maxnum]

[print(s_sort[i]) for i in index_num]

Solution (Python):
import collections
n=int(input())
data=[""]*n
for i in range(n):
    data[i]=input()
data=sorted(data)
count=collections.Counter(data)
num=max(count.values())
for v,k in count.items():
    if k==num:
        print(v)

Solution (Python):
import collections
n = int(input())
c = collections.Counter([ input() for i in range(n) ])
ma = max(c.values())
print(*sorted([ i for i, j in c.items() if j == ma ]), sep='\n')

Solution (Python):
from collections import Counter

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

counter = Counter(S)
maxv = max(counter.values())
ans = []
for k, v in counter.items():
    if v == maxv:
        ans.append(k)

ans.sort()

for s in ans:
    print(s)

Solution (Python):
import collections
n = int(input())
c = collections.Counter([ input() for i in range(n) ])
ma = max(c.values())
print(*sorted([ i for i, j in c.items() if j == ma ]), sep='\n')

Solution (Python):
from collections import defaultdict
d = defaultdict(int)
n = int(input())
for _ in range(n): d[input()] += 1
s = sorted(d.items(), key=lambda x: (-x[1], x[0]))
nmax = s[0][1]
for i in s:
  if i[1] != nmax: break
  print(i[0])

Solution (Python):
import sys
from collections import defaultdict

def solve():
    input = sys.stdin.readline
    N = int(input())
    sDict = defaultdict(int)
    maxCount = 0
    for i in range(N):
        s = input().strip("\n")
        sDict[s] += 1
        maxCount = max(maxCount, sDict[s])
    maxS = []
    for key in sDict:
        if sDict[key] == maxCount:
            maxS.append(key)
    maxS.sort()
    print(*maxS, sep="\n")

    return 0

if __name__ == "__main__":
    solve()

Solution (Python):
from collections import Counter

n = int(input())
s = [input() for _ in range(n)]
cnt = Counter(s)
li = sorted(cnt.items(), key=lambda x: (-x[1], x[0]))
m = li[0][1]
for i in range(len(li)):
    if li[i][1] < m:
        break
    print(li[i][0])

Solution (Python):
n,*s=map(str,open(0).read().split())
mydict={}
for i in set(s):
    mydict[i]=1
for i in s:
    mydict[i]+=1
    """
    if s[i] in mydict:
        mydict[s[i]]+=1
    else:
        mydict[s[i]]=1
    """
v_max=max(mydict.values())
for i in sorted([kv[0] for kv in mydict.items() if kv[1]==v_max]):
    print(i)

Solution (Python):
N=int(input())
L=list(input() for i in range(N))
L=sorted(L)
X=L[0]
c=0
d=0
e=[]
for i in range(N):
  if L[i]==X:
    c+=1
    if i==N-1 and c>d:
      e=[X]
    elif i==N-1 and c==d:
      e.append(X)
  elif L[i]!=X and d<c:
    d=c
    c=0
    e=[]
    e.append(X)
    X=L[i]
    c+=1
  elif L[i]!=X and d==c:
    c=1
    e.append(X)
    X=L[i]
    if i==N-1:
      e.append(X)
  elif L[i]!=X and d>c:
    c=0
    X=L[i]
    c+=1
for i in e:
  print(i)

Solution (Python):
n=int(input())
d={}
for x in range(n):
  key=input()
  if key not in d:
    d[key]=0
  d[key]+=1
  
values=d.values()
a=max(values)
b=[]
for y in d:
  if d[y]==a:
    b.append(y)
    
b=sorted(b)
for r in b:
  print(r)

Solution (Python):
N=int(input())
d={}
ans=[]
num=0
for x in range(N):
  S=input()
  if S not in d:
    d[S]=1
  else:
    d[S] += 1
  if d[S]>num:
    num=d[S]
    ans=[]
    ans.append(S)
  elif d[S]==num:
    ans.append(S)
ans.sort()
for i in range(len(ans)):
  print(ans[i])

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

d = {}

for _ in range(N):
  S = input()
  if S in d:
    d[S] += 1
  else:
    d[S] = 1

m = max(d.values())

for s in sorted(k for k in d if d[k] == m):
  print(s)

Solution (Python):





N = int(input())







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

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

for k, v in d:
    if cnt_max == v:
        print(k)

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

c = collections.Counter(s)
max_cnt = max(c.values())

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

Solution (Python):
import collections
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n = I()
    S = [input() for _ in range(n)]
    word = collections.Counter(S).most_common()
    maxi = word[0][1]
    ans = []
    for w in word:
        if w[1] == maxi:
            ans.append(w[0])
        else:
            break
    ans.sort()
    a = "\n".join(ans)
    print(a)

if __name__ == '__main__':
    main()

Solution (Python):
dict={}
for _ in range(int(input())):
  s=input()
  if s not in dict:
    dict[s] = 1
  else:
    dict[s] += 1
dict=sorted(dict.items(),key=lambda x:-x[1])
print(*sorted([dict[i][0] for i in range(len(dict)) if dict[0][1]==dict[i][1]]),sep='\n')

Solution (Python):
import sys 
from collections import Counter
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
N = int(readline())
l = read().decode().split()
c = Counter(l)
 
max = c.most_common()[0][1]
ans = [i[0] for i in c.items() if i[1] >= max]
 
print('\n'.join(sorted(ans)))

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

d = {}
for _ in range(N):
  s = input()
  if s in d:
    d[s] += 1
  else:
    d[s] = 1
    
d = {k: v for k, v in sorted(d.items(), key=lambda item: item[1], reverse=True)}

max_count = -1
values = []
for k, v in d.items():
  if max_count < v:
    max_count = v
  if v != max_count:
    break
  values.append(k)

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

Solution (Python):

import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    N = II()

    counter = cl.Counter()
    for i in range(N):
        s = input()
        counter.update({s: 1})
    item, value = zip(*counter.most_common())
    ans = []
    max_num = value[0]
    for i in range(len(value)):
        if value[i] == max_num:
            ans.append(item[i])

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


main()

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

from collections import Counter
C = Counter(S)

maxC = max(C.values())

A=[]
for k,v in C.items():
  
  if v==maxC: A.append(k)

A = sorted(A)

for a in A:
  print(a)

Solution (Python):
from collections import Counter as Ct
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))

def do():
    n=INT()
    dic=[]
    for i in range(n):
        s=STR()
        dic.append(s)
    ctd=Ct(dic)
    ctm=max(ctd.values())
    ans=[]
    for key,value in ctd.items():
        if value==ctm:
            ans.append(key)
    
    ans=sorted(ans)

    for i in ans:
        print(i)


if __name__=='__main__':
    do()

Solution (Python):
import collections

n = int(input())
s = list(input() for i in range(n))
c = collections.Counter(s)
p = max(c.values())
s = sorted(list(set(s)))

for i in range(len(s)):
    if c[s[i]] == p:
        print(s[i])

Solution (Python):
import collections

n = int(input())
s = list(input() for i in range(n))
s = sorted(s)
c = collections.Counter(s)
p = max(c.values())
s = sorted(list(set(s)))

for i in range(len(s)):
    if c[s[i]] == p:
        print(s[i])

Solution (Python):
n=int(input())
arr=[input() for _ in range(n)]
dic={}
for i in range(n): 
 if arr[i] not in dic:
   dic[arr[i]]=1
 else:
   dic[arr[i]]+=1
largest=max(dic.values()) 
ans=[]
for keys in dic.keys():
 if dic[keys]==largest: 
   ans.append(keys)
ans=sorted(ans) 
for words in ans:
 print(words)

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

for i in range(n):
  s = input()
  if(s not in d.keys()):
    d[s] = 1
  else:
    d[s] +=1
    
max = max(d.values())
ans = []
for i in d.keys():
  if(d[i] == max):
    ans.append(i)
for i in sorted(ans):
  print(i)

Solution (Python):
_,*ss = open(0).read().split()

from collections import Counter
c = Counter(ss)

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

for s in sorted(key for key,count in c.items() if count==mx):
    print(s)

Solution (Python):
import sys 
from collections import Counter

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
l = read().decode().split()
c = Counter(l)

max = c.most_common()[0][1]
ans = [i[0] for i in c.items() if i[1] >= max]

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

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

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

max_count = max(d.values())

for i in sorted(d.keys()):
  if d[i] == max_count:
    print(i)

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
m = max(d.values())

ans = [_ for _ in d if d[_] == m]
ans.sort()
[print(_) for _ in ans]

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


s_dict = {}
for i in range(n):
    s = input()    
    if s not in s_dict:
        s_dict[s] = 1
    s_dict[s] += 1

max_value = max(s_dict.values())
ans = []
for key, value in s_dict.items():
    if value == max_value:
        ans.append(key)

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

Solution (Python):
n = int(input())
s = {}
maxvalue = -1
for i in range(n):
    sn = input()
    if(s.get(sn) == None):
        s[sn] = 0
    else:
        s[sn] += 1
    maxvalue = max(maxvalue,s[sn])

answers = []
for key in s.keys():
    if s[key] == maxvalue:
        answers.append(key)

answers.sort()

for ans in answers:
    print(ans)

Solution (Python):
from collections import Counter

N = int(input())
S = []
for _ in range(N):
    S.append(input())
counter = Counter(S)
sorted_S = list(sorted(counter.keys()))
maxcnt = max(counter.values())
for Si in sorted_S:
    if counter[Si] == maxcnt:
        print(Si)