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:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# vim:fenc=utf-8 ff=unix


def get_inv_value(item):
    return -item[1]


def solv(N, S):
    d = {}
    for s in S:
        if s in d:
            d[s] += 1
        else:
            d[s] = 1
    lst = sorted(d.items(), key=get_inv_value)
    m = lst[0][1]
    lst = sorted([l[0] for l in lst if l[1] == m])
    return "\n".join(lst)


if __name__ == "__main__":

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

    ans = solv(N, S)

    print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict as de

n = int(input())
x = de(int)
for i in range(n):
    s = input()
    x[s] += 1
x = sorted(x.items(), key=lambda x:x[1], reverse=True)
y = 0
z =[]
for i,j in x:
    if y > j:
        break
    z.append(i)
    y = j
z = sorted(z)
for i in z:
    print(i)

Submission status: Accepted

Solution code:
from collections import Counter
n=int(input())
s=[input() for _ in range(n)]
c=Counter(s)
c=c.most_common()
i=0
ans=[]
for i in range(len(c)):
  if c[0][1] == c[i][1]:
    ans.append(c[i][0])

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

Submission status: Accepted

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


def solve(N: int, S: "List[str]"):
    D=dict()
    M=1
    for s in S:
        if s in D:
            D[s] = D[s]+1
            if M < D[s]:
                M=D[s]
        else:
            D[s] = 1
    L = list()
    for d in D:
        if D[d] == M:
            L.append(d)
    LL = sorted(L)
    for ll in LL:
        print(ll)
    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:
N = int(input())
d = dict()
for i in range(N):
    S = input()
    if S not in d:
        d[S] = 1
    else:
        d[S] += 1
max_vote = max(d.values())
ans = []
for k, v in d.items():
    if v == max_vote:
        ans.append(k)
ans.sort()
for a in ans:
    print(a)

Submission status: Accepted

Solution code:
rang = int(input())
words = []
for i in range(rang):
    words.append(input())

d = {w: 0 for w in words}
m = 0
for w in words:
    d[w] += 1
    if (d[w] > m):
         m = d[w]
most = [k for k,v in d.items() if v == m]

most.sort()
for wrd in most:
    print(wrd)

Submission status: Accepted

Solution code:
from collections import Counter
def check(n):
    d = Counter([input() for _ in range(n)])
    result = d.most_common()
    max_cnt = result[0][1]
    namelist = []
    for name, cnt in result:
        if max_cnt == cnt:
            namelist.append(name)
    for name in sorted(namelist):
        print(name)
    
n = int(input())
check(n)

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

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

l = []

for k in dict:
    if dict[k] == s[0][1]:
        l.append(k)

ss = sorted(l)
for v in ss:
    print(v)

Submission status: Accepted

Solution code:
import collections
n = int(input())
l = []
for i in range(n):
    l.append(input())
c = collections.Counter(l)
t = sorted(c.most_common())
t.sort(key=lambda x: x[1],reverse=True)
ma = t[0][1]
for i in range(len(t)):
    if t[i][1] < ma:
        break
    print(t[i][0])

Submission status: Accepted

Solution code:
import collections
n = int(input())
wl = []
for i in range(n):
  wl.append(input())
  
s = collections.Counter(wl)
m = max(s.values())
ans = []
for k,v in s.items():
  if (v == m):
    ans.append(k)
for w in sorted(ans):
  print(w,sep=' ')

Submission status: Accepted

Solution code:
import collections
D = collections.defaultdict(int)
N = int(input())
for i in range(N):
    D[input()] += 1
high = -1
ans = dict()
for k,v in sorted(D.items(), key=lambda x:x[1], reverse=True):
    if high <= v:
        high = v
        ans[k] = v
    else:
        break
ans = sorted(ans.keys())
for a in ans:
    print(a)

Submission status: Accepted

Solution code:
from collections import Counter

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

cnt = -1
counter_s = Counter(s)
ans = []
for word, num in counter_s.most_common():
  if cnt == -1 or cnt == num:
    ans.append(word)
    cnt = num
  else:
    break

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

Submission status: Accepted

Solution code:
N = int(input())
S_dic = {}
mode_list = []
mode_num = 0
for i in range(N):
    S = input()
    if S in S_dic:
        l = S_dic[S]+1
        S_dic[S] = S_dic[S]+1
    else:
        l=1
        S_dic[S]=1
    if mode_num==l:
        mode_list.append(S)
    elif mode_num<l:
        mode_list = []
        mode_list.append(S)
        mode_num = l

mode_list.sort()

for w in mode_list:
    print(w)

Submission status: Accepted

Solution code:
import collections

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

c = collections.Counter(names)

max_value = max(c.values())

output_list = []
for k, v in c.items():
    if v == max_value:
        output_list.append(k)

for name in sorted(output_list):
    print(name)

Submission status: Accepted

Solution code:
from collections import Counter
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N = int(input())
    S = [input() for _ in [0] * N]

    cnt = Counter(S).most_common()
    j = cnt[0][1]
    ans = []
    for v, i in cnt:
        if i == j:
            ans.append(v)
    ans.sort()
    print(*ans, sep='\n')


main()

Submission status: Accepted

Solution code:
N=int(input())
S=[input() for i in range(N)]
import collections
cS=collections.Counter(S)
maxV=max(cS.values())
keys = [k for k, v in cS.items() if v == maxV]
keys.sort()
for i in  range(len(keys)):
    print(keys[i])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Feb 16 21:10:50 2020

@author: H_Hoshigi
"""


N = int(input())
S_dict = {}
for i in range(N):
    S_i = input()
    try:
        S_dict[S_i]
    except KeyError:
        S_dict[S_i] = 1
    else:
        S_dict[S_i] += 1

S_soretd_list = sorted(S_dict.keys())
answer_list = []
max_frequency = 0
for i in S_soretd_list:
    if S_dict[i] > max_frequency:
        max_frequency = S_dict[i]
        answer_list = [i]
    elif S_dict[i] == max_frequency:
        answer_list.append(i)
    else:
        pass
for i in answer_list:
    print(i)

Submission status: Accepted

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

import collections    
C = collections.Counter(S)
M = C.most_common()[0][1]
R = [c for c in C.keys() if C[c]==M]
R.sort()

for r in R:
    print(r)

Submission status: Accepted

Solution code:
import sys
from collections import Counter

N = int(sys.stdin.readline())
S = []
uniqueS = []
for i in range(N):
    tempS = input()
    S.append(tempS)

SC = Counter(S)
max = max(SC.values())

ans_list = []
for i in SC.items():
    if i[1] == max:
        ans_list.append(i[0])
ans_list.sort()

for i in ans_list:
    print(i)

Submission status: Accepted

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

dic = dict()
for s in S_list:
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1

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

outs = []
max = None
for (out, num) in dict_sorted:
    if max is None:
        outs.append(out)
        max = num
    elif max == num:
        outs.append(out)
    else:
        break

for out in sorted(outs):
    print(out)

Submission status: Accepted

Solution code:
from collections import defaultdict
import heapq

n = int(input())
s_dic = defaultdict(int)
max_count = 0
for _ in range(n):
    s = input()
    s_dic[s] += 1
    max_count = max(s_dic[s], max_count)

ans = []
for key in s_dic.keys():
    if s_dic[key] == max_count:
        heapq.heappush(ans, key)
for _ in range(len(ans)):
    print(heapq.heappop(ans))

Submission status: Accepted

Solution code:
import collections
n = int(input())
s = []
for _ in range(n):
    s.append(input())
sc = collections.Counter(s).most_common()
ans = []
ans.append(sc[0][0])
mn = sc[0][1]
for n in range(1, len(sc)):
    if sc[n][1] == mn:
        ans.append(sc[n][0])
    else:
        break
for anss in sorted(ans):
    print(anss)

Submission status: Accepted

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

import collections
c =  collections.Counter(S)
MAX = max(c.values())
SET = []
for i in range(N):
    if c[S[i]]==MAX:
        SET.append(S[i])
SET = list(set(SET))
SET.sort()
for item in SET:
    print(item)

Submission status: Accepted

Solution code:
#!python3.4
# -*- coding: utf-8 -*-
# abc155/abc155_c
import sys
import collections

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    c = collections.Counter()
    most_n = 0
    most_s = []
    for _ in range(N):
        s = i2s()
        c[s] += 1
        if c[s] == most_n:
            most_s.append(s)
        elif c[s] > most_n:
            most_s = [s]
            most_n = c[s]
        # print(most_s)
    for ms in sorted(most_s):
        print(ms)
    return

main()

Submission status: Accepted

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

import collections

n = int(input())
c = collections.Counter([input() for i in range(n)])
m = max(c.values())
k = list(c.keys())
v = list(c.values())
data = []
for i in range(len(c)):
    if v[i] == m:
        data.append(k[i])
        

data.sort()

[print(i) for i in data]

Submission status: Accepted

Solution code:
N = int(input())

dic = {}
s = ""
for i in range(N):
    s = input()
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1

max = 0
for i in dic.values():
    if (max < i):
        max = i

mojiSet = set()
for moji in dic.keys():
    if (max == dic[moji]):
        mojiSet.add(moji)

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    str_dict = dict()
    for n in range(N):
        s = input()
        if s in str_dict:
            str_dict[s] += 1
        else:
            str_dict[s] = 1
    max_s = max(str_dict.values())
    result_list = list()
    for a, b in str_dict.items():
        if b == max_s:
            result_list.append(a)
    result_list.sort()
    for r in result_list:
        print(r)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import defaultdict
n = int(input())
d = defaultdict(int)
for _ in range(n):
    d[input()] += 1
sorted_pairs = [(k, v) for k, v in sorted(d.items(), key=lambda item: item[1], reverse=True)]   
max_freq = sorted_pairs[0][1]

result = []
for k, v in sorted_pairs:
    if v != max_freq:
        break
    result.append(k)

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

Submission status: Accepted

Solution code:
def main(n,s):
    s.sort()
    val = s[0]
    idx = 0
    maxcount = 1
    lst = [[1, val]]
    for i in range(1,len(s)):
        if s[i] == val:
            lst[idx][0] += 1
            maxcount = max(maxcount, lst[idx][0])
        else:
            idx += 1
            val = s[i]
            lst.append([1,val])
    res = []
    for i in range(len(lst)):
        if lst[i][0] == maxcount:
            res.append(lst[i][1])
    res.sort()
    for i in range(len(res)):
        print(res[i])
    
n = int(input())
s = [input() for _ in range(n)]
main(n,s)

Submission status: Accepted

Solution code:
import collections

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

c = collections.Counter(s)
count = c.most_common()[0][1]

s2 = [i[0] for i in c.items() if i[1] == count]
s2 = sorted(s2)

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

Submission status: Accepted

Solution code:
n = int(input())

S = []
for i in range(n):
    S.append(input())
    
max_temp = 1
count = {}
for s in S:
    if s in count:
        count[s] += 1
        if count[s]>max_temp:
            max_temp = count[s]
    else:
        count[s] = 1
        
res = [kv[0] for kv in count.items() if kv[1] == max_temp]
res.sort()

for i in res:
    print(i)

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())
keys = [key for key, val in d.items() if val == m]

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

Submission status: Accepted

Solution code:
N = int(input())

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

m = max(res.values())
keys = [k for k, v in res.items() if v == m]
keys.sort()

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

Submission status: Accepted

Solution code:
N = int(input())

D={}
L = [0]*N
for i in range(N):
    L[i]=input()
    if D.get(L[i],None)==None:
        D[L[i]]=1
    else:
        D[L[i]]+=1
D = sorted(D.items(),reverse=True,key=lambda x:x[1])
n=D[0][1]
s=""

List=[]
for i in range(len(D)):
    if(D[i][1]==n and D[i][0]!=s):
        List.append(D[i][0])
        s=D[i][0]
List=sorted(List)

for l in List:
    print(l)

Submission status: Accepted

Solution code:
import numpy as np

n = int(input())
s_list = [input() for i in range(n)]

new_dict = {}
for s in s_list:
    if s not in new_dict.keys():
        new_dict[s] = 1
    else:
        new_dict[s] += 1
    
values = []
keys = []    
for key in new_dict.keys():
    values.append(new_dict[key])
    keys.append(key)
    
values = np.array(values)
keys = np.array(keys)

max_index = values == np.max(values)
keys = keys[max_index].tolist()
keys = sorted(keys)

for key in keys:
    print(key)

Submission status: Accepted

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

o = {}
for a in A:
    if a in o:
        o[a] += 1
    else:
        o[a] = 1

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

max = 0
res = []
for o in o_sorted:
    if o[1] < max:
        break
    max = o[1]
    res.append(o[0])

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

Submission status: Accepted

Solution code:
import collections


class Solution:
    def solve(self, N: int, S):

        counter = collections.Counter(S)

        most_common = counter.most_common()

        num = most_common[0][1]

        answer = []

        for s in most_common:
            if s[1] == num:
                answer.append(s[0])
            else:
                break

        return sorted(answer)


if __name__ == '__main__':

    # standard input
    N = int(input())

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

    # solve
    solution = Solution()
    ans = solution.solve(N, S)
    for s in ans:
        print(s)

Submission status: Accepted

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n = int(input())
s_dict = {}
max_n = 0
for i in range(0, n):
    s = input()
    if s in s_dict:
        s_dict[s] += 1
        if s_dict[s] > max_n:
            max_n = s_dict[s]
    else:
        s_dict[s] = 1
        if max_n == 0:
            max_n = 1
s_list = []
for s in s_dict:
    if s_dict[s] == max_n:
        s_list.append(s)
s_list = sorted(s_list)
for s in s_list:
    print(s)

Submission status: Accepted

Solution code:
n = int(input())
# s = [None] * n
dic = {}
for i in range(n):
    s_tmp = input()
    try:
        dic[s_tmp] += 1
    except KeyError:
        dic[s_tmp] = 1

s = []
for k, v in dic.items():
    s.append((k, v))
s.sort(reverse=True, key=lambda x: x[1])
max_n = s[0][1]
ans = []
for i in range(len(s)):
    if (s[i][1] == max_n):
        ans.append(s[i][0])
    else:
        break

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

Submission status: Accepted

Solution code:
import collections
n = int(input())
s_L = []
for _ in range(n):
    s = input()
    s_L.append(s)
c = collections.Counter(s_L)
c = sorted(c.items(),key=lambda x: x[1],reverse=True)
num = c[0][1]
c = sorted(c,key=lambda x:x[0])
for k,v in c:
    if v == num:
        print(k)

Submission status: Accepted

Solution code:
N = int(input())
S = []
L = {}
maxL = 0
maxS = []
for i in range(N):
    s = input()
    if s in L:
        L[s] += 1
    else:
        L[s] = 1
        
    if maxL < L[s]:
        maxL = L[s]
        maxS = [s]
    elif maxL == L[s]:
        maxS.append(s)

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

Submission status: Accepted

Solution code:
n = int(input())
d = {}
max_ = 1
for i in range(n):
    s = input()
    if d.get(s) is None:
        d[s] = 1
    else:
        d[s] += 1
        if max_ < d[s]:
            max_ = d[s]
ans = sorted(d.items())
for k, v in ans:
    if v == max_:
        print(k)

Submission status: Accepted

Solution code:
n = input()
arr_c = [input() for i in range(int(n))]

dic = {}

for elem in arr_c:
  if elem in dic:
    dic[elem] += 1
  else:
    dic[elem] = 1

freq = max(dic.values())

sorted_dic = sorted(dic.items(), key=lambda x: x[0])

for tup in sorted_dic:
  if tup[1] == freq:
    print(tup[0])

Submission status: Accepted

Solution code:
N = int(input())
mydict = {}
max = 0
for i in range(N):
    S = input()
    if S in mydict.keys():
        mydict[S] = mydict[S] + 1
    else:
        mydict[S] = 1
        
    if max < mydict[S]:
        max = mydict[S]

keys = [k for k, v in mydict.items() if v == max]
keys.sort()
for key in keys:
    print(key)

Submission status: Accepted

Solution code:
def solve():
    N = int(input())
    s_lst = [input() for i in range(N)]
    s_lst.sort()
    a_lst = []
    s_dict = {}
    for w in s_lst:
        if not w in s_dict.keys():
            s_dict[w] = 1
        else:
            s_dict[w] += 1
    s_max = max(list(s_dict.values()))
    i = 0
    while i < len(s_lst):
        w = s_lst[i]
        if s_dict[w] == s_max:
            a_lst.append(w)
        i += s_dict[w]
    for i in range(len(a_lst)):
        print(a_lst[i])

if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
N = int(input())
S_dic = {}
for i in range(N):
  S = input()
  if S in S_dic.keys():
    S_dic[S] += 1
  else:
    S_dic[S] = 1
sort_dic = sorted(S_dic.items(), key=lambda x:x[1], reverse=True)
before = 0
ans = []
for i in sort_dic:
  if i[1] >= before:
    ans.append(i[0])
  else:
    break
  before = i[1]
ans.sort()
for i in ans:
  print(i)

Submission status: Accepted

Solution code:
n=int(input())
slist=[]
for i in range(n):
    slist.append(input())
slist.sort()
anslist=[]
anslist.append([slist[0],1])
kosulist=[]
for i in range(1,n):
    if slist[i]!=slist[i-1]:
        kosulist.append(anslist[-1][1])
        anslist.append([slist[i],1])
    else:
        anslist[-1][1]+=1
        if i==n-1:
            kosulist.append(anslist[-1][1])
maxkosu=max(kosulist)
answer=[]
for i in range(len(anslist)):
    if anslist[i][1]==maxkosu:
        answer.append(anslist[i][0])
for i in range(len(answer)):
    print(answer[i])

Submission status: Accepted

Solution code:
# Code for C - Poll
# Use input() to fetch data from STDIN
import collections

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

c = collections.Counter(s)
maxC = max(c.values())
z = list(filter(lambda z: z[1] == maxC, c.most_common()))
for x in sorted([y[0] for y in z]):
    print(x)

Submission status: Accepted

Solution code:
from collections import Counter
n=int(input())
s=[]
count=[]
for i in range(n):
    s.append(input())
c=Counter(s)
freq_scores = c.most_common()
max_count = freq_scores[0][1]
modes = []
for num in freq_scores:
    if num[1] == max_count:
        modes.append(num[0])
modes.sort()
for mode in modes:
    print(mode)

Submission status: Accepted

Solution code:
N = int(input())
D = dict()
M = 0
for _ in range(N):
    s = input()
    if D.get(s) is None:
        D[s] = 1
    else:
        D[s] += 1
    M = max(M, D[s])
keys = sorted([k for k, n in D.items() if n == M])
for k in keys:
    print(k)

Submission status: Accepted

Solution code:
n = int(input())

dicN = {}
nList = []
for i in range(n):
  nList.append(input())

for i in nList:
  if not(i in dicN):
    dicN[i]=1
  else:
    dicN[i] += 1

maxN = max(dicN.values())

result = []
for i in list(dicN.items()):
  if i[1] == maxN:
    result.append(i[0])
  #else:
  #  break

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

Submission status: Accepted

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

res_n = 0
res = []
for k, v in s.items():
    if v > res_n:
        res.clear()
        res.append(k)
        res_n = v
    elif v == res_n:
        res.append(k)

res.sort()
for r in res:
    print(r)

Submission status: Accepted

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

import collections
c0 = collections.Counter(s)
c1 = c0.most_common()
max = c1[0][1]
l = []
for x, i in c0.items():
    if i == max:
        l.append(x)
ans = sorted(l)
for i in ans:
    print(i)

Submission status: Accepted

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

from collections import Counter
s = Counter(s)
v_max = s.most_common()[0][1]
s2 = sorted(s.items())
#s.sort(key=lambda pair: pair[0])
ans = []
for k,v in s2:
  if v_max == v:
    print(k)

Submission status: Accepted

Solution code:
N = int(input())

S = {}
ans_n = 0

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

    ans_n = max(ans_n, S[s])

S = sorted(S.items(), key=lambda x: x[0])


for s in S:
    if s[1] == ans_n:
        print(s[0])

Submission status: Accepted

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

Submission status: Accepted

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

n = max(d.values())

res = [kv[0] for kv in d.items() if kv[1] == n]

res.sort()

for s in res:
    print(s)

Submission status: Accepted

Solution code:
N = int(input())

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

S.sort()
ans = [""]
maximum = 0
hoge = S[0]
nyoro = 0
for i in S:
    if i == hoge:
        nyoro += 1
    else:
        if maximum < nyoro:
            ans = [hoge]
            maximum = nyoro
        elif maximum == nyoro:
            ans.append(hoge)
        
        hoge = i
        nyoro = 1
else:
    if maximum < nyoro:
        ans = [hoge]
    elif maximum == nyoro:
        ans.append(hoge)

ans.sort()

for i in ans:
    print(i)

Submission status: Accepted

Solution code:
n = int(input())
S = [input() for _ in range(n)]
d_S = dict()
for s in S:
    d_S[s] = d_S.get(s, 0) + 1
max_v = max(d_S.values())
most_S = []
for s in d_S.items():   
    if ( s[1] == max_v):
        most_S.append(s[0])
for s in sorted(most_S):
    print(s)

Submission status: Accepted

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

def solve(N: int, S: "List[str]"):
    counter = Counter(S).most_common()

    most_value = counter[0][1]
    answer_list = []

    for key,value in dict(counter).items():
        if value == most_value:
            answer_list.append(key)
    
    answer_list = list(set(answer_list))
    answer_list.sort()

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

    return


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

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

max_s = collections.Counter(s).most_common()[0][1]
for i, j in collections.Counter(s).most_common():
    if j == max_s:
        s_list.append(i)
print(*sorted(s_list), sep = "\n")

Submission status: Accepted

Solution code:
import collections
N = int(input())
S = []
answer = []
for _ in range(N):
    S.append(input())

S_dict = collections.Counter(S)
# print(S_dict.most_common())
max_num = S_dict.most_common()[0][1]
# i = 0
# while True:
#     if max_num != S_dict.most_common()[i][1]:
#         break
#     else:
#         answer.append(S_dict.most_common()[i][0])
#     i += 1
for i in S_dict.most_common():
    # print(i[1])
    if i[1] == max_num:
        answer.append(i[0])

answer.sort()
for v in answer:
    print(v)
# print(answer)

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
S = Counter([input() for _ in range(N)])
v = max(S.values())
s = sorted(S.most_common())
if len(S) == 1:
    print(list(S)[0])
    exit()
for k, val in s:
    if val == v:
        print(k)

Submission status: Accepted

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

N = int(input())  # type: int

dic = {}
for i in range(N):
    word = input()
    if word in dic:
        dic[word] = dic[word] + 1
    else:
        dic[word] = 1

max = max(dic.values())
keys = [k for k, v in dic.items() if v == max ]
for i in sorted(keys):
    print(i)

Submission status: Accepted

Solution code:
from collections import defaultdict

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

d2 = sorted(d.items(), key=lambda x: -x[1])
d3 = sorted(map(lambda x: x[0], filter(lambda x: x[1] == d2[0][1], d2)))

for s in d3:
  print(s)

Submission status: Accepted

Solution code:
N = int(input())
D = dict()
for _ in range(N):
    cand = input()
    if cand not in D:
        D[cand] = 1
    else:
        D[cand] += 1
mx = max(D.values())
A = sorted(D.items(), key=lambda x: -x[1])
ans = []
for k, m in A:
    if m == mx:
        ans.append(k)
    else:
        break

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

Submission status: Accepted

Solution code:
from collections import defaultdict
d = defaultdict(int)

N = int(input())

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

for string in S:
    d[string] += 1

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

ans = []

tmp = sorted_d[0][1]
for i in range(len(sorted_d)):
    if sorted_d[i][1] == tmp:
        ans.append(sorted_d[i][0])
        tmp = sorted_d[i][1]
    else:
        break

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
dict = {}
max_count = 0
max_count_words = []

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

  if(s in dict):
    dict[s] += 1
  else:
    dict[s] = 1

for key, value in dict.items():
  if(value > max_count):
    max_count = value
    max_count_words = [key]
  elif(value == max_count):
    max_count_words.append(key)

list.sort(max_count_words)
print("\n".join(map(str, max_count_words)))

Submission status: Accepted

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


value_max = max(dictionary.values())

max_list = []
for k, v in dictionary.items():
    if v == value_max:
        max_list.append(k)

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

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())
words = [input() for _ in range(n)]
d = Counter(words)
m = max(d.values())
max_l = [kv[0] for kv in d.items() if kv[1] == m]
print('\n'.join(sorted(max_l)))

Submission status: Accepted

Solution code:
N = int(input())
S = []
for i in range(N):
    S.append(input())
S.sort()
li = []
count = 0
baf = S[0]
for i in range(1, N):
    if S[i] == baf:
        baf = S[i]
        count += 1
    else:
        li.append([baf, count])
        baf = S[i]
        count = 0
li.append([baf, count])
li.sort(key=lambda x : -x[1])
baf2 = li[0][1]
print(li[0][0])
for i in range(1, len(li)):
    if li[i][1] != baf2:
        break
    print(li[i][0])

Submission status: Accepted

Solution code:
import collections

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

c = collections.Counter(S)
a = c.most_common()
m = a[0][1]
ans = list()
ans.append(a[0][0])

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

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

Submission status: Accepted

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

max_val = 0
for i in range(n):
  key = input()
  try:
    s[key] += 1
  except:
    s[key] = 1
  if s[key] > max_val:
    max_val = s[key]

ans = dict(filter(lambda kv: kv[1] == max_val, s.items()))
for k,v in sorted(ans.items()):
  print(k)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    s=[]
    for i in range(n):
        s.append(input())
    # print(s)
    s.sort()
    stemp = s[0]
    ans = []
    cnt =1
    # print(s)
    for i in range(1,n):
        if stemp == s[i]:
            cnt += 1
            continue
        else:
            ans.append([cnt, stemp])
            cnt = 1
            stemp = s[i]
    ans.append([cnt, stemp])
    ans.sort()
    aa = []
    if len(ans) != 1:
        temp = ans[-1][0]
        aa.append(ans[-1][1])
    else:
        print(ans[0][1])
        return


    for i in range(2,n+1):
        if ans[-i][0] == temp:
            aa.append(ans[-i][1])
        else:
            break
    aa.sort()
    for i, ss in enumerate(aa):
        print(ss)

if __name__=='__main__':
    main()