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



Sample input:
7
beat
vet
beet
bed
vet
bet
beet


Sample output:
beet
vet

Submission status: Accepted

Solution code:
from sys import stdin
from itertools import groupby
n = int(stdin.readline().rstrip())
li = [stdin.readline().rstrip() for _ in range(n)]
li.sort()
lin = []
for key, value in groupby(li):
    lin.append((key,len(list(value))))
lin.sort(key=lambda x:(x[1]*(-1),x[0]))
point = lin[0][1]
for i,j in lin:
    if j == point:
        print(i)
    else:
        break

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

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

from collections import Counter

c = Counter(S)

ans = []

max_count = max(c.values())

for i in c:
    if c[i] == max_count:
        ans.append(i)
ans.sort()

for j in ans:
    print(j)

Submission status: Accepted

Solution code:
from collections import Counter

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

sc = Counter(s).most_common()
maxi = sc[0][1]
ans = []
for i, j in sc:
    if j == maxi:
        ans.append(i)

ans = sorted(ans)
print(*ans)

Submission status: Accepted

Solution code:
N = int(input())
dicta = {}
for i in range(N):
    s = input()
    if s not in dicta:
        dicta[s] = 1
    else:
        dicta[s]+=1
maxv = max(dicta.values())
ans = []
for k,v in dicta.items():
    if v == maxv:
        ans.append(k)
ans.sort()
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
from collections import Counter

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

c = Counter(s)
mx = max([v for v in c.values()])

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

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

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    cnt = {}
    max_num = 0
    for _ in range(N):
        s = input().rstrip('\n')
        if s not in cnt:
            cnt[s] = 1
        else:
            cnt[s] += 1
        if cnt[s] > max_num:
            max_num = cnt[s]

    ans = []
    for s in cnt:
        if cnt[s] == max_num:
            ans.append(s)
    ans.sort()
    for a in ans:
        print(a)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

from collections import defaultdict
dd = defaultdict(int)

max_n = 0

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

ans = []
for key in dd:
    if dd[key]==max_n:
        ans.append(key)

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8

from collections import Counter
def ri():
    return int(input())

def rl():
    return list(input().split())

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

def main():
    n = ri()
    ls = Counter()
    for i in range(n):
        s = input()
        ls[s] += 1
    m = -1
    ans = []
    for k, c in ls.most_common():
        if m == -1:
            m = c
        if c < m:
            break
        ans.append(k)
    ans.sort()
    for s in ans:
        print(s)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
*S, = [input() for _ in [0]*N]

cnt = {}
for s in S:
    cnt[s] = cnt.get(s,0) + 1

M = max(cnt.values())
ans = []
for k,v in cnt.items():
    if v==M:
        ans.append(k)
ans.sort()
for out in ans:
    print(out)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1



n=int(input())
C=collections.Counter([input() for i in range(n)])
M=max(C.values())
S=[]
for e,i in  C.items():
  if i == M:
    S.append(e)
S.sort()
print(*S,sep="\n")

Submission status: Accepted

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

t = max(d, key = lambda i : d[i])
print(*(sorted([i for i in d if d[i] == d[t]])), sep = '\n')

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
a = [input() for i in range(n)]
c = Counter(a)
m = c.most_common()[0][1]
ans = []
for i,x in c.items():
  if x == m:
    ans.append(i)
ans.sort()
print(*ans,sep="\n")

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from collections import Counter
n=int(input())
S=[input() for _ in range(n)]
Sc=Counter(S)
Scm=Sc.most_common()
a,cnt=Scm[0]
ans=[]
for a,b in Scm:
    if b==cnt:
        ans.append(a)
    else:
        continue
ans.sort()
print(*ans, sep='\n')

Submission status: Accepted

Solution code:
n = int(input())
from collections import defaultdict
m = defaultdict(int)
for i in range(n):
  s = input()
  m[s] += 1
ma = sorted(m.values())[-1]
x = sorted(m.items())
for e in x:
  if e[1] == ma:
    print(e[0])

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(1000000000)
import math
from fractions import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    vn = vk = vn_k = 1
    for i in range(1, n+1):
        vn = vn * i % modp
        if i == k:
            vk = vn
        if i == n-k:
            vn_k = vn
    return vn * get_inv(vk, modp) * get_inv(vn_k, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

def main():
    N=ii()
    d = defaultdict(int)
    for _ in range(N):
        d[input()]+=1
    m = max(d.values())
    ss = [s for s in d.keys() if d[s]==m]
    ss.sort()
    for s in ss:
        print(s)

main()

Submission status: Accepted

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

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

ans = []
cnt = 0
for i in memo:
    if memo[i] > cnt:
        ans = []
        cnt = memo[i]
        ans.append(i)
    elif memo[i] == cnt:
        ans.append(i)
    else:
        pass
ans = sorted(ans)
for string in ans:
    print(string)

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
Ss = [input() for i in [0]*N]
C = Counter(Ss)
m = max(C.values())

ans = sorted([k for k,v in C.items() if v == m])

for a in ans:
    print(a)

Submission status: Accepted

Solution code:
from collections import Counter
import sys
input = sys.stdin.readline

def solve():
    N = int(input())
    Sss = [input().rstrip() for _ in range(N)]

    cnt = Counter(Sss)
    #print('cnt:', cnt)

    maxNum = max(cnt.values())
    #print('maxNum:', maxNum)

    anss = []
    for key, value in cnt.items():
        if value == maxNum:
            anss.append(key)
    #print('anss:', anss)

    anss.sort()

    print('\n'.join(anss))


solve()

Submission status: Accepted

Solution code:
from collections import defaultdict


dict = defaultdict(int)
n = int(input())
for _ in range(n):
    s = input()
    dict[s] += 1

maxim = max(dict.values())

candidates = []

for key, count in dict.items():
    if count == maxim:
        candidates.append(key)

candidates.sort()

for ans in candidates:
    print(ans)

Submission status: Accepted

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

D = []

S.sort()

re = S[0]
c = 1
for i in range(1, N):
  if re == S[i]:
    c += 1
  else:
    D.append([c, re])
    c = 1
    re = S[i]
D.append([c, re])

D.sort(reverse = True)
mi = D[0][0]
L = []
for i in range(len(D)):
  if D[i][0] == mi:
    L.append(D[i][1])
  else:
    break

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

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict
range = xrange
input = raw_input

n = int(input())

count = defaultdict(int)
S = sys.stdin.read().split()
for c in S:
    count[c] += 1

best = -1
for s in count:
    best = max(best, count[s])

out = []
for s in count:
    if count[s] == best:
        out.append(s)
out.sort()
print '\n'.join(out)

Submission status: Accepted

Solution code:
from collections import defaultdict

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

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

maxn = max(D.values())

res = []

for s in S:
    if D[s] == maxn:
        res.append(s)

res = sorted(set(res))

for r in res:
    print(r)

Submission status: Accepted

Solution code:
N = int(input())
D = {}
for _ in range(N):
    S = input()
    if S not in D: D[S]=0
    D[S]+=1

M = max(D.values())
for S in sorted(list(D)):
    if D[S]==M: print(S)

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
a = [input() for _ in range(n)]

cnt = Counter(a)
max_s = max(cnt.values())
ans = []
for s, i in cnt.items():
    if i == max_s:
        ans.append(s)

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

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
S = [input() for _ in range(n)]
C = Counter(S)
l = C.most_common()[0][1]
L = []
for i, j in C.items():
  if j == l:
    L.append(i)
L.sort()
print(*L, sep="\n")

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
Ss = [input() for _ in range(N)]
ct = Counter(Ss)
M = ct.most_common(1)[0][1]
for s in sorted(ct.keys()):
    if ct[s] == M:
        print(s)

Submission status: Accepted

Solution code:
import collections
N = int(input())

S = [input() for i in range(N)]
table = collections.defaultdict(int)
for x in S:
    table[x] += 1

table = list(table.items())
table.sort(key=lambda x: x[1], reverse=True)
ans = []
k = table[0][1]
for x, i in table:
    if i == k:
        ans.append(x)
ans.sort()
for x in ans:
    print(x)

Submission status: Accepted

Solution code:
def main():
    from collections import Counter

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

    ctr = Counter(s)

    _, most_cnt = ctr.most_common()[0]

    ret = []
    for key, cnt in ctr.most_common():
        if cnt != most_cnt:
            break
        ret.append(key)

    ret.sort()

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


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())

Submission status: Accepted

Solution code:
from collections import defaultdict
N = int(input())
d = defaultdict(int)
for _ in range(N):
    s = input()
    d[s]+=1
m = max(d.values())
ans = []
for k, v in d.items():
    if v == m:
        ans.append(k)
ans.sort()
print(*ans, sep = '\n')

Submission status: Accepted

Solution code:
from sys import stdin, stdout

n = input()
f = dict()
inp = stdin.readlines()
for line in inp:
    s = line.strip()
    try: f[s] += 1
    except: f[s] = 1

mx = 0
for key in f:
    mx = max(mx, f[key])

l = []
for key in f:
    if f[key] == mx:
        l.append(key)
l.sort()

stdout.write("\n".join(l))

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

import sys
readline = sys.stdin.readline
read = sys.stdin.read

#n,*a = [int(i) for i in read().split()]
#a = [int(i) for i in readline().split()]
#n = int(input())

n = int(input())
#n,*a = [int(i) for i in read().split()]
from collections import Counter

d = Counter(read().split())

m = max(d.values())

a = sorted(d.items())

for s,si in a:
    if si == m:
        print(s)

Submission status: Accepted

Solution code:

lis = []
dic = {}

N = int(input())
maxi = 0

for i in range(N):

    S = input()

    if S not in dic:
        lis.append(S)
        dic[S] = 1
    else:
        dic[S] += 1

    maxi = max(maxi , dic[S])

lis.sort()

ans = []

for i in lis:
    if dic[i] == maxi:
        ans.append(i)


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

Submission status: Accepted

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

ANS = []
for d in D:
    if D[d] == ma:
        ANS.append(d)
for ans in sorted(ANS):
    print(ans)

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

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

n = ni()
d = dict()
for _ in range(n):
    x = input()
    if x not in d: d[x] = 0
    d[x] += 1
f = max(d.values())
l = [x for x in d if d[x] == f]
l.sort()
print(*l, sep='\n')

Submission status: Accepted

Solution code:
from collections import Counter

n=int(input())
s=[input() for i in range(n)]
c=Counter(s)
c_v=sorted(c.values(),reverse=True)

m=c_v[0]

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

Submission status: Accepted

Solution code:
import sys,collections

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# Summarize count of factor within list -- START --
def summarize_list(l):
  sl=sorted(l)

  a=sl[0]
  c=1
  res=[]

  for x in sl[1:]:
    if x==a:
      c+=1
    else:
      res.append([a,c])
      a=x
      c=1
  res.append([a,c])

  return res
# Summarize count of factor within list --- END ---

def main():
  n=I()
  l=[S() for _ in range(n)]

  l=summarize_list(l)

  l=sorted(l,key=lambda x:x[0])
  l=sorted(l,key=lambda x:x[1],reverse=True)

  a=l[0][1]
  print(l[0][0])

  for x,y in l[1:]:
    if y!=a:
      break
    else:
      print(x)

main()
# print(main())

Submission status: Accepted

Solution code:
N=int(input())
from collections import Counter
c=Counter([input() for i in range(N)]).most_common()
r=[]
V=c[0][1]
for k,v in c:
    if v!=V:
        break
    r.append(k)
print(*sorted(r),sep="\n")

Submission status: Accepted

Solution code:
def examA():
    N = LI()
    N.sort()
    if N[0]==N[1] and N[0]!=N[2]:
        print("Yes")
    elif N[1]==N[2] and N[0]!=N[2]:
        print("Yes")
    else:
        print("No")
    return

def examB():
    N = I()
    A = LI()
    for a in A:
        if a%2==0:
            if a%3!=0 and a%5!=0:
                print("DENIED")
                return
    print("APPROVED")
    return

def examC():
    N = I()
    S = [SI()for _ in range(N)]
    d = defaultdict(int)
    for s in S:
        d[s] += 1
    t = max(d.values())
    ans = []
    for s in S:
        if d[s]==t:
            ans.append(s)
            d[s] = 0
    ans.sort()
    for v in ans:
        print(v)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math,random
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examC()

"""

"""

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.buffer.readline
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getlist():
    return list(map(int, input().split()))
import math
import heapq
from collections import defaultdict, Counter, deque
MOD = 10**9 + 7
INF = 10**15


def main():
    n = getN()
    # n, m = getlist()
    # nums = getlist()
    d = defaultdict(int)
    for i in range(n):
        s = input().strip()
        d[s] += 1
    # print(d)
    mx = max(d.values())
    ans = [k for (k, v) in d.items() if v == mx]

    ans.sort()
    for an in ans:
        print(str(an)[2:-1])

if __name__ == '__main__':
    main()

"""
9999
3

2916
"""

Submission status: Accepted

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

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

ans_buf = []
max_c =0
for key in d.keys():
    if d[key] > max_c:
        ans_buf = []
        ans_buf.append(key)
        max_c = d[key]
    elif d[key] == max_c:
        ans_buf.append(key)
    else:
        continue

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
d = {}
n = int(input())
c = 0
for _ in range(n):
    s = input()
    if s not in d:
        d[s] = 1
    else:
        d[s] += 1
    c = max(c, d[s])
lis = sorted(d.items(), key=lambda x: x[1], reverse=True)
ans = []
for a in lis:
    if a[1] == c:
        ans.append(a[0])
ans = sorted(ans)
for v in ans:
    print(v)

Submission status: Accepted

Solution code:
N = input()
S = [raw_input() for _ in range(N)]

M = {}
for s in S:
  if s not in M:
    M[s] = 0
  M[s] += 1
m = max(M.values())
for a in sorted(k for k in M if M[k]==m):
  print a

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
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))  # type: int
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, S)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

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)

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

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

Submission status: Accepted

Solution code:

n = int(input())

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

from collections import Counter
c = Counter(S)
# print(c)
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])

Submission status: Accepted

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
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()

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input()) # n=1
def inpm(): return map(int,input().split()) # x=1,y=2
def inpl(): return list(map(int, input().split())) # a=[1,2,3,4,5,...,n]
def inpls(): return list(input().split())  # a=['1','2','3',...,'n']
def inplm(n): return list(int(input()) for _ in range(n)) # x=[] 複数行
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)]) # [[1,1,1,1],[2,2,2,2],[3,3,3,3]] 
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()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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]

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from sys import stdin
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

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
# print(d)
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)