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
input = sys.stdin.readline
N = int(input())
S = []
for _ in range(N):
    s = input().replace("\n", "")
    S.append(s)
S.sort()
f = 0
tres = 0
res = [S[0]]
for i in range(1, N):
    if S[i] == S[i-1]:
        f += 1
    else:
        f = 0
    if f == tres:
        res.append(S[i])
    elif f > tres:
        tres = f
        res = [S[i]]

print("\n".join(map(str, res)))

Submission status: Accepted

Solution code:
import sys
N = int(input())
d = {}
max = 0

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

A = []

for k in d:
    if d[k]==max:
        A.append(k)

A.sort()

for a in A:
    print(a)

Submission status: Accepted

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

m = max(count_dict.values())
for e in sorted(k for k in count_dict if count_dict[k] == m):
    print(e)

Submission status: Accepted

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

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

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

    d_m = max(d.values())
    m_list = [kv[0] for kv in d.items() if kv[1] == d_m]
    m_list = sorted(m_list)
    print('\n'.join(m_list))

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
from collections import Counter

n = int(sys.stdin.readline().rstrip())
s = sys.stdin.read().split()

def main():
    c = Counter(s)
    ma = max(c.values())
    res = []
    for l, v in c.items():
        if v == ma:
            res.append(l)
    return sorted(res)

if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n')

Submission status: Accepted

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

ans = []
count = 1
max_count = 0

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

    else:
        if count > max_count:
            ans = [s[i]]
            max_count = count
            count = 1
        elif count == max_count:

            ans += [s[i]]
            count = 1
        else:
            count = 1

for a in ans:
    print(a)

Submission status: Accepted

Solution code:
N = int(input())
words = dict()
for i in range(N):
    w = input()
    if w in words:
        words[w] -= 1
    else:
        words[w] = -1
        
wd_list = list()
for w,c in words.items():
    wd_list.append((c,w))  # Tupple of count(rev), word
    
wd_list.sort()
max_c = wd_list[0][0]
for w in wd_list:
    if w[0] != max_c:
        break
    print(w[1])

Submission status: Accepted

Solution code:
#標準入力からの値取得(N)
N = int(input())
#標準入力からの値取得(List)
S = []
for i in range(N):
  S.append(input())
#ループで廻しつつ要素数をカウントする
ans = {}
for cnt in S:
  if cnt in ans:
    ans[cnt] += 1
  else:
  	ans[cnt] = 1
max_v = max(ans.values())
#ソートしながら出力。辞書をソートするとリストになるので注意。
for k, v in sorted(ans.items()):
  if v == max_v:
    print(k)

Submission status: Accepted

Solution code:
n = int(input())
dic = {}
m = 0
for i in range(n):
  s = input()
  if s in dic:
    dic[s] += 1
    m = max(m, dic[s])
  else:
    dic[s] = 1
    m = max(m, dic[s])
ans = []
for s in dic:
  if dic[s] == m:
    ans.append(s)
print('\n'.join(sorted(ans)))

Submission status: Accepted

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

for i in range (n):
  key=input()
  if key not in dic:
    dic[key]=1
  else:
    dic[key]+=1
    
max_v=max(dic.values())

ls=sorted(list(filter(lambda key:dic[key]==max_v,list(dic))))

for key in ls:
  print (key)

Submission status: Accepted

Solution code:
n = int(input())
s = [input() for i in range(n)]
s.sort()
ans = []
c = 1
max = 0
for i in range(1, n):
    if s[i - 1] == s[i]:
        c += 1
    else:
        if c == max:
            ans.append(s[i - 1])
        elif c > max:
            ans.clear()
            ans.append(s[i - 1])
            max = c
        c = 1
if c == max:
    ans.append(s[-1])
elif c > max:
    ans.clear()
    ans.append(s[n - 1])
for des in ans:
    print(des)

Submission status: Accepted

Solution code:
import collections
N = int(input())
l=[]
for i in range(N):
    l.append(input())
c = collections.Counter(l)
values, counts = zip(*c.most_common())
s=len(values)
l=[]
for i in range(s):
    l.append(values[i])
    if i!=s-1 and counts[i] != counts[i+1]:
        break
l=sorted(l)
for i in l:print(i)

Submission status: Accepted

Solution code:
import collections

n = int(input())
s = [input() for _ in range(n)]
c_sort = collections.Counter(s).most_common()
list_most = [c_sort[i][0] for i in range(len(c_sort)) if c_sort[i][1] == c_sort[0][1]]
for i in sorted(list_most):
    print(i)

Submission status: Accepted

Solution code:
from collections import Counter
n, cnt, mx, arr = int(input()), Counter(), -1, []
for i in range(n):
    s = input()
    arr.append(s)
    cnt[s] += 1
    mx = max(mx,cnt[s])
res = []
for i in arr:
    if cnt[i] == mx:
        res.append(i)
        cnt[i] = 0
res.sort()
for i in res:
    print(i)

Submission status: Accepted

Solution code:
import collections

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

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

for alpha, beta in count.items():
    if beta == max_count:
        ans.append(alpha)
ans.sort()
print("\n".join(ans))

Submission status: Accepted

Solution code:
n=int(input())
poll={}
m=0
rtn=[]
for v in range(n):
    s=input()
    if s in poll:
        poll[s]+=1
        if poll[s]>m:
            m=poll[s]
    else:
        poll[s]=0
for s in poll:
    if poll[s]==m:
        rtn.append(s)
rtn.sort()
for x in rtn:
    print(x)

Submission status: Accepted

Solution code:
from collections import Counter

def main():
    n = int(input())
    s = [input() for _ in range(n)]
    C = Counter(s)
    mx = max(C.values())
    ans = []
    for k,v in C.items():
        if v == mx:
            ans.append(k)
    ans.sort()
    print("\n".join(ans))


if __name__ == "__main__":
    main()

Submission status: Accepted

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

ans = []
counter = 1
memo = 0

for i in range(1, N):
    if S[i] == S[i-1]:
        counter += 1
    else:
        if counter == memo:
            ans.append(S[i-1])
        elif counter > memo:
            ans.clear()
            ans.append(S[i-1])
            memo = counter
        counter = 1
if counter == memo:
    ans.append(S[N-1])
elif counter > memo:
    ans.clear()
    ans.append(S[N-1])
    memo = counter
for a in ans:
    print(a)

Submission status: Accepted

Solution code:
from collections import Counter

def main():
    n = int(input())
    s = [input() for _ in range(n)]
    C = Counter(s)
    cl = C.most_common()
    mx = cl[0][1]
    ans = []
    for c in cl:
        if (c[1] == mx):
            ans.append(c[0])
        else:
            break
    ans.sort()
    for i in ans:
        print(i)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N=int(input())
L=[input() for i in range(N)]
L.sort()
c=1
memo=0
ans=[]
for i in range(1,N):
  if L[i]==L[i-1]:
    c+=1
  else:
    if c==memo:
      ans.append(L[i-1])
    elif c>memo:
      ans.clear()
      ans.append(L[i-1])
      memo=c
    c=1
if c==memo:
  ans.append(L[N-1])
elif c>memo:
  ans.clear()
  ans.append(L[N-1])
for i in range(len(ans)):
  print(ans[i])

Submission status: Accepted

Solution code:
from collections import defaultdict
n=int(input())
s=defaultdict(lambda: 0)
m=-1
for _ in range(n):
    k=input()
    s[k] += 1
    m=max(s[k],m)
for x in sorted([k for k,v in s.items() if v==m]):
    print(x)

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())
a = [input() for x in range(n)]
b = Counter(a)
c = max(b.values())
s = [s for s, g in b.items() if g == c]
s.sort()
print('\n'.join(s))

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    dic = {}
    mx = 0
    for i in range(n):
        s = input()
        if s in dic:
            dic[s] += 1
        else:
            dic[s] = 1
        mx = max(mx,dic[s])
    l = []
    for k,v in dic.items():
        if v == mx:
            l.append(k)
    l.sort()
    for i in l:
        print(i)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    dic = {}
    mx = 0
    for i in range(n):
        s = input()
        if s in dic:
            dic[s] += 1
        else:
            dic[s] = 1
        mx = max(mx,dic[s])
    l = []
    for k,v in dic.items():
        if v == mx:
            l.append(k)
    l.sort()
    for i in range(len(l)):
        print(l[i])


if __name__ == "__main__":
    main()

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 i in d:
    if d[i] == m:
        ans.append(i)
ans.sort()
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
def main():
    dic = {}
    n = int(input())
    for i in range(n):
        s = input().rstrip()
        if s in dic.keys():
            dic[s] += 1
        else:
            dic[s] =  1
    m = 0
    for v in dic.values():
        if m < v:
            m = v
    s_dic = sorted(dic.items(), key=lambda x:x[0])
    for k, v in s_dic:
        if v == m:
            print(k)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from collections import Counter

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

c = Counter(S)
most_cnt = 0

for v in c.values():
    most_cnt = max(most_cnt, v)
    
ans = []
for k, v in c.items():
    if v == most_cnt:
        ans.append(k)
ans.sort()
print(*ans, sep="\n")

Submission status: Accepted

Solution code:
from operator import itemgetter
import datetime

n = int(input())
sn = dict()

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

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

max_val = max(dict(sn).values())

for si in sn:
    if(int(si[1]) == max_val):
        print(si[0])
    else:
        break

Submission status: Accepted

Solution code:
import collections


N = int(input())
S = [input() for _ in range(N)]
c = collections.Counter(S)
values, counts = zip(*c.most_common())
ans = []
if len(values) == 1:
    ans.append(values[0])
else:
    for i in range(N):
        if counts[i] == counts[0]:
            ans.append(values[i])
        else:
            break
ans.sort()
for i in range(len(ans)):
    print(ans[i])

Submission status: Accepted

Solution code:
N = int(input())
d = dict()

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

maxi = 0
ans = []
for key, val in d.items():
    if val > maxi:
        maxi = val
        ans = [key]
    elif val == maxi:
        ans.append(key)

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

Submission status: Accepted

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

def main():
    n=int(input())
    S=[input().strip() for _ in range(n)]
    C=Counter(S)
    cnt=C.most_common()[0][1]
    Ans=[]
    for key,val in C.items():
        if val==cnt:
            Ans.append(key)
    Ans.sort()
    print(*Ans,sep='\n')
    
if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
from collections import*
_,*s=open(0)
c=Counter(s).most_common()
print(*sorted(a*(b==c[0][1])for a,b in c))

Submission status: Accepted

Solution code:
n = int(input())
dict = {}
mx = 0
for i in range(n):
    s = input()
    if s not in dict:
        dict[s] = 0
    dict[s] += 1
    mx = max(mx, dict[s])
ans = []
for s in dict:
    if dict[s] == mx:
        ans.append(s)
ans.sort()
for s in ans:
    print(s)

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_max = max(d.values())
ans = [k for k, v in d.items() if v == d_max]
for a in sorted(ans):
    print (a)

Submission status: Accepted

Solution code:
n = int(input())
l = [input() for i in range(n)]
l.sort()
c = 1
ans = []
m = 0
for i in range(n-1):
    if l[i] == l[i+1]:
        c += 1
    else:
        if c > m:
            ans.clear()
            ans.append(l[i])
            m = c
        elif c == m:
            ans.append(l[i])
        c = 1
if m == 1:
    ans.append(l[-1])
elif c > m:
    ans.clear()
    ans.append(l[-1])
    m = c
elif c == m:
    ans.append(l[-1])
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
import collections
c = collections.Counter([input() for i in range(int(input()))])
c = c.most_common()
pre = c[0][1]
ans = []
for key,val in c:
  if val < pre:
    break
  ans.append(key)
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):
  a=input()
  s.append(a)
c=Counter(s)

mx=max(c.values())
ans=[]
for i in c:
  if c[i]==mx:
    ans.append(i)
ans.sort()
for i in ans:
  print(i)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#import sys; sys.stdin=open('input_file.txt')
#------------------------------------------
from collections import defaultdict
import sys
input = sys.stdin.readline
N = int(input())
D = defaultdict(int)
for i in range(N):
    D[input().rstrip()] += 1
A = []
maxv = 0
for k,v in sorted(D.items(),key=lambda x:x[1],reverse=True):
    if maxv > v:
        break
    maxv = v
    A.append(k)
A.sort()
print('\n'.join(A))

Submission status: Accepted

Solution code:
from collections import Counter
c=Counter()
n=int(input())
lis=[]
for _ in range(n):
    lis.append(input())
for x in lis:
    c[x]+=1

max=0
for k,v in c.items():
    if max<v:
        max=v

lis=[]
for k,v in c.items():
    if max==v:
        lis.append(k)
lis.sort()
for x in lis:
    print(x)

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
c = Counter(s)
m = 0
for v in c.values():
	m = max(m, v)
ans = []
for k, v in c.items():
	if v == m:
		ans.append(k)
ans.sort()
print(*ans, sep="\n")

Submission status: Accepted

Solution code:
from sys import stdin

import collections

def main():

    input = stdin.readline

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

    for _ in range(A):
        S.append(input()[:-1])

    c = collections.Counter(S)

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

    S_ans = []
    for value,key in c.most_common():
        if(key == maxnum):
            S_ans.append(value)
        else:
            break

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

ans=[]
for i in s.keys():
  if s[i]==mx:
    ans.append(i)
ans.sort()
for i in ans:
  print(i)

Submission status: Accepted

Solution code:
import collections

n = int(input())
s = [str(input()) for _ in range(n)]
word_dict = collections.Counter(s)
maxVal = max(word_dict.values())
max_list = [key for key, value in word_dict.items() if value == maxVal]
max_list.sort()
for item in max_list:
    print(item)

Submission status: Accepted

Solution code:
from collections import Counter

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

S_Counter=Counter(S)
Max=max(set(S_Counter.values()))

print('\n'.join(sorted(s for s,v in S_Counter.items() if v==Max)))

Submission status: Accepted

Solution code:
from collections import Counter

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

S_Counter=Counter(S)
Max=max(S_Counter.values())

print('\n'.join(sorted(s for s,v in S_Counter.items() if v==Max)))

Submission status: Accepted

Solution code:
from collections import Counter

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

counter = Counter(S)
count = counter.most_common()
most = count[0][1]
c = []

for i in range(len(counter)):
    if count[i][1] == most:
        c.append(count[i][0])

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

Submission status: Accepted

Solution code:
import unittest


class TestC(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think(['beat', 'vet', 'beet', 'bed', 'vet', 'bet', 'beet']), ['beet', 'vet'])

    def test_2(self):
        self.assertEqual(think(['buffalo', 'buffalo', 'buffalo', 'buffalo', 'buffalo', 'buffalo', 'buffalo', 'buffalo']), ['buffalo'])

    def test_3(self):
        self.assertEqual(think(['bass', 'bass', 'kick', 'kick', 'bass', 'kick', 'kick']), ['kick'])

    def test_4(self):
        self.assertEqual(think(['ushi', 'tapu', 'nichia', 'kun']), ['kun', 'nichia', 'tapu', 'ushi'])


def solve():
    s = read()
    result = think(s)
    write(result)


def read():
    n = read_int(1)[0]
    s = []
    for _ in range(n):
        s.append(read_line())
    return s


def read_int(n):
    return read_type(int, n, sep=' ')


def read_float(n):
    return read_type(float, n, sep=' ')


def read_type(t, n, sep):
    return list(map(lambda x: t(x), read_line().split(sep)))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(s):
    d = {}
    for e in s:
        d[e] = d.get(e, 0) + 1
    maximum = 0
    for key, value in d.items():
        maximum = max(maximum, value)
    result = []
    for key, value in d.items():
        if value == maximum:
            result.append(key)
    result.sort()
    return result


def write(result):
    for r in result:
        print(r)


if __name__ == '__main__':
    # unittest.main()
    solve()

Submission status: Accepted

Solution code:
##C
N = int(input())
S = list(input() for i in range(N))

import collections

c = collections.Counter(S).most_common()
a,b = c[0]
ans = list()
for j,k in c:
    if k == b:
        ans.append(j)
    else:
        break
        
ans.sort()
for l in ans:
    print(l)

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())

l = [input() for i in range(n)]

c = Counter(l)

ml = c.most_common()
mc = ml[0][1]

ml.sort()

for i in ml:
    if i[1] == mc:
        print(i[0])

Submission status: Accepted

Solution code:
import sys
from collections import Counter
input = sys.stdin.readline
N = int(input())
S = [input() for _ in range(N)]

c = Counter(S)
max_c = max(c.values())
names = [name for name, cnt in c.items() if cnt == max_c]
names.sort()
print(*names, sep='\n')

Submission status: Accepted

Solution code:
n = int(input())
l = dict()
for i in range(n):
    s = input()
    if s not in l:
        l[s]=1
    else:
        l[s]+=1
l1 = []
for i in l:
    l1.append((l[i],i))
l1.sort()
l1 = l1[::-1]
p=0
#print(l1)
l2 = []
l2.append(l1[0][1])
for i in range(len(l1)-1):
    if l1[i][0]==l1[i+1][0]:
        l2.append(l1[i+1][1])
        p=i
    else:
        break
l2.sort()

for i in l2:
    print(i)

Submission status: Accepted

Solution code:
import collections
N=int(input())
L=[input() for _ in range(N)]
K=collections.Counter(L).most_common()
bv, bk=K[0]
#print(bk)
ANS=[]
for v,k in K:
  if bk == k:
    ANS.append(v)
  else:
    break
S=sorted(ANS)
[print(s) for s in S]

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

M = max(d.values())
for j,k in sorted(d.items()):
  if k == M:
    print(j)

Submission status: Accepted

Solution code:
from collections import Counter
N=int(input())
Ss=[input() for i in range(N)]
Ss=Counter(Ss).most_common()
mincount=Ss[0][1]
ans=[]
for s in Ss:
    if s[1]==mincount:
        ans.append(s[0])
for a in sorted(ans):
    print(a)

Submission status: Accepted

Solution code:
n = int(input())
data_list = []
for _ in range(n):
    data_list.append(input(""))

data_list_a = set(data_list)
data_list_a = list(data_list_a)
m = len(data_list_a)

data_a = [0 for _ in range(m)]

data_dic = dict(zip(data_list_a, data_a))

for i in range(n):
    data_dic[data_list[i]] += 1

data_score = data_dic.values()
max_value = max(data_score)
ans = []


for i in range(m):
    if data_dic[data_list_a[i]] == max_value:
        ans.append(data_list_a[i])


ans.sort()

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

Submission status: Accepted

Solution code:
import sys
input_first = input()
N= int(input_first)

worddic={}

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

# result=[keyval[0] for keyval in worddic.items() if keyval[1]==max(worddic.values())]

maxval = 0
for i in worddic.items():
    if i[1] > maxval :
        maxval = i[1]
        result=[]
        result.append(i[0])
    elif i[1] == maxval:
        result.append(i[0])
    else:
        pass

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

Submission status: Accepted

Solution code:
n = int(input())
dic = {}
for _ in range(n):
    s = input()
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 0
top = []
laeger = 0
for v in dic.values():
    if v >= laeger:
        laeger = v

for k, v in dic.items():
    if v == laeger:
        top.append(k)
for i in sorted(top):
    print(i)

Submission status: Accepted

Solution code:
N=int(input())
S = []
for j in range(N):
    S.append(input())
import collections
S2=collections.Counter(S)
S1=S2.most_common()

S3=[]
S3.append(S1[0][0])
for i in range(1,len(S1)):
    if S1[i][1]==S1[0][1]:
        S3.append(S1[i][0])
    else:
        break
S3=sorted(S3)
for i in range(0, len(S3)):
    print(S3[i])

Submission status: Accepted

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

def main():
    N = int(input())
    c = Counter()
    m = 0
    S = [input() for i in range(N)]
    for s in S:
        c[s] += 1
        m = max(m, c[s])

    ans = sorted([k for k, v in c.items() if v == m])
    print('\n'.join(ans))
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import *
N = int(input())
c = Counter()
m = 0

for i in range(N):
    S = input()
    c[S] += 1
    m = max(m, c[S])

ans = sorted([k for k, v in c.items() if v == m])
print('\n'.join(ans))

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())
sl = list(input() for _ in range(n))

cnt = Counter(sl)
# print('cnt:', cnt)
maxNum = max(cnt.values())
# print('maxNum:', maxNum)

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

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

Submission status: Accepted

Solution code:
n,*s=map(str,open(0).read().split())
from collections import*
c=Counter(s).most_common()
maxm=c[0][1]
ans=[]
for i,j in c:
  if maxm==j:
    ans+=i,
for b in sorted(ans):
  print(b)

Submission status: Accepted

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


def main():
    from collections import Counter

    n = int(input())
    s = [input() for _ in range(n)]
    c = Counter(s)
    max_value = max(c.values())
    ans = list()

    for key, value in c.items():
        if value == max_value:
            ans.append(key)

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


if __name__ == '__main__':
    main()

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
S=sorted(S.items(),key=lambda x:(-x[1],x[0]))
Max=S[0][1]
for k,v in S:
    if v!=Max:
        break
    print(k)

Submission status: Accepted

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


def main():
    from collections import Counter

    n = int(input())
    s = [input() for _ in range(n)]
    c = sorted(Counter(s).items(), key=lambda x: x[1], reverse=True)
    max_value = c[0][1]
    ans = list()

    for key, value in c:
        if value == max_value:
            ans.append(key)

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
a={}
for _ in range(n):
    s=input()
    if(s in a):
        a[s]+=1
    else:
        a[s]=1
a=sorted(a.items(),key=lambda x:x[1],reverse=True)
b=[]
b.append(a[0][0])
for j in a[1:]:
    if(j[1]==a[0][1]):
        b.append(j[0])
    else:
        break
for t in sorted(b):
    print(t)

Submission status: Accepted

Solution code:
n=int(input())
a=[]
for i in range(n):
   a.append(input())
a.sort()
d={}
for i in range(n):
    if a[i] not in d:
        d[a[i]]=1
    else:
        d[a[i]]+=1
all_values=d.values()
m=max(all_values)
l=[]
for i in d:
    if d[i]==m:
        l.append(i)
l.sort()
for i in l:
    print(i)

Submission status: Accepted

Solution code:
n=int(input())
s=[input() for _ in range(n)]
ans={}
for i in range(len(s)):
    if(s[i] not in ans):
        ans[s[i]] = 1
    else:
        ans[s[i]] += 1
ans=sorted(ans.items(), key = lambda x:x[1], reverse = True)
anss=[]
anss.append(ans[0][0])
for j in range(1,len(ans)):
    if(ans[j][1] == ans[0][1]):
        anss.append(ans[j][0])
    else:
        break
for t in sorted(anss):
    print(t)

Submission status: Accepted

Solution code:
N = int(input())
S = []
maxnum = 0
maxyouso = {}
anslist = []
for kai in range (N):
    S.append(input())
for moji in S:
    if moji not in maxyouso:
        maxyouso[moji] = 1
    else:
        maxyouso[moji] = maxyouso[moji] + 1
for num in maxyouso:
    if maxyouso[num] > maxnum:
        maxnum = maxyouso[num]
for num in maxyouso:
    if maxyouso[num] == maxnum:
        anslist.append(num)
anslist.sort()
for k in anslist:
    print(k)

Submission status: Accepted

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

from collections import Counter

N = int(input())
S = [input().rstrip().decode() for _ in range(N)]
S = Counter(S)
max_S = max(S.values())

name = sorted([k for k, v in S.items() if v == max_S])
print(*name, sep="\n")

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 i in d :
    if d[i] == m :
        ans.append(i)
ans.sort()
for i in ans:
    print(i)

Submission status: Accepted

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

dict_maxval=max(dict.values())
    
res = [k for k, v in dict.items() if v == dict_maxval]
res.sort()
for word in res:
  print(word)

Submission status: Accepted

Solution code:
from collections import Counter
n=int(input())
s=[input() for i in range(n)]
c=Counter(s)
t=[]
u=c.most_common()
v=u[0][1]
t.append(u[0][0])
for i in range(1,len(c)):
  a=u[i][1]
  if v>a:
    break
  else:
    t.append(u[i][0])
t.sort()
for i in t:
  print(i)

Submission status: Accepted

Solution code:
from collections import Counter

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

c = Counter(a)
list = c.most_common()
max = list[0][1]

ans = []
for i, j in list:
    if j == max:
        ans.append(i)
    else:
        break

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

Submission status: Accepted

Solution code:
import collections

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

c=collections.Counter(S)
tmp=c.most_common()[0][1]
m=sorted(c.most_common())
for i in m:
    if(i[1]==tmp):
        print(i[0])

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
maximum = 0
s_list = None
for s, t in d.items():
  if maximum < t:
    maximum = t
    s_list = [s]
  elif maximum == t:
    s_list.append(s)
s_list.sort()
for s in s_list:
  print(s)

Submission status: Accepted

Solution code:
from collections import defaultdict

N = int(input())
S = defaultdict(int)

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

poll = defaultdict(list)
for k, v in S.items():
    poll[v].append(k)

ans = sorted(poll[max(poll.keys())])

for a in ans:
    print(a)

Submission status: Accepted

Solution code:
from collections import Counter
n=int(input())
a=[input() for _ in range(n)]
cal=Counter(a)
#print(cal)
m=0
for i in cal.keys():
    val=cal[i]
    m=max(m,val)
#print(val)
ans=[]
for i in cal.keys():
    val=cal[i]
    if val==m:
        ans.append(i)
ans.sort()
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
from collections import defaultdict
n = int(input())
s = [input() for _ in range(n)]
dd = defaultdict(int)

for x in s:
    dd[x] += 1
mx = max(dd.values())

for k in sorted(j for j,y in dd.items() if y == mx):
    print(k)

Submission status: Accepted

Solution code:
N=int(input())
S=[]
for i in range(N):
    s=input()
    S.append(s)
m=1
x=dict()
for i in range(N):
    if S[i] in x:
        x[S[i]]+=1
        m=max(m,x[S[i]])
    else:
        x[S[i]]=1
l=[]
for idx in x:
    if x[idx]==m:
        l.append(idx)
l.sort()
for i in range(len(l)):
    print(l[i])

Submission status: Accepted

Solution code:
poll_table = {}

poll_times = int(input())

max_poll = 0

for i in range(poll_times):
  polled = input()
  if polled in poll_table.keys():
    poll_table[polled] += 1
  else:
    poll_table[polled] = 1

  if max_poll < poll_table[polled]:
    max_poll = poll_table[polled]

max_list = []
for key in poll_table.keys():
  if poll_table[key] == max_poll:
    max_list.append(key)

max_list.sort()

for polled in max_list:
  print(polled)

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
CS = Counter(S)
v = 0
ans = []
for i  in CS.values():
  v = max(v,i)
for j,k in CS.items():
  if v == k:
    ans.append(j)
ans.sort()
print(*ans,sep="\n")

Submission status: Accepted

Solution code:
# coding: utf-8
if __name__ == '__main__':
    dic = dict()
    n = int(input())
    for i in range(n):
        val = input()
        if val in dic.keys():
            dic[val]+=1
        else:
            dic[val]=1
    max_keys = max(dic.values())
    values_of_max_key = [val for val in dic if dic[val] == max_keys]
    sorted_values_of_max_key = sorted(values_of_max_key)
    for s in sorted_values_of_max_key:
        print(s)

Submission status: Accepted

Solution code:
n = int(input())
d = {}
for i in range(n):
    s = input()
    d[s] = d[s]+1 if (s in d) else 1
d_sorted = sorted(d.items(), key=lambda x:x[1], reverse=True)
m = d_sorted[0][1]
result = []
for i in d_sorted:
    if i[1]!=m:
        break
    result.append(i[0])
print(*sorted(result), sep='\n')