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:
from collections import Counter
n = int(input())

s = Counter(sorted([input() for _ in range(n)]))
mx = max(s.values())

for k,v in s.items():
    if v == mx:
        print(k)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import collections

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

dic = collections.Counter(S)
max_value = max(dic.values())

for k, v in dic.items():
  if v == max_value:
    print(k)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
S = Counter(input() for _ in range(N))
m = max(S.values())
for v in sorted(s for k, v in S.items() if k == m):
	print(v)

Submission status: Wrong Answer

Solution code:

num = input()
l = []
for i in range(0,int(num)):
    l.append(input())

cnt = []
for item in list(set(l)):
    cnt.append(l.count(item))

num_dict = dict(zip(list(set(l)),cnt))
max_v = max(num_dict.values())

keys = []

for word, num in num_dict.items():
    if num == max_v:
        keys.append(word)

print(sorted(keys))

Submission status: Wrong Answer

Solution code:
n=int(input())
list_ = [input() for i in range(n)]
dic = {}
for a in list_:
    if a in dic:
        dic[a] += 1
    else:
        dic[a]   = 1
maxa = max(dic.values())
ans = [x for x, y in dic.items() if y == maxa]
print(sorted(ans))

Submission status: Wrong Answer

Solution code:
n=int(input())
dic = {}
for i in range(n):
    a = input()
    if a in dic:
        dic[a] += 1
    else:
        dic[a]   = 1
maxa = max(dic.values())
ans = [x for x, y in dic.items() if y == maxa]
print(sorted(ans))

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

c = Counter(s)
c2 = c.most_common()
m = c2[0][1]#最大値
ans = [i[0] for i in c2 if i[1] == m]#回数が最大となるもの
print(*ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = []
for i in range(n):
    s.append(input())
dic ={}
for key in s:
    if key not in dic:
        count = 1
    dic[key] = count
    count = count+1
res = sorted(list(filter(lambda key:dic[key]==max(dic.values()),list(dic))))
for key in res:
    print(key)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(input().split())
dic ={}
for key in s:
    if key not in dic:
        count = 1
    dic[key] = count
    count = count+1
res = sorted(list(filter(lambda key:dic[key]==max(dic.values()),list(dic))))
for key in res:
    print(key)

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())

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

count = Counter(a)
tmp = []
for ss, ii in count.most_common():
    if ii > 1:
        tmp.append(ss)
tmp.sort()
for t in tmp:
    print(t)

Submission status: Wrong Answer

Solution code:
N = int(input())

L = []
S = set()
for i in range(N):
  s = input()
  L.append(s)
  S.add(s)
L.sort()

M = 0
for i in S:
  M = max(M, L.count(i))
  
for i in S:
  if L.count(i) == M:
    print(i)

Submission status: Wrong Answer

Solution code:
n= int(input())
s = [input() for _  in range(n)]
compare = list(set(s))
ans1 = []
for i in compare:
  ans1.append(s.count(i))
  s.remove(i) 
print(ans1) 
ans2 = [i for i,x in enumerate(ans1) if x == max(ans1)]
for i in ans2:
  print(compare[i])

Submission status: Wrong Answer

Solution code:
n= int(input())
s = [input() for _  in range(n)]
compare = list(set(s))
ans1 = [s.count(i) for i in compare]
ans2 = [i for i,x in enumerate(ans1) if x == max(ans1)]
for i in ans2:
  print(compare[i])

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)
cnt=1
for i in range(n-1):
    if s[i]==s[i+1]:
        cnt+=1
    else:
        if cnt==ans:
            pri.append(s[i])
            cnt=1
        else:
            cnt=1
if cnt==ans:
    pri.append(s[-1])
print(ans)
for i in range(len(pri)):
    print(pri[i])

Submission status: Wrong Answer

Solution code:
n=int(input())

d={}
for i in range(n):
  s=input()
  if(s in d):
    d[s]+=1
  else:
    d[s]=1
    
ma=max(d.values())
for i in sorted(d):
  if(d[i]==ma):
    print(d[i])

Submission status: Wrong Answer

Solution code:
N=int(input())
S=[input() for i in range(N)]
D=dict()
for i in range(N):
    if S[i] in D:
        D[S[i]]+=1
    else:
        D[S[i]]=1
k=D[max(D)]
X=[]
for i in D:
    if D[i]==k:
        X.append(i)
for line in sorted(X):
    print(line)

Submission status: Wrong Answer

Solution code:
import collections as cl
import sys
input = sys.stdin.readline

N = int(input().strip())
S_list = [input().strip() for _ in range(N)]
# print(S_list)
c = cl.Counter(S_list)
ordered = c.most_common()
max_num = max(ordered)[1]
max_list = sorted([item[0] for item in ordered if item[1] == max_num])

for i in max_list:
    print(i)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=[input() for i in range(N)]
D=dict()
for i in range(N):
    if S[i] in D:
        D[S[i]]+=1
    else:
        D[S[i]]=1
k=D[max(D)]
X=[]
for s in D:
    if D[s]==k:
        X.append(s)
for line in sorted(X):
    print(line)

Submission status: Wrong Answer

Solution code:
import collections as cl
import sys
input = sys.stdin.readline

N = int(input().strip())
S_list = [input().strip() for _ in range(N)]
# print(S_list)
c = cl.Counter(S_list)
ordered = c.most_common()
max_num = max(ordered)[1]
max_list = set([item[0] for item in ordered if item[1] == max_num])

for i in max_list:
    print(i)

Submission status: Wrong Answer

Solution code:
import collections as cl
import sys
input = sys.stdin.readline

N = int(input().strip())
S_list = [input().strip() for _ in range(N)]
# print(S_list)
c = cl.Counter(S_list)
ordered = c.most_common()
max_num = max(ordered)[1]
max_list = [item[0] for item in ordered if item[1] == max_num]

print(*max_list)

Submission status: Wrong Answer

Solution code:
import collections

n = int(input())
s_list=[input() for i in range(n)]

s_dict=collections.Counter(s_list)
    
ans = [kv[0] for kv in s_dict.items() if kv[1] == max(s_dict.values())]
print(*ans, sep='\n')

Submission status: Wrong Answer

Solution code:
n = int(input())
words = {}
for i in range(n) :
    new_word = input()
    if new_word in words.keys() :
        words[new_word] += 1
    else :
        words[new_word] = 1

mx_freq = words[max(words)]
mx_words = [k for k, v in words.items() if v == mx_freq]

mx_words.sort()

for mx_word in mx_words :
    print(mx_word)

Submission status: Wrong Answer

Solution code:
def main():
    n =int( input())

    cnt=dict()
    
    for _ in range(n):
        s=input()
        if s in cnt:
            cnt[s]+=1
        else :
            cnt[s]=1
    #print(cnt)
    
    num = 0
    res =[]
    for key,value in cnt.items():
        print(key,":::",value)
        if value > num:
            num=value
            res.append(key)
        elif value==num:
            res.append(key)

    #print("res::",res)

    
    #a = [k for k, v in cnt.items() if v == max(cnt.values())]


    #print("結果発表：：：：",len(res))
    res.sort()
    for elm in res:
        print(elm)


main()

Submission status: Wrong Answer

Solution code:
import collections as coll

N = int(input())
A = sorted([input() for _ in range(N)])
C = coll.Counter(A).most_common()
C = [k for k,v in C if v == C[0][1]]
print(*C, sep='\n')

Submission status: Wrong Answer

Solution code:
import collections

N = int(input())
wordDict = {}
maxNum = 0
for i in range(N):
    word = input()
    if( word in wordDict ):
        wordDict[word] += 1
    else:
        wordDict[word] = 1
    
max_v = max(wordDict.values())
keys = [k for k, v in wordDict.items() if v == max_v]

sorted(keys)
for word in keys[::-1]:
    print(word)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

print(list(set(s)))

Submission status: Wrong Answer

Solution code:
n = int(input().rstrip())
 
current_max = 0
current = []
table = {}
 
for i in range(n):
    s = input().rstrip()
    table[s] = table[s] + 1 if table.get(s) is not None else 0
    if table[s] > current_max:
        current = [s]
        current_max = table[s]
    elif table[s] == current_max:
        current.append(s)
    else:
        continue
 
score_sorted = sorted(table.items(), key=lambda x:-x[1])

max = 0
results = []
for k, v in score_sorted:
    if max > v:
      break
    results.append(k)

results.sort()

for word in results:
  print(word)

Submission status: Wrong Answer

Solution code:
n = int(input().rstrip())
 
current_max = 0
current = []
table = {}
 
for i in range(n):
    s = input().rstrip()
    table[s] = table[s] + 1 if table.get(s) is not None else 0
    if table[s] > current_max:
        current = [s]
        current_max = table[s]
    elif table[s] == current_max:
        current.append(s)
    else:
        continue
 
score_sorted = sorted(table.items(), key=lambda x:-x[1])

max = 0
for k, v in score_sorted:
    if max > v:
      break
    max = v
    print(k)

Submission status: Wrong Answer

Solution code:
n = int(input())
s_lst = [str(input()) for i in range(n)]
s_lst.sort()

count_lst = []
count = 1

if n==1:
    count_lst.append(1)
else:
    for i in range(1,n):
        s1 = s_lst[i-1]
        s2 = s_lst[i]

        if s1==s2:
            count += 1
            if i==n-1:
                count_lst.append(count)
        else:
            count_lst.append(count)
            count = 1

    if s_lst[-1]!=s_lst[-2]:
        count_lst.append(1)


new_slst = list(set(s_lst))
max_count = max(count_lst)
answer_lst = []

for i in range(len(count_lst)):
    cou = count_lst[i]
    s = new_slst[i]
    if cou==max_count:
        answer_lst.append(s)

answer_lst.sort()
for i in range(len(answer_lst)):
    answer = answer_lst[i]
    print(answer)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
lst = [input() for i in range(n)]
c = Counter(lst)
c2 = c.most_common()
m = c2[0][1]
ans = [i[0] for i in c2 if i[1] == m]
print('\n'.join(sorted(ans, key=lambda x:x[0])))

Submission status: Wrong Answer

Solution code:
n = int(input())
s_lst = [str(input()) for i in range(n)]
s_lst.sort()

count_lst = []
count = 1
for i in range(n-1):
    s1 = s_lst[i]
    s2 = s_lst[i+1]

    if s1==s2:
        count += 1
        if i==n-2:
            count_lst.append(count)
    else:
        count_lst.append(count)
        count = 1

if n>1:
    if s_lst[-1]!=s_lst[-2]:
        count_lst.append(1)
if n==1:
    count_lst.append(1)

new_slst = list(set(s_lst))
max_count = max(count_lst)
answer_lst = []

for i in range(len(count_lst)):
    cou = count_lst[i]
    s = new_slst[i]
    if cou==max_count:
        answer_lst.append(s)

answer_lst.sort()
for i in range(len(answer_lst)):
    answer = answer_lst[i]
    print(answer)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
lst = [input() for i in range(n)]
c = Counter(lst)
c2 = c.most_common()
m = c2[0][1]
for i in c2:
  if i[1] == m:
    print(i[0])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import Counter
n=int(input())
a=[input() for _ in range(n)]
c=Counter(a)
sorted(c.items())
max_cnt=max(c.values())
names=[name for name,v in c.items() if v==max_cnt]
print(*names,sep='\n')

Submission status: Wrong Answer

Solution code:
from collections import Counter
n=int(input())
a=[input() for _ in range(n)]
c=Counter(a)
sorted(c.items())
max_cnt=max(c.values())
print(max_cnt)
names=[name for name,v in c.items() if v==max_cnt]
print(*names,sep='\n')

Submission status: Wrong Answer

Solution code:
from collections import Counter
n=int(input())
a=[input() for _ in range(n)]
c=Counter(a)
sorted(c.items())
max_cnt=max(c.values())
print(max_cnt)
names=[name for name,v in c.items() if v==max_cnt]
print(names)

Submission status: Wrong Answer

Solution code:
n = int(input())
Strings = [input() for _ in range(n)]
dic = {}

for s in Strings:
    if s not in dic.keys():
        dic[s] = 1
    else:
        dic[s] += 1

maxValue = dic[max(dic)]
ans = []

for s in dic:
    if dic[s] == maxValue:
        ans.append(s)

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

Submission status: Wrong Answer

Solution code:
# C - Poll
from collections import Counter


def main():
    _, *S = open(0).read().split()
    cnt = Counter(S)
    max_votes = max(cnt)
    ans = [k for k, v in cnt.items() if v == max_votes]
    ans.sort()
    print("\n".join(ans))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())

d = {}
for _ in range(N):
    S = input()
    if S in d:
        d[S] += 1
    else:
        d[S] = 1

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

Submission status: Wrong Answer

Solution code:
N = int(input())
S = []
for i in range(N):
    S.append(input())
vote = {}
for j in S:
    if j not in vote:
        vote[j] = 1
    else:
        vote[j] += 1
most = set()
highNo = 0
for k in vote:
    if vote[k] > highNo:
        most.clear()
        most.add(k)
        highNo = vote[k]
    elif vote[k] == highNo:
        most.add(k)
for h in most:
    print(h)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = []
for i in range(N):
    S.append(input())
vote = {}
for j in S:
    if j not in vote:
        vote[j] = 1
    else:
        vote[j] += 1
most = set()
highNo = 0
for k in vote:
    if vote[k] > highNo:
        most.clear()
        most.add(k)
        highNo = vote[k]
    if vote[k] == highNo:
        most.add(k)
for h in most:
    print(h)

Submission status: Wrong Answer

Solution code:
import collections

N = int(input())
S = [input() for _ in range(N)]
c = collections.Counter(S)
c.most_common().sort()
values, counts = zip(*c.most_common())
if len(values) == 1:
    print(values[0])
else:
    for i in range(N):
        if counts[i] == counts[0]:
            print(values[i])
        else:
            exit()

Submission status: Wrong Answer

Solution code:
n  = int(input())

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

data_list.sort()

data_set = list(set(data_list))

data_set.sort()

data_dict = {}

for i in range(len(data_set)):
    data_dict[data_set[i]] = 0
    for j in range(len(data_list)):
        if data_set[i] == data_list[j]:
            data_dict[data_set[i]] += 1


max_k_list = [kv[0] for kv in data_dict.items() if kv[1] == max(data_dict.values())]


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

Submission status: Wrong Answer

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

def abc155c(num, s):
    appearance_dict = {} # 文字列:出現回数
    array = [[] for _ in range(num)] # (出現回数-1)をindexに文字列を配列で管理する
    max_cnt = 0

    for i in range(0, num):
#        target = s[i]
        target = input()
        cnt = 0 # appearance count

        if( target in appearance_dict ):
            cnt = appearance_dict[target]
            array[cnt-1].remove(target)
        appearance_dict[target] = cnt+1

        # sortしながら配列に追加する
        insert_idx = 0
        target_array = array[cnt]
        if( target_array != [] ):
            for sort_idx in range(0, len(target_array)):
                if( target < target_array[sort_idx] ): 
                    insert_idx = sort_idx
                    break
        array[cnt].insert(insert_idx, target)

        if( cnt > max_cnt ) : max_cnt = cnt

    return(array[max_cnt])

###
# main
if(__name__ == '__main__'):
    # input
    num = int(input())
    s = [None for _ in range(num)]
#    for i in range(0, num):
#        s[i] = input()

    ans = abc155c(num, s)

    # output
    for name in ans :
        print(name)
# else:
# do nothing

Submission status: Wrong Answer

Solution code:

import collections

N = int(input())
S = [input() for _ in range(N)]
S.sort()
c = collections.Counter(S)
values, counts = zip(*c.most_common())
if len(values) == 1:
    print(values[0])
'''
else:
    for i in range(N):
        if counts[i] == counts[0]:
            print(values[i])
        else:
            exit()
'''
ss = c.most_common()[0][1]
for values, counts in c.most_common():
    if counts == ss:
        print(values)

Submission status: Wrong Answer

Solution code:
import collections

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

res = []

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

for i in range(len(counts)):
    if counts[i] == counts[0]:
        res.append(values[i])

for i in res:
    print(i)

Submission status: Wrong Answer

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

def abc155c(num, s):
    appearance_dict = {} # 文字列:出現回数
    array = [[] for _ in range(num)] # (出現回数-1)をindexに文字列を配列で管理する
    max_cnt = 0

    for i in range(0, num):
        target = s[i]
        cnt = 0 # appearance count

        if( target in appearance_dict ):
            cnt = appearance_dict[target]
            array[cnt-1].remove(target)
        appearance_dict[target] = cnt+1

        # sortしながら配列に追加する
        insert_idx = 0
        target_array = array[cnt]
        if( target_array != [] ):
            for sort_idx in range(0, len(target_array)):
                if( target < target_array[sort_idx] ): 
                    insert_idx = sort_idx
                    break
        array[cnt].insert(insert_idx, target)

        if( cnt > max_cnt ) : max_cnt = cnt

    return(array[max_cnt])

###
# main
if(__name__ == '__main__'):
    # input
    num = int(input())
    s = [None for _ in range(num)]
    for i in range(0, num):
        s[i] = input()

    ans = abc155c(num, s)

    # output
    for name in ans :
        print(name)
# else:
# do nothing

Submission status: Wrong Answer

Solution code:
import collections
import sys

N = int(input())
S = [input() for _ in range(N)]
S.sort()
c = collections.Counter(S)
values, counts = zip(*c.most_common())
if len(values) == 1:
    print(values[0])
else:
    for i in range(N):
        if counts[i] == counts[0]:
            print(values[i])
        else:
            sys.exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
lis = []
lis2 = {}
lis3 = []
for _ in range(n):
  lis.append(input())

for w in lis:
  if w not in lis2.keys():
    lis2[w] = 1
  else:
    lis2[w] += 1

ma = max(lis2.values())

for k, v in lis2.items():
  if v == ma:
    lis3.append(k)

for a in lis3:
  print(a)

Submission status: Wrong Answer

Solution code:
N = int(input())
dic = {}
nmax = 1
for i in range(N):
  s = str(input())
  if s in dic:
    dic[s] += 1
    #毎回dic更新する度に最大値も更新
    nmax = dic[s]
  else:
    dic[s] = 1
slist = []
for k in dic:
  if dic[k] == nmax:
    slist.append(k)
for s in sorted(slist):
  print(s)

Submission status: Wrong Answer

Solution code:
n = int(input())
lis = []
lis2 = {}
lis3 = []
for _ in range(n):
  lis.append(input())

for w in lis:
  if w not in lis2.keys():
    lis2[w] = 1
  else:
    lis2[w] += 1

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

for a in range(len(sort_lis2)):
  if a == 0:
    lis3.append(sort_lis2[0][0])
  else:
    if sort_lis2[0][1] == sort_lis2[a][1]:
      lis3.append(sort_lis2[a][0])

for b in lis3:
  print(b)

Submission status: Wrong Answer

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

counter = Counter(s)
max_num = max(counter.values())
for i in counter:
    if counter[i] == max_num:
        print(i)

Submission status: Wrong Answer

Solution code:
import collections


N = int(input())
S = [input() for _ in range(N)]
S.sort()
c = collections.Counter(S)
values, counts = zip(*c.most_common())
if len(values) == 1:
    print(values[0])
else:
    for i in range(N):
        if counts[i] == counts[0]:
            print(values[i])
        else:
            exit()

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, Counter
import sys
n=int(input())
#d=defautldict(int)
l=[]
for _ in range(n):
  s=input()
  l.append(s)
c = Counter(l).most_common()
max_ = c[0][1]
for tup in c:
  p,q = tup
  if q != max_:
    sys.exit()
  else:
    print(p)

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
s = [input() for _ in range(n)]
s = collections.Counter(s)
m = max(s.values())

a = []
for d in s.items():
    if d[1] == m:
        a.append(d[0])
for s in a:
    print(s)

Submission status: Wrong Answer

Solution code:
from collections import Counter


def words_sort_ordered(words_list):
    cnt = Counter()
    for word in words_list:
        cnt[word] += 1

    written_words_number = []
    for x in cnt.values():
        written_words_number.append(x)

    answer_words_list = []

    for word, number in dict(cnt).items():
        if number == max(written_words_number):
            answer_words_list.append(word)

    return sorted(answer_words_list)


if __name__ == '__main__':
    words_num = int(input())
    words_list = [input() for i in range(words_num)]
    print(words_sort_ordered(words_list))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = []
for n in range(N):
    S.append(input())
dic = {}


for n in range(N):
    if S[n] not in dic:
        dic[S[n]] = 1
    else:
        dic[S[n]] += 1

max = max(dic.values())

for key,val in dic.items():
    if val == max:
        print(key)

Submission status: Wrong Answer

Solution code:
from collections import Counter
data = ['aaa', 'bbb', 'ccc', 'aaa', 'ddd']
counter = Counter(data)
print(counter.most_common()[0][0])

Submission status: Wrong Answer

Solution code:
from collections import Counter

pass

Submission status: Wrong Answer

Solution code:
N = int(input())
S = []
 
for _ in range(N):
    S.append(input())
 
ansarray = sorted(S)
 
P = []
count = 0
d = {}
 
for i in range(N-1):
    if ansarray[i+1] == ansarray[i]:
        count = count + 1
        d[ansarray[i]] = count
    if ansarray[i+1] != ansarray[i]:
        count = 0
 
if count == 0:
    for i in range(len(ansarray)):
        print(ansarray[i])
else:
    for k, v in d.items():
        if max(d.values()) == v:
            print(k)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = []
 
for _ in range(N):
    S.append(input())
 
ansarray = sorted(S)
 
P = []
count = 0
d = {}
 
for i in range(N-1):
    if ansarray[i+1] == ansarray[i]:
        count = count + 1
        d[ansarray[i]] = count
    if ansarray[i+1] != ansarray[i]:
        count = 0
 
if count == 0:
    for i in range(len(ansarray)):
        print(ansarray[i])

for k, v in d.items():
    if max(d.values()) == v:
        print(k)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
n=int(input())
dic=defaultdict(int)
for _ in range(n):
    s = input()
    dic[s]+=1
L=list(dic.items())
L.sort(key=lambda x:x[0])
c=L[0][1]
for a,b in L:
    c=max(c,b)
for p in L:
    if p[1] == c:
        print(p[0])
    else:
        break

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
n=int(input())
dic=defaultdict(int)
for _ in range(n):
    s = input()
    dic[s]+=1
L=list(dic.items())
L.sort(key=lambda x:-x[1])
c = L[0][1]
for p in L:
    if p[1] == c:
        print(p[0])
    else:
        break

Submission status: Wrong Answer

Solution code:
import collections

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

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

S = sorted(S)
# 配列カウントして入れてくれる
cnt = collections.Counter()
# カウンターして連想配列
for i in range(N):
    cnt[S[i]] += 1

max_k_list = [kv[0] for kv in cnt.items() if kv[1] == max(cnt.values())]

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

Submission status: Wrong Answer

Solution code:
import collections
def inverse_lookup(d, x):
    cList = []
    for k,v in d.items():
        if x == v:
            l = k
            cList.append(l) 
    return cList

n = int(input())
List=[input() for i in range(n)]
c = collections.Counter(List)
print(c)
n = max(c.values())
out=sorted(inverse_lookup(c,n))
for word in out:
    print(word)

Submission status: Wrong Answer

Solution code:
import collections as col


n=int(input())
s=[input() for i in range(n)]
c = col.Counter(s)
max = max(c.values())
ans = []

for key,val in c.items():
    if val == max:
       ans.append(key)


for i in ans:
    print(i)

Submission status: Wrong Answer

Solution code:
import collections

def main():
    n =int( input())

    cnt=dict()
    for _ in range(n):
        s=input()
        if s in cnt:
            cnt[s]+=1
        else :
            cnt[s]=1
    #print(cnt)
    
    a = [k for k, v in cnt.items() if v == max(cnt.values())]
    print("aa")
    a.sort()
    for elm in a:
        print(elm)

main()

Submission status: Wrong Answer

Solution code:
from collections import Counter

def main():
  n = int(input())
  l = [input() for _ in range(n)]
  s = Counter(l)
  ans = []
  for x in s.most_common():
    ans.append(x[0])
  ans.sort()
  for x in ans:
    print(x)
  

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
N = int(input())

Sdict = dict()
max = 0
for _ in range(N):
    s = input()
    if s in Sdict:
        Sdict[s] += 1
    else:
        Sdict[s] = 0
    
maxi = 0
lis = []
for k,v in Sdict.items():
    if v > maxi:
        lis = [k]
        maxi = v
    if v == maxi:
        lis.append(k)
lis.sort()
for k in lis:
    print(k)

Submission status: Wrong Answer

Solution code:
import collections

def main():
    n =int( input())

    cnt=dict()
    for _ in range(n):
        s=input()
        if s in cnt:
            cnt[s]+=1
        else :
            cnt[s]=1
    #print(cnt)
    
    a = [k for k, v in cnt.items() if v == max(cnt.values())]
    for elm in a :
        print(elm)

main()

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

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

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

Submission status: Wrong Answer

Solution code:
n = int(input())
dic = {}
for _ in range(n):
  k = input()
  dic[k] = 1 if k not in dic else dic[k] + 1
result = []
for i,j in dic.items():
  result.append((j,i))
  result.sort()
  maxi = result[-1][0]
  reresult=[]
  for i in result:
    if maxi == i[0]:
      reresult.append(i[1])
      for i in sorted(reresult):
        print(i)

Submission status: Wrong Answer

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

for i in range(n): #辞書型でカウント
  s = input()
  a.setdefault(s, 0)
  a[s] += 1
  
ans = []
mx = 0
for key, value in a.items(): #最大値のものをリストに入れる
  if mx < value:
    mx = value
    ans = [key]
  elif mx == value:
    ans.append(key)

for i in ans:
  print(i)

Submission status: Wrong Answer

Solution code:
import itertools
from collections import Counter

N=int(input())
a=[input() for i in range(N)]

a = sorted(a)
#print(a)


counter = Counter(a)

mode_v = counter.most_common()[0][-1]

#print(mode_v)
it = itertools.takewhile(
    lambda kv: kv[-1] == mode_v, sorted(counter.most_common())
)

#sorted(it)

for k, v in it:
	print(k)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = dict()
for _ in range(n):
    s = input()
    if s in a:
        a[s] += 1
    else:
        a[s] = 1

M = max(a.values())
for s in a:
    if a[s] == M:
        print(s)

Submission status: Wrong Answer

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

from collections import defaultdict
d = defaultdict(lambda:0)

for k in S:
    d[str(k)]+=1

dmax=max(d)
ansn=d[dmax]
ans=[]
for i in set(S):
    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:
from collections import Counter
N = int(input())
Sc = Counter([input() for _ in range(N)]).most_common()
print(Sc)
max_num = Sc[0][1]
ans = []
for key, val in Sc:
    if val == max_num:
        ans.append(key)
ans.sort()
for t in ans:
    print(t)

Submission status: Wrong Answer

Solution code:
import itertools
from collections import Counter

N=int(input())
a=[input() for i in range(N)]

a = sorted(a)
#print(a)


counter = Counter(a)

mode_v = counter.most_common()[0][-1]
it = itertools.takewhile(
    lambda kv: kv[-1] == mode_v, counter.most_common()
)

for k, v in it:
	print(k)

Submission status: Wrong Answer

Solution code:
import collections

n = int(input())
s = [input() for i in range(n)]
c = collections.Counter(s)

m = max(c.values())

ans = [k for k, v in c.items() if m == v]
ans.sort()

print(i for i in ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
List=[input() for i in range(N)]

import collections
a=collections.Counter(List)
values, counts = zip(*a.most_common())

b=max(counts) 
[print(k) for k, v in a.items() if v == b]

Submission status: Wrong Answer

Solution code:
import collections
import itertools

a = int(input())

s = [input() for i in range(a)]

counter = collections.Counter(s)

mode_v = counter.most_common()[0][-1]
it = itertools.takewhile(
    lambda kv: kv[-1] == mode_v, counter.most_common()
)

l = []

for k, v in it:
  l.append(k)

l = ' '.join(l)
print(l)

Submission status: Wrong Answer

Solution code:
#from math import sqrt
#from heapq import heappush, heappop
#from collections import deque

n = int(input())

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

l.sort()

max_count = 0
count = 0
results = []
ps = None
for s in l:
    if s == ps or ps is None:
        count += 1
    else:
        if max_count < count:
            max_count = count
            results = [ps]
        elif count == max_count:
            results.append(ps)
        count = 1
    ps = s

if max_count < count:
    max_count = count
    results = [ps]
elif count == max_count:
    results.append(ps)

results.sort()
print("--")
for str in results:
    print(str)