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: Time Limit Exceeded

Solution code:
n=int(input())
s=[""]*n
ans=[""]

for i in range(n):
  s[i]=input()
  
  
ind=list(set(s))
num=s.count(ind[0])

for i in range(len(ind)):
  if (s.count(ind[i])>num):
    ans=[ind[i]]
    num=s.count(ind[i])
  elif (s.count(ind[i])==num and ans!=[""]):
    ans.append(ind[i])
  elif (s.count(ind[i])==num and ans==[""]):
    ans=[ind[i]]
ans=sorted(ans)
for i in range(len(ans)):
  print(ans[i])

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
b = ''
for i in range(n):
    b += (input() + ' ')
a = list(b.split())
a_count = [a.count(i) for i in a]
print('\n'.join(sorted(set([a[i] for i in range(len(a_count)) if a_count[i] == max(a_count)]))))

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
sn=[input() for _ in range(n)]
l=set(sn)
cnt=[sn.count(s) for s in l]
m=max(cnt)
ans = [s for i,s in enumerate(l) if cnt[i]==m]
for a in sorted(ans):
    print(a)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
S=[input() for i in range(n) ]
L=sorted(set(S))
cnt=[]
for l in L:
    cnt.append(S.count(l))
op=[L[i] for i, x in enumerate(cnt) if x == max(cnt)]
print("\n".join(op))

Submission status: Time Limit Exceeded

Solution code:
# 初期入力
N = int(input())
word = [ input() for i in range(N) ]

# 単語をキーに数を数えて辞書
from collections import Counter
kazu_word = Counter(word)

#一番多い単語を抜き出す
kazu_word_max =[i for i,v in kazu_word.items() if v == max(kazu_word.values())]
kazu_word_max_sorted = sorted(kazu_word_max)
"""
print(kazu_word)
print(kazu_word_max)
"""
#print(*kazu_word_max_sorted,sep="\n")
print("\n".join(kazu_word_max_sorted))

Submission status: Time Limit Exceeded

Solution code:
# 初期入力
N = int(input())
word = [ input() for i in range(N) ]

# 単語をキーに数を数えて辞書
from collections import Counter
kazu_word = Counter(word)

#一番多い単語を抜き出す
kazu_word_max =[i for i,v in kazu_word.items() if v == max(kazu_word.values())]
kazu_word_max.sort()
"""
print(kazu_word)
print(kazu_word_max)
"""
print(*kazu_word_max,sep="\n")

Submission status: Time Limit Exceeded

Solution code:
# 初期入力
N = int(input())
word = [ input() for i in range(N) ]

# 単語をキーに数を数えて辞書
from collections import Counter
kazu_word = Counter(word)

#一番多い単語を抜き出す
kazu_word_max =[i for i,v in kazu_word.items() if v == max(kazu_word.values())]
kazu_word_max_sorted = sorted(kazu_word_max)
"""
print(kazu_word)
print(kazu_word_max)
"""
print(*kazu_word_max_sorted,sep="\n")

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a = []
for i in range(n):
    a.append(input())
a_count = [a.count(i) for i in a]
print('\n'.join(sorted(set([a[i] for i in range(len(a_count)) if a_count[i] == max(a_count)]))))

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
n = int(input())
lists = [input() for i in range(n)]
count = [0] * n
for i in range(n):
    for j in range(n):
        if lists[i] == lists[j]:
            count[i] += 1
max = max(count)
for k in range(n):
    if count[k] != max:
        lists[k] = 11111111111
ans = set(lists)
ans.discard(11111111111)
new_ans = list(ans)
new_ans.sort()
for l in range(len(new_ans)):
    print(new_ans[l],end="")

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
lists = [input() for i in range(n)]
count = [0] * n
for i in range(n):
    for j in range(n):
        if lists[i] == lists[j]:
            count[i] += 1
max = max(count)
for k in range(n):
    if count[k] != max:
        lists[k] = 11111111111
ans = set(lists)
ans.discard(11111111111)
new_ans = sorted(tuple(ans))
for l in range(len(new_ans)):
    print(new_ans[l])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
lists = [input() for i in range(n)]
count = [0] * n
for i in range(n):
    for j in range(n):
        if lists[i] == lists[j]:
            count[i] += 1
max = max(count)
for k in range(n):
    if count[k] != max:
        lists[k] = 11111111111
ans = set(lists)
ans.discard(11111111111)
new_ans = sorted(list(ans))
for l in range(len(new_ans)):
    print(new_ans[l])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
lists = [input() for i in range(n)]
count = [0] * n
for i in range(n):
    for j in range(n):
        if lists[i] == lists[j]:
            count[i] += 1
max = max(count)
for k in range(n):
    if count[k] != max:
        lists[k] = "none1111111"
ans = set(lists)
ans.discard("none1111111")
new_ans = sorted(list(ans))
for l in range(len(new_ans)):
    print(new_ans[l])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
lists = [input() for i in range(n)]
count = [0] * n
# リストの要素ごとに書かれた回数をカウント
for i in range(n):
    for j in range(n):
        if lists[i - 1] == lists[j - 1]:
            count[i - 1] += 1
# 最も多い回数を取得
max = max(count)
# 最も多い回数ではない要素を削除用データに置換
for k in range(n):
    if count[k - 1] == max:
        continue
    else:
        lists[k - 1] = "none1111111"
# 最も多い回数の要素から重複を削除、昇順でソート
ans = set(lists)
# 削除用データを削除
ans.discard("none1111111")
ans_list = list(ans)
new_ans = sorted(ans_list)
for l in range(len(new_ans)):
    print(new_ans[l])

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter

N, *S = open(0).read().split()
count = Counter(S)
ans_list = [i for i, j in count.items() if j == max(count.values())]
ans_list.sort()
print("\n".join(ans_list))

Submission status: Time Limit Exceeded

Solution code:
N, *S = open(0).read().split()
dict = {i : 0 for i in S}
for i in S:
  dict[i] += 1
ans_list = [i for i, j in dict.items() if j == max(dict.values())]
ans_list.sort()
print("\n".join(ans_list))

Submission status: Time Limit Exceeded

Solution code:
N, *S = open(0).read().split()
dict = {i : 0 for i in S}
for i in S:
  dict[i] += 1
print("\n".join(sorted([i for i, j in dict.items() if j == max(dict.values())])))

Submission status: Time Limit Exceeded

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

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

dict = {i : 0 for i in S}
for i in S:
  dict[i] += 1
for k in sorted([i for i, j in dict.items() if j == max(dict.values())]):
  print(k)

Submission status: Time Limit Exceeded

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

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

dict = {i : 0 for i in set(S)}
for i in S:
  dict[i] += 1
for k in sorted([i for i, j in dict.items() if j == max(dict.values())]):
  print(k)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
lst = []
for i in range(N):
  lst.append(input())
count_dict = {}
for v1 in lst[:-1]:
  count_dict[v1] = 1
  for v2 in lst[lst.index(v1)+1:]:
    if v1 == v2:
      count_dict[v1] += 1
if not lst[-1] in count_dict.keys():
  count_dict[lst[-1]] = 1
max_kv_list = [kv for kv in count_dict.items() if kv[1] == max(count_dict.values())]
for v in sorted(max_kv_list):
  print(v[0])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
lst = []
for i in range(N):
  lst.append(input())
count_dict = {}
for v1 in lst[:-1]:
  count_dict[v1] = 1
  for v2 in lst[lst.index(v1)+1:]:
    if v1 == v2:
      count_dict[v1] += 1
if not lst[-1] in count_dict.keys():
  count_dict[lst[-1]] = 1
max_count = 1
for key, value in count_dict.items():
  if count_dict[key] > max_count:
    max_key = key
    max_count = count_dict[key]
max_keys = []
for key in count_dict.keys():
  if count_dict[key]  == max_count:
    max_keys.append(key)
for v in sorted(max_keys):
  print(v)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a = []
for i in range(n):
    a.append(input())
a_count = [a.count(i) for i in a]
[print(j) for j in sorted(set([a[i] for i in range(len(a_count)) if a_count[i] == max(a_count)]))]

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
N = int(input())
S = [input() for i in range(N)]
C = Counter(S)
M = [kv[0] for kv in C.items() if kv[1] == max(C.values())]
M.sort()
A = '\n'.join(M)
print(A)

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
N = int(input())
S = [input() for i in range(N)]
C = Counter(S)
M = [kv[0] for kv in C.items() if kv[1] == max(C.values())]
M.sort()
for i in range(len(M)):
    print(M[i])

Submission status: Time Limit Exceeded

Solution code:
import sys
n = int(input())
s = []
s_num = []
for i in range(n):
  si = input()
  if not si in s:
    s.append(si)
    s_num.append(1)
  else:
    s_num[s.index(si)] += 1
maxs = []
m = max(s_num)
for j in range(len(s_num)):
  if s_num[j] == m:
    maxs.append(s[j])
maxs = sorted(maxs)
for ma in maxs:
  print(ma)

Submission status: Time Limit Exceeded

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

nondup=list(set(S))
count_list={}
for element in nondup:
    count_list[element]=S.count(element)
count_sorted = sorted(count_list.items(), key=lambda x:x[1], reverse=True)

max_number=0
max_list=[]
for n in range(len(count_sorted)):
    if count_sorted[n][1]>=max_number:
        max_number=count_sorted[n][1]
        max_list.append(count_sorted[n][0])
print(*sorted(max_list),sep='\n')

Submission status: Time Limit Exceeded

Solution code:
# 200216 C

import collections

N = int(input())
S = [""] * N
for i in range(N):
    S[i] = input()
c = collections.Counter(S)
cv = c.values()
ans = []
for i in c:
    if c[i] == max(cv):
        ans.append(i)
ans = sorted(ans)
for i in ans:
    print(i,end=" ")
print("")

Submission status: Time Limit Exceeded

Solution code:
# 200216 C

import collections

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

c = collections.Counter(S)
cv = c.values()
ans = []
for i in c:
    if c[i] == max(cv):
        ans.append(i)
ans = sorted(ans)
for i in ans:
    print(i,end=" ")
print("")

Submission status: Time Limit Exceeded

Solution code:
# 200216 C

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


Ssimple = sorted(list(set(S)))
cntlist = [0] * len(Ssimple)

for i in range(len(Ssimple)):
    cntlist[i] = S.count(Ssimple[i])

for i in range(len(Ssimple)):
    if cntlist[i] == max(cntlist):
        print(Ssimple[i],end=" ")
print("")

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
S=[]
Word=set()
for i in range(N):
    s=input()
    Word.add(s)
    S.append(s)
Word=list(Word)
ans=[[0]*2 for i in range(len(Word))]
maxcnt=0
for k in range(len(Word)):
    ans[k][0]=Word[k]
    ans[k][1]=S.count(Word[k])
    maxcnt=max(maxcnt,ans[k][1])
ans=sorted(ans)
for i in range(len(Word)):
    if ans[i][1]==maxcnt:
        print(ans[i][0])

Submission status: Time Limit Exceeded

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

# 辞書作成
s_list = list(set(s))
s_dict = dict()
for i in s:
    if i not in s_dict:
        s_dict[i] = 1
    else:
        s_dict[i] += 1

# 最大値のkeyのみリスト化
max_s_list = [i[0] for i in s_dict.items() if i[1] == max(s_dict.values())]
# ソート
max_s_list.sort(key=lambda x: x[0])
print(*max_s_list, sep="\n")

Submission status: Time Limit Exceeded

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

# 辞書作成
s_list = list(set(s))
s_dict = {}
for i in range(len(s_list)):
    s_dict[s_list[i]] = 0

# カウント
for i in range(len(s)):
    s_dict[s[i]] += 1

# 最大値のkeyのみリスト化
max_s_list = [kv[0] for kv in s_dict.items() if kv[1] == max(s_dict.values())]
# ソート
max_s_list.sort(key=lambda x: x[0])
print(*max_s_list, sep="\n")

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
l=[]
l2=['a','b']
num=l2[0]
con=0
for i in range(n):
    s=input()
    l.append(s)
    co=l.count(s)
    if co>con:
        con=co
        num=l.count(s)
l1=sorted(set(l))
for j in l1:
    if l.count(j)==num:
        print(j)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
moto=[0]*n
for k in range(0,n):
  moto[k]=input()
syurui=list(set(moto))
kosu=[0]*len(syurui)
for k in range(0,len(syurui)):
  kosu[k]=moto.count(syurui[k])
answer=[]
for k in range(0,len(syurui)):
  if moto.count(syurui[k])==max(kosu):
    answer.append(syurui[k])
answer.sort()
for k in range(0,len(answer)):
  print(answer[k])

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
moto=[0]*n
for k in range(0,n):
  moto[k]=input()
syurui=list(set(moto))
kosu=[0]*len(syurui)
for k in range(0,len(syurui)):
  kosu[k]=moto.count(syurui[k])
answer=[]
for k in range(0,len(syurui)):
  if moto.count(syurui[k])==max(kosu):
    answer.append(syurui[k])
answer.sort()
for k in range(0,len(answer)):
  print(answer[k])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

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

Submission status: Time Limit Exceeded

Solution code:
import collections

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

c = collections.Counter(s)

for i in sorted(k for k in c if c[k] == max(c.values())):
    print(i)

Submission status: Time Limit Exceeded

Solution code:
import collections

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

c = collections.Counter(s)
for i in c:
    if c[i] == max(c.values()):
        ans.append(i)
ans.sort()

for i in ans:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
import collections

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

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

Submission status: Time Limit Exceeded

Solution code:
import collections

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

c = collections.Counter(s)
keys = [k for k, v in c.items() if v == max(c.values())]

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

Submission status: Time Limit Exceeded

Solution code:
import collections
N, *d = open(0).read().split()
N = int(N)
v = collections.Counter(d)
e = [k for k in v.items() if k[1] == max(v.values())]
u = sorted(list(dict(e).keys()))
for h in u:
    print(h)

Submission status: Time Limit Exceeded

Solution code:
import collections
N = int(input())
S = [input() for _ in range(N)]
v = collections.Counter(S)
e = [k for k in v.items() if k[1] == max(v.values())]
u = sorted(list(dict(e).keys()))
for h in u:
    print(h)

Submission status: Time Limit Exceeded

Solution code:
import collections
N = int(input())
S = [input() for _ in range(N)]
v = collections.Counter(S)
e = [k for k in v.items() if k[1] == max(v.values())]
u = sorted(list(dict(e).keys()))
for h in u:
    print(h)

Submission status: Time Limit Exceeded

Solution code:
import collections

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

s.sort()

word = []
num = []
list = []
word.append(s[0])
num.append(1)

for i in range(1, len(s)):
    if s[i] != s[i-1]:
        word.append(s[i])
        num.append(1)
    else:
        num[len(word)-1] += 1

for i in range(len(word)):
    if num[i] == max(num):
        list.append(word[i])

list.sort()

for i in list:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
import collections

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

list = []

for i in range(len(c)):
    if c.most_common()[i][1] == c.most_common()[0][1]:
        list.append(c.most_common()[i][0])
    else:
        break

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
data=[]
data1=[]
for i in range(n):
    x=input()
    if x not in data:
        data.append(x)
        data1.append(1)
    else:
        for j in range(len(data)):
            if data[j]==x:
                break
        data1[j]=data1[j]+1
key=[]
ma=max(data1)
for i in range(len(data1)):
    if data1[i]==ma:
        key.append(data[i])
key=sorted(key)
for i in key:
    print(i)

Submission status: Time Limit Exceeded

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

s.sort()

num = [0 for i in range(n)]

for i in range(n):
    for j in range(i+1, n):
        if s[i] == s[j]:
            num[i] += 1

for i in range(n):
    if num[i] == max(num):
        print(s[i])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
word = []
for i in range(n):#文字列毎
  inp = input()
  for j in range(len(word)):#word配列の長さ毎
    if inp in word[j]:#word[j]に含まれる場合
      if j + 1 == len(word):
        word.append([inp])
        break
    else:
      word[j].append(inp)
      break
  if i == 0:
    word.append([inp])
tmp1 = word[len(word)-1]
tmp2 = []
for i in tmp1:
  if i not in tmp2:
    tmp2.append(i)
tmp2.sort()
for i in tmp2:
  print(i)

Submission status: Time Limit Exceeded

Solution code:
import collections

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

c=collections.Counter(l)
cc=c.most_common()
ccc=[]
for j in cc:
    if j[1]==max(c.values()):
        ccc.append(j[0])

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

Submission status: Time Limit Exceeded

Solution code:
import collections

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

c=collections.Counter(l)
cc=sorted(c.most_common())
ccc=[]
for j in cc:
    if j[1]==max(c.values()):
        ccc.append(j[0])

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

Submission status: Time Limit Exceeded

Solution code:
# mapに値を入れてここにある値を参照し、listと比較。その数の最大を求め、最大のリストを表示。
A=int(input())
b = [str(input()) for i in range(A)]
max = 0
for i in b:
  if b.count(i) > max:
    max = b.count(i)
x = [0]
b.sort()
for i in b:
  if b.count(i) == max:
    if x.count(i) == 0:
      x.append(i)
      print(i)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
import numpy as np

n = int(input())
sl = list(input() for _ in range(n))
sl_set = list(set(sl))
sl_set.sort()

m = 0
l = []
for s in sl_set:
    a = sl.count(s)
    m = max(m, a)
    l.append(a)

m_idx = np.where(np.array(l) == m)
for i in m_idx[0]:
    print(sl_set[i])

Submission status: Time Limit Exceeded

Solution code:
# mapに値を入れてここにある値を参照し、listと比較。その数の最大を求め、最大のリストを表示。
A=int(input())
b = sorted([str(input()) for i in range(A)])
maxValue = 0
for i in b:
  if b.count(i) > maxValue:
    maxValue = b.count(i)
x = []
for i in b:
  if b.count(i) == maxValue:
    if x.count(i) == 0:
      x.append(i)
      print(i)

Submission status: Time Limit Exceeded

Solution code:
# mapに値を入れてここにある値を参照し、listと比較。その数の最大を求め、最大のリストを表示。
A=int(input())
b = [str(input()) for i in range(A)]
max = 0
for i in b:
  if b.count(i) > max:
    maxValue = b.count(i)
x = [0]
b.sort()
for i in b:
  if b.count(i) == maxValue:
    if x.count(i) == 0:
      x.append(i)
      print(i)

Submission status: Time Limit Exceeded

Solution code:
# mapに値を入れてここにある値を参照し、listと比較。その数の最大を求め、最大のリストを表示。
A=int(input())
b = sorted([str(input()) for i in range(A)])
max = 0
for i in b:
  if b.count(i) > max:
    maxValue = b.count(i)
x = [0]
for i in b:
  if b.count(i) == maxValue:
    if x.count(i) == 0:
      x.append(i)
      print(i)

Submission status: Time Limit Exceeded

Solution code:
# mapに値を入れてここにある値を参照し、listと比較。その数の最大を求め、最大のリストを表示。
A=int(input())
b = sorted([str(input()) for i in range(A)])
max = 0
for i in b:
  if b.count(i) > max:
    maxValue = b.count(i)
x = []
for i in b:
  if b.count(i) == maxValue:
    if x.count(i) == 0:
      x.append(i)
      print(i)

Submission status: Time Limit Exceeded

Solution code:
# 最大表示。
A=int(input())
b = sorted([str(input()) for i in range(A)])

target = []
max = 0
for i in b:
  if b.count(i) > max:
    maxValue = b.count(i)
x = []
answer = []
for i in b:
  if b.count(i) == maxValue:
    if x.count(i) == 0:
      x.append(i)
      print(i)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n=int(input())
a=[str(input()) for i in range(n)]
b=sorted(set(a),key=lambda x:x)
b=[[i,0]for i in b]
lenb=range(len(b))
for i in lenb:
  for j in a:
    if j==b[i][0]:
      b[i][1]+=1
c=np.array([i[1] for i in b])
maxb=max(c)
#b=sorted(b,key=lambda x:x[0])
for i in lenb:
  if b[i][1]==maxb:
    print(b[i][0])

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n=int(input())
a=np.array([str(input()) for i in range(n)])
b=set(a)
b=[[i,0]for i in b]
lenb=range(len(b))
for i in lenb:
  for j in a:
    if j==b[i][0]:
      b[i][1]+=1
c=np.array([i[1] for i in b])
maxb=max(c)
b=sorted(b,key=lambda x:x[0])
for i in lenb:
  if b[i][1]==maxb:
    print(b[i][0])

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=[str(input()) for i in range(n)]
b=set(a)
b=[[i,0]for i in b]
lenb=range(len(b))
for i in lenb:
  for j in a:
    if j==b[i][0]:
      b[i][1]+=1
maxb=max(b,key=lambda x:x[1])
maxb=maxb[1]
b=sorted(b,key=lambda x:x[0])
for i in lenb:
  if b[i][1]==maxb:
    print(b[i][0])

Submission status: Time Limit Exceeded

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

maxi = 0

for _ in range(n):
    s = input()

    if s in st:
        st[s] += 1
    else:
        st[s] = 1

    if st[s] > maxi:
        maxi = st[s]

max_k = sorted([kv[0] for kv in st.items() if kv[1] == max(st.values())])

for k in max_k:
    print(k)

Submission status: Time Limit Exceeded

Solution code:
import collections
import sys
def input():
    return sys.stdin.readline()[:-1]
N = int(input())
strings = [0] * N
for i in range(N):
    strings[i] = input()
    
values, counts = zip(*collections.Counter(strings).most_common())
a = counts[0]
if len(counts) == 1:
    print(values[0])
else:
    b = counts[1]
    ms = [values[0]]
    t = 1
    while a == b:
        ms.append(values[t])
        b = counts[t + 1]
    ms2 = sorted(ms)
    for j in ms2:
        print(j)

Submission status: Time Limit Exceeded

Solution code:
import collections
N = int(input())
strings = [0] * N
for i in range(N):
    strings[i] = input()
    
values, counts = zip(*collections.Counter(strings).most_common())
a = counts[0]
if len(counts) == 1:
    print(values[0])
else:
    b = counts[1]
    ms = [values[0]]
    t = 1
    while a == b:
        ms.append(values[t])
        b = counts[t + 1]
    ms2 = sorted(ms)
    for j in ms2:
        print(j)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = []
s_cnt = [0] * n
for i in range(n):
    temp = input()
    if not temp in s:
        s.append(temp)
    s_cnt[s.index(temp)] += 1
maxi = max(s_cnt)
ans_lst = []
for i in range(len(s)):
    if s_cnt[i] == maxi:
        ans_lst.append(s[i])
ans_lst.sort()
ans = ""
for i in range(len(ans_lst)):
    ans += ans_lst[i]
    if i != len(ans_lst) - 1:
        ans += "\n"
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = []
s_cnt = [0] * n
for i in range(n):
    temp = input()
    if not temp in s:
        s.append(temp)
    s_cnt[s.index(temp)] += 1
maxi = max(s_cnt)
ans_lst = []
for i in range(n):
    if s_cnt[i] == maxi:
        ans_lst.append(s[i])
ans_lst.sort()
for i in ans_lst:
    print(i)

Submission status: Time Limit Exceeded

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

for i in s2:
  ans.append([s.count(i),i])
ans.sort()
sai = max(ans)

for i in range(len(ans)):
  if ans[i][0] == sai[0]:
    print(ans[i][1])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
slist=[]
cntlist = []
for i in range(N):
  s = input()
  if s in slist:
    cntlist[slist.index(s)] += 1
  else:
    slist.append(s)
    cntlist.append(1)
maxi = max(cntlist)
cntindex = [i for i, x in enumerate(cntlist) if x == maxi]
anslist = []
for i in cntindex:
  anslist.append(slist[i])
anslist.sort()
for ans in anslist:
  print(ans)

Submission status: Time Limit Exceeded

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

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

ans = [kv[0] for kv in dic.items() if kv[1] == max(dic.values())]

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

Submission status: Time Limit Exceeded

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

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

ans = [k for k, v in dic.items() if v == max(dic.values())]
ans.sort()
for i in ans:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
d = {}
for i in range(N):
  key = input()
  if key in d:
    d[key] += 1
  else:
    d[key] = 1

l_max = [kv[0] for kv in d.items() if kv[1] == max(d.values())]
l_max.sort()
for ch in l_max:
  print(ch)

Submission status: Time Limit Exceeded

Solution code:
import collections
N = int(input())
S = [input() for i in range(N)]
ans = collections.defaultdict(int)
for i in S:
  ans[i] += 1
  
max_list = [kv[0] for kv in ans.items() if kv[1] == max(ans.values())] 
max_list.sort()
for i in max_list:
  print(i)

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
n = int(input())
li = [input() for _ in range(n)]
a = Counter(li)
keys = [k for k, v in a.items() if v == max(a.values())]
keys = sorted(keys)
for i in keys:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter

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

ans = Counter(s)
for k, v in sorted(ans.items()):
  if v == max(ans.values()):
    print(k)

Submission status: Time Limit Exceeded

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

n = int(input())
s = [input() for i in range(n)]
ans = {}
word_list = list(set(s))

for i in word_list:
  ans[i] = s.count(i)

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = [input() for i in range(n)]
ans = {}
word_list = list(set(s))

for i in word_list:
  ans[i] = s.count(i)

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = [input() for i in range(n)]
ans = []
out = []
word_list = list(set(s))

for i in word_list:
  ans.append([s.count(i), i])

ans.sort(reverse = True)

for j in ans:
  if j[0] == ans[0][0]:
    out.append(j[1])

out.sort()
for k in out:
  print(k)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

A=[]
B=[]
C=[]
saidai = 0
for i in range(N):
    A.append(input())
C=sorted(set(A))

for i in C:
    y = A.count(i)
    B.append([i, y])
    saidai = max(y, saidai)

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

A=[]
B=[]
saidai = 0
for i in range(N):
    x = input()
    A.append(x)
    y = A.count(x)
    B.append([x, y])
    saidai = max(y, saidai)
B.sort() 
for i in range(N):
    if B[i][1] == saidai:
        print(B[i][0])

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter

N = int(input())

S = [input() for i in range(N)]
X = Counter(S).most_common()

lst = [k for k, v in X if v == Counter(S).most_common()[0][1]]
print('\n'.join(sorted(lst)))

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
N = int(input())
S = list(str(input()) for i in range(N))
c = Counter(S)

for max_key in sorted(list(k for k,v in c.items() if v == max(c.values()))):
    print(max_key)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Dic = {}

for s in S:
    if s in Dic:
        Dic[s] += 1
    else:
        Dic[s] = 1

for max_key in sorted([k for k, v in Dic.items() if v==max(Dic.values())]):
    print(max_key)

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
n=int(input())
s=[]
for _ in range(n):
    s.append(input())
c = Counter(s)
ans=[]
for i,j in c.items():
    if j == max(c.values()):
        ans.append(i)
print("\n".join(sorted(ans)))

Submission status: Time Limit Exceeded

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


ans_list = {}
count = 0
for s in s_list:
  s_count = s_list.count(s)
  ans_list[s] = s_count

  # # print(s_count)
  # if s_count > count:
  #   ans_list.clear()
  #   ans_list.append(s)
  #   # print(ans_list)
  #   count = s_count
  # elif s_count == count:
  #   ans_list.append(s)

# print(ans_list)

ans_list = [kv[0] for kv in ans_list.items() if kv[1] == max(ans_list.values())]
# print(max_ans_list)
    
ans_list = sorted(ans_list)
# print(ans_list)

for ans in ans_list:
  print(ans)

Submission status: Time Limit Exceeded

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

s_list_set = set(s_list)
# print(s_list_set)

ans_list = {}
count = 0
for s in s_list_set:
  s_count = s_list.count(s)
  ans_list[s] = s_count

  # # print(s_count)
  # if s_count > count:
  #   ans_list.clear()
  #   ans_list.append(s)
  #   # print(ans_list)
  #   count = s_count
  # elif s_count == count:
  #   ans_list.append(s)

# print(ans_list)

ans_list = [kv[0] for kv in ans_list.items() if kv[1] == max(ans_list.values())]
# print(max_ans_list)
    
ans_list = sorted(ans_list)
# print(ans_list)

for ans in ans_list:
  print(ans)

Submission status: Time Limit Exceeded

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

s_list_set = set(s_list)
# print(s_list_set)

ans_list = []
count = 0
for s in s_list_set:
  s_count = s_list.count(s)
  # print(s_count)
  if s_count > count:
    ans_list.clear()
    ans_list.append(s)
    # print(ans_list)
    count = s_count
  elif s_count == count:
    ans_list.append(s)
    
ans_list = sorted(ans_list)
# print(ans_list)

for ans in ans_list:
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
n=int(stdin.readline().rstrip())
#print(n)
dic={}
for i in range(n):
    s=stdin.readline().rstrip()
    if s in dic.keys():
        dic[s] +=1
    else:
        dic[s]=1
#print(dic)
#print(dic.keys())
sup=0
suc=[]
for (i,number) in dic.items():
    if number>sup:
        suc=[]
        sup=number
        suc.append(i)
    elif number==sup:
        suc.append(i)
for k in (sorted(suc)):
    print(k)