Buggy python submission (verdict: Runtime Error):
import sys

n,k = [ int(i) for i in input().split(" ")]
arr = [ int(i) for i in input().split(" ")]



# 10 40
# 5 4 3 2 -1 0 0 0 0 0

# 30 413
# -170202098 -268409015 537203564 983211703 21608710 -443999067 -937727165 -97596546 -372334013 398994917 -972141167 798607104 -949068442 -959948616 37909651 0 886627544 -20098238 0 -948955241 0 -214720580 277222296 -18897162 834475626 0 -425610555 110117526 663621752 0

negatives = []
zeros = []
positives = []
tmp = []

for i in arr:
  if i < 0:
    negatives.append(i)
  elif i == 0:
    zeros.append(i)
  else:
    positives.append(i)

negatives.sort()
zeros.sort()
positives.sort()

ngs = len(negatives) * len(positives)
if k < ngs:
  for i in range(len(negatives)):
    for j in range(i+1, len(negatives)):
      tmp.append(arr[i] * arr[j])
      if len(tmp) > k: break

  print(tmp[k-1])
  sys.exit()

k = k - ngs

zs = 0
for i in range(len(zeros)):
  zs += len(arr) - i-1

if k < zs:
  print(str(0))
  sys.exit()

k = k - zs

# positives.extend(negatives)
for i in range(len(positives)):
  for j in range(i+1, len(positives)):
    tmp.append(arr[i] * arr[j])

import pdb; pdb.set_trace()
tmp.sort()
print(tmp[k-1])

Fixed submission:
from bisect import bisect_left, bisect_right
N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
neg_end = bisect_left(A, 0)
pos_start = bisect_right(A, 0)

pos_cnt = N - pos_start
neg_cnt = neg_end
zero_cnt = N - (pos_cnt + neg_cnt)

neg_pairs_cnt = pos_cnt * neg_cnt
zero_pairs_cnt = zero_cnt * (pos_cnt + neg_cnt) + (zero_cnt * (zero_cnt-1) // 2)

if K <= neg_pairs_cnt:
  # X以下のpairはK個以上あるか？
  ok, ng = 0, -10**18
  while abs(ok - ng) > 1:
    X = (ok+ng) // 2
    or_higher_cnt, r = 0, pos_start
    # それぞれのnegごとに尺取り法
    for l in range(neg_end):
      while r < N and A[l] * A[r] > X:
        r += 1
      # positive_integers - (max_point - positive_start_index)
      or_higher_cnt += pos_cnt - (r - pos_start)

    if or_higher_cnt >= K:
      ok = X
    else:
      ng = X
  print(ok)

elif K <= neg_pairs_cnt + zero_pairs_cnt:
  print(0)

else:
  K -= (neg_pairs_cnt + zero_pairs_cnt)
  ok, ng = 10**18, 0
  while abs(ok - ng)> 1:
    X = (ok+ng) // 2
    or_higher_cnt = 0

    r = N - 1
    for l in range(pos_start, N):
      while r < N and A[l] * A[r] > X and l < r:
        r -= 1
      or_higher_cnt += max(0, r-l)

    l = 0
    for r in range(neg_end-1, -1, -1):
      while l < N and A[l] * A[r] > X and l < r:
        l += 1
      or_higher_cnt += max(0, r-l)

    if or_higher_cnt >= K:
      ok = X
    else:
      ng = X

  print(ok)

Buggy python submission (verdict: Time Limit Exceeded):
n,k = [ int(i) for i in input().split(" ")]
arr = [ int(i) for i in input().split(" ")]

tmp = []
for i in range(len(arr)):
  for j in range(i+1, len(arr)):
    tmp.append(arr[i] * arr[j])

tmp.sort()
print(tmp[k-1])

Fixed submission:
from bisect import bisect_left, bisect_right
N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
neg_end = bisect_left(A, 0)
pos_start = bisect_right(A, 0)

pos_cnt = N - pos_start
neg_cnt = neg_end
zero_cnt = N - (pos_cnt + neg_cnt)

neg_pairs_cnt = pos_cnt * neg_cnt
zero_pairs_cnt = zero_cnt * (pos_cnt + neg_cnt) + (zero_cnt * (zero_cnt-1) // 2)

if K <= neg_pairs_cnt:
  # X以下のpairはK個以上あるか？
  ok, ng = 0, -10**18
  while abs(ok - ng) > 1:
    X = (ok+ng) // 2
    or_higher_cnt, r = 0, pos_start
    # それぞれのnegごとに尺取り法
    for l in range(neg_end):
      while r < N and A[l] * A[r] > X:
        r += 1
      # positive_integers - (max_point - positive_start_index)
      or_higher_cnt += pos_cnt - (r - pos_start)

    if or_higher_cnt >= K:
      ok = X
    else:
      ng = X
  print(ok)

elif K <= neg_pairs_cnt + zero_pairs_cnt:
  print(0)

else:
  K -= (neg_pairs_cnt + zero_pairs_cnt)
  ok, ng = 10**18, 0
  while abs(ok - ng)> 1:
    X = (ok+ng) // 2
    or_higher_cnt = 0

    r = N - 1
    for l in range(pos_start, N):
      while r < N and A[l] * A[r] > X and l < r:
        r -= 1
      or_higher_cnt += max(0, r-l)

    l = 0
    for r in range(neg_end-1, -1, -1):
      while l < N and A[l] * A[r] > X and l < r:
        l += 1
      or_higher_cnt += max(0, r-l)

    if or_higher_cnt >= K:
      ok = X
    else:
      ng = X

  print(ok)