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: Accepted

Solution code:
n=int(input())
box={}
for i in range(n):
  vote=input()
  if not(vote in box):
    box[vote]=1
  else:
    box[vote]+=1
m=0
win=[]
for num in box.values():
  if num > m:
    m=num
for name,num in box.items():
  if num==m:
    win.append(name)
win=sorted(win)
for i in win:
  print(i)

Submission status: Accepted

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

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

max_ = max(s_dict.values())
ans = []

for key in s_dict.keys():
    if s_dict[key] == max_:
       ans.append(key)
    else:
        continue

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

Submission status: Accepted

Solution code:
from collections import Counter
from itertools import groupby

def main():
    n = int(input())

    l = []
    for i in range(n):
        l.append(str(input()))

    freqs = groupby(Counter(l).most_common(), lambda x:x[1])
    d = [val for val,count in next(freqs)[1]]
    d.sort()
    for i in d:
        print(i)

main()

Submission status: Accepted

Solution code:
stdin = open(0).read().split('\n')
d={}
for i in range(1,int(stdin[0])+1):
    s=stdin[i]
    if s in d:
        d[s] = d[s]+1
    else:
        d[s] =1
max=1
for num in d.values():
    if num>max:max=num
for k,v in sorted(d.items()):
    if v==max:print(k)

Submission status: Accepted

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

maxs = max(s.values())
ss = []
for k, v in s.items():
  if maxs == v:
    ss.append(k)
ss.sort()
for si in ss:
  print(si)

Submission status: Accepted

Solution code:
from collections import defaultdict

n = int(input())
st = [input() for _ in range(n)]
d = defaultdict(int)
p = []
max = 0

for s in st:
  d[s] += 1
  if max < d[s]:
    max = d[s]
  
for key in d.keys():
  if d[key] == max:
    p.append(key)
p=sorted(p)
for pi in p:
  print(pi)

Submission status: Accepted

Solution code:
import sys
from collections import Counter

n, *s = sys.stdin.read().split()

def main():
    c = Counter(s)
    m = max(c.values())
    ans = [s for s, v in c.items() if v == m]
    print(*sorted(ans), sep='\n')
         
if __name__ ==  '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
from collections import Counter

n, *s = sys.stdin.read().split()

def main():
    cnt = sorted(Counter(s).items(), key=lambda x: -x[1])
    m = cnt[0][1]
    ans = [s for s, c in cnt if c == m]
    print(*sorted(ans), sep='\n')
         

if __name__ ==  '__main__':
    main()

Submission status: Accepted

Solution code:
N=int(input())

d={}
for _ in range(N):
    S=input()
    if S in d:
        d[S]+=1
    else:
        d[S]=1
        
m=max(d.values())
for s in sorted(k for k in d if d[k]==m):
    print(s)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    cnt = {"":0}
    ans = 0

    for i in range(n):
        s = input()
        if cnt.get(s) == None:
            cnt[s] = 1
        else:
            cnt[s] += 1
        ans = max(ans, cnt[s])

    ls = []
    for k in cnt:
        if cnt[k] == ans:
            ls.append(k)

    ls.sort()

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

main()

Submission status: Accepted

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

dict ={}
for i in arr:
    if i not in dict:
        dict[i] = 1
    else:
        dict[i] += 1

max_n = max(dict.values())

ans =[]
for i in dict:
    if dict[i] == max_n:
        ans.append(i)

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

Submission status: Accepted

Solution code:
N = int(input())

d = {}

max = 0

for _ in range(N):
    S = input()
    if S in d:
        d[S] = d[S] + 1
        if max < d[S]:
            max = d[S]
        continue
    d[S] = 1
    if max < d[S]:
        max = d[S]

ans = []

for key in d:
    if d[key]==max:
        ans.append(key)

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

Submission status: Accepted

Solution code:
N = int(input())
S =[]
times = {}
for i in range(N):
  word = input()
  if word in times:
    times[word] = times[word] + 1
  else:
    times[word] = 1
max_value = max(times.values())
words = []
for i in times.items():
  if i[1] == max_value:
    words.append(i[0])
words = sorted(words)
for i in words:
  print(i)

Submission status: Accepted

Solution code:
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    S = [iss() for _ in range(N)]
    S.sort()
    di = {}
    mx = 0
    for s in S:
        if s in di:
            di[s] += 1
            mx = max(di[s], mx)
        else:
            di[s] = 0

    ret = []
    for s in di:
        if di[s] == mx: ret.append(s)
    print(*sorted(ret), sep='\n')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
S =[]
times = {}
for i in range(N):
  word = input()
  if word in times:
    times[word] = times[word] + 1
  else:
    times[word] = 1
#itemsでタプルにして、mは一番多い回数を取っている。最後の[1]はタプルの二個目の要素の意味で、数字。
#key = lembdaのところはxが引数で、x[1]を参照するという意味、ここで引数は、times.items()のはず
m = max(times.items(), key = lambda x:x[1])[1]
a = []
for t in times.items():
	if(t[1]==m):
		a.append(t[0])
 
a.sort()
for t in a:
	print(t)

Submission status: Accepted

Solution code:
N = int(input())
S =[]
times = {}
for i in range(N):
  word = input()
  if word in times:
    times[word] = times[word] + 1
  else:
    times[word] = 1
m = max(times.items(), key = lambda x:x[1])[1]
a = []
for t in times.items():
	if(t[1]==m):
		a.append(t[0])
 
a.sort()
for t in a:
	print(t)

Submission status: Accepted

Solution code:
import collections

n = int(input());
S = [];

for i in range(n):
  S.append(input());

c = collections.Counter(S)

num = c.most_common()[0][1];
ans = [];

for a,b in c.most_common():
    if b == num:
      ans.append(a);
      continue;
    
    else:
      break;

ans = sorted(ans);

for i in ans:
  print(i);

Submission status: Accepted

Solution code:
N = int(input())
S = [input() for _ in range(N)]
import collections
max = max(collections.Counter(S).values())
letter = [a for a , b in collections.Counter(S).most_common() if b == max]
for a in sorted(letter):
    print(a)

Submission status: Accepted

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

m = max(ans.items(), key = lambda x:x[1])[1]
a = []
for t in ans.items():
	if(t[1]==m):
		a.append(t[0])

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, S: "List[str]"):
    from itertools import groupby
    S = sorted(S)
    t = [(len(list(v)), k) for k, v in groupby(S)]
    n = max(tt[0] for tt in t)
    return sorted([k for _, k in filter(lambda tt: tt[0] == n, t)])


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    print(*solve(N, S), sep='\n')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
d = dict()
for i in range(n):
    s = input()
    if not s in d:
        d[s] = 1
    else:
        d[s] += 1

sorted_d = sorted(d.items(), reverse=True, key=lambda x:x[1])
ans_list = []
for x in sorted_d:
    if x[1] == sorted_d[0][1]:
        ans_list.append(x[0])
    else:
        break

ans_list.sort()
print(*ans_list, sep='\n')

Submission status: Accepted

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input())
    dic = {}
    for i in range(n):
        s = input()
        if s in dic:
            dic[s] += 1
        else:
            dic[s] = 1
    max_ = max(dic.values())
    L = []
    for k,v in dic.items():
        if v == max_:
            L.append(k)
    L = sorted(L)
    print(*L,sep='\n')
if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
d = {}
max_value = 1
n = int(input())
for i in range(n):
    t = input()
    if t in d.keys():
        d[t] += 1
        if d[t] > max_value:
            max_value = d[t]
    else:
        d.setdefault(t, 1)
#print(f"d = {d}")
#print(f"max_value = {max_value}")
#print(f"d.keys() = {d.keys()}")
#print(f"d.values() = {d.values()}")
d = sorted(d.items())
#print(d)
for k, v in d:
    if v == max_value:
        print(k)

Submission status: Accepted

Solution code:
def main():
    n = int(input())

    m = dict()
    n_max = -1;
    for _ in range(n):
        s = input()
        if s not in m:
            m[s] = 0
        else:
            m[s] += 1

        n_max = max(m[s], n_max)

    for k, v in sorted(m.items(), key=lambda x: x[0]):
        if v == n_max:
            print(k)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
ini = lambda: int(input())
inl = lambda: list(map(int, input().split()))
ins = lambda: input().strip()
mod = 10**9 + 7

N = ini()
S = []
for i in range(N):
	S.append(ins())

import collections
cnt = collections.Counter(S)
max_c = max(cnt.values())
ans = []
for s, c in cnt.items():
	if c == max_c:
		ans.append(s)
for a in sorted(ans):
	print(a)

Submission status: Accepted

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

for _ in range(n):
  s = input()
  if s_dict.get(s, -1) == -1:
    s_dict[s] = 1
  else:
    s_dict[s] += 1

if len(s_dict) == 1:
  print(list(s_dict.keys())[0])
  exit()
  
s_dict2 = sorted(s_dict.items(), key=lambda x:x[1], reverse=True)
s_list = []
i = 0

while s_dict2[i][1] == s_dict2[0][1]:
  s_list.append(s_dict2[i][0])
  i += 1
  if i == len(s_dict2):
    break

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

Submission status: Accepted

Solution code:
n = int(input())

ll = [str(input()) for i in range(n)]

import collections
c = collections.Counter(ll)

values, counts = zip(*c.most_common())
values = list(values)
counts = list(counts)

m = max(list(counts))

l = []
for i in range(len(values)):
  if counts[i] == m:
    l.append(values[i])

l = sorted(l)

for i in l:
  print(i)

Submission status: Accepted

Solution code:
N=int(input())
S=[input() for i in range(N)]
S=sorted(S)
cnt=1
max_cnt=1
ans=[S[0]]
for i in range(N-1):
    if S[i]==S[i+1]:
        cnt+=1
    else:
        cnt=1
    if cnt==max_cnt:
        ans.append(S[i+1])
    if cnt>max_cnt:
        max_cnt=cnt
        ans=[S[i+1]]
ans=sorted(ans)
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
'''
INPUT SHORTCUTS
N, K = map(int,input().split())
N ,A,B = map(int,input().split())
string = str(input())
arr = list(map(int,input().split()))
N = int(input())
'''

N = int(input())
h = {}
maxnum = 1
for _ in range(N):
	string = ''
	string = str(input())
	if string in h:
		h[string]+=1
		maxnum = max(maxnum,h[string])
	else:
		h[string]=1
maxList = []
for i in h.keys():
	if h[i]==maxnum:
		maxList.append(i)
maxList.sort()
for x in maxList:
	print(x)

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
c = Counter(s)
ans = []
max_values = max(c.values())

for k in c.keys():
    if c[k] == max_values:
        ans.append(k)

ans = sorted(ans)
for item in ans:
    print(item)

Submission status: Accepted

Solution code:
def myAnswer(N:int,S:list) -> None:
   dic = {}
   for s in S:
      if(s in dic.keys()):
         dic[s]+=1
      else:
         dic[s]=1
   MAX = max(dic.values())
   dic2 = sorted(dic.items())
   for key,value in dic2:
      if(MAX == value):
         print(key)
   

def modelAnswer():
   tmp=1
def main():
   N = int(input())
   S = []
   for _ in range(N):
      S.append(input())
   myAnswer(N,S[:])
if __name__ == '__main__':
   main()

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
work = [input() for _ in range(N)]
work = Counter(work)
i = -1
result = []
for key, value in work.most_common():
    if i == -1 or i == value:
        i = value
        result.append(key)
for r in sorted(result):
    print(r)

Submission status: Accepted

Solution code:
n=int(input())
s=[input() for i in range(n)]
nl={i:0 for i in set(s)}
c=0
for i in s:
  nl[i]+=1
  if nl[i]>c:
    c=nl[i]
ans=[i for i in set(s) if nl[i]==c]
ans.sort()
[print(i) for i in ans]

Submission status: Accepted

Solution code:
N=int(input())
S = [input() for _ in range(N)]
import collections 
C=collections.Counter(S)
maxC=max(C.values())
keys = [k for k, v in C.items() if v == maxC]
[print(j) for j in sorted(keys)]

Submission status: Accepted

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

S.sort()
ans=[S[0]]
num=1
max_num=1
for i in range(N-1):
  if(S[i]==S[i+1]):
    num+=1
  else:
    num=1
  if(num==max_num):
    ans.append(S[i+1])
  if(num>max_num):
    max_num=num
    ans=[S[i+1]]
  
ans.sort()
for i in range(len(ans)):
  print(ans[i])

Submission status: Accepted

Solution code:
from collections import defaultdict


def main():
    n = int(input())
    strings = [input() for i in range(n)]
    s_dict = defaultdict(int)
    for s in strings:
        s_dict[s] -= 1
    s_sorted = sorted(s_dict.items(), key=lambda x: (x[1], x[0]))

    max_num = s_sorted[0][1]
    for t in s_sorted:
        if t[1] == max_num:
            print(t[0])
        else:
            break
 

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())
s = []
for i in range(n):
    s.append(input())
ans = {}
for i in s:
    if i in ans:
        ans[i] += 1
    else:
        ans[i] = 1
ans2 = sorted(ans.items(), key=lambda x:x[1], reverse=True)
ans_list = {ans2[0][0]}
ans_cnt = ans2[0][1]
for i, j in ans2:
    if ans_cnt == j:
        ans_list.add(i)

ans_list2 = list(ans_list)
ans_list2.sort(reverse=False)
for i in ans_list2:
    print(i)

Submission status: Accepted

Solution code:
from collections import Counter
n=int(input())
mylist=[]
for i in range(n):
    s=input()
    mylist.append(s)
#print(mylist)
c=Counter(mylist)

#max=sum(x==max(mylist) for x in mylist)
answer=[]
flag=0
#print(max)
for word,i in c.most_common():
    #print(word,i)
    if flag==0:
        max=i
        flag+=1
        answer.append(word)
    else:
        if i==max:
            answer.append(word)
        else:
            break

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

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
S = Counter(input() for _ in range(N))
m = max(S.values())
for v in sorted(k for k, v in S.items() if v == m):
	print(v)

Submission status: Accepted

Solution code:
n=int(input())
arr=list(input() for _ in range(n))
dic={}

for i in range(n):
  if arr[i] not in dic:
    dic[arr[i]]=1
  else:
    dic[arr[i]]+=1
     
largest=max(dic.values())
ans=[]
for keys in dic.keys():
  if dic[keys]==largest:
    ans.append(keys)
ans=sorted(ans)

for words in ans:
  print(words)

Submission status: Accepted

Solution code:
# Useful data structures
from collections import Counter

# For sys.std*, sys.argv etc...
import sys

# For cases when input tokens are spread unevenly over many lines.
# This provides methods for reading tokens of various types.
class BufferedTokenizer:
    pass

def read_ints():
    return [int(token) for token in input().split()]

def read_tokens():
    return input().split()

def main():
    N = read_ints()[0]
    votes = Counter(input() for _ in range(N))
    best = votes.most_common(1)[0][1]
    for vote in sorted(v[0] for v in votes.most_common() if v[1] == best):
        print(vote)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import defaultdict

dic = defaultdict(int)
N = int(input())
for i in range(N):
    S = input()
    dic[S] += 1
candidate = list(zip(*sorted(dic.items(), key=lambda x: (-x[1], x[0]))))
for i in range(len(candidate[0])):
    if candidate[1][i] != candidate[1][0]:
        exit()
    print(candidate[0][i])

Submission status: Accepted

Solution code:
N = int(input())
S = [input() for _ in range(N)]
dic = {}
for s in S:
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1

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

Submission status: Accepted

Solution code:
n=int(input())

candidates={}
for i in range(n):
    candidate=input()
    if candidate in candidates:
        candidates[candidate]+=1
    else:
        candidates[candidate]=1

max_k_list = []
maxvalue=max(candidates.values())
for candidate in candidates:
    if candidates[candidate]==maxvalue:
        max_k_list.append(candidate)


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

Submission status: Accepted

Solution code:
import collections
n = int(input())
s = [input() for _ in range(n)]
ss = collections.Counter(s)
# print(ss)

n_ma = max(ss.values())
ans = []
for k in ss.keys():
    if ss[k] == n_ma:
        ans.append(k)
ans = sorted(ans)
for a in ans:
    print(a)

Submission status: Accepted

Solution code:
N = int(input())
S = {}
for i in range(N):
    s = input()
    if s in S:
        S[s] += 1
    else:
        S[s] = 1

m = max(S.values())

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



for i in ans:
    print(i)

Submission status: Accepted

Solution code:
N=int(input())
a=[]
for i in range(N):
	a.append(str(input()))
a=sorted(a)
a.append('A')
M=0
temp=0
ans=[]
for i in range(N):
	if a[i]==a[i+1]:
		temp+=1
	else:
		if M<temp:
			ans=[a[i]]
			M=temp
			temp=0
		elif M==temp:
			ans.append(a[i])
			temp=0
		else:
			temp=0
for i in range(len(ans)):
	print(ans[i])

Submission status: Accepted

Solution code:
#C

N = int(input())
S = []

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

import collections
c = collections.Counter(S)
m = max(c.values())

words = []

for k,v in c.most_common():
  if v == m:
    words += [k]
  else:
    break

for w in sorted(words):
  print(w)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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

cnt = Counter(S)
tmp = cnt.most_common()[0][1]

all_sort = sorted(cnt.most_common(), key=lambda x:x[0])

for key, val in all_sort:
  if val == tmp:
    print(key)

Submission status: Accepted

Solution code:
from collections import Counter

N = int(input())
S = [input() for _ in range(N)]
clist = Counter(S)
M = max(clist.values())
rlist = []

for i in clist.keys():
    if clist[i] == M:
        rlist.append(i)

rlist.sort(reverse=False)

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

Submission status: Accepted

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

table = {}
for Si in S:
    table[Si] = 1 if table.get(Si) is None else table.get(Si) + 1

maximum = max(table.values())

condition = lambda maxium: lambda item: item[1] == maximum
condition = condition(maximum)

answer = filter(condition, table.items())
answer = dict(answer)
answer = list(answer.keys())
answer.sort()
answer = "\n".join(answer)

print(answer)

Submission status: Accepted

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

table = {}
for Si in S:
    table[Si] = 1 if table.get(Si) is None else table.get(Si) + 1

maximum = max(table.values())

condition = lambda maxium: lambda item: item[1] == maximum
answer = filter(condition(maximum), table.items())
answer = dict(answer)
answer = list(answer.keys())
answer.sort()
answer = "\n".join(answer)

print(answer)

Submission status: Accepted

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

table = {}
for Si in S:
    table[Si] = 1 if table.get(Si) is None else table.get(Si) + 1

maximum = max(table.values())

foo = lambda item: item[1] == maximum
filtered = filter(foo, table.items())
filtered = dict(filtered)
bar = list(filtered.keys())
bar.sort()

answer = "\n".join(bar)

print(answer)

Submission status: Accepted

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

table = {}
for Si in S:
    table[Si] = 1 if table.get(Si) is None else table.get(Si) + 1

maximum = max(table.values())

answer = []
for key, value in table.items():
    if value != maximum: continue
    
    answer.append(key)
answer.sort()
answer = "\n".join(answer)


print(answer)

Submission status: Accepted

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

for _ in range(N):
    s = input()

    if s in S.keys():
        S[s] += 1
    else:
        S[s] = 1

m = max(S.values())
for s in sorted(map(lambda x: x[0], filter(lambda x: x[1] == m, S.items()))):
    print(s)

Submission status: Accepted

Solution code:
n = int(input())
dic = {}
for i in range(n):
  s = input()
  if s not in dic: dic[s] = 1
  else: dic[s] += 1
v = dic.values()
v = sorted(v)
max_num = v[len(v)-1]
ans = []
for s in dic:
  if dic[s]==max_num:
    ans.append(s)
ans = sorted(ans)
for i in range(len(ans)):
  print(ans[i])

Submission status: Accepted

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

n_ma = max(ss.values())
ans = []
for i in ss.keys():
    if ss[i] == n_ma:
        ans.append(i)

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

Submission status: Accepted

Solution code:
n = int(input())
dic = {}
for i in range(n):
    a = input()
    if a in dic:
        dic[a] += 1
    else:
        dic[a] = 0

l = sorted(dic.items(), key=lambda x: x[1], reverse=True)
num = l[0][1]
ok = []
for i in range(len(l)):
    if l[i][1] == num:
        ok.append(l[i][0])
    else:
        break
ok.sort()
for i in ok:
    print(i)

Submission status: Accepted

Solution code:
N=int(input())
dic={}
for i in range(N):
    s=input()
    if s in dic:
        dic[s]+=1
    else:
        dic[s]=0
m=max(dic[i] for i in dic)
ans=[]
for j in dic:
    if dic[j]==m:
        ans.append(j)
ans.sort()
for k in range(len(ans)):
    print(ans[k])

Submission status: Accepted

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

for s in Ss:
    d[s] += 1
mx = max([d[k] for k in d.keys()])
ans = []
for k in d.keys():
    if d[k] == mx:
       ans.append(k)
for a in sorted(ans):
    print(a)

Submission status: Accepted

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

d = defaultdict(int)
for S in Ss:
    d[S] += 1

mx = max([d[k] for k in d.keys()])

ans = []
for k in d.keys():
    if d[k] == mx:
       ans.append(k)
       
for a in sorted(ans):
    print(a)

Submission status: Accepted

Solution code:
cnt = int(input())
dict = {}

for i in range(cnt):
    vote = input()
    if vote in dict:
        dict[vote] += 1
    else:
        dict[vote] = 1
        
max_vote = max(dict.values())
a = filter(lambda x: x[1] == max_vote, dict.items())
b = map(lambda x: x[0], a)
lst = list(b)
lst.sort()
for word in lst:
    print(word)

Submission status: Accepted

Solution code:
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

N = I()
L = []

for i in range(N):
    L.append(S())

max = []
m = 0
cnt = Counter(L)

for v, c in cnt.most_common():
     if m < c:
        max.clear()
        max.append(v)
        m = c
     elif m == c:
        max.append(v)

for s in sorted(max):
    print(s)

Submission status: Accepted

Solution code:
import collections

N = int(input())
l = []
 
for _ in range(N):
    s = str(input())
    l.append(s)

c = collections.Counter(l)
c = c.most_common()
 
most_count = c[0][1]
c.sort()
 
for i in range(len(c)):
    if c[i][1] == most_count:
        print(c[i][0])

Submission status: Accepted

Solution code:
N = int(input())
l = []

for _ in range(N):
    s = str(input())
    l.append(s)

import collections
c = collections.Counter(l)
c = c.most_common()

most_count = c[0][1]
c.sort()

for i in range(len(c)):
    if c[i][1] == most_count:
        print(c[i][0])

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
N = INT()
S = [input() for _ in range(N)]
 
cnt_s = Counter(S)
tmp = cnt_s.most_common()[0][1]
for key, val in sorted(cnt_s.most_common(), key=itemgetter(0)):
		if val == tmp:
      			print(key)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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

cnt_s = Counter(S)
tmp = cnt_s.most_common()[0][1]
for key, val in sorted(cnt_s.most_common(), key=lambda x:x[0]):
		if val == tmp:
      			print(key)

Submission status: Accepted

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

for _ in range(n):
    t = input()
    s.setdefault(t, 1)
    s[t] += 1

ans = []
m = max(s.values())
for k, v in s.items():
    if v == m:
        ans.append(k)

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

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())
l = list("")
for i in range(n):
    l.append(input())
c = Counter(l)
c = c.most_common()
max = c[0][1]
a = list("")
for i in range(len(c)):
    if c[i][1] == max:
        a.append(c[i][0])
    else:
        break
a.sort()
for i in range(len(a)):
    print(a[i])

Submission status: Accepted

Solution code:
import math
from functools import reduce
import itertools
#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))





N=input1()
S=[]
for _ in range(N):
	S.append(str(input()))

dic={}
results=[]
for s in S:
	if s not in dic:
		dic[s]=1
	else:
		dic[s]+=1
ans=10000010010


score_sorted = sorted(dic.items(), key=lambda x:x[1])

max_count=max(dic.values())
for x in score_sorted:
	if x[1]==max_count:
		results.append(x[0])
results.sort()
for i in results:
	print(i)

Submission status: Accepted

Solution code:
N=input()
n=int(N)

p=[]
for i in range(n):
    p.append(input())

ha = {}

for i in p :
    if (i not in ha.keys()) :
        ha[i] = 1
    else :
        ha[i] += 1

res = ha.items()

res = sorted(ha.items(), key = lambda x : x[1] , reverse = True )

i = 1
k = res[0][1]

while (i < len(res) and res[i][1] == k) :
    i += 1

res = res[ : i]

res.sort()
for i in res :
    print (i[0])

Submission status: Accepted

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

from collections import Counter

n = int(readline())
s = [input() for i in range(n)]
check = list(Counter(s).items())
check.sort(key=lambda x: (-x[1], x[0]))
max_a = check[0][1]
for k, v in check:
    if v != check[0][1]:
        break
    print(k)

Submission status: Accepted

Solution code:
import collections as c
 
n = int(input())
alist = [input() for i in range(n)]
 
clist = c.Counter(alist)
anlist = clist.most_common()
anslist = []
for i in range(0,len(anlist)):
    if anlist[0][1] == anlist[i][1]:
        anslist.append(anlist[i][0])
anslistt = sorted(anslist)
 
for i in (anslistt):
    print(i)

Submission status: Accepted

Solution code:
n=int(input())
s=[]
ha={}

for i in range (n):
    s.append(input())
    if (s[i] not in ha.keys()):
        ha[s[i]]=1
    else:
        ha[s[i]]=ha[s[i]]+1

ans=sorted(ha.items(),key=lambda x:x[1], reverse=True)

k=ans[0][1]
i=0
while (i< len(ans) and ans[i][1]==k):
    i+=1

ans=ans[:i]
ans.sort()
for ss in ans:
    print(ss[0])