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())

counter = {}
max_count = 0
for _ in range(N):
    s = input()
    n = counter.get(s, 0) + 1
    max_count = max(max_count, n)
    counter[s] = n

most_common = (k for k, v in counter.items() if v == max_count)
for s in sorted(most_common):
    print(s)

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
prev = -1
for k, v in sorted(Counter(input() for _ in range(n)).most_common(), key=lambda kv: (-kv[1], kv[0])):
    if prev > 0 and prev != v:
        break
    print(k)
    prev = v

Submission status: Accepted

Solution code:
n=int(input())
dic = {}
for i in range(n):
    st=input()
    dic.setdefault(st,0)
    dic[st]+=1
ans=0
answers=[]
for k,v in dic.items():
    if v==ans:
        ans=v
        answers.append(k)
    elif v>ans:
        ans=v
        answers=[k]
answers.sort()
for ans in answers:
    print(ans)

Submission status: Accepted

Solution code:
def main():
    import sys
    from collections import Counter

    N = int(input())
    S = [sys.stdin.readline().rstrip('\n') for _ in range(N)]
    c = Counter(S)
    _max = max(c.values())
    keys = [k for k, v in c.items() if v == _max]
    print('\n'.join(sorted(keys)))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
num = input()

strs = []

for i in range(int(num)):
  strs.append(input())

strs.sort()

b = ""
cnt = 0
max = -1
maxstr = set()

for s in strs:
  if b == s:
    cnt += 1
  else:
    cnt = 0
  if cnt > max:
    max = cnt
    maxstr.clear()
    maxstr.add(s)
  elif cnt == max:
    maxstr.add(s)
  b = s

ls = list(maxstr)
ls.sort()
for m in ls:
  print(m)

Submission status: Accepted

Solution code:
i = int(input())

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


dic2 = sorted(dic.items(), key=lambda x:x[1])
k = len(dic2)-1
s = 0
ans = []
for p in range(len(dic2)):
    t = dic2[k][1]
    ans.append(dic2[k][0])
    k -= 1
    if t == dic2[k][1]:
        s = 1
    else:
        break
ans.sort()
for ak in ans:
    print(ak)

Submission status: Accepted

Solution code:
n = int(input())
dic = {}
for i in range(n):
    string = input()

    if string in dic:
        dic[string] += 1
    else:
        dic[string] = 0

answers = []
app = 0

for key, value in dic.items():
    if value > app:
        answers.clear()
        answers.append(key)
        app = value
    elif value == app:
        answers.append(key)

answers.sort()
for ans in answers:
    print(ans, sep="\n")

Submission status: Accepted

Solution code:
def main():
    from collections import Counter

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

    c = Counter(S)
    _max = max(c.values())

    keys = [k for k, v in c.items() if v == _max]
    print('\n'.join(sorted(keys)))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    from collections import Counter

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

    c = Counter(S)
    _max = max(c.values())

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

def main():
    from collections import Counter
    
    N = int(input())
    S = [input() for _ in range(N)]
    
    c = Counter(S)
    _max = max(c.values())
    
    ans = []
    for k, v in c.items():
        if v == _max:
           ans += [k]
    
    for a in sorted(ans):
        print(a)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import Counter

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

c = Counter(S)
_max = max(c.values())

ans = []
for k, v in c.items():
    if v == _max:
       ans += [k]

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

Submission status: Accepted

Solution code:
import collections

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

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

count = common[0][1]
ans = []
for i in common:
  if i[1] == count:
    ans.append(i[0])
  else:
    break
ans.sort()
print(*ans,sep='\n')

Submission status: Accepted

Solution code:
dic = {}
N = int(input())
for i in range(N):
    tmp = input()
    if tmp in dic:
        dic[tmp] += 1
    else:
        dic[tmp] = 1
m = max(sorted(dic.values()))
ans = []
for i in dic.items():
    if i[1] == m:
        ans.append(i[0])
for i in sorted(ans):
    print(i)

Submission status: Accepted

Solution code:
N = int(input())
lis = []
indexes = []
cou = 1
ans = []
c_p = 0
for _ in range(N):
  lis.append(input())
lis.sort()
if len(lis) != len(set(lis)):
  lis.append("zzzzzzzzzzzzzz")
  for i in range(N):
    if lis[i] == lis[i+1]:
      cou += 1
    else:
      indexes.append(cou)
      cou = 1
  L = len(indexes)
  M = max(indexes)
  for k in range(L):
    if indexes[k] == M:
      ans.append(lis[c_p])
    c_p += indexes[k]
  print(*ans)
else:
  print(*lis)

Submission status: Accepted

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

for _ in range(n):
    s = input()
    if s in dict1:
        dict1[s] += 1
    else:
        dict1[s] = 1

dict_sorted = sorted(list(dict1.items()), key = lambda x: x[0])
dict_sorted.sort(key = lambda x: x[1], reverse = True)

max1 = dict_sorted[0][1]

for i in range(len(dict_sorted)):
    if dict_sorted[i][1] == max1:
        print(dict_sorted[i][0])
    else:
        break

Submission status: Accepted

Solution code:
N=int(input())

Di={"":0}

for i in range(N):
    poll=str(input())
    
    if poll in Di.keys():
        Di[poll] += 1
    else:
        Di[poll] = 1


Di=sorted(Di.items())
Di.remove(("",0))

maxvalue=0
maxkey=[]

#print(Di)
for k in Di:
    if k[1] > maxvalue:
        maxvalue=k[1]
        maxkey=[]
        maxkey.append(k[0])
    elif k[1] == maxvalue:
        maxkey.append(k[0])

for m in maxkey:
    print(m)

Submission status: Accepted

Solution code:
import collections
N = int(input())
s = []
for _ in range(N):
    s.append(input())
word_nums = collections.OrderedDict(sorted(collections.Counter(s).items(), key=lambda x: x[1], reverse=True))
max_num = max(list(word_nums.values()))
output = []
for i, j in word_nums.items():
    if max_num == j:
        output.append(i)
    else:
        break
for i in sorted(output):
    print(i)

Submission status: Accepted

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

counter=Counter(list1)
m=max(counter.values())

ans=[]
for word,c in counter.most_common():
    if c==m:
        ans.append(word)
    else:
        break

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

Submission status: Accepted

Solution code:
import collections

n = int(input())
li = list()

for i in range(n):
    li.append(input())

key = list(collections.Counter(li).keys())
value = list(collections.Counter(li).values())
ans = list()
maxValue = max(value)

for i in range(len(value)):
    if maxValue == value[i]:
        ans.append(key[i])

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

Submission status: Accepted

Solution code:
n = int(input())

d = {}

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

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

Submission status: Accepted

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

for _ in range(n):
    s = input()
    if s in dict1:
        dict1[s] += 1
    else:
        dict1[s] = 1

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

max1 = dict_sorted[0][1]

for i in range(len(dict_sorted)):
    if dict_sorted[i][1] == max1:
        print(dict_sorted[i][0])
    else:
        break

Submission status: Accepted

Solution code:
Nu=int(input())
dic={}
ls=[]
maxd=0
for i in range(Nu):
  tmp=input()
  if tmp in dic:
    dic[tmp]=dic[tmp]+1
    maxd=max(dic[tmp],maxd)
  else:
    dic[tmp]=0
for k,v in dic.items():
  if v==maxd:
    ls.append(k)
ls.sort()
for x in ls:
  print(x)

Submission status: Accepted

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

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

s.sort()

max1 = 0
ans = []
tmp = ''
count = 0

for i in s:
    if tmp == i:
        count += 1
    else:
        if max1 > count:
            count = 1
            tmp = i
        elif max1 == count:
            ans.append(tmp)
            count = 1
            tmp = i
        else:
            ans = [tmp]
            max1 = count
            count = 1
            tmp = i

if max1 > count:
    count = 1
    tmp = i
elif max1 == count:
    ans.append(tmp)
    count = 1
    tmp = i
else:
    ans = [tmp]
    max1 = count
    count = 1
    tmp = i

for i in ans:
    print(i)

Submission status: Accepted

Solution code:
import collections
n = int(input())
s = [input() for _ in range(n)]
c = collections.Counter(s)
mv = c.most_common()[0][1]
l = [i for i,v in c.items() if v == mv]
l.sort()
for j in l:
    print(j)

Submission status: Accepted

Solution code:
input = open(0).readline
n = int(input())
array = []

for i in range(n):
    x = input().rstrip('\n')
    array.append(x)
    
d = {}

for s in array:
    if s in d.keys():
        d[s] +=1
    else:
        d[s] = 1

max_val = max(d.values())
array2 = [key for key in d if d[key] == max_val]
array2 = sorted(array2)

for s in array2:
    print(s)

Submission status: Accepted

Solution code:
import collections


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

dic = collections.Counter(s)
k = dic.most_common()
m = k[0][1]
mx = m
i = 0
ans = []
while m == mx: 
    ans.append(k[i][0])
    i += 1
    if i > len(k)-1:
        break
    m = k[i][1]

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

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
S = [input() for i in range(N)]
c = Counter(S)
ans = c.most_common()
ans = [i[0] for i in ans if i[1] == ans[0][1]]
for i in sorted(ans):
    print(i)

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
c = Counter(S)
ans = c.most_common()
ans = [i[0] for i in ans if i[1] == ans[0][1]]
for i in sorted(ans):
    print(i)

Submission status: Accepted

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

M = max(D.values())
for S in sorted(list(D)):
    if D[S]==M:
      print(S)

Submission status: Accepted

Solution code:
import collections

N = int(input())

l = []
for x in range(N):
    x = input()
    l.append(x)

l_dict = collections.Counter(l)

max_n = max(l_dict.values())

l_max = sorted([x[0] for x in l_dict.items() if x[1] == max_n])

for a in l_max:
    print(a)

Submission status: Accepted

Solution code:
N = int(input())

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

dic = {}
for i in data:
  dic[i] = dic.get(i, 0) + 1

data = []
for i in dic.keys():
  data.append((-dic[i], i))

data.sort()

thresh = data[0][0]
for i in data:
  if i[0] == thresh:
    print(i[1])

Submission status: Accepted

Solution code:
import sys

lines = [l.rstrip() for l in sys.stdin.readlines()]
d = {}

n = int(lines[0])
for l in lines[1:]:
    if l in d.keys():
        d[l] += 1
    else:
        d[l] = 1

s = sorted(d.items(), key=lambda x: -x[1])
l = sorted([e for e in s if e[1] == s[0][1]], key=lambda x: x[0])

for k, _ in l:
    print(k)

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

max_s = max(dic.values())
max_s_list = []


for k,v in dic.items():
    if v == max_s:
        max_s_list.append(k)

max_s_list = sorted(max_s_list)

for j in max_s_list:
    print(j)

Submission status: Accepted

Solution code:
import collections

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

c = collections.Counter(s)
max_num = max(c.values())
d = []
for key,value in c.items():
  if value == max_num:
    d.append(key)

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

Submission status: Accepted

Solution code:
from collections import Counter

N = int(input())
cnt = Counter()
for i in range(N):
  cnt[input()] += 1

mc = cnt.most_common(1)[0][1]
ms = []
for kw, count in cnt.most_common():
  if(count<mc):
    break
  ms.append(kw)
  
ms.sort()
for s in ms:
  print(s)

Submission status: Accepted

Solution code:
n = int(input())
dict = {}
for i in range(n):
  a = input()
  if (not (a in dict.keys())):
    dict[a] = 1
  else:
    dict[a] += 1
b = max(dict.values())
list = []
for i in dict.keys():
  if dict[i] == b:
    list.append(i)
list.sort()
for i in list:
  print(i)

Submission status: Accepted

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

list = sorted(d.values())
max_value = max(list)
sorted_list = sorted(d.items(), key=lambda x: x[0])

for i, j in sorted_list:
    if j == max_value:
        print(i)

Submission status: Accepted

Solution code:
N = int(input())
l = {}
for _ in range(N):
  s = input()
  l.setdefault(s, 0)
  l[s] += 1
l = sorted([(v, k) for k, v in l.items()])
c = l[-1][0]
r = []
for i in range(-1, -len(l)-1, -1):
  if l[i][0] < c:
    break
  r.append(l[i][1])
for x in reversed(r):
  print(x)

Submission status: Accepted

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

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

a = len(list1)-1
temp = len(list1)-1
list2 = []
while a >= 0 and list1[temp][1] == list1[a][1]:
    list2.append(list1[a][0])
    a -= 1
list2.sort()

for a in list2:
    print(a)

Submission status: Accepted

Solution code:
n = int(input())
Dict = {}
for i in range(n):
  Str = input()
  if Str in Dict:
    Dict[Str]+=1
  else:
  	Dict[Str] = 0 
List = list(Dict.values())
Max = max(List)
Dict_sorted = sorted(Dict.items(), key=lambda x:x[0])
for i,j in Dict_sorted:
  if j ==Max:
    print(i)

Submission status: Accepted

Solution code:
N = int(input())

strs = []
dicts = {}
for i in range(N):
    s = input()
    if dicts.get(s) is not None:
        dicts[s] += 1
    else:
        dicts[s] = 1

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

i = 0
sts = []
for s in dict_sorted:
    if dicts[s[0]] == dicts[dict_sorted[0][0]]:
        sts.append(s[0])
    i = dicts[s[0]]

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

Submission status: Accepted

Solution code:
from collections import defaultdict

N = int(input())
A = [input() for _ in range(N)]
A.sort()
d = defaultdict(int)
for a in A:
    d[a] += 1

l = sorted(d.items())
max_v = 0

for _, v in l:
    if v > max_v:
        max_v = v
    
for k, v in l:
    if v == max_v:
        print(k)
    else:
        continue

Submission status: Accepted

Solution code:
import sys

ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: [int(x) for x in ns().split()]
nall = lambda: [int(x) for x in sys.stdin.readlines()]
sall = lambda: [x.strip() for x in sys.stdin.readlines()]

def main():
    _ = ni()
    xs = sall()
    d = {}
    for x in xs:
        if x in d:
            d[x] = d[x] + 1
        else:
            d[x] = 1

    r = []
    m = 0
    for k, v in d.items():
        if v > m:
            r = [k]
            m = v
        elif v == m:
            r.append(k)

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


main()

Submission status: Accepted

Solution code:
n = int(input())

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

s.sort()

count_ = 0
max_ = 0
tmp = 'DUMMY'
ans = []
for i in range(n):
    if(tmp == s[i]):
        count_ += 1
    else:
        if(max_ < count_):
            max_ = count_
            ans = [tmp]
        elif(max_ == count_):
            ans.append(tmp)
        count_ = 1
        tmp = s[i]

if(max_ < count_):
    max_ = count_
    ans = [tmp]
elif(max_ == count_):
    ans.append(tmp)

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

d=Counter(S)
maxi=0
for i in d.keys():
    maxi=max(maxi,d[i])

ans=[]
for i in d.keys():
    if d[i]==maxi:
        ans.append(i)
ans=sorted(ans)
print('\n'.join(ans))

Submission status: Accepted

Solution code:
n = int(input())
wk = wkmax = 0
si = {}
for i in range(n):
    st = input()
    if st in si:
        si[st] = si[st] + 1
    else:
        si[st] = 1
    wk = si[st]
    wkmax = max(wk,wkmax)
sl = sorted(si.items())
for i in range(len(sl)):
    if wkmax == sl[i][1]:
        print(sl[i][0])

Submission status: Accepted

Solution code:
import collections
n=int(input())
s=[]
num=[]
ans=[]
for i in range(n):
    s.append(input())
c = collections.Counter(s)
v=(c.most_common())
num=v[0][1]
for j in v:
    if (j[1]==num):
        ans.append(j[0])
    else:
        break
for k in sorted(ans):
	print(k)

Submission status: Accepted

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

ans_n = max(s.values())

sorted_s = sorted(s.items())

for i in range(len(sorted_s)):
    if sorted_s[i][1] == ans_n:
        print(sorted_s[i][0])

Submission status: Accepted

Solution code:
from collections import Counter

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

c = Counter(S)
c_max = max(c.values())
[print(x) for x in sorted([s for s in set(S) if c[s] == c_max])]

Submission status: Accepted

Solution code:
N = int(input())

S_dict = dict()

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

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

max_polled = score_S_list[0][1]

max_polled_S = list()

for S in score_S_list:
    if S[1] == max_polled:
        max_polled_S.append(S[0])
    else:
        break
        
max_polled_S.sort()

for S in max_polled_S:
    print(S)

Submission status: Accepted

Solution code:
from collections import Counter

votes = Counter([input() for _ in range(int(input()))])

v = votes.most_common()
num = v[0][1]


ans_list = []
for i in  v:
	if(i[1] == num):
		 ans_list.append(i[0])
	else:
		break

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

Submission status: Accepted

Solution code:
N = int(input())

dic = {}

for i in range(N):
    S = input()
    
    if (S in dic) == False:
        dic[S] = 1
    else:
        dic[S] += 1
        
keys = []
maxv = max(dic.values())
for key , value in dic.items():
    if value == maxv:
        keys.append(key)
k = keys.sort()
for i in keys:
    print(i)

Submission status: Accepted

Solution code:
N = int(input())
dc={}
for i in range(N):
  s=input()
  if s in dc:
    dc[s]+=1
  else:
    dc[s]=1
m=max(dc.values())
w = [kv[0] for kv in dc.items() if kv[1] == m]
w.sort()
for p in w:
  print(p)

Submission status: Accepted

Solution code:
import sys

lines = [l for l in sys.stdin]
length = int(lines[0])
words = lines[1:]
counter = {w: 0 for w in words}

for w in words:
  counter[w] += 1
  
max_count = max(counter.values())

ret = [w for w, v in counter.items() if v == max_count]
ret.sort()
for w in ret:
  print(w)

Submission status: Accepted

Solution code:
from collections import Counter

# Initializing variables
n = int(input())
s = [input() for i in range(n)]
c = Counter(s)  # This is a dictionary
max_ = max(c.values())  # print(max_) == prints max number of times sth that was said the most was in user input.

# Calculating...
c = sorted([k for k, v in c.items() if v == max_])
for j in c :
    print(j)

Submission status: Accepted

Solution code:
import collections

number = int(input())

array = []

for i in range(number):
    array.append(input())

dic = collections.Counter(array).most_common()

max_dic = [dic[0][0]]

for i in range(len(dic) - 1):
    if dic[i + 1][1] == dic[0][1]:
        max_dic.append(dic[i + 1][0])
        
max_dic.sort()

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

Submission status: Accepted

Solution code:
n = int(input())

d = {}
for i in range(n):
  t = input()
  if t in d.keys():
    d[t] += 1
  else:
    d[t] = 0

s = sorted(list(set(d.keys())))
m = max(d.values())

for s in s:
  if d[s] == m:
    print(s)

Submission status: Accepted

Solution code:
N = int(input())

d = {}

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

m = max(d.values())
      
#n = [int(x) for x in input().split()]

s = sorted(k for k in d if d[k] == m)

for i in s:
  print(i)

Submission status: Accepted

Solution code:
from collections import Counter

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

d = Counter(s)
m = max(d.values())
ans = [i for i in d if d[i] == m]
ans = sorted(ans)

for i in ans:
    print(i)

Submission status: Accepted

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

count = {}
for s in S:
    count[s] = count.get(s, 0) + 1
max_count = max(count.values())
ret = []
for k in count.keys():
    if count[k] == max_count:
        ret.append(k)
ret = sorted(ret)
for r in ret:
    print(r)

Submission status: Accepted

Solution code:

from collections import Counter


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

C=Counter(S).most_common()
L=len(C)

D=[]

D.append(C[0][0])

for i in range(1,L):
    if C[0][1]==C[i][1]:
        D.append(C[i][0])
D.sort()
M=len(D)

for i in range(M):
    print(D[i])

Submission status: Accepted

Solution code:
import collections
n = int(input())
arr = []
ans = []
for i in range(n):
    s = input()
    arr.append(s)
c = collections.Counter(arr)
max_s = c.most_common()[0][1]
for j, k in c.items():
    if k == max_s:
        ans.append(j)
s_ans = sorted(ans)
for l in s_ans:
    print(l)

Submission status: Accepted

Solution code:
from collections import Counter
import sys
input=sys.stdin.readline
n=int(input())
s=[input().rstrip() for _ in range(n)]
C=Counter(s).most_common()
f=C[0][1]
t=[]
for k,v in C:
	if v<f:
		break
	t.append(k)
print(*sorted(t),sep="\n")

Submission status: Accepted

Solution code:
import sys

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

dicstok = {}
dicktos = {}

for i in range(n):
  k = s[i]
  v = dicstok.get(k, 0)
  dicstok[k] = v+1

  if(dicktos.get(v+1) == None):
    dicktos[v+1] = set([])
  dicktos[v+1].add(k)
  # setから消す
  if(v>=1):
    dicktos[v].discard(k)


ls = len(dicktos)
l = list(sorted(list(dicktos[ls])))

for k in l:
  print(k)

Submission status: Accepted

Solution code:
import collections
n=int(input())
li=[input() for _ in range(n)]
c=collections.Counter(li)
M=max(c.values())
ans=[]
for k,v in c.items():
    if v==M:
      ans.append(k)
ans.sort()
for i in range(len(ans)):
  print(ans[i])

Submission status: Accepted

Solution code:
from collections import defaultdict

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

d = defaultdict(int)
for key in S:
    d[key] += 1
    
dl = sorted(d.items(), key=lambda x: x[0], reverse=False)
Max = max(d.values())

for i in range(len(dl)):
  if dl[i][1] == Max:
    print(dl[i][0])

Submission status: Accepted

Solution code:
import collections

N = int(input())
list_1 = [input() for i in range(N)]
list_2 = collections.Counter(list_1)

m = max(list_2.values())

ans = [k for k in list_2 if list_2[k] == m]

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

Submission status: Accepted

Solution code:
import collections
n = int(input())
lst = [input() for i in range(n)]
c = collections.Counter(lst)
num = max(c.values())
lst = []
for k,v in c.items():
    if v==num:
        lst.append(k)
lst.sort()
for l in lst:
    print(l)

Submission status: Accepted

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

counted = collections.Counter(s)

m = max(counted.values())

chars = []
for key, value in counted.items():
    if value == m:
        chars.append(key)
chars=sorted(chars)

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

Submission status: Accepted

Solution code:
import collections

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

maxn = m[0][1]
ans = []

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

Submission status: Accepted

Solution code:
import collections

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

maxn = m[0][1]
ans = []

ans.append(m[0][0])
for i in range(len(m)-1):
    if m[i+1][1] == maxn:
        ans.append(m[i+1][0])
    else:
        break
for i in sorted(ans):
    print(i)

Submission status: Accepted

Solution code:
import collections
 
n = int(input())
s = [input() for i in range(n)]
 
counter = collections.Counter(s)
most = counter.most_common()
ans = []
for i in range(len(counter.keys())):
    if most[i][1] == most[0][1]:
        ans.append(most[i][0])
    else:
        break
ans.sort()
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
import sys

n = int(input())
s_di = dict()

for i in range(n):
    t = input()
    if t not in s_di:
        s_di[t] = 1
    else:
        s_di[t] += 1

s_di = sorted(tuple(s_di.items()))
s_di = sorted(s_di, key=lambda s: s[1])
# print(s_di)

n_max = s_di[-1][1]

for s in s_di:
    if s[1] == n_max:
        print(s[0])

Submission status: Accepted

Solution code:
n = int(input())
d = dict()
max_value = 0
for i in range(n):
  x = input()
  if x in d:
    d[x] += 1
  else:
    d[x] = 1
  max_value = max([max_value, d[x]])

d = sorted([(key, value) for key, value in d.items()], key = lambda x: x[0])
for key, value in d:
  if value == max_value:
    print(key)

Submission status: Accepted

Solution code:
n = int(input())
mymap = {}
maxi = 0
for i in range(n):
	s = str(input())
	if (s in mymap):
		mymap[s] += 1
	else:
		mymap[s] = 1
	maxi = max(maxi, mymap[s])
	
ans = []

for key in mymap:
	if (mymap[key] == maxi):
		ans.append(key)
		
ans.sort()

for s in ans:
	print(s)

Submission status: Accepted

Solution code:
n = int(input())
s_dic = {}
count = 0
for i in range(n):
    tmp = input()
    s_dic.setdefault(tmp, 0)
    s_dic[tmp] += 1
    if count < s_dic[tmp]:
        count = s_dic[tmp]
ans = [k for k, v in s_dic.items() if v == count]
ans.sort()
for a in ans:
    print(a)

Submission status: Accepted

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

c=collections.Counter(a)
m=c.most_common()
most=m[0][1]
ans=[]
ans.append(m[0][0])
for i in range(len(m)-1):
  if m[i+1][1]==most:
       ans.append(m[i+1][0])
  else:
       break
for out in sorted(ans):
       print(out)

Submission status: Accepted

Solution code:
import collections

N = int(input())
S = list(input() for i in range(N))
S.sort()

common = collections.Counter(S).most_common()
N_common = common[0][1]

candidates = [cand for cand in common if cand[1] == N_common]

for i in sorted(candidates):
    print(i[0])

Submission status: Accepted

Solution code:
import collections

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

c = collections.Counter(p)
m = c.most_common()
most = m[0][1]

answer = []

answer.append(m[0][0])

for i in range(len(m)-1):
    if m[i+1][1] == most:
        answer.append(m[i+1][0])
    else:
        break

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

Submission status: Accepted

Solution code:
import collections

def main():
    n = int(input())
    p = [input() for i in range(n)]

    c = collections.Counter(p)
    m = c.most_common()
    most = m[0][1]

    answer = []

    answer.append(m[0][0])

    for i in range(len(m)-1):
        if m[i+1][1] == most:
            answer.append(m[i+1][0])
        else:
            break

    for output in sorted(answer):
        print(output)
    return


main()

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())
s = [input() for i in range(n)]
c = Counter(s)
max_ = max(c.values())
c = sorted([k for k, v in c.items() if v == max_])
for a in c:
    print(a)

Submission status: Accepted

Solution code:

def main():
    N = int(input())
    dict = {}

    for _ in range(N):
        word = input()
        if word in dict:
            dict[word] += 1
        else:
            dict[word] = 0

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

    for d in dict:
        if d[1] == m:
            print(d[0])
    return 0


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

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

list = []
list.append(sortDic[0][0])
j = 0

if len(sortDic) != 1:
    while j < len(sortDic)-1 and sortDic[j][1] == sortDic[j+1][1]:
        list.append(sortDic[j+1][0])
        j += 1

list = sorted(list)

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

Submission status: Accepted

Solution code:
n = int(input())
from collections import defaultdict as dd
Dic = dd(lambda: 0)
for i in range(n):
  Dic[input()] += 1
#Lis = [[key, value] for (key, value) in zip(Dic.keys(), Dic.values())]
#print(Lis)

max_val = max(Dic.values())
Cands = [key for key, value in zip(Dic.keys(), Dic.values()) if value == max_val]
Cands.sort()
print(*Cands, sep="\n")

Submission status: Accepted

Solution code:
N = int(input())
S = [input() for i in range(N)]
import collections
s = collections.Counter(S)
M = max(s.values())
s = [e for e in s if s[e] == M]
t = sorted(s)
for e in t:
    print(e)

Submission status: Accepted

Solution code:
n = int(input())
d = dict()
for _ in range(n):
    x = str(input())
    if x in d:
        d[x] += 1
        continue
    else:
        d[x] = 0

d_sort = sorted(d.items(), key=lambda d:d[1], reverse = True)
d_max = d_sort[0][1]

ans = []
for i in d_sort:
    if d_max == i[1]:
        ans.append(i[0])
    else:
        break

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

Submission status: Accepted

Solution code:
from collections import Counter

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

c = Counter(S)
max_c = max(c.values())
#キーの昇順でソート
c_sorted = sorted(c.items(), key = lambda x:x[0])
for v in c_sorted:
    if v[1] == max_c:
        print(v[0])