Problem:


Score: 400 points

Problem Statement

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?

Constraints

All values in input are integers.

2 \leq N \leq 2 \times 10^5

1 \leq K \leq \frac{N(N-1)}{2}

-10^9 \leq A_i \leq 10^9\ (1 \leq i \leq N)

Input

Input is given from Standard Input in the following format:

N K
A_1 A_2 \dots A_N

Output

Print the answer.

Sample Input 1

4 3
3 3 -4 -2

Sample Output 1

-6

There are six ways to form a pair. The products of those pairs are 9, -12, -6, -12, -6, 8.

Sorting those numbers in ascending order, we have -12, -12, -6, -6, 8, 9. The third number in this list is -6.

Sample Input 2

10 40
5 4 3 2 -1 0 0 0 0 0

Sample Output 2

6

Sample Input 3

30 413
-170202098 -268409015 537203564 983211703 21608710 -443999067 -937727165 -97596546 -372334013 398994917 -972141167 798607104 -949068442 -959948616 37909651 0 886627544 -20098238 0 -948955241 0 -214720580 277222296 -18897162 834475626 0 -425610555 110117526 663621752 0

Sample Output 3

448283280358331064



Sample input:
4 3
3 3 -4 -2


Sample output:
-6

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
nums = list(map(int, input().split()))

pos = []
neg = []
zero = []

for n in nums:
    if n < 0:
        neg.append(n)
    elif n > 0:
        pos.append(n)
    else:
        zero.append(n)

neg.sort()
pos.sort()
len_neg = len(neg)
len_pos = len(pos)
len_zero = len(zero)
neg_pattern = len_neg * len_pos
pos_pattern = (len_pos * (len_pos - 1) // 2) * (len_neg * (len_neg - 1) // 2)
zero_pattern = (len_neg + len_pos) * len_zero

if K <= neg_pattern:
    res = []
    for minus in neg:
        for plus in pos:
            res.append(minus * plus)
    res.sort()
    print(res[K - 1])
elif K <= (neg_pattern + zero_pattern):
    print(0)
else:
    res = []
    for i in range(len_neg - 1):
        for j in range(i + 1, len_neg):
            res.append(neg[i] * neg[j])
    
    for i in range(len_pos - 1):
        for j in range(i + 1, len_pos):
            res.append(pos[i] * pos[j])
    res.sort()
    pattern = (N * (N - 1)) // 2
    index = -1 * (pattern - K + 1)
    print(res[index])

Submission status: Runtime Error

Solution code:
import heapq

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

ans = []
mem = {}
for i in range(n):
    for j in range(n):
        if i > j:
            heapq.heappush(ans, mem.get(f"{i}_{j}", A[i] * A[j]))

for _ in range(k):
    a = heapq.heappop(ans)
print(a)

Submission status: Runtime Error

Solution code:
import itertools

N, K = [int(n) for n in input().rstrip().split(' ')]

A = [int(n) for n in input().rstrip().split(' ')]

comb_A = list(itertools.combinations(A, 2))
comb_A.sort()
ans = comb_A[K][0] * comb_A[K][1]
print(ans)

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
List = list(map(int, input().split()))

flag = True
res = []
List = sorted(List)
minus = 0
plus = 0

for i in range(a):
    if List[i] < 0:
        minus += 1
    else:
        plus += 1
        
if minus * plus > b:
    for i in range(minus):
        for j in range(minus, a):
            res.append(List[i] * List[j])
else:
    flag = False
    for i in range(minus, a):
        for j in range(i+1, a):
            res.append(List[i] * List[j])

res = sorted(res)
if flag:
    print(res[b-1])
else:
    print(res[(b-1)-((minus*plus)-1)-1])
#print(res)

Submission status: Runtime Error

Solution code:
import heapq

N, K = map(int, input().split())
pos_nums = []
neg_nums = []
zeros = []
A = list(map(int, input().split()))
for a in A:
    if a > 0:
        pos_nums.append(a)
    elif a < 0:
        neg_nums.append(a)
    else:
        zeros.append(a)

pos_nums.sort()
neg_nums.sort()

len_pos = len(pos_nums)
len_neg = len(neg_nums)
len_zero = len(zeros)

if (K - 1) // len_pos <= len_neg:
    print(neg_nums[(K - 1) // len_pos] * pos_nums[K - (K - 1) // len_pos * len_pos - 1])
elif len_pos * len_neg < K <= len_pos * len_neg + len_zero * (len_pos + len_neg) + len_zero * (len_zero - 1) // 2:
    print(0)
else:
    nums = []
    if len_pos >= 2:
        for i in range(len_pos - 1):
            for j in range(i + 1, len_pos):
                heapq.heappush(nums, pos_nums[i] * pos_nums[j])

    if len_neg >= 2:
        for i in range(len_neg - 1):
            for j in range(i + 1, len_neg):
                heapq.heappush(nums, neg_nums[i] * neg_nums[j])

    for i in range(K - len_pos * len_neg - len_zero * (len_pos + len_neg) - len_zero * (len_zero - 1) // 2):
        ans = heapq.heappop(nums)

    print(ans)

Submission status: Runtime Error

Solution code:
import itertools
import sys
N,K=map(int,input().split())
*A,= map(int, input().split())
ANS=[sys.maxsize]*K

A=sorted(A)
A=list(itertools.combinations(A,2))
for x,y in A:
  if x*y<ANS[K-1]:
    ANS[K-1]=x*y
    ANS=sorted(ANS)
print(ANS[K-1])

Submission status: Runtime Error

Solution code:
import numpy as np
import itertools

N, K = input().split(" ")
aList = np.array(input().split(" "), dtype=np.int).tolist()
tempList = sorted([a * b for a, b in itertools.combinations(aList, 2)])

print(tempList[int(K)])

Submission status: Runtime Error

Solution code:
import itertools

N, K = map(int, input().split())
A = list(map(int, input().split()))
B = [None]*(N*(N-1)//2)

counter = 0
for i in range(N-1):
    for j in range(i+1, N):
        B[counter] = A[i]*A[j]
        counter += 1

C = sorted(B)
print(C[K-1])

Submission status: Runtime Error

Solution code:
n,k = map(int,input().split())
a = list(map(int,input().split()))
inf = float("inf")
b = [inf]*(n*n)
c = 0

for i in range(n):
  for j in range(i+1,n):
    b[c] =a[i]*a[j]
    c += 1
d = sorted(b)
print(d[k])

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
listo = list(map(int, input().split()))
mlist, zlist, plist = [], [], []
for i in listo:
    if i < 0:
        mlist.append(i)
    elif i == 0:
        zlist.append(i)
    else:
        plist.append(i)
minus, zero, plus = len(mlist), len(zlist), len(plist)
pzero = (zero * (N - zero)) + (zero * (zero - 1)) // 2
pminus = minus * plus
pplus = ((N * (N - 1)) // 2) - (pzero + pminus)
if K < pminus:
    prod = []
    for i in mlist:
        for j in plist:
            prod.append(i * j)
    prod.sort()
    print(prod[K-1])
elif K < pzero:
    print(0)
else:
    prod = []
    for i in range(minus):
        for j in range(i+1, minus):
            prod.append(mlist[i] * mlist[j])
    for i in range(plus):
        for j in range(i+1, plus):
            prod.append(plist[i] * plist[j])
    prod.sort()
    print(prod[K-1-pminus-pzero])

Submission status: Runtime Error

Solution code:
nk = list(map(int, input().split()))
n = nk[0]
k = nk[1]

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

a_posi = []
a_nega = []
a_zero = []

for aa in a:
    if aa > 0:
        a_posi.append(aa)
    elif aa == 0:
        a_zero.append(aa)
    else:
        a_nega.append(aa)

num_a_posi = len(a_posi)
num_a_nega = len(a_nega)
num_a_zero = len(a_zero)

def combination(n):
    return n * (n-1) / 2

num_posi_result = combination(num_a_posi) + combination(num_a_nega)
num_nega_result = num_a_posi * num_a_nega
num_zero_result = combination(n) - num_posi_result - num_nega_result

nega_posi = 0

if k <= num_nega_result:
    nega_posi = -1
else:
    k -= num_nega_result
    if k <= num_zero_result:
        nega_posi = 0
    else:
        k -= num_zero_result
        nega_posi = 1

target_list = []
if nega_posi == -1:
    for ap in a_posi:
        for an in a_nega:
            target_list.append(ap*an)
elif nega_posi == 0:
    target_list.append(0)
else:
    for i in range(len(a_posi)):
        for j in range(i+1, len(a_posi)):
            target_list.append(a_posi[i] * a_posi[j])
    
    for i in range(len(a_nega)):
        for j in range(i+1, len(a_nega)):
            target_list.append(a_nega[i] * a_nega[j])  
    

target_list.sort()
print(target_list[int(k)-1])

Submission status: Runtime Error

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

sa = list(sorted(a))
kumi = n*(n-1)//2
r = []
for i, si in enumerate(sa[0:k-1]):
  for b in sa[i+1:len(a)]:
    r.append(si*b)
    if len(r) > k:
      break
sr = sorted(r)
print(sr[k-1])

Submission status: Runtime Error

Solution code:
import numpy as np
def numpy_combinations(arr):
  r, c = np.triu_indices(len(arr), 1)
  ar = arr[r].reshape(-1, 1)
  ac = arr[c].reshape(-1, 1)
  return np.hstack((ar, ac))

def solve(N, K, S):
    arr = np.array(S, dtype=np.int64)
    arr = numpy_combinations(arr)
    arr = np.prod(arr, axis=1)
    arr = np.sort(arr)
    print(arr[K-1])


def main():
    N, K = map(int, input().split())
    S = [int(x) for x in input().split()]
    solve(N, K, S)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline

def main():
    n,k=map(int,input().split())
    a=list(map(int,input().split()))
    ans=[0]*(int(n*(n-1)/2))
    cnt=0
    for i in range(n):
        for j in range(i,n):
            if i==j:
                continue
            else:
                ans[cnt]=a[i]*a[j]
            cnt+=1
    ans.sort()
    print(ans[k-1])
    
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
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])

Submission status: Runtime Error

Solution code:
import bisect
n,k = map(int,input().split( ))
a = list(map(int, input().split( )))

a.sort()

#2分探索
#負の数あるぞ

j = bisect.bisect_left(a,-0,1)
l = bisect.bisect_right(a,0.1)
a1 = a[:j]
a2 = a[l:]
if (j+1)*(n-l)>=k:##負の数で揃う
    mx = 0
    mn = -max(a1[0]*a1[0],a2[0]*a2[0])-1
    while mx-mn>1:
        md = (mx+mn)//2
        cnt = 0
        for t in range(j):
            tmp = bisect.bisect_left(a2,md/a1[t])
            cnt += n-l-tmp 
        if cnt >=k:
            mx = md
        else:
            mn = md
        print(mx)
    exit()
k -= j*(n-l)

if k<=(l-j)*(l-j-1)//2+(n-l+j)*(l-j):
    print(0)
    exit()
#print(k,(n-l+j)*(l-j)+(l-j)*(l-j-1)//2)
k-=(l-j)*(l-j-1)//2+(n-l+j)*(l-j)
#print(k,k)
mx = max(a1[0]*a1[0],a2[-1]*a2[-1])+1
mn = -1
a1 = [-a1[j-i-1] for i in range(j)]
while mx-mn>1:
    md = (mx+mn)//2
    cnt = 0
    for t in range(j):
        tmp = bisect.bisect_right(a1,md//a1[t])
        cnt += tmp
        if tmp >=t+1:
            cnt-=1
    for t in range(n-l):
        tmp = bisect.bisect_right(a2,md//a2[t])
        cnt += tmp
        if tmp>=t+1:
            cnt-=1
    if cnt >= 2*k:
        mx = md
    else:
        mn = md
print(mx)

Submission status: Runtime Error

Solution code:
import numpy as np
N, K = map(int, input().split())
aa = np.array(list(map(int, input().split())))

# p = [aa[i] * aa[j]  for i in range(N-1) for j in range(i+1, N)]
"""
for i in range(N-1):
  for j in range(i+1, N):
    p.append()
"""

p = aa[:, np.newaxis] * aa[np.newaxis].astype(float)
f = np.tril(np.ones((N, N)))
# print(f)
p[f == 0] = np.nan
q = p.flatten()

q.sort()
# print(q)
# print(p)
# p = list(set(p))
print(int(q[K-1]))

Submission status: Runtime Error

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n, k = map(int, input().split())
a_list = list(map(int, input().split()))
zero_count = 0
sei_a_list = []
hu_a_list = []
for a in a_list:
    if a == 0:
        zero_count += 1
    elif a > 0:
        sei_a_list.append(a)
    else:
        hu_a_list.append(a)

sei_list = []
hu_list = []
for i in range(0, len(sei_a_list)):
    for j in range(i + 1, len(sei_a_list)):
        sei_list.append(sei_a_list[i] * sei_a_list[j])
for i in range(0, len(hu_a_list)):
    for j in range(i + 1, len(hu_a_list)):
        sei_list.append(hu_a_list[i] * hu_a_list[j])
for i in range(0, len(sei_a_list)):
    for j in range(0, len(hu_a_list)):
        hu_list.append(sei_a_list[i] * hu_a_list[j])
sei_list = sorted(sei_list)
hu_list = sorted(hu_list)
zero_list = [0] * (n * zero_count - zero_count * (zero_count + 1) // 2)
all_list = hu_list + zero_list + sei_list
print(all_list[k - 1])

Submission status: Runtime Error

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

  B = [0] * ((N**2-N)//2)
  k=0
  for i in range(N):
    for j in range(N-i):
      if i==N-1-j:
        continue
      else:
        B[k]=A[i]*A[N-1-j]
        k+=1
  c= sorted(B)
  print(c[K-1])

main()

Submission status: Runtime Error

Solution code:
import sys
import numpy as np

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

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

a_np = np.zeros(int(n * (n-1) / 2), dtype="int64")

p = 0
for i in range(n-1):
    for j in range(i+1, n):
        a_np[p] = a[i] * a[j]
        p += 1
a_np.sort()
print(int(a_np[k-1]))

Submission status: Runtime Error

Solution code:
from itertools import combinations
n, k = map(int, input().split())
*A, = map(int, input().split())
print(sorted(x*y for x, y in combinations(A, 2))[k])

Submission status: Runtime Error

Solution code:
import itertools

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

l = list(itertools.combinations(A, 2))

r = []
for t in l:
    r.append(t[0] * t[1])

print(sorted(r)[K])

Submission status: Runtime Error

Solution code:
def pairs(n , k , a):

    kakelist = []
    for i in xrange(n - 1):
        for w in xrange(1 + i , n):
            kakelist.append(a[i] * a[w])

    kakelist.sort()

    return kakelist[k - 1]

def main():
    n , k = map(int , input().split())
    a = list(map(int,input().split()))
    print(pairs(n , k , a))

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
from itertools import combinations
N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = []
for i, j in combinations(A, 2):
  ans += [i*j]
print(sorted(ans)[K])

Submission status: Runtime Error

Solution code:
N, K = map(int,input().split())

A = list(map(int,input().split()))
B = []
for i in range(len(A)):
    for k in range(i + 1, len(A)):
        B.append(A[i]*A[k])
B.sort()
print(B)
print(B[K])

Submission status: Runtime Error

Solution code:
N = int(input())

strList = list([])

for i in range(N):
  strList.append(str(input()))

strDict = {}

for item in strList:
  if item not in strDict.keys():
    strDict[item] = 1
  else:
    strDict[item] += 1

maxList = list([])

for strKeys in strDict.keys():
  if strDict[strKeys] == max(strDict.values()):
    maxList.append(strKeys)

print(sorted(maxList))

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))

A = sorted(A)

under_zero = []
zero = []
over_zero = []

for i in range(N):
    if A[i] < 0:
        under_zero.append(A[i])
    elif A[i] == 0:
        zero.append(A[i])
    else:
        over_zero.append(A[i])
        
#print(under_zero)
#rint(zero)
#print(over_zero)

if K > len(under_zero) * len(over_zero) and K <= (len(under_zero) + len(over_zero)) * len(zero) + len(under_zero) * len(over_zero):
    print(0)
if K <= len(under_zero) * len(over_zero):
    over = K % len(over_zero) - 1
    under = K // len(over_zero)
    print(over_zero[over] * under_zero[under])
if K > (len(under_zero) + len(over_zero)) * len(zero) + len(under_zero) * len(over_zero):
    pass

Submission status: Runtime Error

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

    seki=[0]*int(N*(N-1)/2)

    cnt = 0
    for i in range(N-1):
        for j in range(i+1,N):
            seki[cnt]=A[i]*A[j]
            cnt += 1
    seki.sort()
    print(seki[K-1])

    return

if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

    seki=[0]*int(N*(N-1)/2)

    cnt = 0
    for i in range(N-1):
        for j in range(i+1,N):
            seki[cnt]=A[i]*A[j]
            cnt += 1
    seki.sort()
    print(len(seki),cnt)
    print(seki[K-1])

    return

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import numpy as np

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

Aarray = np.matrix([A])
mulA = np.array(Aarray.T * Aarray)

mul_list = []
for i, row in enumerate(mulA):
    mul_list += list(row[(i+1):])
    
ans = sorted(mul_list)[max(K-1, 0)]
print(ans)

Submission status: Runtime Error

Solution code:
import bisect
n, k = map(int, input().split())
A = sorted(list(map(int, input().split())))

hu = bisect.bisect_left(A, 0)
zero = bisect.bisect_right(A, 0) - hu
sei = n - hu - zero

if k < hu * sei:
  # k番目
  lst = sorted([
    A[i] * A[j] for i in range(0, hu) for j in range(sei, n)
  ])
  print(lst[k])
elif k < hu * sei + zero * (hu + sei) + zero * (zero-1) // 2:
  print(0)
else:
  lst = ([
    A[i] * A[j] for i in range(0, hu-1) for j in range(i+1, hu)
  ])
  lst += ([
    A[i] * A[j] for i in range(zero+hu, n-1) for j in range(i+1, n)
  ])
  k = k - 1 - (hu * sei + zero * (hu + sei) + zero * (zero-1) // 2)
  print(sorted(lst)[k])

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int n, k;
    cin >> n >> k;
    vector<int64_t> a(n), ans;
    for (auto& e : a) cin >> e;
    for (int i=0; i<n-1; i++) {
        for (int j=i+1; j<n; j++) {
            ans.push_back(a[i] * a[j]);
        }
    }
    sort(ans.begin(), ans.end());
    cout << ans[k-1] << endl;
}

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
array = list(map(int, input().split()))
positive = []; negative = []
zeros = 0
for a in array:
    if a > 0:
        positive.append(a)
    elif a < 0:
        negative.append(a)
    else:
        zeros += 1
if len(negative) * len(positive) >= K:
    res = sorted([positive[x] * negative[y] for x in range(len(positive)) for y in range(len(negative))])
    print(res[K])
elif len(negative) * len(positive) + (len(negative) + len(positive)) * zeros + zeros * (zeros-1) // 2 >= K: 
    print(0)
else:
    res = [positive[x] * positive[y] for x in range(len(positive)-1) for y in range(x+1, len(positive))] + [negative[x] * negative[y] for x in range(len(negative)-1) for y in range(x+1, len(negative))]
    res = sorted(res)
    print(res[K - 1 - (len(negative) * len(positive) + (len(negative) + len(positive)) * zeros +  + zeros * (zeros-1) // 2)])

Submission status: Runtime Error

Solution code:
import itertools

N, K = [int(num) for num in input().split(' ')]
As = [int(num) for num in input().split(' ')]

AA = sorted([a*b for a,b in itertools.combinations(As, r=2)])

print(AA[K])

Submission status: Runtime Error

Solution code:
NK = input().split()
N = int(NK[0])
K = int(NK[1])

AN = input().split()
AN = [int(a) for a in AN]

import numpy as np
AN = np.array(AN)
AN2 = [AN[i]*AN[i+1:] for i in range(N-1)]

AN2 = np.concatenate(AN2)
pro2 = np.sort(AN2, kind='quick_sort')
print(pro2[K-1])

Submission status: Runtime Error

Solution code:
import numpy as np 
a, *D, = [list(map(int, s.split())) for s in open(0)] 
D = D[0]
D_array = np.array(D)
D_matrix = np.dot(D_array.reshape([len(D_array), 1]),  D_array.reshape([1, len(D_array)]))
D_diag = np.diag(D_matrix) 
D_diag.flags.writeable = True
D_diag[:] = 1e18

print(np.sort(D_matrix.flatten())[(a[1] - 1)*2])

Submission status: Runtime Error

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

    seki=[0]*int(N/2*(N-1))

    cnt = 0
    for i in range(N-1):
        for j in range(i+1,N):
            seki[cnt]=A[i]*A[j]
            cnt += 1
    seki.sort()
    print(seki[K-1])

    return

if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

import numpy as np

A = np.array(a)
tmp = np.outer(A, A)
#l = [0] * int((n * (n-1)) / 2)
l = []
for i in range(n):
  for j in range(i+1, n):
    l.append(tmp[i, j])
l.sort()

print(l[k-1])

Submission status: Runtime Error

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

sa = list(sorted(a))

r = []
for i, si in enumerate(sa[0:k-1]):
  for b in sa[i+1:len(a)]:
    r.append(si*b)

sr = sorted(r)
print(sr[k-1])

Submission status: Runtime Error

Solution code:
from itertools import combinations
# 負 * 正(大きい順)
if K <= len(A_m) * len(A_p):
    idx_m = K // len(A_p)
    idx_p = -(K % len(A_m))
    ans = A_m[idx_m] * A_p[idx_p]
# 負 * 負
# 正 * 正
else:
    test = []
    for a in combinations(A_p,2):
        test.append(A[0]*A[1])
    for a in combinations(A_m,2):
        test.append(A[0]*A[1])
    test = sorted(test)
    ans = test[K - (len(A_m) * len(A_p))]
print(ans)

Submission status: Runtime Error

Solution code:
from itertools import combinations

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

L = list(combinations(A,2))
ans = []
for i in L:
  ans.append(i[0]*i[1])
  
ans.sort()

print(ans[K])

Submission status: Runtime Error

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

    seki=[0]*int(N*(N-1)*0.5)

    cnt = 0
    for i in range(N-1):
        for j in range(i+1,N):
            seki[cnt]=A[i]*A[j]
            cnt += 1
    seki.sort()
    print(seki[K-1])

    return

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
N, K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

results = []

for i in range(len(A)):
  for j in range(i + 1, len(A)):
    results.append(A[i] * A[j])

results.sort()

print(results[K])

Submission status: Runtime Error

Solution code:
N,K =map(int, input().split())
A=list(map(int, input().split()))

B = [0] * ((N**2-N)//2)
k=0
for i in range(N):
  for j in range(N-i):
    if i==N-1-j:
      continue
    else:
      B[k]=A[i]*A[N-1-j]
      k+=1
c= sorted(B)
print(c[K-1])

Submission status: Runtime Error

Solution code:
import itertools
n, k = map(int, input().split())
a = [int(x) for x in input().split()]
plus = list(filter(lambda x : x >= 0, a))
minus = list(filter(lambda x : x < 0, a))
plus_number = len(plus)
minus_number = len(minus)
if k <= plus_number * minus_number:
  l = [None] * (plus_number * minus_number)
  i = 0
  for m in minus:
    for p in plus:
      l[i] = m * p
      i += 1
  l.sort()
  print(l[k-1])
else:
  k -= (plus_number * minus_number)
  l = list(itertools.combinations(minus, 2)) + list(itertools.combinations(plus, 2))
  l = list(map(lambda x : x[0] * x[1], l))
  l.sort()
  print(l[k - 1])

Submission status: Runtime Error

Solution code:
n,order = map(int, input().split())
nums = [int(str) for str in input().split()]
maxn = int(n * (n-1) /2)
result = list(range(maxn))
bangou = 0

for x in range(n-1):
  for y in range(n):
    if y > x:
      result[bangou] = int( nums[x] * nums[y] )
      bangou += 1

result.sort()
print(result[order-1])

Submission status: Runtime Error

Solution code:
import numpy as np
n, k = map(int, input().split())
a = list(map(int, input().strip().split()))

x = np.zeros((int(n * (n-1) / 2)),dtype =np.int64)
y = np.zeros((int(n * (n-1) / 2)),dtype =np.int64)

s = 0
e = 0
for i in range(n-1):
    m = n - 1 - i
    e = s + m
    x[s:e] = np.full(m, a[i])
    y[s:e] = a[i+1:]
    s = e

#print(x)
#print(y)

z = x * y
#print(z)
w = np.sort(z)
print(w[k-1])

Submission status: Runtime Error

Solution code:
N,K =map(int, input().split())
A=list(map(int, input().split()))

B = [0] * ((N**2-N)//2)
k=0
for i in range(N):
  for j in range(N-i):
    if i==N-1-j:
      continue
    else:
      B[k]=A[i]*A[N-1-j]
      k+=1
c= sorted(B)
print(c[K-1])

Submission status: Runtime Error

Solution code:
import numpy as np

N, K = np.fromstring(input(), int, sep=" ")
As = np.fromstring(input(), int, sep=" ")

i, j = np.tril_indices(N, -1)
print(sorted(As[i] * As[j])[K-1])

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
ls = list(map(int, input().split()))

ans = [0] * int(n * (n - 1) / 2)
idx = 0

for i in range(1, n):
    for j in range(i):
        ans[idx] = ls[i] * ls[j]
        idx += 1 

ans.sort()

print(ans[k - 1])

Submission status: Runtime Error

Solution code:
import itertools

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

pair_list = []

for i in itertools.combinations(a, 2):
    pair_list.append(i[0] * i[1])

print(sorted(pair_list)[k])

Submission status: Runtime Error

Solution code:
list1=[]
list2=[]
n,m = input().split()
n = int(n)
m = int(m)
for i in range(0,n):
  a=int(input())
  list1.append(a)
for i in list1:
    for j in list1:
        list2.append(i*j)
print(list2[m])

Submission status: Runtime Error

Solution code:
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

import numpy as np
A = np.array(A)

R = []
for n in range(len(A)-1):
    R.append(A[n] * A[n+1:])
R = np.concatenate(R)
R.sort()
print(R[K-1])

Submission status: Runtime Error

Solution code:
# from itertools import *

class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """

    def __init__(self, n_max, mod=10 ** 9 + 7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n - r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n + 1):
            fac.append(fac[i - 1] * i % self.mod)
            facinv.append(facinv[i - 1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n + 1)
        modinv[1] = 1
        for i in range(2, n + 1):
            modinv[i] = self.mod - self.mod // i * modinv[self.mod % i] % self.mod
        return modinv

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

c = Combination(1000000)
# c = list(combinations(a, 2))
p = []

for i in range(len(c)):
    p.append(c[i][0] * c[i][1])

p.sort()

print(p[k-1])

Submission status: Runtime Error

Solution code:
import os
import statistics
import os
import statistics

def quickSort(arr):

    # 配列のメジアンより小さい要素を集めた配列
    left = []

    # 配列のメジアンより大きい要素を集めた配列
    right = []

    # 再帰の停止条件
    # 再帰的に配列を分割した後の、要素数が1以下になったら停止する
    if len(arr) <= 1:
        return arr

    # 配列の中央値(メジアン)を取得する
    median = int(statistics.median(arr))

    # 配列内に含まれる中央値の個数を数えるための変数
    medianFlg = 0

    for element in arr:
        # 配列の要素(element)が中央値より小さいので、
        # 配列leftに値を格納する
        if element < median:
            left.append(element)
        # 配列の要素(element)が中央値より大きいので、
        # 配列rightに値を格納する
        elif element > median:
            right.append(element)
        else:
        # elementが配列の中央値の場合は、
        # 返り値に加える中央値の個数分だけ、フラグに+1し続ける
            medianFlg += 1

    # 配列がどのように分割されているかを確かめたい場合は、
    # このタイミングでprintで確認すると良い
    # print(left)
    # print(right)

    # 配列left、配列right毎に再帰を行い
    # 配列を小さな配列に区切る
    left = quickSort(left)
    right = quickSort(right)

    # 配列left、中央値の[median]、配列rightを結合したものを返す
    return left + [median] * medianFlg + right
N,K=map(int,input().split())
a=map(int,input().split())
A=list(a)
b=[]
for i in range(N):
 for j in range(N):
  if i <= j:
   continue
  else:
   b.append(A[i]*A[j])
C=quickSort(b)
print(C[K-1])

Submission status: Runtime Error

Solution code:
N,K=map(int,input().split())

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

product = [0] * int(((N-1)/2)*(N))

k = 0
for i in range(N):
	for j in range(i + 1, N):
		product[k] = AL[i] * AL[j]
		k = k + 1

product.sort()

print(product[K - 1])

Submission status: Runtime Error

Solution code:

N, K=(int(i) for i in input().split())
a=[int(i) for i in input().split()]

import numpy as np

na = np.asarray([a])

nb = na*na.T
nb = np.tril(nb)
nb = nb - np.diag(np.diag(nb))
b = list(nb.reshape(-1,))
ans= sorted(b)
idx = ans.index(0)
idx
ans = ans[0:idx] + ans[idx+N*(N+1)//2:]

print(int(ans[K-1]))

Submission status: Runtime Error

Solution code:
def main():
    from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #n = int(stdin.readline()[:-1])   
    #r = stdin.readline()[:-1]
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]
    #n = int(r)
    #a = r.split()
    #a,b,c = r.split()
    #a = list(map(int, r.split()))
    #a,b,c,d = map(int, r.split())
    #a = list(map(int, r.split()))
    #a = [int(s[i]) for i in range(1, n+1)]
    #a = [list(map(int, r.split())) for i in range(1,n+1)]
    #a = [list(map(int, input().split())) for i in range(1,n+1)]
    #res = 0

    n,k=map(int,input().split())
    a = map(int, input().split())
    from itertools import combinations
    b=sorted([v[0]*v[1] for v in combinations(a,2)])
    
    print(b[k])

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
aa = list(map(int, input().split()))

p = []
for i in range(N-1):
  for j in range(i+1, N):
    p.append(aa[i] * aa[j])

p.sort()
print(p[K])

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
B = [None] * (N*(N-1)//2)

k = 0
for i in range(N-1):
    for j in range(i+1, N):
        B[k] = A[i] * A[j]
        k += 1

B.sort()

print(B[K-1])

Submission status: Runtime Error

Solution code:
import numpy as np
def numpy_combinations(arr):
  r, c = np.triu_indices(len(arr), 1)
  #return np.array(r*c)
  return np.stack((arr[r], arr[c]), 1)

def solve(N, K, S):
    arr = np.array(S, dtype=np.int64)
    arr = numpy_combinations(arr)
    arr = np.prod(arr, axis=1)
    arr = np.sort(arr)
    print(arr[K-1])


def main():
    N, K = map(int, input().split())
    S = [int(x) for x in input().split()]
    solve(N, K, S)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
def main():
    n,k=map(int,input().split())
    a=list(map(int,input().split()))
    lis=[0]*((n*(n-1))//2)
    c=0
    flag=True
    while flag==True:
        for i in range(n-1):
            for j in range(i+1,n):
                lis[c]=a[i]*a[j]
                c+=1
                if a[i]==a[-2] and a[j]==a[-1]:
                    flag=False
    lis=sorted(lis)
    print(lis[k-1])

if __name__=='__main__':
    main()

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
import itertools
a=list(map(int,input().split()))
a_pos = [i for i in a if i>0]
pos = len(a_pos)
a_zero = len([i for i in a if i==0])
a_neg = [i for i in a if i<0]
neg = len(a_neg)
if k<= neg*pos:
  li = [i*j for i in a_pos for j in a_neg]
  li.sort()
  print(li[k-1])
elif neg*pos < k <= (n*(n-1)//2) - (pos*pos + neg*neg):
  print(0)
else:
  pp = list(itertools.combinations(a_pos, 2))
  nn = list(itertools.combinations(a_neg, 2))
  li = [i[0]*i[1] for i in pp] + [i[0]*i[1] for i in nn]
  li.sort(reverse=True)
  # 後ろから数えて n*(n-1)//2 - k + 1 番目
  l = n*(n-1)//2 - k + 1
  #print(li,l)
  print(li[l-1])

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
A = list(map(int,input().split()))  

seki = [0] * int(N*(N-1)//2)
count = 0
for i in range(N):
  for j in range(i+1,N):
    seki[count] = A[i] * A[j]
    count += 1
seki.sort()
print(seki[K-1])