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:
N = int(input())
S = [str(input()) for _ in range(N)]

S.sort()
lst = [1]
for i in range(1, N):
    if S[i] == S[i-1]:
        lst[-1] += 1
    else:
        lst.append(1)

candidate = list(set(S))
candidate.sort()
#print(candidate)

max_value = max(lst)
max_index = [i for i, x in enumerate(lst) if x == max_value]
#print(max_index)

for j in range(len(max_index)):
    print(candidate[max_index[j]])

Submission status: Accepted

Solution code:
from collections import OrderedDict
n = int(input())
d = {}
for i in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1
d = OrderedDict(sorted(d.items()))
mx = 0
for v in d.values():
    mx = max(v, mx)
for k, v in d.items():
    if v == mx:
        print(k)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

def LI(): return list(map(int, stdin.readline().split()))
def LS(): return list(stdin.readline())

from collections import Counter
n = int(input())
s = Counter([input() for i in range(n)])
high = max(s.values())
ans = [k for k,v in s.items() if v==high]
print('\n'.join(sorted(ans)))

Submission status: Accepted

Solution code:
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
#from heapq import heappop, heappush
from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import combinations
def run():
    N, *S = read().split()
    dic = defaultdict(lambda:0)
    for s in S:
        dic[s] += 1
    dic = sorted(dic.items(), key = lambda x:x[1], reverse=True)
    num = dic[0][1]
    ret = []
    for s, n in dic:
        if n != num:break
        ret.append(s)
    print('\n'.join(sorted(ret)))


if __name__ == "__main__":
    run()

Submission status: Accepted

Solution code:
from sys import stdin, setrecursionlimit


def main():
    n = int(stdin.readline())
    s = [stdin.readline()[:-1] for _ in range(n)]
    keys = list(set(s))
    keys.sort()
    summary = {}

    for key in keys:
        summary[key] = 0

    m = 0
    for si in s:
        summary[si] += 1
        m = max(summary[si], m)

    for key in keys:
        if summary[key] == m:
            print(key)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Submission status: Accepted

Solution code:
from collections import Counter

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

C = Counter(S)

ma = max(C.values())
ans = sorted(k for k, v in C.items() if v == ma)

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)
a = max([c[i] for i in set(s)])
r = []
for i in set(s):
    if c[i] >= a:
        r.append(i)
r.sort()
[print(i) for i in r]

Submission status: Accepted

Solution code:
N = int(input())
List = [input() for i in range(N)]
from collections import Counter
C = Counter(List)
C = C.most_common()
Newlist = []

for p in range(len(C)):
  if C[p][1] == C[0][1]:
    Newlist.append(C[p][0])
  else:
    break
Newlist.sort()
for i in range(len(Newlist)):
  print(Newlist[i])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Thu May  7 22:30:26 2020

@author: shinba
"""

from operator import itemgetter

N = int(input())

data = {}

for i in range(N):
    string = input()
    if string in data:
        data[string] += 1
    else:
        data[string] = 1

s = sorted(data.items(),key=itemgetter(1),reverse = True)

M = s[0][1]

ans = [s[0][0]]
for i in range(1,len(s)):
    if s[i][1] == M:
        ans.append(s[i][0])
    else:
        break

ans.sort()

for i in ans:
    print(i)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=[input() for i in range(n)]
    from collections import Counter
    c=Counter(l)
    csort=c.most_common()
    maxl=[]
    for i in range(len(csort)):
        if csort[i][1]==csort[0][1]:
            maxl.append(csort[i][0])
    maxl.sort()
    for i in maxl:
        print(i)
resolve()

Submission status: Accepted

Solution code:
from collections import deque

N = int(input())
S = [""] * N
for i in range(N):
    S[i] = input()
mostfrequent = deque()
wordcount = {}
frequentoccurence = 0

for s in S:
    if not s in wordcount:
        wordcount[s] = 1
    else:
        wordcount[s] += 1
    if wordcount[s] == frequentoccurence:
        mostfrequent.append(s)
    if wordcount[s] > frequentoccurence:
        frequentoccurence = wordcount[s]
        mostfrequent.clear()
        mostfrequent.append(s)
frequentlist = list(mostfrequent)
frequentlist.sort()
print("\n".join(frequentlist))

Submission status: Accepted

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

temp = collections.Counter(s)
temp = temp.most_common()

ans = []
num = temp[0][1]

for i,j in temp:
    if num == j:
        ans.append(i)
    else:
        break

print(*sorted(ans))

Submission status: Accepted

Solution code:
N = int(input())
words = {}
for i in range(N):
  name = input()
  if name not in words:
    words[name] = 1
  elif name in words:
    words[name] += 1
    
res_name = []
Max = max(words.values())
for i in words.keys():
  if words[i] == Max:
    res_name.append(i)
res_name = sorted(res_name)
for i in res_name:
  print(i)

Submission status: Accepted

Solution code:
from collections import Counter
def resolve():
    n=int(input())
    l=[input() for i in range(n)]
    c=Counter(l)
    maxl=[]
    cntmax=max(c.values())
    for name,kazu in c.items():
        if kazu==cntmax:
            maxl.append(name)
    maxl.sort()
    for i in maxl:
        print(i)
resolve()

Submission status: Accepted

Solution code:
import sys
import collections
from collections import Counter

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

cur = Counter(s)
mx = 0
for v in cur.values():
    mx = max(mx, v)

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

Submission status: Accepted

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

cnt = collections.Counter(s_)
cntList = list(cnt.most_common())
cnt_f = cnt.most_common()[0][1]

resList = []
for i in range(len(cntList)):
    if cntList[i][1] == cnt_f:
        resList.append(cntList[i][0])
    else:
        break

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

Submission status: Accepted

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

import collections
ans=[]
c = collections.Counter(s).most_common()
zzz = c[0][1]
for i in range(len(c)):
    if zzz == c[i][1]:
        ans.append(c[i][0])
    else:
        break
ans.sort()
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
import collections
n=int(input())
s=[input() for _ in range(n)]
c=collections.Counter(s)
common=c.most_common()
value,cnt=zip(*common)
common.sort(key=lambda x:x[0])
m=max(cnt)
for cc in common:
  if cc[1]==m:
    print(cc[0])

Submission status: Accepted

Solution code:
import collections
n=int(input())
s=[input() for i in range(n)]
dic=collections.Counter(s)
ans=[]
largest=max(dic.values())
for keys in dic.keys():
    if dic[keys]==largest:
        ans.append(keys)
ans=sorted(ans)
print(*ans)

Submission status: Accepted

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

set_s = set(s)
cnt_s = collections.Counter(s)

m=0
for i in set_s:
    m = max(m,cnt_s[i])
ans=[]
for i in set_s:
    if cnt_s[i]==m:
        ans.append(i)
ans = sorted(ans)

for a in ans:
    print(a)

Submission status: Accepted

Solution code:
import collections

# A = input()
# A = int(input())
# A = map(int, input().split())
# A = list(map(int, input().split()))
# A = [int(input()) for i in range(N)]
#
# c = collections.Counter()
N = int(input())
S = [input() for s in range(N)]

c = collections.Counter(S)
cmc = c.most_common()
nmc = c.most_common()[0][1]

ans = []
for cmc_ in cmc:
  if cmc_[1] == nmc:
    ans.append(cmc_[0])
  else:
    break

ans.sort()
[print(ans_) for ans_ in ans]

Submission status: Accepted

Solution code:
N = int(input())
dic = dict()
lis = list()
for i in range(N):
    tmp = input()
    lis.append(tmp)
    dic[tmp] =0
maxi = 0
for i in lis:
    dic[i] +=1
    if maxi < dic[i]:
        maxi = dic[i]
result = list()
for name in dic:
    if dic[name] == maxi:
        result.append(name)

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

Submission status: Accepted

Solution code:
from collections import Counter
 
N = int(input())
S = []
for i in range(N):
    S.append(input())
S.sort()

c = Counter(S).most_common()

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

Submission status: Accepted

Solution code:
N=int(input())
data={}
for i in range(N):
    name=input()
    if data.get(name) == None:
        data[name]=0
    data[name] += 1
data = sorted(data.items(),key=lambda x:x[1])
if len(data) == 1:
    print(data[-1][0])
else:
    mx=data[-1][1]
    l=[]
    for i in range(N):
        if data[len(data)-i-1][1] == mx:
            l.append(data[len(data)-i-1][0])
        else:
            break
    l.sort()
    for i in l: print(i)

Submission status: Accepted

Solution code:
N=int(input())
S=[]
dict={}

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

S.sort()

for n in range(N):
  if n!=0 and S[n]==S[n-1]:
    dict[S[n]]+=1
  else:
    dict[S[n]]=1
    
MAX=max(dict.values())
S2=[]

for k,v in dict.items():
  if v==MAX:
    S2.append(k)

S2.sort()
for s2 in S2:
  print(s2)

Submission status: Accepted

Solution code:
import collections

n = int(input())
s = list(input() for i in range(n))

col = collections.Counter(s)
col = col.most_common()

count = [0]
k = 0

for i in range(len(col)):
    if i == 0:
        count[k] = col[i][1]
        k += 1
    elif count[k-1] == col[i][1]:
        count.append(col[i][1])

ans = [0]*len(count)

for i in range(len(count)):
    ans[i] = col[i][0]
ans.sort()

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

Submission status: Accepted

Solution code:
N = int(input())
dict1 = {}
for _ in range(N):
  s = input()
  if s in dict1:
    dict1[s] += 1
  else:
    dict1[s] = 1
max_num= max(dict1.values())
list1 = [d[0] for d in dict1.items() if d[1]==max_num]
list1.sort()
for s in list1:
  print(s)

Submission status: Accepted

Solution code:
n = int(input())

words = []
dict = {}
for i in range(n):
    s = input()
    words.append(s)
    if s not in dict:
        dict[s] = 0
    dict[s] += 1

max = max(dict.values())
for s in sorted([d for d in dict if dict[d] == max]):
    print(s)

Submission status: Accepted

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

m=max(d.values())
n=[]
for i in d.keys():
        if d[i]==m:
                n.append(i)
n.sort()
for i in n:
        print(str(i))

Submission status: Accepted

Solution code:
import collections
n=int(input())
s = [0]*n
for i in range(n):
    s[i] = input()
c = collections.Counter(s).most_common()
maxn = c[0][1]
ans = []
for i in range(len(c)):
    if c[i][1] == maxn:
        ans.append(c[i][0])
print('\n'.join(sorted(ans)))

Submission status: Accepted

Solution code:
# C - Poll

N = int(input())
D = {}
mx = 0
for _ in range(N):
    s = str(input())
    if s not in D:
        D[s] = 0
    D[s] += 1
    if mx < D[s]:
        mx = D[s]

for a in sorted([d for d in D if D[d] == mx]):
    print(a)

Submission status: Accepted

Solution code:
n = int(input())

result = {}
max = 0
for i in range(n):
    a = str(input())
    if not a in result:
        result[a] = 0
    result[a] += 1
    if max < result[a]:
        max = result[a]

result = sorted(result.items(), key=lambda x: (x[1], x[0]))
for val in result:
    if max == val[1]:
        print(val[0])

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

n = I()
s = SR(n)
sc = Counter(s)
most = sc.most_common()[0][1]
ans = []
for s, num in sc.most_common():
    if num == most:
        ans.append(s)
ans.sort()
for x in ans:
    print(x)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

N = int(input().strip())
S_list = [input().strip() for _ in range(N)]
#-----

S_dic = {}

for s in S_list:
    S_dic.setdefault(s, 0)
    S_dic[s] += 1

S_dic_sorted = sorted(S_dic.items(), key = lambda x: x[1], reverse=True)
max_cnt_S = S_dic_sorted[0][1]
ans = []

for k,v in S_dic_sorted:
    if v == max_cnt_S:
        ans.append(k)

ans.sort()

for word in ans:
    print(word)

Submission status: Accepted

Solution code:
from collections import Counter

N = int(input())
S = []
for i in range(N):
    S.append(input())
S.sort()
c = Counter(S).most_common()
m = c[0][1]
c.sort()
for i in range(len(c)):
    if c[i][1] == m:
        print(c[i][0])

Submission status: Accepted

Solution code:
import collections

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

counter_ = collections.Counter(data)

max_ = max(list(counter_.values()))

ans = []
for c_name in counter_:
  if counter_[c_name] == max_:
    ans.append(c_name)

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

Submission status: Accepted

Solution code:
import collections

N = int(input())

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

sA = list(set(A))
# sAs = sorted(sA)

c = collections.Counter(A)


# print(sA)

count = [] 

# print(count)

for i in range(len(sA)):
    w = sA[i]
    count.append(c[w])
    # count[i] = ss
    
# print(count)

point = []

maX = max(count)

# print(maX)

point2 = [i for i, x in enumerate(count) if x == maX]

ancer = [sA[point2[i]] for i in range(len(point2))]

# print(ancer)

ancerABC = sorted(ancer)

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

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
lst = [(input()) for _ in range(n)]
c = Counter(lst)
d = c.most_common()
e = d[0][1]
lst_new = []
for f in c.keys():
    if c[f] == e:
        lst_new.append(f)
lst_new.sort()
for g in lst_new:
    print(g)

Submission status: Accepted

Solution code:
from collections import defaultdict

n = int(input())
dict1 = defaultdict(int)

for i in range(n):
    s = str(input())
    dict1[s] += 1

dict1 = sorted(dict1.items(), key=lambda x:x[1], reverse=True)
max = dict1[0][1]
ans = []
for i in range(len(dict1)):
    if dict1[i][1] == max:
        ans.append(dict1[i][0])
    else:
        break

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

Submission status: Accepted

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

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

S = sorted(S.items(), key=lambda x: (-x[1], x[0]))
n = S[0][1]
for s in S:
    if s[1] != n:
        break
    print(s[0])

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
n = int(readline())
s = [readline().rstrip() for _ in range(n)]

import collections

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

ans = [c[0][0]]
v_max = c[0][1]
for k,v in c[1:]:
    if v == v_max:
        ans.append(k)
ans.sort()

for a in ans:
    print(a)

Submission status: Accepted

Solution code:
n=int(input())
dic={}
maxx=1
for i in range(n):
  s=input()
  if s in dic:
    dic[s]+=1
  else:
    dic[s]=1
  if dic[s]>maxx:
    maxx=dic[s]
lis=[]
for i in range(len(dic)):
  kk=dic.popitem()
  if kk[1]==maxx:
    lis.append(kk[0])
lis.sort()
for i in range(0,len(lis)):
  print(lis[i])

Submission status: Accepted

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

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

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

Submission status: Accepted

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

ssdict = {}
for i in range(n):
    if Ss[i] in ssdict:
        ssdict[Ss[i]] += 1
    else:
        ssdict[Ss[i]] = 0

cnt = 0
ans = []
for key in ssdict:
    if ssdict[key] > cnt:
        ans = []
        ans.append(key)
        cnt = ssdict[key]
    elif ssdict[key] == cnt:
        ans.append(key)
    else:
        continue

srt = sorted(ans)
for value in srt:
    print(value)

Submission status: Accepted

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

Mx = max(dic.values())
ans = []
for key in dic.keys():    
    if dic[key] == Mx:
        ans.append(key)
ans.sort()
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
from functools import reduce

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

for i, s in enumerate(S):
    if s in s_map:
        s_map[s] += 1
    else:
        s_map[s] = 1

s_list = list(s_map.items())
s_list.sort(key=lambda x:x[1], reverse=True)
max_num = s_list[0][1]
res = list(filter(lambda item: item[1] == max_num, s_list))
res.sort(key=lambda x: x[0], reverse=False)
for i, item in enumerate(res):
    print(item[0])

Submission status: Accepted

Solution code:
import collections

N = int(input())
S = list()
for i in range(N):
  S.append(str(input()))

c = collections.Counter(S)
d = c.most_common()
d = d + [("test", 0)]
e = list()

e.append(d[0][0])

for j in range(N):
  if d[j][1] == d[j+1][1]:
    e.append(d[j+1][0])
  else:
    break

f = sorted(e)

for k in range(len(f)):
  print(f[k])

Submission status: Accepted

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

s = collections.Counter(s).most_common()
mx = s[0][1]

ans = []
for k, v in s:
    if mx == v:
        ans.append(k)


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

Submission status: Accepted

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

max=d[0][1]

A=[]
for i in d:
  if i[1]==max:
    A.append(i[0])
print(*sorted(A),sep='\n')

Submission status: Accepted

Solution code:
from heapq import heapify,heappop,heappush
que = []
heapify(que)
N = int(input())
S =[]
for i in range(0,N,1):
    S.append(input())
S.sort()
count=1
max_count =0
pre = S[0]
for i in range(1,N,1):
    if S[i]==pre:
        count+=1
    else:
        count=1
    if max_count < count:
        max_count = count
    pre = S[i]

count=1
pre = S[0]
for i in range(1,N,1):
    if S[i]==pre:
        count+=1
    else:
        if count ==max_count:
            print(pre)
        count=1
    pre = S[i]

if count ==max_count:
            print(pre)

Submission status: Accepted

Solution code:
from collections import *
n,*s=map(str,open(0).read().split())
s=Counter(s).most_common()
print(*sorted((a+'\n')*(i==s[0][1]) for a,i in s))

Submission status: Accepted

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

import collections
A = collections.Counter(s)
 
B = max(A.values())
C = [i for i in A if A[i] == B]
C = sorted(C)
 
for i in C:
    print(i)

Submission status: Accepted

Solution code:
from collections import defaultdict

n = int(input())
s = defaultdict(int)

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

top = max(s.values())
ans = []

for k in s.keys():
    if s[k] == top:
        ans.append(k)

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

Submission status: Accepted

Solution code:
N = int(input())
S = list(input() for i in range(N))  #スペース抜きの単語を複数行

import collections
A = collections.Counter(S)

B = max(A.values())
C = [i for i in A.keys() if A[i] == B]
C = sorted(C)

for i in C:
    print(i)

Submission status: Accepted

Solution code:
N = int(input())
S = list(input() for i in range(N))  #スペース抜きの単語を複数行

import collections
A = collections.Counter(S)

B = max(A.values())
C = [i for i in A if A[i] == B]
C = sorted(C)
 
for i in C:
    print(i)

Submission status: Accepted

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

A = Counter(S)
A = sorted(A.items(),key=lambda x:x[1],reverse = True)
i,s = A[0]
Ans = []
for i,j in A:
    if j==s:
        Ans.append(i)
    else:
        break
Ans = sorted(Ans)
for i in Ans:
    print(i)

Submission status: Accepted

Solution code:
import collections as col

if __name__ == '__main__':
	N = int(input())
	lst = []
	for _ in range(N):
		lst.append(input())

	c = col.Counter(lst)
	C = c.most_common()
	l = []
	co = C[0][1]
	for cc in C:
		if cc[1] == co:
			l.append(cc[0])
		else:
			break
	l.sort()
	for s in l:
		print(s)

Submission status: Accepted

Solution code:
N = int(input())
Sn = [input() for _ in range(N)]
Sn.sort()
cnt = {}
ans = []
for k in range(N):
  if Sn[k] in cnt:
    cnt[Sn[k]] += 1 
  else:
    cnt[Sn[k]] = 1
max_val = max(cnt.values())
ans = list(filter(lambda x:cnt[x] == max_val, cnt))
ans.sort()
[print(a) for a in ans]

Submission status: Accepted

Solution code:
import collections
import itertools


N =int(input())
List = []
Dictionary = []
for i in range(N):
    In = input()
    List.append(In)
    
counters= collections.Counter(List)
counter = sorted(counters.items())
mode_v = counters.most_common()[0][-1]

for j in range(len(counter)):
    an = counter[j][1]
    if mode_v == an:
        print(counter[j][0])
    else:
        continue

Submission status: Accepted

Solution code:
n=int(input())
s=[]
m={}
for i in range(n):
    st=input()
    if(st in m):m[st]+=1
    else:m[st]=1
mx=max(m.values())
ans=[]
for i in m:
    if(m[i]==mx):ans.append(i)
ans=sorted(ans)
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
import collections
N = int(input())
S_list = [input() for i in range(N)]

c = collections.Counter(S_list)
c2 = c.most_common()
cnt_list = c.values()
cnt_max = max(cnt_list)

str_list = []

for j in range(len(c)):
  if c2[j][1] == cnt_max:
    str_list.append(c2[j][0])

str_list.sort()

for k in range(len(str_list)):
  print(str_list[k])

Submission status: Accepted

Solution code:
from collections import defaultdict

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

d = defaultdict(int)

for s in S:
    d[s] += 1
    
mx = max(d.values())
for k, v in sorted(d.items(), key=lambda x: x[0]):
    if v == mx:
        print(k)

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
largest=max(DIC.values())
ans=[]
for s in DIC:
    if DIC[s]==largest:
        ans.append(s)
    else:
        continue
ans.sort()
for t in ans:
    print(t)

Submission status: Accepted

Solution code:
from collections import Counter
N=int(input())
listS=[]
for i in range(N):
  S=input()
  listS+=[S]
listS=Counter(listS)
listS=listS.most_common()
ans=[]
MAX=listS[0][1]
for i in range(len(listS)):
  if listS[i][1]==MAX:
    ans+=[listS[i][0]]
  else:
    break   
ans.sort()
for i in ans:
  print(i)

Submission status: Accepted

Solution code:
from collections import Counter
N=int(input())
listS=[]
for i in range(N):
  S=input()
  listS+=[S]
listS=Counter(listS).most_common()
ans=[]
MAX=listS[0][1]
for i in range(len(listS)):
  if listS[i][1]==MAX:
    ans+=[listS[i][0]]
  else:
    break   
ans.sort()
for i in ans:
  print(i)

Submission status: Accepted

Solution code:
N=int(input())
listS=[]
for i in range(N):
  S=input()
  listS+=[S]
listS.sort()
counter=[]
count=1
for i in range(N-1):
  if listS[i]==listS[i+1]:
    count+=1
  else:
    counter+=[count]
    count=1
    
counter+=[count]    
MAX=max(counter)
count=1

for i in range(N-1):
  if listS[i]==listS[i+1]:
    count+=1
  else:
    count=1
  if count==MAX:
    print(listS[i])
    
if MAX==1:
  print(listS[-1])

Submission status: Accepted

Solution code:
from collections import Counter

# まずは代入
n = int(input())
s = [input() for _ in range(n)]
c = Counter(s).most_common()  # もうリストにしちゃった<3
# この時点で, cは個数が多い順に並んでる
# たとえば入力例1だと
# [('vet', 2), ('beet', 2), ('beat', 1), ('bed', 1), ('bet', 1)]

ans = []
max = c[0][1]  # 最大の個数は何か? 数値を代入
for item, count in c:
	if count == max:
		ans.append(item)
	else:
		break  # もうこれ以下は弱いのしかないのでbreakします

ans.sort()  # 辞書順に並べる

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

Submission status: Accepted

Solution code:
import collections

#まずは代入
n = int(input())
s = [input() for _ in range(n)]
c = collections.Counter(s).most_common() #もうリストにしちゃった<3
d = collections.Counter([c[x][1] for x in range(len(c))])
#この時点で, cは個数が多い順に並んでる
#たとえば入力例1だと
#[('vet', 2), ('beet', 2), ('beat', 1), ('bed', 1), ('bet', 1)]

ans = []
max = c[0][1] #最大の個数は何か? 数値を代入
for item,count in c[0:d[max]]:
	if count==max:
		ans.append(item)
	else:
		break #もうこれ以下は弱いのしかないのでbreakします

ans.sort() #辞書順に並べる

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

Submission status: Accepted

Solution code:
import collections

#まずは代入
n = int(input())
s = [input() for _ in range(n)]
c = collections.Counter(s).most_common() #もうリストにしちゃった<3
#この時点で, cは個数が多い順に並んでる
#たとえば入力例1だと
#[('vet', 2), ('beet', 2), ('beat', 1), ('bed', 1), ('bet', 1)]

ans = []
max = c[0][1] #最大の個数は何か? 数値を代入
for item,count in c:
	if count==max:
		ans.append(item)
	else:
		break #もうこれ以下は弱いのしかないのでbreakします

ans.sort() #辞書順に並べる

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

Submission status: Accepted

Solution code:
import sys;input=lambda:sys.stdin.readline().rstrip();aint=lambda:int(input());ints=lambda:list(map(int,input().split()))
import math;floor,ceil=lambda x:int(math.floor(x)),lambda x:int(math.ceil(x))
from functools import reduce;gcd=lambda*x:reduce(math.gcd,x);lcm=lambda*x:reduce(lambda x,y:(x*y)//gcd(x,y),x,1)
from collections import deque
import bisect
Yes=lambda b:print("Yes"if b else"No");YES=lambda b:print("YES"if b else"NO")
is_even=lambda x:True if x%2==0 else False

def main():
  n=aint()
  d=dict()
  for i in range(n):
    inp=input()
    if inp in d:
      d[inp]+=1
    else:
      d[inp]=1
  d_sorted=sorted(d.items(),key=lambda x:x[0])
  num=max(d.values())
  for cont in d_sorted:
    if cont[1]==num:
      print(cont[0])

if __name__ == '__main__':
    main()

Submission status: Accepted

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

c = collections.Counter(s)
l=c.most_common()
x=[l[0][0]]
for i in range(1,len(l)):
  if l[i-1][1]==l[i][1]:
    x.append(l[i][0])
  else:
    break
x.sort()    
for i in x:
  print(i)

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

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

m = d[0][1]
l = []
for i in range(len(d)):
    if(d[i][1] < m):break
    l.append(d[i][0])
l.sort()
for r in l:print(r)

Submission status: Accepted

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

count = Counter(lst)
m = max(count.values())

ans = []
for k, v in count.items():
  if v == m:
    ans.append(k)

ans.sort()

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

Submission status: Accepted

Solution code:
from collections import defaultdict


def main():
    N = int(input())
    counter = defaultdict(int)
    for _ in range(N):
        s = input()
        counter[s] += 1
    max_cnt = 0
    max_cnt_str_list = list()
    for s, cnt in counter.items():
        if cnt > max_cnt:
            max_cnt = cnt
            max_cnt_str_list = [s]
        elif cnt == max_cnt:
            max_cnt_str_list.append(s)
    max_cnt_str_list = sorted(max_cnt_str_list)
    for s in max_cnt_str_list:
        print(s)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
lst = [input() for i in range(n)]
lst.sort()
lst.append("END")

maxi = 0
ans = []
count = 1

for i in range(n):
  if lst[i] == lst[i+1]:
    count += 1
  else:
    if count > maxi:
      ans = [lst[i]]
      maxi = count
    elif count == maxi:
      ans.append(lst[i])
    count = 1
    
for i in range(len(ans)):
  print(ans[i])

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
s = []
for _ in range(n):
    s.append(input())
s = Counter(s)
words, counts = zip(*s.most_common())
selected = []
num = None
for w, c in zip(words, counts):
    if num == None:
        num = c
        selected.append(w)
    else:
        if c == num:
            selected.append(w)
        else:
            break
print(*sorted(selected), sep='\n')

Submission status: Accepted

Solution code:
N = int(input())
S = [input() for _ in range(N)]
dic = dict()
for s in S:
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1
score_sorted = sorted(dic.items(), key=lambda x: -x[1])
m = score_sorted[0][1]
ret = []
for k,v in score_sorted:
    if v == m:
        ret.append(k)
    else:
        break
ret = sorted(ret)
for item in ret:
    print(item)

Submission status: Accepted

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

from collections import Counter
words = []
counter = Counter(s)

items = list(counter.items())
max_count = max(counter.values())

for i in range(len(items)):
    if items[i][1] != max_count:
        continue
    else:
        words.append(items[i][0])

words.sort()

for word in words:
    print(word)