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: Runtime Error

Solution code:
N = int(input())
S = []
for n in range(N):
    S.append(input())
dic = {}


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

max = max(dic.values())
out = []

for key,val in dic.items():
    if val == max:
        out.append(val)
out.sorted()
for val in range(len(out)):
    print(val)

Submission status: Runtime Error

Solution code:
from collections import Counter
n = input()
s = [input() for _ in range(n)]
s = Counter(s)
m = max(s.values())

a = []
for d in s.items():
    if d[1] == m:
        a.append(d[0])
for s in a:
    print(s)

Submission status: Runtime Error

Solution code:
from collections import Counter
N = int(input())
L = [input() for _ in range(N)]
#for n in range(N):
    #S = input()
    #L.append(S)
Dic = Counter(L)

max_k_list = [i for i, j in Dic.items() if j == max(Dic.values())]
max_k_list = max_k_list.sort()
for t in max_k_list:
    print(t)

Submission status: Runtime Error

Solution code:
from collections import Counter
N = int(input())
#L = []
L = [input() for _ in range(N)]
#for n in range(N):
    #S = input()
    #L.append(S)
Dic = Counter(L)
max_k_list = [kv[0] for kv in Dic.items() if kv[1] == max(Dic.values())]
max_k_list = max_k_list.sort()
for t in max_k_list:
    print(t)

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<string> s;
  map<string, int> mp;
  rep(i, n) {
    string a;
    cin >> a;
    s.push_back(a);
  }
  rep(i, n) mp[s[i]] = 0;
  rep(i, n) mp[s[i]]++;
  int k = 0;
  for(auto m : mp) {
    k = max(k, m.second);
  }
  sort(all(s));
  int p, q;
  p = q = 0;
  while (q < n) {
    while(s[p] == s[q] && q < n) q++;
    if(k == (q - p)) {
      out(s[p]);
    }
    p = q;
  }
  return 0;
}

Submission status: Runtime Error

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)
l = []
for k in d:
    v = d[k]
    if v != m:
        continue
    l.append(v)

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

Submission status: Runtime Error

Solution code:
N = int(input())

Sdict = dict()
for _ in range(N):
    s = input()
    if s in Sdict:
        Sdict[s] += 1
    else:
        Sdict[s] = 0
    
print(Sdict)
maxi = 0
lis = []
for k,v in Sdict.itens():
	if v > maxi:
        lis = [k]
        maxi = v
    if v == maxi:
		lis.append(k)

print(lis.sort())

Submission status: Runtime Error

Solution code:
import  collections 
N = int(input())
list_a = [input() for i in range(N)]
dict_a = collections.Counter(list_a)


list_ans = []

list_ans.append(dict_a.most_common()[0][0])
while True:
    if dict_a.most_common()[0][1] == dict_a.most_common()[i][1]:
        list_ans.append(dict_a.most_common()[i][0])
    else:
            break

list_ans.sort()
for i in range (0,len(list_ans)):
    print(list_ans[i])

Submission status: Runtime Error

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

c = {}
res = []

for i in range(n):
    if List[i] in c.keys():
        c[List[i]] += 1
    else:
        c[List[i]] = 1

ac = c.most_common() ##これが無いとACにならない！！！！
                     ##毎回の計算がかなりの時間ロスだった
res.append(ac[0][0])
for i in range(1, leng):
    if ac[i][1] >= ac[i-1][1]:
        res.append(ac[i][0])
    else:
        break

#res = sorted(res)
res.sort()
for j in range(len(res)):
    print(res[j])

Submission status: Runtime Error

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

from collections import defaultdict
d = defaultdict(lambda:0)

for k in S:
    d[str(k)]+=1

dmax=max(d.value())
ansn=dmax
ans=[]
for i in set(S):
    if d[i]==ansn:
        ans.append(i)

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

Submission status: Runtime Error

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

def abc155c(num, s):
    array = [[] for _ in range(2*10^5)]
    max_cnt = 0

    for i in range(0, num):
        target = s[i]
        cnt = 0 # appearance count
        iter_num = 0
        # array内で一致する文字列を見つける
        for iter in array:
            iter_num += 1
            for string in iter:
                if( target == string ):
                    cnt = iter_num
                    break
            if( cnt != 0 ): break

        if( cnt != 0 ):
            array[cnt-1].remove(target)
        array[cnt].append(target)
        if( cnt > max_cnt ) : max_cnt = cnt

    # sort in array[max_cnt]
    sortedArray = sorted(array[max_cnt])

    return(sortedArray)

###
# main
if(__name__ == '__main__'):
    # input
    s = [None for _ in range(2*10^5)]
    num = int(input())
    for i in range(0, num):
        s[i] = input()

    ans = abc155c(num, s)

    # output
    for name in ans :
        print(name)
# else:
# do nothing

Submission status: Runtime Error

Solution code:
import collections as col
N=int(input())
S=[]
answer=[]

for _ in range(N):
    S.append(input())
T=sorted(S)
s=col.Counter(T)
values, counts = zip(*s.most_common())
#print(values,counts)
print(values[0])
t=1

for i in range(N):
    if counts[i]==max(counts):
        answer.append(values[i])
answer.sort()
for j in answer:
    print(j)

Submission status: Runtime Error

Solution code:
def contest(N, str):
    count = {}

    for s in str:
        if s not in count:
            count[s] = 1

        else:
            count[s] +=  1
    
    ret = sorted(count.items(),key=lambda count: count[1], reverse=True)
    maxnum = ret[0][1]
    
    retVal = []

    for r in ret:
        if r[1] == maxnum:
            retVal.append(r[0])
            
        else:
            break

    result = '\n'.join(sorted(retVal))

    return result


if __name__ == "__main__":
    N = int(input())
    S = []

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

    print(contest(N, str))

Submission status: Runtime Error

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

def abc155c(num, s):
    array = [[] for _ in range(2*10^5)]
    max_cnt = 0

    for i in range(0, num):
        target = s[i]
        cnt = 0 # appearance count
        iter_num = 0
        # array内で一致する文字列を見つける
        for iter in array:
            iter_num += 1
            if( iter != None ):
                for string in iter:
                    if( target == string ):
                        cnt = iter_num
                        break
                if( cnt != 0 ): break

        if( cnt != 0 ):
            array[cnt-1].remove(target)
        if( array[cnt] == None ):
            array[cnt] = []
        array[cnt].append(target)
        if( cnt > max_cnt ) : max_cnt = cnt

    # sort in array[max_cnt]
    sortedArray = sorted(array[max_cnt])

    return(sortedArray)

###
# main
if(__name__ == '__main__'):
    # input
    s = [[] for _ in range(2*10^5)]
    num = int(input())
    for i in range(0, num):
        s[i] = input()

    ans = abc155c(num, s)

    # output
    for name in ans :
        print(name)
# else:
# do nothing

Submission status: Runtime Error

Solution code:
import collections
N=int(input())
S=[input() for i in range(N)]
c=collections.Counter(S)
most=c.most_common()[0][1]
if len(c)==1:
  print(c.most_common()[0][0])
else:
  for i in range(len(c)):
    print(c.most_common()[i][0])
    if c.most_common()[i+1][1] !=most:
      break

Submission status: Runtime Error

Solution code:
import collections
n = int(input())
ls = [input() for i in range(n)]    
c = collections.Counter(ls)
count = c.most_common()[0][1]
ans = []
if c.most_common()[0][1] == 1:
    ls.sort()
    for i in ls:
        print(i)
else:
    for i in range(len(c)):
        p = c.most_common()
        if p[i][1] == count:
            ans.append(p[i][0])
        else:
            break   
    ans = sorted(ans
    for i in ans:
      print(i)

Submission status: Runtime Error

Solution code:
import collections
N=int(input())
S=[input() for i in range(N)]
c=collections.Counter(S)
most=c.most_comon()[0][1]
if len(c)==1:
  print(c.most_common()[0][0])
else:
  for i in range(len(c)):
    print(c.most_common()[i][0])
    if c.most_common()[i+1][1] !=most:
      break

Submission status: Runtime Error

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

a = 0
for i in range(n):
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1
    if dic[s] > a:
        a = dic[s]
box= []
for i in dic:
    if dic[i] == a:
        box.append(i)

ans = sorted(box)
for in in range(len(ans)):
    print(ans)

Submission status: Runtime Error

Solution code:
from collections import Counter
int = int(input())
word = [input() for i in range(int)]
s = Counter(word)
u = a.most_common()
u.sort()
for j in range(len(u)):
    print(u[j])

Submission status: Runtime Error

Solution code:
from collections import *
n=int(input())
a=[]
for _ in range(n):
  a.append(input())
aset=set(a)
cnt=Counter(a)
maxi=0
for k in cnt.keys():
  maxi=max(maxi,cnt[k])

anss=[]
for s in seta:
  if cnt[s]==maxi:
    anss.append(s)
anss.sort()
for i in range(len(anss)):
  print(anss[i])

Submission status: Runtime Error

Solution code:
import collections
N = int(input())
s = []
for n in range(N):
    si = input()
    s.append(si)
sd = collections.Counter(s)
S = list(sd.keys())
print(S[0])
print(S[1])

Submission status: Runtime Error

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

S3=[]
S3.append(S1[0][0])
for i in range(1,len(S1)):
    if S1[i][1]==S1[0][1]:
        S3.append(S1[i][0])
    else:
        break
S3=sorted(S3)
for i in range(0, len(S3)):
    print(S3[i])

Submission status: Runtime Error

Solution code:
dic={}
n=int(input())
d=[]
for i in range(n):
  d.append(input())
  if d[-1] in dic:
  	dic[d[-1]]+=1
  else:
    dic[d[-1]]=1
mx=max(mx,dic.values())
for k,v in sorted(dic.items(),key=lambda x:(-x[1],x[0])):
  if mx==v:
    print(k)

Submission status: Runtime Error

Solution code:
import collections
n = int(input())
ls = [input() for i in range(n)]    
c = collections.Counter(ls)
count = c.most_common()[0][1]
ans = []
if c.most_common()[0][1] == 1:
    ls.sort()
    for i in ls:
        print(i)
else:
    c.sort()
    for i in range(len(c)):
        p = c.most_common()
        if p[i][1] == count:
            print(p[i][0])
        else:
            break

Submission status: Runtime Error

Solution code:
import collections

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

c = collections.Counter(List)
m = 0
for v in c.values():
  m = max(m, v)
  
for k, v in c.items():
  if v == m:
    res.append(k)
    
res.sort()
for i in range(les(res)):
  print(res[i])

Submission status: Runtime Error

Solution code:
dic={}
n=int(input())
d=[]
for i in range(n):
  d.append(input())
mx=0
for w in d:
  dic[w]=d.count(w)
  mx=max(mx,dic[w])

for k,v in sorted(dic.items(),key=lambda x:(x-[1],x[0])):
  if mx==v:
    print(k)

Submission status: Runtime Error

Solution code:
import collections

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

c = collections.Counter(List)

for v in c.values():
  m = max(m, v)
  
for k, v in c.items():
  if v == m:
    res.append(k)
    
res.sort()
for i in range(les(res)):
  print(res[i])

Submission status: Runtime Error

Solution code:
N = int(input())
s = [input() for i in range(N)]
myDict = {}
for i in s:
  myDict[i] = s.count(i)
max_k_list = [kv[0] for kv in myDict.items() if kv[1] == max(myDict.values())]
sortList = sorted(max_k_list)
s_n = '\n'.join(sortlist)
print(s_n)

Submission status: Runtime Error

Solution code:
from collections import Counter
import numpy as np
import pandas as pd
N = int(input())
list = [input() for _ in range(0,N)]
counted = Counter(list)
res_max= counted.most_common()[0][1]

ans = []
for k, v in counted.items():
    if k == v:
        ans.append(k)

ans.sort()
print(*ans, sep="\n")

Submission status: Runtime Error

Solution code:
import collections

N = int(input())
d = []
for i in range(N):
    n = input()
    d.append(n)
c = collections.Counter(d)

x = 1
n = 1 #最頻値の数
while c.most_common()[x-1][1] == c.most_common()[x][1]:
    x += 1
    n += 1

values, counts = zip(*c.most_common())
l = sorted(values[0:n])
for i in l:
    print(i)

Submission status: Runtime Error

Solution code:
import collections
a = int(input())
l = []
for i in range(a):
    l.append(input())
counted = collections.Counter(l)
 
m = max(counted.values())
 
chars = [key for key, value in counted.items()
             if value == m].sort()
chars.sort()

for i in chars:
    print(i)

Submission status: Runtime Error

Solution code:
l = [input() for i in range(n)]
l.sort()
i = 0
count = 1
ans = []
max = 1
while i < n-1:
  if l[i] == l[i+1]:
    count += 1
    i += 1
    if count >= max:
      max = count
    if i == n-1:
      ans.append([l[n-1], count])

  else:
      ans.append([l[i],count])
      count = 1
      i += 1

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

Submission status: Runtime Error

Solution code:
n=int(input())
s=sorted([input() for k in range(n)])
s3 = sorted(list(set(s)))
if(len(set(s))==len(s)):
    for u in range(len(s)):
        print(s[u])
    exit()
else:
    s1=s2 = [m for m in s3 if s.count(m)>1]
    i = (len(s)-len(s1))//len(s3)                                                                         while(len(s2)!=0):
        s2 = [m for m in s3 if s.count(m)>i]
        if(len(s2)==0):
               break
        s1 = s2
        i+=1
for j in s1:
    print(j)

Submission status: Runtime Error

Solution code:
import itertools
n=int(input())
s = []
for _ in range(n):
    s.append(input())
#print(s)
#s = list(itertools.chain.from_iterable(s))
#print(s)
s_u = list(set(s))
box = []
box.append([s_u[0],s.count(s_u[0])])
for i in range(1,len(s_u)):
    if max(box) < s.count(s_u[i]):
        box.remove(max(box))
        box.append([s_u[i],s.count(s_u[i])])
    elif max(box) == s.count(s_u[i]):
        box.append([s_u[i],s.count(s_u[i])])
            
ans_box = sorted(box)
for i in range(len(ans_box)):
    print(ans_box[i])

Submission status: Runtime Error

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

    
print(0)
for j in range(ans.max):
    print(ans[j])

Submission status: Runtime Error

Solution code:
import sys
input_first = input()
N= int(input_first)

wordl = []
timesl = []

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

maxnum = 1
tmp=1
resultl  =[]
for i in  range(N-1):
    if wordl[i] == wordl[i+1]:
        tmp +=1
    else:
        if maxval == tmp:
            resultl.append(wordl[i])
        elif maxval<tmp:
            resultl = []
            resultl.append(wordl[i])
            maxval = tmp
        else:
            pass
        tmp = 1


resultl.sort()

print(resultl)

Submission status: Runtime Error

Solution code:
import collections

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

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

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

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

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

Submission status: Runtime Error

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

d={}

for i in s:
  if i in d:
    d[i]+=1
  else:
    d[i]=1
d=sorted(d.items(),reverse=True)



for i in d.key():
  print(i)

Submission status: Runtime Error

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


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


if n == 1:
    print(s[0])
elif n >= 2 and len(c.keys()) == 1:
    print(c.most_common()[0][0])
for i in range(k):
    if k[0][0] == k[i][1]:
        ans.append(k[i][0])
    else:
        break
        
ans = sorted(ans)
[print(i) for i in ans]

Submission status: Runtime Error

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

lines = sys.stdin.readlines()
c = Counter(lines)
  
m = 0
mc = []
  
for item, count in c.most_common():  
  if m == 0:
    m = count
  
  if m > count:
    break
  else:
    mc += [item]

mc.sort()

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

Submission status: Runtime Error

Solution code:
import numpy as np

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

a = np.array(a)

unique_elements, counts_elements = np.unique(a, return_counts=True)
elements = unique_elements[counts_elements == np.max(counts_elements)]
for i in elements:
    print(i)
    print('\n')

Submission status: Runtime Error

Solution code:
import collections

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

for j in c:
    if m == int(c.most_common()[0][1]):
        print(c.most_common()[0][0])
        c.pop(0)

Submission status: Runtime Error

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

d={}

for i in s:
  if i in d:
    d[i]+=1
  else:
    d[i]=1
d=sorted(d.items,reverse=True)



for i in d.key:
  print(i)

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
S = [input() for __ in range(N)]

S = np.array(S)
keys = set(S)
ans = {}
cnt = 0
ls = []
for key in keys:
    ans[key] = len(np.where(S == key)[0])

max_v = max(ans.values())
keys = [k for k, v in d.items() if v == max_v]
keys.sort()
for key in keys:
    print(key)

Submission status: Runtime Error

Solution code:
from collections import Counter
import numpy as np
import pandas as pd
N = int(input())
list = [input() for _ in range(0,N)]
counted = Counter(list)
res= counted.most_common()

res = pd.DataFrame(res)
[print(i) for i in res[0][res[1] == res[1].max()]]

Submission status: Runtime Error

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

C=Counter(S)
A=[]
B=[]

for i,j in C.most_common():
    A.append(i)
    B.append(j)
for k in range(len(A)):
    if B[k]=B[0]:
        print(A[k])

Submission status: Runtime Error

Solution code:
N=int(input())
P=[input().split() for i in range(N)]
print(c.most_common(P))

Submission status: Runtime Error

Solution code:
import numpy as np

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

a = np.array(a)

unique_elements, counts_elements = np.unique(a, return_counts=True)
elements = unique_elements[counts_elements == np.max(counts_elements)]
for i in elements:
    print(i)

Submission status: Runtime Error

Solution code:
import numpy as np

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

a = np.array(a)

unique_elements, counts_elements = np.unique(a, return_counts=True)
elements = unique_elements[counts_elements == np.max(counts_elements)]
for i in elements:
    print(i)

Submission status: Runtime Error

Solution code:
import collections
import itertools

N = int(input())
L = []
D = {}
for _ in range(N):
    x = input()
    L.append(x)

counter = collections.Counter(L)

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

print(sorted(*(k for k, v in it)))

Submission status: Runtime Error

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

d={}

for i in s:
  if i in d:
    d[i]+=1
  else:
    d[i]=0
d=sorted(d.items,reverse=True)



for i in d.key:
  print(i)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
d = {}
for i range(n):
  s = input()
  if s not in d:d[s] = 0
  d[s] += 1
max_cnt = sorted(d.items(), key=lambda tp:tp[1])[-1][1]
a1 = filter(lambda tp:tp[1] == max_cnt, d.items())
a2 = map(lambda tp:tp[0], a1)
for s in sorted(a2):
  print(s)

Submission status: Runtime Error

Solution code:
N = int(input())
L = []
Dic = {}
for n in range(N):
    S = input()
    L.append(S)
Unique = list(set(L))

for i in Unique:
    Dic[i]=0

for j in range(len(L)):
    Dic[j] = Dic[j] + 1
    
max_k_list = [kv[0] for kv in Dic.items() if kv[1] == max(Dic.values())]
max_k_list = sorted(max_k_list)
for t in max_k_list:
    print(t)

Submission status: Runtime Error

Solution code:
n = int(input())
S=[0]*n
for i in range(n):
  a=input()
  S[i]=a
S.sort()

arr = []
comp_pre=""
comp=""
cnt=0
row=-1
for i in range(n):
  comp=S[i]
  if comp != comp_pre:
    cnt=1
    row+=1
    arr.append([cnt,comp])
  else:
    cnt+=1
    arr[row][0]=cnt
  comp_pre = comp

arr1=sorted(arr, key=lambda x: -x[0])

num_pre=arr1[0][0]
for i in range(n):
  if num_pre==arr1[i][0]:
    print(arr1[i][1])
  else:
    break
  num_pre=arr1[i][0]

Submission status: Runtime Error

Solution code:
import numpy as np

N = int(input())
a = input().split()

a = np.array(a)

unique_elements, counts_elements = np.unique(a, return_counts=True)
elements = unique_elements[counts_elements == np.max(counts_elements)]
for i in elements:
    print(i)
    print('\n')

Submission status: Runtime Error

Solution code:
import collections

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

for i in c:
    if m == int(c.most_common()[0][1]):
        print(c.most_common()[0][0])
        c.pop(0)

Submission status: Runtime Error

Solution code:
# coding: utf-8


def main():
    n = int(input())
    polls_dict = {}
    for _ in range(n):
        poll = input()
        if poll not in polls_dict:
            polls_dict[poll] = 1
        else:
            polls_dict[poll] += 1

    max_poll = max(polls_dict.values())
    #polls_set = sorted(polls_dict.keys())
    polls_dict = sorted(polls_dict)

    for key, value in polls_dict.items():
        if value == max_poll:
            print(key)
        else:
            pass

    #for poll in polls_set:
    #    print(poll)
    
    return 0


if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

myList = []
myDict = {}
for i in s:
  if i not in myList:
    myList.append(i)
    else:
      myDict[i] = s.count(i)

max_k_list = [kv[0] for kv in myDict.items() if kv[1] == max(myDict.values())]
sortList = sorted(max_k_list)

for i in sortList:
  print(i)

Submission status: Runtime Error

Solution code:
import pandas as pd
a = int(input())
b = []
for i in range(a):
    b.append(input())
b = pd.Series(b) 
c = b.mode().tolist()
c.sort()
for i in c:
    print(i)

Submission status: Runtime Error

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

S.sort()

while S != []:
  if S[0] == S[i - 1]:
    count = S.count(S[0])
  else:
    count = 0
  
  if count > i:
    A = [S[0]]
    i = count
  elif count == i:
    A = A + [S[0]]
    
  S[0:count] = []

for val in A:
	print(val)

Submission status: Runtime Error

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

arr = []
max_num = 0;
for k,v in dictionary.items():
  if max_num == 0 or max_num < v:
    max_num = v
    arr = []
    arr.append(k)
  elif max_num == v:
    max_num = v
    arr.append(k)
    
arr.sort()
for i in arr:
  print(i)

Submission status: Runtime Error

Solution code:
N = int(input())
S = list()
count = 0
lis = [0]*N
ans = list()
for i in range(N):
  S.append(input())
S.sort()
for i in range(N-1):
  if S[i] == S[i+1]:
    count += 1
  else:
    list[i] = count
    count = 0
dai = 1
for i in range(N-1):
  if lis[i] < lis[i+1] and dai < lis[i+1]:
    ans.clear()
    ans.append(S[i+1])
    dai = lis[i+1]
  elif lis[i] < lis[i+1] and dai == lis[i+1]:
    ans.append(S[i+1])
    dai = lis[i+1]
if dai == 1 and count == 0:
  [print(i) for i in S]
elif dai == 1 and count == 1:
  print(ans)
elif count == N-1:
  print(S[0])
else:
  [print(i) for i in ans]

Submission status: Runtime Error

Solution code:
N = int(input())
s = [input() for i in range(N)]
from collections import Counter
s1 = sorted(s)
 
c = collections.Counter(s1)
s2 = c.most_common()
 
#print(s2)
a = 0
for i in range(len(s2)):
    if s2[0][1] == s2[i][1]:
        a = a + 1
 
for i in range(a):
    print(str(s2[i][0]))

Submission status: Runtime Error

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

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

for (key, value) in votes.iteritems():
    dict[value].append(key)
maxVote = sorted(dict.keys(), reverse=True)[0]
if len(dict[maxVote]) > 1:
    print(sorted(dict[maxVote])[0])
else:
    print(dict[maxVote][0])

Submission status: Runtime Error

Solution code:
n = int(input())

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

Submission status: Runtime Error

Solution code:
import collections

N = int(input())
S = [input() for i in range(N)]
SS = []
c = collections.Counter(S)
n = len(c.most_common())
for j in range(1, n):
    if(c.most_common()[0][1] == c.most_common()[2][1]):
        if(c.most_common()[0][1] == c.most_common()[j][1]):
            b = c.most_common()[j][0]
            SS.append(b)
SS.append(c.most_common()[0][0])
sortedS = sorted(SS)
[print(k) for k in sortedS]

Submission status: Runtime Error

Solution code:
from numba import njit

@njit
def main():
  N = int(input())
  S = [str(input()) for _ in range(N)]
  S_ = [x for x in set(S) if S.count(x) > 1] #重複している要素を取り出す
  if len(S_)==0:
    S.sort()
    for i in range(len(S)):
      print(S[i])
  else:
    chofuku_number=[S.count(x) for x in S_]
    max_chofuku = max(chofuku_number)
    answer=[S_[i] for i in range(len(chofuku_number)) if chofuku_number[i]==max_chofuku]
    answer.sort()
    for i in range(len(answer)):
      print(answer[i])
if __name__ == '__main__':
  main()

Submission status: Runtime Error

Solution code:
l = [input() for i in range(n)]
l.sort()
i = 0
max = 1
count = 1
ans = []

while i < n-1:
  if l[i] == l[i+1]:
    count += 1
    i += 1
    if i == n-1 and count >= max:
      ans.append(l[n-1])

  else:
    if count >= max:
      max = count
      ans.append(l[i])
      count = 1
      i += 1
    else:
      count = 1
      i += 1

if max == 1:
  ans.append(l[n-1])
      
for i in ans:
  print(i)

Submission status: Runtime Error

Solution code:
import collections
N=int(input())
S=[input() for i in range(N)]
c=collections.Counter(S)
if len(c.most_common())==1:
  print(c.most_common()[0][0])
else:
  for i in range(len(c.most_common())):
    print(c.most_common()[i][0])
    if c.most_common()[i][1] !=c.most_common()[i+1][1]:
      break

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import collections as col
N=int(input())
counts=[]
A=[]
S=[]
T=[]
U=[]
for _ in range(N):
    S.append(input())
T=sorted(S)
s=col.Counter(T)
values, counts = zip(*s.most_common())

print(values[0])
t=1

while t<=len(values) and counts[t]==counts[t-1]:
    print(values[t])
    t+=1

Submission status: Runtime Error

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

ss=sorted(s)
t=0
c=1
count=[]
for i in range(1,n):
    if i==n-1:
        if ss[t]==ss[i]:
            count.append(c+1)
        else:
            count.append(c)
            count(1)
    else:
        if ss[t]==ss[i]:
            c+=1
        else:
            t=i
            count.append(c)
            c=1
u=0
for i in count:
    if i==max(count):
        print(ss[u])
    u+=i

Submission status: Runtime Error

Solution code:
import numpy as np

N = int(input())
a = input().split()

a = np.array(a)

unique_elements, counts_elements = np.unique(a, return_counts=True)
elements = unique_elements[counts_elements == np.max(counts_elements)]
for i in elements:
    print(i)

Submission status: Runtime Error

Solution code:
def main():
	# n,m = map(int,input().split())
	n = int(input())
	l = [str(input()) for i in range(n)]
	
	import collections

	c = collections.Counter(l)
	lc = sorted(list(c.items()), key = lambda x:x[1] , reverse = True)
	# print(lc)
	ans = []
	checker = 0
	i = 0
	while checker == 0:
		if lc[i][1] == lc[0][1]:
			ans.append(lc[i][0])
		else:
			checker += 1
		i += 1

	# keys = [k for k, v in c.items() if v == max(c.values())]
	# print(list(c.items())[0][0])
	# checker = 0
	# while checker == 0:
	# 	if c.items() == max(c.values()):
	ans.sort()
	print('\n'.join(map(str, ans)))

	
	
 
if __name__ == '__main__':
	main()