Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def f(x):
    cnt = 0
    for i,j in enumerate(a):
        if j == 0:
            if x < 0:
                continue
            cnt += n-i-1
        elif j > 0:
            r =  br(a,x//j)
            if r <= i:
                continue
            cnt += r - i - 1
        else:
            l = bl(a,-(x//-j))
            if l <= i:
                l = i+1
            cnt += n - l
        if cnt >= k:
            return True
    return False

n,k = LI()
a = LI()
a.sort()

ok = 10**18
ng = -10**18
while ok-ng > 1:
    mid = (ok+ng)//2
    if f(mid):
        ok = mid
    else:
        ng = mid
print(ok)



    

Fixed submission:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def f(x):
    cnt = 0
    if x < 0:
        j = p-1
        for i in range(m)[::-1]:
            while j >= 0:
                if minus[i]*plus[j] <= x:
                    j -= 1
                else:
                    break
            cnt += p - j - 1
    else:
        j = p-1
        for i in range(p):
            while j >= 0:
                if plus[i]*plus[j] > x:
                    j -= 1
                else:
                    break
            cnt += max(0,j - i)
        j = 0
        for i in range(m)[::-1]:
            while j < m:
                if minus[i]*minus[j] > x:
                    j += 1
                else:
                    break
            cnt += max(0,i - j)
        cnt += (m+p)*zero + zero*(zero-1)//2 + m*p
    return cnt >= k
        
n,k = LI()
a = LI()
a.sort()
minus = [x for x in a if x < 0]
plus = [x for x in a if x > 0]
m = len(minus)
p = len(plus)
zero = bl(a,1) - br(a,-1)
ok = 10**18
ng = -10**18-1
while ok-ng > 1:
    mid = (ok+ng)//2
    if f(mid):
        ok = mid
    else:
        ng = mid
print(ok)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def f(x):
    cnt = 0
    for i,j in enumerate(a):
        if j == 0:
            if x >= 0:
                cnt += n-i-1
        elif j > 0:
            r =  br(a,x//j)
            if r <= i:
                continue
            cnt += r - i - 1
        else:
            l = bl(a,-(x//-j))
            if l <= i:
                l = i+1
            cnt += n - l
    return cnt >= k

n,k = LI()
a = LI()
a.sort()

ok = 10**18
ng = -10**18
while ok-ng > 1:
    mid = (ok+ng)//2
    if f(mid):
        ok = mid
    else:
        ng = mid
print(ok)



    

Fixed submission:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def f(x):
    cnt = 0
    if x < 0:
        j = p-1
        for i in range(m)[::-1]:
            while j >= 0:
                if minus[i]*plus[j] <= x:
                    j -= 1
                else:
                    break
            cnt += p - j - 1
    else:
        j = p-1
        for i in range(p):
            while j >= 0:
                if plus[i]*plus[j] > x:
                    j -= 1
                else:
                    break
            cnt += max(0,j - i)
        j = 0
        for i in range(m)[::-1]:
            while j < m:
                if minus[i]*minus[j] > x:
                    j += 1
                else:
                    break
            cnt += max(0,i - j)
        cnt += (m+p)*zero + zero*(zero-1)//2 + m*p
    return cnt >= k
        
n,k = LI()
a = LI()
a.sort()
minus = [x for x in a if x < 0]
plus = [x for x in a if x > 0]
m = len(minus)
p = len(plus)
zero = bl(a,1) - br(a,-1)
ok = 10**18
ng = -10**18-1
while ok-ng > 1:
    mid = (ok+ng)//2
    if f(mid):
        ok = mid
    else:
        ng = mid
print(ok)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def f(x):
    cnt = 0
    for i in range(n):
        if a[i] == 0:
            if x >= 0:
                cnt += n-i-1
        elif a[i] > 0:
            r =  br(a,x//a[i])
            if r <= i:
                continue
            cnt += r - i - 1
        else:
            l = bl(a,-(x//-a[i]))
            if l <= i:
                l = i+1
            cnt += n - l
    return cnt >= k
n,k = LI()
a = LI()
a.sort()

ok = 10**18+1
ng = -10**18-1
while ok-ng > 1:
    mid = (ok+ng)//2
    if f(mid):
        ok = mid
    else:
        ng = mid
print(ok)



    

Fixed submission:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def f(x):
    cnt = 0
    if x < 0:
        j = p-1
        for i in range(m)[::-1]:
            while j >= 0:
                if minus[i]*plus[j] <= x:
                    j -= 1
                else:
                    break
            cnt += p - j - 1
    else:
        j = p-1
        for i in range(p):
            while j >= 0:
                if plus[i]*plus[j] > x:
                    j -= 1
                else:
                    break
            cnt += max(0,j - i)
        j = 0
        for i in range(m)[::-1]:
            while j < m:
                if minus[i]*minus[j] > x:
                    j += 1
                else:
                    break
            cnt += max(0,i - j)
        cnt += (m+p)*zero + zero*(zero-1)//2 + m*p
    return cnt >= k
        
n,k = LI()
a = LI()
a.sort()
minus = [x for x in a if x < 0]
plus = [x for x in a if x > 0]
m = len(minus)
p = len(plus)
zero = bl(a,1) - br(a,-1)
ok = 10**18
ng = -10**18-1
while ok-ng > 1:
    mid = (ok+ng)//2
    if f(mid):
        ok = mid
    else:
        ng = mid
print(ok)