Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    from bisect import bisect_left
    input = sys.stdin.readline

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

    minus = []
    plus = []
    zero = 0
    for a in A:
        if a > 0:
            plus.append(a)
        elif a < 0:
            minus.append(-a)
        else:
            zero += 1
    plus.sort()
    minus.sort()
    ok = -10 ** 18 - 1
    ng = 10 ** 18 + 1
    mid = 0
    while ng - ok > 1:
        cnt = 0
        if mid == 0:
            if len(plus) * len(minus) < K:
                ok = mid
            else:
                ng = mid
        elif mid > 0:
            for a in A:
                #if mid == 27:
                #    print(a, cnt)
                if a < 0:
                    j = bisect_left(minus, (mid-1) // (-a) + 1)
                    cnt += N - len(minus) + j
                    if a * a < mid:
                        cnt -= 1
                elif a == 0:
                    cnt += N - 1
                else:
                    j = bisect_left(plus, (mid-1) // a + 1)
                    cnt += N - len(plus) + j
                    #if mid == 27:
                    #    print(j, mid // a)
                    if a * a < mid:
                        cnt -= 1
            #print(cnt, mid)
            assert cnt%2 == 0
            cnt //= 2
            if cnt < K:
                ok = mid
            else:
                ng = mid
        else:
            for a in A:
                if a < 0:
                    j = bisect_left(plus, (-mid) // (-a) + 1)
                    cnt += len(plus) - j
                elif a > 0:
                    j = bisect_left(minus, (-mid) // a + 1)
                    cnt += len(minus) - j
            assert cnt %2 == 0
            cnt //= 2
            if cnt < K:
                ok = mid
            else:
                ng = mid
        mid = (ok+ng)//2

    print(ok)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    import sys
    from bisect import bisect_left
    input = sys.stdin.readline

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

    minus = []
    plus = []
    zero = 0
    for a in A:
        if a > 0:
            plus.append(a)
        elif a < 0:
            minus.append(-a)
        else:
            zero += 1
    plus.sort()
    minus.sort()
    plus_num = len(plus)
    minus_num = len(minus)
    if plus_num * minus_num < K <= (N*(N-1))//2 - (plus_num*(plus_num-1))//2 - (minus_num*(minus_num-1))//2:
        print(0)
        exit()
    if plus_num * minus_num >= K:
        ng = 0
        ok = -10**18-1
        mid = (ng+ok)//2
        while ng - ok > 1:
            cnt = 0
            j = 0
            for a in reversed(minus):
                while True:
                    if j == plus_num:
                        break
                    if a * plus[j] < -mid:
                        j += 1
                    else:
                        break
                #print(mid, a, j)
                cnt += plus_num - j
            #print(mid, cnt)
            if cnt < K:
                ok = mid
            else:
                ng = mid
            mid = (ok+ng)//2
        print(ng)
    else:
        K -= (N*(N-1))//2 - (plus_num*(plus_num-1))//2 - (minus_num*(minus_num-1))//2
        ng = 10**18+1
        ok = 0
        mid = (ok+ng)//2
        while ng - ok > 1:
            cnt = 0
            j = plus_num-1
            for a in plus:
                while True:
                    if j == -1:
                        break
                    if a * plus[j] > mid:
                        j -= 1
                    else:
                        break
                cnt += j+1
            for a in plus:
                if a**2 <= mid:
                    cnt -= 1
                else:
                    break
            j = minus_num-1
            for a in minus:
                while True:
                    if j == -1:
                        break
                    if a * minus[j] > mid:
                        j -= 1
                    else:
                        break
                cnt += j+1
            for a in minus:
                if a**2 <= mid:
                    cnt -= 1
                else:
                    break
            #print(cnt)
            assert cnt%2 == 0
            cnt //= 2
            if cnt < K:
                ok = mid
            else:
                ng = mid
            mid = (ok+ng)//2
        print(ng)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    from bisect import bisect_left
    input = sys.stdin.readline

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

    minus = []
    plus = []
    zero = 0
    for a in A:
        if a > 0:
            plus.append(a)
        elif a < 0:
            minus.append(-a)
        else:
            zero += 1
    plus.sort()
    minus.sort()
    ok = -10 ** 18 - 1
    ng = 10 ** 18 + 1
    mid = 0
    while ng - ok > 1:
        cnt = 0
        if mid == 0:
            if len(plus) * len(minus) < K:
                ok = mid
            else:
                ng = mid
        elif mid > 0:
            for a in A:
                #if mid == 27:
                #    print(a, cnt)
                if a < 0:
                    j = bisect_left(minus, (mid-1) // (-a) + 1)
                    cnt += N - len(minus) + j
                    if a * a < mid:
                        cnt -= 1
                elif a == 0:
                    cnt += N - 1
                else:
                    j = bisect_left(plus, (mid-1) // a + 1)
                    cnt += N - len(plus) + j
                    #if mid == 27:
                    #    print(j, mid // a)
                    if a * a < mid:
                        cnt -= 1
            #print(cnt, mid)
            assert cnt%2 == 0
            cnt //= 2
            if cnt < K:
                ok = mid
            else:
                ng = mid
        else:
            for a in A:
                if a < 0:
                    j = bisect_left(plus, (-mid) // (-a) + 1)
                    cnt += len(plus) - j
                elif a > 0:
                    j = bisect_left(minus, (-mid) // a + 1)
                    cnt += len(minus) - j
            assert cnt %2 == 0
            cnt //= 2
            if cnt < K:
                ok = mid
            else:
                ng = mid
        mid = (ok+ng)//2

    print(ok)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    import sys
    from bisect import bisect_left
    input = sys.stdin.readline

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

    minus = []
    plus = []
    zero = 0
    for a in A:
        if a > 0:
            plus.append(a)
        elif a < 0:
            minus.append(-a)
        else:
            zero += 1
    plus.sort()
    minus.sort()
    plus_num = len(plus)
    minus_num = len(minus)
    if plus_num * minus_num < K <= (N*(N-1))//2 - (plus_num*(plus_num-1))//2 - (minus_num*(minus_num-1))//2:
        print(0)
        exit()
    if plus_num * minus_num >= K:
        ng = 0
        ok = -10**18-1
        mid = (ng+ok)//2
        while ng - ok > 1:
            cnt = 0
            j = 0
            for a in reversed(minus):
                while True:
                    if j == plus_num:
                        break
                    if a * plus[j] < -mid:
                        j += 1
                    else:
                        break
                #print(mid, a, j)
                cnt += plus_num - j
            #print(mid, cnt)
            if cnt < K:
                ok = mid
            else:
                ng = mid
            mid = (ok+ng)//2
        print(ng)
    else:
        K -= (N*(N-1))//2 - (plus_num*(plus_num-1))//2 - (minus_num*(minus_num-1))//2
        ng = 10**18+1
        ok = 0
        mid = (ok+ng)//2
        while ng - ok > 1:
            cnt = 0
            j = plus_num-1
            for a in plus:
                while True:
                    if j == -1:
                        break
                    if a * plus[j] > mid:
                        j -= 1
                    else:
                        break
                cnt += j+1
            for a in plus:
                if a**2 <= mid:
                    cnt -= 1
                else:
                    break
            j = minus_num-1
            for a in minus:
                while True:
                    if j == -1:
                        break
                    if a * minus[j] > mid:
                        j -= 1
                    else:
                        break
                cnt += j+1
            for a in minus:
                if a**2 <= mid:
                    cnt -= 1
                else:
                    break
            #print(cnt)
            assert cnt%2 == 0
            cnt //= 2
            if cnt < K:
                ok = mid
            else:
                ng = mid
            mid = (ok+ng)//2
        print(ng)


if __name__ == '__main__':
    main()