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

import sys
from collections import Counter
INF = float("inf")


def solve(N: int, S: "List[str]"):
    c = Counter()
    for s in S:
        c[s] += 1

    m = -1
    for key in c:
        if c[key] > m:
            m = c[key]
    ans = []
    for key in c:
        if c[key] == m:
            ans.append(key)
    ans.sort()
    for line in ans:
        print(line)

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

c = Counter(input() for _ in range(N))

c = [(-cnt,s) for s,cnt in c.items()]
c.sort()

v = c[0][0]
for a,s in c:
    if a == v:
        print(s)
    else:
        break

Solution (Python):
import sys
from collections import defaultdict as dd
input = sys.stdin.readline
N = int(input())
s = []
d = dd(int)
for _ in range(N): s.append(input()[: -1])
for x in s: d[x] += 1
ks = d.keys()
mx = max(d.values())
res = []
for k in ks:
  if d[k] == mx: res += [k]
res.sort()
for r in res: print(r)

Solution (Python):
from collections import Counter

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

c=Counter(S)
c=sorted(dict(c).items(),key=lambda w:(-w[1],w[0]))

for w in c:
    if w[1]==c[0][1]:
        print(w[0])

Solution (Python):
n = int(input())
s = {}
for _ in range(n):
    i = input()
    if i in s:
        s[i] += 1
    else:
        s[i] = 1
ans = []
b = 0
for i in s:
    if b < s[i]:
        ans = []
        b = s[i]
    if b == s[i]:
        ans.append(i)
ans.sort()
for i in ans:
    print(i)

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    d = collections.defaultdict(int)
    for _ in range(N):
        s = S()
        d[s] += 1
    v_max = 0
    for k, v in d.items():
        v_max = max(v, v_max)
    sts = []
    for k, v in d.items():
        if v == v_max:
            sts.append(k)
    sts = sorted(sts)
    for string in sts:
        print(string)

main()

Solution (Python):
from collections import defaultdict

d = defaultdict(int)

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

m = max(d.values())

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

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

Solution (Python):


import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
s = [input() for _ in range(n)]
c = list(Counter(s).items())
c.sort(key = itemgetter(1),reverse=1)
m = c[0][1]
lst = []
for i,j in c:
    if m == j:
        lst.append(i)
lst.sort()
for i in lst:
    print(i)

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

MAX = max(D.values())
ans = []
for k, v in D.items():
    if v == MAX:
        ans.append(k)

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

Solution (Python):
n = int(input())
lis = [str(input()) for i in range(n)]
lis.sort()
cnt = 1
li = []
for i in range(n-1):
    if lis[i] == lis[i+1]:
        cnt += 1
    else:
        li.append([lis[i],cnt])
        cnt = 1
li.append([lis[-1],cnt])
li.sort(key = lambda x:x[0])
li.sort(key = lambda x:x[1],reverse = True)
num = li[0][1]
for i in range(len(li)):
    if num == li[i][1]:
        print(li[i][0])

Solution (Python):
def main():
    from collections import Counter as ct

    n = int(input())
    a = [input() for _ in [0]*n]
    c = ct(a)
    m = max(c.values())
    a = sorted([i for i, j in c.items() if j == m])
    for i in a:
        print(i)


main()

Solution (Python):
from collections import Counter

def read():
    N = int(input().strip())
    S = list()
    for i in range(N):
        s = input().strip()
        S.append(s)
    return N, S

def solve(N, S):
    counter = Counter(S)
    outputs = list()
    max_count = None
    for k, v in counter.most_common():
        if max_count is None:
            max_count = v
        elif max_count > v:
            break
        outputs.append(k)
    return sorted(outputs)


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    for output in outputs:
        print(output)

Solution (Python):

n = int(input())

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

from collections import Counter
c = Counter(S)

A = [[c[i], i] for i in c.keys()]
A.sort(reverse=True)
ANS = []
m = A[0][0]
i = 0
while i < len(A) and A[i][0] == m:
    ANS.append(A[i][1])
    i += 1
ANS.sort()
for i in range(len(ANS)):
    print(ANS[i])

Solution (Python):











import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    S=[ST() for _ in range(N)]
    d = defaultdict(int)
    ma = 0
    for s in S:
        d[s]+=1
        ma = max(ma, d[s])
    ans = []
    for s,v in d.items():
        if v==ma:
            ans.append(s)
    ans.sort()
    print(*ans,sep="\n")

if __name__ == '__main__':
    main()

Solution (Python):
def main():

    N = int(input())
    d = dict()
    for _ in range(N):
        s = input()
        d[s] = d.get(s, 0) + 1
    max_c = 0
    for s in d:
        max_c = max(max_c, d[s])
    ans = []
    for s in d:
        if d[s] == max_c:
            ans.append(s)
    ans.sort()
    for s in ans:
        print(s)


if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter

N, = list(map(int, input().split()))
S = []
for i in range(N):
    S.append(input())
S = Counter(S)
best = max((v, k) for k, v in S.items())

for w in sorted(k for k, v in S.items() if v == best[0]):
    print(w)

Solution (Python):
import sys, bisect, math, itertools, string, queue, copy


from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush

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 sorted([list(map(int, input().split())) for _ in range(n)]) 
def graph():
    n=inp()
    g=[[] for _ in range(n)]
    for i in range(n):
        a = inp()
        a -= 1
        g[i].append(a)
        g[a].append(i)
    return n,g

def main():
    n = inp()
    dic = defaultdict(int)
    for _ in range(n):
        s = input()
        dic[s] += 1
    ans = []
    M = 0
    for e in dic:
        if M < dic[e]:
            M = dic[e]
            ans = [e]
        elif M == dic[e]:
            ans.append(e)
    ans.sort()
    for i in range(len(ans)):
        print(ans[i])           
    
if __name__ == "__main__":
    main()

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

from collections import Counter
C=Counter(S)
MAX=max(C.values())

ANS=[]
for c in C:
    if C[c]==MAX:
        ANS.append(c)

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

Solution (Python):
from collections import Counter

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

cnt = Counter(S)
M = max(cnt.values())

ret = []
for k, v in cnt.items() :
  if v == M :
    ret.append(k)
    
ret.sort()
for r in ret :
  print(r)

Solution (Python):
import sys
from collections import defaultdict

N = int(sys.stdin.readline())
A = defaultdict(int)
for _ in range(N):
    s = sys.stdin.readline().strip()
    A[s] += 1

max_cnt = max(A.values())
ans = []
for key in A:
    if A[key] == max_cnt:
        ans.append(key)
ans.sort()
[print(s) for s in ans]

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

cnt = {}
mx = 0
for i in range(n):
    s = input()
    if s not in cnt:
        cnt[s] = 0
    cnt[s] += 1
    mx = max(mx, cnt[s])

ans = []
for s in cnt:
    if cnt[s] == mx:
        ans.append(s)

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

Solution (Python):
from collections import defaultdict
N = int(input())
m = 0
dic = defaultdict(int)
for i in range(N):
  s = input()
  dic[s] += 1
  if dic[s]>m:
    m = dic[s]
ans = []
for k in dic.keys():
  if dic[k]==m:
    ans += [str(k)]
ans.sort()
for a in ans:
  print(a)

Solution (Python):
from collections import Counter

n = int(input())

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

cs = Counter(S)
mi = 0
for v in cs.values():
    mi = max(mi, v)

ret = [k for k, v in cs.items() if v == mi]
ret.sort()
for r in ret:
    print(r)

Solution (Python):



from math import *
from copy import *
from string import *				
from random import *				
from sys import stdin
from sys import maxsize
from operator import *				
from itertools import *
from collections import Counter		
from collections import defaultdict 

'''

'''

def solve(l):
	n = len(l)
	

N = int(stdin.readline())
d = {}
for _ in range(N):
	s = input()
	if(s not in d):
		d[s] = 1
	else:
		d[s] += 1
d = sorted(d.items(), key=itemgetter(1))
maxx = 0

for i in d:
	maxx = max(maxx,i[1])
l = []
for i in d:
	if(i[1] == maxx):
		l.append(i[0])
l = sorted(l)
for i in l:
	print(i)

Solution (Python):
from collections import Counter

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

for k in cnt.keys():
    if cnt[k]==M:
        ans.append(k)

ans.sort()

for ans_i in ans:
    print(ans_i)

Solution (Python):
def main():
    N = int(input())
    S = [input() for _ in range(N)]
    t = {}
    m = 0
    for s in S:
        t[s] = t.get(s, 0) + 1
        m = max(m, t[s])
    r = []
    for k, v in t.items():
        if v == m:
            r.append(k)
    r.sort()
    print('\n'.join(r))





main()

Solution (Python):
from sys import setrecursionlimit as srl; srl(10**7)
rr = raw_input
rrm = lambda: map(int, raw_input().split())

N =int(rr())
from collections import Counter
count = Counter()
for _ in xrange(N):
    count[rr()] += 1
M = max(count.values())
ans = []
for k in count:
    if count[k] == M:
        ans.append(k)
ans.sort()
for x in ans:
    print x

Solution (Python):
n = int(input())
s = [input() for _ in range(n)]
d = dict()
for st in s:
    if st not in d:
        d[st] = 1
    else:
        d[st] += 1
m = max(d.values())
ans = set()
for k, v in d.items():
    if v == m:
        ans.add(k)
ans = sorted(ans)
for st in ans:
    print(st)

Solution (Python):
import sys
def fastio():
    from io import StringIO
    from atexit import register
    global input
    sys.stdin = StringIO(sys.stdin.read())
    input = lambda : sys.stdin.readline().rstrip('\r\n')
    sys.stdout = StringIO()
    register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

def debug(*var, sep = ' ', end = '\n'):
    print(*var, file=sys.stderr, end = end, sep = sep)

INF = 10**20
MOD = 10**9 + 7
I = lambda:list(map(int,input().split()))

from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br

n, = I()
d = dd(int)
maximum = 0
for i in range(n):
    s = input()
    d[s] += 1
    maximum = max(maximum, d[s])

ans = []
for i in d:
    if d[i] == maximum:
        ans.append(i)
ans.sort()
for i in ans:
    print(i)

Solution (Python):
from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
C = Counter(S)
M = max(C.values())
print(*sorted(k for k, v in C.items() if v == M), sep="\n")

Solution (Python):


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

cnt = {}

for s in S:
    if s in cnt.keys():
        cnt[s] += 1
    else:
        cnt[s] = 1

max_appeared = max(cnt.values())

max_list = [k for k, v in cnt.items() if v == max_appeared]
for k in sorted(max_list):
    print(k)

Solution (Python):

import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N = read_a_int()
from collections import defaultdict
kai = defaultdict(lambda: 0)
for _ in range(N):
    S = read()[:-1]
    kai[S] += 1

m = max(kai.values())
ans = []
for k, v in kai.items():
    if v == m:
        ans.append(k)
ans.sort()
print(*ans, sep='\n')

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

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

m = max(S.values())
A = []
for k, v in S.items():
    if v == m:
        A.append(k)

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

Solution (Python):
n=int(input())
d={}
m=0
for i in range(n):
  s=input()
  if s not in d:d[s]=1
  else:d[s]+=1
  m=max(m,d[s])
t=set()
for i in d:
  if d[i]==m:t.add(i)
x=[i for i in t]
x.sort()
for i in x:print(i)

Solution (Python):
import os
import sys
from collections import Counter

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7



N = int(sys.stdin.buffer.readline())
S = [sys.stdin.buffer.readline().decode().rstrip() for _ in range(N)]

counts = Counter(S)
_, m = counts.most_common(1)[0]
ans = []
for s, cnt in counts.items():
    if cnt == m:
        ans.append(s)
ans.sort()
print(*ans, sep='\n')

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
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)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    s = [input() for i in range(n)]
    d = defaultdict(lambda : 0)
    for i in s:
        d[i] += 1
    d = list(d.items())
    d.sort(key = lambda x:(-x[1],x[0]))
    a = d[0][1]
    for i,j in d:
        if j == a:
            print(i)
            
    return


if __name__ == "__main__":
    solve()

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

max_cnt = 0
for i in d:
    max_cnt = max(max_cnt, d[i])

t = []
for i in d:
    if d[i]==max_cnt:
        t.append(i)
t.sort()
print(*t, sep='\n')

Solution (Python):
import sys

def solve():
    N = int(input())
    word = dict()
    for i in range(N):
        s = input()
        if s in word: word[s] += 1
        else: word[s] = 1

    L = []
    for key in word:
        L.append((word[key], key))
    L.sort(reverse = True)
    maxs = L[0][0]
    Ans = []
    for num, s in L:
        if num == maxs: Ans.append(s)
    Ans.sort()
    for a in Ans:
        print(a)

    return 0

if __name__ == "__main__":
    solve()

Solution (Python):
from collections import Counter

n = int(input())
sss = [input() for _ in range(n)]
cnt = Counter(sss)
l = max(cnt.values())
ans = [s for s, c in cnt.items() if c == l]
ans.sort()
print('\n'.join(ans))

Solution (Python):
from bisect import *
from collections import *
from fractions import gcd
from math import factorial
from itertools import *
from heapq import *
import copy




N=int(input())
S=Counter([input() for i in range(N)]).most_common()
S=[i[0] for i in S if i[1]==S[0][1]]
for i in sorted(S):
    print(i)

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