Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
alist = list(map(int, input().split()))
alist.sort()

inf = int(1e+18) + 1
l = -inf
r = inf

while l + 1 < r:
    x = (l + r) // 2
    total = 0
    for i in range(n):
        if alist[i] < 0:
            ll = -1
            rr = n
            while ll + 1 < rr:
                xx = (ll + rr) // 2
                if alist[i] * alist[xx] < x:
                    rr = xx
                else:
                    ll = xx
            total += n - rr
        else:
            ll = -1
            rr = n
            while ll + 1 < rr:
                xx = (ll + rr) // 2
                if alist[i] * alist[xx] < x:
                    ll = xx
                else:
                    rr = xx
            total += rr
        if alist[i] * alist[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 = np.sort(a)
zero = a[a == 0]
pos = a[a > 0]
neg = a[a < 0]

def f(x):
    """count the number of products , <= x"""
    cnt_tpl = 0
    # zero and ...
    if x >= 0:
        cnt_tpl += len(zero) * n
    # positive and ...
    cnt_tpl += np.searchsorted(a, x // pos, side='right').sum()
    # negative and ...
    cnt_tpl += (n - np.searchsorted(a, (-x - 1) // (-neg), side='right')).sum()
    # a^2
    cnt_tpl -= np.count_nonzero(a * a <= x)
    assert cnt_tpl % 2 == 0
    return cnt_tpl // 2

left = -10 ** 18
right = 10 ** 18
while left + 1 < right:
    x = (left + right) // 2
    if f(x) >= k:
        right = x
    else:
        left = x

print(right)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
alist = list(map(int, input().split()))

ans_list = []
for i in range(n - 1):
    for j in range(i + 1, n, 1):
        ans_list.append(alist[i] * alist[j])
ans_list.sort()
print(ans_list[k - 1])

Fixed submission:
import numpy as np

n, k = map(int, input().split())
a = np.array(input().split(), np.int64)

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

def f(x):
    """count the number of products , <= x"""
    cnt_tpl = 0
    # zero and ...
    if x >= 0:
        cnt_tpl += len(zero) * n
    # positive and ...
    cnt_tpl += np.searchsorted(a, x // pos, side='right').sum()
    # negative and ...
    cnt_tpl += (n - np.searchsorted(a, (-x - 1) // (-neg), side='right')).sum()
    # a^2
    cnt_tpl -= np.count_nonzero(a * a <= x)
    assert cnt_tpl % 2 == 0
    return cnt_tpl // 2

left = -10 ** 18
right = 10 ** 18
while left + 1 < right:
    x = (left + right) // 2
    if f(x) >= k:
        right = x
    else:
        left = x

print(right)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
alist = list(map(int, input().split()))

ans_list = []
for i in range(n - 1):
    for j in range(i + 1, n, 1):
        ans_list.append(alist[i] * alist[j])
ans_list.sort()
print(ans_list[k - 1])

Fixed submission:
import numpy as np

n, k = map(int, input().split())
a = np.array(input().split(), np.int64)

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

def f(x):
    """count the number of products , <= x"""
    cnt_tpl = 0
    # zero and ...
    if x >= 0:
        cnt_tpl += len(zero) * n
    # positive and ...
    cnt_tpl += np.searchsorted(a, x // pos, side='right').sum()
    # negative and ...
    cnt_tpl += (n - np.searchsorted(a, (-x - 1) // (-neg), side='right')).sum()
    # a^2
    cnt_tpl -= np.count_nonzero(a * a <= x)
    assert cnt_tpl % 2 == 0
    return cnt_tpl // 2

left = -10 ** 18
right = 10 ** 18
while left + 1 < right:
    x = (left + right) // 2
    if f(x) >= k:
        right = x
    else:
        left = x

print(right)