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
import collections
n = int(input())
# s = []
dic = {}
s = []
for i in range(n):
    s.append(input())
c = collections.Counter(s)
values, counts = zip(*c.most_common())
if counts[0] == 1:
    for i in sorted(values):
        print(i)
else:
    for i in range(len(counts)-1):
        if counts[i] != counts[i+1]:
            stop = i
            break
    a = values[:i+1]
    for v in sorted(a):
        print(v)

Submission status: Accepted

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

l = collections.Counter(l)
x = max(l.values())
t = [kv[0] for kv in l.items() if kv[1] == x]
t.sort()

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

Submission status: Accepted

Solution code:
n = int(input())

poll = {}

for _ in range(n):
  i = input()
  if poll.get(i) is None:
    poll[i] = 1
  else:
    poll[i] += 1

maxVotes = max(poll.values())
ans = []
for key in poll.keys():
  if poll[key] == maxVotes:
    ans.append(key)

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

Submission status: Accepted

Solution code:
from collections import Counter
import numpy as np
N = int(input())
S = [input() for _ in range(N)]
c = Counter(S)
candidate = sorted(np.array(list(c.keys()))[np.array(list(c.values())) == max(c.values())])
for i in range(len(candidate)):
  print(candidate[i])

Submission status: Accepted

Solution code:
N = int(input())
s = [input() for _ in range(N)]
bucket = {}

for i in range(N):
  if s[i] in bucket:
    bucket[s[i]].append(s[i])
  else:
    bucket[s[i]] = []

Max = 0
Max_key = []
for i in bucket:
  if Max < len(bucket[i]):
    Max = len(bucket[i])

for i in bucket:
  if Max == len(bucket[i]):
    Max_key.append(i)

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

Submission status: Accepted

Solution code:
N = input()

Sdict = {}

for i in range((int)(N)):
    S=input()
    if S in Sdict.keys():
        Sdict[S] += 1
    else:
        Sdict[S] = 1

new_dict = sorted(Sdict.items(),key = lambda x:-x[1])

max_key_list=[]

max_num=-1

for k,v in new_dict:
    if max_num == -1:
        max_key_list.append(k)
        max_num = v
    elif v == max_num:
        max_key_list.append(k)
    else:
        break

answer_list = sorted(max_key_list)

for ans in answer_list:
    print(ans)

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] = 1

#print(max(dic.values()))

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

mValue = max(dic.values())

for e in sDic :
    #print(e[0])
    if e[1] != mValue :
        break
    print(e[0])

Submission status: Accepted

Solution code:
N = int(input())
d = dict()
m = 0
for _ in range(N):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1
    if d[s] > m:
        m = d[s]

sd = sorted(d.items(), reverse=True, key=lambda x:x[1])
ans = []
for k, v in sd:
    if v == m:
        ans.append(k)
    else:
        break

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

Submission status: Accepted

Solution code:
from collections import Counter
def main():
    N = int(input())
    S = []
    for n in range(N):
        S.append(input())
    cmc = Counter(S).most_common()
    nmax = cmc[0][1]
    mc_words = sorted([cmc[i][0] for i in range(len(cmc)) if cmc[i][1] == nmax])
    for w in mc_words:
        print(w)

main()

Submission status: Accepted

Solution code:
N = int(input())
dicta = {}
for i in range(N):
    word = input()
    dicta.setdefault(word, 0)
    dicta[word] += 1
word_c = list(dicta.items())
word_c.sort(key=lambda tup: tup[1], reverse=True)
max_len_word = [word_c[0][0]]
for j in range(1,len(word_c)):
    if word_c[j][1] == word_c[0][1]:
        max_len_word.append(word_c[j][0])
    else:
        break
max_len_word.sort()
for word in max_len_word:
    print(word)

Submission status: Accepted

Solution code:
N = int(input())


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


d = {}
for i in range(N):
    if d.get(S[i]) is None:
        d[S[i]] = 1
    else:
        d[S[i]] += 1

max_val = max(d.values())
keys_of_max_val = [key for key in d if d[key] == max_val]

ans_lst = sorted(keys_of_max_val)
for v in ans_lst:
    print(v)

Submission status: Accepted

Solution code:
n = int(input())
s = [input() for i in range(n)]
d ={}
for key in s:
    if key in d:
        d[key] += 1
    else:
        d[key] = 1
Max = max(d.values())
max_k_list = [kv[0] for kv in d.items() if kv[1] == Max]
max_k_list.sort()
for i in max_k_list:
    print(i)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
a=[]
for i in range(n):
  a.append(input())
count={}

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

max = 0
for k in count.keys():
  if max < count[k]:
    max=count[k]

l =[]
for k in count.keys():
  if count[k]==max:
    l.append(k)

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

Submission status: Accepted

Solution code:
N = int(input())

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

S.sort()

before = S[0]
num = 0
tmp = 0
R = []
for i in range(1, N):
    if S[i] == before:
        tmp += 1
    else:
        if tmp == num:
            R.append(before)
        elif tmp > num:
            R.clear()
            R.append(before)
            num = tmp
        before = S[i]
        tmp = 0

if tmp == num:
    R.append(S[N-1])
elif tmp > num:
    R.clear()
    R.append(S[N-1])
    num = tmp

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

Submission status: Accepted

Solution code:
import collections
import itertools

# N枚の投票用紙
N = int(input())

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

counter = collections.Counter(s)

mode_v = counter.most_common()[0][-1]
it = itertools.takewhile(
    lambda kv: kv[-1] == mode_v, counter.most_common()
)

l_it=list(it)
l_it.sort()
for k, v in l_it:
    print(k)

Submission status: Accepted

Solution code:
n = int(input())
s_list = [input() for _ in range(n)]
most_list = []
counter_dict = {}
for s in s_list:
    if s in counter_dict:
        counter_dict[s] += 1
    else:
        counter_dict[s] = 1

sorted_counter = sorted(counter_dict.items(), key=lambda x: x[1], reverse=True)
ans = []
max_num = sorted_counter[0][1]
for c in sorted_counter:
    if max_num == c[1]:
        ans.append(c[0])
    else:
        break

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

Submission status: Accepted

Solution code:
n = int(input())
dic = {}
for i in range(n):
    a = input()
    if a not in dic.keys():
        dic[a] = 1
    else:
        dic[a] += 1
maxer = max(dic.values())
keys = [k for k, v in dic.items() if v == maxer]
keys.sort()
for i in range(len(keys)):
    print(keys[i])

Submission status: Accepted

Solution code:
table = dict()
mx = 0

for i in range(int(input())):
    s = input()
    tmp = table.get(s, 0) + 1
    table[s] = tmp
    if mx < tmp: mx = tmp

items = sorted(table.items(), key = lambda x: (-x[1], x[0]))

for item in items:
    if item[1] < mx: break
    print(item[0])

Submission status: Accepted

Solution code:
import collections

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

c = collections.Counter(ls)

cs = c.most_common()
mst = cs[0][1]

ans = []

for i in range(len(cs)):
    if mst == cs[i][1]:
        ans.append(cs[i][0])
    elif mst != cs[i][1]:
        break

ans.sort()

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

Submission status: Accepted

Solution code:
from collections import Counter
import bisect

N = int(input())
S = [input() for _ in range(N)] ## 縦一列


cnt = list(Counter(S).items())
cnt = sorted(cnt, key=lambda x: (-x[1], x[0]))

max_cnt = cnt[0][1]

lst = [cnt[i][1] for i in range(len(cnt))][::-1]
n_print = len(cnt) - bisect.bisect_left(lst, max_cnt)

for i in range(n_print):
  print(cnt[i][0])

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)

n = int(input())
d = {}

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

max_v = max(d.values())
kv_list = [kv for kv in d.items() if kv[1] == max_v]
kv_list.sort()
for kv in sorted(kv_list):
    print(kv[0])

Submission status: Accepted

Solution code:
import sys,collections,math,random,fractions,bisect;sys.setrecursionlimit(10**7)
sr = sys.stdin.readline; P = print; P2 = lambda x: print(*x, sep="\n")
def I(i=0): t = [int(x)-i for x in sr().split()];return t
def S(): t = sr().split(); return t if len(t) > 1 else t[0]
L1,L2,L3,L4, = [],[],[],[]
 
N, = I()
d = collections.defaultdict(int)
for _ in range(N):
    d[S()] += 1
maxvalue = max(d.values())
d = sorted(d.items(),key=lambda x: x[1])
d = sorted(d)
for e in d:
    if e[1] == maxvalue:
        print(e[0])

Submission status: Accepted

Solution code:
N = int(input())

dicts = {}

for _ in range(N):
    S = input()
    if S in dicts:
        dicts[S] += 1
    else:
        dicts[S] = 1

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

buf = dicts[0][1]
for k, v in dicts:
    if v == buf:
        max_list.append(k)
    else:
        break

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

Submission status: Accepted

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

c = Counter(l)
co = c.most_common()[0][1]
ans = []
for s in c.most_common():
  if s[1] < co:
    break
    
  ans.append(s[0])

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

Submission status: Accepted

Solution code:
N = int(input())
dic = {}
for _ in range(N):
    name = input()
    if name not in dic.keys():
        dic[name] = 1
    else:
        dic[name] += 1
max_num = 0
box = []
for v in dic.values():
    if v > max_num:
        max_num = v 
for k, v in dic.items():
    if max_num == v:
        box.append(k)
box = sorted(box)
for con in box:
    print(con)

Submission status: Accepted

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

SM = dict()
for s in S:
    if not s in SM:
        SM[s] = 0
    SM[s] += 1
ansM = sorted(SM.items(), key=lambda x: x[1], reverse=True)

count = ansM[0][1]
ans = list()
for a in ansM:
    if a[1] == count:
        ans.append(a[0])
    else:
        break

for a in list(sorted(ans)):
    print(a)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# https://atcoder.jp/contests/abc155/tasks/abc155_c

import collections
n = int(input())
buf = []
for _ in range(n):
    buf.append(input())
c = collections.Counter(buf)
max_count = c.most_common()[0][1]
ans = []
for k, v in c.items():
    if v == max_count:
        ans.append(k)
ans.sort()
for name in ans:
    print(name)

Submission status: Accepted

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

RList = []
R = 1

tmp = 1

for i in range(1, N):
    if NList[i] == NList[i - 1]:
        tmp += 1
    else:
        if R < tmp:
            R = tmp
            RList = [NList[i - 1]]
        elif R == tmp:
            RList.append(NList[i - 1])
        
        tmp = 1

if R < tmp:
    R = tmp
    RList = [NList[N - 1]]
elif R == tmp:
    RList.append(NList[N - 1])
    
for i in range(len(RList)):
    print(RList[i])

Submission status: Accepted

Solution code:
import collections

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

s = collections.Counter(s)
values, counts = zip(*s.most_common())

ans = []
c_be = counts[0]
for i, c in enumerate(counts):
    if c_be == c:
        ans.append(values[i])

ans.sort()

for a in ans:
    print(a)

Submission status: Accepted

Solution code:
n=int(input())
d={}
for i in range(n):
  j=input()
  if j not in d:
    d[j]=1
  else:
    d[j]+=1
  
n=d[max(d, key=d.get)]

l=[k for k, v in d.items() if v==n]
print(" ".join(sorted(l)))

Submission status: Accepted

Solution code:
import collections
# import math


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

    counter = collections.Counter(S)
    _, max_count = counter.most_common()[0]

    ans = []

    for key in counter:
        if (counter[key] == max_count):
            ans.append(key)

    ans.sort()

    for a in ans:
        print(a)


resolve()

Submission status: Accepted

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

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
        n = int(lines[0])
        for _ in range(n):
            lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]
        n = int(lines[0])
    
    s = lines[1:]


    return (n, s)


def solve(n, s):

    d = dict() 
    max_cnt = 0
    for i in range(n):
        cnt = d.get(s[i], 0)
        cnt = cnt + 1
        d[s[i]] = cnt
        if cnt > max_cnt:
            max_cnt = cnt

    result = []
    for word, cnt in d.items():    
        if cnt == max_cnt:
            result.append(word)

    result.sort()

    return  result


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()

Submission status: Accepted

Solution code:
import collections
n = int(input())

a = []
for _ in range(n):
    a.append(input())
#print(a)
b = collections.Counter(a).most_common()

c = []
d = b[0][1]
for i in range(len(b)):
    if b[i][1] != d:
        break
    c.append(b[i][0])
#print(c)
e = sorted(c)

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

Submission status: Accepted

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

def solve(N: int, S: "List[str]"):
    a=collections.Counter(S)
    c=a.most_common()[0][1]
    ans=[]
    for i in a:
        if a[i]==c:
            ans.append(i)
    ans.sort()

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


# 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]"
    solve(N, S)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import Counter
votes = []
for i in range(int(input())):
    votes.append(input())

result = Counter(votes).most_common()
winners = [x[0] for x in result if x[1] == result[0][1]]
for winner in sorted(winners):
    print(winner)

Submission status: Accepted

Solution code:
n=int(input())
d=dict()
while n>0:
    s=input()
    if d.get(s)==None:
        d[s]=1
    else:
        d[s]+=1
    n-=1
d2=sorted(d.items(),key=lambda x:x[1],reverse=True)
arr=[]
for i in d2:
    if i[1]==d2[0][1]:
        arr.append(i[0])
    else:
        break

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

Submission status: Accepted

Solution code:
from collections import Counter
from operator import itemgetter
N = int(input())
S = [input() for _ in range(N)]

L = Counter(S)
L = L.most_common()
maxi = L[0][1]
L.sort(key=itemgetter(0))

for i in range(len(L)):
    if L[i][1] == maxi:
        print(L[i][0])

Submission status: Accepted

Solution code:
n = int(input())
dict = {}
for _ in range(n):
    s = input()
    if s in dict:
        dict[s] += 1
    else:
        dict[s] = 0
max_val = max(dict.values())
max_list = [k for k, v in dict.items() if v == max_val]
max_list.sort()
for i in max_list:
    print(i)

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
l = Counter(s)
l_common = list(l.most_common())
max_n = l.most_common()[0][1]
l_common = sorted(l_common,key=lambda x:(x[1],x[0]))
for i,j in l_common:
  if j == max_n:
    print(i)

Submission status: Accepted

Solution code:
import collections

n = int(input())
#a,b = map(int,input().split())
#a_L = list(map(int,input().split()))
a_L = []
max_num = 0

for _ in range(n):
    s = input()
    a_L.append(s)

c = collections.Counter(a_L)

# for k,v in c:
#     print(k,v)
c = sorted(c.items(),key=lambda x: x[1],reverse=True)

max_num = c[0][1]

c = sorted(c,key=lambda x:x[0])
for k,v in c:
    if v == max_num:
        print(k)

Submission status: Accepted

Solution code:
import collections

n = int(input())

s = []
for _ in range(n):
    s.append(input())

c = collections.Counter(s)
common = c.most_common()
ans = []
idx = common[0][1]
for i in common:
    if idx == i[1]:
        ans.append(i[0])
    else:
        pass

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

Submission status: Accepted

Solution code:
from collections import Counter

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

c = Counter(s)

mostCommon = c.most_common()
count = mostCommon[0][1]
ans = []
ans.append(mostCommon[0][0])

for i in range(1, len(mostCommon)):
    if count == mostCommon[i][1]:
        ans.append(mostCommon[i][0])
    else:
        break

ans.sort()

for _ans in ans:
    print(_ans)

Submission status: Accepted

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


def solve(N: int, S: "List[str]"):
    d = {}
    for s in S:
        if s in d:
            d[s] += 1
        else:
            d[s] = 1

    maxv = 0
    res = []
    for k, v in sorted(d.items(), key=lambda x: -x[1]):
        if v >= maxv:
            res.append(k)
            maxv = v

    for s in sorted(res):
        print(s)
    return


# 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]"
    solve(N, S)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
''' Hey stalker :) '''
INF = 10**10
def main():
    print = out.append
    ''' Cook your dish here! '''
    n = get_int()
    li = [input() for _ in range(n)]
    cnt = Counter(li)
    st = []
    maxi = max(cnt.values())
    for i in cnt:
        if cnt[i]==maxi: st.append(i)
    st.sort()
    for i in st:
        print(i)


''' Pythonista fLite 1.1 '''
import sys
from collections import defaultdict, Counter
#from bisect import bisect_left, bisect_right
#from functools import reduce
#import math
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
out = []
get_int = lambda: int(input())
get_list = lambda: list(map(int, input().split()))
main()
#[main() for _ in range(int(input()))]
print(*out, sep='\n')

Submission status: Accepted

Solution code:
def run():
  N = int(input())
  di = {}
  for n in range(N):
    S = input()
    di.setdefault(S, 0)
    di[S] += 1
  count_max = max(di.items(), key=lambda x: x[1])[1]
  sorted_li = [k[0]  for k in sorted(di.items(), key=lambda x: x[0]) if k[1] == count_max]
  for s in sorted_li:
    print(s)

if __name__ == '__main__':
  run()

Submission status: Accepted

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

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

d_sorted = sorted(ds.items(), key=lambda x: x[0])
f_sorted = sorted(d_sorted, key=lambda x: x[1], reverse=True)

i = f_sorted[0][1]

for s in f_sorted:
    if s[1] == i:
        print(s[0])
    else:
        break

Submission status: Accepted

Solution code:
from collections import defaultdict

n = int(input())
d = defaultdict(int)

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

n = max(d.values())
ans = sorted(d.items())  
  
for ans_i in ans:
    if ans_i[1]==n:
      print(ans_i[0])

Submission status: Accepted

Solution code:
i=int(input())
l=[""]*i
for k in range(i):
  l[k]=input()
l.sort()
maxi=0
kosu=0
li=[]
subk=""
for k in l:
  if subk!=k:
    kosu=0
    subk=k
  kosu+=1
  if kosu==maxi:
    li.append(k)
  elif kosu>maxi:
    li.clear()
    li.append(k)
    maxi=kosu
for k in li:
  print(k)

Submission status: Accepted

Solution code:
import collections

n = int(input())
s_list = [input() for _ in range(n)]
s_cnt = collections.Counter(s_list)
s_sorted = s_cnt.most_common()
ans_list = [s[0] for s in s_sorted if s[1] == s_sorted[0][1]]
ans_list.sort()
for ans in ans_list:
    print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import collections
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    s = list()
    for i in range(n):
        s.append(str(input()).replace('\n', ''))

    c = dict(collections.Counter(s))
    max_count = max(c.values())
    ans = list()
    for k, v in c.items():
        if v == max_count:
            ans.append(k)

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
from collections import Counter

n = int(sys.stdin.readline().strip())

ss = []
counter = Counter()
for i in range(n):
    s = sys.stdin.readline().strip()
    counter[s] += 1
    ss.append(s)

count_items = counter.most_common()
count_max = count_items[0][1]
ans = []


for count_item in count_items:
    if count_max == count_item[1]:
        ans.append(count_item[0])
    else:
        break

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

Submission status: Accepted

Solution code:
N = int(input())
SL = []
for i in range(N):
    SL.append(input())
SL.sort()
t = 0
B=0
output = []
while t < N:
    A = SL[t]
    B += 1
    while (t<N-1)and(SL[t]==SL[t+1]):
        B+=1
        t+=1
    output.append([A,B])
    B=0
    t+=1
#
# if SL[N-1]!=SL[N-2]:
#     output.append([SL[N-1],1])

output.sort(key=lambda x:x[1],reverse=True)

print(output[0][0])
t = 1
while (t<len(output))and(output[t-1][1]==output[t][1]):
    print(output[t][0])
    t+=1

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
m = max(a.values())
l = []
for i,j in a.items():
    if j == m:
        l.append(i)
for i in sorted(l):
    print(i)

Submission status: Accepted

Solution code:
N = int(input())
d = {}
m = 0
s = set()
for _ in range(N):
  str = input()
  if str in s:
    d[str] += 1
  else :
    s.add(str)
    d[str] = 1
  m = max(m,d[str])
l = []
for _ in d.keys():
  if d[_] == m:
    l.append(_)
l.sort()
print(*l,sep="\n")

Submission status: Accepted

Solution code:
n = int(input())

al = {}
for i in range(n):
    a = input()
    if not a in al:
        al[a] = 1
    else:
        al[a] += 1

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

Submission status: Accepted

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

for s in S:
    if s not in ans:
        ans[s] = 1
    else:
        ans[s] += 1

n = max(ans.values())
l = []
for k, v in ans.items():
    if v== n:
        l.append(k)
l.sort()
for i in l:
    print(i)

Submission status: Accepted

Solution code:
from collections import Counter

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

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

res = []
for i in c:
    if c[i] == m:
        res.append(i)

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

Submission status: Accepted

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

for i in range(N):
	Si = input()
	if Si not in words.keys():
		words[Si] = 1
	else:
		words[Si] += 1

        
max_num = max(words.values())
max_words = [word for word, val in words.items() if val==max_num]
for word in sorted(max_words):
	print(word)

Submission status: Accepted

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

ans_d={s:0 for s in S_}
for s in S:
    ans_d[s]+=1

M=max(set(ans_d.values()))
for k,v in sorted(ans_d.items()):
    if v==M:
        print(k)

Submission status: Accepted

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

S=Counter(s)
c = S.most_common()[0][1]
values, counts = zip(*S.most_common())
res = []
for va, co in zip(values, counts):
  if co == c:
    res.append(va)
res = sorted(res)

for i in res:
  print(i)

Submission status: Accepted

Solution code:
# coding: utf-8
from collections import Counter
n = int(input())
s = [input() for i in range(n)]
res = dict(Counter(s))
res = sorted(res.items())
# print(res)
res = sorted(res, key=lambda x: x[1], reverse=True)
tmp = res[0][1]
for i,j in res:
    if tmp > j:
        break
    print(i)

Submission status: Accepted

Solution code:
#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    N = int(input())
    d = {}
    for i in range(N):
        s = input().strip()
        if s in d:
            d[s] += 1
        else:
            d[s] = 1

    ans = list(sorted(d.items(), key=lambda x: x[1], reverse=True))
    n = ans[0][1]
    ans2 = []
    for k, v in ans:
        if v != n: break
        ans2.append(k)
    for s in sorted(ans2):
        print(s)

if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
N = int ( input().strip() ) ;

dic = {} ;
r = -1 ;
for x in range ( N ) :
	s = input().strip() ;
	d = dic[s] if s in dic else 0;
	dic[s] = d + 1 ;

m = max( dic.values() ) ;
L = [] ;
for key in dic :
	if dic[key] != m : continue ;
	L.append( key ) ;
L.sort() ; 
for x in L : 
	print ( x ) ;

Submission status: Accepted

Solution code:
N=int(input())
d={}
for i in range(N):
    s=input()
    if s in d:
        d[s]+=1
    else:
        d[s]=1
ds=sorted(d.items(),key=lambda x:-x[1])
buf=[]
f=0
for sn in ds:
    s=sn[0]
    n=sn[1]
    if f==0:
        buf.append(s)
        nb=n
        f=1
    else:
        if n!=nb:
            break
        buf.append(s)
buf.sort()
for i in buf:
    print(i)

Submission status: Accepted

Solution code:
from collections import defaultdict

N = int(input())

polls = defaultdict(int)

max_poll = 0

for _ in range(N):
  k = input()
  polls[k] += 1
  max_poll = max(max_poll, polls[k])
  
for k in sorted([k for k in polls.keys() if polls[k] == max_poll]):
  print(k)

Submission status: Accepted

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

max_val = max(s_dic.values())
for s in sorted(s_dic):
    if s_dic[s] == max_val:
        print(s)

Submission status: Accepted

Solution code:
import collections

N = int(input())
l = [input() for _ in range(N)]
l = collections.Counter(l)
l = list(l.most_common())
sorted(l, key=lambda x: (-x[1], x[0]))
# print(l)
max_num = l[0][1]
values, counts = zip(*l)
ans = []
for i in range(len(l)):
    if l[i][1] != max_num:
        break
    # print(values[i])
    ans.append(l[i][0])
ans.sort()
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
import collections

n = int(input())
list = []
for x in range(n):
    s = input()
    list.append(s)
c = collections.Counter(list)
mc = c.most_common()
max = mc[0][1]
anslist = []
for val in mc:
    if max == val[1]: anslist.append(val[0])
    else: break
anslist.sort()
for x in anslist:
    print(x)

Submission status: Accepted

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

count = {}
for s_i in s:
    if not s_i in count:
        count[s_i] = 0
    count[s_i] += 1
res = sorted(zip(count.keys(), count.values()),
             key=lambda x: x[1], reverse=True)

num = res[0][1]
res2 = []
for res_i in res:
    if res_i[1] != num:
        break
    res2.append(res_i[0])

res2.sort()
for res2_i in res2:
    print(res2_i)

Submission status: Accepted

Solution code:
n = int(input())
s = {}
mx = 0
for i in range(n):
    c = input()
    if c in s:
        s[c] += 1
    else:
        s[c] = 1
    mx = max(s[c], mx)
res = []

for key in s:
    if s[key] == mx:
        res.append(key)
for c in sorted(res):
    print(c)

Submission status: Accepted

Solution code:
N = int(input())
vote = []
for i in range(N):
    s = input()
    vote.append(s)
vote = sorted(vote)
vote.append("zzzzzzzzzzz")

if N == 1:
    ans = [vote[0]]
else:
    ans = []
    num = 1
    M = 0
    for i in range(1,N+1):
        if vote[i] == vote[i-1]:
            num += 1
        else:
            name = vote[i-1]
            if num == M:
                ans.append(name)
                num = 1
            elif num > M:
                ans = [name]
                M = num
                num = 1
            else:
                num = 1
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
import collections

N = int(input())
S = [input() for n in range(N)]
S = collections.Counter(S)
M = S.most_common()[0][1]
S = sorted(S.items(), key=lambda _: _[0])
for s in S:
    if s[1] == M:
        print(s[0])

Submission status: Accepted

Solution code:
import collections

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

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

c = collections.Counter(S)


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

for k,v in dict(c).items():
        if v != num:
                continue
        else:
                ans.append(k)

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

Submission status: Accepted

Solution code:
n = int(input())
a = {}
for i in range(n):
  s = input()
  a[s] = a.get(s,0) + 1
max_a = max(a.values())
b = sorted([i for i in a.keys() if a[i]==max_a])
[print(i) for i in b]

Submission status: Accepted

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

m = 0
for k in s:
    m = max(m, s[k])

ans = []
for k in s:
    if s[k] == m:
        ans.append(k)
ans.sort()
for a in ans:
    print(a)

Submission status: Accepted

Solution code:

word = {}

cnt = int(input())

for i in range(0,cnt):
    w = input()
    if w not in word:
        word[w] = 1
    else:
        word[w] += 1

m = max(word.values())
search = [i for i in word.keys() if word[i] == m]
[print(i) for i in sorted(search)]

Submission status: Accepted

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

d_sort = sorted(d.items())
max_val = max(d.values())

for s, val in d_sort:
  if val==max_val:print(s)