TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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.

Submission attempts (in order):
import sys
input = sys.stdin.readline

n = int(input())
s = list(input() for _ in range(n))

s_set = sorted(list(set(s)))
s_num = [0]*len(s_set)

for i in range(n):
    s_num[s_set.index(s[i])] += 1

ans_num = max(s_num)
for i in range(len(s_set)):
    if s_num[i] == ans_num:
        print(s_set[i])

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 = sorted(list(s.items()), key=lambda x: x[0])

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

Verdicts: Time Limit Exceeded

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
s = sorted([input() for i in range(n)])
s_ = list(set(s))
if len(s_) != n:
    s.append(0)
    co = [1] + [0 for i in range(len(s_)-1)]
    ind = 0
    for i in range(1, n):
        if s[i-1] == s[i]:
            co[ind] += 1
        else:
            ind += 1
            co[ind] += 1
    ma = max(co)
    arg = [i for i in range(len(s_)) if co[i]==ma]
    ans = [s_[i] for i in arg]
    print("\n".join(sorted(ans)))
    
else:
    print("\n".join(s))

n = int(input())
s = sorted([input() for i in range(n)])
s_ = list(set(s))
if len(s_) != n:
    s.append(0)
    co = [1] + [0 for i in range(len(s_)-1)]
    ind = 0
    for i in range(1, n):
        if s[i-1] == s[i]:
            co[ind] += 1
        else:
            ind += 1
            co[ind] += 1
    ma = max(co)
    arg = [i for i in range(len(s_)) if co[i]==ma]
    ans = [s_[i] for i in arg]
    print("\n".join(sorted(ans)))
    
else:
    print("\n".join(s_))

n = int(input())
s = sorted([input() for i in range(n)])
s_ = sorted(list(set(s)))
if len(s_) != n:
    s.append(0)
    co = [1] + [0 for i in range(len(s_)-1)]
    ind = 0
    for i in range(1, n):
        if s[i-1] == s[i]:
            co[ind] += 1
        else:
            ind += 1
            co[ind] += 1
    ma = max(co)
    arg = [i for i in range(len(s_)) if co[i]==ma]
    ans = [s_[i] for i in arg]
    print("\n".join(sorted(ans)))
    
else:
    print("\n".join(s))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import collections
import itertools

N = int(input())
L = []
D = {}
for _ in range(N):
    x = input()
    L.append(x)

counter = collections.Counter(L)

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

print(sorted(*(k for k, v in it)))


import collections
import itertools

N = int(input())
L = []
D = {}
for _ in range(N):
    x = input()
    L.append(x)

counter = collections.Counter(L)

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

print(*(k for k, v in it))


N = int(input())
L = []
D = {}
for _ in range(N):
    x = input()
    L.append(x)

for x in L:
    D[x] = 0
    
for x in L:
    D[x] += 1

SortD = sorted(D.items(), key=lambda x:x[1])
maxD = SortD[-1][1]
ans = []
for x in reversed(SortD):
    if x[1] == maxD:
        ans.append(x[0])
    else:
        break
for x in sorted(ans):
    print(x)


Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import collections
N = int(input())
A=[input() for i in range(N)]
c = collections.Counter(A)
values, counts = zip(*c.most_common())
k = max (counts)
l =counts.count(k)
V = []
for i in range(l):
  V.append(values[i])
sorted(V)
for j in range(len(V)):
  print(V[j])

import collections
N = int(input())
A=[input() for i in range(N)]
c = collections.Counter(A)
values, counts = zip(*c.most_common())
k = max (counts)
l =counts.count(k)
V = []
for i in range(l):
  V.append(values[i])
L = sorted(V)
for j in range(len(L)):
  print(L[j])

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
#C

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


result={}
for i in S:
    if i in result:
        result[i]+=1
    else:
        result[i]=1


x=max(result.values())

for i in result.items():
    if i[1]==x:
        print(i[0])

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

d={}

for i in s:
  if i in d:
    d[i]+=1
  else:
    d[i]=1
d=sorted(d.items,reverse=True)



for i in d.key:
  print(i)


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

d={}

for i in s:
  if i in d:
    d[i]+=1
  else:
    d[i]=1
d=sorted(d.items(),reverse=True)



for i in d.key():
  print(i)


#C

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


result={}
for i in S:
    if i in result:
        result[i]+=1
    else:
        result[i]=1

x=max(result.values())
x.sort

for i in result.items():
    if i[1]==x:
        print(i[0])

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

d={}

for i in s:
  if i in d:
    d[i]+=1
  else:
    d[i]=0
d=sorted(d.items,reverse=True)



for i in d.key:
  print(i)

#C

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


result={}
for i in S:
    if i in result:
        result[i]+=1
    else:
        result[i]=1

x=max(result.values())

Z=[]
for i in result.items():
    if i[1]==x:
        Z.append(i[0])
Z.sort()
for i in Z:
    print(i)

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())
S = ['0'] * N
for i in range(N):
    S[i] = input()
import collections
c = collections.Counter(S)
li = list(c.values())
ca = list(c.keys())
li.sort()
max = li[-1]
for i in ca:
    if c[i] == max:
        print(i)

#template
def inputlist(): return [int(k) for k in input().split()]
#template
N = int(input())
s = [0]*N
for i in range(N):
    s[i] = input()
from collections import Counter
c = Counter(s)
li = []
m = max(list(c.values()))
for i in list(c.keys()):
    if c[i] == m:
        li.append(i)
li.sort()
for i in range(len(li)):
    print(li[i])

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import collections
n = int(input())
s=[input() for i in range(n)]
ans = []


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


if n == 1:
    print(s[0])
elif n >= 2 and len(c.keys()) == 1:
    print(c.most_common()[0][0])
for i in range(len(k)):
    if k[0][0] == k[i][1]:
        ans.append(k[i][0])
    else:
        break
        
ans.sort()
print(*ans, sep="\n")


import collections
n = int(input())
s=[input() for i in range(n)]
ans = list()


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


if n == 1:
    print(s[0])
elif n >= 2 and len(c.keys()) == 1:
    print(c.most_common()[0][0])
for i in range(k):
    if k[0][0] == k[i][1]:
        ans.append(k[i][0])
    else:
        break
        
ans = sorted(ans)
[print(i) for i in ans]

import collections
n = int(input())
s=[input() for i in range(n)]
ans = list()


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


if n == 1:
    print(s[0])
elif n >= 2 and len(c.keys()) == 1:
    print(c.most_common()[0][0])
for i in range(len(k)):
    if k[0][0] == k[i][1]:
        ans.append(k[i][0])
    else:
        break
        
ans = sorted(ans)
[print(i) for i in ans]

import collections
n = int(input())
s=[input() for i in range(n)]
ans = list()

c = collections.Counter(s)

m = max(c.values())
for k,v in c.items():
    if v ==m:
        ans.append(k)
ans.sort()
print(*ans,sep="\n")

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())

dic = set()
for i in range(N):
    dic.add(str(input()))

dic = list(dic)
dic.sort()

for i in dic:
    print(i)

N = int(input())

dic = set()
for i in range(N):
    dic.add(str(input()))

dic.sort()

for i in list(dic):
    print(i)

N = int(input())

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

l = dic.items()
max = 0
for i in l:
    if i[1] > max:
        max = i[1]

result = []
for i in l:
    if i[1] == max:
        result.append(i[0])

result.sort()

for i in result:
    print(i)

N = int(input())


inin = []
for i in range(N):
    inin.append(str(input()))
    
dic = {}
for i in inin:
    if i not in dic:
        dic[i] = 1
    else:
        dic[i] = dic[i]+1

l = dic.items()
max = 0
for i in l:
    if i[1] > max:
        max = i[1]

result = []
for i in l:
    if i[1] == max:
        result.append(i[0])

result.sort()

for i in result:
    print(i)

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
c = Counter(s)
d = c.most_common()
cntmax = d[0][1]
l = [i[0] for i in c.items() if i[1] >= cntmax]
for i in range(len(l)):
    print(l[i])

import collections

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

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

slist = list(str.items())

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

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

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

words = []
cnt = dict()
for i in range(n):
  if s[i] not in words:
    words.append(s[i])
    cnt[s[i]] = 1
  else:
    cnt[s[i]] += 1

cnt_sorted = sorted(cnt.items(), key=lambda x:x[1], reverse=True)
for j in range(len(cnt_sorted)):
  if cnt_sorted[j][1] == cnt_sorted[0][1]:
    print(cnt_sorted[j][0])
  else:
    break

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

words = set()
cnt = dict()
for i in range(n):
  if s[i] not in words:
    words.add(s[i])
    cnt[s[i]] = 1
  else:
    cnt[s[i]] += 1

top_words = []
max_val = 0
for k, v in cnt.items():
  if v > max_val:
    max_val = v
    top_words = [k]
  elif v == max_val:
    top_words.append(k)

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())
S = []

for i in range(N):
    tmp = input()
    S.append(tmp)
S.sort()
if N == 1:
    print(S[0])
    exit()
ans = []
SS = []
count = 1
print(S)
for i in range(N-1):
    if i == N-2:
        if S[i] == S[i+1]:
            count += 1
            ans.append(count)
            SS.append(S[i])
        else:
            ans.append(count)
            SS.append(S[i])
            ans.append(1)
            SS.append(S[i+1])
    elif S[i] == S[i+1]:
        count += 1
    else:
        ans.append(count)
        SS.append(S[i])
        count = 1

m = max(ans)

for i in range(len(SS)):
    if ans[i] == m:
        print(SS[i])

from collections import Counter

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

count = Counter(S).most_common()
mode = count[0][1]
count.sort()
##print("--")
for i in range(len(count)):
    if count[i][1] == mode:
        print(count[i][0])


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
def main():
    N = int(input())
    S = [input() for _ in range(N)]
    dict = {}
    for i in range(N):
        if S[i] not in dict:
            dict[S[i]] = 1
        else:
            dict[S[i]] += 1
    ans = {}
    p = 0
    for i ,j in dict.items():
        if p < j : p = j

        if j not in ans:
            ans[j] = [i]
        else:
            ans[j].append(i)
    for i in range(len(ans[p])):
        print(ans[p][i])
if __name__ == '__main__':
    main()


def main():
    N = int(input())
    S = [input() for _ in range(N)]
    dict = {}
    for i in range(N):
        if S[i] not in dict:
            dict[S[i]] = 1
        else:
            dict[S[i]] += 1
    ans = {}
    p = 0
    for i ,j in dict.items():
        if p < j : p = j

        if j not in ans:
            ans[j] = [i]
        else:
            ans[j].append(i)
    ans[p].sort()
    for i in range(len(ans[p])):
        print(ans[p][i])
if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
num = int(input())
i = [int(input()) for _ in range(num)]

count_dict = {}
for ele in i:
  if ele not in count_dict:
    count_dict[ele] = 1
  else:
    count_dict[ele] += 1
    
max_count = max(count_dict.values())
max_str = [a for a in count_dict if count_dict[a] == max_count]
for string in sorted(max_str):
  print(string)

num = int(input())
i = [int(input()) for _ in range(num)]

count_dict = {}
for ele in i:
  if ele not in count_dict:
    count_dict[ele] = 1
  else:
    count_dict[ele] += 1

max_count = max(count_dict.values())
max_str = [a for a in count_dict if count_dict[a] == max_count]
for string in sorted(max_str):
  print(string)

num = int(input())
i = [input() for _ in range(num)]
 
count_dict = {}
for ele in i:
  if ele not in count_dict:
    count_dict[ele] = 1
  else:
    count_dict[ele] += 1
 
max_count = max(count_dict.values())
max_str = [a for a in count_dict if count_dict[a] == max_count]
for string in sorted(max_str):
  print(string)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import collections

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

s = collections.Counter(S)

max_val = max(s.values())

for key, value in s.items():
  if value == max_val:
    print(key)

N = int(input())
S = [input() for _ in range(N)]
 
s = {}

for i in S:
  if i in s:
    s[i] += 1
  else:
    s[i] = 1
 
max_val = max(s.values())
 
for key, value in s.items():
  if value == max_val:
    print(key)

from collections import defaultdict

N = int(input())
S = [input() for _ in range(N)]
  
d = defaultdict(int)
for k in S:
  d[k] += 1

max_val = max(d.values())
keys_of_max_val = [key for key in d if d[key] == max_val]

for i in keys_of_max_val:
  print(i)

from collections import defaultdict, Counter

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

a = Counter(lis)

tmp = 0
for key, value in a.items():
    tmp = max(value, tmp)

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

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

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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]);

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 range(len(ans)):
  print(ans[a]);

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]);


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

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 a,b in c.most_common():
    if b == num:
      ans.append(a);
      continue;
    
    else:
      break;

ans = sorted(ans);

for i in ans:
  print(i);


Verdicts: Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())
S =[]
times = {}
for i in range(N):
  word = input()
  if word in times:
    times[word] = times[word] + 1
  else:
    times[word] = 1
print(times)
max_k_list = [kv[0] for kv in times.items() if kv[1] == max(times.values())]
new_str_list = sorted(max_k_list)
for i in new_str_list:
  print(i)

N = int(input())
S =[]
times = {}
for i in range(N):
  word = input()
  if word in times:
    times[word] = times[word] + 1
  else:
    times[word] = 1
max_value = max(times.values())
words = []
for i in times.items():
  if i[1] == max_value:
    words.append(i[0])
words = sorted(words)
for i in words:
  print(i)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())
dictionary = {}
for i in range(N):
    S = input()
    if S not in dictionary.keys():
        dictionary[S] = 1
    else:
        dictionary[S] += 1


value_max = max(dictionary.values())

max_list = []
for k, v in dictionary.items():
    if v == value_max:
        max_list.append(k)

for i in max_list:
    print(i)

N = int(input())
dictionary = {}
for i in range(N):
    S = input()
    if S not in dictionary.keys():
        dictionary[S] = 1
    else:
        dictionary[S] += 1


value_max = max(dictionary.values())

max_list = []
for k, v in dictionary.items():
    if v == value_max:
        max_list.append(k)

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import collections
N = int(input())
S_list = [input() for i in range(N)]
c = collections.Counter(S_list)
l = {}
for x, y in zip(*c):
  if x in l.keys():
    l[x] = [y]
  else:
    l[x].append(y)

for x in sorted(l.keys(), reverse=True):
  for y in sorted(l[x]):
    print(y)




import collections
N = int(input())
S_list = [input() for i in range(N)]
c = collections.Counter(S_list)
l = {}
m = c[0][0]
for x, y in zip(*c):
  if x in l.keys():
    l[x] = [y]
  else:
    l[x].append(y)

  
for y in sorted(l[m]):
  print(y)

N = int(input())

value_dict = {}

for x in range(N):
    value = input()
    if value not in value_dict.keys():
        value_dict[value] = 1
        continue
    value_dict[value] += 1

max_count = max(value_dict.values())
max_values = [k for k, v in value_dict.items() if v == max_count]
max_values.sort()


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


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())

S = [None] * N

m = dict()

for i in range(N):
  s = input()
  if not s in m.keys():
    m[s] = 1
  else:
    m[s] += 1

max_cnt = max(m.values())

ret = []

for k, v in sorted(m.items(), key=lambda x: x[1], reverse=True):
  if v < max_cnt:
    break
  ret.append(k)

ret.sort()
print(ret)

N = int(input())
 
S = [None] * N
 
m = dict()
 
for i in range(N):
  s = input()
  if not s in m.keys():
    m[s] = 1
  else:
    m[s] += 1
 
max_cnt = max(m.values())
 
ret = []
 
for k, v in sorted(m.items(), key=lambda x: x[1], reverse=True):
  if v < max_cnt:
    break
  ret.append(k)
 
ret.sort()
for s in ret:
  print(s)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from collections import Counter
N = int(input())
A = []
for i in range(N):
  A.append(input())
C= Counter(A)
B = 0
for v in c.values():
  B = max(B,v)
ans = []
for k, v in c.items()
  if v == B:
    ans.append(k)
ans.sort()
print(*ans,sep='\n')

from collections import Counter
N = int(input())
A = []
for i in range(N):
  A.append(input())
C= Counter(A)
B = 0
for v in c.values():
  B = max(B,v)
ans = []
for k, v in c.items():
  if v == B:
    ans.append(k)
ans.sort()
print(*ans,sep='\n')

from collections import Counter
N = int(input())
A = []
for i in range(N):
  A.append(input())
C= Counter(A)
B = 0
for v in C.values():
  B = max(B,v)
ans = []
for k, v in C.items():
  if v == B:
    ans.append(k)
ans.sort()
print(*ans,sep='\n')

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import collections
N = int(input())
l = []
for _ in range(N):
    s = input()
    l.append(s)
c = collections.Counter(l)
i=0
j=0
while True:
    print(c.most_common()[i][0])
    if i+1<len(c.most_common()):
        if c.most_common()[i+1][1] == c.most_common()[i][1]:
            i+=1
            continue
        else:
            break
    else:
        break


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

ans=sorted(ans)

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from collections import Counter

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

max = s[0][1]
max_s = []

for i in range(len(s)):
    if int(s[i][1]) == int(max):
        max_s.append(s[i][0])
max_s.sort()
print(max_s)

from collections import Counter

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

max = s[0][1]
max_s = []

for i in range(len(s)):
    if int(s[i][1]) == int(max):
        max_s.append(s[i][0])
max_s.sort()

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import sys #sys.stdin.readline()
import heapq #heap
from collections import defaultdict
fastinp = lambda: sys.stdin.readline().split(' ')[0].split('\n')
inp = lambda: input().split(' ')
ml = lambda x, y=int: list(map(y, x))
debug = lambda *args: print(*args, sep=' | ')
n = int(fastinp()[0])
hmap = defaultdict(int)
for i in range(n):
    hmap[fastinp()[0]] += 1
m = 0
for k, v in hmap.items():
    m = max(m, v)
for k, v in hmap.items():
    if v == m:
        print(k)


import sys #sys.stdin.readline()
import heapq #heap
from collections import defaultdict
fastinp = lambda: sys.stdin.readline().split(' ')[0].split('\n')
inp = lambda: input().split(' ')
ml = lambda x, y=int: list(map(y, x))
debug = lambda *args: print(*args, sep=' | ')
n = int(fastinp()[0])
hmap = defaultdict(int)
for i in range(n):
    hmap[fastinp()[0]] += 1
m = 0
for k, v in hmap.items():
    m = max(m, v)
list = []
for k, v in hmap.items():
    if v == m:
        list.append(k)
print(*sorted(list), sep='\n')


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n=int(input())
a={}
for _ in range(n):
  m=input()
  if m in a:
    a[m]+=1
  else:
    a[m]=1
for k in a.items() :
     if k[1] == max(a.values()):
      print(k[0])

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from collections import Counter

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

counter = Counter(s)
count = counter.most_common()
print(counter, count)
most = count[0][1]

c = []
for i in range(len(count)):
    print(count[i][1])
    if most == count[i][1]:
        c.append(count[i][0])

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

from collections import Counter

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

counter = Counter(s)
count = counter.most_common()
most = count[0][1]

c = []
for i in range(len(count)):
    print(count[i][1])
    if most == count[i][1]:
        c.append(count[i][0])

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

from collections import Counter

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

counter = Counter(s)
count = counter.most_common()
most = count[0][1]

c = []
for i in range(len(count)):
    if most == count[i][1]:
        c.append(count[i][0])

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

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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
for x in range(0,len(lis)): 
    if lis[j][0] == fnum:
        lis2.append(lis[j][1])
    else:
        break
lis2.sort()
for k in lis2:
    print(k)
    

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

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

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
def resolve():
    N = int(input())
    arr = list(map(int, input().split()))
    for num in arr:
        if not num % 2 and not (num % 3 == 0 or num % 5 == 0):
            print('DENIED')
            quit()
    print('APPROVED')

resolve()

def resolve():
    N = int(input())
    from collections import defaultdict
    cnt = defaultdict(int)
    for _ in range(N):
        cnt[input()] += 1
    items = sorted(cnt.items(), key=lambda x: (-x[1], x[0]))
    max_v = items[0][1]
    for item in items:
        if max_v != item[1]:
            break
        print(item[0])

resolve()

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
from collections import *
N = int(input())
count = Counter(input().split())


m = max(count.values())


ans = [a for a,b in count.items() if b == m]
ans.sort()
for S in ans:
    print(S)

from collections import *
N = int(input())
count = Counter([ input() for _ in range(N)])

m = max(count.values())

ans = [a for a,b in count.items() if b == m]
ans.sort()
for S in ans:
    print(S)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
list_a = []

for i in range(n):
  list_a.append(input())

d = {}
for i in list_a:
  if i in d:
    d[i] = d[i] + 1
  else:
    d[i] = 1

key = [k for k, v in d.items() if v == d[max(d)]]
for i in key:
  print(i)

# n = int(input())
# list_a = []


#   list_a.append(input())

# d = {}


#     d[i] = d[i] + 1
#   else:
#     d[i] = 1



#   print(i)

  
n = int(input())
list_a = []

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

max_value = max(d.values())
key = sorted([k for k, v in d.items() if v == max_value])
for i in key:
    print(i)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import sys
stdin = sys.stdin
from collections import defaultdict

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

n = ni()
d = defaultdict(int)
for _ in range(n):
    s = ns()
    d[s] += 1
d = sorted(d.items(), key = lambda x:x[1], reverse=True)
ki, vi = d[0]
print(ki)
for k, v in d[1:]:
    if v == vi:
        print(k)
    else:
        quit()

import sys
stdin = sys.stdin
from collections import defaultdict

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

n = ni()
d = defaultdict(int)
for _ in range(n):
    s = ns()
    d[s] += 1
d = sorted(d.items(), key = lambda x:x[1], reverse=True)
ki, vi = d[0]
k = [ki]
for ki, v in d[1:]:
    if v == vi:
        k.append(ki)
k.sort()
for ki in k:
    print(ki)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import collections
n=int(input())
s=[]
for i in range(n):
  S=input()
  s.append(S)
d=collections.Counter(s)
e=list(d.items())
e.sort(key=lambda x:-x[1])
f=list(d.values())
f.sort(reverse=True)
g=list(d.keys())
num=1
for i in range(1,len(f)):
  if f[i]==f[0]:
    num+=1
  else:
    break
lst=[]
for j in range(num):
  lst.append(g[j])
lst.sort()
for j in range(num):
  print(lst[j])
  




import collections
n=int(input())
s=[]
for i in range(n):
  S=input()
  s.append(S)
d=collections.Counter(s)
e=list(d.items())
e.sort(key=lambda x:-x[1])
lst=[]
for i in range(len(e)):
  if e[i][1]==e[0][1]:
    lst.append(e[i][0])
  else:
    break
lst.sort()
for j in range(len(lst)):
  print(lst[j])




Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from collections import defaultdict
from collections import OrderedDict
N = int(input())
ans = dict()
for _ in range(N):
    k = str(input())
    if k in ans:
        ans[k]+=1
    else:
        ans.update({k:1})
eve = defaultdict(list)
for key, value in sorted(ans.items()):
    eve[value].append(key)
l = eve[max(groupedByValue)]
for i in l:
    print(i)

from collections import defaultdict
from collections import OrderedDict
N = int(input())
answer = dict()
for _ in range(N):
    k = str(input())
    if k in ans:
        ans[k]+=1
    else:
        ans.update({k:1})
groupedByValue = defaultdict(list)
for key, value in sorted(ans.items()):
    groupedByValue[value].append(key)
l = groupedByValue[max(groupedByValue)]
for i in l:
    print(l)

from collections import defaultdict
from collections import OrderedDict
N = int(input())
ans = dict()
for _ in range(N):
    k = str(input())
    if k in ans:
        ans[k]+=1
    else:
        ans.update({k:1})
groupedByValue = defaultdict(list)
for key, value in sorted(ans.items()):
    groupedByValue[value].append(key)
j = groupedByValue[max(groupedByValue)]
for i in j:
    print(i)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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)

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:
    continue
  ans.append(name)
ans.sort()
for a in ans:
  print(a)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N = input().split(' ')
S = [input() for i in range(N)]

ans = {}
for i in S:
  if i in ans:
    ans[i] += 1
  else:
    ans[i] = 1

max_value = max(ans.value())
ANS = []
for key, value in ans.item():
  if ans[key] == max_value:
    ANS.append(key)
    
for i in sorted(ANS):
  print(i)

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

ans = {}
for i in S:
  if i in ans:
    ans[i] += 1
  else:
    ans[i] = 1

max_value = max(ans.values())
ANS = []
for key, value in ans.items():
  if ans[key] == max_value:
    ANS.append(key)
    
for i in sorted(ANS):
  print(i)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
from itertools import groupby

n = int(input())

words = []

for i in range(n):
    words.append(input())

words.sort()

count_w = {}

for key, value in groupby(words):
    count_w[key] = len(list(value))

for i in list(count_w.keys):
    if count_w[i] == max(list(count_w.values)):
        print(i)

n = int(input())

words = [input() for _ in range(n)]

d = {}

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

m = max(d.values())
ANS = []

for keys in d.keys():
    if d[keys] == m:
        ANS.append(keys)

ANS = sorted(ANS)

for i in ANS:
    print(i)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input().rstrip())
d = {}
for _ in range(N):
    string = input().rstrip()
    if string in d.keys():
        d[string] += 1
    else:
        d[string] = 1
d = sorted(d.items(), key=lambda x:x[1], reverse=True)
print(d)
rets = []
max = -1
for string, val in d:
    if max == -1:
        max = val
    elif max != val:
        break
    rets.append(string)

for a in rets[::-1]:
    print(a)


N = int(input().rstrip())
d = {}
for _ in range(N):
    string = input().rstrip()
    if string in d.keys():
        d[string] += 1
    else:
        d[string] = 1
d = sorted(d.items(), key=lambda x: x[1], reverse=True)
# print(d)
rets = []
max = -1
for string, val in d:
    if max == -1:
        max = val
    elif max != val:
        break
    rets.append(string)

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


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from collections import defaultdict

n = int(input())
dict = defaultdict(int)

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

ans_list = [k for k,v in dict.items() if v == max(dict.values())]

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

from collections import defaultdict

n = int(input())
dict1 = defaultdict(int)

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

dict1 = sorted(dict1.items(), key=lambda x:x[1], reverse=True)
max = dict1[0][1]
ans = []
for i in range(len(dict1)):
    if dict1[i][1] == max:
        ans.append(dict1[i][0])
    else:
        break

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import collections

n = int(input())
s = [input() for i in range(n)]
cnt = collections.Counter(s)
largest= max(list(cnt.values()))

for k in cnt.keys():
  if cnt[k] == largest:
    print(k)

import collections


n = int(input())
s = [input() for i in range(n)]
cnt = collections.Counter(s)
largest= max(list(cnt.values()))
l = []

for k in cnt.keys():
  if cnt[k] == largest:
    l.append(k)

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import Counter
n=int(input())
s=[input() for i in range(n)]
c=Counter(s)
l=list(c)
l.sort(key=lambda x:x[1],reverse=True)
a=l[0][1]
i=0
while i<n and l[i][1]==a:
  print(l[i][0])
  i+=1

from collections import Counter
n=int(input())
s=[input() for i in range(n)]
c=Counter(s)
l=c.most_common()
l.sort(key=lambda x:x[1],reverse=True)
a=l[0][1]
i=0
ans=[]
while i<len(l) and l[i][1]==a:
  ans.append(l[i][0])
  i+=1
ans.sort()
for j in ans:
  print(j)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import collections as col
N=int(input())
S=[]
answer=[]

for _ in range(N):
    S.append(input())
T=sorted(S)
s=col.Counter(T)
values, counts = zip(*s.most_common())
#print(values,counts)
print(values[0])
t=1

for i in range(N):
    if counts[i]==max(counts):
        answer.append(values[i])
answer.sort()
for j in answer:
    print(j)
 

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

S_d={}
A=[]

for i in range(N):
    if S[i] not in S_d.keys():
        S_d[S[i]]=1
    else:
        S_d[S[i]]+=1

max_co=max(S_d.values())

for j in S_d.keys():
    if S_d[j]==max_co:
        A.append(j)

B=sorted(A)

for k in B:
    print(k)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
s = [input() for _ in range(n)]

s_sort = sorted(s)

s_num = [1]*n

for i in range(1,n):
    if s_sort[i] == s_sort[i-1]:
        s_num[i] += s_num[i-1]

Maxnum = max(s_num)

index_num = [n for n, v in enumerate(s_num) if v == Maxnum]

[print(s_sort[i]) for i in index_num,]


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

s_sort = sorted(s)

s_num = [1]*n

for i in range(1,n):
    if s_sort[i] == s_sort[i-1]:
        s_num[i] += s_num[i-1]

Maxnum = max(s_num)

index_num = [n for n, v in enumerate(s_num) if v == Maxnum]

[print(s_sort[i]) for i in index_num]


Verdicts: Runtime Error

Accepted
Problem: 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.

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

set_list = set(S)
str_ls =[]
num_ls = []
flag = 0

for i in set_list:
    num_ls.append(S.count(i))
    str_ls.append(i)

for i in range(len(str_ls)):
    if num_ls[i] == max(num_ls):
        print(str_ls[i])

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

ls=[]
for i in S:
    if i not in ls:
        ls.append(i)
str_ls =[]
num_ls = []
flag = 0

for i in ls:
    num_ls.append(S.count(i))
    str_ls.append(i)

for i in range(len(str_ls)):
    if num_ls[i] == max(num_ls):
        print(str_ls[i])

from collections import defaultdict
from collections import OrderedDict
N = int(input())
ans = dict()
for _ in range(N):
    k = str(input())
    if k in ans:
        ans[k]+=1
    else:
        ans.update({k:1})
groupedByValue = defaultdict(list)
for key, value in sorted(ans.items()):
    groupedByValue[value].append(key)
l = groupedByValue[max(groupedByValue)]
for i in l:
    print(i)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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))

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

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]
for A in sorted(ans):
    print(A)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):

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




l=list(set(s))


l.sort()


a=[]


for i in range(len(l)):
    a.append(s.count(l[i]))
    

r j in range(len(a)):
    while a[j]==max(a):
        print(l[j])
        j+=1




n=int(input())
s=[input() for i in range(n)]
s=sorted(s)
s.append('')
s1=s[0]
ans=['']
tmp=1
kaisu=0
for i in range(1,n+1):
    if s[i]==s1:
        
        tmp+=1
    else:
        if kaisu<tmp:
        
        
        
            ans=['']
            ans.append(s1)
            kaisu=tmp
        elif kaisu==tmp:
        
            ans.append(s1)
        tmp=1
        s1=s[i]
        
for i in range(1,len(ans)):
    print(ans[i])

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N=int(inpu())
ans=[]
dic={}
for i in range(N):
  let=input()
  if let in dic.keys:
    dic.update({let:1})
  else:
    dic.update({let:dic[let]+1})
score_sorted = sorted(score.items(), key=lambda x:x[1])
a=0
for each in score_sorted.keys():
  if score_sorted[each]>=a:
    ans+=each
    a=score_sorted[each]
  else:
    break
ans.sort()
for each in ans:
  print(each)

dic = {}
ans = []
a = 0

N = int( input() )
for i in range( N ):
  let = input()
  if let not in dic:
    dic.update( { let : 1 } )
  else:
    num=dic[ let ]
    dic[ let ] = num + 1
dic_sorted = sorted(dic.items(), key=lambda x:x[1])
for each in dic_sorted.keys():
  if dic_sorted[ each ] >= a:
    ans+=1
    a=dic_sorted[ each ]
  else:
    break
ans.sort()
for each in ans:
  print(each)

dic = {}
ans = []
a = 0

N = int( input() )
for i in range( N ):
  let = input()
  if let not in dic:
    dic.update( { let : 1 } )
  else:
    num=dic[ let ]
    dic[ let ] = num + 1
dic_sorted = sorted(dic.items(), key=lambda x:x[1],reverse=True)
for each in dic_sorted:
  if each[1] >= a:
    ans.append(each[0])
    a=each[1]
  else:
    break
ans.sort()
for each in ans:
  print(each)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())
k = []
maximum = 1
now = 1
ans = []
for i in range(N):
    S = input()
    k.append(S)
k.sort()
for j in range(len(k)-1):
    if k[j] == k[j+1]:
        now += 1
        if j == len(k)-2:
            if now>maximum:
                maximum = now
                ans.clear()
                ans.append(k[j])
            elif now == maximum:
                ans.append(k[j])
            else:
                break
    else:
        if now>maximum:
            maximum = now
            ans.clear()
            ans.append(k[j])
        elif now == maximum:
            ans.append(k[j])
        else:
            continue
        if j == len(k)-2:
            if now == maximum:
                ans.append(k[j+1])
for i in range(len(ans)):
    print(ans[i])

import collections
N = int(input())
k = []
for i in range(N):
  k.append(input())
c = collections.Counter(k)
l = list(c.most_common())
P = l[0][1]
a = []
for i in range(len(l)):
  if l[i][1] == P:
    a.append(l[i][0])
  else:
    break
a.sort()
for j in range(len(a)):
  print(a[j])

Verdicts: Wrong Answer

Accepted