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: Wrong Answer

Solution code:
def check(input_list):
    vote_dict = {}
    
    for a in input_list:
        if(a in vote_dict.keys()):
            vote_dict[a] += 1
        else:
            vote_dict[a] = 1
            
    return [k for k, v in vote_dict.items() if v == max(vote_dict.values())]

if __name__ == '__main__':
    num = int(input())
    input_list = [input() for a in range(num)]

    for str in check(input_list):
        print(str)

Submission status: Wrong Answer

Solution code:

import collections

n = int(input())

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

c = collections.Counter(ss)

l = c.most_common()

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

Submission status: Wrong Answer

Solution code:
def solve(n: int, words: list):
    word_map = dict()
    max_count = 0
    for word in words:
        count = word_map.get(word, 0) + 1
        word_map[word] = count
        max_count = max(max_count, count)
   
    for word in sorted(word_map):
        if(word_map[word] == max_count):
            print(word)


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

Submission status: Wrong Answer

Solution code:
s=[]
ansl=[]
m=0
n=int(input())
li=[]

for i in range(n):
    a=input()
    li.append(a)
    if li.count(a)>m:
        ansl=[a]
        m=li.count(a)
    elif li.count(a)==m and a not in li[:i-1]:
        ansl.append(a)




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

Submission status: Wrong Answer

Solution code:
import sys
import collections

N = int(input())
S = []
for _ in range(N):
    S.append(input()) 
c = collections.Counter(S)
a = c.most_common()
s = c.most_common()[0][1]
ans = []
for i in a:
    if i[1] == s:
        print(i[0])

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
s = list(input() for i in range(n))
s.sort()
counted = collections.Counter(s)

m = max(counted.values())
chars = [key for key, value in counted.items()
             if value == m]

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

Submission status: Wrong Answer

Solution code:
import collections as col
N=int(input())
S=[]

for _ in range(N):
    S.append(input())
T=sorted(S)
s=col.Counter(T)
values, counts = zip(*s.most_common())

print(values[0])
t=1

while t<=len(values)-1 and counts[t]==counts[t-1]:
    print(values[t])
    t+=1

Submission status: Wrong Answer

Solution code:
N= int(input())
S = [""] * (N)
C = [0] * (N)

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

D=list(set(S))

for i in range(len(D)):
	C[i] = S.count(D[i])

MAX=max(C)
for i in range(len(C)):
	if C[i]==MAX:
		print(D[i])

Submission status: Wrong Answer

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]

for i in range(len(c.most_common())):
    tmp, tmp2 = c.most_common()[i]
    if tmp2 == max:
        print(tmp)
        continue
    else:
        break

Submission status: Wrong Answer

Solution code:
from collections import Counter

N, *a = open(0).read().split()
c = Counter(a)
keys = [k for k, v in c.items() if v ==c.most_common()[0][1] ]

string = "\n".join(keys)
print(string)

Submission status: Wrong Answer

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

c = collections.Counter(s1)
s2 = c.most_common()

values,counts = zip(*s2)
a = 0
for i in range(len(counts)):
    if counts[0] == counts[i]:
        a = a + 1

for j in range(a):
    print(str(values[j]))

Submission status: Wrong Answer

Solution code:
n = int(input())

S = list(str(input()) for i in range(n))
SortedS = sorted(S) #辞書式にソート
s = [] #各文字列の回数
S2 = [] #各文字列
count = 1
for i in range(n - 1):
    if i == n - 2 and SortedS[i] != SortedS[i + 1]:
        s.append(count)
        s.append(1)
        S2.append(SortedS[i])
        S2.append(SortedS[i + 1])
    
    else:
        if SortedS[i] == SortedS[i + 1]:
            count += 1
            if i == n - 2:
                s.append(count)
                S2.append(SortedS[i])
        else:
            s.append(count)
            S2.append(SortedS[i])
            count = 1
ans = []
M = max(s)
for i in range(len(s)):
    if s[i] == M:
        ans.append(S2[i])
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

lists = dics.most_common()
flag = 0
for word,cnt in lists:
	if flag == 0:
		maxc = cnt
		flag = 1	
	if maxc == cnt:
		print(word)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=sorted([input() for k in range(n)])
p=[]
if(len(set(s))==len(s)):
    for u in range(len(s)):
        print(s[u])
    exit()
else:
    s1 = [m for m in sorted(list(set(s))) if s.count(m)>1]
    i = 2
    while():
        s2 = [m for m in sorted(list(set(s))) if s.count(m)>i]
        if(len(s2) ==0):
            break
        else:
            s1 = s2
            continue

for j in range(len(s1)):
    print(s1[j])

Submission status: Wrong Answer

Solution code:
import collections
def main(input_s):
    c = collections.Counter(input_s)
    c_sort = c.most_common(1)
    max_count = c_sort[0][1]
    out_result = []
    for key, value in c.items():
        if value==max_count:
            out_result.append(key)
    return out_result

if __name__ == '__main__':
    N = int(input()) #1行目のNを取得する
    s = [input() for i in range(N)] #複数行の数値の入力を取得
    huga = main(s)
    for i in huga:
        print(i)

Submission status: Wrong Answer

Solution code:
from collections import Counter 
num = input()
ins = list()
aa = list()
qc = 0
for abhsa in range(0, int(num)):
  ins.append(input())
cnt = Counter(ins)
nums = cnt.most_common()
res = nums[0][0]
values, counts = zip(*cnt.most_common())
aa.append(values[0])
for haha in counts:
  aqc = qc + 1
  if int(len(counts) - int("1")) >= aqc:
    if counts[qc] == counts[aqc]:
      aa.append(values[aqc])
      qc += 1
print("\n".join(aa))

Submission status: Wrong Answer

Solution code:
N = int(input())
Ss = {}
for _ in range(N):
  s = input()
  if s in Ss:
    Ss[s] += 1
  else:
    Ss[s] = 1

max_value = max(Ss.values())  # maximum value
max_keys = [k for k, v in Ss.items() if v == max_value]
for k in max_keys:
  print(k)

Submission status: Wrong Answer

Solution code:

import collections

n = int(input())

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

c = collections.Counter(ss)

l = c.most_common()

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

Submission status: Wrong Answer

Solution code:

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

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

Submission status: Wrong Answer

Solution code:
n=int(input())
s=[]
ans=[]
cnt=1
mx=1
for i in range(n):
  a=input()
  s.append(a)
s.sort()

tmp=s[0]
ans.append(tmp)
for i in range(1,n):
  #print("s",s[i])
  if s[i]==tmp:
    cnt+=1
    if cnt==mx:
      ans.append(tmp)
      #print(ans,3)
    if cnt>mx:
      ans=[]
      #print(ans,1)
      ans.append(tmp)
      #print(ans,2)
      mx=cnt
  else:
    if mx==1:
      ans.append(s[i])
    cnt=1
  tmp=s[i]
ans=set(ans)
for i in ans:
  print(i)

Submission status: Wrong Answer

Solution code:
import collections

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

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

S.sort()
counter = collections.Counter(S)
common = counter.most_common()
# common.sort(key=lambda x: x[1], reverse=True)
# print(common)


if (len(common) == 1):
    print(common[0][0])
else:
    print(common[0][0])
    tmp = common[0][1]

    for i in range(1, len(common)):
        if (common[i][1] == tmp):
            print(common[i][0])

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
s = [input() for i in range(n)]
p = collections.Counter(s)
res = sorted(p.items(), key=lambda x: x[1],reverse = True)

keys = []
if(len(s) == len(set(s))):
  print(sorted(s))
  
#keys = [i for i,m in p.items() if m == p.values()]
for i,m in res:
  if(m == max(p.values())):
    keys.append(i)
  else:
    break
keys=sorted(keys)
for i in range(len(keys)):
  print(keys[i])

Submission status: Wrong Answer

Solution code:
N=int(input())
List=[input() for i in range(N)]
List_sorted=sorted(List)
setchar=List_sorted[0]
List_cuted=[]
count=0
kari=[]
count_list=[]
#print(List_sorted)
List_sorted_len=len(List_sorted)

for i in range(List_sorted_len):
    if(setchar==List_sorted[i]):
        count+=1
    if(i==List_sorted_len-1):
        List_cuted.append(List_sorted[i])
        aa=[]
        aa.append(List_sorted[i])
        aa.append(count)
        kari.append(aa)
        count_list.append(count)
        continue
    if(setchar!=List_sorted[i]):
        List_cuted.append(List_sorted[i-1])
        setchar=List_sorted[i]
        aa=[]
        aa.append(List_sorted[i-1])
        aa.append(count)
        kari.append(aa)
        count_list.append(count)

max_count_list=max(count_list)-1
#print(max_count_list)
#print(List_cuted)

for i in range(len(List_cuted)):
    if(i>=len(List_cuted)-2):
        kari[i][1]-=1
    
    #print(kari[i][0])
    #print(kari[i][1])
    if(max_count_list !=0):
        if(kari[i][1] == max_count_list):
            print(kari[i][0])

if(max_count_list == 0):
    for i in range(len(List_sorted)):
        print(List_sorted[i])

Submission status: Wrong Answer

Solution code:
n=int(input())
st=[]
l=[0 for i in range(n)]
for i in range(n):
    st.append(input())
for i in range(n):
    if st[i] not in l:
        l[i]+=1
    if i==n-1:break
    for j in range(i+1,n):
        if st[i]==st[j]:
            l[i]+=1
m=max(l)
if m==1:
    for i in range(n):
        print(st[i])
else:
    s=[]
    for i in range(n):
        if m==l[i]:
            s.append(st[i])
    for word in sorted(l):
        print(word)

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
S = []
for _ in range(N):
    S.append(input())
clist = collections.Counter(S)
vals = clist.values()
maxs=[i for i, v in enumerate(vals) if v == max(vals)]
keys = list(clist)
for i in maxs:
	print(keys[i])

Submission status: Wrong Answer

Solution code:
def main():
	# n,m = map(int,input().split())
	n = int(input())
	l = [str(input()) for i in range(n)]
	
	import collections

	c = collections.Counter(l)
	lc = sorted(list(c.items()), key = lambda x:x[1] , reverse = True)
	print(lc[0][0])
	ans = []
	checker = 0
	i = 0
	while checker == 0 and i < len(lc):
		if lc[i][1] == lc[0][1]:
			ans.append(lc[i][0])
		else:
			checker += 1
		i += 1

	# keys = [k for k, v in c.items() if v == max(c.values())]
	# print(list(c.items())[0][0])
	# checker = 0
	# while checker == 0:
	# 	if c.items() == max(c.values()):
	ans.sort()
	print('\n'.join(map(str, ans)))

	
	
 
if __name__ == '__main__':
	main()

Submission status: Wrong Answer

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

list1 = sorted(b.items(), key=lambda x: x[1])
list1.reverse()

a = 0
list2=[]
while a<len(list1) and list1[0][1] == list1[a][1]:
    list2.append(list1[a][0])
    list2.sort()
    a += 1

print(list2)

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
L =  list(str(input()) for i in range(N))
c = collections.Counter(L)
# print(c)
max_k_list = [kv[0] for kv in c.items() if kv[1] == max(c.values())]
# max_k_list=c[c == c.max()].index
# print(max_k_list)
for j in reversed(list(c.keys())):
    if j in max_k_list:
        print(j)
# for i in max_k_list:
#     print(i)

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
from collections import defaultdict

N,*S=read().decode('utf-8').split()
cnt=0
d = defaultdict(int)
res=[]
for s in S:
  if d[s]!=0:
    continue
  else:
    d[s]+=1
  x=S.count(S)
  if cnt<x:
    cnt=x
    res=[s]
  elif cnt==x:
    res.append(s)
print(*sorted(res))

Submission status: Wrong Answer

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

c = collections.Counter(s1)
s2 = c.most_common()


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

for j in range(a):
    print(str(s2[j][0]))

Submission status: Wrong Answer

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

s.sort()
s.append("ZZZZZZZZZZZZ")

ans = []
maxcnt = 0
cnt =0
for i in range(len(s)-1):
  if s[i] == s[i+1]:
    cnt += 1
  else:
    if maxcnt < cnt :
      maxcnt = cnt
      ans = []
      ans.append(s[i])
      cnt = 0
    elif maxcnt == cnt :
      ans.append(s[i])
      cnt = 0
for j in range(len(ans)):
  print(ans[j])

Submission status: Wrong Answer

Solution code:
import numpy as np
from operator import itemgetter

N=int(input())
List=[input() for i in range(N)]
SetList=list(set(List))
nc=[List.count(SetList[i]) for i in range(len(SetList))]


indexmax=np.where(np.array(nc) == np.array(nc).max())[0]
MaxList=itemgetter(*indexmax)(SetList)
MaxListS=sorted(MaxList)
for i in MaxListS:
    print(i)

Submission status: Wrong Answer

Solution code:
import collections
a = int(input())
li1 = []

for i in range(a):
    li1.append(str(input()))

sorted(li1)
c = collections.Counter(li1)

key, value = zip(*c.most_common())
print(key[0])
for i in range(1,len(key)):
    if(value[0] == value[i]):
        print(key[i])
    else:
        break;

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
arr = []
arr_max = []
for i in range(N):
    arr.append(input())
dic = Counter(arr)
inverse = [(value, key) for key, value in dic.items()]
max_s = max(inverse)[0]
for key,value in dic.items():
    if value == max_s: 
        arr_max.append(key)
    else: continue
for j in arr_max: print (j)

Submission status: Wrong Answer

Solution code:
import collections
 
N = int(input())
l = [input() for _ in range(N)]
 
c = collections.Counter(l)
 
L = c.most_common()
 
values, counts = zip(*c.most_common())
 
A = list(values)
B = list(counts)
 
b = B.count(B[0])
 
a = A[0:b + 1]
 
for i in a[0:]:
		print(i)

Submission status: Wrong Answer

Solution code:
import collections as col
N=int(input())
counts=[]
A=[]
S=[]
T=[]
U=[]
for _ in range(N):
    S.append(input())
T=sorted(S)
s=col.Counter(T)
values, counts = zip(*s.most_common())

print(values[0])
t=1

while t<=(len(values)-1) and counts[t]==counts[t-1]:
    print(values[t])
    t+=1

Submission status: Wrong Answer

Solution code:
import collections

n= int(input())
L=[]
for i in range(n):
    L.append(input())
s = sorted(L)
c = collections.Counter(s)
for i in range(len(c)-1):
    print(c.most_common()[i][0])
    if c.most_common()[i][1] != c.most_common()[i+1][1]:
        exit()

Submission status: Wrong Answer

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

s.sort()
s.append("ZZZZZZZZZZZ")
ans = []
maxcnt = 0
cnt =0
for i in range(n):
  if s[i] == s[i+1]:
    cnt += 1
  else:
    if maxcnt < cnt :
      maxcnt = cnt
      ans = []
      ans.append(s[i])
      cnt = 0
    elif maxcnt == cnt :
      ans.append(s[i])
      cnt = 0

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

Submission status: Wrong Answer

Solution code:
import sys
import collections

N = int(input())
S = []
for _ in range(N):
    S.append(input()) 
c = collections.Counter(S)
a = c.most_common()
s = c.most_common()[0][1]
ans = []
for i in a:
    if i[1] == s:
        print(i[0])
        sys.stdout.flush

Submission status: Wrong Answer

Solution code:
from collections import Counter


N=int(input())
l=['']*N
for i in range(N):
    l[i]=input()

l.sort()

print(l)
c=1
c_crt=1
pre=""
ans=[]
for e in l+[""]:
    if e == pre:
        c_crt+=1
    else:
        if c_crt > c:
            ans=[pre]
            c=c_crt
        elif c_crt == c:
            ans.append(pre)
        c_crt=1
    pre=e
for e in ans:
    print(e)

Submission status: Wrong Answer

Solution code:
import collections
a = int(input())
li1 = []

for i in range(a):
    li1.append(str(input()))

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

key, value = zip(*c.most_common())
print(key[0])
for i in range(1,len(key)):
    if(value[0] == value[i]):
        print(key[i])
    else:
        break;

Submission status: Wrong Answer

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

B = Counter(A)


max = [kv for kv in B.items() if kv[1] == max(B.values())]

for i in reversed(max):
    print(i[0])

Submission status: Wrong Answer

Solution code:
import collections

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

c = collections.Counter(l)

L = c.most_common()

values, counts = zip(*c.most_common())

A = list(values)
B = list(counts)

b = B.count(B[0])

a = A[0:b + 1]

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
a_list = [str(input()) for i in range(n)]
aa = sorted(a_list)
c = collections.Counter(aa)

cc = c.most_common()
values, counts = zip(*c.most_common())
max_counts = max(counts)


counts_num = counts.count(max_counts)

for i in range(counts_num):
    print(values[i])

Submission status: Wrong Answer

Solution code:
n = int(input())

str_list = []
for n in range(n):
    str_list.append(input())

cnt_dict = {_ : str_list.count(_) for _ in set(str_list)}

print(
    sorted(
        [l[0] for l in cnt_dict.items() if l[1] == max(cnt_dict.values())]
    )
)

# print(sorted(ans_list))
# print(ans_list.sort()) なぜか文字列だと使えない

Submission status: Wrong Answer

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

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

cand = []

for i in range(N):
    if not S[i] in cand:
        cand.append(S[i])

cand_count = []

for i in range(len(cand)):
    cand_count.append(S.count(cand[i]))

cand_max_ind = []

roop = 0
max_count = 0
while max_count <= max(cand_count):
    max_count = max(cand_count)
    cand_max_ind.append(cand[cand_count.index(max(cand_count))+roop])
    cand_count.pop(cand_count.index(max(cand_count)))
    if len(cand_count) == 0:
        break
    roop = roop+1

cand_max_ind.sort()
print(cand_max_ind)

Submission status: Wrong Answer

Solution code:
n=int(input())
st=[]
l=[0 for i in range(n)]
for i in range(n):
    st.append(input())
for i in range(n):
    if st[i] not in l:
        l[i]+=1
    if i==n-1:break
    for j in range(i+1,n):
        if st[i]==st[j]:
            l[i]+=1
m=max(l)
if m==1:
    for i in range(n):
        print(st[i])
else:
    s=[]
    for i in range(n):
        if m==l[i]:
            s.append(st[i])
    s.sort()
    for i in s:
        print(i)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = []
for i in range(N):
    S.append(str(input()))
dict_uni = {x:S.count(x) for x in set(S) if S.count(x)>=1}
dict_sorted = sorted(dict_uni.items(), key=lambda x:x[1], reverse=False)
for i in dict_sorted:
    print(i[0])

Submission status: Wrong Answer

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

print(s)
numbers = dict()
maxval = 1
for val in s:
    if val in numbers:
        if maxval == numbers[val]:
            maxval = maxval + 1
        numbers[val] += 1
    else:
        numbers[val] = 1

ret = [kv[0] for kv in numbers.items() if kv[1] == maxval]
for v in sorted(ret):
    print(v)

Submission status: Wrong Answer

Solution code:
n = int(input())
s,t = [],{}
for i in range(n):
  s.append(input())
for i in list(set(s)):
  t[i] = s.count(i)
#t = dict(sorted(t.items(), key=lambda x:x[0]))
t = dict(sorted(t.items(), key=lambda x:x[0]))
#t.sort(reverse=True)
m = max(t.values())
for i in t.items():
  if i[1] == m:
    print(i[0])
  else:
    continue

Submission status: Wrong Answer

Solution code:
import collections

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

c = collections.Counter(l)

L = c.most_common()

values, counts = zip(*c.most_common())

A = list(values)
B = list(counts)

b = B.count(B[0])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import collections
N=int(input())
S=[]
for i in range(N):
  s=str(input())
  S +=[s]
T=collections.Counter(S)
answer=T.most_common()
for i in range(len(T)):
  if answer[i][1]==answer[0][1]:
    print(answer[i][0])
  else:
    break

Submission status: Wrong Answer

Solution code:
import sys
import collections

N = int(input())
S = [str(input()) for i in range(N)]
# S_jadge1 = [s for s in S if s.islower()]
# S_jadge2 = [s for s in S if 1 <= len(s) <= 10]
# if len(S) != len(S_jadge1):
#     sys.exit()
# if len(S) != len(S_jadge2):
#     sys.exit()
if not 1 <= N <= 2*10*5:
    sys.exit()

c = collections.Counter(S)
max_val = max(c.values())
A = [key for key, value in c.items() if value == max_val]
A = sorted(A)
print('\n'.join(A))
# print(c.items())

Submission status: Wrong Answer

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

s.sort()

ans = []
maxcnt = 0
cnt =0
for i in range(n-1):
  if s[i] == s[i+1]:
    cnt += 1
  else:
    if maxcnt < cnt :
      maxcnt = cnt
      ans = []
      ans.append(s[i])
      cnt = 0
    elif maxcnt == cnt :
      ans.append(s[i])
      cnt = 0
  if i == n-2:
    if maxcnt < cnt :
      maxcnt = cnt
      ans = []
      ans.append(s[i+1])
      cnt = 0
    elif maxcnt == cnt :
      ans.append(s[i+1])
      cnt = 0

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

Submission status: Wrong Answer

Solution code:
import collections

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

c = collections.Counter(sorted(S_list))
most_count = c.most_common()[0][1]

for i in c.items():
  if i[1] == most_count:
    print(i[0])

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
s_list = sorted(list(input() for _ in range(n)))

s = Counter(s_list)

ans_num = s.most_common(1)[0][1]

s_1 = list(s.items())

for i in range(len(s_1)):
    if s_1[i][1] == ans_num:
        print(s_1[i][0])

Submission status: Wrong Answer

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

for k in S:
    d[k]+=1

d=dict(d)
dmax=max(d)
ansn=d[dmax]
ans=[]
for i in d.keys():
    if d[i]==ansn:
        ans.append(i)

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

Submission status: Wrong Answer

Solution code:
n = int(input())
s = [input() for i in range(n)]
s.sort(reverse=True)
l = set(s)
ms = len(s) - len(l)
if len(l) == 1:
    print(s[0])
    exit()
elif len(l) == n:
    s.sort()
    print("\n".join(s))
    exit()

ans = 0
ans_l = []
for i in l:
    sc = s.count(i)
    if sc > ans:
        ans_l = [i]
        ans = sc
    elif sc == ans:
        ans_l.append(i)
      
print("\n".join(ans_l))

Submission status: Wrong Answer

Solution code:
n = int(input())

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

s = sorted(s)
d = {s[0]:1}
for i in range(1, n):
	if s[i-1] == s[i]:
		d[s[i]] += 1
	else:
		d[s[i]] = 1

#m = max(d)#これだと辞書順で一番最後にくる単語を代入してるらしいのでなんとか、数が大きいものを探したい。
m = sorted(d.items(), key=lambda x:x[1])[-1][1]


for i in d:
	if d[i] == m:
		print(i)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

lists = dics.most_common()
maxc = lists[0][1]

for word,cnt in lists:
	if maxc == cnt:
		print(word)

Submission status: Wrong Answer

Solution code:
import collections

n=int(input())
a = [input() for i in range(n)]
b = sorted(list(set(a)))
d = {}
for i in b:
    d[i] = a.count(i)

c = collections.Counter(d)
t=0
for i in c.most_common():
    if t >0 and i[1] != t:
        break
   
    print(i[0])
    t=i[1]

Submission status: Wrong Answer

Solution code:
import collections

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

c = collections.Counter(l)

L = c.most_common()

values, counts = zip(*c.most_common())

print("a")

Submission status: Wrong Answer

Solution code:
n = int(input())
s = [input() for _ in range(n)]
s.sort()
dic = {}
for i in s:
    if i in dic:
        dic[i] += 1
    else: dic[i] = 1
max_k = max(dic.values())
for i in dic:
    if dic[i] == max_k:
        print(i)

Submission status: Wrong Answer

Solution code:
N = int(input())
S_list = []
for i in range(N):
    x = input()
    S_list.append(x)
another_list = [S_list[0]]
cnt_list = [1]
for i in range(1, N):
    for j in range(len(another_list)):
        if another_list[j] == S_list[i]:
            cnt_list[j] += 1
            break
    if j == len(another_list)-1:
        another_list.append(S_list[i])
        cnt_list.append(1)
max_v = max(cnt_list)
cnt = []
for i in range(len(cnt_list)):
    if max_v == cnt_list[i]:
        cnt.append(i)
cnt1 = []
for i in range(len(cnt)):
    cnt1.append(another_list[cnt[i]])
for i in range(len(cnt1)):
    print("{}".format(cnt1[i]))

Submission status: Wrong Answer

Solution code:
import sys
import collections
n = int(input())
li=[input() for _ in range(n)]
li.sort()
c = collections.Counter(li)
max_list = [kv[0] for kv in c.items() if kv[1] == max(c.values())]
for s in max_list:
  print(s)

Submission status: Wrong Answer

Solution code:
import collections

n = int(input())
data_list = [input() for i in range(n)]
data_list.sort()

count_dict = collections.Counter(data_list)

max_val = max(count_dict.values())
max_keys = [key for key in count_dict if count_dict[key] == max_val]

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

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

lists = dics.most_common()

print(lists[0][1])
maxc = lists[0][1]

for word,cnt in lists:
	if maxc == cnt:
		print(word)

Submission status: Wrong Answer

Solution code:
import sys
import collections

N = int(input())
S = [str(input()) for i in range(N)]
# S_jadge1 = [s for s in S if s.islower()]
# S_jadge2 = [s for s in S if 1 <= len(s) <= 10]
# if len(S) != len(S_jadge1):
#     sys.exit()
# if len(S) != len(S_jadge2):
#     sys.exit()
if not 1 <= N <= 2*10*5:
    sys.exit()

# if not S.islower():
#     print("error:lower")
#     sys.exit()

c = collections.Counter(S)
max_val = max(c.values())
A = [key for key, value in c.items() if value == max_val]
print('\n'.join(A))
# print(c.items())

Submission status: Wrong Answer

Solution code:
import collections

N = int(input())
S = []
kaisuu = []
solution = []
index = 0

for i in range(N):
  tmp = input()
  S.append(tmp)
  
c = collections.Counter(S)

d = c.most_common()

max_ = d[0][1]

for i in range(len(d)):
  if d[i][1] == max_:
    solution.append(d[i][0])

for i in solution:
  print(i)

Submission status: Wrong Answer

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

s.sort()

ans = []
maxcnt = 0
cnt =0
for i in range(n-1):
  if s[i] == s[i+1]:
    cnt += 1
  else:
    if maxcnt < cnt :
      maxcnt = cnt
      ans = []
      ans.append(s[i])
      cnt = 0
    elif maxcnt == cnt :
      ans.append(s[i])
      cnt = 0
  if i == n-2:
    if maxcnt < cnt :
      maxcnt = cnt
      ans = []
      ans.append(s[i])
      cnt = 0
    elif maxcnt == cnt :
      ans.append(s[i])
      cnt = 0

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

Submission status: Wrong Answer

Solution code:
# input1 = list(map(int, (input().split())))
# input2 = list(map(int, (input().split())))
N = int(input())
input2 = []
for i in range(N):
    input2.append(input())

jisyo = {}

for a in input2:
    if a not in jisyo:
        jisyo[a] = 1
    else:
        jisyo[a] += 1

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

m = result[0][1]
for r in result:
    if m != r[1]:
        exit(0)
    print(r[0])

Submission status: Wrong Answer

Solution code:
n = int(input())
List=[input() for i in range(n)]
max = 0
for i in List:
    if max <= List.count(i):
        # 最大値更新
        max = List.count(i)
        # 出現回数最大の文字をコピーしたリスト作成
name_List = [i for i in List if List.count(i) == max]

# print(name_List)
# print(set(name_List))
setted_List = set(name_List)
# print(sorted(setted_List))
for i in setted_List:
    print(i)

Submission status: Wrong Answer

Solution code:
import collections

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

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

A = sorted(A)
A = collections.Counter(A)

count = []
B = A.most_common()

for i in range(len(A)):
  count.append(B[i][1])

for i in range(len(A)):
  if B[i][1] == max(count):
    print(B[i][0])

Submission status: Wrong Answer

Solution code:
n=int(input())
s=[input() for i in range(n)]
s.sort()
cnt=1
ans=0
pri=[]
for i in range(n-1):
    if s[i]==s[i+1]:
        cnt+=1
    else:
        ans=max(cnt,ans)
        cnt=1
ans=max(cnt,ans)
for i in range(n):
    if ans==s.count(s[i]):
        pri.append(s[i])
print(ans)
t=set(pri)
p=list(t)
p.sort()
for i in range(len(p)):
    print(p[i])

Submission status: Wrong Answer

Solution code:
import sys
import collections

N = int(input())
S = [str(input()) for i in range(N)]
S_jadge1 = [s for s in S if s.islower()]
S_jadge2 = [s for s in S if 1 <= len(s) <= 10]
if len(S) != len(S_jadge1):
    sys.exit()
if len(S) != len(S_jadge2):
    sys.exit()
if not 1 <= N <= 2*10*5:
    sys.exit()

# if not S.islower():
#     print("error:lower")
#     sys.exit()

c = collections.Counter(S)
max_val = max(c.values())
A = [key for key, value in c.items() if value == max_val]
print(*A)
# print(c.items())

Submission status: Wrong Answer

Solution code:
import collections

N = int(input())
dic = {}
for i in range(N):
  s = str(input())
  if dic.get(s):
    dic[s] += 1
  else:
    dic[s] = 1

max_k_list = [kv[0] for kv in dic.items() if kv[1] == max(dic.values())]
s_n = '\n'.join(max_k_list)
print(s_n)

Submission status: Wrong Answer

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


numbers = dict()
maxval = 1
for val in s:
    if val in numbers:
        if maxval == numbers[val]:
            maxval = maxval + 1
        numbers[val] += 1
    else:
        numbers[val] = 1

[print(kv[0]) for kv in numbers.items() if kv[1] == maxval]