TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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.

Submission attempts (in order):
n=int(input())
d=dict()

for i in range(n):
  a=input()
  d.setdefault(s,0)
  d[s] += 1

mx=0
result=[]
for key,value in d.items:
  if mx < value:
    mx = value
    result=[key]
  elif mx == value:
    result.append(key)

result.sort()

for i in range(len(result)):
  print(i)

n = int(input())
s= []

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

s.sort()
n =set(s)
n=list(n)
print(n)

f = []

for i in range(len(n)):
    f.append([n[i],s.count(n[i])])

f.sort(reverse=True,key=lambda f:f[1])

max = f[0][0]
fl=[]
for i in range (len(f)):
    if f[i][1] == max:
        fl.append(f[i][0])
    else:
        break

fl.sort()
ans=(set(fl))
ansf=list(ans)

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

n = int(input())
s= []

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

s.sort()
n =set(s)
n=list(n)
print(n)

f = []

for i in range(len(n)):
    f.append([n[i],s.count(n[i])])

f.sort(reverse=True,key=lambda f:f[1])
max = f[0][1]
fl=[]
for i in range (len(f)):
    if f[i][1] == max:
        fl.append(f[i][0])
    else:
        break

fl.sort()
ans=(set(fl))
ansf=list(ans)

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

n = int(input())
s= []

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

s.sort()
n =set(s)
n=list(n)

f = []

for i in range(len(n)):
    f.append([n[i],s.count(n[i])])

f.sort(reverse=True,key=lambda f:f[1])
max = f[0][1]
fl=[]
for i in range (len(f)):
    if f[i][1] == max:
        fl.append(f[i][0])
    else:
        break

fl.sort()
ans=(set(fl))
ansf=list(ans)

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

n=int(input())
d=dict()

for i in range(n):
  a=input()
  d.setdefault(a,0)
  d[a] += 1

mx=0
result=[]
for key,value in d.items():
  if mx < value:
    mx = value
    result=[key]
  elif mx == value:
    result.append(key)

result.sort()

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

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())
S = []
for x in range(N):
    S.append(input())
S_label_n = []
S_label = list(set(S))
for x in S_label:
    S_label_n.append(S.count(x))
maxIndex = [i for i, x in enumerate(S_label_n) if x == max(S_label_n)]
ans_list = []
for x in maxIndex:
    ans_list.append(S_label[x])
ans_list.sort()
print(ans_list)

import sys
input = sys.stdin.readline
N = int(input())
dictS = {}
for x in range(N):
    tmp = input().rstrip()
    if tmp in dictS:
        dictS[tmp] = dictS[tmp]+1
    else:
        dictS[tmp]=1
        
max_n =max(dictS.values())
maxIndex = [x for x in dictS.items() if x[1] ==max_n ]
ans_list = []
for x in maxIndex:
    ans_list.append(x[0])
ans_list.sort()
for x in ans_list:
    print(x)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
k=int(input())
p=[input() for i in range(k)]
m=0
a=[]
for j in frozenset(p):
  if not p.count(j)<m:
    a.append(j)
print("\n".join(sorted(a)))

from collections import Counter
k=int(input())
p=Counter(input() for f in range(k))
j=sorted(p.most_common(), key=lambda a:1-a[1])
j=[m[0] for m in j if m[1]==j[0][1]]
print("\n".join(sorted(j)))

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import collections
n=int(input())
data=[""]*n
for i in range(n):
    data[i]=input()
count=collections.Counter(data)
num=max(count.values())
for v,k in count.items():
    if k==num:
        print(v)

import collections
n=int(input())
data=[""]*n
for i in range(n):
    data[i]=input()
data=sorted(data)
count=collections.Counter(data)
num=max(count.values())
for v,k in count.items():
    if k==num:
        print(v)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import collections
N = int(input())
S = [str(input()) for i in range(N)]
new_S = collections.Counter(S)
M = max(new_S.values())
#X = []
for K,V in new_S.items():
  if V == M:
    print(K)

import collections
N = int(input())
S = [str(input()) for i in range(N)]
new_S = collections.Counter(S)
M = max(new_S.values())
X = []
for K,V in new_S.items():
  if V == M:
    X.append(K)
X.sort()
for x in X:
  print(x)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):

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

cnt = []
for item in list(set(l)):
    cnt.append(l.count(item))

num_dict = dict(zip(list(set(l)),cnt))
max_v = max(num_dict.values())

keys = []

for word, num in num_dict.items():
    if num == max_v:
        keys.append(word)

print(sorted(keys))


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

cnt = []
l_t = list(set(l))
for item in l_t:
    cnt.append(l.count(item))

num_dict = dict(zip(l_t),cnt))
max_v = max(num_dict.values())

keys = []

for word, num in num_dict.items():
    if num == max_v:
        keys.append(word)

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

from collections import Counter
N = int(input())
S = Counter(input() for _ in range(N))
m = max(S.values())
for v in sorted(k for k, v in S.items() if v == m):
	print(v)


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())
str_lis = []
for i in range(N):
  str_lis.append(ord(input()))

max_num = 0
max_str = []
for i in str_lis:
  if str_lis.count(i) > max_num and not i in max_str:
    max_num = str_lis.count(i)
    max_str = []
    max_str.append(i)
  elif str_lis.count(i) == max_num and not i in max_str:
    max_num = str_lis.count(i)
    max_str.append(i)
    
new_max_str = sorted(max_str)

for i in new_max_str:
  print(chr(i))

from collections import Counter

N = int(input())

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

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N=int(input())
S={i:input() for i in range(N)}
value=[]
max=0

for i in S.values():
	N=list(S.values()).count(i)
	if N>max or N==max:
		max=N
for j in S.values():
	M=list(S.values()).count(j)
	if N==M:
		value.append(j)
value.sort()
[print(i) for i in value]

import sys
from collections import Counter
N = int(sys.stdin.readline())
S = sys.stdin.read().split()
 
count = Counter(S)
max_num = max(count.values())

max_list = [i for i,j in count.items() if j==max_num]
 
max_list.sort()
print('\n'.join(max_list))

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from collections import defaultdict
from collections import OrderedDict
n = int(input())
answer = dict()
for _ in range(n):
    z = str(input())
    if z in answer:
        ans[z]+=1
    else:
        answer.update({z:1})
groupedByValue = defaultdict(list)
for key, value in sorted(answer.items()):
    groupedByValue[value].append(key)
M = groupedByValue[max(groupedByValue)]
for i in M:
    print(i)

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

from collections import defaultdict
from collections import OrderedDict
n = int(input())
answer = dict()
for _ in range(n):
    z = str(input())
    if z in answer:
        answer[z]+=1
    else:
        answer.update({z:1})
groupedByValue = defaultdict(list)
for key, value in sorted(answer.items()):
    groupedByValue[value].append(key)
M = groupedByValue[max(groupedByValue)]
for i in M:
    print(i)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import collections
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    s = list()
    for i in range(n):
        s.append(str(input()).replace('\n', ''))

    c = dict(collections.Counter(s))
    max_count = max(c.values())
    for k, v in c.items():
        if v == max_count:
            print(k)


if __name__ == '__main__':
    main()


#!/usr/bin/env python
# -*- coding: utf-8 -*-

import collections
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    s = list()
    for i in range(n):
        s.append(str(input()).replace('\n', ''))

    c = dict(collections.Counter(s))
    max_count = max(c.values())
    ans = list()
    for k, v in c.items():
        if v == max_count:
            ans.append(k)

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


if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())
l = []

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

import collections
c = collections.Counter(l)

ml = [kv for kv in c.items() if kv[1] == max(c.values())]

for _ in range(len(ml)):
    print(ml[_][0])

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

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

import collections
c = collections.Counter(l)
c = c.most_common()

most_count = c[0][1]
for i in range(len(c)):
    if c[i][1] == most_count:
        print(c[i][0])

d = {}
N = int(input())

for _ in range(N):
    s = str(input())
    if s in d.keys():
        d[s] += 1
    else:
        d[s] = 1

ans = []

for i in range(len(sd)):
    if sd[i][1] == max(d.values()):
        ans.append(sd[i][0])

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

d = {}
N = int(input())

for _ in range(N):
    s = str(input())
    if s in d.keys():
        d[s] += 1
    else:
        d[s] = 1

sd = sorted(d.items())

for i in range(len(sd)):
    if sd[i][1] == max(d.values()):
        print(sd[i][0])
    else:
        exit()


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

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

import collections
c = collections.Counter(l)
c = c.most_common()
c.sort()
most_count = c[0][1]
for i in range(len(c)):
    if c[i][1] == most_count:
        print(c[i][0])

d = {}
N = int(input())

for _ in range(N):
    s = str(input())
    if s in d.keys():
        d[s] += 1
    else:
        d[s] = 1

ans = []

for i in range(len(d)):
    if d[i][1] == max(d.values()):
        ans.append(d[i][0])

ans = sorted(ans)

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

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

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

import collections
c = collections.Counter(l)
c = c.most_common()

most_count = c[0][1]
c.sort()

for i in range(len(c)):
    if c[i][1] == most_count:
        print(c[i][0])

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N=int(input())
S=[input() for i in range(N)]
S=sorted(S)
cnt=1
max_cnt=1
ans=[S[0]]
for i in range(N-1):
    if S[i]==S[i+1]:
        cnt+=1
    else:
        cnt=1
    if cnt==max_cnt:
        ans.append(S[i+1])
    if cnt>max_cnt:
        ans=[S[i+1]]
ans=sorted(ans)
for i in ans:
    print(i)

N=int(input())
S=[input() for i in range(N)]
S=sorted(S)
cnt=1
max_cnt=1
ans=[S[0]]
for i in range(N-1):
    if S[i]==S[i+1]:
        cnt+=1
    else:
        cnt=1
    if cnt==max_cnt:
        ans.append(S[i+1])
    if cnt>max_cnt:
        max_cnt=cnt
        ans=[S[i+1]]
ans=sorted(ans)
for i in ans:
    print(i)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from collections import Counter

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

c=[i for i in max(Counter(s))]

for j in c:
	print(j)

from collections import Counter
 
n=int(input())
s = [input() for _ in range(n)]
 
c=[i for i,j in Counter(s).items() if j == max(Counter(s).values())]
 
for k in c:
	print(k)

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)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
#155
def main():
    N = int(input())
    S = [input() for i in range(N)]
    S.sort()
    ans = []
    max_len = 0
    streak = 1
    for i in range(len(S)-1):
        if(S[i]==S[i+1]):
            streak+=1
        else:
            if(streak>max_len):
                max_len = streak
                ans = [S[i]]
            elif(streak==max_len):
                ans.append(S[i])
            streak=1
    for a in ans:
        print(a)
main()

#155
def main():
    N = int(input())
    S = [input() for i in range(N)]
    S.sort()
    ans = []
    max_len = 0
    streak = 1
    for i in range(N-1):
        if(S[i]==S[i+1]):
            streak+=1
        else:
            if(streak>max_len):
                max_len = streak
                ans = [S[i]]
            elif(streak==max_len):
                ans.append(S[i])
            streak=1
    if(N==1 or S[-2]!=S[-1]):
        ans.append(S[-1])
    for a in ans:
        print(a)
main()

#155
def main():
    N = int(input())
    S = [input() for i in range(N)]
    S.sort()
    ans = []
    max_len = 0
    streak = 1
    for i in range(N-1):
        if(S[i]==S[i+1]):
            streak+=1
            if(i==N-2):
                if(streak>max_len):
                    max_len = streak
                    ans = [S[i]]
                elif(streak==max_len):
                    ans.append(S[i])
        else:
            if(streak>max_len):
                max_len = streak
                ans = [S[i]]
            elif(streak==max_len):
                ans.append(S[i])
            streak=1
    if(N==1 or S[-2]!=S[-1]):
        ans.append(S[-1])
    for a in ans:
        print(a)
main()

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())
A = {}

MAX = 0
for i in range(N):
    s = input()
    A[s] = A.get(s,0) + 1
    MAX = max(MAX, A[s])

for k,v in A.items():
  if MAX == v:
    print(k)

N = int(input())
A = {}

MAX = 0
for i in range(N):
    s = input()
    A[s] = A.get(s,0) + 1
    MAX = max(MAX, A[s])

B = sorted(A.items())
print(B)
for k, v in B:
    if v == MAX:
        print(k)

N = int(input())
A = {}

MAX = 0
for i in range(N):
    s = input()
    A[s] = A.get(s,0) + 1
    MAX = max(MAX, A[s])

A = sorted(A.items())
for k,v in A.items():
  if MAX == v:
    print(k)

N = int(input())
A = {}

MAX = 0
for i in range(N):
    s = input()
    A[s] = A.get(s,0) + 1
    MAX = max(MAX, A[s])

B = sorted(A.items())
for k, v in B:
    if v == MAX:
        print(k)

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
# -*- coding: utf-8 -*-

import os
import datetime

def main():

    str_dict = {}
    val_1 = int(input())
    for i in range(val_1):
        val_x = input()

        if not val_x in str_dict:
            str_dict[val_x] = 1
        else:
            num = str_dict.get(val_x)
            str_dict[val_x] = num + 1

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




if __name__ == '__main__':
    main()

# -*- coding: utf-8 -*-

import os
import datetime

def main():

    str_dict = {}
    val_1 = int(input())
    for i in range(val_1):
        val_x = input()

        if not val_x in str_dict:
            str_dict[val_x] = 1
        else:
            num = str_dict.get(val_x)
            str_dict[val_x] = num + 1

    max_count = max(str_dict.values())
    max_list = []

    for k, v in sorted(str_dict.items(), key=lambda x: -x[1]):
        if max_count == v:
            max_list.append(k)

    new_list = sorted(max_list)

    for key in new_list:
        print(key)





if __name__ == '__main__':
    main()

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from collections import Counter

n = int(input())
s = [input() for i in range(n)]
news = sorted(s)
c = Counter(news)
max = c.most_common()[0][1]
print(c)
for i in range(n):
  if max == c.most_common()[i][1]:
    print(c.most_common()[i][0])
  else:
    break

import collections as co

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

c = co.Counter(s)
max = c.most_common()[0][1]
r = 1
i = 0

while r == 1:
  if max == c.most_common()[i][1]:
    print(c.most_common()[i][0])
  else:
    r = 0
  i += 1



from collections import Counter

n = int(input())
s = [input() for i in range(n)]
c = Counter(s)
C = c.most_common()
a = C[0][1]
ans = []
for i in range(len(c)):
  if C[i][1] == a:
    ans.append(C[i][0])

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

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
from collections import Counter

N = int(input())
S = [input() for x in range(N)]
E = Counter(a)
c = max(E.values())
s = [s for s, g in b.items() if g == c]
s.sort()
print('\n'.join(s))

from collections import Counter

N = int(input())
A = [input() for x in range(N)]
cnt = Counter(A)
mx = max(cnt.values())
sorted(cnt.items())
print('\n'.join(s for s, v in cnt.items() if v == mx))

from collections import Counter
 
N = int(input())
S = [input() for x in range(N)]
E = Counter(S)
c = max(E.values())
s = [s for s, g in b.items() if g == c]
s.sort()
print('\n'.join(s))

from collections import Counter

N = int(input())
A = [input() for x in range(N)]
cnt = Counter(A)
mx = max(cnt.values())
s = [s for s, v in cnt.items() if v == mx]
s.sort()
print('\n'.join(s))


Verdicts: Runtime Error

Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())
S = []

import collections

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

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

c_max = C[0][1]

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

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

import collections

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

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

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

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
def main():
  num = int(input())

  tmp = [input() for i in range(num)]

  tmp2 = {}
  for t in tmp:
    if len(tmp2) == 0:
      tmp2[t] = 1
    else:
      if t in tmp2:
        tmp2[t] += 1
      else:
        tmp2[t] = 1

  tmp2 = sorted(tmp2.items(), key=lambda x:x[1])
  for t in sorted(tmp2):
    if tmp2[0][1] == t[1]:
      print(t[0])

main()

def main():
  num = int(input())

  tmp = [input() for i in range(num)]

  tmp2 = {}
  for t in tmp:
    if len(tmp2) == 0:
      tmp2[t] = 1
    else:
      if t in tmp2:
        tmp2[t] += 1
      else:
        tmp2[t] = 1

  _tmp2 = sorted(tmp2.items(), key=lambda x:x[1])
  tmp3 = sorted(tmp2.items())
  for t in tmp3:
    if _tmp2[-1][1] == t[1]:
      print(t[0])

main()

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import collections
n = input()
s = [input() for _ in range(n)]
s = collections.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)


from collections import Counter
data = ['aaa', 'bbb', 'ccc', 'aaa', 'ddd']
counter = Counter(data)
print(counter.most_common()[0][0])

from collections import Counter

pass

import collections
n = int(input())
s = [input() for _ in range(n)]
s = collections.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)

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)

from collections import Counter
n = int(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 sorted(a):
    print(s)

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
from collections import Counter


def main(n, s):
    c = Counter(s)
    max_count = c.most_common()[0][1]
    res = []
    for keys, count in c.most_common():
        if max_count == count:
            res.append(keys)

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


if __name__ == "__main__":
    n = int(input())
    s = [input() for _ in range(n)]


from collections import Counter


def main(n, s):
    c = Counter(s)
    max_count = c.most_common()[0][1]
    res = []
    for keys, count in c.most_common():
        if max_count == count:
            res.append(keys)
        else:
            print("\n".join(sorted(res)))
            return


if __name__ == "__main__":
    n = int(input())
    s = [input() for _ in range(n)]


from collections import Counter


def main(n, s):
    c = Counter(s)
    max_count = c.most_common()[0][1]
    res = []
    for keys, count in c.most_common():
        if max_count == count:
            res.append(keys)

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


if __name__ == "__main__":
    n = int(input())
    s = [input() for _ in range(n)]

    main(n, s)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())
d = {}
for _ in range(N):
  s = input()
  if not s in d:
    d[s] = 1
  else:
    d[s] += 1
x = sorted(list(d.items()), key=lambda x:x[1], reverse=True)
n = 0
l = []
for k, v in x:
  if v >= n:
    n = v
    l.append(v)
for y in sorted(l):
  print(y)


N = int(input())
d = {}
for _ in range(N):
  s = input()
  if not s in d:
    d[s] = 1
  else:
    d[s] += 1
x = sorted(list(d.items()), key=lambda x:x[1], reverse=True)
n = 0
for k, v in x:
  if v >= n:
    n = v
    print(k)

N = int(input())
d = {}
for _ in range(N):
  s = input()
  if not s in d:
    d[s] = 1
  else:
    d[s] += 1
x = sorted(list(d.items()), key=lambda x:x[1])
n = 0
for k, v in x:
  if v >= n:
    n = v
    print(k)

N = int(input())
d = {}
for _ in range(N):
  s = input()
  if not s in d:
    d[s] = 1
  else:
    d[s] += 1
x = sorted(list(d.items()), key=lambda x:x[1], reverse=True)
n = 0
l = []
for k, v in x:
  if v >= n:
    n = v
    l.append(k)
for y in sorted(l):
  print(y)


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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]] >= i:
        sts.append(s[0])
    i = dicts[s[0]]

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

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(dict.items(), key=lambda x:x[1])

i = 0
for s in dict_sorted.key():
    if dicts[s] >= i:
        print(s)
    i = dicts[s]

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
for s in dict_sorted:
    if dicts[s[0]] >= i:
        print(s[0])
    i = dicts[s[0]]


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)

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from collections import Counter
n = int(input())
a = [input() for i in range(n)]

c = Counter(a)
d = c.most_common()

for i in c.items():
   if i[1] == d[0][1]:
     print(i[0])


from collections import Counter


def main():
    N = int(input())
    A = [input() for _ in range(N)]

    c = Counter(A)
    max_num = c.most_common()[0][1]
    ANS = [i[0] for i in c.items() if i[1] == max_num]
    ANS.sort()
    for ans in ANS:
        print(ans)


if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())
D = {}
for i in range(N):
  S = input()
  if S in D:
    D[S] += 1
  else:
    D[S] = 1
M = max(D)
L = []
for i in D:
  if D[i] == M:
    L.append(i)
L.sort()
for i in range(len(L)):
  print(L[i])

N = int(input())
D = {}
for i in range(N):
  S = input()
  if S in D:
    D[S] += 1
  else:
    D[S] = 1
M = max(D[i] for i in D)
L = []
for i in D:
  if D[i] == M:
    L.append(i)
L.sort()
for i in range(len(L)):
  print(L[i])


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import collections
import itertools
N=int(input())
#P=list(map(int,input().split()))
st=[]
for i in range(N):
    s=str(input())
    st.append(s)
c = collections.Counter(st)

ret = [letter for letter,count in c.most_common() if count == c.most_common()[0][1]]

sorted(ret)
for r in ret:
    print(r)


import collections
import itertools
N=int(input())
#P=list(map(int,input().split()))
st=[]
for i in range(N):
    s=str(input())
    st.append(s)
c = collections.Counter(st)
count=c.most_common()
max=count[0][1]
min=count[-1][1]
if max==min:
    st=list(set(st))
    st.sort()
    for k in st:
        print(k)
    exit()
ret=[]
for letter,cou in count:

     if cou == max:
         ret.append(letter)
     else:
         break
ret.sort()
for r in ret:
    print(r)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n=int(input())
a=[]
import collections as cc
a=[input() for i  in range(n)]
f=cc.Counter(a)
ch=max(f.values())
ans=[]
for i in a:
    if f[i]==ch:
        ans.append(i)
ans.sort()
for i in set(ans):
    print(i)

n=int(input())
a=[]
import collections as cc
a=[input() for i  in range(n)]
f=cc.Counter(a)
ch=max(f.values())
ans=[]
for i in a:
    if f[i]==ch:
        ans.append(i)
ans=list(set(ans))
ans.sort()
for i in ans:
    print(i)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n=int(input())
arr=list(input() for _ in range(n)
dic={}

for i in range(n):
 if arr[i] not in dic:
  dic[arr[i]]=1
 else:
  dic[arr[i]]+=1
     
largest=max(dic.values())
ans=[]
for keys in dic.keys():
 if dic[keys]==largest:
  ans.append(keys)
ans=sorted(ans)

for words in ans:
 print(words)

n=int(input())
arr=list(input() for _ in range(n))
dic={}

for i in range(n):
  if arr[i] not in dic:
    dic[arr[i]]=1
  else:
    dic[arr[i]]+=1
     
largest=max(dic.values())
ans=[]
for keys in dic.keys():
  if dic[keys]==largest:
    ans.append(keys)
ans=sorted(ans)

for words in ans:
  print(words)

Verdicts: Runtime Error

Accepted
Problem: We have N integers A_1, A_2, ..., A_N.  There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list?

Submission attempts (in order):
import numpy as np
N, K = map(int, input().split())
L = np.array(list(map(int, input().split())))

L = np.sort(L)
pos = L[0<L]
neg = L[0>L]
zero = len(L[L==0])

def f(x):
  tmp = 0
  if x>=0:
    tmp += zero*N
  tmp += np.searchsorted(L, x//pos, side='right').sum()
  tmp += (N - np.searchsorted(L, x//neg, side='left')).sum()
  tmp -= np.count_nonzero(L*L<=x)
  return tmp//2

l, r = -10**18, 10**18
while l<r-1:
  m = (l+r)//2
  count = f(m)
  if count >= K:
    r = m
  else:
    l = m

print(r)

import numpy as np
N, K = map(int, input().split())
L = np.array(list(map(int, input().split())))

L = np.sort(L)
pos = L[0<L]
neg = L[0>L]
zero = len(L[L==0])

def f(x):
  tmp = 0
  if x>=0:
    tmp += zero*N
  tmp += np.searchsorted(L, x//pos, side='right').sum()
  tmp += (N - np.searchsorted(L, -(-x//neg), side='left')).sum()
  tmp -= np.count_nonzero(L*L<=x)
  return tmp//2

l, r = -10**18, 10**18
while l<r-1:
  m = (l+r)//2
  count = f(m)
  if count >= K:
    r = m
  else:
    l = m

print(r)

Verdicts: Wrong Answer

Accepted
Problem: We have N integers A_1, A_2, ..., A_N.  There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list?

Submission attempts (in order):
n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = []
for i in range(n):
    for j in range(i + 1, n):
        print(a[i], a[j])
        b.append(a[i] * a[j])
ans = list(sorted(b))
print(ans[k])


import numpy as np

n, k = [int(i) for i in input().split()]
a = np.array(sorted([int(i) for i in input().split()]))
posi = a[a > 0]
zero = a[a == 0]
nega = a[a < 0]


l = -10 ** 18 - 1
r = 10 ** 18 + 1
while r - l > 1:
    mid = (r + l) // 2
    cnt = 0
    if mid >= 0:
        cnt += len(zero) * n

    cnt += a.searchsorted(mid // posi, side="right").sum()
    cnt += (n - a.searchsorted(-(-mid // nega), side="left")).sum()
    cnt -= np.count_nonzero(a * a <= mid)
    cnt //= 2
    if cnt >= k:
        r = mid
    else:
        l = mid
print(r)


Verdicts: Runtime Error

Accepted
Problem: We have N integers A_1, A_2, ..., A_N.  There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list?

Submission attempts (in order):
import numpy as np

n, k = map(int, input().split())
a = list(map(int, input().split()))

a = np.array(a)
a.sort()

nega = a[a<0]
zero = a[a==0]
posi = a[a>0]

l = -10**18-1
r = 10**18+1
while r - l > 1:
   mid = (r+l)//2
   cnt = 0
   if mid >= 0:
      cnt += len(zero)*n
   cnt += a.searchsorted(mid//posi, side='right').sum()
   cnt += (n - a.searchsorted(mid//nega, side='left')).sum()
   cnt -= np.count_nonzero(a*a <= mid)
   cnt //=2
   if cnt >= k:
      r = mid
   else:
      l= mid

print(r)



import numpy as np

n, k = map(int, input().split())
a = list(map(int, input().split()))

a = np.array(a)
a.sort()

nega = a[a<0]
zero = a[a==0]
posi = a[a>0]

l = -10**18-1
r = 10**18+1
while r - l > 1:
   mid = (r+l)//2
   cnt = 0
   if mid >= 0:
      cnt += len(zero)*n
   cnt += a.searchsorted(mid//posi, side='right').sum()
   cnt += (n - a.searchsorted(-(-mid//nega), side='left')).sum()
   cnt -= np.count_nonzero(a*a <= mid)
   cnt //=2
   if cnt >= k:
      r = mid
   else:
      l= mid

print(r)



Verdicts: Wrong Answer

Accepted
Problem: We have N integers A_1, A_2, ..., A_N.  There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list?

Submission attempts (in order):
import numpy as np
n,k = map(int,input().split())
a = list(map(int,input().split()))
a = np.array(a)
a.sort()
p = a[a>0]
z = a[a==0]
m = a[a<0]
low = -10**18
high = 10**18
while high-low>1:
    mid = (high + low) //2
    count = 0
    if mid >= 0:
        count += len(z)*n
    count += a.searchsorted(mid//p,side = "right").sum()
    count += (n-a.searchsorted(-(-mid//m),side = "left")).sum()
    count -= np.count_nonzero(a*a <= mid)
    count /= 2
    print(count)
    if count >= k:
        high = mid
    if count < k:
        low = mid
print(high)


import numpy as np
n,k = map(int,input().split())
a = list(map(int,input().split()))
a = np.array(a)
a.sort()
p = a[a>0]
z = a[a==0]
m = a[a<0]
low = -10**18
high = 10**18
while high-low>1:
    mid = (high + low) //2
    count = 0
    if mid >= 0:
        count += len(z)*n
    count += a.searchsorted(mid//p,side = "right").sum()
    count += (n-a.searchsorted(-(-mid//m),side = "left")).sum()
    count -= np.count_nonzero(a*a <= mid)
    count /= 2
    if count >= k:
        high = mid
    if count < k:
        low = mid
print(high)


Verdicts: Wrong Answer

Accepted
Problem: We have N integers A_1, A_2, ..., A_N.  There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list?

Submission attempts (in order):
N, K = map(int, input().split())


A = list(map(int, input().split()))


ans = []
for x in range(len(A)):
    for y in range(x+1, len(A)):
        ans.append(A[x]*A[y])
ans.sort()
print(ans)
print(ans[K-1])




import numpy as np
N, K = map(int, input().split())

A = np.array(list(map(int, input().split())))
A.sort()

pos = A[A > 0]
neg = A[A < 0]
zero = A[A == 0]

l = -10**18
r = 10**18

while l + 1 < r:
    x = (l+r) // 2
    cnt = 0
    if x >= 0:
        cnt += N * len(zero)

    cnt += A.searchsorted(x//pos, side="right").sum()
    cnt += (N - A.searchsorted(-(-x//neg), side="left")).sum()
    cnt -= np.count_nonzero(A * A <= x)
    cnt //= 2

    if cnt >= K:
        r = x
    else:
        l = x

print(r)




Verdicts: Wrong Answer

Accepted
Problem: We have N integers A_1, A_2, ..., A_N.  There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list?

Submission attempts (in order):
import numpy as np

N,K = [int(i) for i in input().split()]
n = np.array([int(i) for i in input().split()])
n=np.sort(n)

mn = n[np.where(n<0)]
mz = n[np.where(n==0)]
mp = n[np.where(n>0)]

#cn = len(mn)
#cp = len(mp)

#tcn = cn*cp


#    print(0)
#    exit(0)

M = 10**18
m = -1*M-1
pos = 0

while M-m > 1:
    a = 0
    pos=(M+m)//2
    a+=np.searchsorted(n,pos//mp,side="right").sum()
    a+=cz*N
    a+=N*len(mn) - np.searchsorted(n,-(-pos//mn),side="left").sum()
    a-=np.count_nonzero(n*n <= pos)
    a=a//2
    if a >= K:
        M=pos
    else:
        m=pos
#print(M,m)
print(M)


import numpy as np

N,K = [int(i) for i in input().split()]
n = np.array([int(i) for i in input().split()])
n=np.sort(n)

mn = n[np.where(n<0)]
mz = n[np.where(n==0)]
mp = n[np.where(n>0)]

M = 10**18
m = -1*M-1
pos = 0

while M-m > 1:
    a = 0
    pos=(M+m)//2
    a+=np.searchsorted(n,pos//mp,side="right").sum()
    a+=cz*N
    a+=N*len(mn) - np.searchsorted(n,-(-pos//mn),side="left").sum()
    a-=np.count_nonzero(n*n <= pos)
    a=a//2
    if a >= K:
        M=pos
    else:
        m=pos
#print(M,m)
print(M)


import numpy as np

N,K = [int(i) for i in input().split()]
n = np.array([int(i) for i in input().split()])
n=np.sort(n)

mn = n[np.where(n<0)]
mz = len(n[np.where(n==0)])
mp = n[np.where(n>0)]
M = 10**18
m = -1*M-1
pos = 0

while M-m > 1:
    a = 0
    pos=(M+m)//2
    a+=np.searchsorted(n,pos//mp,side="right").sum()
    if pos >= 0: a+=mz*N
    a+=N*len(mn) - np.searchsorted(n,-(-pos//mn),side="left").sum()
    a-=np.count_nonzero(n*n <= pos)
    a=a//2
    if a >= K:
        M=pos
    else:
        m=pos
        
print(M)


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: We have N integers A_1, A_2, ..., A_N.  There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list?

Submission attempts (in order):
import numpy as np


def partsolve(A, x, positive, zero, negative):
    
    count = 0
    if x >= 0:
        count = len(zero) * len(A)
    P = x // positive
    Pc = np.searchsorted(A, P, side='right')
    count += Pc.sum()

    N = (-x-1) // -negative
    Nc = np.searchsorted(A, N, side='right')
    Nc = len(A) - Nc
    count += Nc.sum()

    count -= np.count_nonzero(A * A <= x)
    return count // 2

def solve(N, K, As):
    A = np.array(sorted(As), np.int64)
    positive = A[A > 0]
    zero = A[A == 0]
    negative = A[A < 0]

    left = -10 ** 18
    right = 10 ** 18
    while right - left > 1:
        mid = left + (right - left) // 2
        c = partsolve(A, mid, positive, zero, negative)
        print(mid, c)
        if c < K:
            left = mid
        else:
            right = mid
    return right


if __name__ == "__main__":
    N, K = tuple(map(int, input().split(" ")))
    As = list(map(int, input().split(" ")))
    print(solve(N, K, As))



import numpy as np


def partsolve(A, x, positive, zero, negative):
    
    count = 0
    if x >= 0:
        count = len(zero) * len(A)
    P = x // positive
    Pc = np.searchsorted(A, P, side='right')
    count += Pc.sum()

    N = (-x-1) // -negative
    Nc = np.searchsorted(A, N, side='right')
    Nc = len(A) - Nc
    count += Nc.sum()

    count -= np.count_nonzero(A * A <= x)
    return count // 2

def solve(N, K, As):
    A = np.array(sorted(As), np.int64)
    positive = A[A > 0]
    zero = A[A == 0]
    negative = A[A < 0]

    left = -10 ** 18
    right = 10 ** 18
    while right - left > 1:
        mid = left + (right - left) // 2
        c = partsolve(A, mid, positive, zero, negative)
        if c < K:
            left = mid
        else:
            right = mid
    return right


if __name__ == "__main__":
    N, K = tuple(map(int, input().split(" ")))
    As = list(map(int, input().split(" ")))
    print(solve(N, K, As))



Verdicts: Wrong Answer

Accepted
Problem: We have N integers A_1, A_2, ..., A_N.  There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list?

Submission attempts (in order):
import numpy as np
n,k = map(int,input().split())
a = np.array(list(map(int,input().split())))
a.sort()
posi = a[a>0]
zero = a[a==0]
nega = a[a<0]

def cnt(x):
    c = 0
    if x >= 0:
        c += len(zero)*n
    c += np.searchsorted(a, x // posi, side = 'right').sum()
    c += n-np.searchsorted(a, (- x - 1) // (-nega), side = 'right').sum()
    c -= np.count_nonzero(a * a <= x)
    return c // 2

l = - 10 ** 18
r = 10 ** 18
while l + 1 < r:
    m = (l + r) // 2
    if cnt(m) < k:
        l = m
    else:
        r = m
print(r)

import numpy as np
n,k = map(int,input().split())
a = np.array(list(map(int,input().split())))
a.sort()
posi = a[a>0]
zero = a[a==0]
nega = a[a<0]

def cnt(x):
    c = 0
    if x >= 0:
        c += len(zero)*n
    c += np.searchsorted(a, x // posi, side = 'right').sum()
    c += (n-np.searchsorted(a, (- x - 1) // (-nega), side = 'right')).sum()
    c -= np.count_nonzero(a * a <= x)
    return c // 2

l = - 10 ** 18
r = 10 ** 18
while l + 1 < r:
    m = (l + r) // 2
    if cnt(m) < k:
        l = m
    else:
        r = m
print(r)

Verdicts: Wrong Answer

Accepted
Problem: We have N integers A_1, A_2, ..., A_N.  There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list?

Submission attempts (in order):
print(0)

import numpy as np

N, K = map(int, input().split())
A = np.array(tuple(map(int, input().split())), dtype=np.int64)

A = np.sort(A)
pos = A[A > 0]
neg = A[A < 0]
zero = len(A[A == 0])

def cnt(x):
    """return #{a <= x | a in A}"""
    ret = 0

    if x >= 0:
        ret += zero * N

    ret += np.searchsorted(A, x // pos, side='right').sum()
    ret += (N - np.searchsorted(A, (-x - 1) // (-neg), side='right')).sum()
    ret -= ((A * A) <= x).sum()
    return ret // 2

overEq = 10**18 + 100
less = -10**18 - 100

while less + 1 < overEq:
    mid = (overEq + less) // 2
    if cnt(mid) >= K:
        overEq = mid
    else:
        less = mid

print(overEq)


Verdicts: Wrong Answer

Accepted
Problem: We have N integers A_1, A_2, ..., A_N.  There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list?

Submission attempts (in order):
import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline



def cnt(x,A,An,Ap,N,Nz):
    res = 0
    if x >= 0:
        res += N * Nz
    res += np.searchsorted(A,x//Ap,side='right').sum()
    res += N * len(An) - np.searchsorted(A,-(-x//An),side='left').sum()
    res -= np.count_nonzero(A*A<=x)
    return res//2


def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))

    print(len(A))

    A = np.array(A)
    A.sort()

    An = A[A<0]
    Az = A[A==0]
    Ap = A[A>0]

    Nz = np.count_nonzero(A==0)

    INF = 10 ** 18

    l = - INF - 1
    r = INF

    while r-l > 1:
        m = (l+r)//2
        if cnt(m,A,An,Ap,N,Nz) >= K:
            r = m
        else:
            l = m

    print(r)





main()


import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline



def cnt(x,A,An,Ap,N,Nz):
    res = 0
    if x >= 0:
        res += N * Nz
    res += np.searchsorted(A,x//Ap,side='right').sum()
    res += N * len(An) - np.searchsorted(A,-(-x//An),side='left').sum()
    res -= np.count_nonzero(A*A<=x)
    return res//2


def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))

    A = np.array(A)
    A.sort()

    An = A[A<0]
    Az = A[A==0]
    Ap = A[A>0]

    Nz = np.count_nonzero(A==0)

    INF = 10 ** 18

    l = - INF - 1
    r = INF

    while r-l > 1:
        m = (l+r)//2
        if cnt(m,A,An,Ap,N,Nz) >= K:
            r = m
        else:
            l = m

    print(r)





main()


Verdicts: Wrong Answer

Accepted
Problem: We have N integers A_1, A_2, ..., A_N.  There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list?

Submission attempts (in order):
import numpy as np
stdin = open(0)

N,K = map(int,input().split())
A = np.array(stdin.read().split(), np.int64)
A = np.sort(A)

maxA = max(np.abs(A))


z = A[A==0]
p = A[A>0]
n = A[A<0]


def check(x):
    ret = 0
    if x >= 0:
        ret += N*len(z)
    ret += np.searchsorted(A,x//p,side='right').sum()
    ret += (N-np.searchsorted(A,x/n)).sum()
    ret -= len([a for a in A if a*a <= x])
    return ret//2;
        

ub = maxA*maxA
lb = -ub-1
while ub-lb > 1:
    mid = (ub+lb)>>1
    if check(mid) < K:
        lb = mid
    else:
        ub = mid
print(ub)

import numpy as np
import math
stdin = open(0)

N,K = map(int,input().split())
A = np.array([int(Ai) for Ai in input().split()])
A = np.sort(A)

maxA = max(np.abs(A))

z = A[A==0]
p = A[A>0]
n = A[A<0]

def check(x):
    ret = 0
    if x >= 0:
        ret += N*len(z)
    ret += np.searchsorted(A,x//p,side='right').sum()
    ret += (N - np.searchsorted(A, -(x // -n))).sum()

    ret -= np.count_nonzero(A*A<=x)
    return ret//2;

ub = maxA*maxA
lb = -ub-1
while ub-lb > 1:
    mid = (ub+lb)>>1
    if check(mid) < K:
        lb = mid
    else:
        ub = mid
print(ub)

Verdicts: Runtime Error

Accepted