Problem:


Score: 300 points

Problem Statement

We have N voting papers. The i-th vote (1 \leq i \leq N) has the string S_i written on it.

Print all strings that are written on the most number of votes, in lexicographical order.

Constraints

1 \leq N \leq 2 \times 10^5

S_i (1 \leq i \leq N) are strings consisting of lowercase English letters.

The length of S_i (1 \leq i \leq N) is between 1 and 10 (inclusive).

Input

Input is given from Standard Input in the following format:

N
S_1
:
S_N

Output

Print all strings in question in lexicographical order.

Sample Input 1

7
beat
vet
beet
bed
vet
bet
beet

Sample Output 1

beet
vet

beet and vet are written on two sheets each, while beat, bed, and bet are written on one vote each. Thus, we should print the strings beet and vet.

Sample Input 2

8
buffalo
buffalo
buffalo
buffalo
buffalo
buffalo
buffalo
buffalo

Sample Output 2

buffalo

Sample Input 3

7
bass
bass
kick
kick
bass
kick
kick

Sample Output 3

kick

Sample Input 4

4
ushi
tapu
nichia
kun

Sample Output 4

kun
nichia
tapu
ushi



Sample input:
7
beat
vet
beet
bed
vet
bet
beet


Sample output:
beet
vet

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
s = Counter([str(input()) for _ in range(n)])
m = max(s.values())
for x in sorted(x for x in s if s[x] == m):
    print(x)

Submission status: Accepted

Solution code:
import collections
N = int(input())
D = collections.Counter(input() for i in range(N))
maximum = max(D.values())
sort = sorted(key for key,value in D.items() if value == maximum)
for s in sort:
    print(s)

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
s = Counter([str(input()) for _ in range(n)])
max_list = []
max_count = 0
for k, v in s.items():
    if max_count < v:
        max_count = v
        max_list = []
    if max_count == v:
        max_list.append(k)
max_list.sort()
for x in max_list:
    print(x)

Submission status: Accepted

Solution code:

def main():
    N = int(input())
    d = {}
    m = 0
    for n in range(N):
        s = input()
        d[s] = d.setdefault(s, 0) + 1
        if d[s] > m:
            m = d[s]
    keys = [k for k, v in d.items() if v == m]
    print('\n'.join(sorted(keys)))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import Counter

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

counter = Counter(s)
max_cnt = max(counter.values())

names = [name for name,val in counter.items() if val==max_cnt]
names.sort()

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

Submission status: Accepted

Solution code:
n = int(input())
dic = {}
val_set = set()
ans = []

for i in range(n):
  temp = input()
  try:
    dic[temp] += 1
  except:
    dic[temp] = 1

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

for key,val in dic:
  val_set.add(val)
  if len(val_set) == 2:
    break
  else:
    ans.append(key)
  
ans = sorted(ans)

for x in ans:
  print(x)

Submission status: Accepted

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

max=max(s.values())
ans=[]
for i,j in s.items():
    if j == max:
        ans.append(i)
ans=sorted(ans)
print('\n'.join(ans))

Submission status: Accepted

Solution code:
import collections

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

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

slist = list(str.items())

ans = []
for i in range(len(set(s))):
    if slist[i][1] == cntmax:
       ans.append(slist[i][0])
ans.sort()

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

Submission status: Accepted

Solution code:
n=int(input())

dic={}
for i in range(n):
    s=input()
    if s not in dic:
        dic[s]=1
    else:
        dic[s]+=1
dic2=sorted(dic.items(), key=lambda x:x[1],reverse=True)
ma=dic2[0][1]

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

Submission status: Accepted

Solution code:
from collections import Counter


def main():
    n = int(input())
    s = []
    for i in range(n):
        s.append(input())
    cnt = Counter(s).most_common()
    num = cnt[0][1]
    for v in  sorted([v for v, c in cnt if c == num]):
        print(v)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())

data = dict()

for i in range(n):
    s = input()
    if s in data:
        data[s] += 1
    else:
        data.setdefault(s,1)
ans = sorted(data.items(),key=lambda x:x[1],reverse=True)
max_num = ans[0][1]
A = []
for item,i in ans:
    if i == max_num:
        A.append(item)
A.sort()

for item in A:
    print(item)

Submission status: Accepted

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

N = int(input())
data = dict()
for _ in range(N):
    s = input()[:-1]
    if s in data:
        data[s] += 1
    else:
        data.setdefault(s, 1)

ans = sorted(data.items(), key=lambda x:x[1], reverse=True)
M = ans[0][1]
A = []
for item, i in ans:
    if M == i:
        A.append(item)
    else:
        break
A.sort()
for item in A:
    print(item)

Submission status: Accepted

Solution code:
class Counter(dict):
  def __missing__(self, i):
    return 0

n = int(input())

s = Counter()

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

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

ans = []
for key, value in s:
  if value == m:
    ans.append(key)
  else:
    break

ans.sort()

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

Submission status: Accepted

Solution code:
class Counter(dict):
  def __missing__(self, i):
    return 0

n = int(input())

s = Counter()

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

s = dict(sorted(s.items(), key=lambda x: -x[1]))
m = max(list(s.values()))

ans = []
for i in s:
  if s[i] == m:
    ans.append(i)

ans.sort()

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

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
words = [0]*N
for i in range(N):
    words[i] = input()
counter = Counter(words)
cnt = max(counter.values())
ans = []
for key,value in counter.items():
    if value == cnt:
        ans.append(key)
ans.sort()
print(*ans,sep="\n")

Submission status: Accepted

Solution code:
from collections import Counter

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

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

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

maxnum=arr[0][1]
ans=[]

for i in range(len(arr)):
    if arr[i][1]==maxnum:
        ans.append(arr[i][0])        
    else:
        break
FA=sorted(ans)
for j in FA:
    print(j)

Submission status: Accepted

Solution code:
from collections import Counter

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

max_count = max(cnt.values())
ans = [k for k, count in cnt.items() if count == max_count]
ans.sort()
print("\n".join(ans))

Submission status: Accepted

Solution code:
from collections import Counter

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

max_count = max(cnt.values())
ans = [k for k, count in cnt.items() if count == max_count]

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

Submission status: Accepted

Solution code:
from collections import Counter

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

max_count = max(cnt.values())
ans = [k for k, count in cnt.items() if count == max_count]

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

Submission status: Accepted

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

max_count = max(d.values())
ans = [s for s, count in d.items() if count == max_count]

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

Submission status: Accepted

Solution code:
from collections import defaultdict
d = defaultdict(int)
n = int(input())
for i in range(n):
  s = input()
  d[s] += 1
d = dict(d)
d = sorted(d.items(), key=lambda x:x[1], reverse=True)
max_s = d[0][1]
l = [d[i][0] for i in range(len(d)) if d[i][1] == max_s]
l.sort()
for s in l:
  print(s)

Submission status: Accepted

Solution code:
import collections

N = int(input())
S = ['']*N

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

s = collections.Counter(S)

max_num = max(s.values())

ans = []

for k, v in s.items():
    if v == max_num:
        ans.append(k)

ans.sort()

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

Submission status: Accepted

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

ans = []
for i in cnt.most_common():
    if oldVal == i[1]:
        ans.append(i[0])
        oldVal = i[1]
    else:
        break
ans.sort()
print('\n'.join(ans))

Submission status: Accepted

Solution code:
n=int(input())
dic={}
mxd=[]
mxc=0
for i in range(n):
  s = input()
  if s in dic:
    dic[s] += 1
  else:
    dic[s] = 1
  if dic[s] > mxc:
    mxc=dic[s]
    mxd=[]
  if dic[s] == mxc:
    mxd.append(s)
mxd.sort()
for d in mxd:
  print(d)

Submission status: Accepted

Solution code:
n=int(input())
you=[]
al=[]
vot=[]
ans=[]
for i in range(n):
  s=input()
  al.append(s)
al.sort()
bef="zzzzzzzzzzz"
co=0
mx=1
for x in al:
  if bef!=x:
    if mx<co:
      mx=co
      ans=[bef]
    elif mx==co:
      ans.append(bef)
    co=1
    bef=x
  else:
    co+=1
if mx<co:
  mx=co
  ans=[bef]
elif mx==co:
  ans.append(bef)
for x in ans:
  print(x)

Submission status: Accepted

Solution code:
N = int(input())
dic = {}
max_v = 0

for i in range(N):
    temp = input()
    if temp in dic:
        dic[temp] += 1
    else:
        dic[temp] = 1
    max_v = max(max_v, dic[temp])

keys = sorted(dic.keys())
for k in keys:
    if dic[k] == max_v:
        print(k)

Submission status: Accepted

Solution code:
n=int(input())
dic = {}
max = 1
for i in range(n):
    s = input()
    if s not in dic:
        dic[s] = 1
    else:
        dic[s] += 1
        if max < dic[s]:
            max = dic[s]
l = []
for i in dic.keys():
    if dic[i] == max:
        l += [i]
l.sort()
for i in l:
    print(i)

Submission status: Accepted

Solution code:
n = int(input())
s = {}
for i in range(n):
  t = input()
  if t in s:
    s[t] += 1
  else:
    s[t] = 1
s = sorted(s.items(), key=lambda x:x[1], reverse=True)
vmax = s[0][1]
ans = []
for si in s:
  if si[1] == vmax:
    ans.append(si[0])
  else:
    break
ans.sort()
for a in ans:
  print(a)

Submission status: Accepted

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

maxi = 0
for _ in range(N):
    s=input()
    if s in dic.keys():
        dic[s] += 1
    else:
        dic[s] = 1
    maxi = max(maxi, dic[s])

keys = sorted(dic.keys())
for k in keys:
    if dic[k] == maxi:
        print(k)

Submission status: Accepted

Solution code:
from collections import defaultdict

def main():
    N = int(input())
    S = defaultdict(int)
    for i in range(N):
        s = input()
        S[s] += 1
    max_cnt = max(S.values())
    ans = []
    for k,v in sorted(S.items(), key=lambda x:x[1], reverse=True):
        if v == max_cnt:
            ans.append(k)
        else:
            break
    for a in sorted(ans):
        print(a)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import defaultdict
def main():
    N = int(input())
    dd=defaultdict(int)
    for _ in range(N):
        dd[input()]+=1
    dd = sorted(dd.items())
    dd = sorted(dd, reverse=True, key=lambda x: x[1])
    cnt = 0
    while len(dd) > cnt and dd[0][1] == dd[cnt][1] :
        print(dd[cnt][0])
        cnt +=1




if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(4100000)
import math
import collections
INF = 10**9


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

    count = 0
    c = collections.Counter(S)
    for _, val in c.items():
        count = max(count, val)
    array = []
    for key, val in c.items():
        if val == count:
            array.append(key)
    array.sort()
    for val in array:
        print(val)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())

count = {}

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

max_count = max(count.values())

ans = []

for k, v in count.items():
    if v == max_count:
        ans.append(k)

ans = sorted(ans)

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

Submission status: Accepted

Solution code:
import collections
N = int(input())
words = []
for i in range(N):
    words.append(input())
c = collections.Counter(words)
counts = c.most_common()
counts = sorted([i for i in counts if i[1] == counts[0][1]])
for i in counts:
    print(i[0])

Submission status: Accepted

Solution code:
S = []

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

S.sort()
count = 0
max_count=0
s_max=[]
for i in range(N):
	if i==0:
		s_0 = S[i]
		s_max.append(s_0)
		continue
	s_1 = S[i]
    
	if s_0 == s_1:
		count += 1
	else:
		count = 0
      
	if max_count==count:
		max_count = count
		s_max.append(s_1)
	elif max_count < count:
		max_count = count
		s_max=[]
		s_max.append(s_1)
      
	s_0 = s_1
    

for i in s_max:
  print(i)

Submission status: Accepted

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

c=collections.Counter(S)
vl=list(c.values())
# 最大要素数
mv=max(vl) 

ans=[]
cc=list(c.items()) # 辞書を[key, value]のリストにする
cc.sort(key=lambda x:x[1], reverse=True) # valueで降順ソート
# 辞書リスト内のkey, valueを調べる
for k, v in cc:
  if v==mv: # valueが要素数最大のやつ
    ans.append(k)
  else:
    break
ans.sort()
[print(a) for a in ans]

Submission status: Accepted

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

c=collections.Counter(S)
vl=list(c.values())
mv=max(vl)

ans=[]
cc=list(c.items())
cc.sort(key=lambda x:x[1], reverse=True)

for k, v in cc:
  if v==mv:
    ans.append(k)
  else:
    break
ans.sort()
[print(a) for a in ans]

Submission status: Accepted

Solution code:
import collections
import sys
N=int(input())
S=[input() for i in range(N)]
c = collections.Counter(S).most_common()
c.sort()
c.sort(key=lambda c:c[1],reverse=True)
max_count=c[0][1]
for _ in c:
  if _[1]==max_count:
    print(_[0])
  else:
    sys.exit()

Submission status: Accepted

Solution code:
n=int(input())
a={}
for _ in range(n):
  m=input()
  if m in a:
    a[m]+=1
  else:
    a[m]=1
b=[]
v=max(a.values())
for k in a.items() :
     if k[1] == v:
      b.append(k[0])
b.sort()
for l in b:
  print(l)

Submission status: Accepted

Solution code:
n = int(input())
s = [input() for i in range(n)]
from collections import Counter
cnter = Counter(s)
lis = cnter.most_common()
maxi = lis[0][1]
i = 0
string = []
for i in range(len(lis)):
    if maxi != lis[i][1]:
        break
    string.append(lis[i][0])
string.sort()
for i in range(len(string)):
    print(string[i])

Submission status: Accepted

Solution code:
line = int(input())
words =[input() for i in range(line)]

import collections

output = []
words_col = collections.Counter(words).most_common()
max_num = words_col[0][1]
for most_word in words_col:
  if max_num != most_word[1]: 
    break
  output.append(most_word[0])

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

Submission status: Accepted

Solution code:
N = int(input())
D = {}
for i in range(N):
    a = input()
    if a in D:
        D[a] += 1
    else:
        D[a] = 1


m = max(D.values())
count = []
for key in D:
    if D[key] == m:
        count.append(key)

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

Submission status: Accepted

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

S=collections.Counter(S)
S=S.most_common()
result = []
result.append(S[0][0])
i=1
while i <len(S):
    if S[0][1] == S[i][1]:
        result.append(S[i][0])
    
    elif S[0][1] < S[i][1]:
        break
    i+=1
result.sort()
[print(i) for i in result]

Submission status: Accepted

Solution code:
import collections
n = int(input())
a=[input() for _ in range(n)]
anslist=[]
b=collections.Counter(a)
c=max(list(b.values()))
for i in b:
    if b[i]==c:
        anslist.append(i)
d=sorted(anslist)
for i in tuple(d):
    print(i)

Submission status: Accepted

Solution code:
n = int(input())
countmax=0
anslist=[]
dic={}
for i in range(n):
    a=input()
    if a in dic:
        dic[a]+=1
    else:
        dic[a]=1
    if dic[a]>countmax:
        countmax=dic[a]
for j in dic.keys():
    if dic[j]==countmax:
        anslist.append(j)
b=sorted(anslist)
for i in b:
    print(i)

Submission status: Accepted

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

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


max_value = max(S.values())

key_li = [key for key,value in S.items() if value==max_value]

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

Submission status: Accepted

Solution code:
N=int(input())
dic={}
Mcount=1
for i in range(N):
    tmp=input()
    if tmp in dic:
        dic[tmp]+=1
        if Mcount<dic[tmp]:
            Mcount=dic[tmp]
    else:    
        dic[tmp]=1
a = sorted(dic.items(), key=lambda x: x[0])

keys = [k for k, v in dic.items() if v == Mcount]
keys.sort()
for i in keys:
    print(i)
# ['key1', 'key2']
# ['key1', 'key2']

Submission status: Accepted

Solution code:
from collections import Counter

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

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

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

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

Submission status: Accepted

Solution code:
from collections import Counter

n=int(input())
s=[ input() for i in range(n)]
dick=Counter(s)
dick=dick.most_common()
#print(dick)
#print(dick.values())
p=dick[0][1]

s=[]
for k,i in dick:
  if i==p:
    s.append(k)
  else:
    break
ss=sorted(s)
for i in ss:
  print(i)

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()) # 最頻値

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
s=[input()for _ in range(n)]
from collections import Counter
cs=Counter(s)
d=dict(cs)
a=list(d.items())
a.sort(key=lambda x:x[1])
ansc=a[-1][1]
ans=[]
while a and ansc==a[-1][1]:
    b,c=a.pop()
    ans.append(b)
ans.sort()
print(*ans,sep='\n')

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import Counter
n = int(input())
s = []
for _ in range(n):
    s.append(input())
a = Counter(s).most_common()
c = a[0][1]
ans = []
for i in a:
    if i[1] == c:
        ans.append(i[0])
ans = sorted(ans)
for j in ans:
    print(j)

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
S = []
for i in range(n):
  S.append(input())
S = sorted(S)
c = Counter(S)
X = c.most_common()
A = []
for i in range(len(X)):
  if X[0][1] == X[i][1]:
    A.append(X[i][0])
  else:
    break
A = sorted(A)
for i in range(len(A)):
  print(A[i])

Submission status: Accepted

Solution code:
N = int(input())
S =  {}
count_max = 0
for i in range(0, N):
  si = input()
  if si in S:
    S[si] = S[si] + 1
  else:
    S[si] = 1
  if S[si] > count_max:
    count_max = S[si]

arr = []
for k in S:
  if S[k] == count_max:
    arr.append(k)
    
arr.sort()
print(*arr, sep='\n')

Submission status: Accepted

Solution code:
import sys
import collections
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    s = [input() for _ in range(n)]
    cnt = collections.Counter(s)
    cnt_max = max(cnt.values())
    d = [k for k, v in cnt.items() if v == cnt_max]
    d = sorted(d)
    print(*d, sep='\n')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
A = {}
B = []
for n in range(N):
    a = input()
    B.append(a)
    A[a] = 0
for n in range(N):
    A[B[n]] += 1
res = 0
C = []
for key, value in A.items():
    if res < value:
        res = value
for key, value, in A.items():
    if res <= value:
        C.append(key)
C.sort()
for c in C:
    print(c)

Submission status: Accepted

Solution code:
import sys
import collections
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    s = [input() for _ in range(n)]
    cnt = collections.Counter(s)
    values, counts = zip(*cnt.most_common())
    d = sorted(values[:counts.count(counts[0])])
    print(*d, sep='\n')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import defaultdict

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

dic = defaultdict(int)
for each in li:
    dic[each] += 1

res = sorted(dic.items(), key=lambda x:x[1], reverse=True)
max_val = 0
res_li = []
for name, val in res:
    if val >= max_val:
        max_val = val
    if max_val == val:
        res_li.append(name)

res_li.sort()
for each in res_li:
    print(each)

Submission status: Accepted

Solution code:
import collections

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

a = collections.Counter(s)
b = a.most_common()
c = 0

for i in range(len(b)):
	if b[i][1] == b[0][1]:
		c += 1
	else:
		break

d = sorted(b[:c])

for j in range(c):
	print(d[j][0])

Submission status: Accepted

Solution code:
from collections import Counter

N = int(input())
S = sorted(Counter([input() for _ in range(N)]).items(), key=lambda x: x[0])
S = sorted(S, key=lambda x: x[1], reverse=1)
cnt_max = S[0][1]
# print(cnt_max)
for i, v in S:
    if v == cnt_max:
        print(i)

Submission status: Accepted

Solution code:
d=dict()
n=int(input())
for i in range(n):
    s=input()
    if s in d:
        # 入力した（s,1）にする
        d[s]+=1
    else:
        d[s]=1
d=list(d.items())
# 0はキー辞書順だからそのまま
d.sort(key=lambda x:x[0])
# 1は数値　昇順にしたいからリバースで
d.sort(key=lambda x:x[1],reverse=True)
m=len(d)
for i in range(m):
    # 先頭のものを先頭を出力
    if d[i][1]==d[0][1]:
        print(d[i][0])
    else:
        break

Submission status: Accepted

Solution code:
# input
n = int(input())
polls = {}

# main
for i in range(n):
  tmp = input()
  if tmp in polls:
    polls[tmp] += 1
  else:
    polls[tmp] = 1

ans = max(polls.values())
result = list(polls.items())
result.sort(key=lambda x: x[0])

# output
for d in result:
  if d[1] == ans:
    print(d[0])

Submission status: Accepted

Solution code:
N=int(input())
A=[]
Q={}
for i in range(N):
    B=input()
    A.append(B)
    Q[B]=0
    
for i in A:
    Q[i]+=1
    
a=max(Q.values())
ans=[]
for i in Q:
    if Q[i]==a:
        ans.append(i)
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 Counter
zisyo=Counter(s)
ans=[]
a=max(zisyo.values())
for i in zisyo:
  if zisyo[i]==a:
    ans.append(i)

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

Submission status: Accepted

Solution code:
import collections
import sys

input = sys.stdin.readline
N = int(input())
candidate = [input().strip("\n") for _ in range(N)]

candidate.sort()
c = collections.Counter(candidate)

MAX = c.most_common()[0][1]

l = sorted([k for k, v in c.items() if v == MAX])

for i in l:
    print(i)

Submission status: Accepted

Solution code:
N = int(input())

d = {}

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

hoge = max(d.values())

max_kv_list = [kv[0] for kv in d.items() if kv[1] == hoge]

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

Submission status: Accepted

Solution code:
from collections import defaultdict
N = int(input())
word_count = defaultdict(int)
for _ in range(N): 
    word_count[input()] += 1
max_amount = sorted(word_count.items(), key=lambda x:x[1],  reverse=True)[0][1]
max_amount_words = sorted([k for k, v in word_count.items() if v == max_amount])
print('\n'.join(max_amount_words))

Submission status: Accepted

Solution code:
import collections

def count(s):
    return collections.Counter(s).most_common()

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

ret = count(S)

max_ = 0
for i in ret:
    max_ = max(i[1], max_)
    
ans = []
for i in ret:
    if i[1] == max_:
        ans.append(i[0])
        
ans = sorted(ans)
for i in ans:
    print(i)

Submission status: Accepted

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

c = collections.Counter(s)
values, counts = zip(*c.most_common())

ss = []
for i in range(counts.count(max(counts))):
	ss.append(values[i])

ss.sort()

for sss in ss:
	print(sss)

Submission status: Accepted

Solution code:
from collections import Counter

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
s = list(read().decode().rstrip().split())

c = Counter(s)
m = max(c.values())
l = sorted([k for k, v in c.items() if v == m])
print(*l)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    indic = {}
    for _ in range(n):
        s = input()
        if s in indic:
            indic[s] += 1
        else:
            indic[s] = 1
    #print(indic)
    max_v = max(indic.values())

    ans = []
    for key in indic:
        if indic[key] == max_v:
            ans.append(key)

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

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)
mx = max(c.values())
A = [e for e,j in c.items() if j == mx]
A.sort()
for p in A:
  print(p)

Submission status: Accepted

Solution code:
import collections as clcts

N = int(input())

V = []
for i in range(N):
    V.append(input())

P = clcts.Counter(V)

W = max(P.values())
A = [i for i, j in P.items() if j == W]
A.sort()

for i in A:
    print(i)

Submission status: Accepted

Solution code:
from collections import Counter
n=int(input())
s = [input() for i in range(n)]
# 各要素の計算
calc=Counter(s)

# print(calc.most_common()[0])
m=0

for v in calc.values():
  m=max(m,v)
ans = []
for k, v in calc.items():
  if v==m:
    ans.append(k)
ans.sort()
# print(*ans, sep="\n")
print('\n'.join(ans))
# print(s)
# for i in range(len(s)):
#   print(s[i])
# print([i for i in if calc.most_common()[i][1])

Submission status: Accepted

Solution code:
from sys import stdin
input = stdin.readline
N = int(input())
S = {}
for n in range(N):
    s = input()
    if S.get(s) == None:
        S[s] = 1
    else:
        S[s] += 1
m = max(S.values())
A = [k for k,v in S.items() if v == m]
A = sorted(A)
for a in A:
    print(a.rstrip('\n'))

Submission status: Accepted

Solution code:
import collections

num_of_papers = int(input())
names = []

for _ in range(num_of_papers):
    names.append(input())

cnt = collections.defaultdict(int)
max_appearance = 0
for _ in names:
    cnt[_] = cnt[_] + 1

    if max_appearance < cnt[_]:
        max_appearance = cnt[_]

max_names = [key for key, value in cnt.items() if value == max_appearance]

max_names.sort()

for _ in max_names:
    print(_)

Submission status: Accepted

Solution code:
from collections import Counter
N=int(input())
S=[input() for i in range(N)]
s=Counter(S)
m=max(s.values())
s=sorted(s.items() ,key=lambda s:s[0])
for a in s:
    if a[1]==m:
        print(a[0])

Submission status: Accepted

Solution code:
N = int(input())

def poll(N):
    memo = {}
    max_votes = 1
    for i in range(N):
        Si = input()
        try:
            memo[Si] += 1
            max_votes = max(max_votes, memo[Si])
        except:
            memo[Si] = 1
    max_list = [key for key, value in memo.items() if value == max_votes]
    return max_list

max_list = poll(N)
max_list.sort()
for item in max_list:
    print(item)

Submission status: Accepted

Solution code:
from collections import Counter
N=int(input())
S=[input() for i in range(N)]
s=Counter(S)
m=max(s.values())
s=sorted(s.items() ,key=lambda s:s[0])
for a in s:
    if a[1]==m:
        print(a[0])

Submission status: Accepted

Solution code:
N=int(input())
S=[input() for i in range(N)]
dictionary={}
for word in S:
    if word in dictionary:
        dictionary[word]+=1
    else:
        dictionary[word]=1
maximum=max(dictionary.values())
for key,value in sorted(dictionary.items()):
    if value==maximum:
        print(key)

Submission status: Accepted

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

cc=collections.Counter(X)
maximum=max(cc.values())

ans=sorted([ss[0] for ss in cc.items() if ss[1]==maximum])
print(*ans)

Submission status: Accepted

Solution code:
from collections import Counter

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

count = Counter(s)
l = count.most_common()

for i, j in l:
    if j == l[0][1]:
        a.append(i)

a.sort()

for k in a:
    print(k)

Submission status: Accepted

Solution code:
import sys
from collections import Counter

input = sys.stdin.readline


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

    c = Counter(S)
    max_v = max(c.values())
    ans = [k for k, v in c.items() if v == max_v]
    ans.sort()

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
from collections import Counter

input = sys.stdin.readline


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

    c = Counter(S)
    max_v = max(c.values())
    ans = [k for k, v in c.items() if v == max_v]
    ans.sort()

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
from collections import Counter

input = sys.stdin.readline


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

    c = Counter(S)
    ans = []
    max_v = max(c.values())
    for k, v in c.items():
        if v == max_v:
            ans.append(k)

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
from collections import Counter

input = sys.stdin.readline


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

    c = Counter(S)
    ans = []
    prev_v = 0
    for k, v in c.most_common():
        if prev_v == 0:
            prev_v = v
        else:
            if prev_v != v:
                break
        ans.append(k)

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


if __name__ == "__main__":
    main()

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

m = max(dic.values())
arr = []

for j in dic:
    if dic[j] == m:
        arr.append(j)

arr.sort()

for k in arr:
    print(k)

Submission status: Accepted

Solution code:
# open(0)を使うことで，開業にとらわれない入力を行う
#N, *S = map(int,open(0).read().split()) # ひょっとして普通にデバッグの入力ではうまく行かないのかも
N = int(input())
S=[]
for _ in range(N):
    S.append(input())
dic = {}
for s in S:
    if not s in dic:
        dic[s] = [s,0]
    dic[s][1] += 1
#dic_swap = {v: k for k,v in dic.values()} # keyとvalueを入れ替えるdic.valuesでkeyとvalueが要素ごとに取得できることがキー
#dic_swap = {v: k for k,v in dic.values()}
dic_swap = {}
for k,v in dic.values():
    if not v in dic_swap :
        dic_swap[v] = [k]
        continue
    dic_swap[v].append(k)

key_sorted = list(dic_swap.keys())
key_sorted.sort()

v = dic_swap[key_sorted[-1]]
v = list(v)
v.sort()
for vi in v:
    print(vi)