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())
index=[]
count=[]
for i in range(N):
    inp=input()
    if inp in index:
        count[index.index(inp)]+=1
    else:
        index.append(inp)
        count.append(1)

rank=max(set(count))
o=[]
while rank in count:
    o.append(index.pop(count.index(rank)))
    del count[count.index(rank)]
o.sort()
for i in o:
    print(i)

Submission status: Time Limit Exceeded

Solution code:

n = int(input())
s = []
a = []
mx = 0
b = []
c = []
d = []

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

a = set(s)
a = list(a)

for j in range(len(a)):
    b.append(s.count(a[j]))

mx = max(b)
#print(b)

for k in range(len(b)):
    if b[k] == mx:
        c.append(k)
for l in range(len(c)):
    d.append(a[c[l]])
d.sort()

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
List=[input() for i in range(n)]
max = 0
for i in List:
    if max <= List.count(i):
        # 最大値更新
        max = List.count(i)
        # 出現回数最大の文字をコピーしたリスト作成
name_List = [i for i in List if List.count(i) == max]

# print(name_List)
# print(set(name_List))
setted_List = set(name_List)
sorted_List =(sorted(setted_List))
for i in sorted_List:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
#!usr/bin/env python3


import sys


def I(): return int(sys.stdin.readline())


def solve():
    n = I()
    sli = [input() for i in range(n)]
    setli = set(sli)
    rank = {}
    for i in setli:
        j = sli.count(i)
        rank[i] = j
    ans = sorted([k for k, v in rank.items() if v == max(rank.values())])
    for i in ans:
        print(i)


# Solve
if __name__ == "__main__":
    solve()

Submission status: Time Limit Exceeded

Solution code:
import itertools
n=int(input())
s = []
for _ in range(n):
    s.append(input())
#print(s)
#s = list(itertools.chain.from_iterable(s))
#print(s)
s_u = list(set(s))
box = []
for i in range(len(s_u)):
    box.append([s_u[i],s.count(s_u[i])])

box = sorted(box,key=lambda x:x[1],reverse=True)

ans_box = []
#ans_box.append(box[0][0])
for j in range(len(box)):
    if box[j][1] == box[0][1]:
        ans_box.append(box[j][0])
        
    else:
        break
ans_box = sorted(ans_box)
for i in range(len(ans_box)):
    print(ans_box[i])

Submission status: Time Limit Exceeded

Solution code:
#C




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

m = 0
l = []
for i in range(len(s)):
    if m < s.count(s[i]):
        l = [s[i]]
        m = s.count(s[i])
    elif m == s.count(s[i]):
        l.append(s[i])
l = sorted(list(set(l)))
for i in l:
    print(i) 
# beat
# vet
# beet
# bed
# vet
# bet
# beet

Submission status: Time Limit Exceeded

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

l = list(set(s))

count = [0] * len(l)
for i, v in enumerate(l):
    count[i] = s.count(v)

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

ans = []
for i in indexes:
    ans.append(l[i])

ans.sort()

for i in ans:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

l = []
for x in range(N):
    x = input()
    l.append(x)
    
l_sorted=sorted(l)

lst = sorted(set(l))
n_list = []

for x in lst:
    n = l_sorted.count(x)
    n_list.append(n)

max_n = max(n_list)
l_max = [i for i, x in enumerate(n_list) if x == max_n]

for x in l_max:
    print(lst[x])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

for_dict = {}
for _ in range(N):
    n = input()
    if n in for_dict:
        for_dict[n] += 1
    else:
        for_dict.setdefault(n, 1)

slist = sorted(for_dict.items(), key = lambda x : x[0])

for ele in slist:
  if ele[1] == max(for_dict.values()):
    print(ele[0])

Submission status: Time Limit Exceeded

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

box = []
S_box = []
last = []
sss = set(S)
an = []

for k in sss:
    S_box.append(k)

for i in range(0, len(sss)):
    box.append(S.count(S_box[i]))

num = max(box)

for a in range(0, len(box)):
    if num == box[a]:
        last.append(a)

for iii in last:
    an.append(S_box[iii])
an = sorted(an)
for aaa in an:
    print(aaa)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = [input() for i in range(N)]
S = sorted(S)
def count(S):
    A = []
    s = 1
    for i in range(0,len(S)-1):
        if S[i] == S[i+1]:
            s = s + 1
        else:
            A.append(s)
            s = 1
    A.append(s)
    return A
def search(S):
    A = count(S)
    x = A[0]
    a = [0]
    for i in range(1,len(A)):
        if x < A[i]:
            x = A[i]
            a = []
            a.append(i)
        elif x == A[i]:
            a.append(i)
    C = []
    for i in range(0,len(a)):
        s = 0
        for j in range(0,a[i]):
            s = s + A[j]
        C.append(S[s])
    return C
print('\n'.join(map(str,search(S))))

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
int = int(input())
word = [input() for i in range(int)]
s = Counter(word)
u = [k for k, v in s.items() if v == max(s.values())]
u.sort()
for j in range(len(u)):
    print(u[j])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = [input() for i in range(N)]
S_set = sorted(list(set(S)))
#print(S_set)
cnt = [0 for i in range(len(S_set))]
word_buf = []
mmax = -1

for i in range(len(S_set)) :
    cnt[i] = S.count(S_set[i])
    if i == 0 :
        word_buf.append(S_set[i])
    else :
        if cnt[i] < mmax :
            pass
        elif cnt[i] == mmax :
            word_buf.append(S_set[i])
        elif cnt[i] > mmax :
            word_buf.clear()
            word_buf.append(S_set[i])
    mmax = max(mmax,cnt[i]) # 現時点での最大値

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

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
s=[input() for i in range(N)]
S=sorted(s)
a=1
num=[]
st=[]
for i in range(N-1):
  if S[i+1]==S[i]:
    a+=1
    if i == (N-2):
        num.append(a)
        st.append(S[-1])
  elif S[i+1]!=S[i]:
    num.append(a)
    st.append(S[i])
    a=1
if S[-1]!=S[-2]:
    num.append(1)
    st.append(S[-1])

d=max(num)
x=[]
if num.count(d)==1:
    print(st[num.index(max(num))])
else:
    ind=[i for i, v in enumerate(num) if v == max(num)]# 複数の最大値のインデックスを全て取得
    st2=[]
    for i in range(len(ind)):
        st2.append(st[ind[i]])
    [print(i) for i in st2]

Submission status: Time Limit Exceeded

Solution code:
def poll(arr):
    ans_h = {}
    for ele in arr:
        if ele in ans_h.keys():
            ans_h[ele] += 1
        else:
            ans_h[ele] = 0
    for ele in sorted([kv for kv in ans_h.items() if kv[1] == max(ans_h.values())]):
        print(ele[0])

if __name__ == "__main__":
    n = int(input())
    arr = [input() for _ in range(0, n)]
    poll(arr)

Submission status: Time Limit Exceeded

Solution code:
import collections

N = int(input())

a = list()

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

c = collections.Counter(a)

#print(c.most_common()[0][1])

b =list()

for i in range(len(c)):
    if(int(c.most_common()[0][1]) == int(c.most_common()[i][1])):
        b.append(c.most_common()[i][0])

b.sort()

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=[]
for i in range(n):
    a.append(input())
z= set(a)
c=list(z)
l=len(c)
b=[0]*l
for i in range(n):
    if(a[i] in c):
        inn=c.index(a[i])
        b[inn]=b[inn]+1
d=[]
indices = [i for i, x in enumerate(b) if x == max(b)]
tt=0
for i in indices:
    d.append(c[i])
    tt=tt+1
d.sort()
for i in range(tt):
    print(d[i])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

d = {}
for i in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1
max_d_list = [kv[0] for kv in d.items() if kv[1] == max(d.values())]

ans = sorted(max_d_list)

for i in ans:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
L_W = []

for i in range(0,n):
    L_W.append(input())
L_nat = set(L_W)
L_nat = sorted(L_nat)
max = 0
ans = []
for i in range(0,len(L_nat)):
    tmp = L_W.count(L_nat[i])
    if max < tmp:
        max = tmp
        ans = []
        ans.append(L_nat[i])
    elif max == tmp:
        ans.append(L_nat[i])

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

Submission status: Time Limit Exceeded

Solution code:
import collections, sys

n = sys.stdin.readline()
s = []
for _ in range(0,int(n)):
  s.append(sys.stdin.readline().replace('\n',''))

if len(set(s)) == 1:
  print(s[0])
  sys.exit()  

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

l = []
l.append(c.most_common()[0][0])
for i in range(0,len(s)):
  if c.most_common()[i][1] == max:
    l.append(c.most_common()[i][0])
  else:
    break
ll = sorted(set(l))
for ls in ll:
  print(ls)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
str_lis = []
max_str_lis = []
max_num = 1
for i in range(N):
  A = str(input())
  str_lis.append(A)
  times = str_lis.count(A)
  if times > max_num:
    max_str_lis = []
    max_str_lis.append(A)
    max_num = times
  if times == max_num and not A in max_str_lis:
    max_str_lis.append(A)

a = []
for i in max_str_lis:
  b = []
  for j in range(len(i)):
    b.append(ord(i[j]))
  a.append(b)
  
new_a = sorted(a)
for i in range(len(new_a)):
  for j in range(len(new_a[i])):
    new_a[i][j] = chr(new_a[i][j])
    
for i in new_a:
  print("".join(i))

Submission status: Time Limit Exceeded

Solution code:
import collections

N = int(input())
A = [input() for i in range(N)]
def count_counter(iterable):
    counter = collections.Counter(iterable)
    return dict(counter)
dict1 = count_counter(A)
max_k_list = sorted([kv[0] for kv in dict1.items() if kv[1] == max(dict1.values())])
for i in max_k_list:
  print(i)

Submission status: Time Limit Exceeded

Solution code:
import collections


N = int(input())

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

result = collections.Counter(S)

result_max = sorted([i for i in result.keys() if result[i] == max(result.values())])

for r in result_max:
    print(r)

Submission status: Time Limit Exceeded

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

res_list = []
max_str = 0  

for st in set(s):
  temp_str = s.count(st)
  if temp_str > max_str:
    res_list = []
    res_list.append(st)
    max_str = temp_str
  elif temp_str == max_str:
    res_list.append(st)

res_list.sort()
for res in res_list:
  print(res)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
all_str = []
all_str = [input() for i in range(N)]
import collections

count = max(collections.Counter(all_str).values())

max_all_str = []
for hikaku in sorted(set(all_str)):
  if all_str.count(hikaku) == count:
    print(hikaku)

Submission status: Time Limit Exceeded

Solution code:
#!usr/bin/env python3


import sys


def I(): return int(sys.stdin.readline())


def solve():
    n = I()
    sli = [input() for i in range(n)]
    setli = set(sli)
    rank = {}
    for i in setli:
        j = sli.count(i)
        rank[i] = j
    for i in sorted([k for k, v in rank.items() if v == max(rank.values())]):
        print(i)


# Solve
if __name__ == "__main__":
    solve()

Submission status: Time Limit Exceeded

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

box = []
S_box = []
last = []
sss = set(S)
an = []

for k in sss:
    S_box.append(k)

for i in range(0, len(sss)):
    box.append(S.count(S_box[i]))

num = max(box)

for a in range(0, len(box)):
    if num == box[a]:
        last.append(a)

for iii in last:
    an.append(S_box[iii])
an = sorted(an)
for aaa in an:
    print(aaa)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
D = {}
for _ in range(N):
    x = input()
    if D.get(x):
        D[x] += 1
    else:
        D[x] = 1
max_k_list = [kv[0] for kv in D.items() if kv[1] == max(D.values())]
print("\n".join(sorted(max_k_list)))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
import collections
mylist = []
A = []
B = []
for i in range(N):
  val = input("")
  if val:
    mylist.append(val)
if len(mylist) != len(set(mylist)):
    c = collections.Counter(mylist)
    for i in range(len(set(mylist))):
        if c.most_common()[0][1] == c.most_common()[i][1]:
            A.append(i)
    for i in range(len(A)):
        B.append(c.most_common()[i][0])
    C = sorted(B)
    for item in C:
        print(item)
else:
    D = sorted(mylist)
    for item in D:
            print(item)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
lisa=[]
ans=1
add=[]
coua=0
for i in range(n):
    a=input()
    lisa.append(a)
    coua=lisa.count(a)
    if ans<coua:
        add=[]
    if ans<=coua:
        ans=coua
        add.append(a)
add=sorted(set(add))
for i in range(len(add)):
    print(add[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)

num = max(c.values())
l = len(c)

ans=[]

for i in range(l):
    if c.most_common()[i][1] == num:
        ans.append(c.most_common()[i][0])
ans.sort()
for x in ans:
    print(x)

Submission status: Time Limit Exceeded

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

S_set = set(S)
Cnt = []
max = 0
for i in S_set:
    Cnt.append([i, S.count(i)])
    if max < S.count(i):
        max = S.count(i)

Cnt_l = sorted(Cnt, reverse = False , key=lambda x: x[0])
#print(Cnt_l)
#print(max)
for i in range(len(Cnt_l)):
    if Cnt_l[i][1] == max:
        print(Cnt_l[i][0])

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
s=[input() for _ in range(n)]
s.sort()
s.append("")
a=[]
count=[]
buf=1
count_max=1
for i in range(n):
    if s[i]==s[i+1]:
        buf+=1
    else:
        if buf>=count_max:
            a.append(s[i])
            count.append(buf)
            count_max=buf
        buf=1
for i in range(len(a)):
    if count[i]==max(count):
        print(a[i])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = []
for _ in range(N):
    S.append(str(input()))
S_ = [x for x in set(S) if S.count(x) > 1] #重複している要素を取り出す
if len(S_)==0:
    S.sort()
    for i in range(len(S)):
        print(S[i])
else:
    chofuku_number=[S.count(x) for x in S_]
    max_chofuku = max(chofuku_number)
    answer=[S_[i] for i in range(len(chofuku_number)) if chofuku_number[i]==max_chofuku]
    answer.sort()
    for i in range(len(answer)):
        print(answer[i])

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
s=[input() for i in range(n)]
s.sort()
cnt=1
ans=0
pri=[]
for i in range(n-1):
    if s[i]==s[i+1]:
        cnt+=1
    else:
        ans=max(cnt,ans)
        cnt=1
ans=max(cnt,ans)
for i in range(n):
    if ans==s.count(s[i]):
        pri.append(s[i])
t=set(pri)
p=list(t)
p.sort()
for i in range(len(p)):
    print(p[i])

Submission status: Time Limit Exceeded

Solution code:
#C - Poll
import collections
N = int(input())
S = [str(input()) for i in range(N)]
#print(S)

A = collections.Counter(S)
maxS = [kv[0] for kv in A.items() if kv[1] == max(A.values())]
maxS = sorted(maxS)
for l in range(len(maxS)):
    print(maxS[l])

Submission status: Time Limit Exceeded

Solution code:
import collections
n = int(input())
s = [input() for i in range(n)]
p = collections.Counter(s)
keys = []
#keys = [i for i,m in p.items() if m == p.values()]
for i,m in p.items():
  if(m == max(p.values())):
    keys.append(i)
keys=sorted(keys)
for i in range(len(keys)):
  print(keys[i])

Submission status: Time Limit Exceeded

Solution code:
import bisect

n = int(input())
sl = []
for i in range(n):
    s = input()
    index = bisect.bisect_left(sl, s)  # 2 最も左(前)の挿入箇所が返ってきている
    sl.insert(index, s)

# print(sl)
c = 0
anss = []
for i, t in enumerate(sl):
    if i == 0:
        c += 1
        target = t
        continue

    if t == target:
        c += 1
    else:
        anss.append([target, c])
        target = t
        c = 1
anss.append([t, c])
anss.sort(key=lambda x: x[1], reverse=True)
target = anss[0][1]
for a in anss:
    if a[1] == target:
        print(a[0])

Submission status: Time Limit Exceeded

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

for i in S:
    if S.count(i) > max:
        max = S.count(i)
        List = [i]
    elif S.count(i) == max:
        List.append(i)

set = set(List)
List2 = list(set)
List2.sort()

for i in List2:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
# from operator import itemgetter

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

# for i in range(n):
#     s.append(input())

buf = []
cnt = []

for i in range(n):
    buf2 = input()
    if buf2 not in buf:
        buf.append(buf2)
        cnt.append(0)
    cnt[buf.index(buf2)] += 1

# for i in s:
#     if i not in buf:
#         buf.append(i)
#         cnt.append(0)
#     cnt[buf.index(i)] += 1

# ans = np.where(cnt == np.max(cnt))[0].tolist()
aaa = np.max(cnt)
ans2 = np.array(buf)[np.array(cnt) == aaa]

# ans = [i for i, x in enumerate(cnt) if x == max(cnt)]

# ans2 = [buf[i] for i in range(len(buf)) if i in ans]


ans3 = np.sort(ans2)

for i in ans3:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8

num = int(input())
line = []
result = []
point =False

for i in range(num):
    line.append(input())

newline = sorted(line)

for i in range(num):
    for j in range(len(result)):
        if result[j][0] == newline[i]:
            result[j][1] += 1
            point = True
    if point == False:
        result.append([newline[i],1])
    else:
        point = False

count = 0
for i in range(len(result)):
    if count < result[i][1]:
        count = result[i][1]

for i in range(len(result)):
    if count == result[i][1]:
        print(result[i][0])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import collections

N = int(input())
dic = {}
for i in range(N):
  s = str(input())
  if dic.get(s):
    dic[s] += 1
  else:
    dic[s] = 1

max_k_list = [kv[0] for kv in dic.items() if kv[1] == max(dic.values())]
max_k_list.sort()
s_n = '\n'.join(max_k_list)
print(s_n)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = sorted([str(input()) for _ in range(n)])

S = set(s)
c_m = int(0)
l = []
ans = []
ans1 = []

for i in range(len(S)):
    a = S.pop()
    c_i = int(s.count(a))
    if c_i >= c_m:
        c_m = c_i
        l.append([c_m, a])
        continue

l.sort(reverse = True)
for i in range(len(l)):
    if l[0][0] == l[i][0]:
        ans.append(l[i][1])
        ans1 = sorted(ans)

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

S = ["0"]*N

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

cnt_ar = sorted(list(set(S)))

length = len(cnt_ar)

ar = [0]*length

for i in range(length):
  ar[i] = S.count(cnt_ar[i])

max_num = max(ar)

for i in range(length):
  if ar[i] == max_num:
    print(cnt_ar[i])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
a = [input() for i in range(N)]
a.sort()
b = [0] * N
flag = 1
cc = 0
for i in range(N):
    c = a.count(a[cc])
    b[cc] = c
    if flag == 1:
        max = c
        flag = 0
    if c > max:
        max = c
    cc = cc + c
    if cc >= N:
        break
for i in range(N):
    if b[i] == max:
        print(a[i])

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N=int(input())
List=[input() for i in range(N)]
SetList=list(set(List))
nc=[]
for i in range(len(SetList)):
    n=List.count(SetList[i])
    nc.append(n)

indexmax=np.where(np.array(nc) == np.array(nc).max())[0]
MaxList=[]
for i in range(len(indexmax)):
    index=indexmax[i]
    MaxList.append(SetList[index])

MaxListS=sorted(MaxList)
for i in MaxListS:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
moji = []
for i in range(n):
    moji.append(input())
moji2=list(set(moji))
ma=0
moji3=[]
count=[]
ch=True
for i in moji2:
    a=moji.count(i)
    if(a>=ma):
        ma=a
        count.append(a)
        moji3.append(i)
#print(count,moji3)
if(count.count(max(count))==1):
    print(moji3[count.index(max(count))])
    exit()
selected=[]
for i in range(len(count)):
    if(ma==count[i]):
        selected.append(moji3[i])
selected.sort()
for i in selected:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
num = int(input())

words = []
for _ in range(num):
    words.append(input())

words = tuple(words)

d = {}
for word in words:
    if word in d:
        d[word] += 1
    else:
        d[word] =1

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

print('\n'.join(max_k_list))

Submission status: Time Limit Exceeded

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

s.sort()
tmp = '0'
sl = []
cnt = 0
mcnt = 0
ans = []

for i in range(n):
    cnt = s.count(s[i])
    s[i].append(int(cnt))
    if mcnt < cnt:
        mcnt = cnt

s.sort(key=lambda x: x[1])

for i in range(n-1,-1,-1):
    if s[i][1] == mcnt:
        ans.append(s[i][0])
    else:
        break

ans.reverse()

for i in ans:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
from operator import itemgetter

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

for i in range(n):
    s = input()
    flg = 0
    for j in sn:
        if(j[0] == s):
            j[1] += 1
            flg = 1
            break
    if(flg == 0):
        sn.append([s,1])
    else:
        continue
        
sn.sort(key=itemgetter(1))
sn.reverse()
#print(sn)

cnt = sn[0][1]
for i in sn:
    if(int(i[1]) == cnt):
        print(i[0])
        continue
    else:
        break

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
N = int(input())
list = [input() for _ in range(0,N)]
counted = Counter(list)
res=[]
for letter,count in counted.most_common() :
    if count < counted.most_common()[0][1]:
        break
    else:
        res.append(letter)

[print(i) for i in sorted(res)]

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter

H=int(input())
input_list=[input() for _ in range(H)]
ans_list=[]
list_set=set(input_list)
max_appeard=Counter(input_list).most_common(1)[0][1]
for item in list_set:
    if Counter(input_list)[item] == max_appeard:
        ans_list.append(item)
ans_list.sort()
for item in ans_list:
  print (item)

Submission status: Time Limit Exceeded

Solution code:
N=input()
list=[]
a=[]
b=[]
c=[]
s=[]
t=0
for i in range(int(N)):
    list.append(input())
    for l in range(len(a)):
        if(a[l]==list[i]):
            b[l]+=1
            t=1
            break
    if t==0:
        a.append(list[i])
        b.append(1)
    else:
        t=0
m=max(b)
for i in range(len(a)):
    if b[i]==m:
        c.append(a[i])
s=sorted(c)
for i in range(len(s)):
    print(s[i])

Submission status: Time Limit Exceeded

Solution code:
def main():
    N = int(input())
    counts = {}
    for i in range(N):
        string = input()
        if string in counts:
            counts[string] += 1
        else:
            counts[string] = 1
    max_k_list = [kv[0] for kv in counts.items() if kv[1] == max(counts.values())]
    max_k_list.sort()
    for j in max_k_list:
        print(j)
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

list,count_list = [],[]
for i in range(0,n):
  Si = str(input())
  if Si in list :
    count_list[list.index(Si)] += 1
  else :
    list.append(Si)
    count_list.append(0)
    
max_index = [i for i, x in enumerate(count_list) if x == max(count_list)]
ans = []
for i in max_index :
  ans.append([list[i]])

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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8


def main():
    n = int(input())
    my_polls_list = []
    for _ in range(n):
        my_polls_list.append(input())

    my_polls_set = set(my_polls_list)
    my_polls_dict = {}
    for poll in my_polls_set:
        if poll not in my_polls_dict:
            my_polls_dict[poll] = my_polls_list.count(poll)
        else:
            my_polls_dict[poll] += my_polls_list.count(poll)
    max_poll = max(my_polls_dict.values())

    for key, value in my_polls_dict.items():
        if value != max_poll:
            my_polls_set.remove(key)

    my_polls_set = sorted(my_polls_set)
    for poll in my_polls_set:
        print(poll)

    return 0


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

S = ["0"]*N

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

cnt_ar = list(set(S))
cnt_ar.sort()

length = len(cnt_ar)

ar = [0]*length

for i in range(length):
  ar[i] = S.count(cnt_ar[i])

max_num = max(ar)

for i in range(length):
  if ar[i] == max_num:
    print(cnt_ar[i])

Submission status: Time Limit Exceeded

Solution code:
def my_index(l, x, default=False):
    return l.index(x) if x in l else default
      
n=int(input())
lk = [0]*n
k=0
ls = []
for i in range(n):
  s = str(input())
  dup = my_index(ls, s, -1)
  if dup == -1:
    ls.append(s)
    lk[k] += 1    
    k += 1
  else:
    lk[dup] += 1

lk_max = [i for i, x in enumerate(lk) if x == max(lk)]

ls_max=[]
for i in range(len(lk_max)):
  ls_max.append(ls[lk_max[i]])

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

Submission status: Time Limit Exceeded

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

li = []
ans = []
for i in range(n):
    if s[i] in ans:
        li[ans.index(s[i])][1] += 1
    else:
        li.append([s[i], 1])
        ans.append(s[i])
            
                
li.sort(key = lambda x: x[0])
li.sort(key = lambda x: x[1] , reverse = True)

a = li[0][1]
for i in range(len(li)):
    if a == li[i][1]:
        print(li[i][0])
    else:
        break

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
tmp = []
for _ in range(N):
    tmp.append(input())
tmp.sort()

w = []
c = []

# print(tmp)
m = 0
for i in tmp:
    if i not in w:
        w.append(i)
        c.append(tmp.count(i))
        if m < tmp.count(i):
            m = tmp.count(i)

# print(w)
# print(c)

for i in c:
    if m == i:
        print(w[c.index(i)])
        c[c.index(i)] = -1

Submission status: Time Limit Exceeded

Solution code:


N=int(input())

S_list = []
S_count = []
max = 1
temp_list = []
#for i in range(N):
#    s = input()
#    temp_list.append(s)

for i in range(N):
    s = input()
    #temp_list = []
    #temp_list.append(s)
    try:
        index = S_list.index(s)
        S_count[index] += 1
        if max < S_count[index]:
            max = S_count[index]
    except ValueError:
        S_list.append(s)
        S_count.append(1)
    
     
#print(S_list)
#print(S_count)
#print(max)
S_max = []
for j in range(len(S_list)):
    if S_count[j] == max:
        S_max.append(S_list[j])

S_max.sort()
for k in range(len(S_max)):
    print(S_max[k])

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip() for _ in range(n)]

s = []
cnt = [0] * n
_max = 0
for tmp in data:
  if tmp not in s:
    s.append(tmp)
  else:
    cnt[s.index(tmp)] += 1
    if _max < cnt[s.index(tmp)]:
      _max = cnt[s.index(tmp)]
    
results = []
for i in range(len(s)):
  if cnt[i] == _max:
    results.append(s[i])

results.sort()
for result in results:
  print(result)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

dic = {}

for i in range(N):
    S = input()
    
    if (S in dic) == False:
        dic[S] = 1
    else:
        dic[S] += 1
        
keys = []
for key , value in dic.items():
    if value == max(dic.values()):
        keys.append(key)
k = keys.sort()
for i in keys:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
import collections

n = int(input())
a = []
max_list = []
max_i = 1

for i in range(n):
    a.append(str(input()))

c = collections.Counter(a)
max_i = c.most_common()[0][1]

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

max_list.sort()

for i in max_list:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict
N = int(input())
mm = defaultdict(int)

for i in range(N):
    key = input()
    mm[key] += 1

max_mms = [kv for kv in mm.items() if kv[1] == max(mm.values()) ]
max_mms.sort()

for i, k in max_mms:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = [''] * N
for i in range(N) :
    S[i] = input()
S_set = sorted(list(set(S)))
#print(S_set)
cnt = [0 for i in range(len(S_set))]
word_buf = []
mmax = -1

for i in range(len(S_set)) :
    cnt[i] = S.count(S_set[i])

    if i == 0 :
        word_buf.append(S_set[i])
    else :
        if cnt[i] < mmax :
            pass
        elif cnt[i] == mmax :
            word_buf.append(S_set[i])
        elif cnt[i] > mmax :
            word_buf.clear()
            word_buf.append(S_set[i])
    mmax = max(mmax,cnt[i]) # 現時点での最大値

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

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter

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

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

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

s_max.sort()
for a in s_max:
  print(a)

Submission status: Time Limit Exceeded

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

S_name = set(S)
S_name = list(S_name)
count = [0 for i in range(len(S_name))]
for i in S:
    temp = S_name.index(i)
    count[temp] += 1

ans_count = [i for i, v in enumerate(count) if v == max(count)]
ans = []
for i in ans_count:
    ans.append(S_name[i])

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

Submission status: Time Limit Exceeded

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

B=[int(li.count(li[i])) for i in range(N)]

M=max(B)
C=[]
for i in range(N):
    if li.count(li[i])==M and not li[i] in C:
        C.append(li[i])
    else:
        pass

C.sort()

L=len(C)

for k in range(L):
    print(C[k])