Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect, bisect_left

n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
b = a[::-1]

ok, ng = -10**19, 10**19
while abs(ng-ok) > 1:
	x = (ng+ok)//2
	res = 0
	for c in a:
		if c*c < x:
			res -= 1
		if c == 0:
			if x > 0:
				res += n
		elif c > 0:
			#res += bisect(a, x/c - 1e-18)
			if c * a[0] >= x:
				pass
			else:
				l, r = 0, n
				while r-l > 1:
					y = (l+r)//2
					if a[y]*c < x:
						l = y
					else:
						r = y
				res += l+1
		else:
			#res += n - bisect(a, x/c + 1e-18)
			if c * b[0] >= x:
				pass
			else:
				l, r = 0, n
				while r-l > 1:
					y = (l+r)//2
					if b[y]*c < x:
						l = y
					else:
						r = y
				res += l+1
	res //= 2
	#print(x, res)
	if res < k:
		ok = x
	else:
		ng = x

print(ng-1)

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
plus, zero, minus = [], [], []
for x in a:
	if x > 0:
		plus.append(x)
	elif x == 0:
		zero.append(x)
	else:
		minus.append(x)
m, z, p = len(minus), len(zero), len(plus)
mm, zz, pp = m * p, z * (m + p) + (z * (z - 1)) // 2, (m * (m-1)) // 2 + (p * (p-1)) // 2
plus.sort()
plus2 = plus[::-1]
minus.sort()
minus2 = minus[::-1]
#print(mm, zz, pp)

if mm + zz >= k and mm < k:
	print(0)
elif mm >= k:
	ok, ng = -10**19, 0
	while ng-ok > 1:
		x = (ng+ok)//2
		res = 0
		l = 0
		for c in plus:
			if l == m:
				res += m
			elif minus[l] * c >= x:
				res += l
			else:
				while minus[l] * c < x:
					l += 1
					if l == m:
						break
				res += l
		if res < k:
			ok = x
		else:
			ng = x
	print(ng-1)
else:
	ok, ng = 0, 10**19
	while ng-ok > 1:
		x = (ng+ok)//2
		lm, lp = 0, 0
		res = 0
		for c in minus:
			if c*c < x:
				res -= 1
			if lm == m:
				res += m
			elif minus2[lm] * c >= x:
				res += lm
			else:
				while minus2[lm] * c < x:
					lm += 1
					if lm == m:
						break
				res += lm
		for c in plus2:
			if c*c < x:
				res -= 1
			if lp == p:
				res += p
			elif plus[lp] * c >= x:
				res += lp
			else:
				while plus[lp] * c < x:
					lp += 1
					if lp == p:
						break
				res += lp
		res //= 2
		res += zz + mm
		#print(x, res)
		if res < k:
			ok = x
		else:
			ng = x
	print(ng-1)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
b = a[::-1]

ok, ng = -10**19, 10**19
while abs(ng-ok) > 1:
	x = (ng+ok)//2
	res = 0
	for c in a:
		if c*c < x:
			res -= 1
		if c == 0:
			if x > 0:
				res += n
		elif c > 0:
			#res += bisect(a, x/c - 1e-18)
			if c * a[0] >= x:
				pass
			else:
				l, r = 0, n
				while r-l > 1:
					y = (l+r)//2
					if a[y]*c < x:
						l = y
					else:
						r = y
				res += l+1
		else:
			#res += n - bisect(a, x/c + 1e-18)
			if c * b[0] >= x:
				pass
			else:
				l, r = 0, n
				while r-l > 1:
					y = (l+r)//2
					if b[y]*c < x:
						l = y
					else:
						r = y
				res += l+1
	res //= 2
	#print(x, res)
	if res < k:
		ok = x
	else:
		ng = x

print(ng-1)

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
plus, zero, minus = [], [], []
for x in a:
	if x > 0:
		plus.append(x)
	elif x == 0:
		zero.append(x)
	else:
		minus.append(x)
m, z, p = len(minus), len(zero), len(plus)
mm, zz, pp = m * p, z * (m + p) + (z * (z - 1)) // 2, (m * (m-1)) // 2 + (p * (p-1)) // 2
plus.sort()
plus2 = plus[::-1]
minus.sort()
minus2 = minus[::-1]
#print(mm, zz, pp)

if mm + zz >= k and mm < k:
	print(0)
elif mm >= k:
	ok, ng = -10**19, 0
	while ng-ok > 1:
		x = (ng+ok)//2
		res = 0
		l = 0
		for c in plus:
			if l == m:
				res += m
			elif minus[l] * c >= x:
				res += l
			else:
				while minus[l] * c < x:
					l += 1
					if l == m:
						break
				res += l
		if res < k:
			ok = x
		else:
			ng = x
	print(ng-1)
else:
	ok, ng = 0, 10**19
	while ng-ok > 1:
		x = (ng+ok)//2
		lm, lp = 0, 0
		res = 0
		for c in minus:
			if c*c < x:
				res -= 1
			if lm == m:
				res += m
			elif minus2[lm] * c >= x:
				res += lm
			else:
				while minus2[lm] * c < x:
					lm += 1
					if lm == m:
						break
				res += lm
		for c in plus2:
			if c*c < x:
				res -= 1
			if lp == p:
				res += p
			elif plus[lp] * c >= x:
				res += lp
			else:
				while plus[lp] * c < x:
					lp += 1
					if lp == p:
						break
				res += lp
		res //= 2
		res += zz + mm
		#print(x, res)
		if res < k:
			ok = x
		else:
			ng = x
	print(ng-1)

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect, bisect_left

n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
b = a[::-1]

ok, ng = -10**19, 10**19
while abs(ng-ok) > 1:
	x = (ng+ok)//2
	res = 0
	for c in a:
		if c*c < x:
			res -= 1
		if c == 0:
			if x > 0:
				res += n
		elif c > 0:
			#res += bisect(a, x/c - 1e-18)
			if c * a[0] >= x:
				pass
			else:
				l, r = 0, n
				while r-l > 1:
					y = (l+r)//2
					if a[y]*c < x:
						l = y
					else:
						r = y
				res += l+1
		else:
			#res += n - bisect(a, x/c + 1e-18)
			if c * b[0] >= x:
				pass
			else:
				l, r = 0, n
				while r-l > 1:
					y = (l+r)//2
					if b[y]*c < x:
						l = y
					else:
						r = y
				res += l+1
	res //= 2
	#print(x, res)
	if res < k:
		ok = x
	else:
		ng = x

print(ng-1)

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
plus, zero, minus = [], [], []
for x in a:
	if x > 0:
		plus.append(x)
	elif x == 0:
		zero.append(x)
	else:
		minus.append(x)
m, z, p = len(minus), len(zero), len(plus)
mm, zz, pp = m * p, z * (m + p) + (z * (z - 1)) // 2, (m * (m-1)) // 2 + (p * (p-1)) // 2
plus.sort()
plus2 = plus[::-1]
minus.sort()
minus2 = minus[::-1]
#print(mm, zz, pp)

if mm + zz >= k and mm < k:
	print(0)
elif mm >= k:
	ok, ng = -10**19, 0
	while ng-ok > 1:
		x = (ng+ok)//2
		res = 0
		l = 0
		for c in plus:
			if l == m:
				res += m
			elif minus[l] * c >= x:
				res += l
			else:
				while minus[l] * c < x:
					l += 1
					if l == m:
						break
				res += l
		if res < k:
			ok = x
		else:
			ng = x
	print(ng-1)
else:
	ok, ng = 0, 10**19
	while ng-ok > 1:
		x = (ng+ok)//2
		lm, lp = 0, 0
		res = 0
		for c in minus:
			if c*c < x:
				res -= 1
			if lm == m:
				res += m
			elif minus2[lm] * c >= x:
				res += lm
			else:
				while minus2[lm] * c < x:
					lm += 1
					if lm == m:
						break
				res += lm
		for c in plus2:
			if c*c < x:
				res -= 1
			if lp == p:
				res += p
			elif plus[lp] * c >= x:
				res += lp
			else:
				while plus[lp] * c < x:
					lp += 1
					if lp == p:
						break
				res += lp
		res //= 2
		res += zz + mm
		#print(x, res)
		if res < k:
			ok = x
		else:
			ng = x
	print(ng-1)