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:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

def LI(): return list(map(int, stdin.readline().split()))
def LS(): return list(stdin.readline())

from collections import Counter
n = int(input())
s = Counter([input() for i in range(n)])
ans = [k for k,v in s.items() if v==max(s.values())]
print('\n'.join(sorted(ans)))

Submission status: Time Limit Exceeded

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

def LI(): return list(map(int, stdin.readline().split()))
def LS(): return list(stdin.readline())

n = int(input())
d = {}
for i in range(n):
    s = input()
    if s not in d.keys():
        d[s] = 0
    d[s] += 1
# print(d)
# print(max(d.values()))
ans = [k for k,v in d.items() if v==max(d.values())]
print('\n'.join(sorted(ans)))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

import numpy as np
a = np.zeros(N)

s = []
n = 0
for i in range(N):
    x = input()
    if not x in s:
        s.append(x)
        n += 1
    else:
        i = s.index(x)
        a[i] += 1

a_max = 0
for i in range(n):
    if a[i] > a_max:
        a_max = a[i]

b = []
for i in range(n):
    if a[i] == a_max:
        b.append(i)
c = []
for i in b:
    c.append(s[i])

c.sort()

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

Submission status: Time Limit Exceeded

Solution code:
import copy

count = int(input())

ls = []

for i in range(count):
    ls.append(input())

buff = copy.copy(ls)
ls2 = set(buff)

max = 0
ans = []

for s in ls2:
    if ls.count(s) >= max:
        if ls.count(s) > max:
            ans.clear()

        ans.append(s)
        max = ls.count(s)

print('\n'.join(sorted(ans)))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
words = {}
for i in range(N):
  name = input()
  if name not in words:
    words[name] = 1
  elif name in words:
    words[name] += 1
    
res_name = []
for i in words.keys():
  if words[i] == max(words.values()):
    res_name.append(i)
res_name = sorted(res_name)
for i in res_name:
  print(i)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
names = list()
for i in range(N):
  names.append(input())
res_dict = dict()
for i in names:
  count = names.count(i)
  res_dict[i] = count
res_name = []
for i in res_dict.keys():
  if res_dict[i] == max(res_dict.values()):
    res_name.append(i)
res_name = sorted(res_name)
for i in res_name:
  print(i)

Submission status: Time Limit Exceeded

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
from collections import Counter
def resolve():
    n=int(input())
    l=[input() for i in range(n)]
    l.sort()
    setl = list(set(l))
    setl.sort()
    cntl=[]
    prev=l[0]
    cnt=0
    for j in range(len(l)):
        if l[j]!=prev:
            cntl.append(cnt)
            prev=l[j]
            cnt=1
            if j==n-1:
                cntl.append(cnt)
        else:
            cnt+=1
            if j==n-1:
                cntl.append(cnt)
    for i in range(len(setl)):
        if cntl[i]==max(cntl):
            print(setl[i])
resolve()

Submission status: Time Limit Exceeded

Solution code:
import collections
N = int(input())
str_list = []
ap_list = []
for i in range(N):
    str_list.append(input())


c = collections.Counter(str_list)


i = 0
#print(len(c))
while c.most_common()[0][1] == c.most_common()[i][1]:
    ap_list.append(c.most_common()[i][0])
    if i < len(c)-1:
        i+=1
    else:
        break

#print(ap_list)

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ls = [input() for o in range(n)]
a = [0 for j in range(len(set(ls)))]
ls.sort()
u = list(set(ls))
u.sort()
p = 0
for i in range(n):
    if i ==0:
        a[i] += 1
    else:
        if ls[i] == ls[i-1]:
            a[p] += 1
        else:
            p +=1
            a[p] +=1
t = max(a)
r = 0
for l in range(len(a)):
    if a[l] != t:
        u.remove(u[r])
    else:
        r +=1
[print(e) for e in u]

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
s1=[input() for x in range(n)]
s2=list(set(s1))
ans_s=[]
max_num=0
for num in s2:
    if max_num < s1.count(num):
        max_num=s1.count(num)
        ans_s.clear()
        ans_s.append(num)
    elif max_num == s1.count(num):
        ans_s.append(num)
ans_s.sort()
[print(x) for x in ans_s]

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
dict1 = {}
for _ in range(N):
  s = input()
  if s in dict1:
    dict1[s] += 1
  else:
    dict1[s] = 1
list1 = [d[0] for d in dict1.items() if d[1]==max(dict1.values())]
list1.sort()
for s in list1:
  print(s)

Submission status: Time Limit Exceeded

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

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

num = len(words)
counter = [0] * num
for i in range(num):
    counter[i] = S.count(words[i])

max = max(counter)
for i in range(num):
    if counter[i] == max:
        print(words[i])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
d = dict()
s = [input() for i in range(n)]
l = []
for i in set(s):
    d[i] = 0
for i in s:
    d[i] += 1
l = [k for k, v in d.items() if v == max(d.values())]
l.sort()
print(*l, sep="\n")

Submission status: Time Limit Exceeded

Solution code:
import collections
n = int(input())
s = [input() for _ in range(n)]
wordlist = collections.Counter(s)
values, counts = zip(*wordlist.most_common())
values = list(values)
counts = list(counts)
for cnt in range(len(counts)):
    if counts[cnt] != max(counts):
        cnt -=1
        break
values = values[:cnt+1]
values.sort()
print("\n".join(values))

Submission status: Time Limit Exceeded

Solution code:
def solve():
    n=int(input())
    count=0
    scount=0
    listcount=0
    anslist=[]
    s=[]
    for i in range(n):
        a=input()
        s.append(a)
    s_count=s.count
    s.sort()
    for i in range(n):
        if listcount==n:
            break
        scount=s_count(s[listcount])
        if scount>count:
            count=scount
            anslist.clear()
            anslist.append(s[listcount])
        elif scount==count:
            anslist.append(s[listcount])
        listcount+=scount
    anslist.sort()
    for i in range(len(anslist)):
        print(anslist[i])
solve()

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
count=0
scount=0
listcount=0
anslist=[]
s=[]
for i in range(n):
    a=input()
    s.append(a)
s_count=s.count
s.sort()
for i in range(n):
    if listcount==n:
        break
    scount=s_count(s[listcount])
    if scount>count:
        count=scount
        anslist.clear()
        anslist.append(s[listcount])
    elif scount==count:
        anslist.append(s[listcount])
    listcount+=scount
anslist.sort()
for i in range(len(anslist)):
    print(anslist[i])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
strings = []
nums = []
for i in range(n):
    string = input()
    if string not in strings:
        strings.append(string)
        nums.append(1)
    else:
        nums[strings.index(string)] += 1

l = []
Mx = max(nums)
for i in range(len(strings)):
    if nums[i] == Mx:
        l.append(strings[i])
l.sort()

for i in l:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
strings = []
nums = []
for i in range(n):
    string = input()
    if string not in strings:
        strings.append(string)
        nums.append(1)
    else:
        nums[strings.index(string)] += 1

l = []
Mx = max(nums)
for i in range(len(strings)):
    if nums[i] == Mx:
        l.append(strings[i])
l.sort()

for i in l:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = list(input() for i in range(N))  #スペース抜きの単語を複数行

import collections
A = collections.Counter(S)

C = [i for i in A if A[i] == max(A.values())]
C = sorted(C)
 
for i in C:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
S= [input() for i in range(N)]
A=list(set(S))
M=len(A)
c=[0]*M

for i in range(M):
  #print(A[i],S.count(A[i]))
  c[i]=S.count(A[i])
#print(A)
#print(c)
max=0
for i in range(M):
  if max<=c[i]:
    max=c[i]
maxS=[]
for i in range(M):
  if max==c[i]:
    maxS.append(A[i])
print(*sorted(maxS),sep='\n')

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = list(input() for i in range(N))  #スペース抜きの単語を複数行

import collections
A = collections.Counter(S)

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

for i in max_k_list:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

words = {}

for i in range(n):
    key = input()
    if key not in words:
        words[key] = 0
    words[key] += 1

l = []

for i,j in words.items():
    if max(words.values()) == j:
        l.append(i)
l.sort()
for i in l:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

words = {}

for i in range(n):
    key = input()
    if key not in words:
        words[key] = 0
    words[key] += 1

swords = sorted(words.items())

for i in swords:
    if max(words.values()) == i[1]:
        print(i[0])

Submission status: Time Limit Exceeded

Solution code:
N =int(input())
List = []
Dictionary = []
for i in range(N):
    In = input()
    List.append(In)
    if In in Dictionary:
        continue
    else:
        Dictionary.append(In)
Max = 0
Answer = []
for j in range(len(Dictionary)):
    var = List.count(Dictionary[j])
    if var > Max:
        Max = var
        Answer = []
        Answer.append(Dictionary[j])
    elif var == Max:
        Answer.append(Dictionary[j])
Answer.sort()
for _ in range(len(Answer)):
    print(Answer[_])

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
s=[]
m={}
for i in range(n):
    st=input()
    if(st in s):m[st]+=1
    else:m[st]=1
    s.append(st)
mx=max(m.values())
ans=[]
for i in m:
    if(m[i]==mx):ans.append(i)
ans=sorted(ans)
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())
s=sorted(s)
ss=sorted(list(set(s)))
m=0
t=[]
for i in ss:
    tm=s.count(i)
    t.append(tm)
    m=max(m,tm)

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

Submission status: Time Limit Exceeded

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

set_list=list(set(S))

List=[]
List_const=[]
for i in set_list:
    List_const=[S.count(i),i]
    List.append(List_const) 
    
List.sort(reverse=True)

List_Ans=[List[0][1]]
for i in range(1,len(List)):
    if List[0][0]==List[i][0]:
        List_Ans.append(List[i][1])
    else:
        break
        
List_Ans.sort()

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

N=int(input())
moji_list = []
moji_count = []
for i in range(N):
  S=input()
  if not S in moji_list:
    moji_list.append(S)
    moji_count.append(1)
  else:
    moji_count[moji_list.index(S)] += 1

koho_moji = []
for i in range(len(moji_count)):
  if moji_count[i] == max(moji_count):
    koho_moji.append(moji_list[i])

#print(koho_moji)

jisho = "abcdefghijklmnopqrstuvwxyz"
suji_jisho = []
max_len = 0
for i in range(len(koho_moji)):
  max_len = max([max_len,len(koho_moji[i])])
#print(max_len)

for i in range(len(koho_moji)):
  k = 0
  for t in range(len(koho_moji[i])):
#    print(koho_moji[i][t], (jisho.index(koho_moji[i][t])+1) * (100**(max_len-t-1)) )
    k = k + (jisho.index(koho_moji[i][t])+1) * (100**(max_len-t-1))
  suji_jisho.append(k)

#print(suji_jisho)
suji_jisho = np.array(suji_jisho)
ind = list(np.argsort(suji_jisho))
for i in range(len(koho_moji)):
  print(koho_moji[ind[i]])

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

N=int(input())
moji_list = []
moji_count = []
for i in range(N):
  S=input()
  if not S in moji_list:
    moji_list.append(S)
    moji_count.append(1)
  else:
    moji_count[moji_list.index(S)] += 1

koho_moji = []
for i in range(len(moji_count)):
  if moji_count[i] == max(moji_count):
    koho_moji.append(moji_list[i])

#print(koho_moji)

jisho = "abcdefghijklmnopqrstuvwxyz"
suji_jisho = []
max_len = 0
for i in range(len(koho_moji)):
  max_len = max([max_len,len(koho_moji[i])])
#print(max_len)

for i in range(len(koho_moji)):
  k = 0
  for t in range(len(koho_moji[i])):
#    print(koho_moji[i][t], (jisho.index(koho_moji[i][t])+1) * (100**(max_len-t-1)) )
    k = k + (jisho.index(koho_moji[i][t])+1) * (100**(max_len-t-1))
  suji_jisho.append(k)

#print(suji_jisho)

ind = list(np.argsort(suji_jisho))
for i in range(len(koho_moji)):
  print(koho_moji[ind[i]])

Submission status: Time Limit Exceeded

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

N = int(input())

Slist = {}
maxNum = 1
for i in range(N):
    S = input()
    if S in Slist.keys():
        Slist[S] += 1
        if Slist[S] > maxNum:
            maxNum = Slist[S]
    else:
        Slist[S] = 1

ans = []
for str in Slist.keys():
    if Slist[str] == maxNum:
        ans.append(str)

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

Slist = {}
maxNum = 1
for i in range(N):
    S = input()
    if S in Slist.keys():
        Slist[S] += 1
        if Slist[S] > maxNum:
            maxNum = Slist[S]
    else:
        Slist[S] = 1

ans = []
for str in Slist.keys():
    if Slist[str] == maxNum:
        ans.append(str)

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ls = [input() for o in range(n)]
a = [0 for j in range(len(set(ls)))]
ls.sort()
u = list(set(ls))
u.sort()
p = 0
for i in range(n):
    if i ==0:
        a[i] += 1
    else:
        if ls[i] == ls[i-1]:
            a[p] += 1
        else:
            p +=1
            a[p] +=1
t = max(a)
r = 0
for l in range(len(a)):
    if a[l] != t:
        u.remove(u[r])
    else:
        r +=1
for q in range(len(u)):
    print(u[q])

Submission status: Time Limit Exceeded

Solution code:
import collections
n = int(input())
ls = [input() for i in range(n)]
c = collections.Counter(ls)
a = c.most_common()[0][1]
t = len(set(ls))
b = [c.most_common()[p][0] for p in range(t) if c.most_common()[p][1] == a]
b.sort()
for k in range(len(b)):
    print(b[k])

Submission status: Time Limit Exceeded

Solution code:
import collections
n = int(input())
ls = [input() for i in range(n)]
c = collections.Counter(ls)
a = c.most_common()[0][1]
b = [c.most_common()[p][0] for p in range(len(c.most_common())) if c.most_common()[p][1] == a]
b.sort()
for k in range(len(b)):
    print(b[k])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for _ in range(N):
  inp = input()
  if inp not in dic:
    dic[inp] = 1
  else:
    dic[inp] = dic[inp] + 1

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

Submission status: Time Limit Exceeded

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

cnt = collections.Counter(S)
ans = sorted([k for k, v in cnt.items() if v == cnt.most_common()[0][1]])

for a in ans:
    print(a)

Submission status: Time Limit Exceeded

Solution code:
import collections
N = int(input())
S = []
for n in range(N):
    S.append(input())
    
cnt = collections.Counter(S)
ans = []
for k, v in cnt.items():
    if v == cnt.most_common()[0][1]:
        ans.append(k)
        
ans = sorted(ans)
for a in ans:
    print(a)

Submission status: Time Limit Exceeded

Solution code:
n =int(input())
s = [input() for i in range(n)]
z = list(set(s))
ans = []
x = 0
for i in z:
    sc = s.count(i)
    if sc > x:
        ans = [i]
        x = sc
    elif sc == x:
        ans.append(i)
for i in sorted(ans):
    print(i)

Submission status: Time Limit Exceeded

Solution code:
n =int(input())
s = [input() for i in range(n)]
z = list(set(s))
ans = []
x = 0
for i in z:
    sc = s.count(i)
    if sc > x:
        ans.clear()
        ans.append(i)
        x = sc
    elif sc == x:
        ans.append(i)
for i in sorted(ans):
    print(i)

Submission status: Time Limit Exceeded

Solution code:
n =int(input())
s = [input() for i in range(n)]
z = list(set(s))
ans = []
x = 0
for i in z:
    if s.count(i) > x:
        ans.clear()
        ans.append(i)
        x = s.count(i)
    elif s.count(i) == x:
        ans.append(i)
ans.sort()
print("\n".join(ans))

Submission status: Time Limit Exceeded

Solution code:
n =int(input())
s = [input() for i in range(n)]
z = list(set(s))
ans = []
x = 0
for i in z:
    if s.count(i) > x:
        ans.clear()
        ans.append(i)
        x = s.count(i)
    elif s.count(i) == x:
        ans.append(i)
for i in sorted(ans):
    print(i)

Submission status: Time Limit Exceeded

Solution code:
import sys
from collections import Counter
input = sys.stdin.readline
input = sys.stdin.buffer.readline

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))


def main():
    N = II()
    #S = input("")
    #S = [input().strip() for i in range(N)]
    S = [0]*N
    for i in range(N):
        si = input()
        si = si.decode('utf-8')
        S[i] = si.strip("\r\n")
    Sc = Counter(S)
    max = Sc.most_common()[0][1]
    i = 1
    ans = [Sc.most_common()[0][0]]
    l = len(set(S))

    while True:
        if l <= i:
            break
        Sci = Sc.most_common()[i]
        if Sci[1] == max:
            ans.append(Sci[0])
            i += 1
        else:
            break
    ans = list(sorted(ans))

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

if __name__ == "__main__":
	main()

Submission status: Time Limit Exceeded

Solution code:
import sys
from collections import Counter
input = sys.stdin.readline
input = sys.stdin.buffer.readline

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))


def main():
    N = II()
    #S = input("")
    #S = [input().strip() for i in range(N)]
    S = [0]*N
    for i in range(N):
        si = input()
        si = si.decode('utf-8')
        S[i] = si.strip("\r\n")
    Sc = Counter(S)
    max = Sc.most_common()[0][1]
    i = 1
    ans = [Sc.most_common()[0][0]]

    while True:
        if len(set(S))<= i:
            break
        if Sc.most_common()[i][1] == max:
            ans.append(Sc.most_common()[i][0])
            i += 1
        else:
            break
    ans = list(sorted(ans))
    
    for j in range(i):
        print(ans[j])

if __name__ == "__main__":
	main()

Submission status: Time Limit Exceeded

Solution code:
import collections
n = int(input())
s = [input() for _ in range(n)]
'''
s=[]
for i in range(0,n):
    s.append(input())
'''
#print(n,s)

c = collections.Counter(s)

d=[]
for i in range(0,len(set(s))):
    d.append(c.most_common()[i][1])
#print(d)

d_len=[]
for i in range(0,len(d)):
    if d[0]==d[i]:
        d_len.append(d[i])
#print(d_len)

e=[]
for i in range(0,len(set(s))):
    e.append(c.most_common()[i][0])

e_1=[]
for i in range(0,len(d_len)):
    e_1.append(e[i])
    
e_1=sorted(e_1)
#print(sorted(e_1))
print(*e_1, sep="\n")

Submission status: Time Limit Exceeded

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

c = collections.Counter(s)

d=[]
for i in range(0,len(set(s))):
    d.append(c.most_common()[i][1])
#print(d)

d_len=[]
for i in range(0,len(d)):
    if d[0]==d[i]:
        d_len.append(d[i])
#print(d_len)

e=[]
for i in range(0,len(set(s))):
    e.append(c.most_common()[i][0])

e_1=[]
for i in range(0,len(d_len)):
    e_1.append(e[i])
    
e_1=sorted(e_1)
#print(sorted(e_1))

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
d = {}
for i in range(n):
  s = input()
  d[s] = d.get(s, 0) + 1

maxKeys = [x[0] for x in d.items() if x[1] == max(d.values())]
so = sorted(maxKeys)
for e in so:
  print(e)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
s = []
c = []
d = []
for i in range(N):
    S = input()
    s.append(S)
for i in range(N):
    c.append(s.count(s[i]))
for i in range(N):
    if max(c) == c[i]:
        d.append(s[i])
d = set(d)
d = list(d)
d.sort()
for i in range(len(d)):
    print(list(d)[i])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = []
for i in range(N):
  S.append(input())
T = list(set(S))
number = [] 
for i in range(len(T)):
  number.append(S.count(T[i]))
maxindex = [i for i, x in enumerate(number) if x == max(number)]
Ans = []
for i in range(len(maxindex)):
  Ans.append(T[maxindex[i]])
Ans.sort()
for i in Ans:
  print(i)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = [input() for hoge in range(n)]
b = sorted(a)
c = set(a)
d = 0
ans = []
for poge in c:
  if d < b.count(poge):
    d = b.count(poge)
for raw in b:
  if d == b.count(raw):
    ans.append(raw)
answer = sorted(set(ans))
for q in answer:
  print(q)

Submission status: Time Limit Exceeded

Solution code:
import collections
N = int(input())
l = []
for _ in range(N):
    s = input()
    l.append(s)
c = collections.Counter(l)
i=0
j=0
ans=[]
while True:
    ans.append(c.most_common()[i][0])
    if i+1<len(c.most_common()):
        if c.most_common()[i+1][1] == c.most_common()[i][1]:
            i+=1
            continue
        else:
            break
    else:
        break
ans.sort()
for _ in range(len(ans)):
    print(ans[_])

Submission status: Time Limit Exceeded

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

j = {}
for i in s:
  if i not in j:
    j[i] = 1
  else:
    j[i] = j[i]+1
    
max_k_list = [kv[0] for kv in j.items() if kv[1] == max(j.values())]
for i in sorted(max_k_list):
  print(i)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
l = []
for i in range(N):
    l.append(str(input()))
res = []
max = 0
for s in l:
    num = l.count(s)
    if max > num:
        continue
    elif max == num:
        res.append(s)
    else:
        res = [s]
        max = num
res = list(set(res))
res.sort()
for r in res:
    print(r)

Submission status: Time Limit Exceeded

Solution code:
import sys
n = int(sys.stdin.readline())
li = []
for _ in range(n):
  li.append(sys.stdin.readline().strip())
max = 0
li2 = list(set(li))
li3 = []
for i in li2:
  cnt = li.count(i)
  if cnt > max:
    max = cnt
    li3 = [i]
  elif cnt == max:
    li3.append(i)
li3.sort()
print('\n'.join(li3))

Submission status: Time Limit Exceeded

Solution code:
def INPUT():return list(int(i) for i in input().split())
#=======================================================================
n=int(input())
D=[]
values=[]
for _ in range(n):
    s=input()
    if s in D:
        values[D.index(s)]+=1
    else:
        D.append(s)
        values.append(1)

ans=[]
m=max(values)
for i in range(len(values)):
    if values[i]==m:
        ans.append(D[i])
ans.sort()

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

Submission status: Time Limit Exceeded

Solution code:
INT_MAX=10**11+7
MOD=10**9+7
def INPUT():return list(int(i) for i in input().split())
def LIST_1D_ARRAY(n):return [0 for _ in range(n)]
def LIST_2D_ARRAY(m,n):return [[0 for _ in range(n)]for _ in range(m)]
#=======================================================================
import math as M
n=int(input())
D=[]
values=[]
for _ in range(n):
    s=input()
    if s in D:
        values[D.index(s)]+=1
    else:
        D.append(s)
        values.append(1)

#print(D)
ans=[]
m=max(values)
for i in range(len(values)):
    if values[i]==m:
        ans.append(D[i])
ans.sort()

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import collections

n = int(input())
s = [input() for i in range(n)]
t = collections.Counter(s)
x = [t.most_common()[i][0] for i in range(len(t.most_common())) if t.most_common()[i][1]==t.most_common()[0][1]]
x.sort()
for i in range(len(x)):
    print(x[i])

Submission status: Time Limit Exceeded

Solution code:
import collections

n = int(input())
s = [input() for i in range(n)]
t = collections.Counter(s)
d = 0
i = 0
x = []
y = []
for i in range(len(t.most_common())):
    y.append(t.most_common()[i][1])
c = y.count(y[0])
for i in range(c):
    x.append(t.most_common()[i][0])
x.sort()
for i in range(len(x)):
    print(x[i])

Submission status: Time Limit Exceeded

Solution code:
import sys
n = int(sys.stdin.readline())
li = []
for _ in range(n):
  li.append(sys.stdin.readline().strip())
li2 = list(set(li))
li2.sort(reverse = False)
cnt_box = []
for i in li2:
  cnt_box.append(li.count(i))
m = max(cnt_box)
i = 0
while i < len(cnt_box):
  if cnt_box[i] == m:
    print(li2[i])
  i += 1

Submission status: Time Limit Exceeded

Solution code:

from collections import Counter

n = int(input())
s = [input() for i in range(n)]
c = Counter(s)
a = c.most_common()[0][1]
ans = []
for i in range(len(c)):
  if c.most_common()[i][1] == a:
    ans.append(c.most_common()[i][0])

ans.sort()
print(*ans,sep="\n")

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
import bisect

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

c = collections.Counter(s)
values,counts = zip(*c.most_common())
max_w = counts[0]
l = len(counts)

ans_list = []
i = 0
while True:
    if i < l:
        if counts[i] == max_w:
            bisect.insort(ans_list,values[i])
    else:
        break
    i += 1 

for j in ans_list:
    print(j)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ma = max(sn)
kouho = []
for i in range(len(s)):
    if ma == sn[i]:
        kouho.append(s[i])

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = []
dic = {}
for i in range(N):
    a = str(input())
    if a not in S:
        S.append(a)
        dic[a] = 1
    else:
        dic[a] += 1
m = max(dic.values())
max_list = [kv[0] for kv in dic.items() if kv[1] == m]
max_list.sort()
for a in max_list:
    print(a)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = []
dic = {}
for i in range(N):
    a = str(input())
    if a not in S:
        S.append(a)
        dic[a] = 1
    if a in S:
        dic[a] += 1
max_list = [kv[0] for kv in dic.items() if kv[1] == max(dic.values())]
max_list.sort()
for a in max_list:
    print(a)

Submission status: Time Limit Exceeded

Solution code:
import collections
N = int(input())
S = [input() for i in range(N)]
s = collections.Counter(S) #出現回数をまとめた辞書型作成

dict = sorted(key for key,value in s.items() if value==max(s.values()))
for d in dict:
    print(d)

Submission status: Time Limit Exceeded

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

count = {}
for i in range(N):
    if not S[i] in count:
        count[S[i]] = 1
    else:
        count[S[i]] += 1
max_k_list = [kv[0] for kv in count.items() if kv[1] == max(count.values())]
max_k_list.sort()
for i in range(len(max_k_list)):
    print(max_k_list[i])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

line_list = []
line_num = []

for i in range(N):
    temp = input()
    if temp in line_list:
        line_num[line_list.index(temp)] += 1
    else:
        line_list.append(temp)
        line_num.append(1)
        
maxs = []

for i in range(len(line_list)):
    if line_num[i] == max(line_num):
        maxs.append(line_list[i])
        
maxs.sort()
for i in range(len(maxs)):
    print(maxs[i])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
slist = []
for i in range(n):
  s = str(input())
  slist.append(s)
sortedlist = sorted(slist)
strsortset = sorted(set(sortedlist), key=sortedlist.index)
setcountlist = []
for i in strsortset:
  setcountlist.append(slist.count(i))
maxcountlist = max(setcountlist)
counter = 0
maxindex = []
for m in setcountlist:
  if m == maxcountlist:
    maxindex.append(counter)
  counter += 1
for k in maxindex:
  print(strsortset[k])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
slist = []
for i in range(n):
  s = str(input())
  slist.append(s)
sortedlist = sorted(slist)
strsortset = sorted(set(sortedlist), key=sortedlist.index)
setcountlist = []
for i in strsortset:
  setcountlist.append(slist.count(i))
maxcountlist = max(setcountlist)
maxindex = [j for j, x in enumerate(setcountlist) if x == maxcountlist]
for k in maxindex:
  print(strsortset[k])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
slist = []
for i in range(n):
  s = str(input())
  slist.append(s)
sortedlist = sorted(slist)
strsortset = sorted(set(sortedlist), key=sortedlist.index)
setcountlist = []
for i in strsortset:
  setcountlist.append(slist.count(i))
maxindex = [j for j, x in enumerate(setcountlist) if x == max(setcountlist)]
for k in maxindex:
  print(strsortset[k])