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:
# -*- coding: utf-8 -*-
from collections import defaultdict
n = int(input())
d = defaultdict(int)

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

l = []
for k in d:
    l.append((d[k],k))
l.sort(key=lambda x:(-x[0],x[1]))
m = l[0][0]
i = 0
while i<len(l) and l[i][0]==m:
    print(l[i][1])
    i += 1

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

n = int(input())
l = [input() for _ in [0] * n]

counted = collections.Counter(l)
#print(counted)
# 最頻値を求める
m = max(counted.values())
#print(m)
# 頻出数の文字を集める
chars = [key for key, value in counted.items()
             if value == m]

print(*sorted(chars),sep='\n')

Submission status: Accepted

Solution code:
from collections import Counter

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

L = Counter(S)
m = 0
for v in L.values():
    m = max(m, v)
ans = []
for k, v in L.items():
    if v == m:
        ans.append(k)
ans.sort()
print(*ans, sep="\n")

Submission status: Accepted

Solution code:
n=int(input())
s=sorted([input() for i in range(n)])
ans = ['']
x=1
max=0
for k in range(n):
    if k<n-1:
        if s[k]==s[k+1]:
            x+=1
        else:
            if max<x:
                ans=[s[k]]
                max=x
            elif max==x:
                ans.append(s[k])
            x=1
    else:
        if max<x:
            ans=[s[k]]
            max=x
        elif max==x:
            ans.append(s[k])

    

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

Submission status: Accepted

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

counter = collections.Counter(s)
count = counter.most_common()

most = count[0][1]

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

c.sort()

for i in range(len(c)):
    print(c[i][0])

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
S = []
for n in range(N):
    S.append(input())
c = Counter(S)
K = []
for i,(k,v) in enumerate(c.most_common()):
    if i==0:
        vmax = v
    else:
        if vmax!=v:
            break
    K.append(k)

K = sorted(K)
for k in K:
    print (k)

Submission status: Accepted

Solution code:
from itertools import groupby
from operator import itemgetter
 
a = sorted(input() for _ in range(int(input())))
a = sorted((-len(tuple(g)), s) for s, g in groupby(a))
for _, s in next(groupby(a, itemgetter(0)))[1]:
  print(s)

Submission status: Accepted

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

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

m = 0
for k in d.keys():
    m = max(d[k],m)

li = []
for k in d.keys():
    if d[k] == m:
        li.append(k)

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

Submission status: Accepted

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

kkk=1
data=[]
for i in range(1,N):
    if S[i]==S[i-1]:
        kkk+=1
    else:
        data.append([kkk,S[i-1]])
        kkk=1
data.append([kkk,S[-1]])
data.sort()
num=data[-1][0]

for u in data:
    if u[0]==num:
        print(u[1])

Submission status: Accepted

Solution code:
n = int(input())
li = []
for i in range(0,n):
    li.append(input())
di = dict()
for j in range(0,len(li)):
    if li[j] in di.keys():
        di[li[j]]+=1
    else:
        di[li[j]] = 1
li.clear()
di = {k: v for k, v in sorted(di.items(), key=lambda item: item[1])}
total = max(di.values())
for k,v in di.items():
    if v == total:
        li.append(k)
li.sort()
for l in li:
    print(l)

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
d = [input() for _ in range(n)]
c = Counter(d).most_common()
now = c[0][1]

data = []
for x in c:
    if x[1] < now:
        break
    data.append(x[0])
data.sort()
for x in data:print(x)

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())
S = [input() for _ in range(n)]
S_cnt = Counter(S)

ans_box, maxi = [], 0

for s in S_cnt:
    cnt = S_cnt[s]
    if maxi < cnt:
        maxi = cnt
        ans_box = [s]
    elif maxi == cnt:
        ans_box.append(s)

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

Submission status: Accepted

Solution code:
import collections

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

for i in range(N):
  SSS.append(input())
#print(N, SSS)

#print(collections.Counter(SSS).most_common())
hindo_ck = collections.Counter(SSS).most_common()

i = 1
hindo_max = list(hindo_ck[0])

if len(hindo_ck) > 1:
  del hindo_max[-1]
  while i < N and hindo_ck[i-1][1] == hindo_ck[i][1]:
    hindo_max.append(hindo_ck[i][0])
    i += 1
  hindo_max.sort()
  
  for h in hindo_max:
    print(h)
  
else:
  hindo_max = hindo_ck[0][0]
  print(hindo_max)
#print(result)

Submission status: Accepted

Solution code:
n=int(input())
arr=[input() for _ in range(n)]
dic={}
for i in range(n):
  if arr[i] not in dic:
    dic[arr[i]]=1
  else:
    dic[arr[i]]+=1
largest=max(dic.values())
ans=[]
for keys in dic.keys():
  if dic[keys]==largest:
    ans.append(keys)
ans=sorted(ans)
for words in ans:
  print(words)

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
ls = []
for _ in range(n):
    ls.append(input())
res = []
counter = Counter(ls).most_common()
for x in counter:
    if x[1] == counter[0][1]:
        res.append(x[0])
print("\n".join(sorted(res)))

Submission status: Accepted

Solution code:


N=int(input())

S_list = []
S_count = []
max = 1
temp_list = []
#for i in range(N):
#    s = input()
#    temp_list.append(s)
S_dict = {}
for i in range(N):
    s = input()
    if s in S_dict.keys():
        S_dict[s] += 1
        if max < S_dict[s]:
            max = S_dict[s]
    else:
        S_dict[s] = 1
    
     
#print(S_list)
#print(S_count)
#print(max)
S_max = []
for j in S_dict:
    if S_dict[j] == max:
        S_max.append(j)

S_max.sort()
for k in range(len(S_max)):
    print(S_max[k])

Submission status: Accepted

Solution code:
from collections import Counter

N = int(input())

str_lis = [str(input()) for i in range(N)]
c = Counter(str_lis)
a = c.most_common()
num = a[0][1]
b = []
for i in a:
  if i[1] == num:
    b.append(i[0])
    num = i[1]
  else:
    break
    
new_b = sorted(b)
for i in new_b:
  print(i)

Submission status: Accepted

Solution code:

a= int(input())
liss = [input() for i in range(a)]

lis = sorted(liss)

maxCount = 1
nCount = 1
maxlist = []


for i in range(a):
    if i != a-1:
        if lis[i] == lis[i + 1]:
            nCount += 1
            if nCount > maxCount:
                maxCount += 1
                maxlist.clear()
            continue
        elif maxCount == nCount:
            maxlist.append(lis[i])

        nCount = 1
    else:
        if maxCount == nCount:
            maxlist.append(lis[i])



lis = sorted(lis)

for s in maxlist:
    print(s)

Submission status: Accepted

Solution code:
# coding: utf-8

def main():
    n = int(input())
    lines = []
    for i in range(0, n):
        lines.append(input())

    dct = {}
    for l in lines:
        if l in dct:
            dct[l] += 1;
        else:
            dct[l] = 1;

    cmax = max(dct.values())

    print('\n'.join(sorted([k for k,v in dct.items() if v == cmax])))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import collections

N = int(input())
s = [input() for i in range(N)]
k = 0
i = 0
ans =[]

c = collections.Counter(s)
c_mc=c.most_common()
for i in range(len(c)):
    if c_mc[i][1] ==c_mc[0][1]:
        ans.append(c_mc[i][0])

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

Submission status: Accepted

Solution code:
n = int(input())
a = []
for i in range(n):
  si = str(input())
  a.append(si)
a.sort()
mx = 1
w = []
j = 1
for i in range(1,n):
  if a[i] == a[i-1]:
    j += 1
  else:
    if j > mx:
      w = [a[i-1]]
      mx = j
    elif j == mx:
      w.append(a[i-1])
    j = 1
if j > mx:
  w = [a[n-1]]
elif j == mx:
  w.append(a[n-1])
for wi in w:
  print(wi)

Submission status: Accepted

Solution code:
from collections import Counter
num = int(input())
value = [input() for i in range(num)]
votes = Counter(value)
dict = {}

for value in votes.values():
    dict[value] = []

for (key, value) in votes.items():
    dict[value].append(key)
maxVote = sorted(dict.keys(), reverse=True)[0]
list_data = dict[maxVote]
list_data.sort()
for i in list_data:
    print(i)

Submission status: Accepted

Solution code:
num = int(input())

put = []
stor = {}
i=0
while i<num :
    name = input()
    if name in stor.keys():
        stor[name] += 1
    else:
        stor[name] = 1
    i += 1

stor=sorted(stor.items(), key=lambda item:item[1], reverse=True)

m = stor[0][1]

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

for i in put:
    print(i)

Submission status: Accepted

Solution code:
from collections import Counter

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

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

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

for item in sorted(c.items()):
    if item[1]==max:
        print (item[0])

Submission status: Accepted

Solution code:
from collections import defaultdict

n =int(input())

d = defaultdict(int)

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

result = sorted(d.items(), key=lambda x: -x[1])

max_val = 0
maxes = []
for r in result:
    if max_val > r[1]:
        break
    else:
        max_val = r[1]
        maxes.append(r[0])

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

Submission status: Accepted

Solution code:
n=int(input())
dic=dict()
for _ in range(n):
    s=input()
    if s in dic:
        dic[s] +=1
    else:
        dic[s]=1
m=max(dic.values())
dic=sorted(dic.items(),key=lambda x: x[0])
for i in range(len(dic)):
    if dic[i][1]==m:
        print(dic[i][0])

Submission status: Accepted

Solution code:
N = int(input())
 
mes_dict = {}
for i in range(N):
  m = input()
  try:
    mes_dict[m] += 1
  except:
    mes_dict[m] = 1

ma =max(mes_dict.values())
answer = sorted([k for k, v in mes_dict.items() if v == ma])
for ans in answer:
  print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s = [input() for i in range(n)]
import collections
c = collections.Counter(s).most_common()
fin = [c[0][0]]
for j in range(1,len(c)):
    if c[j][1]==c[j-1][1]:
        fin.append(c[j][0])
        continue
    break
for kekka in sorted(fin):
    print(kekka)

Submission status: Accepted

Solution code:
from collections import defaultdict
from collections import OrderedDict
N = int(input())
ans = dict()
for _ in range(N):
    k = str(input())
    if k in ans:
        ans[k]+=1
    else:
        ans.update({k:1})
groupedByValue = defaultdict(list)
for key, value in sorted(ans.items()):
    groupedByValue[value].append(key)
l = groupedByValue[max(groupedByValue)]
for i in l:
    print(i)

Submission status: Accepted

Solution code:
n=int(input())
s=[input() for _ in range(n)]
s.sort()
s.append("")
a=[]
count=[]
buf=1
count_max=1
for i in range(n):
    s_i=s[i]
    if s_i==s[i+1]:
        buf+=1
    else:
        if buf>=count_max:
            a.append(s_i)
            count.append(buf)
            if buf>count_max:
                count_max=buf
        buf=1
count_max=max(count)
for i in range(len(a)):
    if count[i]==count_max:
        print(a[i])

Submission status: Accepted

Solution code:
n=int(input())

l={}
for i in range(n):
    s = input()
    if s in l:
        l[s]+=17
    else:
        l[s]=1

xa = max(l.values())

keys = [k for k, v in l.items() if v == xa]
keys.sort()

for i in keys:
    print(i)

Submission status: Accepted

Solution code:
import sys
import collections

N = int(input())
S = []
for _ in range(N):
    S.append(input()) 
c = collections.Counter(S)
a = c.most_common()
s = c.most_common()[0][1]
ans = []
for i in sorted(a):
    if i[1] == s:
        print(i[0])
        sys.stdout.flush

Submission status: Accepted

Solution code:
n=int(input())
s=[]
for i in range(n):
    s.append(input())
s=sorted(s)
t=0
c=0
ct=[]
for i in range(1,n):
    c+=1
    if s[t]!=s[i]:
        ct.append(c)
        c=0
        t=i
ct.append(c+1)
u=0
cm=max(ct)
for i in ct:
    if i==cm:
        print(s[u])
    u+=i

Submission status: Accepted

Solution code:
n = int(input())
s = [input() for i in range(n)]
import collections
c = collections.Counter(s).most_common()
fin = [c[0][0]]
for j in range(1,len(c)):
    if c[j][1]==c[j-1][1]:
        fin.append(c[j][0])
        continue
    break
a = sorted(fin)
for kekka in a:
    print(kekka)

Submission status: Accepted

Solution code:
import collections
n = int(input())
s = [input() for i in range(n)]
lst = collections.Counter(s)
max_val = max(lst.values())
keys_of_max_val = [key for key in lst if lst[key] == max_val]
print("\n".join(sorted(keys_of_max_val)))

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())
s_list = sorted(list(input() for _ in range(n)))

s = Counter(s_list)

ans_num = s.most_common(1)[0][1]

s_1 = sorted(list(s.items()), key=lambda x: x[0])

for i in range(len(s_1)):
    if s_1[i][1] == ans_num:
        print(s_1[i][0])

Submission status: Accepted

Solution code:
def solve(n: int, words: list):
    word_map = dict()
    max_count = 0
    for word in words:
        count = word_map.get(word, 0) + 1
        word_map[word] = count
        max_count = max(max_count, count)
   
    for word in sorted(word_map.keys()):
        if(word_map[word] == max_count):
            print(word)


def main():
    n = int(input())
    li = []
    for i in range(n):
        li.append(input())
    solve(n, li)


main()

Submission status: Accepted

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

def calcFreq(list):
    freq_dict = {}
    for i in list:
        if i in freq_dict:
            freq_dict[i] += 1
        else:
            freq_dict[i] = 1
    sorted_freq_list=sorted(freq_dict.items(), key=lambda x:x[1], reverse=True)
    return sorted_freq_list

freq_list=calcFreq(string_list)
max_freq_number=freq_list[0][1]
string_list_most_freq=[]
for i in freq_list:
    if i[1] != max_freq_number:
        break 
    string_list_most_freq.append(i[0])
string_list_most_freq.sort()    

print('\n'.join(string_list_most_freq))

Submission status: Accepted

Solution code:
from collections import Counter
import itertools

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

cnt_words = Counter(s)

mode_v = cnt_words.most_common()[0][-1]
it = itertools.takewhile(
    lambda kv: kv[-1] == mode_v, cnt_words.most_common()
)
m = []
for i in it:
    m.append(i[0])
m.sort()
for item in m:
    print(item)

Submission status: Accepted

Solution code:
from collections import Counter
N=int(input())
ll=[input() for i in range(N)]
ll=Counter(ll)
ll=ll.most_common()
ll=sorted(ll,key=lambda x:(x[1]),reverse=True)
ans=[l for l in ll if l[1]==ll[0][1] ]
ans=sorted(ans,key=lambda x:(x[0]),reverse=False)
for i in ans:
    print(i[0])

Submission status: Accepted

Solution code:
from collections import defaultdict
N = int(input())
S = [input() for i in range(N)]
input_dict = defaultdict(int)
for key in S:
    input_dict[key] += 1
max_value = max(input_dict.values())
max_list = []
for k, v in input_dict.items():
    if v == max_value:
        max_list.append(k)
max_list.sort()
[print(i) for i in max_list]

Submission status: Accepted

Solution code:
import collections

N = input()
M = [input()for i in range(int(N))]
X = collections.Counter(M)
max(X.items(), key=lambda x:x[1])[0]
i = max(X.values())
Y = [k for k, v in X.items() if v == i]
b = len(Y)
Z = sorted(Y,key =str.lower)
for i, v in enumerate(Z):
    if i > b:
        break
    else:
        print(Z[i])

Submission status: Accepted

Solution code:
import collections, sys

n = sys.stdin.readline()
s = []
for _ in range(0,int(n)):
  s.append(sys.stdin.readline().replace('\n',''))

c = collections.Counter(s)
max = c.most_common()[0][1]
l = sorted(list(dict(filter(lambda x: x[1]==max, c.items())).keys()))
for k in l:
  print(k)

Submission status: Accepted

Solution code:
import collections
 
N = int(input())
l = [input() for _ in range(N)]
 
c = collections.Counter(l)
 
L = c.most_common()
 
values, counts = zip(*c.most_common())
 
A = list(values)
B = list(counts)
 
b = B.count(B[0])
 
a = A[0:b]
c = sorted(a)

for i in c[0:]:
		print(i)

Submission status: Accepted

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

max_value = max(Ss.values())  # maximum value
max_keys = [k for k, v in Ss.items() if v == max_value]
for k in sorted(max_keys):
  print(k)

Submission status: Accepted

Solution code:
from collections import Counter 
num = input()
ins = list()
aa = list()
qc = 0
for abhsa in range(0, int(num)):
  ins.append(input())
cnt = Counter(ins)
nums = cnt.most_common()
res = nums[0][0]
values, counts = zip(*cnt.most_common())
aa.append(values[0])
for haha in counts:
  aqc = qc + 1
  if int(len(counts) - int("1")) >= aqc:
    if counts[qc] == counts[aqc]:
      aa.append(values[aqc])
      qc += 1
    else:
      break
aca = sorted(aa)
print("\n".join(aca))

Submission status: Accepted

Solution code:
from collections import defaultdict
N = int(input())
mm = defaultdict(int)

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

max_val= max(mm.values())
mm_max = []
for kv in mm.items():
    if kv[1] == max_val:
        mm_max.append(kv)

mm_max.sort()
for v in mm_max:
    print(v[0])

Submission status: Accepted

Solution code:
from itertools import groupby
from operator import itemgetter
 
a = sorted(input() for _ in range(int(input())))
a = sorted((-sum(map(bool,g)), s) for s, g in groupby(a))
for _, s in next(groupby(a, itemgetter(0)))[1]:
  print(s)

Submission status: Accepted

Solution code:

import collections

n = int(input())

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

c = collections.Counter(ss)

l = c.most_common()
ans = []
ans.append(l[0][0])
for i in range(len(l)-1):
  if l[i][1] == l[i+1][1]:
    ans.append(l[i+1][0])
  else:
    break

ans.sort()

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

Submission status: Accepted

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

cc = c.most_common()
values, counts = zip(*c.most_common())
max_counts = max(counts)


counts_num = counts.count(max_counts)

ans = []
for i in range(counts_num):
    ans.append(values[i])
    
ans = sorted(ans)

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

Submission status: Accepted

Solution code:
import collections
n = int(input())
s = list(input() for i in range(n))
counted = collections.Counter(s)

m = max(counted.values())
chars = [key for key, value in counted.items()
             if value == m]
chars.sort()
for i in range(len(chars)):
    print(chars[i])

Submission status: Accepted

Solution code:
import sys
import numpy as np
import collections

n = int(input())

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

c = collections.Counter(s)

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

max = c_sort[0][1]
max_list = []

for it in c_sort:
    if (it[1] == max):
        max_list.append(it[0])   
max_list.sort()
for list in max_list:
    print(list)

Submission status: Accepted

Solution code:
import collections

N = int(input())
S_list = []
for i in range(N):
  S_list.append(input())
c = collections.Counter(S_list)
most_count = c.most_common()[0][1]

ans_list = []
for i in c.items():
  if i[1] == most_count:
    ans_list.append(i[0])

ans_list.sort()

for i in ans_list:
  print(i)

Submission status: Accepted

Solution code:
import collections

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

c = collections.Counter(S)
max = c.most_common()[0][1]
ans = [i[0] for i in c.items() if i[1] == max]
ans.sort()

for s in ans:
    print(s)

Submission status: Accepted

Solution code:
n=int(input())
s=[]
for i in range(n):
  s.append(input())
s.sort()
# print(s)
count=1
counts=[]
max=0
top_number=[]
for i in range(n-1):
  if s[i]==s[i+1]:
    count+=1
  if i==n-2 and s[i]==s[i+1]:
    counts.append(count)
    if max<count:
      max=count
      top_number=[i]
    elif max==count:
      top_number.append(i)
  if i==n-2 and s[i]!=s[i+1]:
    counts.append(count)
    if max<count:
      max=count
      top_number=[i]
    elif max==count:
      top_number.append(i)
    if max==1:
      top_number.append(i+1)
  elif s[i]!=s[i+1]:
    counts.append(count)
    if max<count:
      max=count
      top_number=[i]
    elif max==count:
      top_number.append(i)
    count=1
# print(counts)
# print(top_number)
for i in range(len(top_number)):
  print(s[top_number[i]])

Submission status: Accepted

Solution code:
import collections
def main(input_s):
    c = collections.Counter(input_s)
    c_sort = c.most_common(1)
    max_count = c_sort[0][1]
    out_result = []
    for key, value in c.items():
        if value==max_count:
            out_result.append(key)
    return out_result

if __name__ == '__main__':
    N = int(input()) #1行目のNを取得する
    s = [input() for i in range(N)] #複数行の数値の入力を取得
    huga = main(s)
    huga = sorted(huga)
    for i in huga:
        print(i)

Submission status: Accepted

Solution code:
import collections
n = int(input())
s = [input() for i in range(n)]
p = collections.Counter(s)
res = sorted(p.items(), key=lambda x: x[1],reverse = True)
 
keys = []
#keys = [i for i,m in p.items() if m == p.values()]
u = max(p.values())
for i,m in res:
  if(m == u):
    keys.append(i)
  else:
    break
keys=sorted(keys)
for i in range(len(keys)):
  print(keys[i])

Submission status: Accepted

Solution code:
import bisect

n = int(input())
sl = ['']*n
for i in range(n):
    sl[i] = input()
sl = sorted(sl, key=str.lower)
# print(sl)
c = 0
anss = []
max_n = 0
for i, t in enumerate(sl):
    if i == 0:
        c += 1
        target = t
        continue

    if t == target:
        c += 1
    else:
        if max_n < c:
            anss = []
            anss.append(target)
            max_n = c
        elif max_n == c:
            anss.append(target)
            max_n = c
        target = t
        c = 1

if max_n < c:
    anss = []
    anss.append(t)
elif max_n == c:
    anss.append(t)


print(*anss)

Submission status: Accepted

Solution code:
n = int(input())

S = list(str(input()) for i in range(n))
SortedS = sorted(S) #辞書式にソート
s = [] #各文字列の回数
S2 = [] #各文字列
count = 1
for i in range(n - 1):
    if i == n - 2 and SortedS[i] != SortedS[i + 1]:
        s.append(count)
        s.append(1)
        S2.append(SortedS[i])
        S2.append(SortedS[i + 1])
    
    else:
        if SortedS[i] == SortedS[i + 1]:
            count += 1
            if i == n - 2:
                s.append(count)
                S2.append(SortedS[i])
        else:
            s.append(count)
            S2.append(SortedS[i])
            count = 1

M = max(s)
for i in range(len(s)):
    if s[i] == M:
        print(S2[i])

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
sList = [input() for _ in range(n)]
c = Counter(sList).most_common()
ans = []
for i in range(len(c)):
    if c[i][1] == c[0][1]:
        ans.append(c[i][0])
    else:
        break
ans.sort()
print("\n".join(ans))

Submission status: Accepted

Solution code:
N = int(input())
dp = {}
max_num = 0
max_list =[]
for i in range(N):
    S = input()
    if S in dp:
        dp[S] += 1
    else:
        dp[S] = 1
    if dp[S] == max_num:
        max_list.append(S)
    elif dp[S] > max_num:
        max_list = [S]
        max_num = dp[S]
max_list.sort()
for s in max_list:
    print(s)

Submission status: Accepted

Solution code:
import collections
def resolve_c():
    n = input()
    s_l = [input() for i in range(int(n))]
    c = collections.Counter(s_l)
    values, counts = zip(*c.most_common())
    results = sorted(list(values[:collections.Counter(counts)[max(counts)]]))
    fin = [print(r) for r in results]
resolve_c()

Submission status: Accepted

Solution code:
from itertools import groupby
from operator import itemgetter
 
a = sorted(input() for _ in range(int(input())))
a = sorted((-len(list(g)), s) for s, g in groupby(a))
for _, s in next(groupby(a, itemgetter(0)))[1]:
  print(s)

Submission status: Accepted

Solution code:
n = int(input())
s = []
for i in range(n):
  s.append(input())
s.sort()
k = 0
f = s
maxk = 0
for i in range(n-1):
  if s[i] == s[i+1]:
    k = k+1
    if k == maxk :
      maxk = k
      f.append(s[i])
    elif k > maxk :
      maxk = k
      f = [s[i]]
  else:
    k = 0
for i in range(len(f)):
  print(f[i])

Submission status: Accepted

Solution code:
n = int(input())
s = [input() for _ in range(n)]
s.sort()
p = [s[0]]
k = [1]
for i in range(1,len(s)):
    if s[i] != s[i-1]:
        p.append(s[i])
        k.append(1)
    else: k[-1] += 1
max_k = max(k)
for i in range(len(p)):
    if k[i] == max_k:
        print(p[i])

Submission status: Accepted

Solution code:
from itertools import groupby
from operator import itemgetter
 
a = sorted(input() for _ in range(int(input())))
a = sorted((-len(tuple(g)), s) for s, g in groupby(a))
for _, s in next(groupby(a, itemgetter(0)))[1]:
  print(s)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    words = {}
    for _ in range(n):
        a = input()
        if a in words:
            words[a] += 1
        else:
            words[a] = 1
    max_val = 0
    results = []
    for i in words.keys():
        if words[i] > max_val:
            max_val = words[i]
            results = []
            results.append(i)
        elif words[i] == max_val:
            results.append(i)

            # results = [key
            #            for key in words.keys() if words[key] == max(words.values())]
            # results.sort()
    results.sort()
    print('\n'.join(map(str, results)))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import collections
 
n = int(input())
st = [input() for i in range(n)]
 
c = collections.Counter(st)
c.most_common()
c_val, c_key= zip(*c.most_common()) 
c_key,c_val = list(c_val),list(map(int,c_key))
counter = 0
res = []
if len(c_val) == 1:
  print(c_key[0])
else:
  for i in range(len(c_val)):
    if c_val[i] >= counter:
      counter = c_val[i]
      res.append(c_key[i])
  res = list(set(res))
  res.sort()
  
  for i in range(len(res)):
    print(res[i])

Submission status: Accepted

Solution code:
import collections
from sys import stdin


def get_result(data):
    N, S = data[0], data[1:]
    c = collections.Counter(S)
    max_count = max(c.values())
    output_s = [key for key, val in c.items() if val == max_count]
    output_s = sorted(output_s)
    return '\n'.join(output_s)

if __name__ == '__main__':
    raw_data = [val.rstrip('\n') for val in stdin.readlines()]
    data = [val for val in raw_data]
    result = get_result(data)
    print(result)

Submission status: Accepted

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

max_count = 0
max_str = []
for s, count in S.items():
    if count > max_count:
        max_count = count
        max_str = [s]
    elif count == max_count:
        max_str.append(s)

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

Submission status: Accepted

Solution code:
N = int(input())

L = {}

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

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

S = []
c = L[0][1]
for i in range(len(L)):
    if c == L[i][1]:
        S.append(L[i][0])
    else:
        break
S = sorted(S)
for s in S:
    print(s)

Submission status: Accepted

Solution code:
n = input()
n = int(n)
# strs= input().split()
hashs = {}

for i in range(n):
    s = input()
    if s not in hashs.keys():
        hashs[s] = 1
    else:
        hashs[s] += 1
# sorted(hashs.items(), key=lambda item:item[1])
maxs = 0
for key, value in hashs.items():
    maxs = max(maxs, value)

res = []
for key, value in hashs.items():
    if value == maxs:
        res.append(key)
res.sort()
for m in range(len(res)):
    print(res[m])

Submission status: Accepted

Solution code:
import collections

words = []
number = int(input())
for i in range(number):
    word = input()
    words.append(word)
new = collections.Counter(words)
most = max(new.values())
ans = new.most_common()
answer = []
for i in ans:
    if i[1] >= most:
        answer.append(i[0])
    else:
        pass
answer.sort()
for i in answer:
    print(i)

Submission status: Accepted

Solution code:
import collections
from collections import Counter
N= int(input())
S = []
for _ in range(N):
    S.append(input())
SS = Counter(S)    
Svalues = list(Counter(S).values())
SSS = max(Svalues)

keys = [k for k, v in SS.items() if v == SSS]
keys.sort()
X = len(keys)
for i in range (X):
   print(keys[i])

Submission status: Accepted

Solution code:
N = int(input())

ans = {}
m = 1
for _ in range(N):
    w = input()
    c = ans.get(w)
    # print(c)
    # print(type(c))
    if c == None:
        ans[w] = 1
    else:
        ans[w] = c + 1
        if c + 1 > m:
            m = c + 1
# print(ans)

tmp = []
for a in ans:
    if ans[a] == m:
        tmp.append(a)

tmp.sort()
for t in tmp:
    print(t)

Submission status: Accepted

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

max_val = max(A.values())
keys = [key for key in A if A[key] == max_val]
keys.sort()
for s in keys:
  print(s)

Submission status: Accepted

Solution code:
N = int(input())

dic = {}

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

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

keys = list(dic.keys())
for key in sorted(keys):
	if dic[key] == maxnum:
		print(key)