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:
import sys


def main():
    n = int(sys.stdin.readline().strip())
    poll = dict()
    max_num = 1
    for _ in range(n):
        p = sys.stdin.readline().strip()
        if p in poll:
            poll[p] += 1
            if max_num < poll[p]:
                max_num = poll[p]
        else:
            poll[p] = 1
    array = []
    for v in poll:
        if poll[v] == max_num:
            array.append(v)
    array.sort()
    for s in array:
        print(s)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
from collections import Counter
N=input()

S=[ sys.stdin.readline().strip() for _ in range(N) ]

C=Counter(S)
C=list(C.items())
C.sort(key=lambda x:(-x[1],x[0]) )

max_cnt=None
for i,x in enumerate(C):
    name=x[0]
    cnt=x[1]
    if i==0:
        max_cnt=cnt
        print name
    else:
        if max_cnt==cnt:
            print name
        else:
            quit()

Submission status: Accepted

Solution code:
from collections import Counter
n=int(input())
s=[]
ansl=[]
for i in range(n):
    s.append(input())
counter = Counter(s)
max=counter.most_common(1)[0][1]
for w in counter.most_common():
    if w[1]==max:
        ansl.append(w[0])
ansl.sort()
for i in range(len(ansl)):
    print(ansl[i])

Submission status: Accepted

Solution code:
import collections
n=int(input())
s=[]
for i in range(n):
    s.append(input())
c=collections.Counter(s)
v=dict(c).values()
mx=max(v)
l=[]
for k,v in dict(c).items():
    if v==mx:
        l.append(k)

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

Submission status: Accepted

Solution code:
from collections import defaultdict
d = defaultdict(int)
N = int(input())
for i in range(N):
    d[input()] += 1
m = max(d.values())
d = sorted(d.items(), key=lambda x:x[1])
d.reverse()
ans = []
for s in d:
    if s[1] == m:
        ans.append(s[0])
    else:
        break
ans.sort()
for a in ans:
    print(a)

Submission status: Accepted

Solution code:
n = int(input())

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

maxCount = max(countMap.values())
maxCountKeys = [k for k, v in countMap.items() if v == maxCount]
for maxCountKey in sorted(maxCountKeys):
  print(maxCountKey)

Submission status: Accepted

Solution code:
n = int(input())
S = dict()
for i in range(n):
    word = input()
    if word not in S:
        S[word] = 1
    else:
        S[word] += 1
S = sorted(S.items(), key=lambda x:x[1], reverse=True)

max_v = S[0][1]
ans = []
for k,v in S:
    if v == max_v:
        ans.append(k)
    else:
        break
ans = sorted(ans)
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
from collections import Counter


def main(n, s):
    c = Counter(s)
    max_count = c.most_common()[0][1]
    res = []
    for keys, count in c.most_common():
        if max_count == count:
            res.append(keys)

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


if __name__ == "__main__":
    n = int(input())
    s = [input() for _ in range(n)]

    main(n, s)

Submission status: Accepted

Solution code:
import collections
N = int(input())
S = [input() for _ in range(N)]
S_C = collections.Counter(S)
max = S_C.most_common()[0][1]
ans = [i[0] for i in S_C.items() if i[1] >= max]
ans.sort()
for i in range(len(ans)):
    print(ans[i])

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import Counter


stdin = open(0)

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

counter = Counter(S)
max_cnt = max(counter.values())
names = [name for name, cnt in counter.items() if cnt == max_cnt]
names.sort()

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

Submission status: Accepted

Solution code:
n = int(input())
s = ["" for _ in range(n)]
for i in range(n):
    s[i] = input()
s.sort()
s.append("")
cnt = 0
m = -1
ans = []
for i in range(n):
    if s[i] == s[i + 1]:
        cnt += 1
    else:
        if cnt > m:
            m = cnt
            ans = [s[i]]
        elif cnt == m:
            ans.append(s[i])
        cnt = 0
for word in ans:
    print(word)

Submission status: Accepted

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

ans = sorted(dic.items(), key=lambda x:x[1])
ans = ans[::-1]
check = ans[0][1]
ans2 = []
for i in range(len(ans)):
    if ans[i][1] == check:
        ans2.append(ans[i][0])
ans2.sort()
for i in ans2:
    print(i)

Submission status: Accepted

Solution code:
import collections

N,*S = open(0).read().split()
N = int(N)

c = collections.Counter(S)
c = sorted(c.items(),key=lambda x:(-x[1],x[0]))
maxCnt = c[0][1]
for i in range(len(c)):
  if c[i][1] == maxCnt:
    print(c[i][0])
  else:
    break

Submission status: Accepted

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

from collections import Counter

c = Counter(S)
mc = c.most_common()

m = mc[0][1]
ls = [c[0] for c in mc if c[1]==m]
ls.sort()

for i in ls:
  print(i)

Submission status: Accepted

Solution code:
import collections
N = int(input())
S = [input() for n in range(N)]
c = collections.Counter(S)
a = []
b = 0

for v,c in c.most_common():
  if b==0:
    m = c
    a.append(v)
    b = 1
  else:
    if m==c:
      a.append(v)

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

Submission status: Accepted

Solution code:
import collections

n=int(input())
s=['' for _ in range(n)]
ans=[]
for i in range(n):
  x=input()
  s[i]=x
c = collections.Counter(s)
l=c.most_common()
r=len(list(set(s)))
cnt=l[0][1]
l.sort(key=lambda x: x[0])
for i in range(r):
  if cnt==l[i][1]:
    print(l[i][0])

Submission status: Accepted

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

i=0
q1=-1
for p,q in sorted(dic.items(),key=lambda x: (-x[1],x[0])):
    if i>0 and q1!=q:
        break
    else:
        print(p)
        i+=1
        q1=q

Submission status: Accepted

Solution code:
n = int(input())
s = {}
for i in range(n):
    tmp = input()
    if not tmp in s.keys():
        s[tmp] = 1
    else:
        s[tmp] += 1
m = 0
l = []
for i in sorted(s.items(), key=lambda x:x[1], reverse=True):
    if m <= i[1]:
        m = i[1]
        l.append(i[0])
    else:
        break
 
for i in sorted(l):
    print(i)

Submission status: Accepted

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

dic=cl.Counter(s)
m=max(dic.values())

ret=[k for k,v in dic.items() if v==m]

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

Submission status: Accepted

Solution code:
from collections import Counter

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

sc = Counter(sl)
#print(sc)

max = 0
ans = []
for i , word in enumerate(sc.most_common()):
    if i == 0:
        max = word[1]
        ans.append(word[0])
        #print(word[0])
    else:
        if max == word[1]:
            ans.append(word[0])
            #print(word[0])
        else:
            break

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

Submission status: Accepted

Solution code:
n = int(input())
a=[]
for i in range(n):
  tmp = input()
  a.append(tmp)
  
dic = {i:0 for i in set(a)}

for i in range(n):
  dic[a[i]] = dic[a[i]]+1  

max_v = 0
for k in dic:
  if dic[k]>max_v:
    max_v = dic[k]

max_items = []
for k in dic:
  if dic[k]==max_v:
    max_items.append(k)

max_items.sort()
for item in max_items:
  print(item)

Submission status: Accepted

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

s_sorted = sorted(s.items(), key=lambda x: -x[1])

max_num = s_sorted[0][1]
results = []

for ss in s_sorted:
    if ss[1] == max_num:
        results.append(ss[0])

results.sort()

for r in results:
    print(r)

Submission status: Accepted

Solution code:
# /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key


yn = 'YNeos'
ynflg = False
cnt = 0
ans = None

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

def intinput():
    return int(input())

def mulinputs():
    return map(int,input().split())

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas



N = intinput()
datas = lineinputs(func=input)

d = dict()
for data in datas:
    if data in d.keys():
        d[data] += 1
    else:
        d[data] = 0

m = max(d.values())
dd = []
for k, v in d.items():
    if v != m:
        continue
    dd.append(k)

dd.sort()
# 出力
for _ in dd:
    print(_)

Submission status: Accepted

Solution code:
import sys
from bisect import bisect_left, bisect_right
input = sys.stdin.readline

N = int(input())
li = [input() for i in range(N)]
li.sort()

key = set(li)
c = [0]*len(key)
ind = 0
ans = [[] for _ in range(len(key))]
for i in key:
    p = bisect_left(li,i)
    q = bisect_right(li,i)
    ans[ind] = [q-p, i]
    ind += 1

ans.sort(reverse=True)
p = ans[0][0]
q = []
for i in range(len(ans)):
    if ans[i][0] == p:
        q.append(ans[i][1])
q.sort()
[print(i,end='') for i in q]

Submission status: Accepted

Solution code:
V = {}
N = int(input())

MaxVote = 0
while N > 0:
    N -= 1
    ### 
    st = str(input())
    V[st] = V.get(st, 0)
    V[st] += 1
    MaxVote = max(MaxVote, V[st])

ans = []
for key, value in V.items():
    if value == MaxVote:
        ans.append(key)
ans.sort()
print(*ans, sep = '\n')

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
dic = []
for _ in range(N):
    s = input()
    dic.append(s)
ans = Counter(dic)
st = ans.most_common(N)

anser = []
max_num = st[0][1]
for a,b in st:
    if max_num == b:
        anser.append(a)

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

Submission status: Accepted

Solution code:
import sys


# N, M = map(int, input().split())
# nums = list(map(int, input().split()))
# nums_2d = [list(map(int, input().split())) for _ in range(N)]


def main():
    solve()


def solve():
    N = int(input())

    s_dict = dict()
    for _ in range(N):
        s = input()
        if s in s_dict:
            s_dict[s] += 1
        else:
            s_dict[s] = 1

    max_v = 0
    new_list = list()
    for key, value in s_dict.items():
        if max_v < value:
            max_v = value
            new_list = list()
            new_list.append(key)
        elif max_v == value:
            new_list.append(key)

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
dic={}
max=0
list=[]

for i in range(n):
    s=input()
    dic.setdefault(s,0)
    dic[s]+=1
    if dic[s]>max:
        list=[s]
        max=dic[s]
    elif dic[s]==max:
        list.append(s)

list.sort()

for word in list:
    print(word)

Submission status: Accepted

Solution code:
def resolve():
    import collections
    n = int(input())
    c = list(collections.Counter([input() for _ in range(n)]).most_common())
    s = []
    m = c[0][1]
    for i in c:
        if i[1] !=m:
            break
        s.append(i[0])
    s.sort()
    print("\n".join(s))
resolve()

Submission status: Accepted

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

S.sort()
S.append("!")

c = []
tmp = ""
cnt = 0
mx = 0

for i in S:
    if i != tmp:
        c.append([cnt, tmp])
        tmp = i
        cnt = 1
    else:
        cnt += 1
    mx = max(mx, cnt)

c.sort()

for i, j in c:
    if i == mx:
        print(j)

Submission status: Accepted

Solution code:
import collections

def solution():
    n = int(input().strip())
    d = collections.defaultdict(int)
    for _ in range(n):
        d[input().strip()] += 1
    maxValue = max(d.values())
    res = [x[0] for x in d.items() if x[1] == maxValue]
    res.sort()
    for x in res:
        print(x)

def main():    
    # T = int(input().strip())
    for _ in range(1):
        solution()
    

main()

Submission status: Accepted

Solution code:
import collections
n = int(input())
s = []
for _ in range(n):
    s_ = input()
    s.append(s_)
s_c = collections.Counter(s)
maxl = max(s_c.values())
ns = [k for k, v in s_c.items() if v == maxl]
for i in sorted(ns):
    print(i)

Submission status: Accepted

Solution code:
N = int(input())
 
S = [None] * N
 
m = dict()
 
for i in range(N):
  s = input()
  if not s in m.keys():
    m[s] = 1
  else:
    m[s] += 1
 
max_cnt = max(m.values())
 
ret = []
 
for k, v in sorted(m.items(), key=lambda x: x[1], reverse=True):
  if v < max_cnt:
    break
  ret.append(k)
 
ret.sort()
for s in ret:
  print(s)

Submission status: Accepted

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

c = collections.Counter(s)
max_count = max(c.values())
ans = []
for k, v in c.items():
    if v == max_count:
        ans.append(k)
ans.sort()
for ans_one in ans:
    print(ans_one)

Submission status: Accepted

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

s_sorted = sorted(s)

current = ''
cnt = 0
max_cnt = 0
ans = []
for i in range(n):
    if s_sorted[i] != current:
        if cnt > max_cnt:
            ans = []
            ans.append(current)
            max_cnt = cnt
        elif cnt == max_cnt:
            ans.append(current)
        cnt = 1
        current = s_sorted[i]
    else:
        cnt += 1

if cnt > max_cnt:
    ans = []
    ans.append(current)
    max_cnt = cnt
elif cnt == max_cnt:
    ans.append(current)

for i in ans:
    print(i)

Submission status: Accepted

Solution code:
import collections

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

c=collections.Counter(s)
r=c.most_common()

mx=r[0][1]
re=[]
for x, y in r:
    if y == mx:
        re.append(x)
    else:
        break
ans=sorted(re)
for a in ans:
    print(a)

Submission status: Accepted

Solution code:
import collections
n=int(input())
s=[]
for i in range(n):
  s.append(input())
c = collections.Counter(s)
s=[]
count=0
for i in c.most_common():
  if len(s)==0:
    count=i[1]
    s.append(i[0])
    continue
  if count!=i[1]:
    break
  else:
    s.append(i[0])

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

Submission status: Accepted

Solution code:
import collections

N = int(input())

words=[]

for i in range(N):
    words.append(input())

c = collections.Counter(words)

l=c.most_common()

max_num = l[0][1]

max_words =[]
    
for i in l:
    if i[1] == max_num:
        max_words.append(i[0])
    else:
        break
        
max_words.sort()

for word in max_words:
    print(word)

Submission status: Accepted

Solution code:
N=int(input())
A=[input() for i in range(N)]
from collections import Counter
A=Counter(A)
ret = []
a=((A.most_common(1))[0])[1]
for i in A.most_common():
  if i[1]==a:
    ret.append(i[0])
  else:
    break
ret.sort()
for i in ret:
  print(i)

Submission status: Accepted

Solution code:
d={}
for _ in range(int(input())):
    i=input()
    d[i]=d.get(i,0)+1
m=max(list(d.values()))    
l=[i for i in d.keys() if d[i]==m]
l.sort()
for i in l:
    print(i)

Submission status: Accepted

Solution code:
import collections


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

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

    SN_counter = collections.Counter(SN)
    most_count = SN_counter.most_common()[0][1]

    for S in sorted([S for S in SN_counter if SN_counter[S] == most_count]):
        print(S)


main()

Submission status: Accepted

Solution code:
n=int(input())
l=[str(input()) for i in range(n)]
l.sort()
r=[-1]
#print(l)
for i in range(n-1):
	if l[i]!=l[i+1]:
		r.append(i)
r.append(n-1)
#print(r)
s=[]
for i in range(len(r)-1):
	s.append(r[i+1]-r[i])
#print(s)
X=max(s)
A=[]
for i in range(len(s)):
	if s[i]==X:
		A.append(l[r[i]+1])
for i in A:
	print(i)

Submission status: Accepted

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

from collections import Counter

cnt_s = sorted(sorted(Counter(S).items(), key=lambda t: t[0])[::-1], key=lambda t:t[1])[::-1]
max_s = max(Counter(S).values())
for k,v in cnt_s:
    if v==max_s:
        print(k)
    else:
        break

Submission status: Accepted

Solution code:
import collections
n=int(input())
l=[]
for _ in range(n):
  s=str(input())
  l.append(s)
g=collections.Counter(l)
h=sorted(g.items(),key=lambda x:x[1])
i=max(g.values())
j=[x for x,y in g.items() if y==i]
j=sorted(j)
for x in j:
  print(x)

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())
words = [input() for _ in range(n)]
counter = Counter(words)
counter_most_common = counter.most_common()
m = counter_most_common[0][1]
s = []
for k, v in dict(counter_most_common).items():
    if v == m:
        s.append(k)

s.sort()

for si in s:
    print(si)

Submission status: Accepted

Solution code:
n = int(input())
s = [str(input()) for _ in range(n)]
s.append('zzzzzzzzzzz')
s.sort()

l_cnt = []
c_max = 1
cnt = 1
bfo = 'xxxxxxxxxxx'

for i in s:
    if i == bfo:
        cnt += 1
        c_max = max(c_max, cnt)
    else:
        l_cnt.append([bfo, cnt])
        bfo = i
        cnt = 1

for j in range(len(l_cnt)):
    if j == 0:
        continue
    else:
        if c_max == l_cnt[j][1]:
            print(l_cnt[j][0])

Submission status: Accepted

Solution code:
N = int(input())
#N,K = map(int, input().split())
dct = {}
mx = 0
for z in range(N):
    x = input()
    try:
        dct[x] += 1
    except:
        dct[x] = 1
    mx = max(mx, dct[x])
keys = list(dct.keys())
ans = []
for key in keys :
    if dct[key] == mx:
        ans.append(key)
ans.sort()
for elem in ans:
    print(elem)

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
S = [input() for i in range(N)]
c = Counter(S)
ans =[]
maxnum = c.most_common()[0][1]
for k, v in c.items():
    if v == maxnum:
        ans.append(k)
ans.sort()
for i in range(len(ans)):
    print(ans[i])

Submission status: Accepted

Solution code:
n = int(input())
X = []
for _ in range(n):
    X += [str(input())]

from collections import Counter

cnt = Counter(X)

s = cnt.most_common()

ans = [s[0][0]]
_cnt0 = s[0][1]

for (word, _cnt) in s[1:]:
    if _cnt0 != _cnt:
        break
    ans += [word]
    _cnt0 = _cnt


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

Submission status: Accepted

Solution code:
n = int(input())
items = [input() for _ in range(n)]

counts = {}
for item in items:
  if item in counts.keys():
    counts[item] += 1
  else:
    counts[item] = 1

max_counts = max([item[1] for item in counts.items()])

rets = [item[0] for item in counts.items() if item[1] == max_counts]
rets = sorted(rets)
print('\n'.join(rets))

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())

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

v = max(kw.values())
ans = []

for key, value in kw.most_common():
    if value == v:
        ans.append(key)

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

Submission status: Accepted

Solution code:
import collections
n = int(input())
s = [input() for _ in range(n)]
c = collections.Counter(s)

cc = c.most_common()

m = cc[0][1]

l = []

for i,j in cc:
    if j == m:
        l.append(i)

ll = sorted(l)
for i in ll:
    print(i)

Submission status: Accepted

Solution code:
import numpy as np

dic = {}

n = int(input())

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

maxv = np.max(np.asarray(list((dic.values()))))

answers = [k for k, v in dic.items() if v == maxv]

sorted_answer = sorted(answers)

for i in sorted_answer:
    print(i)

Submission status: Accepted

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

M = d[0][1]

A = []
for k, v in d:
    if v == M:
        A.append(k)
    else:
        break

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

Submission status: Accepted

Solution code:
n = int(input())
s = []
for i in range(n):
    s.append(input())
s.sort()
a = []
an = 0
t = ''
tn = 0
s.append('')
for si in s:
    if si != t:
        if tn > an:
            a = [t]
            an = tn
        elif tn == an:
            a.append(t)
        t = si
        tn = 0
    tn += 1
print('\n'.join(a))

Submission status: Accepted

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

dict = {}

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

dict_list = list(dict.items())
dict_list.sort(key=lambda x: x[1], reverse=True)
max = dict_list[0][1]
dict_list.sort(key=lambda x: x[0])

for id in dict_list:
	if max == id[1]:
		print(id[0])

Submission status: Accepted

Solution code:
def solve():
    from sys import stdin
    f_i = stdin
    
    N = int(f_i.readline())
    
    count = dict()
    S = []
    for i in range(N):
        s = f_i.readline().rstrip()
        if s in count:
            count[s] += 1
        else:
            count[s] = 1
        S.append(s)
    
    S = set(S)
    count_max = max(count.values())
    answers = filter(lambda x: count[x] == count_max, S)
    
    print('\n'.join(sorted(answers)))

solve()

Submission status: Accepted

Solution code:
import collections

def main():
    n = int(input())
    s_list = [input() for _ in range(n)]
    c = collections.Counter(s_list)
    mc = c.most_common()

    ans_list = []
    max_v = mc[0][1]
    for k, v in mc:
        if v == max_v:
            ans_list.append(k)
    ans_list.sort()
    ans = '\n'.join(ans_list)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())

dics = {}

for i in range(N):
    si = input()
    if si in dics.keys():
        dics[si] += 1
    else:
        dics[si] = 1

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

# print(dic2)

endlist = []

kmax = dic2[0][1]
for kt in dic2:
    v = kt[1]
    if v == kmax:
        endlist.append(kt[0])
    else:
        break

slist = sorted(endlist, key=str.lower)
for s in slist:
    print(s)

Submission status: Accepted

Solution code:
N=int(input())
d = dict()
for i in range(N):
    wd = input()
    if wd in d:
        d[wd] +=1
    else:
        d[wd] = 1
r=sorted(d.items(),key=lambda x:-x[1])
res = []
for it in r:
    if it[1]==r[0][1]:
        res .append(it[0])
res = sorted(res)
for it in res:
    print(it)

Submission status: Accepted

Solution code:
from collections import defaultdict
n = int(input())
d = defaultdict(int)

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

d2 = sorted(d.items(), key=lambda x:x[1], reverse=True)
b = [k for k, v in dict(d2).items() if v == d2[0][1]]

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

Submission status: Accepted

Solution code:
import collections

def main():
    n = int(input())
    l = [input() for i in range(n)]
    c = collections.Counter(l)
    max_values = max(c.values())
    max_words = [k for k, v in c.items() if v == max_values]
    max_words.sort()
    ans = "\n".join(max_words)
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N = INT()
    S = [INPUT() for _ in range(N)]

    c = Counter(S)
    m = 0
    ans = []
    for key, value in c.most_common():
        if value >= m:
            m = value
            ans.append(key)
        else:
            continue

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
num = dict()
for i in range(n):
    s = input()
    if s in num:
        num[s] += 1
    else:
        num[s] = 1
num_s = sorted(num.items(), key=lambda x:x[1],reverse=True)
max_num = max(num.values())
ans = []
for i in range(len(num_s)):
    if num_s[i][1] == max_num:
        ans.append(num_s[i][0])
ans.sort()
for i in range(len(ans)):
    print(ans[i])

Submission status: Accepted

Solution code:
import collections
n = int(input())
lis = []
for _ in range(n):
    lis.append(input())
c = collections.Counter(lis)
most = c.most_common()
most_counter = c.most_common()[0][1]
#print(most)
#print(most_counter)
tmp_lis = []
for m in most:
    if m[1] == most_counter:
        tmp_lis.append(m[0])
    else:
        break
for t in sorted(tmp_lis):
    print(t)

Submission status: Accepted

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

cnt=Counter(S)
cnt=cnt.most_common()
maxcnt=cnt[0][1]
ans=[]
for i in range(len(cnt)):
  if cnt[i][1]==maxcnt:
    ans.append(cnt[i][0])
  else:
    break
ans.sort()
print(*ans,sep='\n')

Submission status: Accepted

Solution code:
N = int(input())

S = {}

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

S = reversed(sorted(S.items(), key=lambda x:x[1]))

result = []
num = 0
for s in S:
    if s[1] < num:
        break
    result.append(s[0])
    num = s[1]

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

Submission status: Accepted

Solution code:
import collections
N = int(input())
S_list = [input() for i in range(N)]
C = collections.Counter(S_list)
L = C.most_common()
max_ = L[0][1]
ans = []
#print("========")
for i in L:
    if i[1] == max_:
        ans.append(i[0])
    else:
        break
ans.sort()
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
from collections import Counter


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

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

outs = [k for k, v in d.items() if v == M]
outs.sort()

for word in outs:
    print(word)

Submission status: Accepted

Solution code:
N = int(input())
S = []
ct = {}
for i in range(N):
    name = input()
    S.append(name)
    if name in ct:
        ct[name] += 1
    else:
        ct[name] = 1

m = 0

for name in S:
    if ct[name] > m:
        m = ct[name]

ls = []

for name in ct:
    if ct[name] == m:
        ls.append(name)

for name in sorted(ls):
    print(name)

Submission status: Accepted

Solution code:
n = int(input())
dic = {}
for i in range(n):
    s = input()
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1
dict_sorted = sorted(dic.items(), key=lambda x:x[1])
max_num = dict_sorted[-1][1]
ans = []
for a in dict_sorted:
    if a[1] == max_num:
        ans.append(a[0])
ans.sort()
for a in ans:
    print(a)

Submission status: Accepted

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

for _ in range(n):
  s=input()
  if s not in d:
    d[s]=1
  else:
    d[s]+=1
    
ans=[]
num=max(d.values())

for i in d.keys():
  #print(i,d[i])
  if d[i]==num:
    ans+=[i]
    
ans.sort()

for i in ans:
  print(i)

Submission status: Accepted

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

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

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

alist = []
for val in memo:
    a, b = val
    if b == mn: alist.append(a)
    else: break

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

Submission status: Accepted

Solution code:
from collections import Counter

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

x = sorted(Counter(s_list).items(),key=lambda x:x[1],reverse=True)
max_num = x[0][1]

result = sorted([i[0] for i in x if i[1] == max_num])

for i in result:
    print(i)

Submission status: Accepted

Solution code:
import sys
from collections import Counter

N = int(sys.stdin.readline())
A = sys.stdin.read().split()
c = Counter(A).most_common()

m = c[0][1]
l = []
l_append = l.append
for i in c:
    if i[1] == m:
        l_append(i[0])
l.sort()
print(*l, sep='\n')

Submission status: Accepted

Solution code:
from collections import defaultdict

N = int(input())
d = defaultdict(int)

max_num = 0
for _ in range(N):
    s = input()
    d[s] += 1
    max_num = max(max_num, d[s])
#print(d)

ans = []
for s in d.keys():
    if d[s] == max_num:
        ans.append(s)
ans.sort()

for s in ans:
    print(s)

Submission status: Accepted

Solution code:
from functools import reduce
from fractions import gcd
from collections import defaultdict
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    N = int(input())
    d = defaultdict(int)
    for _ in range(N):
        s = input()[:-1]
        d[s] += 1
    d = sorted(d.items(), key=lambda x:x[1], reverse=True)
    k = d[0][1]
    d.sort()
    for t in d:
        if t[1] == k:
            print(t[0])
    
    


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
s=[input() for i in range(n)]
d=[]
x=0
count=1
s.sort()
for i in range(n-1):
  if s[i]==s[i+1]:
    count+=1
  else:
    d.append([count,s[i]])
    count=1
d.append([count,s[-1]])
d.sort()
x=d[-1][0]
for i in range(len(d)):
  if x==d[i][0]:
    print(d[i][1])

Submission status: Accepted

Solution code:
N = int(input())
C = {}
for i in range(N):
    buf = input()
    if buf in C:
        C[buf] += 1
    else:
        C[buf] = 1
max_n = max(C.values())
max_values = [i[0] for i in C.items() if i[1] == max_n]
for line in sorted(max_values):
    print(line)

Submission status: Accepted

Solution code:
N=int(input())

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

v=list(D.values())
mx=max(v)

lis=[]
for key,val in D.items():
    if val==mx:
        lis.append(key)

lis.sort()

for i in lis:
    print(i)

Submission status: Accepted

Solution code:
N = int(input())
l = {}
m = 0
for _ in range(N):
  s = input()
  if not s in l:
    l[s] = 1
  l[s] += 1
  m = max(m, l[s])
ml = []
for k, v in l.items():
  if v == m:
    ml.append(k)
ml.sort()
for i in range(len(ml)):
  print(ml[i])