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

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('c1.in')


def read_int_list():
    return list(map(int, input().split()))


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


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    N = read_int()
    s = []
    for i in range(N):
      S = read_str()
      s.append(S)
    s.sort()
    s.append('')

    res = []
    M = -1
    m = 1
    for i in range(1, N+1):
      if s[i-1] == s[i]:
        m += 1
      else:
        if m == M:
          res.append(s[i-1])
        if m > M:
          M = m
          res = [s[i-1]]
        m = 1
    print(*res, sep='\n')


def main2():
    N = read_int()
    s = []
    for i in range(N):
      S = read_str()
      s.append(S)

    d = dict()
    for i in range(N):
      if s[i] not in d:
        d[s[i]] = 0
      d[s[i]] += 1
    # print(d)

    M = -1
    for key, value in d.items():
      if value > M:
        M = value
    # print(M)

    res = []
    for key, value in d.items():
      if value == M:
        res.append(key)
    res.sort()
    print(*res, sep='\n')



def main3():
    N = read_int()
    s = []
    for i in range(N):
      S = read_str()
      s.append(S)

    d = Counter(s)
    
    M = -1
    for key, value in d.items():
      if value > M:
        M = value
    # print(M)

    res = []
    for key, value in d.items():
      if value == M:
        res.append(key)
    res.sort()
    print(*res, sep='\n')


main3()

Submission status: Accepted

Solution code:
import collections
N = int(input())
List=[input() for i in range(N)]
 
c = collections.Counter(List)
c_sorted = sorted(c.items(), key=lambda x:x[1],reverse=True)
 
maxCount = c_sorted[0][1]
keys = [k for k, v in c.items() if v ==maxCount]
keys.sort()
for s in keys:
    print(s)

Submission status: Accepted

Solution code:
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('c1.in')


def read_int_list():
    return list(map(int, input().split()))


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


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    N = read_int()
    s = []
    for i in range(N):
      S = read_str()
      s.append(S)
    s.sort()
    s.append('')

    res = []
    M = -1
    m = 1
    for i in range(1, N+1):
      if s[i-1] == s[i]:
        m += 1
      else:
        if m == M:
          res.append(s[i-1])
        if m > M:
          M = m
          res = [s[i-1]]
        m = 1
    print(*res, sep='\n')


def main2():
    N = read_int()
    s = []
    for i in range(N):
      S = read_str()
      s.append(S)

    d = dict()
    for i in range(N):
      if s[i] not in d:
        d[s[i]] = 0
      d[s[i]] += 1
    # print(d)

    M = -1
    for key, value in d.items():
      if value > M:
        M = value
    # print(M)

    res = []
    for key, value in d.items():
      if value == M:
        res.append(key)
    res.sort()
    print(*res, sep='\n')

main2()

Submission status: Accepted

Solution code:
from collections import Counter
n=int(input())
f=[]
for i in range(n):
    s=input()
    f.append(s)
d=dict(Counter(f))
#print(d)
f=[]
kk=max(d.values())
for key,value in d.items():
    if value==kk:
        f.append(key)
f.sort()
for x in f:
    print(x)

Submission status: Accepted

Solution code:
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('c1.in')


def read_int_list():
    return list(map(int, input().split()))


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


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    N = read_int()
    s = []
    for i in range(N):
      S = read_str()
      s.append(S)
    s.sort()
    s.append('')

    res = []
    M = -1
    m = 1
    for i in range(1, N+1):
      if s[i-1] == s[i]:
        m += 1
      else:
        if m == M:
          res.append(s[i-1])
        if m > M:
          M = m
          res = [s[i-1]]
        m = 1
    print(*res, sep='\n')


main()

Submission status: Accepted

Solution code:
N = int(input())
S = [input() for i in range(N)]
S.sort()
k = [0]* (N - 1)
for i in range(N - 1):
    if S[i] == S[i + 1]:
        k[i] = 1
if k == [0]* (N-1):
    for i in range (N):
        print(S[i])
else:
    t = [0]*(N-1)
    for i in range(N-1):
        if k[i] == 0:
            t[i] = 0
        else:
            t[i] = t[i - 1] + 1
    M = max(t)
    for i in range (N-1):
        if t[i] == M:
            print(S[i])

Submission status: Accepted

Solution code:
# C - Poll
from collections import Counter


def main():
    _, *S = open(0).read().split()
    cnt = Counter(S)
    max_votes = max(cnt.values())
    ans = [k for k, v in cnt.items() if v == max_votes]
    ans.sort()
    print("\n".join(ans))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from collections import Counter

N = int(input())
A = [input() for i in range(N)]

c = Counter(A).most_common()
k, v = zip(*c)

[print(s) for s in sorted(k[:v.count(v[0])])]

Submission status: Accepted

Solution code:
arr = []
track = dict()
for _ in range(int(input())) :
    s = input()
    arr.append(s)
for i in arr :
    track[i] = 0
for i in arr :
    track[i]+=1
result = []
for i in track :
    result.append(track[i])
m = max(result)
g = []
for i in track :
    if track[i] == m :
        g.append(i)
g.sort()
for i in g :
    print(i)

Submission status: Accepted

Solution code:
N = int(input())
D = {}
for i in range(N):
  a_i = input()
  if a_i in D.keys():
    D[a_i] += 1
  else:
    D[a_i] = 1
m = 0
for v in D.values():
	m = max(m, v)
ans = []
for k, v in D.items():
	if v == m:
		ans.append(k)
ans.sort()
print(*ans, sep="\n")

Submission status: Accepted

Solution code:
# C - Poll
from collections import Counter


def main():
    _, *S = open(0).read().split()
    cnt = Counter(S).most_common()
    max_votes = cnt[0][1]
    ans = []
    for a, i in cnt:
        if i < max_votes:
            break
        ans.append(a)
    ans.sort()
    print("\n".join(map(str, ans)))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from collections import defaultdict

N = int(input())
S = [input() for _ in range(N)]
D = defaultdict(lambda: 0)
for s in S:
    D[s] += 1
d_max = max(D.values())
T = []
for k, v in D.items():
    if v == d_max:
        T.append(k)
T.sort()
print(*T, sep="\n")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

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

Submission status: Accepted

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

tmp = sorted(dic.items(), key=lambda x:(-x[1], x[0]))
for i in range(len(tmp)):
  if tmp[i][1] == tmp[0][1]:
    print(tmp[i][0])
  else:
    break

Submission status: Accepted

Solution code:
n=int(input())
s=[input() for i in range(n)]
l=list(set(s))
o=[]
for x in range(len(s)):
    o.append(0)
dic=dict(zip(l,o))

for x in s:
   if x in dic:dic[x]+=1
d=sorted(dic.items(),key=lambda x:-x[1])
m=d[0][1]
p=[]
for r in d:
    if r[1]==m:p.append(r[0])
u=sorted(p)
for y in u:
    print(y)

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
    
tmp = sorted(dic.items(), key=lambda x:x[0])
tmp = sorted(tmp, key=lambda x:x[1], reverse=True)
for i in range(len(tmp)):
  if tmp[i][1] == tmp[0][1]:
    print(tmp[i][0])
  else:
    break

Submission status: Accepted

Solution code:
N = int(input())
S = []
for i in range(N):
    S.append(input())
vote = {}
for j in S:
    if j not in vote:
        vote[j] = 1
    else:
        vote[j] += 1
most = set()
highNo = 0
for k in vote:
    if vote[k] > highNo:
        most.clear()
        most.add(k)
        highNo = vote[k]
    elif vote[k] == highNo:
        most.add(k)
most = list(most)


def sortLexo(givenList):
    givenList.sort()
    for i in givenList:
        print(i)
sortLexo(most)

Submission status: Accepted

Solution code:
n=int(input())
l={}
mx=0
for i in range(n):
    s=input()
    if s not in l:
        l[s]=1
    else:l[s]+=1
    mx=max(mx,l[s])
ans=[]
for j in l:
    #print("jの中身",j,"l[j]の中身",l[j])
    if l[j]==mx:
        ans.append(j)
        #print(ans)
#print(ans)
ans.sort()
for k in ans:print(k)

Submission status: Accepted

Solution code:
import collections

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

c = collections.Counter(S)
value_and_counts = c.most_common()

max_number = value_and_counts[0][1]

value_and_counts.sort()

for i in value_and_counts:
    if max_number == i[1]:
        print(i[0])

Submission status: Accepted

Solution code:
import collections
 
n = int(input())
 
res = []
 
for _ in range(n):
  res.append(input())
 
c = collections.Counter(res)
aa = c.most_common()
 
ss = aa[0][1]
res2 = []
 
aa.sort()
for i in aa:
  if i[1] == ss:
    res2.append(i[0])
    print(i[0])

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
l = []
for _ in range(n):
  l.append(input())
  
c = Counter(l).most_common()
m = max([x[1] for x in c])
result = sorted([x[0] for x in c if x[1]==m])
for s in result:
  print(s)

Submission status: Accepted

Solution code:
import collections


n = int(input())
s = [input() for i in range(n)]
c = collections.Counter(s)

sss = set(s)
mx = 0
pl = []
for ss in sss:
    if c[ss] > mx:
        mx = c[ss]
        pl = [ss]
    elif c[ss] == mx:
        pl.append(ss)
pl = sorted(pl)
for i in pl:
    print(i)

Submission status: Accepted

Solution code:
from collections import Counter

n=int(input())
s=[input() for i in range(n)]
c=Counter(s)

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

ans=[]
for k,v in c.items():
 if v==m:
  ans.append(k)
ans.sort()
for i in ans:
 print(i)

Submission status: Accepted

Solution code:
import collections

def check(input_list):

    vote_dict = collections.Counter(input_list)
    max_value = max(vote_dict.values())

    result_list = [k for k, v in vote_dict.items() if v == max_value]
    result_list.sort()
    
    return result_list

if __name__ == '__main__':
    num = int(input())
    input_list = [input() for a in range(num)]

    for str in check(input_list):
        print(str)

Submission status: Accepted

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

S_d={}
A=[]

for i in range(N):
    if S[i] not in S_d.keys():
        S_d[S[i]]=1
    else:
        S_d[S[i]]+=1

max_co=max(S_d.values())

for j in S_d.keys():
    if S_d[j]==max_co:
        A.append(j)

B=sorted(A)

for k in B:
    print(k)

Submission status: Accepted

Solution code:
N = int(input())
dic = {}
Max = 1

for _ in range(N):
  S = input()
  if not S in dic:
    dic[S] = 1
  else:
    dic[S] += 1
    Max = max([Max, dic[S]])

ans = []
    
for x in dic:
  if dic[x] == Max:
    ans.append(x)

ans_sorted = sorted(ans)
for y in range(len(ans)):
  print(ans_sorted[y])

Submission status: Accepted

Solution code:
from collections import defaultdict, Counter

if __name__ == "__main__":
    count = int(input().strip())
    votes = defaultdict(int)
    for _ in range(count):
        vote = input().strip()
        votes[vote] += 1
    ordered_votes = Counter(votes).most_common()
    max_votes = ordered_votes[0][1]
    winners = []
    for candidate, vote in ordered_votes:
        if vote  == max_votes:
            winners.append(candidate)
        else:
            break
    
    for name in sorted(winners):
        print(name)

Submission status: Accepted

Solution code:
N = int(input())
d = {}
for i in range(N):
    S = input()
    if S in d.keys():
        d[S] = d[S] + 1
    else:
        d[S] = 1
max_val = max(d.values())
max_k_ls = [kv[0] for kv in d.items() if kv[1]==max_val]
max_k_ls = sorted(max_k_ls)

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

Submission status: Accepted

Solution code:
n = int(input())
lis = []
lis2 = {}
lis3 = []
for _ in range(n):
  lis.append(input())

for w in lis:
  if w not in lis2.keys():
    lis2[w] = 1
  else:
    lis2[w] += 1

ma = max(lis2.values())

for k, v in lis2.items():
  if v == ma:
    lis3.append(k)

lis3.sort()

for a in lis3:
  print(a)

Submission status: Accepted

Solution code:
n=int(input())
l=[None for i in range(n)]
for i in range(n):
    l[i]=input()
l.sort()
m=0
now=l[0]
cnt=1
ll=[[] for i in range(n+1)]
for i in range(1,n):
    if l[i]!=now:
        m=max(m,cnt)
        ll[cnt].append(now)
        now=l[i]
        cnt=1
    else:
        cnt+=1
m=max(m,cnt)
ll[cnt].append(now)
for s in ll[m]:
    print(s)

Submission status: Accepted

Solution code:
N = int(input())
dic = {}
nmax = 1
for i in range(N):
  s = str(input())
  if s in dic:
    dic[s] += 1
    #毎回dic更新する度に最大値も更新
    nmax = max(dic[s], nmax)
  else:
    dic[s] = 1
slist = []
for k in dic:
  if dic[k] == nmax:
    slist.append(k)
for s in sorted(slist):
  print(s)

Submission status: Accepted

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

counter = Counter(s)
max_num = max(counter.values())
ans_list = [i for i in counter if counter[i] == max_num]
for i in sorted(ans_list):
    print(i)

Submission status: Accepted

Solution code:
from collections import defaultdict
d=defaultdict(int)
for i in range(int(input())):
    d[input()]+=1
ans=[]
d=list(d.items())
d.sort(key=lambda x:-x[1])

m=d[0][1]
for i,j in d:
    if m==j:
        ans+=[i]
    else:
        break

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

Submission status: Accepted

Solution code:
from collections import defaultdict
d=defaultdict(int)
for i in range(int(input())):
    d[input()]+=1
ans=[]
d=list(d.items())
d.sort(key=lambda x:-x[1])

m=d[0][1]
for i,j in d:
    if m==j:
        ans+=[i]

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

Submission status: Accepted

Solution code:
import collections

N = int(input())

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

c = collections.Counter(S)
max = max(c.values())
answerlist = [key for key, v in c.items() if v == max]
answerlist.sort()
for answer in answerlist:
    print(answer)

Submission status: Accepted

Solution code:
from collections import Counter

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

Sc = Counter(S).most_common()
m = Sc[0][1]
ans = []
for s in Sc:
    if s[1] == m:
        ans.append(s[0])
    else:
        break
ans.sort()
for a in ans:
    print(a)

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

d = max(dic.values())
max_k_list = [kv[0] for kv in dic.items() if kv[1] == d]
max_k_list.sort()

for s in max_k_list:
    print(s)

Submission status: Accepted

Solution code:
N = int(input())
# スペース区切りの整数をリストに入力

sdic = {}

nMax = 1

for i in range(N):
    s = str(input())
    if s in sdic:
        sdic[s] += 1
        nMax = max(nMax,sdic[s])
    else:
        sdic[s] = 1

slist = []
for k in sdic:
    if sdic[k] == nMax:
        slist.append(k)

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

Submission status: Accepted

Solution code:
from collections import defaultdict, Counter
import sys
n=int(input())
#d=defautldict(int)
l=[]
for _ in range(n):
  s=input()
  l.append(s)
c = Counter(l).most_common()
max_ = c[0][1]
ans=[]
for tup in c:
  p,q = tup
  if q != max_:
    break
  else:
    ans.append(p)
ans.sort()
for a in ans:
  print(a)

Submission status: Accepted

Solution code:
from collections import Counter
n=int(input())
string_list = [input() for i in range(n)]
str_count = Counter(string_list).most_common()
max = []
for i in str_count:
    if i[1] == str_count[0][1]:
        max.append(i[0])
    else:
        break
max.sort()
for w in max:
    print(w)

Submission status: Accepted

Solution code:
N = int(input())
L = []
D = {}
for _ in range(N):
    x = input()
    L.append(x)

for x in L:
    D[x] = 0
    
for x in L:
    D[x] += 1

SortD = sorted(D.items(), key=lambda x:x[1])
maxD = SortD[-1][1]
ans = []
for x in reversed(SortD):
    if x[1] == maxD:
        ans.append(x[0])
    else:
        break
for x in sorted(ans):
    print(x)

Submission status: Accepted

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


dict = defaultdict(int)
n = int(input())
for _ in range(n):
    s = input()
    dict[s] += 1

maxim = max(dict.values())

candidates = []

for key, count in dict.items():
    if count == maxim:
        candidates.append(key)

candidates.sort()

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

Submission status: Accepted

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

a = []
for d in s.items():
    if d[1] == m:
        a.append(d[0])
for s in sorted(a):
    print(s)

Submission status: Accepted

Solution code:
N = int(input())
S = []
for i in range(N):
    S.append(input())
A = []
from collections import Counter
d = Counter(S)
md = d.most_common(1)[0][1]
for key, value in d.items():
    if value == md:
        A.append(key)
As = sorted(A)
for a in As:
    print(a)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
N = int(input())

d = {}

m = 0
for i in range(N):
    S = input()
    if S in d:
        d[S] += 1
    else:
        d[S] = 1
    if d[S] > m: m = d[S]

ans_l = []

for k, v in d.items():
    if v==m: ans_l.append(k)

ans_l = sorted(ans_l)

for ans in ans_l:
    print(ans)

Submission status: Accepted

Solution code:
N = int(input())
S = []
for n in range(N):
    S.append(input())
dic = {}


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

max = max(dic.values())
out = []

for key,val in dic.items():
    if val == max:
        out.append(key)

out.sort()
for key in out:
    print(key)

Submission status: Accepted

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

max_count = max(polls.values())

results = []

for s in polls:
  if polls[s] == max_count:
    results.append(s)

results.sort()

for res in results:
  print(res)

Submission status: Accepted

Solution code:
from bisect import *
from collections import *
from itertools import *
import functools
import sys
import math
from decimal import *
from copy import *
from heapq import *
from fractions import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = 1000010
MOD = 10**9+7
spf = [i for i in range(MAXN)]
spf[0]=spf[1] = -1
def sieve():
    for i in range(2,MAXN,2):
        spf[i] = 2
    for i in range(3,int(MAXN**0.5)+1):
        if spf[i]==i:
            for j in range(i*i,MAXN,i):
                if spf[j]==j:
                    spf[j]=i
def fib(n,m):
    if n == 0:
        return [0, 1]
    else:
        a, b = fib(n // 2)
        c = ((a%m) * ((b%m) * 2 - (a%m)))%m
        d = ((a%m) * (a%m))%m + ((b)%m * (b)%m)%m
        if n % 2 == 0:
            return [c, d]
        else:
            return [d, c + d]

def charIN(x= ' '):
    return(sys.stdin.readline().strip().split(x))

def arrIN(x = ' '):
    return list(map(int,sys.stdin.readline().strip().split(x)))

def ncr(n,r):
    num=den=1
    for i in range(r):
        num = (num*(n-i))%MOD
        den = (den*(i+1))%MOD

    return (num*(pow(den,MOD-2,MOD)))%MOD

def flush():
    return sys.stdout.flush()

'''*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*'''
x = [input() for _ in range(int(input()))]
c = Counter(x)
mx = max(c.values())
ans = []
for i,j in c.items():
    if j==mx:
        ans.append(i)

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

Submission status: Accepted

Solution code:
from collections import defaultdict
n = int(input())
d = defaultdict(lambda: 0)
for i in range(n):
    s = input()
    d[s] += 1
k = max(d.values())
ansl = []
for key, value in d.items():
    if value == k:
        ansl.append(key)
ansl = sorted(ansl)
print(*ansl)

Submission status: Accepted

Solution code:
from itertools import groupby
N =int(input())
d = [input() for i in range(N)]

d.sort()
#print(d)
p=-1
b=[]
for key, value in groupby(d):
  a = len(list(value))
  if p<a:
    #print(p,len(list(value)))
    b=[]
    b.append(key)
    p=a
  elif p==a:
    #print(222)
    b.append(key)
for i in b:
  print(i)

Submission status: Accepted

Solution code:
N = int(input())
Dic = {}
for n in range(N):
    S = input()
    if S in Dic.keys():
        Dic[S] = Dic[S] + 1
    else:
        Dic[S] = 1

max_val = max(Dic.values())# 変数にmax()の値を代入.
max_k_list = [kv[0] for kv in Dic.items() if kv[1] == max_val]#変数を参照する形にする.
max_k_list = sorted(max_k_list)

#for t in max_k_list:　←小技2を用いない場合
   # print(t) ←小技2を用いない場合
print(*max_k_list, sep="\n") # 小技2

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
L = [input() for _ in range(N)] # 小技1

#L = [] ← 小技1を使わない場合
#for n in range(N): ← 小技1を使わない場合
    #S = input() ← 小技1を使わない場合
    #L.append(S) ← 小技1を使わない場合

Dic = Counter(L)
max_value = max(Dic.values())
max_k_list = [i for i, j in Dic.items() if j == max_value]
max_k_list = sorted(max_k_list)
 
print(*max_k_list , sep="\n")

Submission status: Accepted

Solution code:
import sys
from collections import Counter

input = sys.stdin.readline

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

c = Counter(l)
m = max(c.values())
c2 = [k for k, v in c.items() if v == m]

for x in sorted(c2):
    print(x)

Submission status: Accepted

Solution code:
from collections import defaultdict

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

mx = 0
for key, val in sdict.items():
  mx = max(mx, val)

ls = []
for key, val in sdict.items():
  if val == mx:
    ls.append(key)

ls.sort()
for s in ls:
  print(s)

Submission status: Accepted

Solution code:
S = [input() for _ in range(int(input()))]
from collections import Counter
ctr = Counter(S)
n = ctr.most_common()[0][1]#一番頻度の高い
ans = []

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

Submission status: Accepted

Solution code:
import collections
n = int(input())
s = [input() for _ in range(n)]
s = collections.Counter(s).most_common()
ans = []
for i in range(1, len(s) + 1):
    ans.append(s[i - 1][0])
    if i == len(s):
        break
    if s[i - 1][1] != s[i][1]:
        break
ans.sort()
print(*ans, sep='\n')

Submission status: Accepted

Solution code:
from collections import defaultdict
n=int(input())
dic=defaultdict(int)
for _ in range(n):
    s = input()
    dic[s]+=1
L=list(dic.items())
L.sort(key=lambda x:x[0])
c=L[0][1]
for a,b in L:
    c=max(c,b)
for a,b in L:
    if b == c:
        print(a)

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
#L = [input() for _ in range(N)]
L = []
for n in range(N):
    S = input()
    L.append(S)
Dic = Counter(L)
max_value = max(Dic.values())
max_k_list = [i for i, j in Dic.items() if j == max_value]
max_k_list = sorted(max_k_list)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
Dic = {}
for n in range(N):
    S = input()
    if S in Dic.keys():
        Dic[S] = Dic[S] + 1
    else:
        Dic[S] = 1

max_val = max(Dic.values())
max_k_list = [kv[0] for kv in Dic.items() if kv[1] == max_val]
max_k_list = sorted(max_k_list)
for t in max_k_list:
    print(t)

Submission status: Accepted

Solution code:
import sys
from collections import Counter
n = int(input())
s_ls = []
ct = Counter()
for i in range(n):
    s = sys.stdin.readline().strip()
    ct.update([s])
_max = max(ct.values())
for k, v in sorted([(k, v) for k, v in ct.items() if v == _max], key=lambda x:x[0]):
    print(k)

Submission status: Accepted

Solution code:
N = int(input())
Dic = {}
for n in range(N):
    S = input()
    if S in Dic.keys():
        Dic[S] = Dic[S] + 1
    else:
        Dic[S] = 1
        
max_value = max(Dic.values())

max_k_list = [kv[0] for kv in Dic.items() if kv[1] == max_value]
max_k_list = sorted(max_k_list)

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

Submission status: Accepted

Solution code:
import collections

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

c = dict(collections.Counter(s))
m = max(c.values())
ans = [k for k, v in c.items() if v == m]

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

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
L = [input() for _ in range(N)]
#for n in range(N):
    #S = input()
    #L.append(S)
Dic = Counter(L)
max_value = max(Dic.values())
max_k_list = [i for i, j in Dic.items() if j == max_value]
max_k_list = sorted(max_k_list)

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

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
L = [input() for _ in range(N)]
#for n in range(N):
    #S = input()
    #L.append(S)
Dic = Counter(L)
max_value = max(Dic.values())
max_k_list = [i for i, j in Dic.items() if j == max_value]
max_k_list = sorted(max_k_list)
for t in max_k_list:
    print(t)

Submission status: Accepted

Solution code:
import collections
s = collections.Counter([input() for s in range(int(input()))])
m = max(s.values())

a = []
for d in s.items():
  if d[1] == m:
    a.append(d[0])
for s in sorted(a):
  print(s)

Submission status: Accepted

Solution code:
from collections import Counter

N, *S = open(0).read().split()

C = Counter(S)

ma = max(C.values())
ans = sorted(k for k, v in C.items() if v == ma)

print("\n".join(ans))

Submission status: Accepted

Solution code:
from bisect import *
from collections import *
from fractions import gcd
from math import factorial
from itertools import *
from heapq import *
import copy


#int(input())
#map(int,input().split())
N=int(input())
S=Counter([input() for i in range(N)]).most_common()
S=[i[0] for i in S if i[1]==S[0][1]]
for i in sorted(S):
    print(i)

Submission status: Accepted

Solution code:
from collections import Counter

N, *S = open(0).read().split()

C = Counter(S)

ma = max(C.values())
ans = sorted(k for k, v in C.items() if v == ma)

for a in ans:
    print(a)

Submission status: Accepted

Solution code:
import collections
 
n = int(input())
s = [input() for i in range(n)]
 
count = collections.Counter(s)
 
max_v = max(count.values())
 
result = [key for key, val in count.items() if val == max_v]

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

Submission status: Accepted

Solution code:
from collections import Counter

N, *S = open(0).read().split()

C = Counter(S).most_common()

ma = C[0][1]
ans = sorted(k for k, v in C if v == ma)

for a in ans:
    print(a)

Submission status: Accepted

Solution code:
from collections import Counter

def main():
  n = int(input())
  l = [input() for _ in range(n)]
  s = Counter(l)
  ans = []
  max_value = max(s.values())
  for x in s:
    if s[x] == max_value:
      ans.append(x)
  ans.sort()
  for x in ans:
    print(x)
  

if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
import collections

n, *s_n = open(0).read().split()
n = int(n)

dic = collections.Counter(s_n)

dic_values_max = max(list(dic.values()))

max_key = [i for i, j in dic.items() if j == dic_values_max]

max_key.sort()

for k in max_key:
    print(k)

Submission status: Accepted

Solution code:
N = int(input())
S={}
for i in range(N):
    k=input()
    if(k not in S):
        S[k]=1
    else:
        S[k]+=1
#print(S)
T=sorted(S.items(),key=lambda x:x[1],reverse=True)
#print(T)
for i in range(len(T)):
    l=T[0][1]
    if(l>T[i][1]):
        T=T[0:i]
        break
#T=T[0:s]
T=sorted(T,key=lambda x:x[0])
for i in range(len(T)):
    print(T[i][0])

Submission status: Accepted

Solution code:
import collections as col


n=int(input())
s=[input() for i in range(n)]
c = col.Counter(s)
max = max(c.values())
ans = []

for key,val in c.items():
    if val == max:
       ans.append(key)

ans.sort()

for i in ans:
    print(i)

Submission status: Accepted

Solution code:
import collections
def inverse_lookup(d, x):
    cList = []
    for k,v in d.items():
        if x == v:
            l = k
            cList.append(l) 
    return cList

n = int(input())
List=[input() for i in range(n)]
c = collections.Counter(List)

n = max(c.values())
out=sorted(inverse_lookup(c,n))
for word in out:
    print(word)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

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

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

Submission status: Accepted

Solution code:
import collections

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

tmp = collections.Counter(ss).most_common()
target = tmp[0][1]
anss = []
for i in tmp:
    if i[1] == target:
        anss.append(i[0])
    else:
        break
anss = sorted(anss, key=str.lower)
print(*anss)