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: Runtime Error

Solution code:
def v_count(l, v):
  n = 0
  while v in l:
    l.remove(v)
    n += 1
  return n

def main():
  N = int(input())
  S = [input() for i in range(N)]
  result = []
  max = 0
  while len(S) > 0:
    buf = S[0]
    n = v_count(S, buf)
    print(S)
    if n > max:
      max = n
      result = [buf]
    elif n == max:
      result.append(buf)
      
  result.sort()

  for s in result:
    print(s)

main()

Submission status: Runtime Error

Solution code:
n = int(input())
S = []
for i in range(n):
  S.append(input())
T = list(set(S))
for i in range(len(T)):
  count.append(S.count(T[i]))
best = max(count)
ans = []
for i in range(len(T)):
  if count[i] == best:
    ans.append( T[i])
ans = sorted(ans)
for i in range(len(ans)):
  print(ans[i])

Submission status: Runtime Error

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: Runtime Error

Solution code:
import collections
n=int(input())
ans=[]
s=["".join(sorted(input())) for _ in range(n)]
c=collections.Counter(s)
m=max(c.values())
for k,v in c.items:
  if v==m:
    ans.append(k)

print(sorted(k))

Submission status: Runtime Error

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

L=[(v,k) for (k,v) in d.items()]
L.sort(reverse=True)
max_cnt=L[0][0]
#print('*'*30)
ans=[]
for l in L:
    if l[0]==max_cnt:
        ans.append(l[1])
    else :
        break

for a in ans:
    print(ans)

Submission status: Runtime Error

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

if len(S) == len(set(S)):
  ans = S
else:
  ans = []
  c = collections.Counter(S)
  c_common = c.most_common()
  max_vote = c_common[0][1]
  for k in range(len(S)):
    if c_common[k][1]== max_vote:
      ans.append(c_common[k][0])
    else:
      break
[print(a) for a in sorted(ans)]

Submission status: Runtime Error

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

import collections

counter = Counter(S)

max_cnt = max(counter.values())

names = [n for n,c in counter.items() if c==max_cnt]
names.sort()
print(*names, sep='\n')

Submission status: Runtime Error

Solution code:
import collections

N = int(input())
S = [input() for _ in range(N)]
S.sort()
c = collections.Counter(S)
a = [c.most_common()[0][0]]
i = 0
if len(c) != 1:
    while c.most_common()[i][1] == c.most_common()[i + 1][1]:
        a.append(c.most_common()[i + 1][0])
        i += 1
for p in a:
    print(p)

Submission status: Runtime Error

Solution code:
import sys


def main():
    readline = sys.stdin.readline
    N = int(readline())
    li = list(readline().split("\n"))
    se = set(li)
    l = len(se)
    li2 = [[s, li.count(s)] for s in se].sort(key=lambda x:x[1])
    maxcount = li2[l - 1][1]
    li3 = [j[0] for j in li2 if j[1] == maxcount].sort()
    for k in li3:
        print(k)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

kensaku = list(set(h))
result = 0
list = []
#print(kensaku)
for i in range(len(kensaku)):
    

    if h.count(kensaku[i]) > result:
        result = h.count(kensaku[i])
        list = []
        list.append(kensaku[i])
    elif h.count(kensaku[i]) == result:
        
        list.append(kensaku[i])
        list.sorted()

#print(list)

for h in range(len(list)):
    print(list[h])

Submission status: Runtime Error

Solution code:
import collections

N = int(input())
S = [input() for _ in range(N)]
S.sort()
c = collections.Counter(S)
a = [c.most_common()[0][0]]
i = 0
if len(c) != 1:
    while c.most_common()[i][1] == c.most_common()[i + 1][1]:
        a.append(c.most_common()[i + 1][0])
        i += 1

print(a)

Submission status: Runtime Error

Solution code:
import collections

N = int(input())
S = [input() for _ in range(N)]
S.sort()
c = collections.Counter(S)
a = [c.most_common()[0][0]]
i=0
while c.most_common()[i][1] == c.most_common()[i + 1][1]:
    a.append(c.most_common()[i + 1][0])
    i += 1

print(a)

Submission status: Runtime Error

Solution code:
from collections import Counter
N = int(input())
S = counter([input() for i in range(N)])
most = S.most_common()[0][1]
ans = []
for name num in S.items:
  if num != most:
    break
  ans.append(name)
ans.sort()
for a in ans:
  print(a)

Submission status: Runtime Error

Solution code:
import collections
from collections import Counter
n=int(input())
s=[input() for i in range(n)]
s=Counter(s)
p=[]
k=s.most_common()
p.append(k[0][0])
for i in range(len(collections.Counter(s))-1):
    if k[i][1]==k[i+1][1]:
        p.append(k[i+2][0])
    else:
        break
p=sorted(p)
for i in range(len(p)):
    print(p[i])

Submission status: Runtime Error

Solution code:
import collections
from collections import Counter
n=int(input())
s=[input() for i in range(n)]
s=Counter(s)
p=[]
k=s.most_common()
p.append(s.most_common()[0][0])
for i in range(len(collections.Counter(s))-1):
    if k[i+1][1]==k[i+2][1]:
        p.append(k[i+2][1])
    else:
        break
p=sorted(p)
for i in range(len(p)):
    print(p[i])

Submission status: Runtime Error

Solution code:
from collections import Counter
n=int(input())
s=[input() for i in range(n)]
s=Counter(s)
p=[]
p.append(s.most_common()[0][0])
for i in range(n-2):
    if s.most_common(i+1)[i][1]==s.most_common(i+2)[i+1][1]:
        p.append(s.most_common(i+2)[i+1][0])
    else:
        break
p=sorted(p)
for i in range(len(p)):
    print(p[i])

Submission status: Runtime Error

Solution code:
from collections import Counter
n=int(input())
s=[input() for i in range(n)]
s=Counter(s)
p=[]
p.append(s.most_common()[0][0])
for i in range(n):
    if s.most_common(i+1)[i][1]==s.most_common(i+2)[i+1][1]:
        p.append(s.most_common(i+2)[i+1][0])
    else:
        break
p=sorted(p)
for i in range(len(p)):
    print(p[i])

Submission status: Runtime Error

Solution code:
n = int(input())
s = [input() for i in range(n)]
ss = sorted(set(s))
l = len(ss)
if len(s)==l:
    for i in ss:
        print(s)
else:
    d = []
    for i in ss:
        d.append([i,0])
    for i in s:
        d[ss.index(i)][1]+=1
    d = sorted(d, key = lambda x:(-x[1],x[0]))
    for i in d:
        if i[1]==d[0][1]:
            print(i[0])

Submission status: Runtime Error

Solution code:
N = int(input())
A = [input() for i in range(N)]
B = list(set(A))
C = [0]*len(B)
for i in range(len(B)):
  C[i] = A.count(B[i])
D = max(C)
for s in sorted([B[i] for i, x in enumerate(C) if x == D]):
　print(s)

Submission status: Runtime Error

Solution code:
N = int(input())
A = [input() for i in range(N)]
B = list(set(A))
C = [0]*len(B)
for i in range(len(B)):
  C[i] = A.count(B[i])
#ここでなんかいもよびだしている
D = max(C)
for s in sorted([B[i] for i, x in enumerate(C) if x == D]:
    print(s)

Submission status: Runtime Error

Solution code:

import collections

rl = sys.stdin.readline

n = int(rl())

li = []
for _ in range(n):
    li.append(rl().rstrip())
c = collections.Counter(li)
max_cnt = 0
li = []
for k, v in c.items():
    if v < max_cnt:
        continue
    elif v == max_cnt:
        li.append(k)
    else:
        max_cnt = v
        li = [k]
li.sort()
print('\n'.join(li))

Submission status: Runtime Error

Solution code:
from collections import Counter
N = int(input())
L = [str(input()) for i in range(N)]
Lc = Counter(L).most_common()
Llist = []             
L_max = Lc[0][1]       
i = 0
while True:
  Llist.append(Lc[i][0])
  if Lc[i+1][1]==L_max:
    i+=1
  else:
    break
print("\n".join(sorted(Llist)))

Submission status: Runtime Error

Solution code:
n = int(input())

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



max_s_val = max(s.value())
t = [k for k, v in s.items() if v == max_s_val]
t.sort()

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

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <set>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;

int main(){
    int N;
    cin >> N;
    string S[N];
    for(int i=0; i<N; i++){
        cin >> S[i];
    }
    sort(S, S+N);
    int vote[200010]={0};
    int max_vote=0;
    for(int i=0; i<N; i++){
        for(int j=i+1; j<N; j++){
            if(S[j]==S[i]){
                vote[i]++;
                max_vote = max(vote[i], max_vote);
            }
        }
    }

    for(int i=0; i<N; i++){
        if(vote[i]==max_vote){
            cout << S[i] << endl;
        }
    }
    return 0;
}

Submission status: Runtime Error

Solution code:
n=int(input())
l={}
ans=[]
for i in range(n):
    s=input()
    if s in l:
        l[s]+=1
    else:
        l.setdefault(s,1)
max_l=max(l.values)

for i in l.keys():
  if l[i]==max_l:
    ans.append(i)
    
ans.sort()
 
for j in ans:
  print(j)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys
from collections import Counter
readline = sys.stdin.buffer.readline # 一行読み込み

n=int(input())
s=["".join(readline().rstrip()) for _ in range(n)]
print(s)

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

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

Submission status: Runtime Error

Solution code:

import sys
from collections import Counter
readline = sys.stdin.buffer.readline # 一行読み込み

n=int(input())
s=["".join(readline().rstrip()) for _ in range(n)]
print(s)

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

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

Submission status: Runtime Error

Solution code:

from collections import Counter

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

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

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

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

Solution code:
import collections
n=int(input())
s=[]
for _ in range(n):
    s.append(str(input()))
ans=collections.Counter(s)
a=max(ans.values())
ans=[i for i,k in ans.items() if a==k]
print(*ans.sort(),sep="\n")

Submission status: Runtime Error

Solution code:
import collections
n=int(input())
s=[]
for _ in range(n):
    s.append(str(input()))
ans=collections.Counter(s)
values,count=zip(*ans)
for l in range(len(count)):
    if max(count)==count[l]:
        print(values[l])

Submission status: Runtime Error

Solution code:
n = int(input())
L = sorted(input() for _ in range(n))
s = sorted(set(L))
c = [0] * len(s)
prev = 0
cnt = 1
l = 0
for i in range(len(L)):
    if L[i] == prev:
        cnt += 1
    else:
        c[l] = cnt
        l += 1
        cnt = 1
m = max(c)
for j in range(len(c)):
    if c[j] == m:
        print(s[j])

Submission status: Runtime Error

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

c = Counter(s)
ma = max(c.values())
for k,v in c:
  if ma == v:
    print(k)

Submission status: Runtime Error

Solution code:
n = int(input())

dic = {}
for _ in range(n):
    s = input()
    dic[s] = dic.get(s, 0) + 1

c = collections.Counter(dic)

print("\n".join(sorted([ k for k,v in c.items() if v == max(c.values()) ])))

Submission status: Runtime Error

Solution code:
n = int(input())

l = [0] * n
for i in range(n):
    l[i] = input()

k = set(l)
m = 0
ans = []

for i in k:
    cnt = l.count(i)
    if cnt > m:
        m = cnt
        ans.clear()
        ans.append(i)
    elif cnt == m:
        ans.append(i)

ans.sort()

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

Submission status: Runtime Error

Solution code:
n = int(input())

l = [0] * n
for i in range(n):
    l[i] = input()

k = set(l)
m = 0
ans = []

for i in k:
    cnt = l.count(i)
    if cnt > m:
        m = cnt
        ans.clear()
        ans.append(i)
    elif cnt == m:
        ans.append(i)

ans.sort()

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

Submission status: Runtime Error

Solution code:
N=int(input())
A=[list(map(int,input().split())) for i in range(N)]
D=dict()
C=[]
for i in set(A):
    D[i]=0
for i in A:
    D[i]+=1
ans=0
for i in D.keys():
    if D[i]==max(D.values()):
        C.append(i)
C=sorted(C)
print(*C,sep='\n')

Submission status: Runtime Error

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())

import pandas as pd
n = int(input())
s = [input() for i in range(n)]
d = pd.Series(s).value_counts()
print('\n'.join(sorted(list(d[d==max(d)].index))))

Submission status: Runtime Error

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(N):
  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: Runtime Error

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 = []
for i in res_dict.keys():
  if res_dict[i] == max(res_dict.values()):
    res_name.append(i)
res_name = sorted(res_name)
for i in res_name:
  print(i)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import collections

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

for i in range(N):
    a.append(str(input()))
a = collections.Counter(a)
b = max(a.values())

max_k_list = [kv[0] for kv in a.items() if kv[1] == b]
max_k_list = sorted(max_k_list)

for i in max_k_list:
print(i)

Submission status: Runtime Error

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(n):
    if cntList[i][1] == cnt_f:
        resList.append(cntList[i][0])
    else:
        break

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

Submission status: Runtime Error

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
from collections import Counter
def resolve():
    n=int(input())
    l=[input() for i in range(n)]
    l.sort()
    setl = list(set(l))
    setl.sort()
    c=Counter(l)
    ll=[*c.values()]
    for i in range(len(setl)):
        if ll[i]==max(ll):
            print(setl[i])
resolve()

Submission status: Runtime Error

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 most_common:
  if cc[1]==max:
    print(cc[0])

Submission status: Runtime Error

Solution code:
n=int(input())
s=[input() for x in range(n)]
l=list(set(s))
l.sort()
cnt=[0]*len(l)
for ss in s:
  cnt[l.index[ss]]+=1
m=max(cnt)
ans=[]
for cc in cnt:
  if cc==m:
    ans.append(cnt.index(cc))
for aa in ans:
  print(l[aa])

Submission status: Runtime Error

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


c = collections.Counter(str_list)


i = 0
while c.most_common()[0][1] == c.most_common() [i][1]:
    ap_list.append(c.most_common()[i][0])
    i+=1
#print(ap_list)

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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


print(c[0][0])
mx=c[0][1]
for i in range(1,len(c)):
    if c[i][1]==mx:
        print(c[i][0])
    else:
        exit()

Submission status: Runtime Error

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: Runtime Error

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(N):
  if listS[i][1]==MAX:
    ans+=[listS[i][0]]
  else:
    break   
ans.sort()
for i in ans:
  print(i)

Submission status: Runtime Error

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
    
MAX=max(counter)

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

Submission status: Runtime Error

Solution code:
from collections import Counter
 
#まずは代入
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: Runtime Error

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,n):
  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: Runtime Error

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()
print(l[0][0])
for i in range(1,n):
  if l[i-1][1]==l[i][1]:
    print(l[i][0])
  else:
    break

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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: Runtime Error

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

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

for k, v in dict(sorted(cnt.items())):
    if v == m:
        print(k)

Submission status: Runtime Error

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)
max = 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: Runtime Error

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]
j = 0
while lis[j][0] == fnum:
    lis2.append(lis[j][1])
    j += 1
lis2.sort()
for k in lis2:
    print(k)

Submission status: Runtime Error

Solution code:
import sys
from collections import Counter
input = sys.stdin.readline
input = sys.stdin.buffer.readline

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))


def main():
    N = II()
    #S = input("")
    #S = [input().strip() for i in range(N)]
    S = [0]*N
    for i in range(N):
        si = input()
        si = si.decode('utf-8')
        S[i] = si.strip("\r\n")
    Sc = Counter(S)
    max = Sc.most_common()[0][1]
    i = 1
    ans = [Sc.most_common()[0][0]]

    while True:
        if Sc.most_common()[i][1] == max:
            ans.append(Sc.most_common()[i][0])
            i += 1
        else:
            break
    
    for j in range(i):
        print(ans[j])

if __name__ == "__main__":
	main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from collections import Counter
n = int(input())
dic = {}
b = []
for i in range(n):
    a = input()
    b.append(a)
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1

for j, k in sorted(dic.items):
    if k == max(dic):
        print(j)

Submission status: Runtime Error

Solution code:
 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: Runtime Error

Solution code:
import collections

n = int(input())
s = [input() for i in range(n)]
t = collections.Counter(s)
d = 0
i = 0
x = []
while d==0:
    x.append(t.most_common()[i][0])
    if len(t.most_common())>1:
        d=t.most_common()[i][1]-t.most_common()[i+1][1]
        i+=1
    else:
        d=1
x.sort()
for i in range(len(x)):
    print(x[i])

Submission status: Runtime Error

Solution code:
import sys
n = int(sys.stdin.readline())
li = []
for _ in range(n):
  li.append(sys.stdin.readline().strip())
li2 = list(set(li)).sort(reverse = True)
cnt_box = []
for i in li2:
  cnt_box.append(li.count(i))
m = max(cnt_box)
i = 0
while i < len(cnt_box):
  if cnt_box[i] == m:
    print(li2[i])
  i += 1

Submission status: Runtime Error

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: Runtime Error

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)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

count = Counter(S)
maxnum = max(count.values())
maxlist= [i for i,j in count.items() if j==maxnum]

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

Submission status: Runtime Error

Solution code:
from collections import Counter

n=int(split())
l=[input() for i in range(n)]
c=Counter(l)
d=max(c.values())
max_list=[k for k,v in c.items() if v==d]
max_list.sort()
for j in max_list:
  print(j)

Submission status: Runtime Error

Solution code:
from collections import Counter

n=int(open(0).readline())
l=open(0).read().split()
c=Counter(l)
max_list=[kv[0] for kv in c.items() if kv[1]==max(c.values())]
max_list.sort()
for j in max_list:
  print(j.strip())

Submission status: Runtime Error

Solution code:
n = int(input())
word = [input() for i in range(n)]
test = list([x,0] for x in set(word))

for i, num in enumerate(test):
  test[i][1] = word.count(num[0])

num_max = int(max(test, key=lambda x: x[1])[1])

print('\n'.join(sorted([num[0] for num in test if(int(num[1] == num_max)))))

Submission status: Runtime Error

Solution code:
import collections
n=int(input())
s=[input() for _ in range(n)]
c=collections.Counter(s)
l=c.most_common()
k=l[0][1]
for i in range(n):
    if l[i][1]==k:print(l[i][0])
    else:exit()

Submission status: Runtime Error

Solution code:
n = int(input())
s = [input() for _ in range(n)]
dic = {}
for i in range(n):
  if s[i] not in dic:
    dic[s[i]] = 1
    else:
      dic[s[i]] += 1
max_dic_val = max(dic.values()) 
ans = []
for keys in dic.keys():
  if dic[keys] == max_dic_val: 
    ans.append(keys)
ans = sorted(ans)
for words in ans:
  print(words)

Submission status: Runtime Error

Solution code:
n = int(input())
d = {}
for _ in range(n):
    s = input()
    if s in d:
        d[s] = +1
    else:
        d[s] = 1
max_d = max(d.values())
ans = sorted([a[0] for i in d.items() if a[1] == max_d])
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
d = {}
for _ in range(n):
    s = input()
    if s  in d:
        d[s] = +1
    else:
        d[s] = 1
max_d = max(d.values())
ans = d.sorted([kv[0] for kv in d.items() if kv[1] == max_d])
print(ans)

Submission status: Runtime Error

Solution code:
import sys
from collections import Counter

n, *s = sys.stdin.read().split()

def main():
    c = Counter(s)
    m = max(c.values())
    ans = [s for s, c in cnt.items() if c == m]
    print(*sorted(ans), sep='\n')
         
if __name__ ==  '__main__':
    main()

Submission status: Runtime Error

Solution code:
import sys
from collections import Counter

n, *s = sys.stdin.read().split()

def main():
    c = Counter(s)
    m = max(c.values())
    ans = [s for s, c in cnt.items if c == m]
    print(*sorted(ans), sep='\n')
         
if __name__ ==  '__main__':
    main()

Submission status: Runtime Error

Solution code:
import collections

n = int(input());
S = [];

for i in range(n):
  S.append(input());

c = collections.Counter(S)
dic2 = sorted(dic.items())

num = c.most_common()[0][1];
ans = [];

for a,b in c.most_common():
    if b == num:
      ans.append(a);
      continue;
    
    else:
      break;

dic2 = sorted(ans);

for i in ans:
  print(i);

Submission status: Runtime Error

Solution code:
import collections

n = int(input());
S = [];

for i in range(n):
  S.append(input());

c = collections.Counter(S)

num = c.most_common()[0][1];
ans = [];

for i in range(len(c)):
  if c.most_common()[i][1] == num:
    ans.append(c.most_common()[i][0]);
    continue;
    
  else:
    break;
    
for a in len(ans):
  print(ans[a]);

Submission status: Runtime Error

Solution code:
import collections

n = int(input());
S = [];

for i in range(n):
  S.append(input());

c = collections.Counter(S)

num = c.most_common()[0][1];
ans = [];

for i in range(len(c)):
  if c.most_common()[i][1] == num:
    ans.append(c.most_common()[i][0]);
    continue;
    
  else:
    break;
    
for a in len(ans):
  print(ans[a]);

Submission status: Runtime Error

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

for _ in range(n):
  s = input()
  if s_dict.get(s, -1) == -1:
    s_dict[s] = 1
  else:
    s_dict[s] += 1

if len(s_dict) == 1:
  print(s_dict.keys())
  exit()
  
s_dict2 = sorted(s_dict.items(), key=lambda x:x[1], reverse=True)
s_list = [s_dict2[0][0]]
i = 0
while s_dict2[i][1] == s_dict2[i+1][1]:
  s_list.append(s_dict2[i+1][0])
  i += 1
  
s_list.sort()
for i in range(len(s_list)):
  print(s_list[i])

Submission status: Runtime Error

Solution code:
N=int(input())
S=['x']*N
for i in range(N):
    S[i]=input()
poll=[]
S_set=list(set(S))
for i in range(len(S_set)):
    poll.append((S.count(S_set[i]),S_set[i]))
poll=sorted(poll)[::-1]
x=poll[0][0]
i=0
ans=[]
while True:
    if x==poll[i][0]:
        ans.append(poll[i][1])
        i+=1
    else:
        break
ans=sorted(ans)
for i in range(len(ans)):
    print(ans[i])

Submission status: Runtime Error

Solution code:
n = int(input())
s = [input() for i in range(n)]
from collections import Counter
c = Counter()
mx = -1
for i in s:
  c[i] += 1
  mx = max(mx, c[i])
 ans = []
for i in s:
  if c[i] == mx:
    ans.append(i)
ans.sort()
print('\n'.join(map(str, ans)))

Submission status: Runtime Error

Solution code:
N = int(input())
l = [input() for _ in range(N)]
l.sort()
l2 = []
for i in range(0,N-1):
    if (l[i]==l[i+1]):
        l2.append(l[i])
ans=list(set(l2))
if len(l2)==0:
    for k in range(0,N):
        print(l[k])
for j in range(0,len(l2)):
    print(ans[j])

Submission status: Runtime Error

Solution code:
n=int(input())
arr=list(input() for _ in range(n)
dic={}

for i in range(n):
 if arr[i] not in dic:
  dic[arr[i]]=1
 else:
  dic[arr[i]]+=1
     
largest=max(dic.values())
ans=[]
for keys in dic.keys():
 if dic[keys]==largest:
  ans.append(keys)
ans=sorted(ans)

for words in ans:
 print(words)

Submission status: Runtime Error

Solution code:
n=int(input())

s=[]
for i in range(n):
    s.append(input())
k=s.copy()   
candidates=list(set(k))

maxnum=0
for candidate in candidates:
    maxnum=max(maxnum,s.count(candidate))
    
ans=[]
for candidate in candidates:
    if s.count(candidate)==maxnum:
        ans.append(candidate)
ans.sort()


for i in ans:
    print(i)

Submission status: Runtime Error

Solution code:
import numpy as np
def f(n, a):
    index, count = np.unique(a, return_counts=True)
    mx = max(count)
    for s in index[count == mx]:
        print(s)
    print(mx)

n = int(input())
a = [0] * n
for i in range(n):
    a[i] = input()
f(n, a)