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())
a=[]
for i in range(N):
  a.append(input())
b=list(set(a))
c=list(map(lambda x:a.count(x),b))
d=int(c.count(max(c)))
e=[]
for k in range(d):
  e.append(b[c.index(max(c))])
  c[c.index(max(c))]=0
for l in range(len(e)):
  print(min(e))
  e.remove(min(e))

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
a=[]
for i in range(N):
  a.append(input())
b=list(set(a))
c=[]
for j in range(len(b)):
  c.append(a.count(b[j]))
d=int(c.count(max(c)))
e=[]
for k in range(d):
  e.append(b[c.index(max(c))])
  c[c.index(max(c))]=0
for l in range(len(e)):
  print(min(e))
  e.remove(min(e))

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
a=[]
for i in range(N):
  a.append(input())
b=list(set(a))
c=[]
for j in range(len(b)):
  c.append(a.count(b[j]))
d=int(c.count(max(c)))
while True:
  if len(b)==0:
    break
  elif a.count(min(b))==max(c):
    print(min(b))
    b.remove(min(b))
  else:
    b.remove(min(b))

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
newlist=list()
for i in range(0,n):
  x=str(input())
  newlist.append(x)
newlist.sort()
dic=dict()
for i in newlist:
  x=newlist.count(i)
  dic[x]=list()
maxx=0  
for i in newlist:
  x=newlist.count(i)
  if x>maxx:
    maxx=x
  dic[x].append(i) 


s=set(dic[maxx])
s=list(s)
s.sort()

for i in s:
  print(i)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n = int(input())
S = [[0] * 2 * 10 * 5] * n
j = 0

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

S = sorted(S)
S_list = sorted(list(set(S)))
count = [1] * len(S_list)
for i in range(n-1):
    if S[i] == S[i+1]:
        count[j] += 1
    else:
        j += 1
maxIndex = [i for i, x in enumerate(count) if x == max(count)]
for i in maxIndex:
    print(S_list[i])

Submission status: Time Limit Exceeded

Solution code:
import sys
from collections import Counter
input=sys.stdin.readline
N=int(input())
d=Counter(list(input()[:-1] for _ in range(N)))
L=[]
for k, v in d.items():
 if v == max(d.values()):
  L.append(k)
L.sort()
for i in L:
 print(i)

Submission status: Time Limit Exceeded

Solution code:
import sys
from collections import Counter
input=sys.stdin.readline
N=int(input())
d=Counter(list(input() for _ in range(N)))
L=[]
for k, v in d.items():
 if v == max(d.values()):
  L.append(k)
L.sort()
for i in L:
 print(i)

Submission status: Time Limit Exceeded

Solution code:
import sys
from collections import defaultdict
d=defaultdict(int)
N=int(input())
L=[]
input=sys.stdin.readline
for _ in range(N):
 s=input()
 d[s]+=1
for k, v in d.items():
 if v == max(d.values()):
  L.append(k)
L.sort()
for i in L:
 print(i)

Submission status: Time Limit Exceeded

Solution code:

from collections import defaultdict
d=defaultdict(int)
N=int(input())
L=[]
for _ in range(N):
 s=input()
 d[s]+=1
for k, v in d.items():
 if v == max(d.values()):
  L.append(k)
L.sort()
for i in L:
 print(i)

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict
d=defaultdict(int)
N=int(input())
L=[]
for _ in range(N):
 s=input()
 d[s]+=1
for k, v in d.items():
 if v == max(d.values()):
  L.append(k)
L.sort()
for i in L:
 print(i)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from collections import Counter


def main():
    N = int(input())
    S = [input() for _ in range(N)]
    S = Counter(S)

    result = []
    for key, value in S.items():
        if value == S.most_common()[0][1]:
            result.append(key)
    result.sort()
    for r in result:
        print(r)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
a=[]
for i in range(N):
  a.append(input())
b=[]
for j in range(len(a)):
  b.append(a.count(a[j]))
c=int(b.count(max(b))/max(b))
d=[]
for k in range(c):
  d.append(a[b.index(max(b))])
  a.remove(d[k])
for l in range(len(d)):
  print(min(d))
  d.remove(min(d))

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
a=[]
for i in range(N):
  a.append(input())
b=[]
for j in range(len(a)):
  b.append(a.count(a[j]))
c=int(b.count(max(b))/max(b))
d=[]
for k in range(c):
  d.append(a[b.index(max(b))])
  a.remove(d[k])
e=[]
for l in range(len(d)):
  e.append(min(d))
  d.remove(e[l])
for m in e:
  print(m)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s =[]
upper = 0

for i in range(n):
    s.append(input())
for i in range(n):
    if upper == s.count(s[i]):
        hokan.append(s[i])
    if upper < s.count(s[i]):
        hokan = []
        hokan.append(s[i])
        upper = s.count(s[i])
while hokan != []:
    print(hokan[-1])
    alpha = hokan[-1]
    while alpha in hokan :
        hokan.remove(alpha)

Submission status: Time Limit Exceeded

Solution code:
words_num = int(input())


def registering(words_num):
  words_dictionary = {}
  for i in range(words_num):
    word = input()
    if not word in words_dictionary.keys():
      words_dictionary[word] = 1
    else:
      words_dictionary[word] += 1
  return words_dictionary

def searching(words_dictionary):
  most_frequentry = [word for word in words_dictionary.keys() if words_dictionary[word] == max(words_dictionary.values())]
  return sorted(most_frequentry)

if __name__ == "__main__":
  words_dictionary = registering(words_num)
  most_frequentry = searching(words_dictionary)
  for word in most_frequentry:
    print(word)

Submission status: Time Limit Exceeded

Solution code:
import collections
# from collections import OrderedDict

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

c = collections.Counter(S)

hoge = []
for k, v in c.items():
    if max(c.values()) == v:
        hoge.append(k)

hoge = sorted(hoge)
for i in hoge:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
m=int(input())
Ss=[input() for _ in range(m)]
s1=list(set(Ss))
num=[]
voc=[]
for l in s1:
    n=Ss.count(l)
    num.append(n)
res=[]
for i,w in enumerate([n==max(num) for n in num]):
    if w:
        res.append(s1[i])
res.sort()
for i in res:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
word_list = []
count_list = []
for i in range(N):
    tmp = input()
    if tmp in word_list:
        count_list[word_list.index(tmp)] += 1
    else:
        word_list.append(tmp)
        count_list.append(1)
        
MAX = -1
for i in range(len(count_list)):
    if count_list[i]>MAX:
        MAX = count_list[i]

        
ans_list = []
for i in range(len(count_list)):
    if count_list[i]==MAX:
        ans_list.append(word_list[i])

ans_list.sort()

for ans in ans_list:
    print(ans)

Submission status: Time Limit Exceeded

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

most_count = c.most_common()[0][1]
answer = []
for i in range(len(c)):
  if most_count == c.most_common()[i][1]:
    answer.append(c.most_common()[i][0])
answer.sort()
for i in answer:
  print(i)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
li=[input() for _ in range(n)]


s=[]
m=0
for i in range(n):
    if li.count(li[i])>m:
        s=[li[i]]
        m=li.count(li[i])
    elif li.count(li[i])==m:
        s.append(li[i])

s=set(s)
s=list(s)
s.sort()
l=len(s)
for i in range(l):
    print(s[i])

Submission status: Time Limit Exceeded

Solution code:
a = int(input())
ar = []
br = {}
cr = []
mx = 0
for i in range(a):
    l = input()
    if l not in ar:
        br[l] = 1
        ar.append(l)
    else:
        br[l] += 1
    if br[l] > mx:
        mx = br[l]
for k,v in br.items():
    if v == mx:
        cr.append(k)
cr.sort()
for r in cr:
    print(r)

Submission status: Time Limit Exceeded

Solution code:
a = int(input())
ar = []
br = {}
mx = 0
for i in range(a):
    l = input()
    if l not in ar:
        br[l] = 1
        ar.append(l)
    else:
        br[l] += 1
    if br[l] > mx:
        mx = br[l]
cr = []
for k,v in br.items():
    if v == mx:
        cr.append(k)
cr.sort()
for r in cr:
    print(r)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S_dict = {}
max_count = 0
max_list = []
for i in range(N):
    S = input()
    if S in S_dict:
        S_dict[S] += 1
    else:
        S_dict[S] = 1
    if max_count < S_dict[S]:
        max_count = S_dict[S]
        max_list = [S]
    elif max_count == S_dict[S] and S not in max_list:
        max_list.append(S)
max_list.sort()
for max_S in max_list:
    print(max_S)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
x = [input() for i in range(n)]
i = 0
count, yo, list_yo = [], [], []

while not(x == []):
  a = x.count(x[i])
  count.append(a)
  yo.append(x[i])
  x.remove(x[i])
  if len(x) < max(count):
    break
  
[list_yo.append(yo[k]) for k, c in enumerate(count) if c == max(count)]
  
list_yo.sort()

[print(list_yo[i]) for i in range(len(list_yo))]

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
x = [input() for i in range(n)]
i = 0
count, yo, list_yo = [], [], []

while not(x == []):
  a = x.count(x[i])
  count.append(a)
  yo.append(x[i])
  x.remove(x[i])
  if len(x) < max(count):
    break
  
for k, c in enumerate(count):
  if c == max(count):
    list_yo.append(yo[k])

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
x = [input() for i in range(n)]
i = 0
count, yo, list_yo = [], [], []

while not(x == []):
  a = x.count(x[i])
  count.append(a)
  yo.append(x[i])
  x.remove(x[i])
  
for k, c in enumerate(count):
  if c == max(count):
    list_yo.append(yo[k])

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

Submission status: Time Limit Exceeded

Solution code:
n= int(input());
dic=dict();
x=1;
for i in range(n):
    temp=input();
    if(temp in dic.keys()):
        dic[temp]+=1;
        if(dic[temp]>x):
            x=dic[temp];
    else:
        dic[temp]=1;
ls=[];
for i in dic.keys():
    if(dic[i]==x):
        ls.append(i);
ls.sort();
for i in ls:
    print(i);

Submission status: Time Limit Exceeded

Solution code:
import collections
from collections import OrderedDict

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

#出現回数のカウント
c = OrderedDict(collections.Counter(S))
ln = len(c.values())

#多い順に並べ替えた辞書をつくる
d = OrderedDict(sorted(c.items(), key = lambda x : x[1], reverse=True))
dval = list(d.values())
dkey = list(d.keys())

#回数が多い単語を抜き出したリストの制作
word = list()
word.append(dkey[0])
i=1
if ln>1:
    while dval[i-1]==dval[i]:
        word.append(dkey[i])
        i+=1
        if i==ln:
            break

#辞書順に並べ替える
dic = sorted(word)

#表示
for i in range(len(dic)):
    print(dic[i])

Submission status: Time Limit Exceeded

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

from collections import Counter
dict_C = Counter(list_S)

keys = [k for k,v in dict_C.items() if v == max(dict_C.values())]
keys.sort()

for ans in keys :
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
ans = {}
for i in range(N):
    a = input()
    ans[a] = ans.get(a,0) + 1

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
L = [input() for i in range(N)]
ans = {}
for i in range(len(L)):
    a = L[i]
    ans[a] = ans.get(a,0) + 1

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
L = [input() for i in range(N)]
ans = {}
for i in range(len(L)):
    a = L[i]
    if a in ans:
        ans[a] += 1
    else:
        ans[a] = 1

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

Submission status: Time Limit Exceeded

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

t = list(set(s))

p = []
for j in t:
  p.append([s.count(j), j])

a = []
b = 0
q = 0
for k in sorted(p, reverse = True):
  if k[0] >= b:
    a.append(k[1])
    b = k[0]
  else:
    break

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

Submission status: Time Limit Exceeded

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

t = list(set(s))

p = []
for j in t:
  p.append([s.count(j), j])

a = []
b = 0
q = 0
for k in sorted(p, reverse = True):
  if k[0] >= b:
    a.append(k[1])
    q +=1
    b = k[0]

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
L = [input() for i in range(N)]
ans = {}
for i in range(len(L)):
    a = L[i]
    b =0
    for i in ans.keys():
        if a ==i:
            b = 1
            ans[i] += 1
            break
        else:
             continue
    if b ==0:
        ans[a] = 1

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=[]
m=[]
b=[]
for i in range(n):
  a.append(input())
kaisu=1
for i in range(n):
  b.append(a.count(a[i]))
for i in range(n):
  if kaisu==b[i]:
    m.append(a[i])
  elif kaisu<b[i]:
    m=[a[i]]
    kaisu=b[i]
m=sorted(list(set(m)))
n=len(m)
for i in range(n):
  print(m[i])

Submission status: Time Limit Exceeded

Solution code:
import sys
import collections

N = int(input())
S = [sys.stdin.readline().strip() for _ in range(N)]
S_dic = collections.Counter(S)
S_sorted = S_dic.most_common()

A = [S_sorted[0][0]]
s = S_sorted[0][1] 
l = len(S_sorted)

for i in range(l - 1):
  if s == S_sorted[i + 1][1]:
    A = A + [S_sorted[i + 1][0]]
  else:
    break
  
A.sort()
for val in A:
  print(val)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=[]
m=[]
for i in range(n):
  a.append(input())
kaisu=1
for i in range(n):
  if kaisu==a.count(a[i]):
    m.append(a[i])
  elif kaisu<a.count(a[i]):
    m=[a[i]]
    kaisu=a.count(a[i])
m=sorted(list(set(m)))
n=len(m)
for i in range(n):
  print(m[i])

Submission status: Time Limit Exceeded

Solution code:
import sys

N = int(input())
S = [sys.stdin.readline().strip() for _ in range(N)]
A = []
i = 0
 
S.sort()
 
while S != []:
  count = S.count(S[0])
  
  if count > i:
    A = [S[0]]
    i = count
  elif count == i:
    A = A + [S[0]]
    
  S[0:count] = []

for val in A:
  print(val)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
L = [input() for i in range(N)]
max = 0
ans = []
while(len(L) > 0):
    a = L[0]
    c = L.count(L[0])
    if c > max:
        max = c
        ans.clear()
        ans.append(L[0])
    elif c == max:
        ans.append(L[0])
    L = [i for i in L if i !=a]
ans.sort()
[print(i) for i in ans]

Submission status: Time Limit Exceeded

Solution code:
import sys
N = int(input())
S = {}
 
for i in range(N):
  key = sys.stdin.readline().rstrip()
  if key in S.keys():
    S[key] = S[key] + 1
  else:
    S[key] = 1

S_sorted = sorted(S.items(), reverse = True, key = lambda x : x[1])
 
A = [S_sorted[0][0]]
i = 0
l = len(S_sorted)
 
for i in range(l - 1):
  if S_sorted[i][1] == S_sorted[i + 1][1]:
    A = A + [S_sorted[i + 1][0]]
  else:
    break
  
A.sort()
for val in A:
  print(val)

Submission status: Time Limit Exceeded

Solution code:
import sys
import collections

N = int(input())
S = [sys.stdin.readline().strip() for _ in range(N)]
S_sorted = (collections.Counter(S)).most_common()

A = [S_sorted[0][0]]
i = 0
l = len(S_sorted)

for i in range(l - 1):
  if S_sorted[i][1] == S_sorted[i + 1][1]:
    A = A + [S_sorted[i + 1][0]]
  else:
    break
  
A.sort()
for val in A:
  print(val)

Submission status: Time Limit Exceeded

Solution code:
import sys
N = int(input())
S = {}

for i in range(N):
  key = sys.stdin.readline().rstrip()
  if key in S.keys():
    S[key] = S[key] + 1
  else:
    S[key] = 1

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

A = [S_sorted[0][0]]
i = 0
l = len(S_sorted)

for i in range(l - 1):
  if S_sorted[i][1] == S_sorted[i + 1][1]:
    A = A + [S_sorted[i + 1][0]]
  else:
    break
  
A.sort()
for val in A:
  print(val)

Submission status: Time Limit Exceeded

Solution code:
import sys
N = int(input())
S = {}

for i in range(N):
  key = sys.stdin.readline().rstrip()
  if key in S.keys():
    S[key] = S[key] + 1
  else:
    S[key] = 1

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

A = [S_sorted[0][0]]
i = 0
l = len(S_sorted)

while i < l - 1:
  if S_sorted[i][1] == S_sorted[i + 1][1]:
    A = A + [S_sorted[i + 1][0]]
    i = i + 1
  else:
    break
  
A.sort()
for val in A:
  print(val)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = {}

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

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

A = [S_sorted[0][0]]
i = 0
l = len(S_sorted)

while i < l - 1:
  if S_sorted[i][1] == S_sorted[i + 1][1]:
    A = A + [S_sorted[i + 1][0]]
    i = i + 1
  else:
    break
  
A.sort()
for val in A:
  print(val)

Submission status: Time Limit Exceeded

Solution code:
#C-Poll
import collections
n=int(input())
words = [input() for _ in range(n)]
count = collections.Counter(words)
leng = len(count)
ansallay = []
#抽出用に何回出てればansに出すかを変数に突っ込む
record = count.most_common()[0][1]
for num in range(leng):
    if(count.most_common()[num][1] == record):
        ansallay.append(count.most_common()[num][0])
    else:
        break
ansallay.sort()
for word in ansallay:
    print(word)

Submission status: Time Limit Exceeded

Solution code:
#C-Poll
import collections
n=int(input())
words = [input() for _ in range(n)]
count = collections.Counter(words)
leng = len(count)
ansallay = []
#抽出用に何回出てればansに出すかを変数に突っ込む
record = count.most_common()[0][1]
for num in range(leng):
    if(count.most_common()[num][1] == record):
        ansallay.append(count.most_common()[num][0])
ansallay.sort()
for word in ansallay:
    print(word)

Submission status: Time Limit Exceeded

Solution code:
#C-Poll
import collections
n=int(input())
words = [input() for _ in range(n)]
count = collections.Counter(words)
leng = len(count)
Flg = True
ansallay = []
for num in range(leng):
    ansallay.append(count.most_common()[num][0])
    #もし配列が1種類しかなかった場合はそれだけ足してbreakする
    if(leng == 1):
      break
    if(count.most_common()[0][1] != count.most_common()[num+1][1]):
        break
    num += 1
    if(num == leng-1):
      if(count.most_common()[0][1] == count.most_common()[num][1]):
        ansallay.append(count.most_common()[num][0])
      break
ansallay.sort()
for word in ansallay:
    print(word)

Submission status: Time Limit Exceeded

Solution code:
#C-Poll
import collections
n=int(input())
words = [input() for _ in range(n)]
count = collections.Counter(words)
leng = len(count)
Flg = True
ansallay = []
for num in range(n-1):
    #もし配列が1種類しかなかった場合はそれだけ足してbreakする
    if(leng == 1):
      ansallay.append(count.most_common()[num][0])
      break
    ansallay.append(count.most_common()[num][0])
    if(count.most_common()[0][1] != count.most_common()[num+1][1]):
        break
    num += 1
    if(num == leng-1):
      if(count.most_common()[0][1] == count.most_common()[num][1]):
        ansallay.append(count.most_common()[num][0])
      break
ansallay.sort()
for word in ansallay:
    print(word)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = [input() for i in range(n)]
s_ = list(set(s))
co = [0 for i in range(len(s_))]
for i in range(len(s_)):
    co[i] = s.count(s_[i])
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)))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = [input() for i in range(n)]
used = [s[0]] + [0 for i in range(n-1)]
co = [1] + [0 for i in range(n-1)]
if n == 1:
    print(used[0])
else:
    ind = 1
    for i in s[1:]:
        if i in used[:ind]:
            co[used[:ind].index(i)] += 1
        else:
            used[ind] = i
            co[ind] = 1
            ind += 1
    ma = max(co)
    arg = [i for i in range(n) if co[i]==ma]
    ans = [used[i] for i in arg]
    print("\n".join(sorted(ans)))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

from collections import Counter
c = Counter(s)

result = [i[0] for i in c.items() if i[1]==max(c.values())]
result.sort()


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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

from collections import Counter
c = Counter(s)

result = [i[0] for i in c.items() if i[1]==max(c.values())]
result = sorted(result)

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

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
N=int(input())
lis=list(input() for _ in range(N))
se=set(lis)
ans=[]
high=0

counter=Counter(lis)
high=counter.most_common()[0][1]

for  j in se:
  if lis.count(j)==high:
    ans.append(j)
ans.sort()

for k in ans:
  print(k)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
lis=list(input() for _ in range(N))
se=set(lis)
ans=[]
high=0

for i in se:
  if lis.count(i)>=high:
    high=lis.count(i)
for  j in se:
  if lis.count(j)==high:
    ans.append(j)
ans.sort()

for k in ans:
  print(k)

Submission status: Time Limit Exceeded

Solution code:
def main():
  n = int(input())
  dict = {}
  for i in range(n):
    s = input()
    if s not in dict:
      dict[s] = 1
    else:
      dict[s] += 1
  max_name = sorted([kv[0] for kv in dict.items() if kv[1] == max(dict.values())])
  for name in max_name:
    print(name)


if __name__ == '__main__':
  main()

Submission status: Time Limit Exceeded

Solution code:
def main():
  n = int(input())
  ls = []
  ls_count = []
  for i in range(n):
    item = input()
    if item not in ls:
      ls.append(item)
      ls_count.append(1)
    else:
      ls_count[ls.index(item)] += 1
  max_count = max(ls_count)
  max_index = [i for i, n in enumerate(ls_count) if n == max_count]
  ans = []
  for idx in max_index:
    ans.append(ls[idx])
  ans = sorted(ans)
  for itm in ans:
    print(itm)
  

if __name__ == '__main__':
  main()

Submission status: Time Limit Exceeded

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

key = set(S)

_dict = {}
for s in key:
    _dict[s] = S.count(s)

sort_dict = sorted(_dict.items(), key=lambda x: -x[1])
c = sort_dict[0][1]
lst = list()
for item in sort_dict:

    if c == item[1]:
        lst += [item[0]]
        c = item[1]
    else:
        break

lst.sort()

for i in lst:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
lis = []
indexes = []
cou = 1
ans = []
for _ in range(N):
  lis.append(input())
lis.sort()
if len(lis) != len(set(lis)):
  lis.append(999)
  for i in range(N):
    if lis[i] == lis[i+1]:
      cou += 1
    else:
      indexes.append(cou)
      cou = 1
  L = len(indexes)
  M = max(indexes)
  for k in range(L):
    if indexes[k] == M:
      ans.append(lis[sum(indexes[:k])])
  print(*ans)
else:
  print(*lis)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
lis = []
indexes = []
cou = 1
ans = []
for _ in range(N):
  lis.append(input())
lis.sort()
if len(lis) != len(set(lis)):
  lis.append(999)
  for i in range(N):
    if lis[i] == lis[i+1]:
      cou += 1
    else:
      indexes.append(cou)
      cou = 1
  L = len(indexes)
  M = max(indexes)
  for k in range(L):
    if indexes[k] == M:
      ans.append(lis[sum(indexes[:k])])
  ans.sort()
  print(*ans)
else:
  print(*lis)

Submission status: Time Limit Exceeded

Solution code:
import collections
n = int(input())
s = [input() for _ in range(n)]
c = collections.Counter(s)
l = [i for i,v in c.items() if v == max(c.values())]
l.sort()
for j in l:
    print(j)

Submission status: Time Limit Exceeded

Solution code:
import  collections 
N = int(input())
list_a = []
 
for i in range (0,N):
    a = input()
    list_a.append(a)
dict_a = collections.Counter(list_a)
 
 
list_ans = []
 
list_ans.append(dict_a.most_common()[0][0])
a = dict_a.most_common()[0][1]
for i in range (1,len(dict_a)):
    if a == dict_a.most_common()[i][1]:
        list_ans.append(dict_a.most_common()[i][0])
 
list_ans.sort()
for i in range (0,len(list_ans)):
    print(list_ans[i])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
str_list = []
for i in range(N):
  str_list.append(input())
str_set = sorted(list(set(str_list)))
cnt = [0] * len(str_set)
for i, str in enumerate(str_set):
  cnt[i] = str_list.count(str)

max_cnt = max(cnt)
for i in range(len(cnt)):
  if cnt[i]==max_cnt:
    print(str_set[i])

Submission status: Time Limit Exceeded

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

w = [kv[0] for kv in dc.items() if kv[1] == max(dc.values())]
w.sort()
for s in w:
  print(s)

Submission status: Time Limit Exceeded

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

lsts=list(set(s))
lrl=list(range(len(lsts)))
n = [0 for i in lrl]
for i in lrl:
  n[i]=s.count(lsts[i])
  
w=[lsts[i] for i in lrl if n[i]==max(n)]
w.sort()
for wd in w:
  print(wd)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
N=[]
for _ in range(n):
  a=input()
  N.append(a)
ids = sorted(list(set(N)))
ans=[0 for _ in range(len(ids))]
for i,j in enumerate(ids):
  ans[i]=N.count(j)
ma=max(ans)
for i in range(len(ans)):
  if ans[i]==ma:
    print(ids[i])

Submission status: Time Limit Exceeded

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

lsts=list(set(s))
lsts.sort()
n = [0 for i in range(len(lsts))]
for i in range(len(lsts)):
  n[i]=s.count(lsts[i])
  
ind=[i for i in range(len(lsts)) if n[i]==max(n)]
for i in ind:
  print(lsts[i])

Submission status: Time Limit Exceeded

Solution code:
def poll():
    N=int(input())
    S=[]
    for i in range(N):
        S.append(input())
    T=[]
    for i in S:
        if all(j!=i for j in T):
            T.append(i)
    T.sort()
    U=[0]*len(T)
    for i in range(len(T)):
        for j in S:
            if T[i]==j:
                U[i]+=1
    Max=[i for i, x in enumerate(U) if x == max(U)]
    for i in Max:
        print(T[i])
poll()

Submission status: Time Limit Exceeded

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

l = [s.count(i) for i in s]
d = {i:j for i,j in zip(s, l)}
m = max(l)

d = {i:j for i, j in zip(s, l)}
ans = [i for i in d if d[i] == m]
ans = sorted(ans)

for i in ans:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict

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

d = defaultdict(int)
for key in S:
    d[key] += 1
    
dl = sorted(d.items(), key=lambda x: x[0], reverse=False)

for i in range(len(dl)):
  if dl[i][1] == max(d.values()):
    print(dl[i][0])

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict

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

d = defaultdict(int)
for key in S:
    d[key] += 1
    
hoge = []

for key in d.keys():
  if d[key] == max(d.values()):
    hoge.append(key)

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

Submission status: Time Limit Exceeded

Solution code:
import collections

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

counter = collections.Counter(s)
ans = []
for i in sorted(list(counter.keys())):
    if counter[i] == counter.most_common()[0][1]:
        print(i)

Submission status: Time Limit Exceeded

Solution code:
import collections

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

counter = collections.Counter(s)
ans = []
for i in counter.keys():
    if counter[i] == counter.most_common()[0][1]:
        ans.append(i)
ans.sort()
for i in range(len(ans)):
    print(ans[i])

Submission status: Time Limit Exceeded

Solution code:
import collections
n = int(input())
s = [input() for i in range(n)]
c = collections.Counter(s)
x = c.most_common()[0][1]
a = []
for i in range(len(c)):
    y = c.most_common()[i][1]
    if y==x:
        a.append(c.most_common()[i][0])
a = sorted(a)
for i in a:
  print(i)

Submission status: Time Limit Exceeded

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

words = list(set(s))
max_num = 0
t = []
for word in words:
    count = s.count(word)

    if count > max_num:
        max_num = count
        t = [word]
    elif count == max_num:
        t.append(word)

t = sorted(t)
for i in t:
  print(i)

Submission status: Time Limit Exceeded

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

n = N
max_num = 0
t = []
while n >= max_num:
    word = s[0]
    count = s.count(s[0])

    if count > max_num:
        max_num = count
        t = [s[0]]
    elif count == max_num:
        t.append(s[0])

    for i in range(count):
        s.remove(word)
    n = len(s)

t = sorted(t)
for i in t:
  print(i)

Submission status: Time Limit Exceeded

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

n = N
max_num = 0
t = []
while n >= max_num:
    word = s[0]
    count = 0
    for i in s:
        if i == word:
            count += 1

    if count > max_num:
        max_num = count
        t = [s[0]]
    elif count == max_num:
        t.append(s[0])

    s = [i for i in s if i != word]
    n = len(s)

t = sorted(t)
for i in t:
  print(i)

Submission status: Time Limit Exceeded

Solution code:

def main():
    N = int(input())
    dict = {}

    for _ in range(N):
        word = input()
        if word in dict:
            dict[word] += 1
        else:
            dict[word] = 0

    max_k_list = [kv[0] for kv in dict.items() if kv[1] == max(dict.values())]
    max_k_list = sorted(max_k_list)
    for m in max_k_list:
        print(m)
    return 0


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import collections
n = int(input())
s = [input() for i in range(n)]
c = collections.Counter(s)
a = []
for i in range(len(c)):
    if c.most_common()[i][1]==c.most_common()[0][1]:
        a.append(c.most_common()[i][0])
a = sorted(a)
for i in a:
  print(i)