Buggy python submission (verdict: Time Limit Exceeded):
def abc155_d():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()

    from bisect import bisect_left, bisect_right
    lower = -10**18
    upper = 10**18
    while upper - lower > 1:
        x = (upper + lower) // 2
        cnt = 0
        for i in range(n-1):
            a = A[i]
            if a < 0:
                idx = bisect_left(A, (x+a+1)//a)
                cnt += n - max(idx, i+1)
            elif a > 0:
                idx = bisect_right(A, x//a)
                cnt += max(0, idx - i - 1)
            else:  # a == 0
                if x >= 0:
                    cnt += n - i - 1
            if cnt >= k: break
        if cnt >= k: upper = x
        else: lower = x
    print(upper)

if __name__ == '__main__':
    abc155_d()

Fixed submission:
def abc155_d():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()

    from bisect import bisect_left, bisect_right
    lower = -10**18
    upper = 10**18
    while upper - lower > 1:
        x = (upper + lower) // 2
        cnt = 0
        for i in range(n-1):
            a = A[i]
            if a < 0:
                idx = bisect_left(A, (x+a+1)//a)
                cnt += n - max(idx, i+1)
            elif a > 0:
                idx = bisect_right(A, x//a)
                cnt += max(0, idx - i - 1)
            else:  # a == 0
                if x >= 0:
                    cnt += n - i - 1
            if cnt >= k: break
        if cnt >= k: upper = x
        else: lower = x
    print(upper)

if __name__ == '__main__':
    abc155_d()

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(int, input().split()))

A = sorted(A)

import bisect
idx0 = bisect.bisect_left(A, 0)
idx1 = bisect.bisect_left(A, 0)

A_nega = A[:idx0]
A_zero = A[idx0:idx1]
A_posi = A[idx1:]

#print(A_nega)
#print(A_zero)
#print(A_posi)

len_nega = len(A_nega)
len_zero = len(A_zero)
len_posi = len(A_posi)

target_area = ''
ans = 0

if len_nega * len_posi >= K:
  target_area = 'np'
elif len_nega * len_posi + len_zero >= K:
  target_area = 'z'
else:
  target_area = 'nn_pp'

#print(target_area)

if target_area == 'np':
  np_multiply = []
  for i in A_nega:
    for j in A_posi:
      np_multiply.append(i*j)

  np_multiply = sorted(np_multiply)
  ans = np_multiply[K-1]

elif target_area == 'z':
  ans = 0

elif target_area == 'nn_pp':
  nnpp_multiply = []
  for i in range(len_nega):
    for j in range(i+1, len_nega):
      nnpp_multiply.append(A_nega[i]*A_nega[j])
  for i in range(len_posi):
    for j in range(i+1, len_posi):
      nnpp_multiply.append(A_posi[i]*A_posi[j])

  nnpp_multiply = sorted(nnpp_multiply)

  K_rest = K - (len_nega * len_posi + len_zero)
  ans = nnpp_multiply[K_rest - 1]

print(ans)

Fixed submission:
def abc155_d():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()

    from bisect import bisect_left, bisect_right
    lower = -10**18
    upper = 10**18
    while upper - lower > 1:
        x = (upper + lower) // 2
        cnt = 0
        for i in range(n-1):
            a = A[i]
            if a < 0:
                idx = bisect_left(A, (x+a+1)//a)
                cnt += n - max(idx, i+1)
            elif a > 0:
                idx = bisect_right(A, x//a)
                cnt += max(0, idx - i - 1)
            else:  # a == 0
                if x >= 0:
                    cnt += n - i - 1
            if cnt >= k: break
        if cnt >= k: upper = x
        else: lower = x
    print(upper)

if __name__ == '__main__':
    abc155_d()