Buggy python submission (verdict: Runtime Error):
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_start = bisect_right(A, 0)

positive_cnt = N - positive_start
negative_cnt = negative_end
zero_cnt = N - (positive_cnt + negative_cnt)

negative_pairs_cnt = positive_cnt * negative_cnt
zero_pairs_cnt = zero_cnt * (positive_cnt + negative_cnt) + (zero_cnt * (zero_cnt - 1) // 2)

if K <= negative_pairs_cnt:
    # にぶたん: X以下になるペアがK個以上あるか？
    ok, ng = 0, -10 ** 18
    while abs(ok - ng) > 1:
        X = (ok + ng) // 2
        or_higher_cnt, r = 0, positive_cnt
        for l in range(negative_end):
            while (r < N) and (A[l] * A[r] > X):
                r += 1
            or_higher_cnt += positive_cnt - (r - positive_start)
        if or_higher_cnt >= K:
            ok = X
        else:
            ng = X

    print(ok)

elif K <= negative_pairs_cnt + zero_pairs_cnt:
    print(0)

else:
    print(1 / 0)
    # # にぶたん: X以下になるペアがK個以上あるか？
    # K -= (negative_pairs_cnt + zero_pairs_cnt)
    # ok, ng = 10 ** 18, 0
    # while abs(ok - ng) > 1:
    #     X = (ok + ng) // 2
    #     or_higher_cnt = 0
    #     continue_flg = False
    # print(ok)


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_start = bisect_right(A, 0)

positive_cnt = N - positive_start
negative_cnt = negative_end
zero_cnt = N - (positive_cnt + negative_cnt)

negative_pairs_cnt = positive_cnt * negative_cnt
zero_pairs_cnt = zero_cnt * (positive_cnt + negative_cnt) + (zero_cnt * (zero_cnt - 1) // 2)

if K <= negative_pairs_cnt:
    # にぶたん: X以下になるペアがK個以上あるか？
    ok, ng = 0, -10 ** 18
    while abs(ok - ng) > 1:
        X = (ok + ng) // 2
        or_higher_cnt, r = 0, positive_start
        for l in range(negative_end):
            while (r < N) and (A[l] * A[r] > X):
                r += 1
            or_higher_cnt += positive_cnt - (r - positive_start)

        if or_higher_cnt >= K:
            ok = X
        else:
            ng = X

    print(ok)

elif K <= negative_pairs_cnt + zero_pairs_cnt:
    print(0)

else:
    # にぶたん: X以下になるペアがK個以上あるか？
    K -= (negative_pairs_cnt + zero_pairs_cnt)
    ok, ng = 10 ** 18, 0
    while abs(ok - ng) > 1:
        X = (ok + ng) // 2
        or_higher_cnt = 0

        r = N - 1
        for l in range(positive_start, N):
            while (r < N) and (A[l] * A[r] > X) and (l < r):
                r -= 1
            or_higher_cnt += max(0, r - l)

        l = 0
        for r in range(negative_end - 1, -1, -1):
            while (l < N) and (A[l] * A[r] > X) and (l < r):
                l += 1

            or_higher_cnt += max(0, r - l)

        if or_higher_cnt >= K:
            ok = X
        else:
            ng = X

    print(ok)

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    from math import ceil
    from bisect import bisect_left, bisect_right
    N, K = map(int, sys.stdin.readline().split())
    A = sorted(list(map(int, sys.stdin.readline().split())))

    positives = [a for a in A if a > 0]
    negatives = [a for a in A if a < 0]
    positive_cnt = len(positives)
    negative_cnt = len(negatives)
    zero_cnt = N - (positive_cnt + negative_cnt)

    negative_pairs_cnt = positive_cnt * negative_cnt
    zero_pairs_cnt = zero_cnt * (positive_cnt + negative_cnt) + (zero_cnt * (zero_cnt - 1) // 2)

    # 考えにくいので、負の値も正になおしてソートしておく
    negatives = sorted([-a for a in negatives])

    if K <= negative_pairs_cnt:
        # にぶたん: X以上になるペアがK個以上あるか？
        ok, ng = 0, 10 ** 18 + 1
        while abs(ok - ng) > 1:
            X = float((ok + ng) // 2)
            or_higher_cnt = 0
            for a in negatives:
                or_higher_cnt += (positive_cnt - bisect_left(positives, ceil(X / a)))
                if or_higher_cnt >= K:
                    ok = X
                    break
            else:
                ng = X

        print(int(-ok))

    elif K <= negative_pairs_cnt + zero_pairs_cnt:
        print(0)

    else:
        # にぶたん: X以下になるペアがK個以上あるか？
        K -= (negative_pairs_cnt + zero_pairs_cnt)
        ok, ng = 10 ** 18, 0
        while abs(ok - ng) > 1:
            X = (ok + ng) // 2
            or_higher_cnt = 0

            for i, a in enumerate(positives):
                j = bisect_right(positives, X // a)
                if i > j:
                    or_higher_cnt += j
                else:
                    or_higher_cnt += i

            if or_higher_cnt >= K:
                ok = X
                continue

            for i, a in enumerate(negatives):
                j = bisect_right(negatives, X // a)
                if i > j:
                    or_higher_cnt += j
                else:
                    or_higher_cnt += i

            if or_higher_cnt >= K:
                ok = X
                continue

            ng = X

        print(ok)


if __name__ == '__main__':
    main()

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_start = bisect_right(A, 0)

positive_cnt = N - positive_start
negative_cnt = negative_end
zero_cnt = N - (positive_cnt + negative_cnt)

negative_pairs_cnt = positive_cnt * negative_cnt
zero_pairs_cnt = zero_cnt * (positive_cnt + negative_cnt) + (zero_cnt * (zero_cnt - 1) // 2)

if K <= negative_pairs_cnt:
    # にぶたん: X以下になるペアがK個以上あるか？
    ok, ng = 0, -10 ** 18
    while abs(ok - ng) > 1:
        X = (ok + ng) // 2
        or_higher_cnt, r = 0, positive_start
        for l in range(negative_end):
            while (r < N) and (A[l] * A[r] > X):
                r += 1
            or_higher_cnt += positive_cnt - (r - positive_start)

        if or_higher_cnt >= K:
            ok = X
        else:
            ng = X

    print(ok)

elif K <= negative_pairs_cnt + zero_pairs_cnt:
    print(0)

else:
    # にぶたん: X以下になるペアがK個以上あるか？
    K -= (negative_pairs_cnt + zero_pairs_cnt)
    ok, ng = 10 ** 18, 0
    while abs(ok - ng) > 1:
        X = (ok + ng) // 2
        or_higher_cnt = 0

        r = N - 1
        for l in range(positive_start, N):
            while (r < N) and (A[l] * A[r] > X) and (l < r):
                r -= 1
            or_higher_cnt += max(0, r - l)

        l = 0
        for r in range(negative_end - 1, -1, -1):
            while (l < N) and (A[l] * A[r] > X) and (l < r):
                l += 1

            or_higher_cnt += max(0, r - l)

        if or_higher_cnt >= K:
            ok = X
        else:
            ng = X

    print(ok)