Problem:


Score: 300 points

Problem Statement

We have N voting papers. The i-th vote (1 \leq i \leq N) has the string S_i written on it.

Print all strings that are written on the most number of votes, in lexicographical order.

Constraints

1 \leq N \leq 2 \times 10^5

S_i (1 \leq i \leq N) are strings consisting of lowercase English letters.

The length of S_i (1 \leq i \leq N) is between 1 and 10 (inclusive).

Input

Input is given from Standard Input in the following format:

N
S_1
:
S_N

Output

Print all strings in question in lexicographical order.

Sample Input 1

7
beat
vet
beet
bed
vet
bet
beet

Sample Output 1

beet
vet

beet and vet are written on two sheets each, while beat, bed, and bet are written on one vote each. Thus, we should print the strings beet and vet.

Sample Input 2

8
buffalo
buffalo
buffalo
buffalo
buffalo
buffalo
buffalo
buffalo

Sample Output 2

buffalo

Sample Input 3

7
bass
bass
kick
kick
bass
kick
kick

Sample Output 3

kick

Sample Input 4

4
ushi
tapu
nichia
kun

Sample Output 4

kun
nichia
tapu
ushi



Sample input:
7
beat
vet
beet
bed
vet
bet
beet


Sample output:
beet
vet

Submission status: Time Limit Exceeded

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

m = 0
for i in s:
    mae = len(s)
    s = [j for j in s if j != i]
    ato = len(s)
    num = mae - ato

    if num > m:
        ans = [i]
        m = num
    elif num == m:
        ans.append(i)


ans.sort()

#print(*ans,sep='\n')
print('\n'.join(map(str, ans)))
#for i in range(len(ans)):
#    print(ans[i])

Submission status: Time Limit Exceeded

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

m = 0
for i in s:
    mae = len(s)
    s = [j for j in s if j != i]
    ato = len(s)
    num = mae - ato

    if num > m:
        ans = [i]
        m = num
    elif num == m:
        ans.append(i)
    if ato - 1 == i:
        break

ans.sort()

print(*ans,sep='\n')
#print('\n'.join(map(str, ans)))
#for i in range(len(ans)):
#    print(ans[i])

Submission status: Time Limit Exceeded

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

u = set(s)
m = 0
ans = []

for i in u:
    mae = len(s)
    s = [j for j in s if j != i]
    ato = len(s)
    num = mae - ato

    if num > m:
        ans = [i]
        m = num
    elif num == m:
        ans.append(i)

ans.sort()

print('\n'.join(map(str, ans)))
#for i in range(len(ans)):
#    print(ans[i])

Submission status: Time Limit Exceeded

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

u = set(s)
m = 0
ans = []

for i in u:
    if s.count(i) > m:
        ans = [i]
        m = s.count(i)
    elif s.count(i) == m:
        ans.append(i)

ans.sort()

print('\n'.join(map(str, ans)))
#for i in range(len(ans)):
#    print(ans[i])

Submission status: Time Limit Exceeded

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

u = set(s)
m = 0
ans = []

for i in u:
    if s.count(i) > m:
        ans = [i]
        m = s.count(i)
    elif s.count(i) == m:
        ans.append(i)

ans.sort()

print('\n'.join(map(str, ans)))
#for i in range(len(ans)):
#    print(ans[i])

Submission status: Time Limit Exceeded

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

u = set(s)
m = 0
ans = []

for i in u:
    if s.count(i) > m:
        ans = [i]
        m = s.count(i)
    elif s.count(i) == m:
        ans.append(i)

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
S = [input() for _ in range(n)]
max = 0
for s in list(set(S)):
  if max < S.count(s):
    max_words = [s]
    max = S.count(s)
  elif max == S.count(s):
    max_words.append(s)
max_words.sort()
print("\n".join(max_words))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
S = [input() for _ in range(n)]
max = 0
for s in set(S):
  if max < S.count(s):
    max_words = [s]
    max = S.count(s)
  elif max == S.count(s):
    max_words.append(s)
max_words.sort()
print("\n".join(max_words))

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
L=[]
M=[]
c=0
for i in range (n):
    s=input()
    if s in L:
        M[L.index(s)]+=1
    else:
        L+=[s]
        M+=[1]
        c+=1
b=max(M)
F=[]
for i in range(c):
    if M[i]==b:
        F+=[L[i]]
F.sort()
for i in F:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter

N=int(input())
S=Counter([input() for _ in range(N)])
S_sorted = sorted(S.items(), key=lambda x:x[0])

for kv in S_sorted:
  if kv[1] == max(S.values()):
    print(kv[0])

Submission status: Time Limit Exceeded

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

count = []
for i in range(len(check_whether_in_S)):
    count.append(0)
for s in S:
    for i in range(len(check_whether_in_S)):
        if s == check_whether_in_S[i]:
            count[i] += 1
            break

# get max
max = -1
for c in count:
    if max < c:
        max = c

name_list = []
for i in range(len(check_whether_in_S)):
    if count[i] == max:
        name_list.append(check_whether_in_S[i])

print()
name_list = sorted(name_list)
for n in name_list:
    print(n)

Submission status: Time Limit Exceeded

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

count = []
for i in range(len(check_whether_in_S)):
    count.append(0)
for s in S:
    for i in range(len(check_whether_in_S)):
        if s == check_whether_in_S[i]:
            count[i] += 1

# get max
max = -1
for c in count:
    if max < c:
        max = c

name_list = []
for i in range(len(check_whether_in_S)):
    if count[i] == max:
        name_list.append(check_whether_in_S[i])

print()
name_list = sorted(name_list)
for n in name_list:
    print(n)

Submission status: Time Limit Exceeded

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

v = sorted(set(s))
num = []

for i in v:
    num.append(s.count(i))
d = dict(zip(v, num))
#d_sort = sorted(d.items(), key=lambda x: x[1], reverse=True)

ma = max(d.values())
for i in v:
    if d.get(i)==ma:
        print(i)

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter

N = int(input())

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

dic = Counter(S)

ans = [key for key, value in dic.items() if value == max(dic.values())]

for key in sorted(ans):
    print(key, end="")
    print("")

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
import fractions
import bisect
import queue
import heapq
import collections
import itertools
sys.setrecursionlimit(4100000)

MOD = int(1e9+7)
PI = 3.14159265358979323846264338327950288
INF = 1e18

'''
1行のint=====================================
N, K = map(int, input().split())
N, M = map(int, input().split())
A, B = map(int, input().split())

H, W = map(int, input().split())

L, R = map(int, input().split())

1行のstring=================================
S, T = input().split()

1行の整数配列================================
P = list(map(int,input().split()))

A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
D = list(map(int,input().split()))

L = list(map(int,input().split()))
R = list(map(int,input().split()))

T = list(map(int,input().split()))

改行あり整数==================================
X = []
Y = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    X.append(x1)
    Y.append(y1)

A = []
for i in range(N):
    a=int(input())
    A.append(a)

Pair = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    Pair.append((x1, y1))
    
2次元整数配列=====================================
A = []
for i in range(N):
    tmp = list(map(int,input().split()))
    A.append(tmp)


N行M列の初期化====================================
dp = [[VAL] * RETU for i in range(GYO)]

'''


N = int(input())
S = []
for i in range(N):
    s = input()
    S.append(s)
 
S.sort()
 
ans = [] # (name, times)
 
 
 
for i in range(N):
    renzoku = 0

    j = i
    while j < N:
        if S[i]==S[j]:
            renzoku+=1
            if j == N-1:
                ans.append((renzoku, S[i]))
                i= INF
                break
 
        else:
            ans.append((renzoku, S[i]))
            i=j
            break
        j+=1
 
 
ans.sort()
saidai = ans[-1][0]
 
for a in ans:
    if a[0] == saidai:
        print(a[1])

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
A=[input() for i in range(N)]
NA=[A.count(A[i]) for i in range(N)]
MAX=max(NA)
NIN=[i for i, v in enumerate(NA) if v == MAX]
LN=len(NIN)
NM=[A[NIN[i]] for i in range (LN)]
NM=sorted(list(set(NM)))
for i in NM:
    print(i)

Submission status: Time Limit Exceeded

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

C=collections.Counter(S)
max_C_list=sorted([i[0] for i in C.items() if i[1]==max(C.values())])

for i in max_C_list:
    print(i)

Submission status: Time Limit Exceeded

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

C=collections.Counter(S)
max_C_list=[i[0] for i in C.items() if i[1]==max(C.values())]
ans_list=sorted(max_C_list)
for i in ans_list:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict
n = int(input())
s = defaultdict(lambda: 0)

for i in range(n):
  s[input()] += 1

max_s = [kv[0] for kv in s.items() if kv[1] == max(s.values())]
if len(max_s) != 1:
    max_s.sort()

for i in max_s:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-

def calc_insert_index(array, target, arg_left, arg_right):
    left = arg_left
    right = arg_right
    while left != right:
        bound = (left + right) >> 1
        if target < array[bound]:
            right = bound
        else:
            left = bound + 1

    if target < array[left]:
        return left
    else:
        return left + 1

def abc155c(num, s):
    appearance_dict = {} # 文字列:出現回数
    array = [[] for _ in range(num)] # (出現回数-1)をindexにして文字列を配列で管理する
    max_cnt = 0

    for i in range(0, num):
        target = s[i]
        cnt = 0 # appearance count

        if target in appearance_dict :
            cnt = appearance_dict[target]
        appearance_dict[target] = cnt + 1

        # 出現回数最大のときのみ2分探索でsortしながら配列に追加する
        insert_idx = 0
        if array[cnt]:
            if cnt == max_cnt:
                insert_idx = calc_insert_index(array[cnt], target, 0, len(array[cnt])-1)
                array[cnt].insert(insert_idx, target)
        else:
            array[cnt].append(target)

        if cnt > max_cnt:
            max_cnt = cnt

    return array[max_cnt]

###
# main
if __name__ == '__main__' :
    # input
    num = int(input())
    s = []
    for i in range(0, num):
        s.append(input())
        
    ans = abc155c(num, s)

    # output
    for name in ans :
        print(name)
# else:
# do nothing

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-

def calc_insert_index(array, target, left, right):
    if left == right:
        if target < array[left]:
            return left
        else:
            return left + 1
    else:
        bound = (left + right) >> 1
        if target < array[bound]:
            return calc_insert_index(array, target, left, bound)
        else:
            return calc_insert_index(array, target, bound+1, right)


def abc155c(num, s):
    appearance_dict = {} # 文字列:出現回数
    array = [[] for _ in range(num)] # (出現回数-1)をindexにして文字列を配列で管理する
    max_cnt = 0

    for i in range(0, num):
        target = s[i]
        cnt = 0 # appearance count

        if target in appearance_dict :
            cnt = appearance_dict[target]
        appearance_dict[target] = cnt + 1

        # 出現回数最大のときのみ2分探索でsortしながら配列に追加する
        insert_idx = 0
        if array[cnt]:
            if cnt == max_cnt:
                insert_idx = calc_insert_index(array[cnt], target, 0, len(array[cnt])-1)
                array[cnt].insert(insert_idx, target)
        else:
            array[cnt].append(target)

        if cnt > max_cnt:
            max_cnt = cnt

    return array[max_cnt]

###
# main
if __name__ == '__main__' :
    # input
    num = int(input())
    s = []
    for i in range(0, num):
        s.append(input())
        
    ans = abc155c(num, s)

    # output
    for name in ans :
        print(name)
# else:
# do nothing

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-

def calc_insert_index(array, target, left, right):
    if left == right:
        if target < array[left]:
            return left
        else:
            return left + 1
    else:
        bound = (left + right) >> 1
        if target < array[bound]:
            return calc_insert_index(array, target, left, bound)
        else:
            return calc_insert_index(array, target, bound+1, right)


def abc155c(num, s):
    appearance_dict = {} # 文字列:出現回数
    array = [[] for _ in range(num)] # (出現回数-1)をindexにして文字列を配列で管理する
    max_cnt = 0

    for i in range(0, num):
        target = input() # s[i]
        cnt = 0 # appearance count

        if target in appearance_dict :
            cnt = appearance_dict[target]
        appearance_dict[target] = cnt + 1

        # 出現回数最大のときのみ2分探索でsortしながら配列に追加する
        insert_idx = 0
        if cnt == max_cnt:
            if array[cnt]:
                insert_idx = calc_insert_index(array[cnt], target, 0, len(array[cnt])-1)
        array[cnt].insert(insert_idx, target)

        if cnt > max_cnt:
            max_cnt = cnt

    return array[max_cnt]

###
# main
if __name__ == '__main__' :
    # input
    num = int(input())
    s = []
#    for i in range(0, num):
#        s.append(input())
        
    ans = abc155c(num, s)

    # output
    for name in ans :
        print(name)
# else:
# do nothing

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-

def calc_insert_index(array, target, left, right):
    if left == right:
        if target < array[left]:
            return left
        else:
            return left + 1
    else:
        bound = (left + right) >> 1
        if target < array[bound]:
            return calc_insert_index(array, target, left, bound)
        else:
            return calc_insert_index(array, target, bound+1, right)


def abc155c(num, s):
    appearance_dict = {} # 文字列:出現回数
    array = [[] for _ in range(num)] # (出現回数-1)をindexにして文字列を配列で管理する
    max_cnt = 0

    for i in range(0, num):
        target = s[i]
        cnt = 0 # appearance count

        if target in appearance_dict :
            cnt = appearance_dict[target]
#            array[cnt - 1].remove(target)
        appearance_dict[target] = cnt + 1

        # 出現回数最大のときのみ2分探索でsortしながら配列に追加する
        insert_idx = 0
        if cnt == max_cnt:
            if array[cnt]:
                insert_idx = calc_insert_index(array[cnt], target, 0, len(array[cnt])-1)
        array[cnt].insert(insert_idx, target)

        if cnt > max_cnt:
            max_cnt = cnt

    return array[max_cnt]

###
# main
if __name__ == '__main__' :
    # input
    num = int(input())
    s = []
    for i in range(0, num):
        s.append(input())
        
    ans = abc155c(num, s)

    # output
    for name in ans :
        print(name)
# else:
# do nothing

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-

def calc_insert_index(array, target, left, right):
    if left == right:
        if target < array[left]:
            return left
        else:
            return left + 1
    else:
        bound = (left + right) >> 1
        if target < array[bound]:
            return calc_insert_index(array, target, left, bound)
        else:
            return calc_insert_index(array, target, bound+1, right)


def abc155c(num, s):
    appearance_dict = {} # 文字列:出現回数
    array = [[] for _ in range(num)] # (出現回数-1)をindexにして文字列を配列で管理する
    max_cnt = 0

    for i in range(0, num):
        target = s[i]
        cnt = 0 # appearance count

        if target in appearance_dict :
            cnt = appearance_dict[target]
            array[cnt - 1].remove(target)
        appearance_dict[target] = cnt + 1

        # 出現回数最大のときのみ2分探索でsortしながら配列に追加する
        insert_idx = 0
        if cnt == max_cnt:
            if array[cnt]:
                insert_idx = calc_insert_index(array[cnt], target, 0, len(array[cnt])-1)
        array[cnt].insert(insert_idx, target)

        if cnt > max_cnt:
            max_cnt = cnt

    return array[max_cnt]

###
# main
if __name__ == '__main__' :
    # input
    num = int(input())
    s = []
    for i in range(0, num):
        s.append(input())
        
    ans = abc155c(num, s)

    # output
    for name in ans :
        print(name)
# else:
# do nothing

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-

def calc_insert_index(array, target, left, right):
    if left == right:
        if target < array[left]:
            return left
        else:
            return left + 1
    else:
        bound = (left + right) >> 1
        if target < array[bound]:
            return calc_insert_index(array, target, left, bound)
        else:
            return calc_insert_index(array, target, bound+1, right)


def abc155c(num, s):
    appearance_dict = {} # 文字列:出現回数
    array = [[] for _ in range(num)] # (出現回数-1)をindexにして文字列を配列で管理する
    max_cnt = 0

    for i in range(0, num):
        target = s[i]
        cnt = 0 # appearance count

        if target in appearance_dict :
            cnt = appearance_dict[target]
            array[cnt - 1].remove(target)
        appearance_dict[target] = cnt + 1

        # 出現回数最大のときのみ2分探索でsortしながら配列に追加する
        insert_idx = 0
        if cnt == max_cnt:
            if array[cnt]:
                insert_idx = calc_insert_index(array[cnt], target, 0, len(array[cnt])-1)
        array[cnt].insert(insert_idx, target)

        if cnt > max_cnt:
            max_cnt = cnt

    return array[max_cnt]

###
# main
if __name__ == '__main__' :
    # input
    num = int(input())
    s = [None for _ in range(num)]
    for i in range(0, num):
        s[i] = input()

    ans = abc155c(num, s)

    # output
    for name in ans :
        print(name)
# else:
# do nothing

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-

def calc_insert_index(array, target, left, right):
    if left == right:
        if target < array[left]:
            return left
        else:
            return left + 1
    else:
        bound = (left + right) >> 1
        if target < array[bound]:
            return calc_insert_index(array, target, left, bound)
        else:
            return calc_insert_index(array, target, bound+1, right)


def abc155c(num, s):
    appearance_dict = {} # 文字列:出現回数
    array = [[] for _ in range(num)] # (出現回数-1)をindexにして文字列を配列で管理する
    max_cnt = 0

    for i in range(0, num):
        target = s[i]
        cnt = 0 # appearance count

        if target in appearance_dict :
            cnt = appearance_dict[target]
            array[cnt - 1].remove(target)
        appearance_dict[target] = cnt + 1

        # 2分探索でsortしながら配列に追加する
        insert_idx = 0
        if array[cnt]:
            insert_idx = calc_insert_index(array[cnt], target, 0, len(array[cnt])-1)
        array[cnt].insert(insert_idx, target)

        if cnt > max_cnt:
            max_cnt = cnt

    return array[max_cnt]

###
# main
if __name__ == '__main__' :
    # input
    num = int(input())
    s = [None for _ in range(num)]
    for i in range(0, num):
        s[i] = input()

    ans = abc155c(num, s)

    # output
    for name in ans :
        print(name)
# else:
# do nothing

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
n=int(input())
s=[input() for _ in range(n)]
d=Counter(s)
keys = [k for k,v in d.items() if v==max(d.values())]
print("\n".join(sorted(keys)))

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
d=dict()
for _ in range(n):
    a=input()
    if a in d:
        d[a]+=1
    else:
        d[a]=1
keys = [k for k,v in d.items() if v==max(d.values())]
print("\n".join(sorted(keys)))

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
d=dict()
for _ in range(n):
    a=input()
    if a in d:
        d[a]+=1
    else:
        d[a]=1
keys = sorted([k for k,v in d.items() if v==max(d.values())])
print("\n".join(keys))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = ["" for i in range(N)]
dict1 = {"key":0}
names =[]
for i in range(N):
    S[i] = input()

for i in range(N):
    if not (S[i] in names):
        names.append(S[i])
        dict1.update({S[i]:1})
    else:
        dict1[S[i]] +=1
max = 0
for i in range(len(names)):
    if max < dict1[names[i]]:
        max = dict1[names[i]]

winners = []

for i in range(len(names)):
    if dict1[names[i]] == max:
        winners.append(names[i])

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = ["" for i in range(N)]
dict1 = {"key":0}
names =[]
for i in range(N):
    S[i] = input()

for i in range(N):
    if not (S[i] in names):
        names.append(S[i])
        dict1.update({S[i]:1})
    else:
        dict1[S[i]] +=1
max = 0
for name in names:
    if max < dict1[name]:
        max = dict1[name]

winners = []

for name in names:
    if dict1[name] == max:
        winners.append(name)

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

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter

N=int(input())
S=Counter([input() for _ in range(N)])
S_max=sorted([kv[0] for kv in S.items() if kv[1] == max(S.values())])
for i in S_max:
  print(i)

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter

N=int(input())
S=Counter([input() for _ in range(N)])
S_max=[kv[0] for kv in S.items() if kv[1] == max(S.values())]
S_max=sorted(S_max)
for i in S_max:
  print(i)

Submission status: Time Limit Exceeded

Solution code:
import sys
import collections
n = int(sys.stdin.readline())
a = []
for _ in range(n):
  a.append(sys.stdin.readline().strip())
c = collections.Counter(a)
print(*sorted([i[0] for i in c.items() if i[1] == max(c.values())]))

Submission status: Time Limit Exceeded

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

d = {}
for i in range(n):
  if s[i] in d.keys():
    d[s[i]] += 1
  else:
    d[s[i]] = 1

m = max(d.values())

ans = [k for k, v in d.items() if v == m]

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

Submission status: Time Limit Exceeded

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

d = {}
for i in range(n):
  if s[i] in d.keys():
    d[s[i]] += 1
  else:
    d[s[i]] = 1

m = max(d.values())

ans = [k for k, v in d.items() if v == m]
ans.sort()

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

Submission status: Time Limit Exceeded

Solution code:
import collections as col

n = int(input())
L_W = []
for i in range(0,n):
    L_W.append(input())
 
dic = col.Counter(L_W)
dic_values_max = max(list(dic.values()))

ans = []
for i in range(len(list(dic.items()))):
    if list(dic.items())[i][1] == dic_values_max:
        ans.append(list(dic.items())[i][0])

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

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter

N = int(input())
S = [input() for _ in range(N)]
ans = sorted([(k,v) for k,v in Counter(S).items() if max(Counter(S).values()) == v], key=lambda x: (-x[1], x[0]))
[print(k[0])for k in ans]

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
count_dict = {}
for _ in range(n):
    e = input()
    if e in count_dict.keys():
        count_dict[e] += 1
    else:
        count_dict[e] = 0

max_list = [e[0] for e in count_dict.items() if e[1] == max(count_dict.values())]
max_list.sort()
for i in max_list:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
input_array = []
for i in range(n):
    input_array.append(input())
counter = {}
max_count = 0
max_key_list = []
for i in set(input_array):
    if max_count < input_array.count(i):
        max_key_list = [i]
        max_count = input_array.count(i)
        continue
    elif input_array.count(i) == max_count:
        max_key_list.append(i)
max_key_list.sort()
for i in max_key_list:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
input_array = []
for i in range(n):
    input_array.append(input())
counter = {}
for i in set(input_array):
    counter[i] = input_array.count(i)
max_key_list = [kv[0] for kv in counter.items() if kv[1]==max(counter.values())]
max_key_list.sort()
for i in max_key_list:
    print(i)

Submission status: Time Limit Exceeded

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

d = {}
for i in range(n):
  if s[i] in d.keys():
    d[s[i]] += 1
  else:
    d[s[i]] = 1

m = max(d.values())

ans = [k for k, v in d.items() if v == m]
ans.sort()

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

d = {}
for i in range(n):
  s = input()
  if s in d.keys():
    d[s] += 1
  else:
    d[s] = 1

m = max(d.values())
ans = []

for k, v in d.items():
  if v == m:
    ans.append(k)
ans.sort()
print(*ans, sep = "\n")

Submission status: Time Limit Exceeded

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

d = {}
for i in range(n):
  if s[i] in d.keys():
    d[s[i]] += 1
  else:
    d[s[i]] = 1

m = max(d.values())
ans = []

for k, v in d.items():
  if v == m:
    ans.append(k)
ans.sort()
print(*ans, sep = "\n")

Submission status: Time Limit Exceeded

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

l = []
l_num = []
for i in range(n):
  a = [s[i], s.count(s[i])]
  if a not in l:
    l.append(a)
    l_num.append(s.count(s[i]))

max_num = max(l_num)
l.sort()

for i in range(len(l)):
  if l[i][1] == max_num:
    print(l[i][0])

Submission status: Time Limit Exceeded

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

l = []
list_num = []
for i in range(n):
  l.append([s[i], s.count(s[i])])
  list_num.append(s.count(s[i]))

max_num = max(list_num)

se = set()
for i in range(n):
  if l[i][1] == max_num:
    se.add(l[i][0])
l_2 =list(se)
l_2.sort()

print(*l_2, sep = "\n")

Submission status: Time Limit Exceeded

Solution code:
import collections

N = int(input())
vote_list = [input() for i in range(N)]
vote_list.sort()

count = collections.Counter(vote_list)
max_count = count.most_common()[0][1]

if max_count == 1:
    for i in vote_list:
        print(i)
elif len(list(set(vote_list))) == 1:
    print(vote_list[0])
else:
    i = 0
    for i in range(10000000000):
        if count.most_common()[i][1] == max_count:
            print(count.most_common()[i][0])
        else:
            break

Submission status: Time Limit Exceeded

Solution code:
import collections
import sys

N = int(input())
S = [input() for _ in range(N)]
# print(S)
if len(set(S)) == 1:
    print(S[0])
    sys.exit(0)
c = collections.Counter(S)
# print(c.most_common())

outputs = []
for i, (key, value) in enumerate(c.most_common()):
    outputs.append(key)
    if i == len(c.most_common())-1 or c.most_common()[i+1][1] != value:
        break
outputs.sort()
for x in outputs:
    print(x)

Submission status: Time Limit Exceeded

Solution code:
import collections

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

c = collections.Counter(S)
# print(c.most_common())

outputs = []
for i, (key, value) in enumerate(c.most_common()):
    outputs.append(key)
    if i == len(c.most_common())-1 or c.most_common()[i+1][1] != value:
        break
outputs.sort()
for x in outputs:
    print(x)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
lit = [input() for i in range(N)]
lit2 = list(set(lit))
lit2.sort()
lit_cnt = []
for i in range(len(lit2)):
    A = lit.count(lit2[i])
    lit_cnt.append(A)
B = max(lit_cnt)
for i in range(len(lit2)):
    if lit_cnt[i] == B:
        print(lit2[i])

Submission status: Time Limit Exceeded

Solution code:
import sys
n = int(input())
arr = {}

for i in range(n):
    s = sys.stdin.readline().rstrip()
    if not s in arr:
        arr[s] = 1
    else:
        arr[s] += 1

dic = [key[0] for key in arr.items() if key[1] == max(arr.values())]
for i in sorted(dic):
    print(i)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
arr = {}

for i in range(n):
    s = input()
    if not s in arr:
        arr[s] = 1
    else:
        arr[s] += 1

dic = [key[0] for key in arr.items() if key[1] == max(arr.values())]
for i in sorted(dic):
    print(i)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S =[input() for _ in range(N)]
A = [S.count(S[i]) for i in range (N)]
Max_A = max(A)
ans = []
for j in range(N):
    if S.count(S[j]) == Max_A:
        ans.append(S[j])
ans = set(ans)
ans = list(ans)
ans.sort()
print("\n".join(ans))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
word_dict = {}
for _ in range(n):
    word = str(input())
    if word in word_dict:
        word_dict[word] +=1
    else:
        word_dict[word] = 1
max_list = [key for key, value in word_dict.items() if value == max(word_dict.values())]
max_list.sort()
for item in max_list:
    print(item)

Submission status: Time Limit Exceeded

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

for i in range(n):
    s = input()
    arr.append(s)
    
counter = 0
dic = []

for i in set(arr):
    c = arr.count(i)
    if counter < c:
        counter = c
        dic = []
        dic.append(i)
    elif counter == c:
        dic.append(i)
    else:
        continue

dic = sorted(dic)
for i in dic:
    print(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:
# coding: utf-8
# Your code here!
# coding: utf-8

def main():
   
    n = int(input())
    alltohyo = list()
    counter = {}
    for _ in range(n):
        alltohyo.append(input())
   
    tohyo = set(alltohyo)
   
    for i in tohyo:
        counter[i] = alltohyo.count(i)
       
    max_val = max(counter.values())
    keys_of_max_val = [key for key in counter if counter[key] == max_val]
    #slist = sorted(counter.items(), key=lambda x: x[1], reverse=True)    
   
    s_keys_of_max_val = sorted(keys_of_max_val)
   
    for i in s_keys_of_max_val:
        print(i)
    #max_count = max(counter)
    #print(max_count)
    #print(alltohyo,tohyo, counter)
   
    return 0


if __name__ == '__main__':
  main()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = dict()
for i in range(N):
    st = str(input())
    if st not in S:
        S[st] = 1
    elif st in S:
        S[st] += 1
max_k_list = [kv[0] for kv in S.items() if kv[1] == max(S.values())]
max_k_list.sort()
for i in max_k_list:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

N = int(input())

S = np.array([], dtype="U10")
cnt = np.array([], dtype=int)

for i in range(N):
  s = input()
  if s in S:
    cnt[np.where(S==s)] += 1
  else:
    idx = np.searchsorted(S,s)
    S = np.insert(S,idx,s)
    cnt = np.insert(cnt,idx,1)

ans = S[cnt==cnt.max()]

for s in ans:
  print(s)