Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left, bisect_right

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

negative_end = bisect_left(a, 0)
positive_begin = bisect_right(a, 0)

negative_cnt = negative_end
positive_cnt = n - positive_begin
zero_cnt = n - negative_cnt - positive_cnt

prod_negative = negative_cnt * positive_cnt
# prod_positive = negative_cnt * (negative_cnt - 1) // 2 + positive_cnt * (positive_cnt - 1) // 2
prod_zero = zero_cnt * (negative_cnt + positive_cnt) + zero_cnt * (zero_cnt - 1) // 2
# print(prod_negative, prod_zero, prod_positive)

if k <= prod_negative:
    high, low = 0, -10**18
    while high > low + 1:
        mid = (high + low) // 2
        or_higher = 0
        r = positive_begin
        for l in range(negative_end):
            while r < n and a[l] * a[r] > mid:
                r += 1
            or_higher += positive_cnt - (r - positive_begin)

        if or_higher >= k:
            high = mid
        else:
            low = mid

    res = high

elif k <= prod_negative + prod_zero:
    res = 0

else:
    k -= prod_negative + prod_zero
    high, low = 10**18, 0
    while high > low + 1:
        mid = (high + low) // 2
        or_higher = 0
        r = n - 1
        for l in range(positive_begin, n):
            while r < n and a[l] * a[r] > mid and l < r:
                r -= 1
            or_higher += r - l if l < r else 0
        l = 0
        for r in range(negative_end - 1, -1, -1):
            while l < n and a[l] * a[r] > mid and l < r:
                l += 1
            or_higher += r - l if l < r else 0

        if or_higher >= k:
            high = mid
        else:
            low = mid

    res = high

print(res)


Fixed submission:
from bisect import bisect_left, bisect_right

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

negative_end = bisect_left(a, 0)
positive_begin = bisect_right(a, 0)

negative_cnt = negative_end
positive_cnt = n - positive_begin
zero_cnt = n - negative_cnt - positive_cnt

prod_negative = negative_cnt * positive_cnt
# prod_positive = negative_cnt * (negative_cnt - 1) // 2 + positive_cnt * (positive_cnt - 1) // 2
prod_zero = zero_cnt * (negative_cnt + positive_cnt) + zero_cnt * (zero_cnt - 1) // 2
# print(prod_negative, prod_zero, prod_positive)

if k <= prod_negative:
    high, low = 0, -10**18
    while high > low + 1:
        mid = (high + low) // 2
        or_higher = 0
        r = positive_begin
        for l in range(negative_end):
            while r < n and a[l] * a[r] > mid:
                r += 1
            or_higher += positive_cnt - (r - positive_begin)

        if or_higher >= k:
            high = mid
        else:
            low = mid

    res = high

elif k <= prod_negative + prod_zero:
    res = 0

else:
    k -= prod_negative + prod_zero
    high, low = 10**18, 0
    while high > low + 1:
        mid = (high + low) // 2
        or_higher = 0
        r = n - 1
        for l in range(positive_begin, n):
            while r < n and a[l] * a[r] > mid and l < r:
                r -= 1
            or_higher += r - l if l < r else 0
        l = 0
        for r in range(negative_end - 1, -1, -1):
            while l < n and a[l] * a[r] > mid and l < r:
                l += 1
            or_higher += r - l if l < r else 0

        if or_higher >= k:
            high = mid
        else:
            low = mid

    res = high

print(res)

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

n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

p = []
for x, y in list(combinations(a, 2)):
    p.append(x*y)

p.sort()
print(p[k-1])


Fixed submission:
from bisect import bisect_left, bisect_right

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

negative_end = bisect_left(a, 0)
positive_begin = bisect_right(a, 0)

negative_cnt = negative_end
positive_cnt = n - positive_begin
zero_cnt = n - negative_cnt - positive_cnt

prod_negative = negative_cnt * positive_cnt
# prod_positive = negative_cnt * (negative_cnt - 1) // 2 + positive_cnt * (positive_cnt - 1) // 2
prod_zero = zero_cnt * (negative_cnt + positive_cnt) + zero_cnt * (zero_cnt - 1) // 2
# print(prod_negative, prod_zero, prod_positive)

if k <= prod_negative:
    high, low = 0, -10**18
    while high > low + 1:
        mid = (high + low) // 2
        or_higher = 0
        r = positive_begin
        for l in range(negative_end):
            while r < n and a[l] * a[r] > mid:
                r += 1
            or_higher += positive_cnt - (r - positive_begin)

        if or_higher >= k:
            high = mid
        else:
            low = mid

    res = high

elif k <= prod_negative + prod_zero:
    res = 0

else:
    k -= prod_negative + prod_zero
    high, low = 10**18, 0
    while high > low + 1:
        mid = (high + low) // 2
        or_higher = 0
        r = n - 1
        for l in range(positive_begin, n):
            while r < n and a[l] * a[r] > mid and l < r:
                r -= 1
            or_higher += r - l if l < r else 0
        l = 0
        for r in range(negative_end - 1, -1, -1):
            while l < n and a[l] * a[r] > mid and l < r:
                l += 1
            or_higher += r - l if l < r else 0

        if or_higher >= k:
            high = mid
        else:
            low = mid

    res = high

print(res)