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:
def jud(a,b):
    dic = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
    if len(a) == 0:
        return 0
    if len(b) == 0:
        return 1
    if a[0] == b[0]:
        return jud(a[1:],b[1:])
    if dic.index(a[0]) > dic.index(b[0]):
        return 1
    if dic.index(a[0]) < dic.index(b[0]):
        return 0
def listint():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a
def megsort(s):
    p = len(s)
    if p == 1:
        return s
    else:
        q = int(p/2)
        left = megsort(s[q:])
        right = megsort(s[:q])
        arr = []
        while len(left)*len(right) != 0:
            if jud(left[0],right[0]) == 1:
                arr.append(right.pop(0))
                
            else:
                arr.append(left.pop(0))
        if len(left) == 0:
            arr.extend(right)
        else:
            arr.extend(left)
        return arr
        

n = int(input())
s = []
for i in range(n):
    s.append(input())
s = megsort(s)
ans = 1
ansar = [s[0]]
now = 1
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        now = now +1
    else:
        now = 1
    if now == ans:
        ansar.append(s[i+1])
    if now > ans:
        ans = now
        ansar = [s[i+1]]
for i in range(len(ansar)):
    print(ansar[i])

Submission status: Time Limit Exceeded

Solution code:
N =int(input())
words=[]
for i in range(N):
    words.append(input().rstrip())
candidate=list(set(words))
standard=0
for i in range(len(candidate)):
    if words.count(candidate[i])>standard:
        standard=words.count(candidate[i])
        presidents=[]
        presidents.append(candidate[i])
    elif words.count(candidate[i])==standard:
        presidents.append(candidate[i])
answers=sorted(presidents)
for answer in answers:
    print(answer)

Submission status: Time Limit Exceeded

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

c = collections.Counter(S)
ans = []

for i in range(len(c.most_common())):
    if i == 0:
        ans.append(((c.most_common()[0][0])))
    
    if i != 0:
        if (c.most_common()[i-1][1]) == (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:
n = int(input())
ar = [input() for _ in range(n)]

d = {}

for a in ar:
    if a in d:
        d[a] += 1
    else:
        d[a] = 1

print("\n".join(sorted([k for k, v in d.items() if v == max(d.values())])))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = [input() for _ in range(0, N)]
t = {}
for i in range(0, N):
    if S[i] in t:
        t[S[i]] += 1
    else:
        t[S[i]] = 1
max_k_list = [kv[0] for kv in t.items() if kv[1] == max(t.values())]
max_k_list.sort()
ans = "\n".join(max_k_list)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

data = {}
names = []
max_poll = 1

for i in range(n):
    s = input()
    if s in names:
        data[s] += 1
    else:
        data[s] = 1
        names.append(s)
    if max_poll < data[s]:
        max_poll = data[s]

winner = []
for key, value in data.items():
    if max_poll == value:
        winner.append(key)

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

Submission status: Time Limit Exceeded

Solution code:
def resolve():
    import sys
    from collections import Counter
    n = int(input())
    s = [sys.stdin.readline().rstrip() for i in range(n)]
    d = Counter(s).most_common()
    e = d[0][1]
    f = ([i for i in set(s) if s.count(i) == e])
    f = sorted(f)
    for i in f:
        print(i)
resolve()

Submission status: Time Limit Exceeded

Solution code:
def resolve():
    from collections import Counter
    n = int(input())
    s = []
    for i in range(n):
        s.append(input())
    d = Counter(s).most_common()
    e = d[0][1]
    f = ([i for i in set(s) if s.count(i) == e])
    f = sorted(set(f))
    for i in f:
        print(i)
resolve()

Submission status: Time Limit Exceeded

Solution code:
def resolve():
    from collections import Counter
    n = int(input())
    s = []
    for i in range(n):
        s.append(input())
    d = Counter(s).most_common()
    e = d[0][1]
    f = ([i for i in s if s.count(i) == e])
    f = sorted(set(f))
    for i in f:
        print(i)
resolve()

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter 

n = int(input())
li = list()
for _ in range(n):
    li.append(input())
a = Counter(li)
m = [x[0] for x in a.items() if x[1] == max(a.values())]
m.sort()
for i in m:
    print(i)

Submission status: Time Limit Exceeded

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

T = sorted(list(set(S)))
U = [S.count(T[i]) for i in range(len(T))]

for i in range(len(T)):
    if S.count(T[i]) == max(U):
        print(T[i])

Submission status: Time Limit Exceeded

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

T = sorted(list(set(S)))
U = [S.count(T[i]) for i in range(len(T))]

for i in range(len(T)):
    if S.count(T[i]) != max(U):
        T[i] = ''

for i in range(len(T)):
    if T[i] != '':
        print(T[i])

Submission status: Time Limit Exceeded

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

T = set(S)
U = list(T)
V = [S.count(U[i]) for i in range(len(T))]

for i in range(len(T)):
    if S.count(U[i]) != max(V):
        U[i] = ''

U = sorted(U)
for i in range(len(T)):
    if U[i] != '':
        print(U[i])

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
N = int(input())
S = [input() for i in range(N)]
S = dict(Counter(S))
T = list(S.keys())
U = list(S.values())
U = [j for j, k in enumerate(U) if k == max(U)]
Ans = []
for u in U:
    Ans.append(T[u])
Ans = sorted(Ans)
for ans in Ans:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
s=[input() for i in range(n)]
a=set(s)
ss=sorted(list(a))
ct=0
for i in a:
    if ct < s.count(i):
        ct = s.count(i)

for i in ss:
    if ct == s.count(i):
        print(i)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = sorted([input() for i in range(N)])
T = sorted(list(set(S)))
count = [0] * len(T)
for i in range(len(T)):
        count[i] = len([j for j, k in enumerate(S) if k == T[i]])
count_index = [k for k, l in enumerate(count) if l == max(count)]
for m in count_index:
    print(T[m])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = sorted([input() for i in range(N)])
T = sorted(list(set(S)))
count = [0] * len(T)
for i in range(len(T)):
    for j in range(N):
        if T[i] == S[j]:
            count[i] += 1
count_index = [k for k, l in enumerate(count) if l == max(count)]
for m in count_index:
    print(T[m])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
str = []
for i in range(N):
    str.append(input())
num = [str.count(x) for x in set(str)]
max_list = []
for i in set(str):
    if(str.count(i) == max(num)):
        max_list.append(i)
max_list.sort()
for i in max_list :print(i)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
S = []
for x in range(N):
    S.append(input().rstrip())
S_label_n = []
S_label = list(set(S))
for x in S_label:
    S_label_n.append(S.count(x))
max_n =max(S_label_n)
maxIndex = [i for i, x in enumerate(S_label_n) if x ==max_n ]
ans_list = []
for x in maxIndex:
    ans_list.append(S_label[x])
ans_list.sort()
for x in ans_list:
    print(x)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = []
for x in range(N):
    S.append(input())
S_label_n = []
S_label = list(set(S))
for x in S_label:
    S_label_n.append(S.count(x))
max_n =max(S_label_n)
maxIndex = [i for i, x in enumerate(S_label_n) if x ==max_n ]
ans_list = []
for x in maxIndex:
    ans_list.append(S_label[x])
ans_list.sort()
for x in ans_list:
    print(x)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = []
for x in range(N):
    S.append(input())
S_label_n = []
S_label = list(set(S))
for x in S_label:
    S_label_n.append(S.count(x))
maxIndex = [i for i, x in enumerate(S_label_n) if x == max(S_label_n)]
ans_list = []
for x in maxIndex:
    ans_list.append(S_label[x])
ans_list.sort()
for x in ans_list:
    print(x)

Submission status: Time Limit Exceeded

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

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

SS = collections.Counter(S)
for i in SS.keys():
    if(SS[i]== max(SS.values())):
        res.append(i)
res.sort()
for i in range(len(res)):
    print(res[i])

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
S={i:input() for i in range(N)}
value=[]
max=0

for i in S.values():
	N=list(S.values()).count(i)
	if N>max or N==max:
		max=N
for j in S.values():
	M=list(S.values()).count(j)
	if N==M:
		value.append(j)
value=list(set(value))
value.sort()
[print(i) for i in value]

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
list_S = [input() for i in range(N)]
list_S.sort()
list_a = []
a = 0
for i in range(N-1):
    if list_S[i] == list_S[i+1]:
        a += 1
    else:
        list_a.append(a+1)
        a = 0
list_a.append(a+1)
newlist_a = sorted(list_a,reverse=True)
A = newlist_a[0]
n = newlist_a.count(A)
ans = ""
if n == 1:
    t = 0
    for i in range(list_a.index(A)):
        t += list_a[i]
    if N == 1:
        ans = list_S[t]
    else:
        ans = list_S[t+1]
else:
    if A==1:
        for i in range(len(list_S)):
            ans += list_S[i]
            ans += "\n"
    else:            
        list_t = []
        b = 0
        for i,x in enumerate(list_a):
            if x == A:
                list_t.append(sum(list_a[0:i]))
                ans += list_S[list_t[b]]
                ans += "\n"
                b += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
list_S = [input() for i in range(N)]
list_S.sort()
list_a = []
a = 0
for i in range(N-1):
    if list_S[i] == list_S[i+1]:
        a += 1
    else:
        list_a.append(a+1)
        a = 0
list_a.append(a+1)
newlist_a = sorted(list_a,reverse=True)
n = newlist_a.count(newlist_a[0])
ans = ""
if n == 1:
    t = 0
    for i in range(list_a.index(newlist_a[0])):
        t += list_a[i]
    if N == 1:
        ans = list_S[t]
    else:
        ans = list_S[t+1]
else:
    if newlist_a[0]==1:
        for i in range(len(list_S)):
            ans += list_S[i]
            ans += "\n"
    else:            
        list_t = []
        b = 0
        for i,x in enumerate(list_a):
            if x == newlist_a[0]:
                list_t.append(sum(list_a[0:i]))
                ans += list_S[list_t[b]]
                ans += "\n"
                b += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import copy

N = int(input())
list_S = [input() for i in range(N) ]
list_S.sort()
list_a = []
a = 0
for i in range(N-1):
    if list_S[i] == list_S[i+1]:
        a += 1
    else:
        list_a.append(a+1)
        a = 0
list_a.append(a+1)
newlist_a = sorted(list_a,reverse=True)
n = newlist_a.count(newlist_a[0])
ans = ""
if n == 1:
    t = list_a.index(newlist_a[0])
    m = 0
    for i in range(t):
        m += list_a[i]
    ans +=list_S[m+t]
else:
    if newlist_a[0]==1:
        for i in range(len(list_S)):
            ans += list_S[i]
            ans += "\n"
    else:            
        list_A = copy.copy(list_a)
        list_t = []
        list_t.append(list_A.index(newlist_a[0]))
        for i in range(n-1):
            list_A.remove(newlist_a[i])
            m = 0
            for j in range(list_A.index(newlist_a[i])+i+1):
                m += list_a[j]
            list_t.append(m)
        for i in range(len(list_t)):
            ans += list_S[list_t[i]]
            ans += "\n"
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
list_S = [input() for i in range(N) ]
list_S.sort()
list_a = []
a = 0
while a < N :
    list_a.append(list_S.count(list_S[a]))
    a += list_S.count(list_S[a])
newlist_a = sorted(list_a,reverse=True)
n = newlist_a.count(newlist_a[0])

ans = ""
if n == 1:
    t = list_a.index(newlist_a[0])
    m = 0
    for i in range(t):
        m += list_a[i]
    ans +=list_S[m+t]
else:
    if newlist_a[0]==1:
        for i in range(len(list_S)):
            ans += list_S[i]
            ans += "\n"
    else:            
        list_A = []
        for i in range(len(list_a)):
            list_A.append(list_a[i])
        list_t = []
        list_t.append(list_A.index(newlist_a[0]))
        for i in range(n-1):
            list_A.remove(newlist_a[i])
            m = 0
            for j in range(list_A.index(newlist_a[i])+i+1):
                m += list_a[j]
            list_t.append(m)
        for i in range(len(list_t)):
            ans += list_S[list_t[i]]
            ans += "\n"
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
list_S = [input() for i in range(N) ]
list_S.sort()
list_a = []
a = 0
while a < N :
    list_a.append(list_S.count(list_S[a]))
    a += list_S.count(list_S[a])
newlist_a = sorted(list_a,reverse=True)
n = newlist_a.count(newlist_a[0])
ans = ""
if n == 1:
    t = 0
    for i in range(list_a.index(newlist_a[0])):
        t += list_a[i]
    ans = list_S[t+1]
else:
    if newlist_a[0]==1:
        for i in range(len(list_S)):
            ans += list_S[i]
            ans += "\n"
    else:            
        list_t = []
        for i,x in enumerate(list_a):
            if x == newlist_a[0]:
                list_t.append(sum(list_a[0:i]))
        for i in range(len(list_t)):
            ans += list_S[list_t[i]]
            ans += "\n"
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
list_S = [input() for i in range(N) ]
list_S.sort()
list_a = []
a = 0
for i in range(N-1):
    if list_S[i] == list_S[i+1]:
        a += 1
    else:
        list_a.append(a+1)
        a = 0
list_a.append(a+1)
newlist_a = sorted(list_a,reverse=True)
n = newlist_a.count(newlist_a[0])

ans = ""
if n == 1:
    t = list_a.index(newlist_a[0])
    m = 0
    for i in range(t):
        m += list_a[i]
    ans +=list_S[m+t]
else:
    if newlist_a[0]==1:
        for i in range(len(list_S)):
            ans += list_S[i]
            ans += "\n"
    else:            
        list_A = []
        for i in range(len(list_a)):
            list_A.append(list_a[i])
        list_t = []
        list_t.append(list_A.index(newlist_a[0]))
        for i in range(n-1):
            list_A.remove(newlist_a[i])
            m = 0
            for j in range(list_A.index(newlist_a[i])+i+1):
                m += list_a[j]
            list_t.append(m)
        for i in range(len(list_t)):
            ans += list_S[list_t[i]]
            ans += "\n"
print(ans)

Submission status: Time Limit Exceeded

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

dic = {}

def count_word(add_word):
	exist = False
	# 辞書dicにすでに書いてあるかチェック
	for key, value in dic.items():
		if add_word==key:
			value += 1
			dic[key] = value
			exist = True
			break
	
	# 辞書dicにない場合、追加
	if exist==False: dic[add_word] = 1

	return dic

for word in s:
	count_word(word)

# 書かれた回数の最大値
value_max = max(dic.values())
# print(value_max)


ans = [k for k, v in dic.items() if v==value_max]
ans = sorted(ans)

for a in ans:
	print(a)

Submission status: Time Limit Exceeded

Solution code:
# ABC 155 C
import numpy as np
N = int(input())
S = [str(input()) for i in range(N)]
S = np.array(S)
 
uni = np.unique(S) # return_counts is not available in numpy 1.8.2
count = np.array([np.sum((S==element)) for element in uni])

max_list = np.argwhere(count==np.max(count))
for index in max_list:
    print(str(uni[index][0]))

Submission status: Time Limit Exceeded

Solution code:
# ABC 155 C
import numpy as np
N = int(input())
S = [str(input()) for i in range(N)]
S = np.array(S)
 
uni = np.unique(S) # return_counts is not available in numpy 1.8.2
count = np.zeros(len(uni))
for i,element in enumerate(uni):
    count[i] = (S==element).sum()
    
max_list = np.argwhere(count==np.max(count))
for index in max_list:
    print(str(uni[index][0]))

Submission status: Time Limit Exceeded

Solution code:
# ABC 155 C
import numpy as np
N = int(input())
S = [str(input()) for i in range(N)]
S = np.array(S)
 
uni = np.unique(S) # return_counts is not available in numpy 1.8.2
uni = np.unique(S) 
count = np.zeros(len(uni))
for i,element in enumerate(uni):
    count[i] = (S==element).sum()
    
max_list = np.argwhere(count==np.max(count))
for index in max_list:
    print(str(uni[index][0]))

Submission status: Time Limit Exceeded

Solution code:
import collections
N = int(input())
S = [input() for _ in range(N)]
c = collections.Counter(S)
n = len(c)
max = c.most_common()[0][1]
d = 0
for j in range(n):
  if c.most_common()[j][1] == max:
    d += 1
  else:
    d = j
    break
ans = [c.most_common()[i][0] for i in range(d)]
ans.sort()
for i in range(d):
  print(ans[i])

Submission status: Time Limit Exceeded

Solution code:
import collections
N = int(input())
S = [input() for _ in range(N)]
c = collections.Counter(S)
n = len(c)
max = c.most_common()[0][1]
ans = [c.most_common()[i][0] for i in range(n) if c.most_common()[i][1] == max]
ans.sort()
m = len(ans)
for i in range(m):
  print(ans[i])

Submission status: Time Limit Exceeded

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

D = {}
for s in S:
    if not s in D.keys():
        D[s] = 0
    else:
        D[s] += 1

max_v = 0
res = []
for key in D.keys():
    if D[key] > max_v:
        max_v = D[key]
        res = [ key ]
    if D[key] == max_v and (not key in res):
        res.append(key)

for r in sorted(res):
    print(r)

Submission status: Time Limit Exceeded

Solution code:
import collections
S = []
ans = []
N = int(input())
for i in range(N):
    s = input()
    S.append(s)
c = collections.Counter(S)
j = 0
while c.most_common()[j][1]==c.most_common()[0][1] and j<len(collections.Counter(S)):
    if j==len(collections.Counter(S))-1:
        ans.append(c.most_common()[j][0])
        break
    ans.append(c.most_common()[j][0])
    j+=1
ans = sorted(ans)
for i in range(len(ans)):
  print(ans[i])

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
word=[list(map(str,input().split())) for i in range(N)]
word.sort()
#print(word)
answer=[]
for i in range(N-1):
    q=0
    while True:
        for j in range(N-i-1):
            if word[i+j]==word[i+j+1]:
                q+=1
            else:
                break
        newdata=[-q,word[i]]        
        answer.append(newdata)
        break
newdata=[0,word[N-1]]
answer.append(newdata)
answer.sort(reverse=True)        
#print(answer)
q=answer[len(answer)-1][0]
for i in range(len(answer)):
    if answer[len(answer)-1-i][0]==q:
        print(answer[len(answer)-1-i][1][0])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

words = []

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

words_s = sorted(list(set(words)))

most = []

max_count = 0

for i in words_s:
    a = words.count(i)
    if a > max_count:
        max_count = a
        most = []
        most.append(i)
    elif a == max_count:
        most.append(i)

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
word_count = {}
for n in range(N):
  s = input()
  if s in word_count:
    word_count[s] += 1
  else:
    word_count[s] = 1
max_word_list = [kv[0] for kv in word_count.items() if kv[1] == max(word_count.values())]
# 辞書順にソートして出力
max_word_list = sorted(max_word_list)
for word in max_word_list:
  print(word)

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
N = int(input())
A = []
for _ in range(N):
  A.append(input())

c = Counter(A)
l = [i[0] for i in c.items() if i[1] == c.most_common()[0][1]]
l.sort()

for s in l:
  print(s)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
def char_frequency(str1):
    dict = {}
    for n in str1:
        keys = dict.keys()
        if n in keys:
            dict[n] += 1
        else:
            dict[n] = 1
    return dict

N = int(input())

S = np.array([])

for i in range(N):
  S =np.append(S,str(input()))

d = char_frequency(S)

d_val = d.values()
d_key = d.keys()

d_val_max = max(d_val)
ans_key = [k for k, v in d.items() if v == d_val_max]
ans_key = sorted(ans_key)

for ans in ans_key:
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
list0 = []
list1 = []
for i in range(N):
  x = input()
  if x in list0:
    t = list0.index(x)
    list1[t] += 1
  else:
    list0.append(x)
    list1.append(1)
l = len(list0)
counter = 0
list2 = []
for i in range(l):
  if list1[i] > counter:
    counter = list1[i]
for i in range(l):
  if list1[i] == counter:
    list2.append(list0[i])
list2 = sorted(list2)
l_2 = len(list2)
for i in range(l_2):
  print(list2[i])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
l1 = list()
for i in range(n):
  l1.append(input())
l2 = set(l1)
M = 1
l3 = []
for s in l2:
  if l1.count(s) > M:
    M=l1.count(s)
    l3=[]
    l3.append(s)
  elif l1.count(s) == M:
    l3.append(s)
  else:
    continue
l4=sorted(l3)
for i in range(len(l4)):
  print(l4[i])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
mozi = list()
for i in range(n):
    mozi.append(input())
mozi.sort()
li = list()

for i in mozi:
    if not i in li:
        li.append(i)
kazu = list()

for i in li:
    kazu.append(mozi.count(i))

m = [i for i ,x in enumerate(kazu) if x == max(kazu)]

for i in m:
    print(li[i])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
mozi = list()
for i in range(n):
    mozi.append(input())
mozi.sort()
li = list()
for i in range(n):
    if not mozi[i] in li:
        li.append(mozi[i])
kazu = list()
for i in li:
    kazu.append(mozi.count(i))
m = [i for i ,x in enumerate(kazu) if x == max(kazu)]
for i in m:
    print(li[i],end=" ")

Submission status: Time Limit Exceeded

Solution code:
import collections
N=int(input())
S=collections.Counter(input() for i in range(N))
dictionary=sorted(key for key,value in S.items() if value==max(S.values()))
for d in dictionary:
    print(d)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
L = []
for i in range(N):
    L.append(input())
L.sort()
A = []
B = []
for i  in L:
    x = L.count(i)
    A.append([i , x])
    B.append(x)
for i in range(N - 1):
    if A[i][0] == A[i +1][0]:
        A[i][1] = 0
max = max(B)
C = []
for i in A:
    if i[1] == max:
        C.append(i[0])
for i in C:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
from collections import Counter
# input
n = int(input())
s = []
for i in range(n):
    s.append(input())
c = Counter(s)
# output
#ma = c.most_common()[0][1]
o = list(k for k, v in c.items() if v == c.most_common()[0][1])
#o = [k for k, v in c.items() if v == ma]
o.sort()
print('\n'.join(o))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
import collections
# input
n = int(input())
s = collections.Counter()
for i in range(n):
    s[input()] += 1
# print(s)
# output
# k = c.most_common()[0][1])
#out = collections.OrderedDict(k)
o = list(k for k, v in s.items() if v == s.most_common()[0][1])
for i in sorted(o):
    print(i)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
x=[]
y=[]
z=[]
for k in range(n):
  x.append(input())
  if x[-1] not in y:
    y.append(x[-1])
x.sort()
y.sort()
count=[1]*len(y)
head=0
for k in range(1,n):
  if x[k]!=x[k-1]:
    head+=1
  else:
    count[head]+=1
maxim=max(count)
for i in range(len(y)):
  if count[i]==maxim:
    print(y[i])

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
import collections
# input
n = int(input())
s = []
for i in range(n):
    s.append(input())
c = collections.Counter(s)
# output
# print(c.most_common()[0][1])
# print(list(c))
o = list(k for k, v in c.items() if v == c.most_common()[0][1])
for i in sorted(o):
    print(i)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
import collections
# input
n = int(input())
s = []
for i in range(n):
    s.append(input())
c = collections.Counter(s)
# output
# print(c.most_common()[0][1])
# print(list(c))
#print(sorted([k for k, v in c.items() if v == c.most_common()[0][1]]))
for i in sorted([k for k, v in c.items() if v == c.most_common()[0][1]]):
    print(i)

Submission status: Time Limit Exceeded

Solution code:
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
from collections import defaultdict
def resolve():
    N = ir()
    S = defaultdict(int)
    for i in range(N):
        S[sr()] += 1
    max_k_list = sorted([kv[0] for kv in S.items() if kv[1] == max(S.values())])
    for l in max_k_list:
        print(l)
resolve()

Submission status: Time Limit Exceeded

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

MAX=0
for i in range(len(A)):
  a=S.count(A[i])
  if a>=MAX:
    MAX=a

ans=[]

for i in A:
  if S.count(i)==MAX:
    ans.append(i)

ans.sort()

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

Submission status: Time Limit Exceeded

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

counter = Counter(words)
fin = [ii[0] for ii in counter.items() if ii[1] == max(counter.values())]

fin.sort()

for jj in fin:
    print(jj)

Submission status: Time Limit Exceeded

Solution code:
num = int(input())

num_list = []
count_list = []

for i in range(0,num):
  num_list.append(input())

num_set = list(set(num_list))

for i in range(0,len(num_set)):
  count_list.append(num_list.count(num_set[i]))

ans = []
max = 0

for i in range(0,len(num_set)):
  temp = count_list[i]
  
  if temp == max:
    ans.append(num_set[i])
  
  if temp > max:
    max = temp
    ans = []
    ans.append(num_set[i])
ans.sort()

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

Submission status: Time Limit Exceeded

Solution code:
num = int(input())

num_list = []

for i in range(0,num):
  num_list.append(input())

num_set = list(set(num_list))
count_list = []

num_list_len = len(num_list)

for i in range(0,len(num_set)):
  while num_set[i] in num_list:
    num_list.remove(num_set[i])
    
  count_list.append(num_list_len - len(num_list))
  num_list_len = len(num_list)

ans = []
max = 0

for i in range(0,len(num_set)):
  temp = count_list[i]
  
  if temp == max:
    ans.append(num_set[i])
  
  if temp > max:
    max = temp
    ans = []
    ans.append(num_set[i])
ans.sort()

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

Submission status: Time Limit Exceeded

Solution code:
i = int(input())
S = [input() for _ in range(i)]
d = {}
l = []
max = 1
for s in list(set(S)):
  if S.count(s) == max:
    max = S.count(s) 
    l.append(s)
  elif S.count(s) > max:
    max = S.count(s) 
    l = []
    l.append(s)    
#keys = sorted([k for k, v in d.items() if v == max])
for key in sorted(l):
  print(key)

Submission status: Time Limit Exceeded

Solution code:
i = int(input())
S = [input() for _ in range(i)]
d = {}
max = 1
for s in list(set(S)):
  if S.count(s) >= max:
    max = S.count(s) 
    d[s] = S.count(s)
keys = sorted([k for k, v in d.items() if v == max])
for key in keys:
  print(key)

Submission status: Time Limit Exceeded

Solution code:
i = int(input())
S = [input() for _ in range(i)]
d = {}
max = 0
for s in list(set(S)):
  if S.count(s) >= max:
    max = S.count(s) 
    d[s] = S.count(s)
keys = sorted([k for k, v in d.items() if v == max])
for key in keys:
  print(key)

Submission status: Time Limit Exceeded

Solution code:
i = int(input())
S = [input() for _ in range(i)]
d = {}
max = 0
for s in list(set(S)):
  d[s] = S.count(s)
  if S.count(s) > max:
    max = S.count(s) 
keys = sorted([k for k, v in d.items() if v == max])
for key in keys:
  print(key)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
l=[input() for i in range(n)]
import collections
c = collections.Counter(l)
#print(c)
e=list(c.most_common())
max_=c.most_common()[0][1]
#print(max_)
d=[]
for i in range(len(e)):
    if e[i][1]!=max_:break
    d.append(e[i][0])
    d.sort()
print(*d)

Submission status: Time Limit Exceeded

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


countDic = { k: words_org.count(k) for k in set(words_org) }
ranking = sorted([item for item in countDic.items()], key = lambda x:x[1], reverse=True)
order = 0
top = ranking[0][1]
candidates = []
while ranking[order][1] == top:
  candidates.append(ranking[order][0])
  order += 1
  if order > len(ranking)-1:
    break
for word in sorted(candidates):
  print(word)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
S=[]
T=[]
for i in range(N):
  S.append(input())
S.sort()
T.append(1)
k=0
for i in range(1,N):
  if S[i]==S[i-1]:
    k+=1
    T[i-1]=1
  else:
    k=1
  T.append(k)
for i in range(N):
  if T[i]==max(T):
    print(S[i])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = [input() for i in range(n)]
#
from collections import Counter
b = Counter(a)
c = list(b.keys())
d = list(b.values())
max_index = [i for i, v in enumerate(d) if v == max(d)]
e =[]
for k in range(len(max_index)):
    e.append(c[max_index[k]])
e = sorted(e)

#
#e = []
#for j in range(len(d)):
    #if int(d[j]) == max(d):
        #e.append(j)
#
#[print(c[e[k]]) for k in range(len(e))]
#f =[]
#for k in range(len(e)):
    #f.append(c[e[k]])
#f = sorted(f)
[print(e[l]) for l in range(len(e))]

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = [input() for i in range(n)]
#
from collections import Counter
b = Counter(a)
c = list(b.keys())
d = list(b.values())
#
e = []
for j in range(len(d)):
    if int(d[j]) == max(d):
        e.append(j)
#
#[print(c[e[k]]) for k in range(len(e))]
f =[]
for k in range(len(e)):
    f.append(c[e[k]])
f = sorted(f)
[print(f[l]) for l in range(len(f))]

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
a=[]
for i in range(N):
  a.append(input())
b=list(set(a))
b.sort()
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 e:
  print(l)