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:
import sys 
from collections import Counter
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
N = int(readline())
l = read().decode().split()
c = Counter(l)
 
max = c.most_common()[0][1]
ans = [i[0] for i in c.items() if i[1] >= max]
 
print('\n'.join(sorted(ans)))

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
    
d = {k: v for k, v in sorted(d.items(), key=lambda item: item[1], reverse=True)}

max_count = -1
values = []
for k, v in d.items():
  if max_count < v:
    max_count = v
  if v != max_count:
    break
  values.append(k)

print("\n".join(sorted(values)))

Submission status: Accepted

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


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


def MI():
    return map(int, sys.stdin.readline().split())


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


def main():
    N = II()

    counter = cl.Counter()
    for i in range(N):
        s = input()
        counter.update({s: 1})
    item, value = zip(*counter.most_common())
    ans = []
    max_num = value[0]
    for i in range(len(value)):
        if value[i] == max_num:
            ans.append(item[i])

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


main()

Submission status: Accepted

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

from collections import Counter
C = Counter(S)

maxC = max(C.values())

A=[]
for k,v in C.items():
  # print(k,v)
  if v==maxC: A.append(k)

A = sorted(A)

for a in A:
  print(a)

Submission status: Accepted

Solution code:
from collections import Counter as Ct
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))

def do():
    n=INT()
    dic=[]
    for i in range(n):
        s=STR()
        dic.append(s)
    ctd=Ct(dic)
    ctm=max(ctd.values())
    ans=[]
    for key,value in ctd.items():
        if value==ctm:
            ans.append(key)
    
    ans=sorted(ans)

    for i in ans:
        print(i)


if __name__=='__main__':
    do()

Submission status: Accepted

Solution code:
import collections

n = int(input())
s = list(input() for i in range(n))
c = collections.Counter(s)
p = max(c.values())
s = sorted(list(set(s)))

for i in range(len(s)):
    if c[s[i]] == p:
        print(s[i])

Submission status: Accepted

Solution code:
import collections

n = int(input())
s = list(input() for i in range(n))
s = sorted(s)
c = collections.Counter(s)
p = max(c.values())
s = sorted(list(set(s)))

for i in range(len(s)):
    if c[s[i]] == p:
        print(s[i])

Submission status: Accepted

Solution code:
n=int(input())
arr=[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:
n = int(input())
d = dict()

for i in range(n):
  s = input()
  if(s not in d.keys()):
    d[s] = 1
  else:
    d[s] +=1
    
max = max(d.values())
ans = []
for i in d.keys():
  if(d[i] == max):
    ans.append(i)
for i in sorted(ans):
  print(i)

Submission status: Accepted

Solution code:
_,*ss = open(0).read().split()

from collections import Counter
c = Counter(ss)

mx = c.most_common(1)[0][1]

for s in sorted(key for key,count in c.items() if count==mx):
    print(s)

Submission status: Accepted

Solution code:
import sys 
from collections import Counter

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
l = read().decode().split()
c = Counter(l)

max = c.most_common()[0][1]
ans = [i[0] for i in c.items() if i[1] >= max]

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

Submission status: Accepted

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

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

max_count = max(d.values())

for i in sorted(d.keys()):
  if d[i] == max_count:
    print(i)

Submission status: Accepted

Solution code:
n = int(input())
d = {}
for i in range(n):
    s = input()
    if s not in d:
        d[s] = 1
    else:
        d[s] += 1
m = max(d.values())

ans = [_ for _ in d if d[_] == m]
ans.sort()
[print(_) for _ in ans]

Submission status: Accepted

Solution code:
n = int(input())

# 入力データ受取り時に、辞書に追加していくやり方
s_dict = {}
for i in range(n):
    s = input()    
    if s not in s_dict:
        s_dict[s] = 1
    s_dict[s] += 1

max_value = max(s_dict.values())
ans = []
for key, value in s_dict.items():
    if value == max_value:
        ans.append(key)

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

Submission status: Accepted

Solution code:
n = int(input())
s = {}
maxvalue = -1
for i in range(n):
    sn = input()
    if(s.get(sn) == None):
        s[sn] = 0
    else:
        s[sn] += 1
    maxvalue = max(maxvalue,s[sn])

answers = []
for key in s.keys():
    if s[key] == maxvalue:
        answers.append(key)

answers.sort()

for ans in answers:
    print(ans)

Submission status: Accepted

Solution code:
from collections import Counter

N = int(input())
S = []
for _ in range(N):
    S.append(input())
counter = Counter(S)
sorted_S = list(sorted(counter.keys()))
maxcnt = max(counter.values())
for Si in sorted_S:
    if counter[Si] == maxcnt:
        print(Si)

Submission status: Accepted

Solution code:
from collections import Counter

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:
from collections import Counter

N = int(input())
S = []
for _ in range(N):
    S.append(input())
counter = Counter(S)
sorted_S = list(sorted(set(S)))
maxcnt = max(counter.values())
for Si in sorted_S:
    if counter[Si] == maxcnt:
        print(Si)

Submission status: Accepted

Solution code:
import collections

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

v_coll = collections.Counter(votes).most_common()

most = v_coll[0][1]
mosts = []

for v, i in v_coll:
    if i == most:
        mosts.append(v)
    else:
        break

mosts.sort()

[print(m) for m in mosts]

Submission status: Accepted

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

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

if len(sorted_Dic)==1:
  print(sorted_Dic[0][0])
else:
  ans_list = []
  for i in range(N):
      if sorted_Dic[i][1]==sorted_Dic[0][1]:
          ans_list.append(sorted_Dic[i][0])
      else:
          break;
  for item in sorted(ans_list):
    print(item)

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 k, v in sorted(D.items()):
  if v==m:
    print(k)

Submission status: Accepted

Solution code:
n=int(input(""))
a={}
for i in range(n):
    s=input("")
    if (s in a):
        a[s]+=1
    else:
        a[s]=1
maxs=0
lists=[]
for i in a:
    t=a[i]
    if(t>maxs):
        lists=[i]
        maxs=t
    elif(t==maxs):
        lists+=[i]
lists.sort()
for i in lists:
    print(i)

Submission status: Accepted

Solution code:
from collections import defaultdict

dic = defaultdict(int)

N = int(input())
for _ in range(N):
  dic[input()] += 1
  
mmax = max(dic.values())
for k, v in sorted(dic.items(), key=lambda x:x[0]):
  if v == mmax:
    print(k)
  else:
    continue

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

mx = max(d.values())
for s in sorted(k for k in d if d[k] == mx) :
    print(s)

Submission status: Accepted

Solution code:
N = int(input())
dic = {}
for _ in range(N):
    s = input()
    dic.setdefault(s, 0)
    dic[s] += 1
ans = list(dic.items())
ans.sort(key=lambda x: (-x[1], x[0]))
m = ans[0][1]
print("\n".join(i[0] for i in ans if i[1] == m))

Submission status: Accepted

Solution code:
from collections import Counter
import sys
n=int(sys.stdin.readline().rstrip())
S=[sys.stdin.readline().rstrip() for _ in range(n)]
    
cnt=Counter(S)
ma = max(cnt.values())
list=[]
for k in cnt.keys():
    if cnt[k] == ma:
      list.append(k)

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

Submission status: Accepted

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

a = {}
ans = []

for i in s:
	if i in a:
		a[i] 	+= 1
	else:
		a[i] = 1

leargest = max(a.values())
for k in a.keys():
	if a[k] == leargest:
 		ans.append(k)

[print(i) for i in ans]

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# ABC155_C
import collections

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

S = collections.Counter(s)
M = S.most_common()[0][1]
S = sorted(S.most_common())

for i in range(len(S)):
    if S[i][1] == M:
        print(S[i][0])

Submission status: Accepted

Solution code:
box={}
n=int(input())
for i in range(n):
    v=input()
    if v in box:
        box[v]+=1
    else:
        box[v]=1
m=max(box.values())
f=[k for k,v in box.items() if v==m]
f.sort()
print('\n'.join(f))

Submission status: Accepted

Solution code:
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

N = int(input())
count = defaultdict(int)
for i in range(N):
    s = input()
    count[s] += 1

mx = 0
for k, v in count.items():
    if v > mx:
        mx = v

ans = []
for k, v in count.items():
    if v == mx:
        ans.append(k)


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

Submission status: Accepted

Solution code:
import numpy as np
N = int(input())
S = np.array([input() for _ in range(N)], dtype=str)
keys, values = np.unique(S, return_counts=True)
cnt = []
for k, v in zip(keys, values):
    cnt.append([k, v])
cnt.sort(reverse=True, key=lambda x: x[1])
a = cnt[0][1]
ans = []
for k, v in cnt:
    if v < a:
        break
    ans.append(k)
ans.sort()
for a in ans:
    print(a)

Submission status: Accepted

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

poll = []
count = []
pre_poll = ''
for i in range(n):
    if pre_poll == s[i]:
        count[-1] += 1
    else:
        poll.append(s[i])
        count.append(1)
        pre_poll = s[i]
        
poll_dict = dict(zip(poll, count))
poll_dict = dict(sorted(poll_dict.items(), key=lambda x:x[1], reverse=True))

val = next(iter(poll_dict.values()))
for t in poll_dict.items():
    if val == t[1]:
        print(t[0])
    else:
        break

Submission status: Accepted

Solution code:
n = int(input())
d = { }
for _ in range(n):
  s = input()
  if s not in d:
    d[s] = 0
  d[s] += 1

  
max_cnt = max(d.values())

max_keys = [s for s, i in d.items() if i == max_cnt]

max_keys.sort()
for k in max_keys:
  print(k)

Submission status: Accepted

Solution code:
import collections
N = int(input())
S = {}
for i in range(N):
    si = input()
    if si in S:
        S[si] += 1
    else:
        S[si] = 1
#print(S)
m = max(S.values())
for i in sorted(S.items()):
    #print(sorted(S.items()))
    #print(S,i[0])
    if i[1] == m:
        print(i[0])

Submission status: Accepted

Solution code:
from collections import Counter
a = []
for i in range(int(input())):
    a.append(input())
a = Counter(a)
m = a.most_common()[0][1]
for i, j in sorted(a.most_common()):
    if j ==m: print(i)

Submission status: Accepted

Solution code:
import collections
n=int(input())
s=[]
for i in range(n):
  s.append(input())
s_cnt=collections.Counter(s)
m=max(s_cnt.values())
ans=[]
cnt=0
for i,v in s_cnt.items():
  if v==m:
    ans.append(i)
    cnt+=1
ans.sort()
for i in range(cnt):
  print(ans[i])

Submission status: Accepted

Solution code:
from collections import Counter
 
_, *s = open(0).read().split()
 
c = Counter(s).most_common()
 
a = []
 
p = 0
for i, j in c:
    if p > j:
        break
    p = j
    a.append(i)
print(*sorted(a), sep="\n")

Submission status: Accepted

Solution code:
from collections import Counter

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

common = S.most_common()
keys = []
for i, pair in enumerate(common):
  key, val = pair
  if i == 0:
    MAX = val
  else:
    if val < MAX:break
  keys.append(key)
keys = sorted(keys)
for i in range(len(keys)):
  print(keys[i])

Submission status: Accepted

Solution code:
import collections
n=int(input())
s=[]
for i in range(n):
  s.append(input())
dict=collections.Counter(s)
dict_sorted=sorted(dict.items())
maximum=max(dict.values())
for key,value in dict_sorted:
  if value==maximum:
    print(key)

Submission status: Accepted

Solution code:
n=int(input())
dict={}
cnt=1
for i in range(n):
  s=input()
  if s in dict:
    dict[s]+=1
    cnt=max(cnt,dict[s])
  else:
    dict[s]=1
dict_sorted=sorted(dict.items())
for j in range(len(dict_sorted)):
  if dict_sorted[j][1]==cnt:
    print(dict_sorted[j][0])

Submission status: Accepted

Solution code:
def main():

    N = int(input())
    d = dict()
    cnt = 0
    for _ in range(N):
        s = input()
        d[s] = d.get(s, 0) + 1
        cnt = max(cnt, d[s])
    ans = []
    for s in d:
        if d[s] == cnt: ans.append(s)
    ans = sorted(ans)
    for s in ans:
        print(s)

    # return " ".join(map(str, sorted(ans)))

if __name__ == '__main__':
    main()
    # print(main())

Submission status: Accepted

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
x = 0
for i in d.keys():
    x = max(x,d[i])
d = sorted(d.items())
for i in d:
    if i[1] == x:
        print(i[0])

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
C = Counter()
for i in range(N):
    C[input()] += 1
n = C.most_common(1)[0][1]
c = [k for k, v in C.items() if v == n]
c.sort()
for _c in c:
    print(_c)

Submission status: Accepted

Solution code:
import sys

# import bisect
# import numpy as np
from collections import deque
# map(int, sys.stdin.read().split())
# import heapq
# import bisect
# import math

from collections import Counter


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    A = []
    for i in range(N):
        S = input()
        A.append(S)
    c = Counter(A)
    maxc = max(c, key=c.get)
    maxc = max(c.values())
    aa = []
    for key, val in c.items():
        if val ==maxc:
            aa.append(key)
    aa.sort()
    print("\n".join(aa))

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())
s = list(input() for _ in range(n))
s.sort()
now = s[0]
ans = [s[0],]
cnt = 0
m_cnt = 0

for i in range(n):
    word = s[i]
    if word == now:
        cnt +=1
        if cnt > m_cnt:
            ans = [word,]
            m_cnt = cnt
        elif cnt == m_cnt:
            ans.append(word)
    else:
        cnt = 1
        now = word
        if cnt > m_cnt:
            ans = [word,]
            m_cnt = cnt
        elif cnt == m_cnt:
            ans.append(word)

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

Submission status: Accepted

Solution code:
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n = i()
#s = {s():0 for _ in range(n)}

a = {}
for i in range(n):
	s = input()
	try:
		a[s] += 1
	except KeyError:
		a[s] = 1
b = sorted(a.items(),key = lambda x:x[0])

memo = max([i[1] for i in a.items()])
for i in b:
	"""print(i,"i")
	print(i[0],"i[0]")
	print(i[1],"i[1]")
	print(max(b)[0],"max(b)[0]")"""
	if i[1] == memo:
		print(i[0])

Submission status: Accepted

Solution code:
n = int(input())

vote = dict()
maxv = 0
for i in range(n):
  s = input()
  if not s in vote:
    vote[s] = 1
  else:
    vote[s] += 1
  maxv = max(maxv, vote[s])

candidates = list()

for k, v in vote.items():
  if int(v) == maxv:
    candidates.append(k)

candidates.sort()

for candidate in candidates:
  print(candidate)

Submission status: Accepted

Solution code:
from sys import stdin

n = int(stdin.readline().strip())
count_dict = {}

for _ in range(n):
  s = stdin.readline().strip()
  count_dict[s] = count_dict.get(s, 0) + 1

max_count = max(count_dict.values())
freq_s_lst = [k for k, v in count_dict.items() if v == max_count]

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

Submission status: Accepted

Solution code:
import collections
N = int(input())
S= [ input() for _ in range(N)]
Sc = collections.Counter(S)
mv = max(Sc.values())
km = []
for key,val in Sc.items():
    if val == mv:
        km.append(key)
kms = sorted(km)
for k in kms:
    print(k)

Submission status: Accepted

Solution code:
if __name__ == '__main__':

	n = int(input())
	
	d = {}
	for i in range(n):
		cmd = input()
		if cmd in d:
			d[cmd] += 1
		else:
			d[cmd] = 1

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

	B = sorted(A)
	for b in B:
		print(b)

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())
a = []
for i in range(n):
    a.append(input())
b = Counter(a)
m = max(b.values())
for k, v in sorted(b.items()):
    if v == m:
        print(k)

Submission status: Accepted

Solution code:
b = {}
for _ in range(int(input())): s=input(); b[s]=b.get(s,0)+1
m = max(b.values())
print(*sorted(k for k in b if b[k]==m))

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
list_S = []
ans = []
for _ in range(n):
    list_S.append(str(input()))

list_S = Counter(list_S)
list_S = list(list_S.items())
list_S.sort(key=lambda x:x[1], reverse=True)

for l in list_S:
    if list_S[0][1] == l[1]:
        ans.append(l[0])
ans.sort()
for s in ans:
    print(s)

Submission status: Accepted

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

N = int(input())
dic = {}
for i in range(N):
    S = input().rstrip('\n')
    if S in dic:
        dic[S] += 1
    else:
        dic[S] = 1

# print(dic)
D = sorted(dic.items(), key=lambda x: (-x[1], x[0]))
# print(D)

nn = D[0][1]

for k, v in D:
    if v == nn:
        print(k)
    else:
        break

Submission status: Accepted

Solution code:
k=int(input())
d=dict()
for i in range(k):
    x=input()
    d[x]=d.get(x,0)+1
q=list()
for k,v in d.items():
    q.append( (v,k) )
bigV=0
for (v,k) in sorted(q,reverse=True):
    if(v>bigV):
        bigV=v
for (v,k) in sorted(q):
    if(v==bigV):
        print(k)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n = int(input())
    d = defaultdict(int)
    mx = 0
    for _ in range(n):
        s = input()
        d[s] += 1
        mx = max(mx, d[s])
    a = []
    for k in d:
        if d[k] == mx:
            a.append(k)
    a.sort()
    for e in a:
        print(e)
    



t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()




"""

"""

Submission status: Accepted

Solution code:
def resolve():
    n = int(input())
    d = {}
    for _ in range(n):
        s = input()
        if s not in d:
            d[s] = 1
        else:
            d[s] += 1
    d = sorted(d.items(), key=lambda x:x[1], reverse=True)
    ans = []
    before = d[0][1]
    for t in d:
        if t[1] != before:
            break
        else:
            ans.append(t[0])
    ans = list(sorted(ans))
    print(*ans, sep="\n")
resolve()

Submission status: Accepted

Solution code:
def resolve():
    n = int(input())
    d = {}
    for _ in range(n):
        s = input()
        if s not in d:
            d[s] = 1
        else:
            d[s] += 1
    d = sorted(d.items(), key=lambda x:x[1], reverse=True)
    ans = []
    before = d[0][1]
    for t in d:
        if t[1] != before:
            break
        else:
            ans.append(t[0])
    ans = list(sorted(ans))
    for a in ans:
        print(a)
resolve()

Submission status: Accepted

Solution code:
import collections
N = int(input())
S = [str(input()) for i in range(N)]
c = collections.Counter(S)
l = c.most_common()
dict = [l[0][0]]
if l[0][1] == N:
    print(*dict)
    exit()
for i in range(N - 1):
    if l[i][1] == l[i + 1][1]:
        dict.append(l[i + 1][0])
        continue
    break
a = sorted(dict)
for x in a:
    print(x)

Submission status: Accepted

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

n, d = int(input()), defaultdict(int)
for i in range(n): d[input()[:-1]] += 1
m = max(d.values())
print('\n'.join(sorted([k for k, v in d.items() if v == m])))

Submission status: Accepted

Solution code:
import sys
import time
import math
st = time.perf_counter()
def inpl():
    return list(map(int, input().split()))
# ------------------------------


N = int(input())
S = [input() for _ in range(N)]
d = dict()
mx = 0
for s in S:
	if s not in d:
		d[s] = 0
	d[s] += 1
	mx = max(d[s], mx)
ans = []
for k,v in d.items():
	if v == mx:
		ans.append(k)
ans.sort()
for a in ans:
	print(a)

# ------------------------------
ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)

Submission status: Accepted

Solution code:
# Template 1.0
import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n =INT()

dd = defaultdict(int)

for _ in range(n):
    dd[input()]+=1

mx = max(dd.values())
zz=  []
for k in dd:
    if(dd[k]==mx):
        zz.append(k)
zz.sort()
# print(zz)
for _ in range(len(zz)):
    print(zz[_])

Submission status: Accepted

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

S = [input() for _ in range(N)]
SC = Counter(S)
Ans = []
num = -1
for ans, value in SC.most_common():
    if num == -1:
        num = value
        Ans.append(ans)
    else:
        if num != value:
            break
        else:
            Ans.append(ans)
Ans.sort()

for a in Ans:
    print(a)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import Counter

def solve(l):
    d = Counter(l)
    d_max = max(d.values())
    max_d_list = sorted([k[0] for k in d.items() if k[1] == d_max])
    return max_d_list



def main():
    N = int(input())
    l = [input() for _ in range(N)]
    d = solve(l)
    for a in d:
        print(a)
    return

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
from collections import Counter

sys.setrecursionlimit(10**7)
input = sys.stdin.readline

n = int(input())
cnt = Counter(input() for _ in range(n))
macnt = max(cnt.values())
names = [k for k, v in cnt.items() if v == macnt]
names.sort()
print(*names, sep='\n')

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict

sys.setrecursionlimit(10**7)
input = sys.stdin.readline

n = int(input())

d = defaultdict(int)
for i in range(n):
    s = input().rstrip()
    d[s] += 1

ma = 0
for v in d.values():
    ma = max(ma, v)

a = sorted(d.items())
for k, v in a:
    if ma == v:
        print(k)

Submission status: Accepted

Solution code:
n = int(input())
s = [input() for s in range(n)]
dic = {}

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

cnt_max = max(dic.values()) 
ans = []
for j in dic.keys():
	if dic[j] == cnt_max:
		ans.append(j)

ans.sort()

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

Submission status: Accepted

Solution code:
from collections import Counter

N = int(input())
counter = Counter([input() for _ in range(N)])
max_cnt = max(counter.values())
names = [name for name, cnt in counter.items() if cnt == max_cnt]
names.sort()

print(*names, sep='\n')

Submission status: Accepted

Solution code:
from collections import defaultdict

N = int(input())
s_counter = defaultdict(int)
for _ in range(N):
    S = input()
    s_counter[S] += 1
S_list = sorted(s_counter.items(), key=lambda x: x[1], reverse=True)
answer = []
for i in range(len(S_list)):
    if S_list[0][1] != S_list[i][1]:
        break
    answer.append(S_list[i][0])
answer.sort()
[print(a) for a in answer]

Submission status: Accepted

Solution code:
n = int(input())
s = [""]+ [input() for _ in range(n)]
sl  = sorted(s)
count = 1
tl = []
for i in range(1,n+1):
    if sl[i-1] == sl[i]:
        count += 1
        tl.append(count)
    else:
        count = 1
        tl.append(count)

a_c = max(tl)
count = 0
for t in tl:
    if t == a_c:
        print(sl[count+1])
        count += 1
    else:
        count += 1

Submission status: Accepted

Solution code:
'''

                            Online Python Compiler.
                Code, Compile, Run and Debug python program online.
Write your code in this editor and press "Run" button to execute it.

'''
from sys import stdin
def read():
    return stdin.readline().strip()

dict={}
output=[]

iteration=int(read())

max_val=-1

for _ in range(iteration):
    item=read()
    
    if dict.get(item) is None:
        dict[item]=0 
    dict[item]+=1 
    max_val = max(dict[item],max_val)
#max_val=max(dict.values())
for k,v in dict.items():
    
    if(max_val==v):
        output.append(k)
    
    
output.sort()
print('\n'.join(output))

Submission status: Accepted

Solution code:

from sys import stdin
def read():
    return stdin.readline().strip()

dict={}
output=[]

iteration=int(read())

max_val=-1

for _ in range(iteration):
    item=read()
    
    if dict.get(item) is None:
        dict[item]=0 
    dict[item]+=1 
    max_val = max(dict[item],max_val)
#max_val=max(dict.values())
for k,v in dict.items():
    
    if(max_val==v):
        output.append(k)
    
    
output.sort()
print('\n'.join(output))

Submission status: Accepted

Solution code:
import numpy as np

N = int(input())

l = []

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

result, counts = np.unique(np.array(l), return_counts=True)
result = result[counts == max(counts)]

for x in np.sort(result):
    print(x)

Submission status: Accepted

Solution code:
N = int(input())
votedict = {}
Max = -1
for _ in range(N):
    S = input()
    if S in votedict:
        votedict[S] += 1
        Max = max(votedict[S],Max)
    else:
        votedict[S] = 1

if Max == -1:
    Max = 1

maxvote = []

for k,v in votedict.items():
    if v == Max:
        maxvote.append(k)

maxvote.sort()

for i in maxvote:
    print(i)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    S_list = []
    for _ in range(N):
        S_list.append(input())

    S_dict = {}
    for s in S_list:
        S_dict[s]=0
    for s in S_list:
        S_dict[s]+=1

    max_v = max(S_dict.values())

    max_k_list = [kv[0] for kv in S_dict.items() if kv[1] == max_v]
    max_k_list.sort()
    for k in max_k_list:
        print(k)

if __name__ == '__main__':
     main()

Submission status: Accepted

Solution code:
import sys
from collections import Counter

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    S = [readline().strip() for _ in range(N)]

    c = Counter(S)
    max_freq = max(c.values())
    ans = [s for s, v in c.items() if v == max_freq]
    ans.sort()

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

    return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import Counter

_, *s = open(0).read().split()

c = Counter(s).most_common()

a = []

p = 0
for i, j in c:
    if p > j:
        break
    p = j
    a.append(i)
print(*sorted(a), sep="\n")

Submission status: Accepted

Solution code:
#

import sys
from bisect import bisect, bisect_left
input=sys.stdin.readline

def main():
    N=int(input())
    S=[input().strip("\n") for i in range(N)]
    S.sort()
    Ss=set(S)
    ooi=[]
    maxc=0
    for s in Ss:
        c=bisect(S,s)-bisect_left(S,s)
        if maxc<c:
            ooi=[s]
            maxc=c
        elif maxc==c:
            ooi.append(s)
    print("\n".join(sorted(ooi)))
        
        
    
    
if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

from collections import Counter

n = int(input())
s = [input() for i in range(n)]
c = Counter(s)
c_max = max(c.values())
ans = [j[0] for j in c.items() if j[1] == c_max]
ans = sorted(ans)
for f in ans:
    print(f)

Submission status: Accepted

Solution code:
from collections import Counter

N=int(input())
S=[input() for i in range(N)]
s=Counter(S)
max_val=max(s.values())
ans=[k for k,v in s.items() if v==max_val]
ans.sort()
for x in ans:
  print(x)