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, math
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict, Counter
from math import factorial
from bisect import bisect_left 


sys.setrecursionlimit(10**7)
N = int(input())
S = [input() for _ in range(N)]

d = defaultdict(int)
for s in S:
    d[s] += 1

maxn = max(list(d.values()))

for s in sorted(d.items()):
    if s[1] == maxn:
        print(s[0])

Solution (Python):
from collections import defaultdict
n=int(input())
d=defaultdict(int)
for _ in range(n):
    d[input()]+=1
d=sorted(d.items(),key=lambda x:x[1],reverse=True)
m=d[0][1]
ans=[]
for k,v in d:
    if v==m:
        ans.append(k)
ans=sorted(ans)
for i in ans:
    print(i)

Solution (Python):
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=pow(10,9)+7

n=int(input())
s=[input() for i in range(n)]
c=dict(Counter(s))
lst=[]
cnt=0
for i in c.items():
    if i[1]>cnt:
        lst=[i[0]]
        cnt=i[1]
    elif i[1]==cnt:
        lst.append(i[0])

lst.sort()

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

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

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

N = int(input())
Ss = Counter([input().rstrip() for _ in range(N)])
m = max(Ss.values())
ans = []
for k, v in Ss.items():
    if v == m:
        ans.append(k)
ans.sort()
print(*ans, sep="\n")

Solution (Python):

N = int(input())
d = {}
for i in range(N):
    s = input()
    if s not in d.keys():
        d[s] = 1
    else:
        d[s] += 1
ans = []
v = max(d.values())
for k in d.keys():
    if d[k] == v:
        ans.append(k)
ans.sort()
for i in range(len(ans)):
    print(ans[i])

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


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

ma = max(dic1.values())
lst1 = []
for i in dic1:
    if dic1[i] == ma:
        lst1.append(i)

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

Solution (Python):
import sys
from collections import Counter
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N = int(readline())
S = read().decode().split()

dicts = Counter(S)
max_cnt = 0
ans_list = []
for v in dicts.values():
    max_cnt = max(max_cnt, v)
for k, v in dicts.items():
    if v == max_cnt:
        ans_list.append(k)

ans_list = sorted(ans_list)

for key in ans_list:
    print(key)

Solution (Python):
n=int(input())
lists=[]
for i in range(n):
    a=input()
    lists.append(a)
import collections 
D=dict(collections.Counter(lists))
K=0
for some in D.values():
    K=max(K,some)
P=[]
for some in D.keys():
    if D[some]==K:
        P.append(some)
P=sorted(P)
for some in P:
    print(some)

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

import collections
c = collections.Counter(s)
ans=[]
first=c.most_common()[0][1]
for tup in c.most_common():
    if tup[1] != first:
        break
    ans.append(tup[0])
ans.sort()

for i in ans:
    print(i)

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

N = int(input())
S = []
S2 = []

for _ in range(N):
    S.append(input().strip())

count = Counter(S)
most = max(count.values())
for key, value in count.items():
    if value == most:
        S2.append([key, value])

S2.sort(key=lambda x:x[0])
for value in S2:
    print(value[0])

Solution (Python):

def solve():
    d = dict()
    for _ in range(int(input())):
        s = input()
        d[s] = d.get(s,0)+1
    m = max(d.values())
    return '\n'.join(sorted([k for k,v in d.items() if v == m]))

if __name__ == '__main__':
    print(solve())

Solution (Python):
import sys, math
from collections import Counter

def input():
    return sys.stdin.readline()[:-1]

def main():
    N = int(input())
    S = [input() for k in range(N)]
    C = Counter(S)
    t = 0
    for e in C.values():
        t = max(e,t)
    ans = []
    for e in C:
        if C[e] == t:
            ans.append(e)
    print(*sorted(ans),sep="\n")

if __name__ == '__main__':
    main()

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

B = c.Counter(A)

M = max(list(B.values()))

ans = []

for s,cnt in B.items():
	if cnt == M:
		ans.append(s)

ans.sort()

for a in ans:
	print(a)

Solution (Python):
from collections import Counter

n=int(input())
s=[input() for _ in range(n)]
c=Counter(s)
mx=c.most_common()[0][1]
ans=[]
for e in c.most_common():
    if mx==e[1]:
        ans.append(e[0])
ans.sort()
print(*ans,sep='\n')

Solution (Python):
n = int(input())
d = dict()
for i in range(n):
    s= input()
    d.setdefault(s, 0)
    d[s] += 1
d = sorted([[x, y] for x, y in d.items()], key=lambda x:x[1], reverse=True)
now = 0
ans = set()
for x, y in d:
    if y >= now:
        ans.add(x)
        now = y
    else:
        break
for x in sorted(ans):
    print(x)

Solution (Python):
d=dict()
n=int(input())
for i in range(n):
    s=input()
    if s in d:
        d[s]+=1
    else:
        d[s]=1
d=list(d.items())
d.sort(key=lambda x:x[0])
d.sort(key=lambda x:x[1],reverse=True)

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

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

Solution (Python):
N = int(input())
S = []
for _ in range(N):
    S.append(input())
from collections import defaultdict as ddict
cnt = ddict(int)
max_cnt = 0
for s in S:
    cnt[s] += 1
    max_cnt = max(max_cnt,cnt[s])
ans = []
for key in cnt.keys():
    if max_cnt == cnt[key]:
        ans.append(key)
for a in sorted(ans):
    print(a)

Solution (Python):


import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

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

C = Counter(A)
mx = max(C.values())
ans = []
for k, v in C.items():
    if v == mx:
        ans.append(k)
ans.sort()
[print(s) for s in ans]

Solution (Python):
N = int(input())
words = {}
max_count = 1
for i in range(N):
    new = input()
    if new in words:
        words[new] += 1
        if words[new] > max_count:
            max_count = words[new]
    else:
        words[new] = 1
ans = []
for word in words:
    if words[word] == max_count:
        ans.append(word)
        
ans.sort()

for elem in ans:
    print(elem)

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

from collections import defaultdict

d = defaultdict(int)

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

a = list(d.keys())
b = list(d.values())

l = len(a)
val = max(b)

ans = []

for i in range(l):
    if b[i] == val:
        ans.append(a[i])

ans = sorted(ans)
l = len(ans)

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

Solution (Python):
n = int(input())
d = {}
for i in range(n):
    x = input()
    if x not in d.keys():
        d[x] = 1
    else:
        d[x] += 1
l = []
m = 0
for i in d.keys():
    m = max(m, d[i])
for i in d.keys():
    if d[i] == m:
        l.append(i)
l = sorted(l)
for i in l:
    print(i)

Solution (Python):
from collections import defaultdict
N = int(input())
Ss = [input() for _ in range(N) ]
di  ={}
for s in Ss:
    if s not in di:
        di[s] = 1
    else:
        di[s] += 1

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

key = di[0][1]
for temp in di:
    k,v = temp
    if key == v:
        print(k)

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

for _ in range(n):
    s = input()
    dic[s] += 1

k = max(dic.values())

ansl = []
for s in dic:
    if dic[s] == k:
        ansl.append(s)

ansl = sorted(ansl)

for s in ansl:
    print(s)

Solution (Python):
from collections import defaultdict
N = int(input())
P = defaultdict(int)
for i in range(N):
  P[input()] += 1
m = max(P.values())
E = []
for k, v in P.items():
  if v == m:
    E.append(k)
E.sort()
for e in E:
  print(e)

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

for _ 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], reverse=True)

flag = True
k = 0
l = []
for key, val in S:
    if flag:
        l.append(key)
        k = val
        flag = False
    else:
        if k == val:
            l.append(key)
        else:
            break

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

Solution (Python):
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
cs = Counter(s)
freq = Counter(cs).most_common()
cnt = Counter(cs).most_common()[0][1]
ans = []
for i, c in freq:
  if c == cnt:
    ans.append(i)
    
ans.sort()

for i in ans:
  print(i)

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

d = {}
for _ in range(N):
    s = input()
    if s not in d:
        d[s] = 0
    d[s] += 1

max_val = max(d.values())
keys = [k for k, v in d.items() if v == max_val]
for k in sorted(keys):
    print(k)

Solution (Python):
from collections import Counter

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

c = Counter(S)

max_cnt = 0
words = []
for s_i, cnt in sorted(c.items(), key=lambda x: x[1], reverse=True):
    if max_cnt <= cnt:
        max_cnt = cnt
        words.append(s_i)
    else:
        break

for word in sorted(words):
    print(word)

Solution (Python):
n = int(input())
s = {}
for i in range(n):
    temp = input()
    s.setdefault(temp, 0)
    s[temp] += 1
num = max(s.values())
s2 = list(s.items())
s3 = [s2[i][0] for i in range(len(s)) if s2[i][1] == num]
s3.sort()
for i in s3:
    print(i)

Solution (Python):
from collections import Counter


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

C = Counter(S)

max = -1
ans = []

for k, v in C.most_common():
    if max == -1:
        max = v
    elif max > v:
        break
    ans.append(k)

ans = sorted(ans)

for a in ans:
    print(a)

Solution (Python):
from collections import defaultdict

N = int(input())
d = defaultdict(int)
for i in range(N):
    s = input().strip()
    d[s] += 1

L = sorted(d.items(), key=lambda x: -x[1])
MX = L[0][1]

L2 = [l[0] for l in L if l[1] == MX]
L2.sort()

for l in L2:
    print(l)

Solution (Python):
n = int(input().strip())
s = [input().strip() for _ in range(n)]
dic = {}

for e in s:
    if e in dic:
        dic[e] += 1
    else:
        dic[e] = 1

ans = []
m = max(dic.values())
for k, v in dic.items():
    if v == m:
        ans.append(k)
ans.sort()
for e in ans:
    print(e)

Solution (Python):
from collections import deque, Counter
from itertools import chain, combinations
import json
import numpy as np


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

    v = sorted([a[0] for a in vs if vs[0][1] == a[1]])
    for a in v:
        print(a)


if __name__ == "__main__":
    main()

Solution (Python):

from __future__ import division, print_function

import os
import sys
from collections import defaultdict
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    n = int(input())

    votes = defaultdict(int)

    m = 0
    top = []
    for _ in range(n):
        s = input()
        votes[s] += 1

        if votes[s] > m:
            m = votes[s]
            top = []

        if votes[s] == m:
            top.append(s)

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




BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")



if __name__ == "__main__":
    main()

Solution (Python):
import collections
n = int(input())
s = []
for i in range(n):
    s.append(input())
s = collections.Counter(s)
ans = []
k = list(s.most_common())
k_len = k[0][1]
for i in k:
    word, count = i
    if count == k_len:
        ans.append(word)
ans.sort()
for i in ans:
    print(i)

Solution (Python):
import sys
from collections import defaultdict
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
N = int(input())
d = defaultdict(int)
max_n= 0
for n in range(N):
    s = input().strip()
    d[s] += 1
    if d[s] > max_n:
        max_n = d[s]

for s in sorted(d.keys()):
    if d[s] == max_n:
        print(s)

Solution (Python):
from collections import Counter
N = int(input())
S = [str(input()) for _ in range(N)]
hoge = Counter(S)
hoge = sorted(hoge.items(), key=lambda x: (-x[1], x[0]))
now = hoge[0][1]
for k, v in hoge:
    if now == v:
        print(k)
    else:
        break

Solution (Python):
from collections import Counter

n = int(input())
s = [input() for i in range(n)]
c = Counter(s).most_common()
m = c[0][1]
a = []
for i in c:
    s, k = i
    if k != m:
        break
    a.append(s)

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

Solution (Python):
import sys
from collections import Counter
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    S=[input() for i in range(N)]
    c=Counter(S)
    mc=c.most_common()
    num=mc[0][1]
    ans=[]
    for t in mc:
        if t[1]==num:
            ans.append(t[0])
        else:
            break
    ans.sort()
    for a in ans:
        print(a)
        
    
        

if __name__ == '__main__':
    main()

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

from collections import Counter
c = Counter(S)

max = None
ans = []
for k, v in sorted(c.items(), key=lambda x: -x[1]):
    if max is None:
        max = v
    if v == max:
        ans.append(k)
    else:
        break

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

Solution (Python):
N = int(input())
from collections import Counter
s = [input() for i in range(N)]
c = Counter(s)

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

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

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

w = [input() for _ in range(n)]
c = collections.Counter(w)
k = c.most_common()
cnt = k[0][1]

ans = []
for i,j in k:
    if j == cnt:
        ans.append(i)
ans.sort()

for i in ans:
    print(i)

Solution (Python):
import sys
from collections import Counter

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
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 LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n=II()
    ss=[SI() for _ in range(n)]
    cnt=Counter(ss)
    pv=-1
    for s,v in sorted(cnt.items(),key=lambda x:(-x[1],x[0])):
        if v!=pv and pv!=-1:break
        print(s)
        pv=v

main()

Solution (Python):
n = int(input())
count_dict = dict()
for i in range(n):
    x = input()
    if x in count_dict:
        count_dict[x] += 1
    else:
        count_dict[x] = 1
max_count = 0
for i in count_dict:
    if count_dict[i] > max_count:
        max_count = count_dict[i]
ans = []
for i in count_dict:
    if count_dict[i] == max_count:
        ans.append(i)
ans = sorted(ans)
for i in ans:
    print(i)

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

mx = 0

for key in mp.keys():
    if mx < mp[key]:
        mx = mp[key]

ans_list = []

for key in mp.keys():
    if mp[key] == mx:
        ans_list.append(key)

ans_list = sorted(ans_list)

for ans in ans_list:
    print(ans)

Solution (Python):
from collections import Counter

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

ans = []
max_v = S.most_common()[0][1]
for key, v in S.most_common():
    if v != max_v:
        break
    ans.append(key)
for s in sorted(ans):
    print(s)

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

cnt = 0
for i, j in dic.items():
    cnt = max(cnt, j)
ans = []
for i, j in dic.items():
    if cnt == j:
        ans.append(i)
ans.sort()
for i in ans:
    print(i)

Solution (Python):
def main():
    N = int(input())
    S = [input() for i in range(N)]
    from collections import Counter
    c = Counter(S)
    cnt = c.most_common()[0][1]
    ans = []
    for s in c.most_common():
        
        if s[1] == cnt:
            ans.append(s[0])
    ans.sort()
    for a in ans:
        print(a)


if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter

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

ctr = Counter(S)
cnt_max =  max(ctr.values())

for s, c in sorted(ctr.items(), key=lambda x: (-x[1], x[0])):
    if c == cnt_max:
        print(s)

Solution (Python):



def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    

    n = int(input())
    s = [input()[:-1] for _ in range(n)]
    from collections import Counter
    ma = 0
    ans = []
    for st, cou in Counter(s).most_common():
        ma = max(ma, cou)
        if cou == ma:
            ans.append(st)
        else:
            break
    ans.sort()
    print(*ans, sep='\n')


if __name__ == '__main__':
    main()

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

    vote = Counter(S)
    most = (vote.most_common(1))[0][1]
    ans = [k for k, v in vote.items() if v == most]
    return '\n'.join(map(str, sorted(ans)))

print(c_poll())

Solution (Python):
from collections import Counter

N = int(input())
strings = Counter([input() for _ in range(N)])
lst = sorted(list(strings.items()), key=lambda x: (-x[1], x[0]))
num = lst[0][1]
for l in lst:
    if l[1] != num: break
    print(l[0])

Solution (Python):
n=int(input())
l=[]
for i in range(n):
    l.append(input())
l.sort()
l.append('1')
f=1
m=1
for i in range(n):
    if l[i]==l[i+1]:
        f+=1
    else:
        m=max(m,f)
        f=1
ans=[]
for i in range(n):
    if l[i]==l[i+1]:
        f+=1
    else:
        if f==m:
            ans.append(l[i])
        f=1
for i in ans:
    print(i)

Solution (Python):
from collections import defaultdict
D = defaultdict(int)
N = int(input())
M = 0
for i in range(N):
    s = input()
    D[s] += 1
    M = max(M,D[s])
ans = []
for i in D:
    if D[i] == M:
        ans.append(i)
ans.sort()
for i in ans:
    print(i)

Solution (Python):
n = int(input())
a = dict()
for i in range(n):
    x = input()
    if x not in a:
        a[x] = 1
    else:
        a[x] += 1

maxer = 0
for i in a:
    if a[i] > maxer:
        maxer = a[i]

out = []
for i in a:
    if a[i] == maxer:
        out.append(i)

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

Solution (Python):
import collections

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

c = collections.Counter(S)
c_most_num = c.most_common()[0][1]
ans = []
for ci in c.most_common():
    if ci[1] == c_most_num:
        ans.append(ci[0])
ans.sort()

for a in ans:
    print(a)

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

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

c = Counter(ss)

ma = max(c.values())
d = dict(filter(lambda x : x[1] == ma, c.items()))
s = sorted(d.keys())

for e in s:
  print(e)

Solution (Python):
import sys
input = sys.stdin.readline
from collections import defaultdict
def main():
    N = int( input())
    S = [ input().strip() for _ in range(N)]
    d = defaultdict( int)
    for s in S:
        d[s] += 1
    m = 0
    for _, v in d.items():
        if v > m:
            m = v
    ANS = []
    for w, v in d.items():
        if v == m:
            ANS.append(w)
    ANS.sort()
    print("\n".join(ANS))
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
M = max(D[i] for i in D)
L = []
for i in D:
  if D[i] == M:
    L.append(i)
L.sort()
for i in range(len(L)):
  print(L[i])

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

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

import collections
import itertools

counter = collections.Counter(A)
mode_v = counter.most_common()[0][-1]
it = itertools.takewhile(
    lambda kv: kv[-1] == mode_v, counter.most_common()
)


B = []
for k, v in it:
    B.append(k)
B = sorted(B)
for i in B:
    print(i)

Solution (Python):
from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
c = Counter(S)
max_num = 0
for i, v in c.items():
    max_num = max(max_num, v)

ret_list = []
for i, v in c.items():
    if v == max_num:
        ret_list.append(i)
ret_list.sort()
for i in ret_list:
    print(i)

Solution (Python):
from collections import Counter
N = int(input())
S = Counter([input() for i in range(N)])
k = max(S.values())
A = []
for s in S:
    if S[s]==k:
        A.append(s)
A.sort()
for a in A:print(a)

Solution (Python):
from collections import Counter

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

C = Counter(S).most_common()
ans = []

for s in C:
    if s[1] == C[0][1]:
        ans.append(s[0])

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

Solution (Python):
N = int(input())
sdict = {}
mf = 0
for _ in range(N):
    s = input()
    if not s in sdict:
        sdict[s] = 1
        if mf == 0:
            mf = 1
    else:
        sdict[s] += 1
        if mf < sdict[s]:
            mf = sdict[s]

out = []
for k, f in sdict.items():
    if f == mf:
        out.append(k)
out.sort()
for o in out:
    print(o)

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

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

n = list(d.values())
n.sort()
max_n = n[-1]
ans = []
for k in d:
  if d[k] == max_n:
    ans.append(k)

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

Solution (Python):
import collections
n=int(input())
s=[input() for i in range(n)]
c=collections.Counter(s)
l=(c.most_common())
x=l[0][1]
ans=[]
for i in range(len(l)):
  if l[i][1]==x:
    ans.append(l[i][0])
  else:
    break
ans.sort()
for i in range(len(ans)):
  print(ans[i])

Solution (Python):
from collections import Counter

N = int(input())
S = [input() for i in range(N)]
Sc = Counter(S)
Sc1 = Sc.most_common()

m = Sc1[0][1]
ans = []
for s in Sc1:
    if s[1] == m:
        ans.append(s[0])
ans.sort()
for a in ans:
    print(a)

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

maxkey = None
result = []
for (val, key) in Counter(S).most_common():
  if maxkey == None:
    maxkey = key
    result.append(val)
  else:
    if maxkey == key:
      result.append(val)
    else:
      break

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

Solution (Python):
n=int(input())
cnt,d=0,{}
for i in range(n):
    s=input()
    if s in d:
        d[s]+=1
    else:
        d[s]=1
    cnt=max(cnt,d[s])
ans=[]
for i in d:
    if d[i]==cnt:
        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)]

s = list(Counter(S).most_common())
n = s[0][1]
ans = []

for i, j in s:
    if j == n:
        ans.append(i)

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

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

table = {}

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

data = []
for S, count in table.items():
	data.append((-count, S))

data.sort()

i = 0
while True:
	print(data[i][1])
	i += 1
	if i >= len(data) or data[i][0] != data[0][0]:
		break

Solution (Python):
n = int(input())
s = [input() for i in range(n)]
smap = {}
for i in range(n):
    smap[s[i]] = smap.get(s[i], 0) + 1
maxs = []
maxsmap = max(list(smap.values()))
for si in smap:
    if maxsmap == smap[si]:
        maxs.append(si)
maxs.sort()
for i in range(len(maxs)):
    print(maxs[i])

Solution (Python):

from collections import Counter
n = int(input())
s = [input() for i in range(n)]

s2 = Counter(s)
mx = 0
for k in s2:
    mx = max(mx,s2[k])
ans = []
for k in s2:
    if s2[k]==mx:
        ans.append(k)
ans.sort()
for st in ans:
    print(st)

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

n = int(input())
s = [str(input().rstrip()) for _ in range(n)]
c = Counter(s)
d_sorted = sorted(c.items(), key=lambda x:x[1], reverse=True)

m = d_sorted[0][1]
ans = []
for key, v in d_sorted:
    if v == m:
        ans.append(key)
ans.sort()
print("\n".join(ans))

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

import collections
d=collections.defaultdict(int)
maxi=0
for i in a:
    d[i]+=1
    maxi=max(d[i],maxi)
b=[]
for word,cnt in d.items():
    if cnt==maxi:
        b.append(word)
b=sorted(b)
for i in b:
    print(i)

Solution (Python):
n = int(input())
s = [input() for i in range(n)]
vote=dict()
for i in range(n):
    try:
        vote[s[i]]+=1
    except:
        vote[s[i]]=1

ans=list()
mx=0
for s,c in vote.items():
    if mx<c:
        ans=list()
        ans.append(s)
        mx=c
    elif mx==c:
        ans.append(s)

ans.sort()

for s in ans:
    print(s)

Solution (Python):
from collections import Counter


def main():
    N = int(input())
    S = [input() for _ in range(N)]
    cnt = list(Counter(S).items())
    cnt.sort(reverse=True, key=lambda x: x[1])
    ans = list(filter(lambda x: x[1] == cnt[0][1], cnt))
    ans.sort()
    for s, c in ans:
        print(s)


if __name__ == "__main__":
    main()

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

d = {}

m = 0
for i in range(N):
    S = input()
    if S in d:
        d[S] += 1
    else:
        d[S] = 1
    if d[S] > m: m = d[S]

ans_l = []

for k, v in d.items():
    if v==m: ans_l.append(k)

ans_l = sorted(ans_l)

for ans in ans_l:
    print(ans)

Solution (Python):
import math
import itertools
import fractions
import heapq
import collections
import bisect
import sys
import copy

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

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
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()

n = I()
di = collections.defaultdict(int)

for i in range(n):
    s = S()
    di[s]+=1

mx = 0
l = []
for i in di:
    if mx<di[i]:
        l = [i]
        mx = di[i]
    elif mx==di[i]:
        l.append(i)
l.sort()
for v in l:
    print(v)

Solution (Python):
n=int(input())
c={}
for i in range(n):
    t=input()
    if t in c:
        c[t]+=1
    else:
        c[t]=1
c=sorted(c.items(),key=lambda x:(-x[1],x[0]))
p=c[0][1]
for i,j in c:
    if j==p:
        print(i)
    else:
        break

Solution (Python):
from collections import Counter
n = int(input())
S = [input() for i in range(n)]
S = Counter(S).most_common()
max_v = S[0][1]
ans = []
for k ,v in S:
    if v == max_v:
        ans.append(k)
ans.sort()
for i in ans:
    print(i)