Buggy python submission (verdict: Time Limit Exceeded):
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n,k = map(int,ipt().split())
    a = [int(i) for i in ipt().split()]
    ap = []
    am = []
    for i in a:
        if i > 0:
            ap.append(i)
        elif i < 0:
            am.append(i)

    ap.sort(reverse=True)
    am.sort()
    hq = []
    if k <= len(ap)*len(am):
        done = [[-1]*len(am)+[1] for _ in [0]*len(ap)]
        done.append([1]*(len(am)+1))
        heapq.heappush(hq,(ap[0]*am[0],0,0))
        done[0][0] = 1
        for i in range(k-1):
            num,api,ami = heapq.heappop(hq)
            if done[api][ami+1] == -1:
                heapq.heappush(hq,(ap[api]*am[ami+1],api,ami+1))
                done[api][ami+1] = 1
            if done[api+1][ami] == -1:
                heapq.heappush(hq,(ap[api+1]*am[ami],api+1,ami))
                done[api+1][ami] = 1
        num,api,ami = heapq.heappop(hq)
        print(num)
    elif n*(n-1)//2-k+1 <= len(ap)*(len(ap)-1)//2+len(am)*(len(am)-1)//2:
        dop = [[-1]*len(ap)+[1] for _ in [0]*(len(ap)+1)]
        for i,di in enumerate(dop):
            di[i] = 1
        dom = [[-1]*len(am)+[1] for _ in [0]*(len(am)+1)]
        for i,di in enumerate(dom):
            di[i] = 1
        if len(ap) > 1:
            heapq.heappush(hq,(-ap[0]*ap[1],0,1,"p"))
            dop[0][1] = 1
        if len(am) > 1:
            heapq.heappush(hq,(-am[0]*am[1],0,1,"m"))
            dom[0][1] = 1
        for i in range(n*(n-1)//2-k):
            num,a0,a1,char = heapq.heappop(hq)
            if char == "p":
                ax = ap
                dx = dop
            else:
                ax = am
                dx = dom
            if dx[a0][a1+1] == -1:
                heapq.heappush(hq,(-ax[a0]*ax[a1+1],a0,a1+1,char))
                dx[a0][a1+1] = 1
            if dx[a0+1][a1] == -1:
                heapq.heappush(hq,(-ax[a0+1]*ax[a1],a0+1,a1,char))
                dx[a0+1][a1] = 1
        num,a0,a1,char = heapq.heappop(hq)
        print(-num)
    else:
        print(0)



    return

if __name__ == '__main__':
    main()


Fixed submission:
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n,k = map(int,ipt().split())
    ps = []
    ms = []
    n0 = 0
    for i in ipt().split():
        ii = int(i)
        if ii == 0:
            n0 += 1
        elif ii > 0:
            ps.append(ii)
        else:
            ms.append(-ii)

    pn = len(ps)
    mn = len(ms)
    if k <= pn*mn:
        ps.sort()
        ms.sort(reverse=True)
        l = -10**(18)
        r = -1
        while l < r:
            mid = l + (r-l)//2
            num = 0 #積がmid以下になる個数
            mi = 0
            for i in ps:
                for j in range(mi,mn):
                    if -i*ms[j] > mid:
                        break
                    mi += 1
                num += mi
            if num < k:
                l = mid+1
            else:
                r = mid
        print(l)

    elif k <= pn*mn+n0*(pn+mn)+n0*(n0-1)//2:
        print(0)

    else:
        k -= pn*mn+n0*(pn+mn)+n0*(n0-1)//2
        ps.sort()
        ms.sort()
        l = 1
        r = 10**18
        while l < r:
            mid = l + (r-l)//2
            num = 0 #積がmid以下になる個数
            mi = 0
            pi = 0
            for i,mk in enumerate(ms[::-1]):
                mi = min(mi,mn-i-1)
                for j in range(mi,mn-i-1):
                    if mk*ms[j] > mid:
                        break
                    mi += 1
                num += mi
            for i,pk in enumerate(ps[::-1]):
                pi = min(pi,pn-i-1)
                for j in range(pi,pn-i-1):
                    if pk*ps[j] > mid:
                        break
                    pi += 1
                num += pi
#            print(mid,num,k)
            if num < k:
                l = mid+1
            else:
                r = mid
        print(l)
    return None

if __name__ == '__main__':
    main()