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:
if __name__ == "__main__":
    n = int(input())
    s = dict()
    for i in range(n):
        tmp = input()
        if tmp not in s:
            s[tmp] = [tmp]
        else:
            s[tmp].append(tmp)

    ls = sorted(s)

    maxvote = 0
    for ss in s:
        if len(s[ss]) > maxvote:
            maxvote = len(s[ss])

    for l in ls:
        if len(s[l]) == maxvote:
            print(l)

Submission status: Accepted

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

Submission status: Accepted

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

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

d = {}
for s in S:
    d.setdefault(s, 0)
    d[s] += 1

dmax = max(d.values())

dmax_list = [k for k, v in d.items() if v == dmax]
for d in sorted(dmax_list):
    print(d)

Submission status: Accepted

Solution code:
n = int(input())
s = [input() for _ in range(n)]
s.sort()
se = sorted(set(s))
j = 0
count = 0
l = [0] * len(se)
for i in s:
    if i == se[j]:
        count += 1
    else:
        l[j] = count
        j += 1
        count = 1
l[j] = count
ma = max(l)
ans = [i for i, x in enumerate(l) if x == ma]
for i in ans:
    print(se[i])

Submission status: Accepted

Solution code:
from collections import Counter

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

cnt = Counter(S)

most = 0
for i in cnt.values():
    most = max(most, i)

ans = []
for i in cnt:
    if cnt[i] == most:
        ans.append(i)

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.append(input())
word_dict = {}
for word in S:
    if word in word_dict:
        word_dict[word] += 1
    else:
        word_dict[word] = 1

max_v = max(word_dict.values())

for key in sorted(word_dict):
    if word_dict[key] == max_v:
        print(key)

Submission status: Accepted

Solution code:
import collections

N = int(input())

S_list = []

for i in range(N):
    tmp = str(input())
    S_list.append(tmp)

c = collections.Counter(S_list)

appear = max(list(c.values()))

keys = [k for k, v in c.items() if v == appear]

keys_sorted = sorted(keys)

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

Submission status: Accepted

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

ma = 0
for i in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1
    if d[s] > ma:
        ma = d[s]

res = []
for e in d:
    if d[e] == ma:
        res.append(e)

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

Submission status: Accepted

Solution code:
import numpy as np

N=int(input())

S=[]
count_S={}
for i in range(N):
    s=input()
    S.append(s)
    count_S[s]=0

for key in S:
    count_S[key]+=1

keys=np.array(list(count_S.keys()))
values=np.array(list(count_S.values()),dtype=np.int32)
out=np.where(values==np.max(values))
result=np.sort(keys[out])

for r in result:
    print(r)

Submission status: Accepted

Solution code:
N = int(input())
#A = list(map(int,input().split()))
d = dict()
for i in range(N):
    key = input()
    if key not in d:
        d[key] = 1
    else:
        d[key] += 1
val_max = 1
for key in d.keys():
    val_max = max(val_max, d[key])
ans = []
for key in d.keys():
    if d[key] == val_max:
        ans.append(key)
ans.sort()
for a in ans:
    print(a)

Submission status: Accepted

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


def solve(N: int, S: "List[str]"):
    d = sorted(set(S))
    cnt = {}
    m = 0
    for w in S:
        if not cnt.get(w):
            cnt[w] = 0
        cnt[w] += 1
        m = max(m, cnt[w])
    for w in d:
        if cnt[w] == m:
            print(w)
    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:
from collections import Counter

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

keys, values = zip(*S.most_common())

v_pre = values[0]
end_idx = None
for i in range(1, len(values)):
    if v_pre == values[i]:
        continue
    else:
        end_idx = i
        break

if end_idx is None:
    answer = keys
else:
    answer = keys[:end_idx]

answer = sorted(answer)
for a in answer:
    print(a)

Submission status: Accepted

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

l=sorted(l)
ll=[]
k=1
for i in range(n-1):
    if l[i]==l[i+1]:
        ll.append(k)
        k+=1
    else:
        ll.append(k)
        k=1
ll.append(k)
c=max(ll)
lll=[]
for i in range(n):
    if ll[i]==c:
        lll.append(l[i])

lll=sorted(set(lll))
for i in lll:
    print(i)

Submission status: Accepted

Solution code:
from collections import Counter

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

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

keys = [k for k, v in c.items() if v >= m]
for ans in sorted(keys):
    print(ans)

Submission status: Accepted

Solution code:
import collections

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

c = collections.Counter(l).most_common()[::1]
res = sorted([i[0] for i in c if i[1] == c[0][1]])
[print(i) for i in res]

Submission status: Accepted

Solution code:
from sys import stdin,stdout
def f(A):
	for i in A:
		if i%2==0:
			if i%3!=0 and i%5!=0:
				return 'DENIED'
	return 'APPROVED'

def main():  	
	for x in stdin:
		n = int(x)
		mx = 0
		dic = {}
		for i in range(n):
			s = input().strip('\n')
			if s in dic:dic[s] += 1
			else:dic[s] = 1
			mx = max(dic[s],mx)
		A = []
		for x in dic:
			if dic[x]==mx:A.append(x)
		A.sort()
		print('\n'.join(A))
if __name__ == "__main__":
    main()

Submission status: Accepted

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

sd = {}
for s in strings:
  if s in sd:
    sd[s] += 1
  else:
    sd[s] = 1

sorted_sd = sorted(sd.items(), key=lambda x:x[1], reverse=True)
pre_c = 0
ans = []
for s, c in sorted_sd:
  if c < pre_c:
    break
  ans.append(s)
  pre_c = c
for a in sorted(ans):
  print(a)

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())
ss = [input() for _ in range(n)]

counter = Counter(ss)

num = counter.most_common(1)[0][1]

ans = sorted([k for k in counter.keys() if counter[k] == num])
print(*ans, sep= '\n')

Submission status: Accepted

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

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

sorted_s = sorted(s, key=s.__getitem__, reverse=True)

print_list = []

for k in s:
    if s[k] == s[sorted_s[0]]:
        print_list.append(k)

for p in sorted(print_list):
    print(p)

Submission status: Accepted

Solution code:
n=int(input())

cnt={}
ans=[]

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

m=max(cnt.values())
key = sorted(cnt.keys())

for a in key:
    if cnt[a] == m:
        print(a)

Submission status: Accepted

Solution code:
from collections import Counter

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

counter = Counter(S)
c_most = counter.most_common()

# a = {}
# for s in S_unique:
#     a[s] = S.count(s)

maxval = c_most[0][1]

anss = []

for s in c_most:
    if s[1] == maxval:
        anss.append(s[0])
    else:
        break

anss = sorted(anss)

for a in anss:
    print(a)

Submission status: Accepted

Solution code:
n_paper = int(input())
vote_data = {}
for _ in range(n_paper):
    votename = input()
    if votename in vote_data:
        vote_data[votename] += 1
    else:
        vote_data[votename] = 1

max_n_vote = max(vote_data.values())
winners = [x for x in vote_data.keys() if vote_data[x] == max_n_vote]
winners.sort()
for winner in winners:
    print(winner)

Submission status: Accepted

Solution code:
import collections

N = int(input())
c = collections.Counter(input() for _ in range(N))

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

a = []
for i in c:
    if c[0][1] != i[1]: break
    a.append(i)

a = sorted(a)
for i in a:
    print(i[0])

Submission status: Accepted

Solution code:
def poll(n , s):

    ss = {}
    maxint = 0
    ans = []

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

    maxint = max(ss.values())

    ans = [k for k, v in ss.items() if v == maxint]

    ans.sort()
    return ans

def main():
    n = int(input())
    s =[str(input()) for i in range(n)]
    ans = poll(n , s)

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
a=[input() for i in range(n)]
a.sort()
a+="zzzzzzzzzzzzzzzzzzz"
m=[]
st=a[0];cnt=1
for i in range(1,n+1):
    if st!= a[i]:
        m.append((st,cnt))
        st=a[i]
        cnt=1
    else:
        cnt+=1
m.sort(key=lambda x:x[0])
m.sort(key=lambda x:x[1],reverse=True)
cnnnk=m[0][1]
for i in m:
    if i[1]==cnnnk:
        print(i[0])
    else:
        break

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
L = [str(input()) for _ in range(N)]
c = Counter(L)
ans = []
for i, x in enumerate(c.most_common()):
  if i>0 and x[1]!=m:
    break
  ans.append(x[0])
  m = x[1]
for x in sorted(ans):
  print(x)

Submission status: Accepted

Solution code:
n = int(input())
a = {}
for _ in range(n):
    c = input()
    if c not in a:
        a[c] = 0
    a[c] += 1

v0 = -1
b = []
for k, v in sorted(a.items(), key=lambda x: -x[1]):
    if v0 < v:
        v0 = v
    if v0 == v:
        b.append(k)

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

Submission status: Accepted

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

mx = max(S_dict.values()); ans = []
for st in S_dict.keys():
    if S_dict[st] == mx:
        ans.append(st)

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

Submission status: Accepted

Solution code:
import sys
N = int(input())
S = (str(x) for x in sys.stdin.read().split())
cnt = {}
for s in S:
  if cnt.get(s):
    cnt[s] = cnt[s] + 1
  else:
    cnt[s] = 1
max_cnt = max(cnt.values())
keys = [k for k, v in cnt.items() if v == max_cnt]
for k in sorted(keys):
  print(k)

Submission status: Accepted

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

li2 = collections.Counter(li)
li3 = li2.most_common()

li4 = []
for i in range(len(li3)):
    if li3[0][1] == li3[i][1]:
        li4.append(li3[i][0])
li4.sort()

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

Submission status: Accepted

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

d = sorted(d.items(), key = lambda x:x[1])
if len(d) <= 1:
    print(d[0][0])
    exit()

tmp, max_value = d.pop()
res = [tmp]
#print(d)
for i in range(len(d)):
    temp_name,temp_value = d.pop()
    if max_value == temp_value:
        res.append(temp_name)
    else:
        break

res.sort()
for i in res:
    print(i)
#print(res)

Submission status: Accepted

Solution code:
N = int(input())
now = 0
temp = {}
ans = []
for _ in range(N):
    a = input()
    if now == 1 or now == 0:
        ans.append(a)
    try:
        temp[a] += 1
        if temp[a] > now:
            ans = [a]
            now = temp[a]
        elif temp[a] == now:
            ans.append(a)
    except:
        temp[a] = 1

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

Submission status: Accepted

Solution code:
N = int(input())
S = dict()
for i in range(N):
  arg = str(input())
  if arg in S:
    S[arg] = S[arg] + 1
  else:
    S[arg] = 1

max_count = max(list(S.values()))
#print(max_count)

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

for kv in S_sorted:
  if kv[1] == max_count:
    print(kv[0])

Submission status: Accepted

Solution code:
N = int(input())
L = {}
for i in range(N):
  A = input()
  if not A in L:
    L[A] = 1
  else:
    L[A] += 1
S = []
maxv = 0
for i in L.keys():
  if L[i] == maxv:
    S.append(i)
  elif L[i] > maxv:
    S = [str(i)]
    maxv = L[i]
S.sort()
print("\n".join(S))

Submission status: Accepted

Solution code:
import collections
n=int(input())
l=[input() for i in range(n)]
c=collections.Counter(l)
k=c.most_common()
s=k[0][1]
b=[]
for i in k:
  if s==i[1]:
    b.append(i[0])
  else:
    break
m=sorted(b)
for o in m:
  print(o)

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())
c = Counter()
for i in range(n):
    c.update([input()])
    
times = c.most_common(1)[0][1]
res = [x[0] for x in c.items() if x[1]==times]
res.sort()

for i in res:
    print(i)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

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

mx = 0
d = {}
r = []

for a in A:
    if not a in d:
        d[a] = 0
    d[a] += 1
    if d[a] > mx:
        r = [a]
        mx = d[a]
    elif d[a] == mx:
        r.append(a)

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

Submission status: Accepted

Solution code:
N = int(input())

S_list = {}
ans = set()

for _ in range(N):
    S = input()
    try:
        S_list[S] += 1
    except KeyError:
        S_list[S] = 0

M = max(S_list.values())
S_list = sorted(S_list.items(), key = lambda x: x[0])

for s, v in S_list:
    if v == M:
        print(s)

Submission status: Accepted

Solution code:
import sys

num = input()
strings = []
for _ in range(int(num)):
    strings.append(input())

count_up = {}
for str in strings:
    if str in count_up:
        count_up[str] += 1
    else:
        count_up[str] = 1


count_up_sorted = sorted(count_up.items(), key=lambda x:x[1], reverse=True)
a = count_up_sorted[0][1]
# print("a:",a)
greaters = []
for value in count_up_sorted:
    if value[1] != a:
        break
    else:
        greaters.append(value[0])

greaters_sorted = sorted(greaters)
for value in greaters_sorted:
    print(value)
# print(strings)
# print(count_up)
# print(count_up_sorted)
# print(greaters)
# print(greaters_sorted)

Submission status: Accepted

Solution code:
N = int(input())
dict_names = dict()
for i in range(N):
  new_name = input()
  if new_name not in dict_names.keys():
    dict_names[new_name] = 1
  else:
    dict_names[new_name] += 1
max_count = max(count for count in dict_names.values())
list_of_max_counted_names = [name for name in dict_names if dict_names[name]==max_count]
list_of_max_counted_names.sort()
[print(name) for name in list_of_max_counted_names]

Submission status: Accepted

Solution code:
import collections

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

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

max_count = counter[0][1]
max_counter = 0

for order in counter:
  if max_count == order[1]:
    max_counter += 1
  else:
    break;

counter = counter[:max_counter]

for s in sorted(counter):
  print(s[0]);

Submission status: Accepted

Solution code:
N = int(input())

d_count = {}
for i in range(N):
    S = str(input())
    d_count.setdefault(S, 0)
    d_count[S] = d_count[S] + 1

max = 0
maxlist = []
for S in d_count:
    if(max < d_count[S] ):
        max = d_count[S]
        maxlist = [S]
    if(max == d_count[S]):
        maxlist.append(S)

maxlist_set = list(set(maxlist))
maxlist_set.sort()
for a in maxlist_set:
    print(a)

Submission status: Accepted

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

check_list = collections.Counter(text_list).most_common()
max_val = max([i[1] for i in check_list])
for i in sorted([i[0] for i in check_list if i[1] == max_val]):
    print(i)

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())

arr = []
for i in range(n) :
	
    arr.append(input())
    
c = Counter(arr).most_common()

max = 0

arr2 = []

for item in c :
  
  if max == 0 :
    
    max = item[1]
    
  if max == item[1] :
    
    arr2.append(item[0])
    
  else :
    
    break
    
arr2.sort()

for item in arr2 :
  
  print(item)

Submission status: Accepted

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

from collections import Counter
checked =  Counter(num_list)
before_count = 0
check_count = 0
result = []
for keyword, count in sorted(checked.items(), key=lambda x: -x[1]):
    if check_count == 0:
        check_count += 1
        result.append(keyword)
        before_count = count
    else:
        if count != before_count:
            break
        else:
            check_count += 1
            result.append(keyword)
            before_count = count

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

Submission status: Accepted

Solution code:
N = int(input())
S = [str(input()) for _ in range(N)]
#print(S)
dic={}
for i in range(N):
  if S[i] in dic.keys():
     dic[S[i]]+=1
  else:
     dic[S[i]]=1    
#print(dic)
sortedd = sorted(dic.items(), key=lambda x:x[1])
#print(sortedd)

maxc=sortedd[-1][1]
#maxc=max(dic.items())
#print(maxc)
#print(dic.keys())

sol=[]
for key in dic.keys():
  if dic[key] == maxc:
    sol+=[str(key)]
#print(sorted(sol))
for x in sorted(sol):
  print(x)
#  print(x+'\n')

Submission status: Accepted

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

for i in range(n):
  s=input()
  if s in d:
    d[s]=d[s]+1
  else:
    d[s]=1
    
maxno=0
z=[]
for k,v in d.items():
  if maxno<v:
    maxno=v
    z=[k,]
  elif maxno==v:
    z.append(k)
z.sort()
for i in z:
  print(i)

Submission status: Accepted

Solution code:
N = int(input())
S = []

import collections

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

C = collections.Counter(S)
C = C.most_common()

c_max = C[0][1]
ans = []
for i, c in enumerate(C):
  if c[1] == c_max:
    ans.append(c[0])
  else:
    break

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

Submission status: Accepted

Solution code:
import collections
n=int(input())
s=[]
ans=[]
for i in range(n):
    si=input()
    s.append(si)
s_new=collections.Counter(s)
s_most=s_new.most_common()
buf=s_most[0][1]
cnt=0
for i in range(len(s_new)):
    if s_most[i][1]==buf:
        ans.append(s_most[i][0])
        cnt+=1
    elif s_most[i][1]<buf:
        break
ans_sorted=sorted(ans)
for i in range(cnt):
    print(ans_sorted[i])

Submission status: Accepted

Solution code:
import collections

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

c = collections.Counter(S)
cnt = c.most_common()
num = cnt[0][1]

ans = []
for i in range(len(cnt)):
    if num == cnt[i][1]:
        ans.append(cnt[i][0])

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

Submission status: Accepted

Solution code:
import collections
N = int(input())
s = [input() for i in range(N)]
counter = collections.Counter(s)
max = max(dict(counter).values())
keys = [k for k, v in dict(counter).items() if v == max]
ans = sorted(keys)
for i in range (len(keys)):
  print(ans[i])

Submission status: Accepted

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

count = 0
l = []

for s in Counter(S).most_common():
    if count <= s[1]:
        l.append(s[0])
        count = s[1]
    else:
        break

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

Submission status: Accepted

Solution code:
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math

import itertools

#import bisect

import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]



def main():
    n=int(input())
    s=[input() for i in range(n)]
    s=sorted(s)
    s.append("")
    tempn=0
    temp=s[0]
    maxn=0
    aa=[]
    for i in range(n+1):
        if temp==s[i]:
            tempn+=1
        else:

            aa.append([s[i-1],tempn])
            maxn=max(maxn,tempn)
            tempn=1
            temp=s[i]
    aa=sorted(aa)

    for a,b in aa:
        if b==maxn:
            print(a)



if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
loopcnt = int(input())
dic = {}
for i in range(0, loopcnt):
    tmp = input()
    #print(dic[tmp])
    if tmp in dic:
        dic[tmp] += 1
    else:
        dic[tmp] = 1

dic_sorted = sorted(dic.items(),key=lambda x:(-x[1],x[0]))
limit = dic_sorted[0][1]
#debug
#print()
for nametpl in dic_sorted:
    if nametpl[1] == limit:
        print(nametpl[0])
    else:
        break

Submission status: Accepted

Solution code:
import collections
n = int(input())
ans = [input() for i in range(n)]
a = collections.Counter(ans)
b = a.most_common()
count = 1
if b[0][1]==1:
    ans.sort()
    for i in ans:
        print(i)
else:
    key = b[0][1]
    for i,j in enumerate(b):
        if j[1] < key:
            count = i
            break
    c = b[:count]
    d = [i[0] for i in c]
    d.sort()
    for i in d:
        print(i)

Submission status: Accepted

Solution code:
n = int(input())
list1 = []
for x in range(n):
    list1.append(input())
list1.sort()
cnts = [1]
vals = [list1[0]]
pos = 1
max_cnt = 0
max_val = []
while pos<n:
    if cnts[-1]>max_cnt:
        max_cnt = cnts[-1]
        max_val = [vals[-1]]
    elif cnts[-1]==max_cnt:
        max_val.append(vals[-1])
    if list1[pos]==vals[-1]:
        cnts[-1]+=1
    else:
        cnts.append(1)
        vals.append(list1[pos])
    pos+=1
if cnts[-1]>max_cnt:
        max_cnt = cnts[-1]
        max_val = [vals[-1]]
elif cnts[-1]==max_cnt:
        max_val.append(vals[-1])
max_val.sort()
for item in max_val:
    print(item)

Submission status: Accepted

Solution code:
import collections
n=int(input())
s = []
for _ in range(n):
    s.append(input())
c = collections.Counter(s)
a = max(c.values())
b = []
for i in c:
    if c[i] == a:
        b.append(i)
b.sort()
for i in b:
    print(i)

Submission status: Accepted

Solution code:
n = int(input())
lis=[input() for i in range(n)]
import collections
ans = []
c = collections.Counter(lis)
clis = c.most_common()
for i in range(len(clis)):
    if clis[i][1] == clis [0][1]:
        ans.append(clis[i][0])
ans.sort()
for j in ans:
    print(j)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections

n = int(input())

l = []

for i in range(n):
    l.append(input())
c = collections.Counter(l)
cx = c.most_common()
nm = cx[0][1]
ans = []
ans.append(cx[0][0])
for i in range(1, len(cx)):
    if (nm == cx[i][1]):
        ans.append(cx[i][0])
    else:
        break

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

Submission status: Accepted

Solution code:
n = int(input())
ans = []
for i in range(n):
    if i == 0:
        s = input()
        S = {s: 1}
        ans.append(s)
        mx = 1
    else:
        s = input()
        if s in S:
            S[s] += 1
            if S[s] > mx:
                ans = [s]
                mx = S[s]
            elif S[s] == mx:
                ans.append(s)
        else:
            S[s] = 1
            if S[s] == mx:
                ans.append(s)
ans = sorted(ans)
for a in ans:
    print(a, sep="\n")

Submission status: Accepted

Solution code:
N = int(input())
S = []

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

Submission status: Accepted

Solution code:
dic = {}

def inn(s):
  if s in dic:
    dic[s] += 1
  else:
    dic[s] = 1

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

m = max(dic.values())
s = list(filter(lambda n:dic[n]==m, dic))

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

Submission status: Accepted

Solution code:
#!python3.4.3

n = int(input())
s_list = []
s_dict = {}
for _ in range(n):
    s = input()
    s_list.append(s)
    if s in s_dict.keys():
        s_dict[s] += 1
    else:
        s_dict[s] = 1

max_ = max(s_dict.values())
result = [key for key in s_dict if s_dict[key] == max_]
result = sorted(result)

for i in result:
    print(i)

Submission status: Accepted

Solution code:
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def has_duplicates(seq):
    return len(seq) != len(set(seq))


N = INT()

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

import collections
S = collections.Counter(S)

T = S.most_common()

ans = []

num = T[0][1]
for t in T:
    if t[1] == num:
        ans.append(t[0])
    else:
        break
ans = sorted(ans)
for a in ans:
    print(a)

Submission status: Accepted

Solution code:
from collections import Counter
def main():
    n=int(input())
    S=tuple(input() for _ in range(n))
    D=Counter(S)
    m=max(D.values())
    L = [d[0] for d in D.items() if d[1]==m]
    L=sorted(L)
    for l in L:
        print(l)
main()

Submission status: Accepted

Solution code:
N = int(input())
S = []

for i in range(N):
  S.append(input())
  
S.sort()
SS = S
count = 1
maxcount = 1
ans = []

for i in range(1, N):
  if S[i-1] == S[i]:
    count += 1
    if count == maxcount:
      ans.append(S[i])
    if count > maxcount:
      ans = []
      ans.append(S[i])
      maxcount = count
  else:
    count = 1
    
if ans == []:
  ans = SS
  
for a in ans:
  print(a)

Submission status: Accepted

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

Submission status: Accepted

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

import collections
c = collections.Counter(s)
values, counts = zip(*c.most_common())

maxn = counts[0]
cnt = counts.count(maxn)
l = []
for i in range(cnt):
  l.append(values[i])

l.sort()

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

Submission status: Accepted

Solution code:
import collections


n = int(input())
w_l = [input() for _ in range(n)]

counter = collections.Counter(w_l)

c_l = counter.most_common()
max_v = c_l[0][1]
ans_l = []
for i in range(len(c_l)):
    word, num = c_l[i]
    if max_v != num:
        break
    ans_l.append(word)

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

Submission status: Accepted

Solution code:
import collections

n = int(input())
l = [input() for _ in range(n)] 
c = collections.Counter(l)
mc = c.most_common()
maxlist = list()
for v, i in mc:
    if i == mc[0][1]:
        maxlist.append(v)
    else:
        break

maxlist.sort()

for j in maxlist:
    print(j)

Submission status: Accepted

Solution code:
from sys import stdin
##  input functions for me
def ria(sep = ''):
    if sep == '' :
        return list(map(int, input().split())) 
    else: return list(map(int, input().split(sep)))
def rsa(sep = ''):
    if sep == '' :
        return input().split() 
    else: return input().split(sep)
def ri(): return int(input())
def rd(): return float(input())
def rs(): return input()
##

## main ##
N = ri()
S = [""] * N
for i in range(N):
    S[i] = rs()

di = dict()
for s in S:
    if not s in di: di[s] = 0
    di[s] += 1

ma = 0
for s in di:
    ma = max(ma, di[s])

l = []
for s in di:
    if di[s] == ma: l.append(s)

l.sort()
print("\n".join(l))

Submission status: Accepted

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

c = Counter(S)
keys, values = zip(*c.most_common())

name = []
k = values[0]

for i in range(len(keys)):
    if values[i] == k:
        name.append(keys[i])

name.sort()

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

Submission status: Accepted

Solution code:
import collections
n = int(input())

s = []
ans = []

for _ in range(n):
    s.append(input())

c = collections.Counter(s)
max_c = max(c.values())

for si, vi in c.items():
    if vi == max_c:
        ans.append(si)

ans2 = sorted(ans)

for s2 in ans2:
    print(s2)

Submission status: Accepted

Solution code:
import collections

n=int(input())
list=[]
for i in range(n):
    s=input()
    list.append(s)
c=collections.Counter(list)
most=c.most_common()
i=0
ans=[most[0][0]]
flag=1
for i in range(len(most)-1):
    if most[i][1]==most[i+1][1]:
            ans.append(most[i+1][0])
    else:
        break
ans.sort()
for i in range(len(ans)):
    print(ans[i])