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=[input()for _ in range(n)]
ls,w,word=[],[],[]

for i in s:
  w.append(i)
  if i in w:
    ls.append(w.count(i))
    
  else:
    ls.append(1)

for i in range(n):
  if ls[i]==max(ls):
    word.append(w[i])
    
if set(word)==1:
  print(word[0])
  
else:
  word=sorted(set(word))
  for i in range(len(word)):
    print(word[i])

Submission status: Time Limit Exceeded

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

#
while len(S):
    if len(S)==1:
        x = [S.pop(), 1]
        ans.append(x)
        break
    x = [S.pop(), 1]
    for i in S[:]:
        if x[0] == i:
            S.remove(i)
            x[1]+=1
    ans.append(x)
ans.sort()
ans.sort(key=lambda x:x[1],reverse=True)

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

Submission status: Time Limit Exceeded

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

"""""#
while len(S):
    if len(S)==1:
        x = [S.pop(-1), 1]
        ans.append(x)
        break
    x = [S.pop(-1), 1]
    for i in S[:]:
        if x[0] == i:
            S.remove(i)
            x[1]+=1
    ans.append(x)
ans.sort()
ans.sort(key=lambda x:x[1],reverse=True)

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

"""

import queue

q=queue.Queue()
for i in S:
    q.put(i)

while not q.empty():
    x = [q.get(), 1]
    if len(ans)==0:
        ans.append(x)
        continue
    t=0
    for i in range(len(ans)):
        if x[0] == ans[i][0]:
            ans[i][1]+=1
            t+=1
            break
    if t==0:
        ans.append(x)
ans.sort()
ans.sort(key=lambda x:x[1],reverse=True)

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

Submission status: Time Limit Exceeded

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

#
while len(S):
    if len(S)==1:
        x = [S.pop(-1), 1]
        ans.append(x)
        break
    x = [S.pop(-1), 1]
    for i in S[:]:
        if x[0] == i:
            S.remove(i)
            x[1]+=1
    ans.append(x)
ans.sort()
ans.sort(key=lambda x:x[1],reverse=True)

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

Submission status: Time Limit Exceeded

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

#
while len(S):
    if len(S)==1:
        x = [S.pop(0), 1]
        ans.append(x)
        break
    x = [S.pop(0), 1]
    for i in S[:]:
        if x[0] == i:
            S.remove(i)
            x[1]+=1
    ans.append(x)
ans.sort()
ans.sort(key=lambda x:x[1],reverse=True)

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

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
S=[]
for i in range(N):
    S.append(input())
S.sort()
S.reverse()
ans=[]
while len(S):
    if len(S)==1:
        x = [S.pop(0), 1]
        ans.append(x)
        break
    x = [S.pop(0), 1]
    for i in S[:]:
        if x[0] == i:
            S.remove(i)
            x[1]+=1
    ans.append(x)

ans.sort(key=lambda x:x[1])
ans.reverse()
for i in range(len(ans)):
    t=ans[0][1]
    if ans[i][1]==t:
        print(ans[i][0])

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict
d = defaultdict(int)
N = int(input())
for i in range(N):
    d[input()] += 1

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

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
li=[]

count=1
n=int(input())
s=[input() for i in range(n)]
counter=Counter(s)
max=counter.most_common()[0][1]


for x in range(len(counter)):
    if max==counter.most_common()[x][1]:
         count+=1
         
         li.append(counter.most_common()[x][0])
    else:
        break
li.sort()
[print(z) for z in li]

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter


count=1
n=int(input())
s=[input() for i in range(n)]
counter=Counter(s)
max=counter.most_common()[0][1]
for x in range(1,len(counter)):
    if max==counter.most_common()[x][1]:
         count+=1
    else:
        break
li=[]*count
for y in range(count):
    
    li.append(counter.most_common()[y][0])
li.sort()

[print(z) for z in li]

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
n = int(input())
S = [input() for _ in range(n)]

poll = Counter(S)

ans = [k for k in poll.keys() if poll[k] == max(list(poll.values()))]
ans.sort()
for a in ans:
     print(a)

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
n = int(input())
S = [input() for _ in range(n)]

poll = dict(Counter(S))

ans = [k for k in poll.keys() if poll[k] == max(list(poll.values()))]
ans.sort()
for a in ans:
     print(a)

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
n = int(input())
S = [input() for _ in range(n)]

dictionary = dict(Counter(S))
ans = ["z" * 10] * n
i = 0
for k in dictionary.keys():
    if dictionary[k] == max(list(dictionary.values())):
        ans[i] = k
        i += 1

ans.sort()
for a in ans:
     if a == "z" * 10:
         break
     print(a)

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter, deque
n = int(input())
S = [input() for _ in range(n)]

dictionary = dict(Counter(S))
ans = [""] * n
i = 0
for k in dictionary.keys():
    if dictionary[k] == max(list(dictionary.values())):
        ans[i] = k
        i += 1

ans.sort()
for a in ans:
    if a == "":
        continue
    print(a)

Submission status: Time Limit Exceeded

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

s_list.sort()

max_times = 0
for s in set(s_list):
    times = s_list.count(s)
    if max_times < times:
        max_times = times

if max_times == 1:
    for s in s_list:
        print(s)
else:
    for i in range(len(s_list)-max_times+1):
        if s_list[i] == s_list[i+max_times-1]:
            print(s_list[i])

Submission status: Time Limit Exceeded

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

s_list.sort()

max_times = 0
for s in s_list:
    times = s_list.count(s)
    if max_times < times:
        max_times = times

s_strip = list(set(s_list))
s_strip.sort()
for s in s_strip:
    times = s_list.count(s)
    if times == max_times:
        print(s)

Submission status: Time Limit Exceeded

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

S_time = list()
for i in range(N):
    counter = 0
    for j in range(N):
        if S[i] == S[j]:
            counter += 1
    S_time.append(counter)

if N == counter:
    print(S[0])
else:
    S_max_list = list()
    max = S_time[0]
    S_max_list.append(0)
    counter_list=1
    for i in range(1,N,1):
        if max == S_time[i]:
            S_max_list.append(i)
            counter_list += 1
        elif max < S_time[i]:
            max = S_time[i]
            S_max_list.clear()
            S_max_list.append(i)
            counter_list = 1

    S_list= list()
    for i in range(counter_list):
        S_list.append(S[S_max_list[i]])

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

Submission status: Time Limit Exceeded

Solution code:
import collections
n = int(input())

s = []
sLen = len(s)
for i in range(n):
    s.append(input())
c = collections.Counter(s)
max = c.most_common()[0][1]
print()
ans = []
for i in range(len(c.most_common())):
    if max == c.most_common()[i][1]:
        ans.append(c.most_common()[i][0])
    else:
        break
ans.sort()
for i in ans:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
from operator import itemgetter

n = int(input())
a = [input() for i in range(n)]
b = list(set(a))
b.sort()
c = []

max = a.count(b[0])

for i in range(len(b)):
	c.append(a.count(b[i]))

unique_count = list(zip(b, c))
unique_count.sort(key = itemgetter(1), reverse=True)

for j in range(len(unique_count)):
	if unique_count[j][1] == unique_count[0][1]:
		print(unique_count[j][0])

Submission status: Time Limit Exceeded

Solution code:
import collections
N = int(input())
 
dic = {}
for i in range(N):
  S = input()
  if S in dic:
    dic[S] += 1
  else:
    dic[S] = 1
maxval = max(dic.values())
 
keys = [k for k, v in dic.items() if  v == max(dic.values())]
[print(sorted(keys)[i]) for i in range(len(keys))]

Submission status: Time Limit Exceeded

Solution code:
import collections
N = int(input())

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

maxval = max(dic.values())

keys = [k for k, v in dic.items() if  v == max(dic.values())]
[print(sorted(keys)[i]) for i in range(len(keys))]

Submission status: Time Limit Exceeded

Solution code:
import collections
N = int(input())
c = collections.Counter([input() for _ in range(N)])
[print(sorted([k for k, v in c.items() if  v == max(c.values())])[i]) \
 for i in range(len([k for k, v in c.items() if  v == max(c.values())]))]

Submission status: Time Limit Exceeded

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

import collections
c = collections.Counter(s)

keys = [k for k, v in c.items() if  v == max(c.values())]
[print(sorted(keys)[i]) for i in range(len(keys))]

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = [input() for _ in range(N)]
D = {s: S.count(s) for s in set(S)}
M = [k for k, v in D.items() if v == max(D.values())]
M.sort()
for m in M:
  print(m)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

word_dict = {}

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

max_list = [kv[0] for kv in word_dict.items() if kv[1] == max(word_dict.values())]
sort_list = sorted(max_list)
for i in sort_list:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
d={}
for x in range(N):
    s = input()
    if d.get(s) is None: d[s] = 1
    else: d[s] += 1
    
print('\n'.join(sorted(dict(filter(lambda x: x[1] == max(d.values()), d.items())).keys())))

Submission status: Time Limit Exceeded

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

score=1
kati=[]
for i in range(N):
  kiroku=1
  for j in range(N-i):
    if j>0 and S[i]==S[i+j]:
      kiroku+=1
  if kiroku==score:
    kati.append(S[i])
  elif kiroku>score:
    score=kiroku
    kati=[S[i]]

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
s=[]
for _ in range(n):
	s.append(input())
element=list(set(s))

Max=0
for i in element:
	Max=max(Max,s.count(i))

ans=[]
for i in element:
	if Max==s.count(i):
		ans.append(i)
ans.sort()
for i in ans:
	print(i)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
lis = [input() for _ in range(n)]
s = set(lis)
a = []
for i in s:
    a.append([lis.count(i), i])
M = max(a, key=lambda i : i[0])
anslis = [i[1] for i in a if i[0]==M[0]]
anslis.sort()
for i in anslis:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
lis = [input() for _ in range(n)]
s = set(lis)
a = []
for i in s:
    a.append([lis.count(i), i])
slis = sorted(a, key=lambda i : i[1])
M = max(slis, key=lambda i : i[0])
func = lambda i:i[1] if i[0] == M else None
anslis = [i[1] for i in slis if i[0]==M[0]]
for i in anslis:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
res = dict()
for i in range(N):
  word = input()
  if word not in res:
    res[word] = 0
  res[word] += 1
max_word = [word[0] for word in res.items() if word[1] == max(res.values())]
max_word.sort()
for el in max_word:
    print(el)

Submission status: Time Limit Exceeded

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

word = list(set(words))
counter = list()
dict = {}

for a in word:
    dict[a] = words.count(a)

max = max(dict.values())

for a in word:
    if dict[a] == max:
        continue
    else:
        del dict[a]

dict2 = sorted(dict.keys())

for a in dict2:
    print(a)

Submission status: Time Limit Exceeded

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

word = list(set(words))
counter = list()
dict = {}

for a in word:
    counter.append(words.count(a))

max = max(counter)

for a,b in zip(word,counter):
    dict[a] = b

for a in word:
    if dict[a] == max:
        continue
    else:
        del dict[a]

dict2 = sorted(dict.keys())

for a in dict2:
    print(a)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = []
for i in range(n):
    inp = input()
    if inp in s:
        s[s.index(inp)+1] += 1
    else:
        s.append(inp)
        s.append(1)

chknum = s[1]
for i,v in enumerate(s):
    if i%2 == 1:
        chknum = max(chknum, v)


ind = [i-1 for i, x in enumerate(s) if x == chknum]

ans = []
for i in ind:
    ans.append(s[i])
    # print(s[i])

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

Submission status: Time Limit Exceeded

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

keys = list(t.keys())
values = list(t.values())
ans = []
for j in [i for i,v in enumerate(values) if v == max(values)]:
    ans.append(keys[j])
ans.sort()
for i in ans:
    print(i)

Submission status: Time Limit Exceeded

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

c = collections.Counter(s)
keys = list(c.keys())
values = list(c.values())
ans = []
for i,v in enumerate(values):
    if v == max(values):
        ans.append(keys[i])
ans.sort()
for i in ans:
    print(i)

Submission status: Time Limit Exceeded

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

tmp = s[:]
tmp = list(set(tmp))
cnt = []
# for i in tmp:
#     cnt.append([i, s.count(i)])
for i in tmp:
    cnt.append(s.count(i))

maxIndex = [i for i,v in enumerate(cnt) if v == max(cnt)]

ans = []
for i in maxIndex:
    ans.append(tmp[i])
# m = 0
# for i in cnt:
#     if m == i[1]:
#         ans.append(i[0])
#     elif m < i[1]:
#         ans.clear()
#         ans.append(i[0])
#         m = i[1]

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

Submission status: Time Limit Exceeded

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

tmp = s[:]
tmp = list(set(tmp))
cnt = []
for i in tmp:
    cnt.append([i, s.count(i)])

ans = []
m = 0
for i in cnt:
    if m == i[1]:
        ans.append(i[0])
    elif m < i[1]:
        ans.clear()
        ans.append(i[0])
        m = i[1]

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
Box = [input() for i in range(N)]
Neet = sorted(list(set(Box)))

Answer = [Box.count(i) for i in Neet ]

m = max(Answer)

for i in range(len(Neet)):
    if Answer[i] == m:
        print(Neet[i])

Submission status: Time Limit Exceeded

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

C = [0] * N

for i in range(N):
    C[i] = S.count(S[i])
    
X = []    

for i in range(N):
    if C[i] == max(C) and not S[i] in X:
        X.append(S[i])

Y = sorted(X)

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

Submission status: Time Limit Exceeded

Solution code:

N = int(input())
S = sorted(input() for i in range(N))

C = [0] * N

for i in range(N):
    C[i] = S.count(S[i])
    
X = []    

for i in range(N):
    if C[i] == max(C) and not S[i] in X:
        X.append(S[i])
        print(S[i])

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a_dict={}
for i in range(n):
    a=input()
    if a not in a_dict:
        a_dict[a]=0
    else:
        a_dict[a]+=1
moji=[i for i,j in a_dict.items() if j==max(a_dict.values()) ]
moji=sorted(moji)
for i in moji:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
import collections
N = int(input()) 
S = [0]*N
for i in range(N):
    S[i] = input()
c = collections.Counter(S)
values,counts = zip(*c.most_common())
X = c.most_common()[0][1]
list = []
for i in range(0,len(c.most_common())):
    if c.most_common()[i][1] == X:
        list.append(c.most_common()[i][0])
    else:
        break
list.sort()
for i in range(len(list)):
    print(list[i])

Submission status: Time Limit Exceeded

Solution code:
import collections
N = int(input()) 
S = [0]*N
for i in range(N):
    S[i] = input()
c = collections.Counter(S)
values,counts = zip(*c.most_common())
X = c.most_common()[0][1]
list = []
for i in range(0,len(c.most_common())):
    if c.most_common()[i][1] == X:
        list.append(c.most_common()[i][0])
list.sort()
for i in range(len(list)):
    print(list[i])

Submission status: Time Limit Exceeded

Solution code:
import collections

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

s_append = s.append
for _ in range(n):
    s_append(input())

pop_times = collections.Counter(s)
most_common_word = []

most_common_word_append = most_common_word.append
for i in pop_times.most_common():
    if pop_times.most_common()[0][1] == i[1]:
        most_common_word_append(i[0])

for x in sorted(most_common_word):
    print(x)

Submission status: Time Limit Exceeded

Solution code:
import collections

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

pop_times = collections.Counter(s)
most_common_word = []

for i in pop_times.most_common():
    if pop_times.most_common()[0][1] == i[1]:
        most_common_word.append(i[0])

sorted_most_common_word = sorted(most_common_word)

for x in sorted_most_common_word:
    print(x)

Submission status: Time Limit Exceeded

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

s = list(set(l) ) 
s.sort( key = lambda x : l.count(x), reverse=True)

m =l.count(s[0])
f = list( filter ( lambda x: l.count(x ) == m  , s ))
f.sort()
print(*f, sep = '\n')

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
import collections
l = [input() for i in range(n)]
l_cnt = collections.Counter(l)
l_cnt_max = []
for i in l_cnt:
    if l_cnt[i] == max(l_cnt.values()):
        l_cnt_max.append(i)
m = sorted(l_cnt_max)
for i in m:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
Box = [input() for i in range(N)]
Neet = sorted(list(set(Box)))

Answer = []
for i in Neet:
    c = Box.count(i)
    Answer.append(c)

m = max(Answer)

for i in range(len(Neet)):
    if Answer[i] == m:
        print(Neet[i])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = [input() for i in range(n)]
from collections import Counter
s1 = Counter(s)
s2 = list(set(s))
s2.sort()
for i in range(len(s2)):
    if s1[s2[i]] == max(s1.values()):
        print(s2[i])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = [input() for i in range(n)]
s.sort()
from collections import Counter
s1 = Counter(s)
s2 = list(set(s))
s2.sort()
for i in range(len(s2)):
    if s1[s2[i]] == max(s1.values()):
        print(s2[i])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s_list = [input() for i in range(n)]
s_set = set(s_list)
max = 0
max_elements = []
for i in s_set:
    c = s_list.count(i)
    if c > max:
        max = c
        max_elements = [i]
    if c == max and i not in max_elements:
        max_elements.append(i)

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = [input() for i in range(n)]
s_set = set(s)
max = 0
max_elements = []
for i in s_set:
    c = s.count(i)
    if c > max:
        max = c
        max_elements = [i]
    if c == max and i not in max_elements:
        max_elements.append(i)

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

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
N=int(input())
A=[0]*N
B=[0]*N
j=0
for i in [0]*N:
 h=input()
 if h in A:
  B[A.index(h)]+=1
 else:
  A[j]=h
  B[j]=1
  j+=1
d=max(B)
C=[]
for i in range(N):
 if B[i]==d:
  C.append(A[i])
C.sort()
for i in range(len(C)):
 print(C[i],end='')

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
N=int(input())
A=[]
B=[]
for i in [0]*N:
 h=input()
 if h in A:
  B[A.index(h)]+=1
 else:
  A.append(h)
  B.append(1)
d=max(B)
C=[]
for i in range(len(B)):
 if B[i]==d:
  C.append(A[i])
C.sort()
for i in range(len(C)):
 print(C[i],end='')

Submission status: Time Limit Exceeded

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
count = {}
c = 0
for i in range(n):
    s = input()
    count[s] = count.get(s,0)+1
ans = sorted([kv[0] for kv in count.items() if kv[1] == max(count.values())])
for item in ans:
    print(item)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
s = [input() for i in range(N)]
L = list(set(s))
S = [s.count(j) for j in L]
M = max(S)
l = len(S)
A = [L[k] for k in range(l) if S[k] == M]
A.sort()
[print(m) for m in A]

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

# 文字列の出現回数を格納
S = {}
for _ in range(N):
    s = input()
    if s in S:
        S[s] += 1
    else:
        S[s] = 1

# 出現回数が最大の文字列をansに格納し、昇順にソートする
ans = [k for k, v in S.items() if v == max(S.values())]
ans.sort()

# 出力
for a in ans:
    print(a)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

# 文字列の出現回数を格納
S = {}
for _ in range(N):
    s = input()
    if s in S:
        S[s] += 1
    else:
        S[s] = 1

# 出現回数が最大の文字列をansに格納し、昇順にソートする
ans = [k for k, v in S.items() if v == max(S.values())]
ans.sort()

# 出力
for a in ans:
    print(a)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
s = []
counts = []
count2 = 0
results = []
for i in range(N):
    s.append(input())
for i in s:
    count = 0
    for i2 in s:
        if i == i2:
            count += 1
    counts.append(count)
for i in counts:
    if max(counts) == i:
        results.append(s[count2])
    count2 += 1
for result in sorted(set(results)):
    print(result)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
l = []
c = []
for i in range(N):
  s = input()
  try:
    index = l.index(s)
    c[index] += 1
  except:
    l.append(s)
    c.append(1)
m = max(c)
n = []
for i in range(len(c)):
  if c[i] == m:
    n.append(l[i])

n.sort()
for g in n:
  print(g)

Submission status: Time Limit Exceeded

Solution code:
inpvals = []
lopvals = []
outvals = []

max_loop = int(input())
idx_loop = 0
while idx_loop < max_loop :
  inpvals.append(input())
  idx_loop = idx_loop+1

max_cnt = 0
lopvals = set(inpvals)
for inpval in lopvals :
  cnt = inpvals.count(inpval)

  if max_cnt <= cnt :
    if max_cnt != cnt :
      outvals = []
    max_cnt = cnt
    outvals.append(inpval)

outvals.sort()
    
for outval in outvals :
  print(outval)

Submission status: Time Limit Exceeded

Solution code:
inpvals = []
outvals = []

max_loop = int(input())
idx_loop = 0
while idx_loop < max_loop :
  inpvals.append(input())
  idx_loop = idx_loop+1

max_cnt = 0
for inpval in set(inpvals) :
  cnt = inpvals.count(inpval)

  if max_cnt <= cnt :
    if max_cnt != cnt :
      outvals = []
    max_cnt = cnt
    outvals.append(inpval)

outvals.sort()
    
for outval in outvals :
  print(outval)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = []
C = []
M = 1
pS = ''
pM = 0
for i in range(N):
  s = input()
  if s in S:
    n = S.index(s)
    C[n] += 1
    if C[n] > M:
      if pS != s:
        pS = s
        pM = M
      M = C[n]
      if M - pM > N - i:
        print(s)
        exit()
  else:
    S.append(s)
    C.append(1)
l = len(C)
A = [S[j] for j in range(l) if C[j] == M]
A.sort()
[print(k) for k in A]

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = []
C = []
M = 1
for i in range(N):
  s = input()
  if s in S:
    n = S.index(s)
    C[n] += 1
    if C[n] > M:
      M = C[n]
  else:
    S.append(s)
    C.append(1)
l = len(C)
A = [S[j] for j in range(l) if C[j] == M]
A.sort()
[print(k) for k in A]

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = []
C = []
for i in range(N):
  s = input()
  if s in S:
    n = S.index(s)
    C[n] += 1
    if C[n] > N // 2:
      print(S[n])
      exit()
  else:
    S.append(s)
    C.append(1)
M = max(C)
l = len(C)
A = [S[j] for j in range(l) if C[j] == M]
A.sort()
[print(k) for k in A]

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = []
C = []
for i in range(N):
  s = input()
  if s in S:
    C[S.index(s)] += 1
  else:
    S.append(s)
    C.append(1)
M = max(C)
l = len(C)
A = [S[j] for j in range(l) if C[j] == M]
A.sort()
[print(k) for k in A]

Submission status: Time Limit Exceeded

Solution code:
import collections

n = int(input())

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

c = collections.Counter(l)

max_list = [kv[0] for kv in c.items() if kv[1] == max(c.values())]
max_list.sort()
for i in range(len(max_list)):
    print(max_list[i])

Submission status: Time Limit Exceeded

Solution code:
import collections


def main():
    n = int(input())
    word_list = []

    for _ in range(n):
        word_list.append(input())

    c = collections.Counter(word_list)
    most_freq_word = sorted([i for i in c if c[i] == max(c.values())])
    print('\n'.join(most_freq_word))


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import collections


def main():
    n = int(input())
    word_list = []

    for _ in range(n):
        word_list.append(input())

    c = collections.Counter(word_list)
    most_freq_word = [i for i in c if c[i] == max(c.values())]

    most_freq_word.sort()
    s = '\n'.join(most_freq_word)
    print(s)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
#!/usr/local/bin python
# -*- coding: utf-8 -*-
#
# ~/PycharmProjects/atcoder/C-.py
#
import collections

n = int(input())
l = [str(input()) for i in range(n)]
# l = ["beat", "vet", "beet", "bed", "vet", "bet", "beet"]
c = collections.Counter(l)
number_of_words = len(c)
ans_before_sort = [c.most_common()[0][0]]

for i in range(number_of_words-1):
    if c.most_common()[i][1] == c.most_common()[i+1][1]:
        ans_before_sort.append(c.most_common()[i+1][0])
    else:
        break

ans_after_sort = sorted(ans_before_sort)
print('\n'.join(ans_after_sort))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
L = [input() for i in range(N)]
c = [L.count(j) for j in L]
C = max(c)
l = [L[k] for k in range(N) if c[k] == C]
m = list(set(l))
m.sort()
[print(n) for n in m]

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
L = [input() for i in range(N)]
l = list(set(L))
c = [L.count(j) for j in l]
C = max(c)
A = [l[k] for k in range(len(l)) if c[k] == C]
A.sort()
[print(l) for l in A]

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
L = [input() for i in range(N)]
l = list(set(L))
l.sort()
c = [L.count(j) for j in l]
C = max(c)
[print(l[k]) for k in range(len(l)) if c[k] == C]

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
L = [input() for i in range(N)]
l = list(set(L))
l.sort()
c = [L.count(j) for j in l]
C = max(c)
[print(k) for k in l if L.count(k) == C]

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
L = []
for i in range(N):
  L.append(input())
l = list(set(L))
l.sort()
c = [L.count(j) for j in l]
C = max(c)
[print(k) for k in l if L.count(k) == C]

Submission status: Time Limit Exceeded

Solution code:
import collections

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

c = collections.Counter(s)
x = c.most_common()[0][1]

for item in s:
  if c[item] == x and item not in  l:
  	l.append(item)

for item in l:
  print(item)

Submission status: Time Limit Exceeded

Solution code:
import collections
from numpy.ma.core import sort
N = int(input())
arr = [input() for i in range(N)]
c = collections.Counter(arr)
# print(max(c.values()))
# ans = [c[x] for x in c]
ans = sorted([x for x in c if c[x] == max(c.values())])
# ans = [x for x in c]
for i in ans:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
d = {}
for i in range(N):
    s = input()
    if s in d.keys():
        d[s] += 1
    else:
        d[s] = 1
keys = [k for k, v in d.items() if v == max(d.values())]
keys.sort()
for k in keys:
    print(k)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
slist = tuple(input() for i in range(n))
sset = set(slist)
slist2 = list(sset)
slist2.sort()
c = 0
for i in slist2:
  if slist.count(i) > c:
    c = slist.count(i)
for i in slist2:
  if c == slist.count(i):
    print(i)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
n = int(input())
slist = tuple(input() for i in range(n))
sset = set(slist)
slist2 = list(sset)
slist2.sort()
count_list = []
c = 0
for i in slist2:
  count_list.append(slist.count(i))
  if slist.count(i) > c:
    c = slist.count(i)
for i in range(len(count_list)):
  if c == count_list[i]:
    print(slist2[i])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
slist = list(input() for i in range(n))
sset = set(slist)
slist2 = list(sset)
slist2.sort()
count_list = []
for i in slist2:
  count_list.append(slist.count(i))
for i in range(len(count_list)):
  if max(count_list) == count_list[i]:
    print(slist2[i])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = [str(input()) for _ in range(n)]
d = dict((l,s.count(l)) for l in set(s))
max = max(d.values())
k = [x for x, y in d.items() if y ==max]
k.sort()
for i in k:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = [input() for i in range(N)]
list.sort(S)
i = 0
y = []
MAX = 0
while i < N:
    a = S.count(S[i])
    if MAX < a:
        MAX = a
        y.clear()
        y.append(S[i])
    elif MAX == a:
        y.append(S[i])
    i+=a
for i in y:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = [input() for i in range(N)]
y = []
N = 0
while S!=[]:
    if N < S.count(S[0]):
        N = S.count(S[0])
        y.clear()
        y.append(S[0])
    elif N == S.count(S[0]):
        y.append(S[0])
    S = [i for i in S if i != S[0]]
for i in sorted(y):
    print(i)