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:
def main():
    import sys
    import collections
    input = sys.stdin.readline
    N = int(input())
    S = [input() for i in range(N)]
    c = collections.Counter(S)
    max_num = c.most_common(1)[0][1]
    c_most = list(c.most_common())
    ss = [cc[0] for cc in c_most if cc[1] == max_num]
    ss.sort()
    print("".join(ss))

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():
    import sys
    import collections
    input = sys.stdin.readline
    N = int(input())
    S = []
    for i in range(N):
        S.append(input())
    c = collections.Counter(S)
    max_num = c.most_common(1)[0][1]
    ss = []
    for cc in c.most_common():
        if cc[1] == max_num:
            ss.append(cc[0])
    ss.sort()
    print("".join(ss))

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())
dic = {}
maxi = 0
for _ in range(n):
  k = input()
  dic[k] = 1 if k not in dic else dic[k] + 1
  if dic[k] > maxi: maxi = dic[k]
result = []
for i,j in dic.items():
  if j == maxi:
    result.append(i)
result.sort()
for r in result:
  print(r)

Submission status: Accepted

Solution code:
N = int(input())

Sdict = dict()
max = 0
for _ in range(N):
    s = input()
    if s in Sdict:
        Sdict[s] += 1
    else:
        Sdict[s] = 0
    
maxi = 0
lis = []
for k,v in Sdict.items():
    if v > maxi:
        lis = [k]
        maxi = v
    elif v == maxi:
        lis.append(k)
lis.sort()
for k in lis:
    print(k)

Submission status: Accepted

Solution code:
def main():
    import sys
    import collections
    input = sys.stdin.readline
    N = int(input())
    S = [input() for i in range(N)]
    c = collections.Counter(S)
    max_num = c.most_common(1)[0][1]
    ss = []
    for cc in c.most_common():
        if cc[1] == max_num:
            ss.append(cc[0])
    ss.sort()
    print("".join(ss))

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import itertools
from collections import Counter

N=int(input())
a=[input() for i in range(N)]

a = sorted(a)
#print(a)


counter = Counter(a)

mode_v = counter.most_common()[0][-1]
cmc= counter.most_common()
#print(cmc)
it = itertools.takewhile(
    lambda kv: kv[-1] == mode_v, cmc
)

#sorted(it)
f=list(it)
#print(f)
f = sorted(f)
#print(f)
for k in range(len(f)):
	print(f[k][0])

Submission status: Accepted

Solution code:
import collections
N=int(input())
S=[""]*N
ans=[]
for k in range(N):
    S[k]=input()
count = collections.Counter(S)
maximum = max(count.values())
for i,j in count.items():
    if j == maximum:
        ans.append(i)
ans.sort()
for j in range(len(ans)):
    print(ans[j])

Submission status: Accepted

Solution code:
N = int(input())

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

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

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

Submission status: Accepted

Solution code:
from collections import Counter

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

c = Counter(s)
c = c.most_common()
ans_number = c[0][1]
c.sort()

for i in range(len(c)):
  if c[i][1] == ans_number:
    print(c[i][0])

Submission status: Accepted

Solution code:
n=int(input())
a=[]
b=[]
c=[]
for i in range(n):
    b=str(input())
    a.append(b)
freq = {}
for item in a:
        if (item in freq):
            freq[item] += 1
        else:
            freq[item] = 1

t=0
b=[]
for items in freq.values():
    if items>t:
        t=items

for key,val in freq.items():
    if val==t:
        b.append(key)
b.sort()
for i in range(len(b)):
    print(b[i])

Submission status: Accepted

Solution code:
from collections import Counter, deque, defaultdict
from functools import lru_cache

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

x = c.most_common()
pv = x[0][1]
arr=[]
for k,v in x:
	if v < pv:
		break
	arr.append(k)
arr.sort()
for k in arr:
	print(k)

Submission status: Accepted

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

for i in range(n): # 辞書型でカウント
  s = input()
  a.setdefault(s, 0)
  a[s] += 1
  
ans = []
mx = 0
for key, value in a.items(): # 最大値のものをリストに入れる
  if mx < value:
    mx = value
    ans = [key]
  elif mx == value:
    ans.append(key)

ans.sort() # 辞書順に出力
for i in ans:
  print(i)

Submission status: Accepted

Solution code:
N=int(input())
S = [input() for i in range(N)]
S.sort()
import itertools
gr = itertools.groupby(S)
ans=[]
n=0
for key, group in gr:
  a=len(list(group))
  if a>n:
    ans=[]
    n=a
    ans.append(key)
  elif a==n:
    ans.append(key)
for a in ans:
  print(a)

Submission status: Accepted

Solution code:
N = int(input())
S = [input() for i in range(N)]
from collections import Counter
ctr = Counter(S)
n = ctr.most_common()[0][1]

cands = []
for j in ctr.keys():
    if ctr[j] == n:
        cands.append(j)
cands.sort()
print(*cands, sep='\n')

Submission status: Accepted

Solution code:
from collections import Counter

N = int(input())
counter = Counter()
for i in range(0, N):
    counter[str(input())] += 1
A = max(counter.values())
S = []
for a, b in counter.items():
    if A == b:
        S.append(a)
S.sort()
for s in S:
    print(s)

Submission status: Accepted

Solution code:
from collections import Counter
N=int(input())
C=sorted(Counter([input() for i in range(N)]).items(),key=lambda x:-x[1])
tmp=C[0][1]
ans = []
for i,j in C:
    if j==tmp:
        ans.append(i)
    else:
        break
for i in sorted(ans):
    print(i)

Submission status: Accepted

Solution code:
import sys
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    s = collections.Counter([str(readline().rstrip().decode('utf-8')) for _ in range(n)]).most_common()
    s.sort(key=lambda x: x[0])
    s.sort(key=lambda x: x[1], reverse=True)
    for k, v in s:
        if v == s[0][1]:
            print(k)
        else:
            break


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

C=Counter(S)
A=[]
B=[]
T=[]

for i,j in C.most_common():
    A.append(i)
    B.append(j)
for k in range(len(A)):
    if B[k]==B[0]:
        T.append(A[k])
T=sorted(T)
for m in range(len(T)):
  print(T[m])

Submission status: Accepted

Solution code:
from collections import*
n,*s=open(0)
c=Counter(s).most_common()
print(*sorted(a*(b==c[0][1])for a,b in c))

Submission status: Accepted

Solution code:
from collections import Counter

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

C = Counter(S)
max_cnt = max(C.values())

names = [names for names, values in C.items() if values == max_cnt]
names.sort()

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

Submission status: Accepted

Solution code:
import collections

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

#c = collections.Counter(List)

c = {}

for i in range(n):
    if List[i] in c.keys():
        c[List[i]] += 1
    else:
        c[List[i]] = 1


m = 0
for v in c.values():
    m = max(m, v)

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

Submission status: Accepted

Solution code:
def contest(N, str):
    count = {}

    for s in str:
        if s not in count:
            count[s] = 1

        else:
            count[s] +=  1
    
    ret = sorted(count.items(),key=lambda count: count[1], reverse=True)
    maxnum = ret[0][1]
    
    retVal = []

    for r in ret:
        if r[1] == maxnum:
            retVal.append(r[0])
            
        else:
            break

    result = '\n'.join(sorted(retVal))

    return result


if __name__ == "__main__":
    N = int(input())
    S = []

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

    print(contest(N, S))

Submission status: Accepted

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

from collections import defaultdict
d = defaultdict(lambda:0)

for k in S:
    d[str(k)]+=1
    
ansn=max(d.values())
ans=[]
for i in set(S):
    if d[i]==ansn:
        ans.append(i)

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

Submission status: Accepted

Solution code:
import collections
n = int(input())
s = [input() for i in range(n)]
c = collections.Counter(s).most_common()
ans = [k for k, v in c if c[0][1] == v]
ans.sort()
for i in ans:
    print(i)

Submission status: Accepted

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

from collections import defaultdict
d = defaultdict(lambda:0)

for k in S:
    d[str(k)]+=1

ansn=0
ans=[]
for i in set(S):
    if d[i]>ansn:
        ansn=d[i]
        ans=[]
    if d[i]==ansn:
        ans.append(i)

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

Submission status: Accepted

Solution code:
n = int(input())
a = dict()
for _ in range(n):
    s = input()
    if s in a:
        a[s] += 1
    else:
        a[s] = 1

M = max(a.values())
ans = []
for s in a:
    if a[s] == M:
        ans.append(s)
ans.sort()
for s in ans:
    print(s)

Submission status: Accepted

Solution code:
from collections import defaultdict

def I(): return int(input())
def MI(): return map(int, input().split())
def LMI(): return list(map(int, input().split()))


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

m = max(d.values())
ans = list()
for s, cnt in d.items():
    if cnt == m:
        ans.append(s)
ans.sort()
for x in ans:
    print(x)

Submission status: Accepted

Solution code:
def main():
    import sys
    import collections
    input = sys.stdin.readline
    N = int(input())
    S = [input() for i in range(N)]
    c = collections.Counter(S)
    max_num = c.most_common(1)[0][1]
    c_most = list(c.most_common())
    ss = [cc[0] for cc in c_most if cc[1] == max_num]
    ss.sort()
    print("".join(ss))


main()

Submission status: Accepted

Solution code:
from collections import Counter
int = int(input())
word = [input() for i in range(int)]
s = Counter(word).most_common()
u = s[0][1]
v = []
for i, j in s:
  if j == u:
    v.append(i)
v.sort()
print(*v)

Submission status: Accepted

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

q = int(input())
a = [input().rstrip() for _ in range(q)]

dic = collections.Counter(a)

ma = max(dic.values())
keys = [k for k, v in dic.items() if v == ma]
keys_s = sorted(keys)
for i in keys_s:
    print(i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
Sc = Counter([input() for _ in range(N)]).most_common()
# print(Sc)
max_num = Sc[0][1]
ans = []
for key, val in Sc:
    if val == max_num:
        ans.append(key)
ans.sort()
for t in ans:
    print(t)

Submission status: Accepted

Solution code:
N=int(input(), 10)
cnt = dict()
for _ in range(N):
    s = input()
    if s in cnt:
        cnt[s] += 1
    else:
        cnt[s] = 0

max_cnt = max(cnt.values())
for word in sorted([key for key, value in cnt.items() if value == max_cnt]):
    print(word)

Submission status: Accepted

Solution code:
def main():
    import sys
    import collections
    input = sys.stdin.readline
    N = int(input())
    S = [input().rstrip() for i in range(N)]
    c = collections.Counter(S)
    max_num = c.most_common(1)[0][1]
    c_most = c.most_common()
    ss = [cc[0] for cc in c_most if cc[1] == max_num]
    ss.sort()
    print("\n".join(ss))

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
D = {}
for _ in range(N):
    s = input()
    D[s] = D.get(s, 0) + 1

L = [(D[d], d) for d in D] + [(0, "*")]
L.sort(key=lambda x: x[1])
L.sort(key=lambda x: x[0], reverse=True)

i = 0
while L[0][0] == L[i][0]:
    print(L[i][1])
    i += 1

Submission status: Accepted

Solution code:
##C
N = int(input())
S = list(input() for i in range(N))

import collections

c = collections.Counter(S)
max = max(c.values())
 
max_k_list = [kv[0] for kv in c.items() if kv[1] == max]
max_k_list.sort()
for l in max_k_list:
    print(l)

Submission status: Accepted

Solution code:
def main():
    import sys
    import collections
    input = sys.stdin.readline
    N = int(input())
    S = [input() for i in range(N)]
    c = collections.Counter(S)
    max_num = c.most_common(1)[0][1]
    ss = [cc[0] for cc in c.most_common() if cc[1] == max_num]
    ss.sort()
    print("\n".join(ss))

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import collections

n = int(input())
ls = [input() for i in range(n)]    
c = collections.Counter(ls)

count = c.most_common()[0][1]
ans = []
p = c.most_common()
for i in range(len(c)):
    if p[i][1] == count:
        ans.append(p[i][0])
    else:
        break   
ans = sorted(ans)
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
n = int(input())

s_list = [""]*n

for i in range(n):
    s_list[i] = input()

s_list.sort()

ans_list = [s_list[0]]
pre_s = s_list[0]
count = 1
max_count = count

if len(s_list) == len(set(s_list)):
    ans_list = s_list
        
    ans_list.sort()

    for s in ans_list:
        print(s)

    exit()


for i in range(1,n):
    if pre_s == s_list[i]:
        count += 1
        if count == max_count:
            ans_list.append(s_list[i])
        if count > max_count:
            max_count = count
            ans_list = [s_list[i]]
    else:
        pre_s = s_list[i]
        count = 1

ans_list.sort()

for s in ans_list:
    print(s)

Submission status: Accepted

Solution code:
import collections
N=int(input())
s=[input() for i in range(N)]
#S=sorted(s)
a=1
num=[]
st=[]
c = collections.Counter(s)#要素数が大きい順に辞書型ですべての要素を返す
#print(c)
max_c = max(c.values())#最も多い要素の数
#print(max_c)
st=[]
for k,v in c.items():
    if v==max_c:
        st.append(k)
st2=sorted(st)
[print(i) for i in st2]

Submission status: Accepted

Solution code:
import numpy as np

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

a = np.sort(np.array(a))

unique_elements, index_elements = np.unique(a, return_index = True)
l = []
for i in range(index_elements.size -1):
  m = index_elements[i + 1] - index_elements[i]
  l.append(m)
l.append(a.size - index_elements[-1])    
elements = unique_elements[l == max(l)]


for i in elements:
	print(i)

Submission status: Accepted

Solution code:
import collections
from collections import Counter

n = int(input())
ls = [input() for i in range(n)]    
c = Counter(ls).most_common()

count = c[0][1]
ans = []

for i in range(len(c)):
    if c[i][1] == count:
        ans.append(c[i][0])
    else:
        break   
ans = sorted(ans)
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
from collections import defaultdict

count = defaultdict(int)
n = int(input())
tmp_max=0
for i in range(n):
    s=input()
    tmp_cnt = count[s]
    tmp_max = max(tmp_max,tmp_cnt+1)
    count[s]+=1

ans=[]
for k,v in count.items():
    if v==tmp_max:
        ans.append(k)
ans=sorted(ans)
for s in ans:
    print(s)

Submission status: Accepted

Solution code:
import sys
import collections as col
input=sys.stdin.readline

def main():
	#N,K=map(int,input().split())
	#N=input().rstrip()
	N=int(input())
	#vA=list(map(int,input().split()))
	vS=[input().rstrip() for _ in [0,]*N]
	cS=col.Counter(vS)
	
	mcS=cS.most_common()
	mc = mcS[0][1]
	res = sorted([s for s,c in mcS if c==mc])
	
	print(*res, sep="\n")


main()

Submission status: Accepted

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

d = Counter(s).most_common()

s = d[0][1]
ans = []
for k, v in d:
    if s == v:
        ans.append(k)
    else:
        break
print(*sorted(ans), sep="\n")

Submission status: Accepted

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

M = max(S.values())

L = list(S)
L.sort()
for i in L:
    if S[i] == M:
        print(i)

Submission status: Accepted

Solution code:
import collections
import itertools

a = int(input())

s = [input() for i in range(a)]

counter = collections.Counter(s)

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

l = []

for k, v in it:
  l.append(k)

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

Submission status: Accepted

Solution code:
from collections import Counter
import heapq

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

word_count=Counter(word)
ma=max(word_count.values())

ans=[k for k, v in word_count.items() if v == ma]
cnt=len(ans)
heapq.heapify(ans)
for i in range(cnt):
    print(heapq.heappop(ans))

Submission status: Accepted

Solution code:
import collections

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

li = collections.Counter(s)
ma= max(li.values())

ans= [i for i,j in li.items() if(j==ma)]
print("\n".join(sorted(ans)))

Submission status: Accepted

Solution code:
from collections import Counter

n=int(input())
string_list=[input() for i in range(n)]
 
counter = Counter(string_list)

m = max(counter.values())

out_li = []

for k,v in counter.items():
  if v == m:
    out_li.append(k)

out_li.sort()
    
print('\n'.join(out_li))

Submission status: Accepted

Solution code:
import collections

n = int(input())
l = []
for i in range(n):
    l.append(str(input()))
c = collections.Counter(l)
c = c.most_common()
max_l = c[0][1]
ans = []
for i in c:
    if i[1] == max_l:
        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 = [input() for _ in range(n)]
s_cnt = Counter(s)
s_cnt_common = s_cnt.most_common()
max_cnt = s_cnt_common[0][1]
ans = []
for i in range(len(s_cnt_common)):
    if s_cnt_common[i][1] == max_cnt:
        ans.append(s_cnt_common[i][0])
ans.sort()
print(*ans)

Submission status: Accepted

Solution code:
import collections

N = int(input())
data = [input() for i in range(N)]

dicdata = collections.Counter(data)

m = max(dicdata.values())

newdata = [k for k, v in dicdata.items() if v == m]

newdata.sort()

[print(i) for i in newdata]

Submission status: Accepted

Solution code:
import collections
N = int(input())
s = [input() for i in range(N)]
 
counter = collections.Counter(s)
count = counter.most_common()
 
most = count[0][1]
 
c =[]
for i in range(len(counter)):
    if count[i][1] == most:
        c.append(count[i][0])
 
c.sort()
 
for i in range(len(c)):
    print(c[i])

Submission status: Accepted

Solution code:
#from math import sqrt
#from heapq import heappush, heappop
#from collections import deque

n = int(input())

l = []
for _ in range(n):
    s = input()
    l.append(s)

l.sort()

max_count = 0
count = 0
results = []
ps = None
for s in l:
    if s == ps or ps is None:
        count += 1
    else:
        if max_count < count:
            max_count = count
            results = [ps]
        elif count == max_count:
            results.append(ps)
        count = 1
    ps = s

if max_count < count:
    max_count = count
    results = [ps]
elif count == max_count:
    results.append(ps)

results.sort()
for str in results:
    print(str)

Submission status: Accepted

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

a = 0
for i in range(n):
    s = str(input())
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1
    if dic[s] > a:
        a = dic[s]
box= []
for i in dic:
    if dic[i] == a:
        box.append(i)

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

Submission status: Accepted

Solution code:
import collections

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

c = collections.Counter(List)


leng = len(c)

ac = c.most_common()
res.append(ac[0][0])
for i in range(1, leng):
    if ac[i][1] >= ac[i-1][1]:
        res.append(ac[i][0])
    else:
        break

#res = sorted(res)
res.sort()
for j in range(len(res)):
    print(res[j])

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect


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


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


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


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


# Solve
if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:

n = int(input())
s= []
for _ in range(n):
    x = input()
    s.append(x)
s.sort()
mydict = {}
for i in range(n):
    x = s[i]
    if x in mydict:
        mydict[x]+=1
    else :
        mydict[x] = 1

max_n = -1
for v in mydict.values():
    max_n = max(max_n,v)
aa = []
for k in mydict:
    if mydict[k] == max_n:
        aa.append(k)
aa = sorted(aa)
for i in aa:
    print(i)

Submission status: Accepted

Solution code:
N = int(input())
S_lis = []
for _ in range(N):
    S_lis.append(input())


S_set = set(S_lis)
S_dict = dict()
# dict initialize
for s in S_set:
    S_dict[s] = 0
# valが全文字通過していくときに辞書のカウントを+1
for val in S_lis:
    S_dict[val] += 1
max_num = max(S_dict.values())
ans = list()
for k, v in S_dict.items():
    if v == max_num:
        ans.append(k)
ans = sorted(ans)
for res in ans:
    print(res)

Submission status: Accepted

Solution code:
from collections import *
n=int(input())
a=[]
for _ in range(n):
  a.append(input())
aset=set(a)
cnt=Counter(a)
cnt=dict(cnt)
maxi=0
for k in cnt.keys():
  maxi=max(maxi,cnt[k])

anss=[]
for s in aset:
  if cnt[s]==maxi:
    anss.append(s)
anss.sort()
for i in range(len(anss)):
  print(anss[i])

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
S = []
for i in range(N):
    S.append(input())
A = []
d = Counter(S)
md = d.most_common(1)[0][1]

for key, value in d.items():
    if value == md:
        A.append(key)

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

Submission status: Accepted

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

import collections

c = collections.Counter(S)
max = max(c.values())
 
max_k_list = [kv[0] for kv in c.items() if kv[1] == max]
max_k_list.sort()
for l in max_k_list:
    print(l)

Submission status: Accepted

Solution code:
import collections
N = int(input())
s = [input() for i in range(N)]
 
counter = collections.Counter(s)
count = counter.most_common()
 
most = count[0][1]
 
c =[]
for i in range(len(count)):
    if count[i][1] == most:
        c.append(count[i][0])
 
c.sort()
 
for i in range(len(c)):
    print(c[i])

Submission status: Accepted

Solution code:
n = int(input())
d = {}
for i in range(n):
  s = input()
  if s not in d:d[s] = 1
  d[s] += 1
max_cnt = sorted(d.items(), key=lambda x:x[1])[-1][1]
s = [x for x, y in d.items() if y == max_cnt]
s.sort()
for name in s:
    print(name)

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
S = [''] * N
for i in range(N) :
    S[i] = input()
S = Counter(S).most_common()
c = S[0][1]

print(*sorted([a for a,s in S if s==c]),sep="\n")

Submission status: Accepted

Solution code:
from collections import  Counter
n = int(input())
a  = [input() for i in range(n)]
cnt = Counter(a)
l = max(cnt.values())
ans = [s for s,c in cnt.items()if c ==l]
ans.sort()
print('\n'.join(ans))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
#a = int(input())
# スペース区切りの整数の入力
#b, c = map(int, input().split())
# 文字列の入力
#s = input()
# 出力
#print("{} {}".format(a+b+c, s))

from collections import Counter

n = int(input())
s=[input() for i in range(n)]
l=Counter(s)
m=0
for i in l.values():
  m=max(m,i)
ans=[]
for k,v in l.items():
  if v==m:
    ans.append(k)
ans.sort()
print(*ans,sep='\n')

Submission status: Accepted

Solution code:
# coding: utf-8


def main():
    n = int(input())
    polls_dict = {}
    for _ in range(n):
        poll = input()
        if poll not in polls_dict:
            polls_dict[poll] = 1
        else:
            polls_dict[poll] += 1

    max_poll = max(polls_dict.values())
    
    polls_set = set()
    for key, value in polls_dict.items():
        if value == max_poll:
            polls_set.add(key)

    polls_set = sorted(polls_set)
    for poll in polls_set:
        print(poll)
    
    return 0


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import Counter


N = int(input()) #1行目のNを取得する
s = [input() for i in range(N)] #複数行の数値の入力を取得
ans=[]

counted = Counter(s)#
counted_sort=counted.most_common()

for i in range(len(counted_sort)):
    if counted_sort[i][1]==counted_sort[0][1]:
        ans.append(counted_sort[i][0])


[print(i) for i in sorted(ans)]

Submission status: Accepted

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

c = collections.Counter(s)

m = max(c.values())
for k,v in c.items():
    if v ==m:
        ans.append(k)
ans.sort()
print(*ans,sep="\n")

Submission status: Accepted

Solution code:
import collections

n = int(input())
l = [input() for _ in [0] * n]

counted = collections.Counter(l)
#print(counted)

# 最頻値を求める
m = max(counted.values())
#print(m)

# 頻出数の文字を集める
chars = [key for key, value in counted.items()
             if value == m]

#chars = []
#for key, value in counted.items():
#    if value == m:
#        chars.append(key)

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

Submission status: Accepted

Solution code:
dic={}
n=int(input())
d=[]
for i in range(n):
  d.append(input())
  if d[-1] in dic:
  	dic[d[-1]]+=1
  else:
    dic[d[-1]]=1
mx=max(dic.values())
for k,v in sorted(dic.items(),key=lambda x:(-x[1],x[0])):
  if mx==v:
    print(k)

Submission status: Accepted

Solution code:
import collections
 
n=int(input())
 
li=[]
ma=0
an=[]
 
for i in range(n):
    li.append(input())
 
c=collections.Counter(li)
c2=c.most_common()
ma=c2[0][1]

for j in range(n):
    if c2[j][1]==ma:
        an.append(c2[j][0])
        
        if len(c2)==j+1:
            break
    else:
        break
 
an.sort()
 
for k in range(len(an)):
    print(an[k])

Submission status: Accepted

Solution code:
N = int(input())
S = list()

for _ in range(N):
    S.append(input())
S_set = set(S)
S_dict = dict()
for s in S_set:
    S_dict[s] = 0

for val in S:
    S_dict[val] += 1
max_num = max(S_dict.values())
ans = list()
for k, v in S_dict.items():
    if v == max_num:
        ans.append(k)
ans = sorted(ans)
for res in ans:
    print(res)

Submission status: Accepted

Solution code:
import collections


N = int(input())

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

count = collections.Counter(S)


mx = max(count.values())

result = [key for key, val in count.items() if val == mx]
print("\n".join(sorted(result)))

Submission status: Accepted

Solution code:
import collections

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

c = collections.Counter(List)
m = 0
for v in c.values():
  m = max(m, v)
  
for k, v in c.items():
  if v == m:
    res.append(k)
    
res.sort()
for i in range(len(res)):
  print(res[i])

Submission status: Accepted

Solution code:
import collections

N = int(input())
S = list(input() for i in range(N))

c = collections.Counter(S)
max = max(c.values())

max_k_list = [kv[0] for kv in c.items() if kv[1] == max]

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

Submission status: Accepted

Solution code:
from collections import Counter


N = int(input())
list = [input() for _ in range(0,N)]
counted = Counter(list)
res_max= counted.most_common()[0][1]
ans = []
for k, v in counted.items():
    if v == res_max:
        ans.append(k)

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

Submission status: Accepted

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

dic = {}
for i in range(N):
    if (S[i] in dic.keys()) == False:
        dic[S[i]] = 1
    else:
        dic[S[i]] = dic[S[i]] + 1

sortdic = sorted(dic.items(), key = lambda x:x[1])

m = sortdic[len(sortdic)-1][1]
ans = []
for i in range(len(sortdic)):
    if sortdic[i][1] == m:
        ans.append(sortdic[i][0])

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

Submission status: Accepted

Solution code:
import collections

N = int(input())
S = list(input() for i in range(N))
dict = {}

for l in S:
        if l in dict:
            dict[l] += 1;
        else:
            dict[l] = 1;
            
max = max(dict.values())

max_k_list = [kv[0] for kv in dict.items() if kv[1] == max]

max_k_list.sort()

for i in max_k_list:
    print(i)

Submission status: Accepted

Solution code:
n = int(input())
l = [str(input()) for i in range(n)]
l.sort()
i = 0
count = 1
ans = []
max = 1
while i < n-1:
  if l[i] == l[i+1]:
    count += 1
    i += 1
    if count >= max:
      max = count
    if i == n-1:
      ans.append([l[n-1], count])

  else:
      ans.append([l[i],count])
      count = 1
      i += 1

if max == 1:
  ans.append([l[n-1], 1])
      
for i in ans:
  if i[1] == max:
    print(i[0])

Submission status: Accepted

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

maxv=max(dic.values())
words=sorted(dic.items(),key=lambda x:x[0])
for item in words:
  if item[1]==maxv:
    print(item[0])

Submission status: Accepted

Solution code:
import collections
a = int(input())
l = []
for i in range(a):
    l.append(input())
counted = collections.Counter(l)
 
m = max(counted.values())
 
chars = [key for key, value in counted.items()
             if value == m]
chars.sort()
 
for i in chars:
    print(i)