Buggy python submission (verdict: Time Limit Exceeded):
import sys

def solve():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    A = [int(a) for a in input().split()]
    M, P = [], []
    Z = 0
    for a in A:
        if a < 0: M.append(a)
        elif a == 0: Z += 1
        else: P.append(a)
    M.sort(reverse = True)
    P.sort()
    mL, pL = len(M), len(P)

    minusT = mL * pL
    zeroT = Z * (mL + pL)

    if K <= minusT: #K番目の数が負の値
        P.sort(reverse = True)
        P.append(0)
        low, high = - 10 ** 18 - 1, 0
        while high - low > 1:
            mid = (low + high) // 2
            pi = 0
            count = 0
            for i in range(mL):
                while M[i] * P[pi] <= mid: pi += 1
                count += pi
            #print(mid, count)
            if count >= K: high = mid
            else: low = mid
        print(high)

    elif K <= minusT + zeroT: #K番目の数が0
        print(0)

    else: #正の数の内、K番目の数は何か
        T = N * (N - 1) // 2
        low, high = 0, 10 ** 18 + 1
        while high - low > 1:
            mid = (high + low) // 2
            count = 0
            for i in range(pL):
                l, h = i, pL
                while h - l > 1:
                    m = (l + h) // 2
                    if P[i] * P[m] >= mid: h = m
                    else: l = m
                count += pL - h
            
            for i in range(mL):
                l, h = i, mL
                while h - l > 1:
                    m = (l + h) // 2
                    if M[i] * M[m] >= mid: h = m
                    else: l = m
                count += mL - h

            #midよりも大きい数字がcount個ある
  
            if T - count >= K: high = mid
            else: low = mid
        print(low)
   
    return 0

if __name__ == "__main__":
    solve()

Fixed submission:
import sys

def solve():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    A = [int(a) for a in input().split()]
    M, P = [], [0]
    Z = 0
    for a in A:
        if a < 0: M.append(a)
        elif a == 0: Z += 1
        else: P.append(a)
    M.sort(reverse = True)
    mL, pL = len(M), len(P)

    minusT = mL * pL
    zeroT = Z * (mL + pL)

    if K <= minusT: #K番目の数が負の値
        P.sort(reverse = True)
        low, high = - 10 ** 18 - 1, 0
        while high - low > 1:
            mid = (low + high) // 2
            pi = 0
            count = 0
            for i in range(mL):
                while M[i] * P[pi] <= mid: pi += 1
                count += pi
            #print(mid, count)
            if count >= K: high = mid
            else: low = mid
        print(high)

    elif K <= minusT + zeroT: #K番目の数が0
        print(0)

    else: #正の数の内、K番目の数は何か
        M.append(0)
        P.sort()
        T = N * (N - 1) // 2
        low, high = 0, 10 ** 18 + 1
        while high - low > 1:
            mid = (high + low) // 2
            count = 0
            pi = pL - 1
            for i in range(pL):
                while P[i] * P[pi] >= mid:
                    pi -= 1
                count += pL - 1 - max(i, pi)
               
            mi = mL - 1
            for i in range(mL):
                while M[i] * M[mi] >= mid:
                    mi -= 1
                count += mL - 1 - max(i, mi)

            #midよりも大きい数字がcount個ある
  
            if T - count >= K: high = mid
            else: low = mid
        print(low)
   
    return 0

if __name__ == "__main__":
    solve()

Buggy python submission (verdict: Time Limit Exceeded):
import sys

def solve():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    A = [int(a) for a in input().split()]
    M, P = [], []
    Z = 0
    for a in A:
        if a < 0: M.append(a)
        elif a == 0: Z += 1
        else: P.append(a)
    M.sort(reverse = True)
    P.sort()
    mL, pL = len(M), len(P)

    minusT = mL * pL
    zeroT = Z * (mL + pL)

    if K <= minusT: #K番目の数が負の値
        P.sort(reverse = True)
        P.append(0)
        low, high = - 10 ** 18 - 1, 0
        while high - low > 1:
            mid = (low + high) // 2
            pi = 0
            count = 0
            for i in range(mL):
                while M[i] * P[pi] <= mid: pi += 1
                count += pi
            #print(mid, count)
            if count >= K: high = mid
            else: low = mid
        print(high)

    elif K <= minusT + zeroT: #K番目の数が0
        print(0)

    else: #正の数の内、K番目の数は何か
        T = N * (N - 1) // 2
        low, high = 0, 10 ** 18 + 1
        while high - low > 1:
            mid = (high + low) // 2
            count = 0
            for i in range(pL):
                l, h = i, pL
                while h - l > 1:
                    m = (l + h) // 2
                    if P[i] * P[m] >= mid: h = m
                    else: l = m
                count += pL - h
            
            for i in range(mL):
                l, h = i, mL
                while h - l > 1:
                    m = (l + h) // 2
                    if M[i] * M[m] >= mid: h = m
                    else: l = m
                count += mL - h

            #midよりも大きい数字がcount個ある
  
            if T - count >= K: high = mid
            else: low = mid
        print(low)
   
    return 0

if __name__ == "__main__":
    solve()

Fixed submission:
import sys

def solve():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    A = [int(a) for a in input().split()]
    M, P = [], [0]
    Z = 0
    for a in A:
        if a < 0: M.append(a)
        elif a == 0: Z += 1
        else: P.append(a)
    M.sort(reverse = True)
    mL, pL = len(M), len(P)

    minusT = mL * pL
    zeroT = Z * (mL + pL)

    if K <= minusT: #K番目の数が負の値
        P.sort(reverse = True)
        low, high = - 10 ** 18 - 1, 0
        while high - low > 1:
            mid = (low + high) // 2
            pi = 0
            count = 0
            for i in range(mL):
                while M[i] * P[pi] <= mid: pi += 1
                count += pi
            #print(mid, count)
            if count >= K: high = mid
            else: low = mid
        print(high)

    elif K <= minusT + zeroT: #K番目の数が0
        print(0)

    else: #正の数の内、K番目の数は何か
        M.append(0)
        P.sort()
        T = N * (N - 1) // 2
        low, high = 0, 10 ** 18 + 1
        while high - low > 1:
            mid = (high + low) // 2
            count = 0
            pi = pL - 1
            for i in range(pL):
                while P[i] * P[pi] >= mid:
                    pi -= 1
                count += pL - 1 - max(i, pi)
               
            mi = mL - 1
            for i in range(mL):
                while M[i] * M[mi] >= mid:
                    mi -= 1
                count += mL - 1 - max(i, mi)

            #midよりも大きい数字がcount個ある
  
            if T - count >= K: high = mid
            else: low = mid
        print(low)
   
    return 0

if __name__ == "__main__":
    solve()