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

Solution (Python):


n = int(input())
S = {}
max_S = 0
res = []

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

for key in S:
    if S[key] == max_S:
        res.append(key)

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

Solution (Python):
n = int(input())
sd = {}

for _ in range(n):
  s=input()
  if s in sd:
    sd[s]+=1
  else:
    sd[s] =1
m=max(sd.values())
ans=[]
for i in sd:
  if sd[i]==m:
    ans.append(i)
ans.sort()
for i in ans:
  print(i)

Solution (Python):
N = int(input())
dic = {}
for i in range(N):
  s = input()
  if s in dic:
    dic[s] += 1
  else:
    dic[s] = 1
m = 0
for v in dic.values():
  if v > m:
    m = v
l = []
for k, v in dic.items():
  if v == m:
    l.append(k)
l.sort()
for ans in l:
  print(ans)

Solution (Python):
import collections
n = int(input())
s = []
for _ in range(n):
    s.append(input())

c = collections.Counter(s)
ma = max(c.items(), key=lambda x: x[1])[1]
ans = []
for _s, cnt in c.items():
    if ma == cnt:
        ans.append(_s)

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

Solution (Python):

from collections import Counter

n=int(input())
s=[]
for i in range(n):
 s.append(input())
c=Counter(s)
mc=c.most_common()
s=[]
ref=mc[0][1]
i=0
while i<len(c):
 if mc[i][1]==ref:
  s.append(mc[i][0])
 i+=1
s.sort()
for i in range(len(s)):
 print(s[i])

Solution (Python):
import collections

n = int(input())
s = []
for i in range(n):
  s.append(input())
count = list(collections.Counter(s).items())
count = sorted(count, key=lambda x: x[1], reverse=True)
result = sorted([i for i in count if i[1] == count[0][1]], key=lambda x:x[0])

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

Solution (Python):



from collections import Counter,deque


from sys import stdin,setrecursionlimit










setrecursionlimit(10**6)
input=stdin.readline

def main():
    n=int(input().rstrip())
    d=dict()
    for _ in range(n):
        s=input().rstrip()
        if s not in d: d[s]=1
        else: d[s]+=1
    ans=Counter(d).most_common()
    ans.sort(key=lambda x: (-x[1],x[0]))
    ma=ans[0][1]
    for i in ans:
        if i[1]!=ma: break
        print(i[0])

if __name__=="__main__":
    main()

Solution (Python):
N = int(input())

S = []

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

S.sort()

A = [1]

for i in range(N):
	if i == 0:
		continue
	else:
		if S[i] == S[i-1]:
			A.append(A[i-1] + 1)
		else:
			A.append(1)

M = 0

for i in range(N):
	if A[i] > M:
		M = A[i]

for i in range(N):
	if A[i] == M:
		print(S[i])

Solution (Python):
N=int(input())
ans={}
cnt=0
for i in range(N):
  t=input()
  if not t in ans.keys():
    ans[t]=1
  else:
    ans[t]+=1
  if cnt<ans[t]:
    cnt=ans[t]
tmp =[]
for i in ans.keys():
  if ans[i]  == cnt:
    tmp.append(i)
tmp.sort()
for i in tmp:
  print(i)

Solution (Python):
N = int(input())
S_dic = {}
for i in range(N):
    S = input()
    if S in S_dic:
        S_dic[S] += 1
    else:
        S_dic[S] = 1
max_v = max(S_dic.values())
ans_list = [key for key, val in S_dic.items() if val == max_v]
ans_list.sort()
print("\n".join(ans_list))

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

max_d = max(dic.values())
ans = []
for k in dic:
    if(dic[k]==max_d):
        ans.append(k)

ans.sort()

for a in ans:
    print(a)

Solution (Python):
n = int(input())
words = {}

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

mx_freq = max(words.values())
mx_words = [k for k in words.keys() if words[k] == mx_freq]

mx_words.sort()

for mx_word in mx_words :
    print(mx_word)

Solution (Python):
n = int(input())
words = {}

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

mx_freq = max(words.values())
mx_words = [k for k, v in words.items() if words[k] == mx_freq]

mx_words.sort()

for mx_word in mx_words :
    print(mx_word)

Solution (Python):
from collections import Counter

N=int(input())
c=Counter([input() for _ in range(N)])
ans=[]
_max_values=max(list(c.values()))
for i in c:
    if c[i]==_max_values:
        ans.append(i)
ans=sorted(set(ans))
for i in ans:
    print(i)

Solution (Python):
a = int(input())

b = {}
for _ in range(a):
    S = input()
    if S in b:
        b[S] += 1
    else:
        b[S] = 1

m = max(b.values())
l = []
for k in b:
    v = b[k]
    if v != m:
        continue
    l.append(k)

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

Solution (Python):
import collections

N = int(input())
wordDict = {}
maxNum = 0
for i in range(N):
    word = input()
    if( word in wordDict ):
        wordDict[word] += 1
    else:
        wordDict[word] = 1
    
max_v = max(wordDict.values())
keys = [k for k, v in wordDict.items() if v == max_v]

keys.sort()

for word in keys:
    print(word)

Solution (Python):
import collections
N = int(input())
S = [input() for i in range(N)]
c = collections.Counter(S).most_common()

ans = []
for i in c:
  if c[0][1] == i[1]:
    ans.append(i[0])
ans.sort()

for i in ans:
  print(i)

Solution (Python):
n = int(input())
a = {}
for i in range(n):
    s = input()
    if s in a:
        a[s] += 1
    else:
        a[s] = 1
d = []
m = max(a.values())
for key, value in a.items():
    if m == value:
        d.append(key)
d.sort()
print(*d, sep='\n')

Solution (Python):
import sys
from collections import Counter

read = sys.stdin.read

N, *S = map(str, read().split())
s = Counter(S)
n = max(s.values())
answer = [i for i, j in s.items() if j == n]
answer.sort()
print('\n'.join(answer))

Solution (Python):
import sys
from collections import Counter

read = sys.stdin.read

N, *S = map(str, read().split())
s = Counter(S).most_common()
n = s[0][1]
answer = [i for i, j in s if j == n]
answer.sort()
print('\n'.join(answer))

Solution (Python):
n = int(input())
s = [input() for _ in range(n)]
s.sort()

a = ""
tt = [[],[]]
for i in s:
    if a != i:
        a = i
        tt[0] += [i]
        tt[1] += [1]
    else:
        tt[1][-1] += 1
t = tt
m = max(t[1])
ans = []
for i in range(len(t[1])):
    if t[1][i] == m:
        ans += [t[0][i]]

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

Solution (Python):
def main():
    n =int( input())

    cnt=dict()
    
    for _ in range(n):
        s=input()
        if s in cnt:
            cnt[s]+=1
        else :
            cnt[s]=1
    
    
    num = 0
    res =[]
    for key,value in cnt.items():
        
        if value > num:
            num=value
            res=[]
            res.append(key)

        elif value==num:
            res.append(key)

    

    
    


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


main()

Solution (Python):
import collections as coll

N = int(input())
A = [input() for _ in range(N)]
C = coll.Counter(A).most_common()
C = sorted([k for k,v in C if v == C[0][1]])
print(*C, sep='\n')

Solution (Python):
n = int(input())
dictionary = {}

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


lst = []

for e in dictionary.items():
    lst.append(list(e))

lst.sort(key=lambda x: (-x[1],x[0]))

memo = lst[0][1]
for key,value in lst:
    if value == memo:
        print(key)
    else:
        break

Solution (Python):
import collections

N = int(input())

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

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

ans = []
for key, val in c.items():
  if val == max_n:
    ans.append(key)
print("\n".join(sorted(list(set(ans)))))

Solution (Python):
from collections import Counter


def words_sort_ordered(words_list):
    word_cnt = Counter()
    for word in words_list:
        word_cnt[word] += 1

    word_written_max_time = 0
    for each_word_ct in word_cnt.values():
        if each_word_ct > word_written_max_time:
            word_written_max_time = each_word_ct

    answer_words_list = []
    for word, number in dict(word_cnt).items():
        if number == word_written_max_time:
            answer_words_list.append(word)

    return sorted(answer_words_list)


if __name__ == '__main__':
    words_num = int(input())
    words_list = [input() for i in range(words_num)]
    for w in words_sort_ordered(words_list):
        print(w)

Solution (Python):
from collections import Counter

n = int(input())
L = [input() for i in range(n)]
C = Counter(L)
maxv = max(C.values())
A = [k for k, v in C.items() if v == maxv]
A.sort()
print('\n'.join(A))

Solution (Python):

from collections import defaultdict
N = int(input())
c = defaultdict(int)
for _ in range(N):
    s = input()
    c[s] += 1
max_cnt = max(c.values())

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

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

Solution (Python):
N = int(input())
S = {}
for i in range(N):
    s = input()
    S[s] = S.get(s, 0) + 1

keys = list(S.keys())
keys.sort(key=lambda x: -S[x])

top_mode = S[keys[0]]

ans = []
for i in range(len(keys)):
    if top_mode == S[keys[i]]:
        ans.append(keys[i])

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

Solution (Python):
import pprint
N = int(input())
S = {}
for i in range(N):
    tmp = input()
    if tmp in S.keys():
        S[tmp] = S[tmp] + 1
    else:
        S[tmp] = 1
    

num = 0
v = []
for key,value in S.items():
    if value > num:
        num = value
        v = [key]
    elif value == num:
        v.append(key)

v.sort()

for i in v:
    print(i)

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


M = Counter(S)
mx = max(M.values())
L = sorted(M.items())
for k,v in L:
    if mx==v: print(k)

Solution (Python):
n = int(input().rstrip())
 
current_max = 0
current = []
table = {}
 
for i in range(n):
    s = input().rstrip()
    table[s] = table[s] + 1 if table.get(s) is not None else 1
 
score_sorted = sorted(table.items(), key=lambda x:-x[1])

max = 0
results = []
for k, v in score_sorted:
    if max > v:
      break
    max = v
    results.append(k)

results.sort()

for word in results:
  print(word)

Solution (Python):
n = int(input())
s_lst = [str(input()) for i in range(n)]
s_lst.sort()

count_lst = []
count = 1

if n==1:
    count_lst.append(1)
else:
    for i in range(1,n):
        s1 = s_lst[i-1]
        s2 = s_lst[i]

        if s1==s2:
            count += 1
            if i==n-1:
                count_lst.append(count)
        else:
            count_lst.append(count)
            count = 1

    if s_lst[-1]!=s_lst[-2]:
        count_lst.append(1)


new_slst = list(set(s_lst))
new_slst.sort()
max_count = max(count_lst)
answer_lst = []

for i in range(len(count_lst)):
    cou = count_lst[i]
    s = new_slst[i]
    if cou==max_count:
        answer_lst.append(s)

answer_lst.sort()
for i in range(len(answer_lst)):
    answer = answer_lst[i]
    print(answer)

Solution (Python):
from collections import Counter
n = int(input())
lst = [input() for i in range(n)]
c = Counter(lst)
c2 = c.most_common()
m = c2[0][1]
ans = [i[0] for i in c2 if i[1] == m]
print('\n'.join(sorted(ans)))

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

S_cnt = Counter(S)
max_cnt = max(S_cnt.values())


names = [name for name, v in S_cnt.items() if v == max_cnt]
names.sort()

print(*names, sep='\n')

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

S_cnt = Counter(S)
max_cnt = max(S_cnt.values())


names = [name for name, v in S_cnt.items() if v == max_cnt]
names.sort()

print(*names, sep='\n')

Solution (Python):
from collections import Counter
n=int(input())
a=[input() for _ in range(n)]
c=Counter(a)
max_cnt=max(c.values())
names=[name for name,v in c.items() if v==max_cnt]
names.sort()
print(*names,sep='\n')

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

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

maxi = max(d.values())
t = list(set([ ss for ss in s if d[ss] == maxi]))
t.sort()
print("\n".join(t))

Solution (Python):
from collections import Counter
 
c = Counter(input() for _ in range(int(input())))
m = max(c.values())
for s in sorted(s for s, k in c.items() if k == m): 
  print(s)

Solution (Python):
from itertools import groupby
from operator import itemgetter

a = groupby(sorted(input() for _ in range(int(input()))))
a = [(len(tuple(g)), s) for s, g in a]
m = max(a, key=itemgetter(0))[0]
for k, s in a:
  if k == m:
    print(s)

Solution (Python):
from itertools import groupby

a = groupby(sorted(input() for _ in range(int(input()))))
a = [(len(tuple(g)), s) for s, g in a]
m = max(a)[0]
for k, s in a:
  if k == m:
    print(s)

Solution (Python):
from collections import defaultdict
N = int(input())
cnt = defaultdict(int)

for _ in range(N):
    cnt[input()] += 1

mx = max(cnt.values())
cnt = [s for s, n in cnt.items() if n == mx]
cnt.sort()

print(*cnt, sep='\n')

Solution (Python):
import collections

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

i = 0
ans = []
while (True):
    ans.append(c_most[i][0])

    i += 1
    if i == len(c_most):
        break
    if c_most[i][1] != c_most[i - 1][1]:
        break
ans.sort()
for i in range(len(ans)):
    print(ans[i])

Solution (Python):
from collections import Counter

c = Counter(input() for _ in range(int(input())))
m = max(c.values())
for s in sorted(s for s, k in c.items() if k == m): 
  print(s)

Solution (Python):
from collections import Counter

c = Counter(input() for _ in range(int(input())))
m = max(c.values())
for s in sorted(s for s in c if c[s] == m): 
  print(s)

Solution (Python):
from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
counter = Counter(S)
max_val = max(counter.values())
for k, v in sorted(counter.items()):
    if v == max_val:
        print(k)

Solution (Python):
from collections import Counter

c = Counter(input() for _ in range(int(input())))
m = max(c.values())
for s in sorted(s for s, k in c.items() if k == m): 
  print(s)

Solution (Python):
from collections import Counter

c = Counter(input() for _ in range(int(input())))
m = c.most_common(1)[0][1]
for s in sorted(s for s, k in c.items() if k == m): 
  print(s)

Solution (Python):
from collections import Counter

c = Counter(input() for _ in range(int(input())))
m = max(c.values())
for s in sorted(s for s, k in c.items() if k == m): 
  print(s)

Solution (Python):
N = int(input())
S = dict()
Max = 1
for i in range(N):
    s = input()
    if s in S:
        S[s] += 1
        if S[s] > Max:
            Max = S[s]
    else:
        S[s] = 1
for key, value in sorted(S.items()):
    if value == Max:
        print(key)

Solution (Python):
def main():
    from collections import defaultdict
    from operator import itemgetter

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

    d = defaultdict(int)
    for w in s:
        d[w] += 1

    mx = max(d.values())
    for key, cnt in sorted(d.items(), key=itemgetter(0)):
        if cnt != mx: continue
        print(key)


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
S = ['0'] * N
for i in range(N):
    S[i] = input()
import collections
c = collections.Counter(S)
li = list(c.values())
ca = c.keys()
li.sort()
max = li[-1]
from collections import deque
lia = deque()
for i in ca:
    if c[i] == max:
        lia.append(i)
liaa = list(lia)
liaa.sort()
n = len(lia)
for i in range(n):
    print(liaa[i])

Solution (Python):
N = int(input())
S = ['0'] * N
for i in range(N):
    S[i] = input()
import collections
c = collections.Counter(S)
li = list(c.values())
ca = c.keys()
li.sort()
max = li[-1]
from collections import deque
lia = deque()
for i in ca:
    if c[i] == max:
        lia.append(i)
liaa = list(lia)
liaa.sort()
n = len(lia)
for i in range(n):
    print(liaa[i])

Solution (Python):
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 = max(words.values())
    
    for key, value in sorted(words.items()):
        if value != max_val:
            continue
        else:
            print(key)
            
            


if __name__ == "__main__":
    main()

Solution (Python):
import collections

N = int(input())

S = []
for _ in range(N):
  S.append(input())
  
c = collections.Counter(S)

d = c.most_common()[0][1]

e = sorted([k for k,v in c.items() if v == d])

for f in e:
  print(f)

Solution (Python):
from collections import Counter
n = int(input())
c = Counter((input() for _ in range(n))).most_common()
ci = c[0][1]
ans = []
for s, i in c:
    if i < ci:
        break
    ans.append(s)
for a in sorted(ans):
    print(a)

Solution (Python):
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 = max(words.values())
    words_sorted = sorted(words.items(), key=lambda x: x[0])
    for key, value in words_sorted:
        if value != max_val:
            continue
        else:
            print(key)


if __name__ == "__main__":
    main()

Solution (Python):
import sys
import socket
from collections import Counter

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('c1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    N = read_int()
    s = []
    for i in range(N):
      S = read_str()
      s.append(S)
    s.sort()
    s.append('')

    res = []
    M = -1
    m = 1
    for i in range(1, N+1):
      if s[i-1] == s[i]:
        m += 1
      else:
        if m == M:
          res.append(s[i-1])
        if m > M:
          M = m
          res = [s[i-1]]
        m = 1
    print(*res, sep='\n')


def main2():
    N = read_int()
    s = []
    for i in range(N):
      S = read_str()
      s.append(S)

    d = dict()
    for i in range(N):
      if s[i] not in d:
        d[s[i]] = 0
      d[s[i]] += 1
    

    M = -1
    for key, value in d.items():
      if value > M:
        M = value
    

    res = []
    for key, value in d.items():
      if value == M:
        res.append(key)
    res.sort()
    print(*res, sep='\n')



def main3():
    N = read_int()
    s = []
    for i in range(N):
      S = read_str()
      s.append(S)

    d = Counter(s)
    
    M = -1
    for key, value in d.items():
      if value > M:
        M = value
    

    res = []
    for key, value in d.items():
      if value == M:
        res.append(key)
    res.sort()
    print(*res, sep='\n')


main3()

Solution (Python):
import collections
N = int(input())
List=[input() for i in range(N)]
 
c = collections.Counter(List)
c_sorted = sorted(c.items(), key=lambda x:x[1],reverse=True)
 
maxCount = c_sorted[0][1]
keys = [k for k, v in c.items() if v ==maxCount]
keys.sort()
for s in keys:
    print(s)

Solution (Python):
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('c1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    N = read_int()
    s = []
    for i in range(N):
      S = read_str()
      s.append(S)
    s.sort()
    s.append('')

    res = []
    M = -1
    m = 1
    for i in range(1, N+1):
      if s[i-1] == s[i]:
        m += 1
      else:
        if m == M:
          res.append(s[i-1])
        if m > M:
          M = m
          res = [s[i-1]]
        m = 1
    print(*res, sep='\n')


def main2():
    N = read_int()
    s = []
    for i in range(N):
      S = read_str()
      s.append(S)

    d = dict()
    for i in range(N):
      if s[i] not in d:
        d[s[i]] = 0
      d[s[i]] += 1
    

    M = -1
    for key, value in d.items():
      if value > M:
        M = value
    

    res = []
    for key, value in d.items():
      if value == M:
        res.append(key)
    res.sort()
    print(*res, sep='\n')

main2()

Solution (Python):
from collections import Counter
n=int(input())
f=[]
for i in range(n):
    s=input()
    f.append(s)
d=dict(Counter(f))

f=[]
kk=max(d.values())
for key,value in d.items():
    if value==kk:
        f.append(key)
f.sort()
for x in f:
    print(x)

Solution (Python):
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('c1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    N = read_int()
    s = []
    for i in range(N):
      S = read_str()
      s.append(S)
    s.sort()
    s.append('')

    res = []
    M = -1
    m = 1
    for i in range(1, N+1):
      if s[i-1] == s[i]:
        m += 1
      else:
        if m == M:
          res.append(s[i-1])
        if m > M:
          M = m
          res = [s[i-1]]
        m = 1
    print(*res, sep='\n')


main()

Solution (Python):
N = int(input())
S = [input() for i in range(N)]
S.sort()
k = [0]* (N - 1)
for i in range(N - 1):
    if S[i] == S[i + 1]:
        k[i] = 1
if k == [0]* (N-1):
    for i in range (N):
        print(S[i])
else:
    t = [0]*(N-1)
    for i in range(N-1):
        if k[i] == 0:
            t[i] = 0
        else:
            t[i] = t[i - 1] + 1
    M = max(t)
    for i in range (N-1):
        if t[i] == M:
            print(S[i])

Solution (Python):

from collections import Counter


def main():
    _, *S = open(0).read().split()
    cnt = Counter(S)
    max_votes = max(cnt.values())
    ans = [k for k, v in cnt.items() if v == max_votes]
    ans.sort()
    print("\n".join(ans))


if __name__ == "__main__":
    main()

Solution (Python):
from collections import Counter

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

c = Counter(A).most_common()
k, v = zip(*c)

[print(s) for s in sorted(k[:v.count(v[0])])]

Solution (Python):
arr = []
track = dict()
for _ in range(int(input())) :
    s = input()
    arr.append(s)
for i in arr :
    track[i] = 0
for i in arr :
    track[i]+=1
result = []
for i in track :
    result.append(track[i])
m = max(result)
g = []
for i in track :
    if track[i] == m :
        g.append(i)
g.sort()
for i in g :
    print(i)

Solution (Python):
N = int(input())
D = {}
for i in range(N):
  a_i = input()
  if a_i in D.keys():
    D[a_i] += 1
  else:
    D[a_i] = 1
m = 0
for v in D.values():
	m = max(m, v)
ans = []
for k, v in D.items():
	if v == m:
		ans.append(k)
ans.sort()
print(*ans, sep="\n")

Solution (Python):

from collections import Counter


def main():
    _, *S = open(0).read().split()
    cnt = Counter(S).most_common()
    max_votes = cnt[0][1]
    ans = []
    for a, i in cnt:
        if i < max_votes:
            break
        ans.append(a)
    ans.sort()
    print("\n".join(map(str, ans)))


if __name__ == "__main__":
    main()

Solution (Python):
from collections import defaultdict

N = int(input())
S = [input() for _ in range(N)]
D = defaultdict(lambda: 0)
for s in S:
    D[s] += 1
d_max = max(D.values())
T = []
for k, v in D.items():
    if v == d_max:
        T.append(k)
T.sort()
print(*T, sep="\n")

Solution (Python):
n = int(input())
s = [input() for _ in range(n)]
s.sort()
if n == 1:
    print(s[0])
else:
    maximum = 1
    ans = [s[0]]
    count = 1
    for i in range(1, n):
        if s[i] == s[i-1]:
            count += 1
        else:
            count = 1
        if count == maximum:
            ans.append(s[i])
        elif count > maximum:
            ans = [s[i]]
            maximum = count
    for i in ans:
        print(i)

Solution (Python):
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)

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

tmp = sorted(dic.items(), key=lambda x:(-x[1], x[0]))
for i in range(len(tmp)):
  if tmp[i][1] == tmp[0][1]:
    print(tmp[i][0])
  else:
    break

Solution (Python):
n=int(input())
s=[input() for i in range(n)]
l=list(set(s))
o=[]
for x in range(len(s)):
    o.append(0)
dic=dict(zip(l,o))

for x in s:
   if x in dic:dic[x]+=1
d=sorted(dic.items(),key=lambda x:-x[1])
m=d[0][1]
p=[]
for r in d:
    if r[1]==m:p.append(r[0])
u=sorted(p)
for y in u:
    print(y)

Solution (Python):
n = int(input())
dic = {}
for i in range(n):
  s = input()
  if s in dic:
    dic[s] += 1
  else:
    dic[s] = 1
    
tmp = sorted(dic.items(), key=lambda x:x[0])
tmp = sorted(tmp, key=lambda x:x[1], reverse=True)
for i in range(len(tmp)):
  if tmp[i][1] == tmp[0][1]:
    print(tmp[i][0])
  else:
    break

Solution (Python):
N = int(input())
S = []
for i in range(N):
    S.append(input())
vote = {}
for j in S:
    if j not in vote:
        vote[j] = 1
    else:
        vote[j] += 1
most = set()
highNo = 0
for k in vote:
    if vote[k] > highNo:
        most.clear()
        most.add(k)
        highNo = vote[k]
    elif vote[k] == highNo:
        most.add(k)
most = list(most)


def sortLexo(givenList):
    givenList.sort()
    for i in givenList:
        print(i)
sortLexo(most)

Solution (Python):
a = int(input())

b = {}
for _ in range(a):
    S = input()
    if S in b:
        b[S] += 1
    else:
        b[S] = 1

m = max(b.values())
l = []
for k in b:
    v = b[k]
    if v != m:
        continue
    l.append(k)

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

Solution (Python):
n=int(input())
l={}
mx=0
for i in range(n):
    s=input()
    if s not in l:
        l[s]=1
    else:l[s]+=1
    mx=max(mx,l[s])
ans=[]
for j in l:
    
    if l[j]==mx:
        ans.append(j)
        

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

Solution (Python):
import collections

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

c = collections.Counter(S)
value_and_counts = c.most_common()

max_number = value_and_counts[0][1]

value_and_counts.sort()

for i in value_and_counts:
    if max_number == i[1]:
        print(i[0])

Solution (Python):
import collections
 
n = int(input())
 
res = []
 
for _ in range(n):
  res.append(input())
 
c = collections.Counter(res)
aa = c.most_common()
 
ss = aa[0][1]
res2 = []
 
aa.sort()
for i in aa:
  if i[1] == ss:
    res2.append(i[0])
    print(i[0])

Solution (Python):
from collections import Counter
n = int(input())
l = []
for _ in range(n):
  l.append(input())
  
c = Counter(l).most_common()
m = max([x[1] for x in c])
result = sorted([x[0] for x in c if x[1]==m])
for s in result:
  print(s)

Solution (Python):
import collections


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

sss = set(s)
mx = 0
pl = []
for ss in sss:
    if c[ss] > mx:
        mx = c[ss]
        pl = [ss]
    elif c[ss] == mx:
        pl.append(ss)
pl = sorted(pl)
for i in pl:
    print(i)

Solution (Python):
from collections import Counter

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

m=c.most_common()[0][1]

ans=[]
for k,v in c.items():
 if v==m:
  ans.append(k)
ans.sort()
for i in ans:
 print(i)

Solution (Python):
import collections

def check(input_list):

    vote_dict = collections.Counter(input_list)
    max_value = max(vote_dict.values())

    result_list = [k for k, v in vote_dict.items() if v == max_value]
    result_list.sort()
    
    return result_list

if __name__ == '__main__':
    num = int(input())
    input_list = [input() for a in range(num)]

    for str in check(input_list):
        print(str)

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

S_d={}
A=[]

for i in range(N):
    if S[i] not in S_d.keys():
        S_d[S[i]]=1
    else:
        S_d[S[i]]+=1

max_co=max(S_d.values())

for j in S_d.keys():
    if S_d[j]==max_co:
        A.append(j)

B=sorted(A)

for k in B:
    print(k)

Solution (Python):
N = int(input())
dic = {}
Max = 1

for _ in range(N):
  S = input()
  if not S in dic:
    dic[S] = 1
  else:
    dic[S] += 1
    Max = max([Max, dic[S]])

ans = []
    
for x in dic:
  if dic[x] == Max:
    ans.append(x)

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

Solution (Python):
from collections import defaultdict, Counter

if __name__ == "__main__":
    count = int(input().strip())
    votes = defaultdict(int)
    for _ in range(count):
        vote = input().strip()
        votes[vote] += 1
    ordered_votes = Counter(votes).most_common()
    max_votes = ordered_votes[0][1]
    winners = []
    for candidate, vote in ordered_votes:
        if vote  == max_votes:
            winners.append(candidate)
        else:
            break
    
    for name in sorted(winners):
        print(name)

Solution (Python):
N = int(input())
d = {}
for i in range(N):
    S = input()
    if S in d.keys():
        d[S] = d[S] + 1
    else:
        d[S] = 1
max_val = max(d.values())
max_k_ls = [kv[0] for kv in d.items() if kv[1]==max_val]
max_k_ls = sorted(max_k_ls)

print(*max_k_ls, sep="\n")

Solution (Python):
n = int(input())
lis = []
lis2 = {}
lis3 = []
for _ in range(n):
  lis.append(input())

for w in lis:
  if w not in lis2.keys():
    lis2[w] = 1
  else:
    lis2[w] += 1

ma = max(lis2.values())

for k, v in lis2.items():
  if v == ma:
    lis3.append(k)

lis3.sort()

for a in lis3:
  print(a)

Solution (Python):
n=int(input())
l=[None for i in range(n)]
for i in range(n):
    l[i]=input()
l.sort()
m=0
now=l[0]
cnt=1
ll=[[] for i in range(n+1)]
for i in range(1,n):
    if l[i]!=now:
        m=max(m,cnt)
        ll[cnt].append(now)
        now=l[i]
        cnt=1
    else:
        cnt+=1
m=max(m,cnt)
ll[cnt].append(now)
for s in ll[m]:
    print(s)

Solution (Python):
N = int(input())
dic = {}
nmax = 1
for i in range(N):
  s = str(input())
  if s in dic:
    dic[s] += 1
    
    nmax = max(dic[s], nmax)
  else:
    dic[s] = 1
slist = []
for k in dic:
  if dic[k] == nmax:
    slist.append(k)
for s in sorted(slist):
  print(s)

Solution (Python):
from collections import Counter
n = int(input())
s = sorted([input() for i in range(n)])

counter = Counter(s)
max_num = max(counter.values())
ans_list = [i for i in counter if counter[i] == max_num]
for i in sorted(ans_list):
    print(i)