Buggy python submission (verdict: Runtime Error):
import sys

N, K = map(int, input().split())
a = sorted(list(map(int, input().split())))
l = -(((1e18)+1)
r=(1e18)+1
while(l + 1 < r):
    x=(l + r) / 2
    total=0
    for i in range(N):
        if a[i] < 0:
            l=-1
            r=N
            while(l + 1 < r):
                c=(l + r) / 2
                if a[c] * a[i] < x:
                    r=c
                else:
                    l=c
            total += n - r
        else:
            l=-1
            r=N
            while(l + 1 < r):
                c=(l + r) / 2
                if a[c] * a[i] < x:
                    l=c
                else:
                    r=c
            total += r
        if a[i] * a[i] < x:
            total -= 1
    total /= 2
    if total < K:
        l=x
    else:
        r=x
print(l)


Fixed submission:
import numpy as np

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

A = np.array(input().split(), np.int64)

A.sort()

posA = A[A > 0]
negA = A[A < 0]
zeros = (A==0).sum()

left = -10**18
right = 10**18

while left+1 < right:
    num = (left+right)//2
    
    less_count = 0
    
    if num >= 0:
        less_count += zeros * n
    
    limit_pair_for_pos = num // posA
    limit_idxs = np.searchsorted(A, limit_pair_for_pos, side='right')
    less_count += limit_idxs.sum()

    limit_pair_for_neg = -(num // -negA)
    limit_idxs = n - np.searchsorted(A, limit_pair_for_neg, side='left')
    less_count += limit_idxs.sum()

    duplicate_cases = (A**2 <= num).sum()
    less_count -= duplicate_cases
    less_count //= 2
    
    if less_count >= k:
        right = num
    else:
        left = num

print(right)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import itertools

N, K = map(int, input().split())
a = list(map(int, input().split()))
L = []
for i in itertools.combinations(a, 2):
  L.append(i[0] * i[1])
print(sorted(L)[K-1])


Fixed submission:
import numpy as np

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

A = np.array(input().split(), np.int64)

A.sort()

posA = A[A > 0]
negA = A[A < 0]
zeros = (A==0).sum()

left = -10**18
right = 10**18

while left+1 < right:
    num = (left+right)//2
    
    less_count = 0
    
    if num >= 0:
        less_count += zeros * n
    
    limit_pair_for_pos = num // posA
    limit_idxs = np.searchsorted(A, limit_pair_for_pos, side='right')
    less_count += limit_idxs.sum()

    limit_pair_for_neg = -(num // -negA)
    limit_idxs = n - np.searchsorted(A, limit_pair_for_neg, side='left')
    less_count += limit_idxs.sum()

    duplicate_cases = (A**2 <= num).sum()
    less_count -= duplicate_cases
    less_count //= 2
    
    if less_count >= k:
        right = num
    else:
        left = num

print(right)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import itertools

N, K = map(int, input().split())
a = list(map(int, input().split()))
a = list(itertools.combinations(a, 2))
L = []
for i in a:
  L.append(i[0] * i[1])
print(sorted(L)[K-1])


Fixed submission:
import numpy as np

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

A = np.array(input().split(), np.int64)

A.sort()

posA = A[A > 0]
negA = A[A < 0]
zeros = (A==0).sum()

left = -10**18
right = 10**18

while left+1 < right:
    num = (left+right)//2
    
    less_count = 0
    
    if num >= 0:
        less_count += zeros * n
    
    limit_pair_for_pos = num // posA
    limit_idxs = np.searchsorted(A, limit_pair_for_pos, side='right')
    less_count += limit_idxs.sum()

    limit_pair_for_neg = -(num // -negA)
    limit_idxs = n - np.searchsorted(A, limit_pair_for_neg, side='left')
    less_count += limit_idxs.sum()

    duplicate_cases = (A**2 <= num).sum()
    less_count -= duplicate_cases
    less_count //= 2
    
    if less_count >= k:
        right = num
    else:
        left = num

print(right)