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

def solve():
    N = int(input())
    S = [input() for i in range(N)]    
    ctr = Counter(S)
    max_cnt = max(ctr.values())
    names = [name for name, cnt in ctr.items() if cnt == max_cnt]
    names.sort()
    return names

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

Submission status: Accepted

Solution code:
N = int(input())
cnt_s = {}
for _ in range(N):
  s = input()
  if s in cnt_s:
    cnt_s[s] += 1
  else:
    cnt_s[s] = 1
  
max_cnt = max(cnt_s.values())

ans = []
for key, value in cnt_s.items():
  if value == max_cnt:
    ans.append(key)
  
[print(s) for s in sorted(ans)]

Submission status: Accepted

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

for _ in range(N):
    s = input()
    if s not in dic:
        dic[s] = 1
    else:
        dic[s] += 1
maxlist = []
# sort_dic = sorted(dic.items(), key=lambda x: x[1], reverse=True)
maxv = max(dic.values())
for di, dv in dic.items():
    if dv == maxv:
        maxlist.append(di)

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

Submission status: Accepted

Solution code:

def myAnswer(N:int,S:list) -> None:
    dic = {}
    for s in S:
        if(s in dic.keys()):
            dic[s]+=1
        else:
            dic[s] = 1
    ans = []
    dic2 = sorted(dic.items(), key=lambda x:x[1],reverse = True)
    MAX = dic2[0][1]
    for key,value in dic2:
        if(MAX == value):
            ans.append(key)
        else:
            break
    ans.sort()
    for a in ans:
        print(a)




def main():
    N = int(input())
    S = [(input()) for _ in range(N)]
    myAnswer(N,S[:])
if __name__ == '__main__':
   main()

Submission status: Accepted

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

N = int(input())

Slist = []
for i in range(N):
    Slist.append(input())
    # if S in Slist.keys():
    #     Slist[S] += 1
    #     if Slist[S] > maxNum:
    #         maxNum = Slist[S]
    # else:
    #     Slist[S] = 1
Slist.sort()

max_cnt = 1
cnt = 1
s_old = Slist[0]
max_Slist = []

for i in range(1,N):
    if Slist[i] == s_old:
        cnt += 1
    else:
        if cnt > max_cnt:
            max_cnt = cnt
            max_Slist = [s_old]
        elif cnt == max_cnt:
            max_Slist.append(s_old)
        s_old = Slist[i]
        cnt = 1

if Slist[N-1] == s_old:
    if cnt > max_cnt:
        max_Slist = [s_old]
    elif cnt == max_cnt:
        max_Slist.append(s_old)

for str in max_Slist:
    print(str)

Submission status: Accepted

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

N = int(input())

Slist = []
for i in range(N):
    Slist.append(input())
    # if S in Slist.keys():
    #     Slist[S] += 1
    #     if Slist[S] > maxNum:
    #         maxNum = Slist[S]
    # else:
    #     Slist[S] = 1
Slist.sort()

max_cnt = 1
cnt = 1
s_old = Slist[0]
max_Slist = []

for i in range(1,N):
    if Slist[i] == s_old:
        cnt += 1
    else:
        if cnt > max_cnt:
            max_cnt = cnt
            max_Slist = [s_old]
        elif cnt == max_cnt:
            max_Slist.append(s_old)
        s_old = Slist[i]
        cnt = 1

if Slist[N-1] == s_old:
    if cnt > max_cnt:
        max_Slist = [s_old]
    elif cnt == max_cnt:
        max_Slist.append(s_old)

for str in max_Slist:
    print(str)

Submission status: Accepted

Solution code:
from collections import defaultdict
dic = defaultdict(int)

n = int(input())
A = [input() for i in range(n)]
for elem in A:
    dic[elem] += 1
# print(dic)
m = max(dic.values())
# print(m)

Ans = []
for key in dic:
    # print(dic[key])
    if dic[key] == m:
        Ans.append(key)

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

Submission status: Accepted

Solution code:
n = int(input())
d = {}
for i in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d.setdefault(s,1)
#d_keysort = sorted(d.items(), key=lambda x:x[0])[0]
mx = max(d.values())
ans_list = [k for k, v in d.items() if v == mx]
ans_list.sort()
for i in range(len(ans_list)):
         print(ans_list[i])

Submission status: Accepted

Solution code:
from collections import Counter


def solve():
    N = int(input())
    S = Counter(input() for _ in range(N))
    max_app = max(S.values())
    print('\n'.join(sorted(k for k, v in S.items() if v == max_app)))


if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
from collections import Counter


N = int(input())
S = Counter(input() for _ in range(N))
max_app = max(S.values())
print('\n'.join(sorted(k for k, v in S.items() if v == max_app)))

Submission status: Accepted

Solution code:
from collections import Counter


N = int(input())
S = Counter(input() for _ in range(N))
max_app = max(S.values())
ans = sorted(k for k, v in S.items() if v == max_app)
[print(string) for string in ans]

Submission status: Accepted

Solution code:
n=int(input())
s = {}
for i in range(n):
    ss = input()
    if ss in s:
        s[ss] += 1
    else:
        s[ss] = 1
s2 = sorted(s.items(),key=lambda x:x[1], reverse = True)
ans = []
va = -1
for key,value in s2:
    if va == -1:
        va = value
        ans.append(key)
    else:
        if va == value:
            ans.append(key)

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

Submission status: Accepted

Solution code:
from collections import defaultdict

n = int(input())
d = defaultdict(int)
for i in range(n):
	s = input()
	d[s] += 1
l = sorted(d.items(), key=lambda x: (-x[1], x[0]))
m = l[0][1]

for i in range(len(l)):
	if l[i][1] == m:
			print(l[i][0])
	else:
		break

Submission status: Accepted

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

import collections
c = collections.Counter(S)
c = c.most_common()

ans = [c[0][0]]

for i in range(len(c)-1):
    if c[i][1] == c[i+1][1]:
        ans.append(c[i+1][0])
    else:
        break
        
ans = sorted(ans)
        
print("\n".join(ans))

Submission status: Accepted

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

M=max(d.values())
d1 = sorted(d.items())
for i,k in d1:
    if k==M:
        print(i)

Submission status: Accepted

Solution code:
import collections
N=int(input())
S=[]
for i in range(N):
   S.append(str(input())) 
c=collections.Counter(S)
c_sorted=sorted(c.items())
s=max(c.values())
for i in c_sorted:
    if i[1]==s:
        print(i[0])

Submission status: Accepted

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


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter


def main():
    N = int(input())
    S = [input() for _ in range(N)]
    c = Counter(S).most_common()
    ans = []
    for item in c:
        if c[0][1] == item[1]:
            ans.append(item[0])
        else:
            break
    ans.sort()

    for i in ans:
        print(i)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N=int(input())
S=[]
for i in range(N):
  S.append(input())  
  
dic={}
for s in S:
  if s in dic:
    dic[s]=dic[s]+1
  else:
    dic[s]=1
num=max(dic.values())
[print(k) for k, v in sorted(dic.items()) if v==num]

Submission status: Accepted

Solution code:
from collections import Counter

# input
N = int(input())
S = []
s_append = S.append

for i in range(N):
    s = input()
    s_append(s)

# check
s_counter = Counter(S)
max = max(s_counter.values())

printed_items = []
append = printed_items.append
max_s = [s[0] for s in s_counter.items() if s[1] == max]
for i in sorted(max_s):
    print(i)

Submission status: Accepted

Solution code:
from collections import Counter

c = Counter(input() for _ in range(int(input())))
m = max(c.values())
for s in sorted(s for s, k in c.items() if k == m): 
  print(s)

Submission status: Accepted

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

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())
ans=[]
for s in dic:
    if dic[s]==m:
        ans.append(s)
ans.sort()
for s in ans:
    print(s)

Submission status: Accepted

Solution code:
import collections

n = int(input())
l = []*n

for x in range(0, n) :
    l.append(input())

l_sorted = sorted(l)
c = collections.Counter(l_sorted)
mc = c.most_common()

pre_v = 0
ans = []
for m in mc :
    k = m[0]
    v = m[1]
    if v < pre_v :
        break
    pre_v = v
    ans.append(k)

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

Submission status: Accepted

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

for _ in range(N):
  inp = input()
  if inp not in dic:
    dic[inp] = 1
  else:
    dic[inp] = dic[inp] + 1

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

Submission status: Accepted

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

cnt = collections.Counter(S)
m = max(cnt.values())

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

Submission status: Accepted

Solution code:
N=int(input())
l={}
ans =[]
 
"""for i in range(N):
  s=input()
  if s in l:
    l[s]+=1
  else:
    l[s]=1
print(l)"""
for i in range(N):
    s=input()
    if s in l:
        l[s]+=1
    else:
        l[s]=1
#print(l)
num = max(l.values())
#print(max)
for i in l:
    #print(l[i])
    if l[i]==num:
      ans.append(i)
b = sorted(ans)
for i in b:
    print(i)

Submission status: Accepted

Solution code:
N = int(input())
dic = {}
for i in range(1,N+1):
    key = input()
    if key not in dic:
        dic[key] = 1
    else:
        dic[key] += 1
lis = []
for key,val in dic.items():
    lis.append([val,key])
lis.sort(reverse = True)

lis2 = []
fnum = lis[0][0]

for j in range(0,len(lis)): 
    if lis[j][0] == fnum:
        lis2.append(lis[j][1])
    else:
        break
lis2.sort()
for k in lis2:
    print(k)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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


# l=sorted(l,key=lambda x:x[1])

# ma=max(l)
max_value=max(l.values())
# max_value=0
# for i in l:
#   if max_value<l[i]:
#     max_value=l[i]

ans=[]

for i in l:
  if max_value==l[i]:
    ans.append(i)
ans.sort()

for i in ans:
  print(i)

Submission status: Accepted

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

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


# l=sorted(l,key=lambda x:x[1])

# ma=max(l)
# max_value=l[ma]
max_value=0
for i in l:
  if max_value<l[i]:
    max_value=l[i]
# print(max_value)

ans=[]

for i in l:
  if max_value==l[i]:
    ans.append(i)
ans.sort()

for i in ans:
  print(i)

Submission status: Accepted

Solution code:
N = int(input())

polls = {}
result = []

for k in range(N):
    S_k = input()
    if (S_k in polls):
        # 既に存在する場合 -> 値を+1
        polls[S_k] = str(int(polls[S_k]) + 1)
    else:
        # 存在していない場合 -> キーを新規作成し値を1にする
        polls[S_k] = "1"

max = 0
# 最大の値を取得する
for key in polls:
    if(max < int(polls[key])):
        max = int(polls[key])

for key in polls:
    if(max == int(polls[key])):
        result.append(key)

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

Submission status: Accepted

Solution code:
n = int(input())
s = []
for i in range(n):
  s.append(input())
s.sort()
k = 0
f = s
mk = 0
for i in range(n-1):
  if s[i] == s[i+1]:
    k = k+1
    if k == mk :
      mk = k
      f.append(s[i])
    elif k > mk :
      mk = k
      f = [s[i]]
  else:
    k = 0
for i in range(len(f)):
  print(f[i])

Submission status: Accepted

Solution code:
from collections import Counter
def solve():
    N = int(input())
    S = tuple(input() for _ in range(N))
    a = Counter(S).most_common()
    max = a[0][1]
    count = 0
    ans = set()
    for i,j in a:
        if j < max:
            break
        ans.add(i)
        count += 1
    ans = sorted(ans)
    print("\n".join(ans))
if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from collections import Counter
N = int(input())
S = []
for i in range(N):
    s = input()
    S.append(s)
S = Counter(S).most_common()
a = []
b = []
for i in S:
    a.append(i[0])
    b.append(i[1])
c = []
for i in range(b.count(max(b))):
    c.append(a[i])
c.sort()
print(*c, sep="\n")

Submission status: Accepted

Solution code:
# coding: utf-8
import sys
from collections import Counter

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
S = [sr() for _ in range(N)]
counter = Counter(S)
mo = counter.most_common()
ma = mo[0][1]
answer = []
for k, v in mo:
    if v == ma:
        answer.append(k)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

n = int(input())
dic = {}
b = []
for i in range(n):
    a = input()
    b.append(a)
for o in b:
    if o in dic:
        dic[o] += 1
    else:
        dic[o] = 1
M = max(dic.values())
for j,k in sorted(dic.items()):
    if k == M:
        print(j)

Submission status: Accepted

Solution code:
import math
import sys
n = int(input())
li=[input()]
for i in range(n-1):
    li.append(input())
li.sort()
cnt = 0
tmp = 1
li.append('')
for i in range(n):
    if (li[i] == li[i + 1]):
        tmp += 1
    else:
        if(cnt<tmp):
            cnt=tmp
        tmp = 1
tmp=1
for i in range(n):
    if (li[i] == li[i + 1]):
        tmp += 1
    else:
        if (cnt == tmp):
                print(li[i])
        tmp = 1

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
dict={}
n=int(input())
for i in range(n):
    s=input()
    if s in dict:
        dict[s]+=1
    else:
        dict.setdefault(s,0)
itemMaxValue = max(dict.items(), key=lambda x: x[1])
listOfKeys = []

for key, value in dict.items():
    if value == itemMaxValue[1]:
        listOfKeys.append(key)
        
listOfKeys.sort()
for x in listOfKeys:
    print(x)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from collections import Counter
N = int(input())
S = []
U = []
X = []
Y = []
for i in range(N):
    s = input()
    S.append(s)
S = Counter(S)
for i in S.most_common():
    X.append(i[0])
    U.append(i[1])
for i in range(U.count(max(U))):
    Y.append(X[i])
Y.sort()
print(*Y, sep = "\n")

Submission status: Accepted

Solution code:
n = int(input())
d = {}
for i in range(n):
  s = input()
  d[s] = d.get(s, 0) + 1
m = max(d.values())
maxKeys = [x[0] for x in d.items() if x[1] == m]
so = sorted(maxKeys)
for e in so:
  print(e)

Submission status: Accepted

Solution code:
from collections import defaultdict
N = int(input())
touhyou = defaultdict(int)
for _ in range(N):
    s = input()
    touhyou[s] +=1
touhyou1=dict(sorted(touhyou.items(),key = lambda x: x[1],reverse = True))
maxn=max(touhyou1.values())
ans=[]
for key,val in zip(touhyou1.keys(),touhyou1.values()):
    if val == maxn:
        ans.append(key)

ans=sorted(ans)

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

Submission status: Accepted

Solution code:
import collections
n = int(input())
a = [input() for hoge in range(n)]
counted = collections.Counter(a)
m = max(counted.values())
chars = [key for key, value in counted.items()
             if value == m]
c = sorted(chars)
for poge in c:
  print(poge)

Submission status: Accepted

Solution code:
n = int(input())
ss = []

for _ in range(n):
    ss.append(input())

d = {}
m = 0

for s in ss:
    if s not in d:
        d[s] = 1
    else:
        d[s] += 1
    m = max(d[s], m)

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

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

Submission status: Accepted

Solution code:
N = int(input())
S = [input() for _ in range(N)]
dictionary = {}
for word in S:
  if word in dictionary:
    dictionary[word] += 1 #辞書の中にその言葉があったら、keyを+1
  else:
    dictionary[word] = 1#無いなら、その言葉を登録して,keyを1にする
maximum = max(dictionary.values()) #辞書のkeyの最大値を返す
for key,value in sorted(dictionary.items()): #keyとvalueの両方に対してfor文
  if value == maximum:
    print(key)

Submission status: Accepted

Solution code:
from collections import Counter as C
n = int(input())
ll = [input() for _ in [0]*n]
p = dict(C(ll))
i = max(p.values())
ld = [x for x in p if p[x] == i]
[print(x) for x in sorted(ld)]

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())
l = []
for a,b in d.items():
  if b == m:
    l.append(a)
l.sort()
for i in l:
  print(i)

Submission status: Accepted

Solution code:
from collections import Counter

N=int(input())

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

c = Counter(Words)

max_value = max(c.values())

word_list=[i[0] for i in c.most_common() if i[1] == max_value]

for k in sorted(word_list):
    print(k)

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())
s = [input() for _ in range(n)]
smax = max(Counter(s).values())
kmax = [k for k, v in Counter(s).items() if v == smax]
print("\n".join(sorted(kmax)))

Submission status: Accepted

Solution code:
import sys
import collections

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

count = collections.Counter(s)

c = count.most_common()
num = c[0][1]

ans = []
for i,v in c:
	if v == num:
		ans.append(i)
ans.sort()
for i in range(len(ans)):
	print(ans[i])

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
l = []
for i in range(n):
  l.append(input())
c = Counter(l)
t = c.most_common()
x = 0
ans = []
for k,v in t:
  if x <= v:
    ans.append(k)
    x = v
ans.sort()
for i in range(len(ans)):
  print(ans[i])

Submission status: Accepted

Solution code:
N = int(input())
d = {}
for i in range(N):
    s = str(input())
    if not s in d:
        d[s] = 1
    else:
        d[s] = d[s] + 1
max = 0
res = []
for key in d:
    num = d[key]
    if num < max:
        continue
    elif num == max:
        res.append(key)
    else:
        max = num
        res = [key]
res.sort()
for r in res:
    print(r)

Submission status: Accepted

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

import collections
u = collections.Counter(s)

m = max(u.values())
v = []
for j in list(u.items()):
    if j[1] == m:
        v.append(j[0])   

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

Submission status: Accepted

Solution code:
#詳しくはcollections pythonで検索。出てきた文字列の数をカウントする。
from collections import Counter
#入力。文字列は扱いやすくするためリスト化した。
#先に空のリスト作らないとリストに入れられないので作る。
N = int(input())
S = [None for _ in range(N)]
for i in range(N):
  S[i] = input()
#出てきた要素とその数をリストに記録。
count = Counter(S)
countkey = list(count.keys())
countval = list(count.values())
#出てきた要素をリストに記録しその数をlcvとする。
lcv = len(countkey)
#再頻出の要素の出現回数を記録。
maxval = max(countval)
#出現回数が最大の要素を記録するためのリストを作製。
Se = [None for _ in range(N)]
#出現回数が最大の要素を記録。
for i in range(lcv):
  if countval[i] == maxval:
    Se[i] = countkey[i]
#記録された要素のみ抽出。型が全てstr型なので一発。
Seprint = [se for se in Se if type(se) == str]
#辞書順に並べろとのことなので並び替え。
Seprint = sorted(Seprint)
#改行して出力するため、最後に残った要素の数を調べる。
lSe = len(Seprint)
#結果
for i in range(lSe):
  print(Seprint[i])

Submission status: Accepted

Solution code:
#詳しくはcollections pythonで検索。出てきた文字列の数をカウントする。
from collections import Counter
#入力。文字列は扱いやすくするためリスト化した。
#先に空のリスト作らないとリストに入れられないので作る。
N = int(input())
S = [None for _ in range(N)]
for i in range(N):
  S[i] = input()
count = Counter(S)
countkey = list(count.keys())
countval = list(count.values())
lcv = len(countval)
maxval = max(countval)
Se = [None for _ in range(N)]
for i in range(lcv):
  if countval[i] == maxval:
    Se[i] = countkey[i]
Seprint = [se for se in Se if type(se) == str]
Seprint = sorted(Seprint)
lSe = len(Seprint)
for i in range(lSe):
  print(Seprint[i])

Submission status: Accepted

Solution code:
from collections import Counter

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

c =Counter(s)
c2 = c.most_common()
a = c2[0][1]
ans = []

for i in range(len(c)):
    if c2[i][1] == a:
        ans.append(c2[i][0])
ans.sort()
print(*ans,sep="\n")

Submission status: Accepted

Solution code:
import collections

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

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

max_c = [c2[0][0]]
#print(len(c.values()))

for i in range(len(c.values())-1):
    if c2[i][1] == c2[i+1][1]:
        max_c.append(c2[i+1][0])
    else :
        break

max_c= sorted(max_c)

for i in max_c:
    print(i)

Submission status: Accepted

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

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

M = max(d.values())

ans_list = []
for k,v in d.items():
    if v == M:
        ans_list.append(k)

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

Submission status: Accepted

Solution code:
import collections

N = int(input())
s_list = []
for i in range(N):
    s_list.append(input())
dict = collections.Counter(s_list)
max_num = 0
for i in dict.values():
    max_num = max(max_num,i)
top_vote = []
for i,j in dict.items():
    if j == max_num:
        top_vote.append(i)
top_vote.sort()
for i in top_vote:
    print(i)

Submission status: Accepted

Solution code:
import collections

n = int(input())
s = [input() for i in range(n)]
t = collections.Counter(s)
tm = t.most_common()
x = [tm[i][0] for i in range(len(tm)) if tm[i][1]==tm[0][1]]
x.sort()
for i in range(len(x)):
    print(x[i])

Submission status: Accepted

Solution code:
from collections import defaultdict

d = defaultdict(lambda: 0)
N = int(input())
max = 0
for _ in range(N):
    word = input()
    new_value = d[word] + 1
    if new_value > max:
        max = new_value
    d[word] = new_value

result = []
for key in d:
    if d[key] == max:
        result.append(key)

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

Submission status: Accepted

Solution code:
import collections

N = int(input())

chars = [input() for _ in range(N)]
char_counts = collections.Counter(chars)

max_count = max(char_counts.values())
max_count_chars = sorted([key for key, value in char_counts.items() if value == max_count])

for char in max_count_chars:
  print(char)

Submission status: Accepted

Solution code:

from collections import Counter

n = int(input())
s = [input() for i in range(n)]
c = Counter(s)
C = c.most_common()
a = C[0][1]
ans = []
for i in range(len(c)):
  if C[i][1] == a:
    ans.append(C[i][0])

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

Submission status: Accepted

Solution code:
n = int(input())
l = [input() for i in range(n)]
d={}

for i in range(len(l)):
    if l[i] in d:
        d[l[i]]+=1
    else:
        d[l[i]]=1

largest=max(d.values())
ans=[]
for key in d.keys():
    if d[key]==largest:
        ans.append(key)
ans=sorted(ans)
for word in ans:
    print(word)

Submission status: Accepted

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

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

M = max(d.values())

ans_list = []
for k,v in d.items():
    if v == M:
        ans_list.append(k)

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

Submission status: Accepted

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

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

M = max(d.values())
ans = []
for k,v in d.items():
    if v == M:
        ans.append(k)

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

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

A = {}
for i in S:
    A.setdefault(i, 1)
    A[i] += 1

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:
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:
def solve():
    names = {}
    for si in s:
        if si in names:
            names[si]+=1
        else:
            names[si] = 1
    maxi = 0
    winners = []
    for n in names:
        maxi = max(maxi, names[n])
    for n in names:
        if names[n] == maxi:
            winners.append(n)
    winners.sort()
    for winner in winners:
        print(winner)
    return



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

# n, m = [int(s) for s in input().split(" ")]
solve()

Submission status: Accepted

Solution code:
#https://atcoder.jp/contests/abc155/tasks/abc155_c
import collections
n=int(input())
s=[]
for i in range(n):
    s.append(input())
c = collections.Counter(s)#出現回数順に並び替える
count=max(c.values())#最大出現回数をcountで保持
l=[]
for key, value in c.items():
    if value==count:
        l.append(key)
l.sort()
for x in l:
    print(x)

Submission status: Accepted

Solution code:
N = int(input())
a = [input()for i in range(N)]
p = []
a.sort()
q = 1
for i  in range(N-1):
    if a[i] == a[i+1]:
        q = q+1
    else:
        p.append([q,a[i]])
        q = 1
p.append([q,a[N-1]])
s = 0
for i in range(len(p)):
    s = max(s,p[i][0])
for i in range(len(p)):
    if p[i][0] == s:
        print(p[i][1])

Submission status: Accepted

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

m=0
ans=[]
for k,v in c:
  if v>=m:
    ans.append(k)
    m=v
ans.sort()
print(*ans,sep='\n')

Submission status: Accepted

Solution code:
n = int(input())
a = [input() for _ in range(n)]
dic = {}
for x in a:
    if x not in dic:
        dic[x] = 0
for x in a:
    dic[x] += 1
dic = sorted(dic.items(),reverse = True ,key = lambda x : x[1])
res = []
maxv = dic[0][1]
for i in range(len(dic)):
    if maxv == dic[i][1]:
        res.append(dic[i][0])
resN = sorted(res)
[print(x) for x in resN]

Submission status: Accepted

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

s_unique = list(set(s))

dic = {}
for u in s_unique:
    dic[u] = 0

for word in s:
    dic[word] += 1

max = max(dic.values())

l = []
for u in s_unique:
    l.append([dic[u], u])

l.sort(reverse=True)

l_ans = []
for a in l:
    if a[0] != max:
        continue
    l_ans.append(a[1])

l_ans.sort()

for ans in l_ans:
    print(ans)

Submission status: Accepted

Solution code:
N = int(input())
S = [str(input()) for i in range(N)]
dic = {}
for a in S:
    if a not in dic:
        dic[a] = 1
    else:
        dic[a] += 1
m = max(dic.values())
max_list = [kv[0] for kv in dic.items() if kv[1] == m]
max_list.sort()
for a in max_list:
    print(a)

Submission status: Accepted

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

word = {}
for i in range(N):
    if L[i] in word:
        word[L[i]] += 1
    else:
        word[L[i]] = 1

max_count = 0
for i in range(N):
    max_count = max(max_count, word[L[i]])
    
ans = []
for i in range(N):
    if word[L[i]] == max_count:
        ans.append(L[i])
  
ans = list(set(ans))
ans.sort()

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

Submission status: Accepted

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

import collections

N = int(input())
S = [input() for i in range(N)]
S_count = collections.Counter(S)
S_most = S_count.most_common()
a, b = S_most[0]
ans = []

for i, j in S_most:
    if j == b:
        ans.append(i)
for i in sorted(ans):
    print(i)

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

max_val = max(D.values())
D = sorted(D.items(),key=lambda x:(-x[1],x[0]))
for key,val in D:
    if val==max_val:
        print(key)
    else:
        exit()

Submission status: Accepted

Solution code:
import collections
N = int(input())
S = [input() for i in range(N)]
c = collections.Counter(S)
l = c.most_common()
n, m = l[0]
ans = []
for i, j in l:
    if j == m:
        ans.append(i)
for a in sorted(ans):
    print(a)

Submission status: Accepted

Solution code:
#bA
import collections
N = int(input())
S = [input() for i in range(N)]
s = collections.Counter(S) #出現回数をまとめた辞書型作成

maximum = max(s.values()) #
list = sorted(key for key,value in s.items() if value==maximum)
#sを利用して、出現回数が最大のものを辞書順に並べたリストを作成

for i in list:
    print(i)