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:
n = int(input())
a={}
b=[]
for i in range(n):
    s=input()
    if s in a:
        a[s]=a[s]+1
    else:
        a[s]=int(1)
        b.append(s)
c=0
print()
for i in b:
    if c < a[i]:
        c=a[i]
b.sort()
for i in b:
    if a[i]==c:
        print(i)
# print(a)

Submission status: Accepted

Solution code:
import collections

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

for i in range(N):
    S.append(input())

c = collections.Counter

max_cnt = max(c(S).values())

max_list = [k for k, v in c(S).items() if v == max_cnt]

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

Submission status: Accepted

Solution code:
import collections

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

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


while(i<n):
  if(c[s[i]] == max):
    rlist.append(s[i])
  i+=1

r2list=list(set(rlist))
r2list.sort()

len= len(r2list)
j=0

while(j<len):
  print(r2list[j])
  j+=1

Submission status: Accepted

Solution code:
N = int(input())

dic = {}
m = 1
for i in range(N):
    st = input()
    if st not in dic:
        dic[st] = 1
    else:
        dic[st] += 1
        if dic[st] > m:
            m = dic[st]

ans = []
for s in dic:
    if dic[s] == m:
        ans.append(s)
ans.sort()
for i in range(len(ans)):
    print(ans[i])

Submission status: Accepted

Solution code:
def main():
  n=int(input())
  poll=[input() for i in range(n)]

  dic={}
  for string in poll:
    if string not in dic:
      dic[string]=1
    else:
      dic[string]+=1
  
  x=max(dic.values()) 
  max_k=[k for k, v in dic.items() if v==x]
  max_k.sort()
  print(*max_k,sep='\n')
  
if __name__=='__main__':
  main()

Submission status: Accepted

Solution code:
from collections import Counter
from itertools import takewhile
N = int(input())
A_list = []
for i in range(N):
	A = str(input())
	A_list.append(A)
A_cnt = Counter(A_list)
mode_A = A_cnt.most_common()[0][-1]
#print(mode_A)
it = takewhile(lambda x: x[-1]== mode_A, A_cnt.most_common())
re_it = sorted(it, key = lambda x: x[0])
for k,v in re_it:
	print(k)

#print(A_cnt.most_common())

Submission status: Accepted

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

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

for i in range(n):
  s = str(input()).rstrip('\n')
  if s in ss:
    ss[s] = ss[s]+1
  else:
    ss[s] = 1

m = max(list(ss.values()))
ss1 = sorted({k:v for k,v in ss.items() if v == m}.items())

for k,v in ss1:
  print(k)

Submission status: Accepted

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

c = Counter(a)
d = c.most_common()
ans = []
for i in c.items():
   if i[1] == d[0][1]:
     ans.append(i[0])
for i in sorted(ans):
  print(i)

Submission status: Accepted

Solution code:
#C
N = int(input())
memo = {}
max_word = 1
for i in range(N):
    Si = input()
    try:
        memo[Si] += 1
        max_word = max(max_word, memo[Si])
    except:
        memo[Si] = 1
        
keys = [k for k, v in memo.items() if v == max_word]
keys.sort()
for item in keys:
  print(item)

Submission status: Accepted

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

from collections import Counter
c = Counter()

for si in S:
    c[si] += 1

ca = []
for name, cnt in c.items():
    ca.append([name, cnt])

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

max_c = ca[0][1]
for name, cnt in ca:
    if cnt == max_c:
        print(name)

Submission status: Accepted

Solution code:
import numpy as np
N = input()

N = int(N)
strs = []
for ii in range(N):
  stri = input()
  strs.append(stri)
strs = np.sort(strs)

ustr, idx = np.unique(strs,return_index=True)
cnts = []
for ii in range(len(idx)-1):
  c = idx[ii+1] - idx[ii]
  cnts.append(c)

cnts.append(N - idx[len(idx)-1]) #最後の文字のカウント
maxcnt = np.max(cnts)

ans = []

for ii in range(len(idx)):
  if cnts[ii] == maxcnt:
    ans.append(ustr[ii])

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

Submission status: Accepted

Solution code:
N = int(input())
paper = [input() for i in range(N)]

D = {}
for p in paper:
    if p not in D:
        D[p] = 1
    else:
        D[p] += 1

key = 0
max_value = 0
k = []
# 辞書の値を取り出す
for i in D:
    if D[i] > max_value:
        max_value = D[i]
        key = i
        k = []
    elif D[i] == max_value:
        k.append(i)

if len(k) == 0:
    print(key)
else:
    k.append(key)
    for j in sorted(k):
        print(j)

Submission status: Accepted

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

def solve(N: int, S: "List[str]"):
    d = defaultdict(int)
    cnt_common = 0
    commons = []

    for s in S:
        d[s] += 1
        if cnt_common < d[s]:
            cnt_common=d[s]
            commons = [s]
        elif cnt_common == d[s]:
            commons.append(s)

    return '\n'.join(sorted(commons))

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

def resolve():
    n = int(input())

    count = OrderedDict()
    for _ in range(n):
        name = input()
        if name not in count.keys():
            count[name] = 1

        else:
            count[name] += 1

    count = OrderedDict(
        sorted(count.items(), key=lambda x: x[0])
    )
    max_polls = max(count.values())

    for k, v in count.items():
        if v == max_polls:
            print(k)
            
resolve()

Submission status: Accepted

Solution code:
n = int(input())

d = {}
for i in range(n):
    x = 0
    s = input()
    if (s in d) == True:
        x = d[s]
        d[s] = x + 1
    else:
        d[s] = 1

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

l = sorted(keys_of_max_val)
for i in l:
    print(i)

Submission status: Accepted

Solution code:
import sys
import collections
n = int(input())
s = [input() for i in range(n)]
s = sorted(s)
c = collections.Counter(s)
li = []
max_v = -1
for k,j in c.items():
    li.append([k,j])
    if max_v<j:
        max_v = j
li = sorted(li)
for i in range(len(li)):
    if li[i][1] == max_v:
        print(li[i][0])

Submission status: Accepted

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

for m in range(n):
    s = input()
    if s:
        if not s in sDict:
            sDict[s] = 1
        else:
            sDict[s] += 1
    else:
        break

sDict = sorted(sDict.items(), key=lambda x:x[1])

tempValue = ""
tempList = []

for key, value in reversed(sDict):
    if tempValue:
        if tempValue != value:
            break   
    else:
        tempValue = value
    
    tempList.append(key)

for element in sorted(tempList):
    print(element)

Submission status: Accepted

Solution code:
import collections

N = int(input())
a = []
for i in range(N):
  a.append(str(input()))
a = collections.Counter(a)
b = max(a.values())
max_k_list = [kv[0] for kv in a.items() if kv[1] == b]
max_k_list = sorted(max_k_list)
for i in max_k_list:
  print(i)

Submission status: Accepted

Solution code:
import collections
import itertools
N=int(input())
di = dict()
l = list()
for i in range(N):
    l.append( input())

c = collections.Counter(l)
ct = c.most_common()
m = ct[0][1]
li = list()
for t in ct:
    if m == t[1]:
        li.append(t[0]) 
    else:
        break
lis = sorted(li)
for s in lis:
    print(s)

Submission status: Accepted

Solution code:

N = int(input())

words = {}
max_count = 0
for i in range(N):
  word = input()

  count = words.get(word, 0) + 1
  words[word] = count

  if max_count < count:
    max_count = count

results = []
for k, v in words.items():
  if v == max_count:
    results.append(k)

for answer in sorted(results):
  print(answer)

Submission status: Accepted

Solution code:
n = int(input())
s = []
count = [0] * n
count[0] = 1

for i in range(n):
    s_e = str(input())
    s.append(s_e)
s.sort()

last = s[0]
s_max = 1

for i in range(1, n):
    if last == s[i]:
        count[i] = count[i-1] + 1       
    else:
        s_max = max(s_max, count[i-1])
        last = s[i]
        count[i] = 1

s_max = max(s_max, count[n-1])

for i in range(n):
    if s_max == count[i]:
        print(s[i])

Submission status: Accepted

Solution code:
from collections import Counter

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

sc = Counter(s)
maxNum = sc.most_common()[0][1]
keys = [k for k , v in sc.most_common() if v == maxNum]
keys.sort()
for word in keys:
    print(word)

Submission status: Accepted

Solution code:
from collections import defaultdict
import sys

def main():
    input = sys.stdin.readline
    n=int(input())
    dic=defaultdict(int)
    st=set([])
    for i in range(n):
        s=input().strip('\n')
        st.add(s)
        dic[s]+=1
    maxv=max(dic.values())
    l=sorted(st)
    for i in range(len(l)):
        if dic[l[i]]==maxv:
            print(l[i])
        
    

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import collections
N = int(input())
counter = collections.Counter([input() for _ in range(N)])
maximum = max(counter.values())
answers = [k for k, v in counter.items() if v == maximum]
answers.sort()
for x in answers:
  print(x)

Submission status: Accepted

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

ans = []
l.sort()
num = 1
max_num = 0

for i in range(1,N):
    if l[i] == l[i-1]:
        num += 1
    else:
        if num > max_num:
            max_num = num
            ans = [l[i-1]]
        elif num == max_num:
            ans.append(l[i-1])
        num = 1
if num > max_num:
        max_num = num
        ans = [l[i]]
elif num == max_num:
    ans.append(l[i])

for i in ans:
    print(i)

Submission status: Accepted

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

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

# valueがmaxであるkeyを探してくる
max_val = max(dic.values())
keys_of_max_val = [key for key in dic if dic[key] == max_val]

keys_of_max_val.sort()

for k in keys_of_max_val:
    print(k)

Submission status: Accepted

Solution code:
N = int(input())
S = []
for i in range(N):
    S.append(input())
S.sort()
S.append("A")
B = []
M = 1
T = 1
for i in range(N):
    if S[i] == S[i+1]:
        T += 1
    elif T < M:
        T = 1
    elif T == M:
        T = 1
        B.append(S[i])
    else:
        M = T
        T = 1
        B = [S[i]]

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

Submission status: Accepted

Solution code:
N = int(input())
a = list(input() for i in range(N))
a.sort()
count = 1
max = 0
ls = []
for i in range(N - 1):
  if a[i] == a[i + 1]:
    count += 1
  else:
    if count > max:
      ls = []
      ls.append(a[i])
      max = count
    elif count == max:
      ls.append(a[i])
    count = 1
if count > max:
  ls = []
  ls.append(a[N - 1])
elif count == max:
  ls.append(a[N - 1])
ls.sort()
for i in range(len(ls)):
  print(ls[i])

Submission status: Accepted

Solution code:
#At coder 2020/2/16 C
import collections

# スペース区切りのサイズNの配列の入力
# スペース区切りのサイズNの配列の入力
N = int(input())
S = [0] * N

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


c = collections.Counter(S)

maxv=max(c.values())
#print(c)
#c = sorted(c.items())

ans = [k for k, v in c.items() if v == maxv]
#ans = sorted(ans.items())
ans=sorted(ans)


for ii in range(len(ans)):
    print(ans[ii])
#    if v == maxv :
#        print(k)

Submission status: Accepted

Solution code:
import collections

n = int(input())
l = [input() for _ in range(n)]
c = collections.Counter(l)

ans = []
count_max = max(c.values())
for i in c.items():
    if list(i)[1] == count_max:
        ans.append(list(i)[0])

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

Submission status: Accepted

Solution code:
from collections import defaultdict
N = int(input())
S = defaultdict(int)
S2 = []
max = 0
for _ in range(N):
    s = input()
    S[s] += 1
    if max < S[s]:
        max = S[s]
for k, v in sorted(S.items(), key=lambda x: -x[1]):
    if max == v:
        S2.append(k)
    else:
        break
for s in sorted(S2):
    print(s)

Submission status: Accepted

Solution code:
import collections
N=int(input())
L=[]
for i in range(N):
  L.append(input())
S=collections.Counter(L)
MS= max(S.values())
ans=[]
for k,v in S.items():
  if v==MS:
    ans.append(k)
ans.sort()
print(' '.join(ans))

Submission status: Accepted

Solution code:
import collections

n = int(input())
s = [input() for _ in range(n)]
a = list(set(s))
ans = []

t = collections.Counter(s)
v = list(t.most_common())[0][1]

for i,j in list(t.most_common()):
	if v == j:
		ans.append(i)

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

Submission status: Accepted

Solution code:

n= int(input())
from collections import Counter
S = []
for _ in range(n):
  s = input()
  S.append(s)

c= Counter(S)
ans =[]
maxvalue =0
# print(c.most_common())
for values, counts in c.most_common():
  if maxvalue > counts:
    break
  else:
    maxvalue = counts
  ans.append(values)
  # print(values)
  
for i in sorted(ans):
  print(i)
# print(sorted(ans))

Submission status: Accepted

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

import collections
a = collections.Counter(S).most_common()
ans = []
for i in range(len(a)):
  if i == 0:
    ans.append(a[i][0])
  elif a[i - 1][1] == a[i][1]:
    ans.append(a[i][0])
  else:
    break
ans.sort()

for j in ans:
  print(j)

Submission status: Accepted

Solution code:
from collections import Counter

N = int(input())
S = [0]*N
for i in range(N):
  S[i] = input()  
S.sort()
c = Counter(S)
m_num = c.most_common()[0][1]

for s in sorted(list(set(S))):
  if c[s] == m_num:
    print(s)

Submission status: Accepted

Solution code:
d = {}
for i in range(int(input())):
  tmp = input()
  if tmp in d.keys():
    d[tmp]+=1
  else:
    d[tmp]=1
max_value = max(d.values())
keys = [k for k,v in d.items() if v == max_value]
for i in sorted(keys):
  print(i)

Submission status: Accepted

Solution code:
N = int(input())

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

s_set = set(dic.keys())
s_set = sorted(s_set)

max = 0
for si in s_set:
  if dic[si] > max:
    max = dic[si]

for si in s_set:
  if dic[si] == max:
    print(si)

Submission status: Accepted

Solution code:
n = int(input())
si = []
s = ""

for i in range(n):
    s = input()
    si.append(s)

li = sorted(si)
li.append("S")
str_li = []
int_li = []
num = 1


for j in range(n):
    if li[j] == li[j+1]:
        num += 1
    else:
        str_li.append(li[j])
        int_li.append(num)
        num = 1
    t = li[j]

n_ma = max(int_li)

for j in range(len(int_li)):
    if int_li[j] == n_ma:
        print(str_li[j])

Submission status: Accepted

Solution code:
import numpy as np
N=int(input())
S=[]
ans={}

pri=[]

for i in range(N):
    tmp=input()
    if(tmp.isdecimal()==0):
        S.append(tmp)

for i in S:
    if(ans.get(i)==None):
        ans[i]=1
    else:
        ans[i]+=1
a=np.max(np.array(list(ans.values())))

for i,j in ans.items():
    if(j==a):
        pri.append(i)
        
pri=sorted(pri)


for i in pri:
    print(i)

Submission status: Accepted

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

max_num = max(str_dic.values())

max_str = [s[0] for s in str_dic.items() if s[1] == max_num]

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

Submission status: Accepted

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

from collections import Counter
X=Counter(S)
Y=X.most_common()
Z=sorted([i[0] for i in X.items() if i[1] == Y[0][1]])

for i in Z:
    print(i)

Submission status: Accepted

Solution code:
import collections
N=int(input())
L=[]
NL=[]
cL={}
for _ in range(N):
  L.append(str(input()))

cL=collections.Counter(L)
v,c=zip(*cL.most_common())

for i in range(len(v)):
           if c[0]==c[i]:
           	NL.append(v[i])
NL.sort()
for j in range(len(NL)):
           print(NL[j])

Submission status: Accepted

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

values, counts = zip(*c.most_common())
index = 0
for i in range(len(counts)-1):
    if counts[i] == counts[i+1]:
        index += 1
    else:
        break
        
ans_list = []
for j in range(index+1):
    ans_list.append(values[j])
ans_list.sort()
for ans in ans_list:
    print(ans)

Submission status: Accepted

Solution code:
import collections

N = int(input())
S = []
for _ in range(N):
  S += [input()]
d = collections.Counter(S).most_common()

for i in sorted([k for k, v in d if v == d[0][1]]):
  print(i)

Submission status: Accepted

Solution code:
import collections

# input
N = int(input())
S = []

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

cnt = collections.Counter(S)
cnt_sorted = sorted(cnt.items(), key=lambda x:x[1], reverse=True)
#print(cnt_sorted)

max = 0
pre = 0
ans = []
for v in cnt_sorted:
  max = v[1]
  if max >= pre:
    ans.append(v[0])
    pre = max
  else:
    break

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

Submission status: Accepted

Solution code:
import sys
import math
import itertools as it
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx():return list(map(lambda x:int(x)*-1,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":pass
n = i()
s = [input() for _ in range(n)]
s.sort()
ss = list(set(s))
ss.sort()
a = [0]*len(ss)
i = 0
j = 0
while n-1 > i:
    if s[i] == s[i+1]:
        a[j] += 1
        i += 1
    else:
        i += 1
        j += 1
m = max(a)
for k in range(len(a)):
    if m == a[k]:
        print(ss[k])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
my_dict = dict()
n = int(input())
for i in range(n):
    my_input = input()
    if my_input in my_dict:
        my_dict[my_input] += 1
    else:
        my_dict[my_input] = 1

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

keys_of_max_val.sort()

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

Submission status: Accepted

Solution code:
n = int(input())
d = {}
ans = []
for i in range(n):
  s = input()
  if s not in d:
    d[s] = 1
  else:
    d[s] += 1
d = sorted(d.items(), key=lambda x:x[1])
score = d[-1][1]
ans = []
for i in range(len(d)):
  if d[i][1] == score:
    ans.append(d[i][0])
ans.sort()
for i in range(len(ans)):
  print(ans[i])

Submission status: Accepted

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


s_sorted1 = sorted(s.items(), key = lambda value: -value[1])
max = s_sorted1[0][1]
ans = []
for j,k in s_sorted1 :
    if k == max :
        ans.append(j)
    else:
        break

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

Submission status: Accepted

Solution code:
from collections import Counter
# N=7
# S=["beat","vet","beet","bed","vet","bet","beet"]
N=int(input())
S=[]
for i in range(N):
    S.append(input())

SC=Counter(S)
values, counts = zip(*SC.most_common())
# １番目の回数がもっとも多く投票された数
most_counts=list(counts)[0]
# 多く投票された数と同じ票数のものは何個ある確認
most_counts_len=len([i for i in list(counts) if i ==most_counts])
# 出力は辞書順にする
output_values=values[:most_counts_len]
output_values=sorted(output_values)
for i in output_values:
    print(i)

Submission status: Accepted

Solution code:
from collections import defaultdict

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

ordered_d = sorted(d.items(), key=lambda x: x[1], reverse=True)
res = []
last_cnt = 0
for i, (name, cnt) in enumerate(ordered_d):
    if i == 0:
        last_cnt = cnt
    if last_cnt != cnt:
        break
    res.append((name, cnt))
        
for name, _ in sorted(res, key=lambda r: r[0]):
    print name

Submission status: Accepted

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

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

result=sorted(keys_of_max_val)
[print(i) for i in result]

Submission status: Accepted

Solution code:
n = int(input())
s = [input() for i in range(n)]
d = {}
for i in s:
    if i in d.keys():
        d[i]=d[i]+1
    else:
        d[i]=1
d_sorted = sorted(d.items(), key=lambda x:x[1])
d_name = [x[0] for x in d_sorted if x[1] == d_sorted[-1][1]]
d_name.sort()
print("\n".join(d_name))

Submission status: Accepted

Solution code:
#155 c
n=int(input())
s=dict()
for i in range(n):
    x=input()
    if x not in s:
        s[x]=1
    else:
        s[x]+=1


max_value=max(s.values())
ans=sorted(s.items(),key=lambda x:x[0])

for i in ans:
    if max_value==i[1]:
        print(i[0])

Submission status: Accepted

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

arr = collections.Counter(words)
_max = arr.most_common()[0][1]
for word in sorted([i[0] for i in arr.items() if i[1] == _max]):
  print(word)

Submission status: Accepted

Solution code:
N = int(input())
s= {}
max_keep=0
for i in range(N):
    key=input()
    s.setdefault(key,0)
    s[key]+=1
    if s[key]>max_keep:
        max_keep=s[key]

max_list=[]
for value in s.values():
  if value==max_keep:
    max_list.append(s)

keys = [k for k, v in s.items() if v==max_keep]
keys.sort()

string = "\n".join(keys)
print(string)

Submission status: Accepted

Solution code:
n = int(input())
data = [input() for x in range(n)]

temp_list = {}

#dictionaryの初期化
for x in list(set(data)):
    temp_list[x] = 0

for x in data:
    temp_list[x] += 1

max_value = max(temp_list.values())
sort_keys = sorted(temp_list.keys())

for x in sort_keys:
    if temp_list[x] == max_value:
        print(x)

Submission status: Accepted

Solution code:
N = int(input())


inin = []
for i in range(N):
    inin.append(str(input()))
    
dic = {}
for i in inin:
    if i not in dic:
        dic[i] = 1
    else:
        dic[i] = dic[i]+1

l = dic.items()
max = 0
for i in l:
    if i[1] > max:
        max = i[1]

result = []
for i in l:
    if i[1] == max:
        result.append(i[0])

result.sort()

for i in result:
    print(i)

Submission status: Accepted

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

    worddic_sorted = sorted(worddic.items(), key=lambda x:x[1], reverse=True)
    selected = list(filter(lambda x:x[1] == worddic_sorted[0][1], worddic_sorted))
    selected_sorted = sorted(selected, key=lambda x:x[0])
    for i in range(len(selected_sorted)):
        print(selected_sorted[i][0])

solve()

Submission status: Accepted

Solution code:
import collections
from collections import Counter
n=int(input())
string_list=[input() for i in range(n)]
c = collections.Counter(string_list)
max = c.most_common()[0][1]
list = []
# print("-------")
for i in c.items():
    if i[1] == max:
        list.append(i[0])

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    s = [input() for i in range(n)]
    res = {}
    for i in s:
        if i not in res:
            res[i] = 1
        res[i] += 1
    keys = max(res.values())
    max_keys = sorted([key for key in res if res[key] == keys])
    for k in max_keys:
        print(k)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from collections import defaultdict

N = int(input())
dic = defaultdict(int)

for i in range(N):
    dic[input()] += 1


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

ans = [dic[0][0]]

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

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    S = {}
    for _ in range(N):
        s = input()
        if s not in S:
            S[s] = 1
        else:
            S[s] += 1

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

    for k in keys:
        print(k)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import collections
import itertools

n = int(input())
lst = []
for _ in range(n):
    lst.append(str(input()))
    
c = collections.Counter(lst)

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

lst2 = [k for k, v in it]

print(' '.join(sorted(lst2)))

Submission status: Accepted

Solution code:
N = int(input())
sMap = {}
sList = []

for i in range(N):
    s = input()
    if s  not in sMap:
        sMap[s] = len(sList)
        sList.append([1, s])
    else:
        num = int(sMap[s])
        sList[num][0] = sList[num][0] + 1
    #print(sList)

sList.sort(reverse=True)
max = sList[0][0]
#print(sList)
ansList = []
for s in sList:
    if s[0] != max:
        break
    ansList.append(s[1])

#print(ansList)
ansList.sort()
ans = '\n'.join(ansList)
print(ans)

Submission status: Accepted

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

#S.sort()


result={}
for i in range (0,len(S)):
    item = S[i]
    if item in result:
        result[item] = result[item]+1
    else:
        result[item] = 1

max_v = max(result.values())

keys = [k for k, v in result.items() if v == max_v]

keys.sort()
s_n = '\n'.join(keys)
print(s_n)

Submission status: Accepted

Solution code:
from collections import defaultdict

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

t = max(S.values())
for v in sorted(dict(filter(lambda kv: kv[1] == t, S.items())).keys()):
    print(v)

Submission status: Accepted

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

scount = Counter(s)
scsort = scount.most_common()
x = scsort[0][1]
anss = []
for i in scsort:
    if i[1] != x:
        break
    anss.append(i[0])

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

Submission status: Accepted

Solution code:
N=int(input())
S=[input() for i in range(N)]
S.sort()
def list_count(my_list):
    dic={} #辞書型の宣言
    for num in my_list:
        if num in dic: #もしnumがkeyとして辞書にあれば
            dic[num]+=1 #valueに+1
        else: #なければ
            dic[num]=1 #dicにnumというkeyを追加し、対応するvalueを1とする
    return dic
K=[]
A=list_count(S)
ookii=max(A.values())
K.append(ookii)
max_k_list = [kv[0] for kv in A.items() if kv[1] == K[0]]
max_k_list.sort()
for j in range(len(max_k_list)):
    print(max_k_list[j])

Submission status: Accepted

Solution code:
N = int(input())

target = dict()
max_count = 0
max_key = list()
for i in range(N):
	S = str(input())
	if S in target:
		count = target[S] +1
		target[S] = count	
	else:
		target[S] = 1
		count = 1

	if max_count < count:
		max_count = count
		max_key = [S]
	elif max_count == count:
		max_key.append(S)

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

Submission status: Accepted

Solution code:
import collections

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

c = collections.Counter(S)
values, counts = zip(*c.most_common())
c_most = []
for s in range(len(values)):
    if counts[0] == counts[s]:
        c_most.append(values[s])
    else:
        break
ans = sorted(c_most)
for j in range(len(ans)):
    print(ans[j])

Submission status: Accepted

Solution code:
import collections

count = input()

l = []
ans = []
for i in range(int(count)):
    l.append(input())
c = collections.Counter(l)
#print(l)
#print(c)
#print(c.most_common()[0][1])
max_count = c.most_common()[0][1]
for i in c.most_common():
    if i[1] != max_count:
        break
    #print(i[0])
    ans.append(i[0])
ans.sort()
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
n = int(input())
l = {}
max = 0
for _ in range(n):
  s = input()
  l[s] = l.get(s, 0) + 1
  if max < l[s]:
    max = l[s]

for i in sorted(list(filter(lambda s: l[s] == max, l.keys()))):
  print(i)

Submission status: Accepted

Solution code:
from collections import Counter

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

list = []

l = Counter(s)
max = max(l.values())

list = [k for k, v in l.items() if v == max]

list.sort()

for j in list:
    print(j)

Submission status: Accepted

Solution code:
n = int(input())
counts = {}
best = 0
best_words = []
for idx in range(n):
    string = input()
    if counts.get(string) is None: counts[string] = 1
    else: counts[string] += 1

    score = counts[string]

    if score > best:
        best = score
        best_words = [string]
    
    elif score == best:
        best_words.append(string)

for string in sorted(best_words):
    print(string)

Submission status: Accepted

Solution code:
N=int(input())

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

B=sorted(A)

import collections
import itertools

counter = collections.Counter(A)

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

answer=[]
for i in it:
    answer.append(i[0])

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

Submission status: Accepted

Solution code:
N = int(input())

s = [None for _ in range(N)]

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

s.sort()

max_list = []
max_v = 1

count = 1
prev = s[0]


for i in range(1, N):
  # print(s[i], prev, count)
  if s[i] == prev:
    count += 1
  else:
    if max_v == count:
      max_list.append(prev)
    elif max_v < count:
      max_list = [prev]
      max_v = count
    count = 1
    prev = s[i]


if max_v == count:
  max_list.append(prev)
elif max_v < count:
  max_list = [prev]
  max_v = count

for k in max_list:
  print(k)