Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.buffer.readline
import bisect

def main():
    N,K = map(int,input().split())
    a = list(map(int,input().split()))
    a.sort()

    def check(x):
        count = 0
        if x > 0:
            for i in range(N):
                if a[i] < 0:
                    num = -(-x//a[i])
                    count += N-max(i+1,bisect.bisect_left(a,num))
                elif a[i] > 0:
                    num = x//a[i]
                    count += max(0,bisect.bisect_right(a,num)-i-1)
                else:
                    count += N-(i+1)
        elif x == 0:
            for i in range(N):
                if a[i] < 0:
                    num = 0
                    count += N-max(i+1,bisect.bisect_left(a,num))
                elif a[i] > 0:
                    continue
                else:
                    count += N-(i+1)
        else:
            for i in range(N):
                if a[i] < 0:
                    num = -(-x//a[i])
                    count += N-bisect.bisect_left(a,num)
                else:
                    continue
        return count
    
    left,right = -10**18-1,10**18+1
    while right-left > 1:
        mid = (left+right)//2
        if check(mid) >= K:
            right = mid
        else:
            left = mid
            
    print(right)
    
if __name__ == "__main__":
    main()


Fixed submission:
import sys
input = sys.stdin.buffer.readline
import numpy as np

def main():
    N,K = map(int,input().split())
    a = np.array(list(map(int,input().split())))
    a.sort()
    posi,zero,nega = a[a>0],a[a==0],a[a<0]
    lz = len(zero)
    
    def ch(x):
        count = 0
        if x >= 0:
            count += lz*N
        count += np.searchsorted(a,x//posi,side="right").sum()
        count += (N-np.searchsorted(a,-(-x//nega))).sum()
        count -= np.count_nonzero(a**2<=x)
        return count//2

    l,r = -10**18-1,10**18
    while r-l > 1:
        mid = (r+l)//2
        if ch(mid) >= K:
            r = mid
        else:
            l = mid

    print(r)
    
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.buffer.readline
import bisect

def main():
    N,K = map(int,input().split())
    a = list(map(int,input().split()))
    a.sort()

    def check(x):
        count = 0
        if x > 0:
            for i in range(N):
                if a[i] < 0:
                    num = -(-x//a[i])
                    count += N-max(i+1,bisect.bisect_left(a,num))
                elif a[i] > 0:
                    num = x//a[i]
                    count += max(0,bisect.bisect_right(a,num)-i-1)
                else:
                    count += N-(i+1)
        elif x == 0:
            for i in range(N):
                if a[i] < 0:
                    num = 0
                    count += N-max(i+1,bisect.bisect_left(a,num))
                elif a[i] > 0:
                    continue
                else:
                    count += N-(i+1)
        else:
            for i in range(N):
                if a[i] < 0:
                    num = -(-x//a[i])
                    count += N-bisect.bisect_left(a,num)
                else:
                    continue
        return count
    
    left,right = -10**18-1,10**18+1
    while right-left > 1:
        mid = (left+right)//2
        if check(mid) >= K:
            right = mid
        else:
            left = mid
            
    print(right)
    
if __name__ == "__main__":
    main()


Fixed submission:
import sys
input = sys.stdin.buffer.readline
import numpy as np

def main():
    N,K = map(int,input().split())
    a = np.array(list(map(int,input().split())))
    a.sort()
    posi,zero,nega = a[a>0],a[a==0],a[a<0]
    lz = len(zero)
    
    def ch(x):
        count = 0
        if x >= 0:
            count += lz*N
        count += np.searchsorted(a,x//posi,side="right").sum()
        count += (N-np.searchsorted(a,-(-x//nega))).sum()
        count -= np.count_nonzero(a**2<=x)
        return count//2

    l,r = -10**18-1,10**18
    while r-l > 1:
        mid = (r+l)//2
        if ch(mid) >= K:
            r = mid
        else:
            l = mid

    print(r)
    
if __name__ == "__main__":
    main()