Buggy python submission (verdict: Time Limit Exceeded):
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
import numpy as np
num = np.array(a, dtype=np.int64)
ans = np.array([], dtype=np.int64)
for i in range(n-1):
    ans = np.insert(ans, 0, num[i] * num[i+1:])
ans = np.sort(ans)
print(int(ans[k-1]))

Fixed submission:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    inf = 10**20
    #mod = 10**9 + 7

    N,k = map(int, input().split())
    zero, p, n = 0, [], []
    a = list(map(int, input().split()))
    for i in a:
        if i==0:
            zero += 1
        elif i > 0:
            p.append(i)
        else:
            n.append(i)
    p.sort()
    n.sort(reverse=True)

    #決め打ち二分探索
    #rはk個以上作れる, lはk個作れない
    l, r = -inf, inf
    while r - l > 1:
        mid = (l + r) // 2
        cnt = 0
        #0以上とき0の分足す
        if mid >= 0:
            cnt += zero*(zero-1)//2 + zero*(N-zero)
        
        if mid > 0:
            #負数足す
            cnt += len(n) * len(p)
            #p, nについてそれぞれ尺取り法で調べる
            for a in (p, n):
                left, right = 0, len(a)-1
                while left < right:
                    #a[l]*a[r]は小さくなっていきmid以下になったらそこから数える
                    while left<right and a[left]*a[right]>mid:
                        right -= 1
                    cnt += right - left
                    #lは最小から始まるのでrの値をリセットする必要はない
                    left += 1
        else:
            right = len(n) - 1
            for left in range(len(p)):
                while right>=0 and p[left]*n[right]<=mid:
                    right -= 1
                cnt += len(n) - right - 1
        
        if cnt >= k:
            r = mid
        else:
            l = mid

    print(r)



if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
ans = []
for i in range(n):
    for j in range(1, n-i):
        ans.append(a[i] * a[i+j])
ans = sorted(ans, reverse=0)
print(ans[k-1])

Fixed submission:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    inf = 10**20
    #mod = 10**9 + 7

    N,k = map(int, input().split())
    zero, p, n = 0, [], []
    a = list(map(int, input().split()))
    for i in a:
        if i==0:
            zero += 1
        elif i > 0:
            p.append(i)
        else:
            n.append(i)
    p.sort()
    n.sort(reverse=True)

    #決め打ち二分探索
    #rはk個以上作れる, lはk個作れない
    l, r = -inf, inf
    while r - l > 1:
        mid = (l + r) // 2
        cnt = 0
        #0以上とき0の分足す
        if mid >= 0:
            cnt += zero*(zero-1)//2 + zero*(N-zero)
        
        if mid > 0:
            #負数足す
            cnt += len(n) * len(p)
            #p, nについてそれぞれ尺取り法で調べる
            for a in (p, n):
                left, right = 0, len(a)-1
                while left < right:
                    #a[l]*a[r]は小さくなっていきmid以下になったらそこから数える
                    while left<right and a[left]*a[right]>mid:
                        right -= 1
                    cnt += right - left
                    #lは最小から始まるのでrの値をリセットする必要はない
                    left += 1
        else:
            right = len(n) - 1
            for left in range(len(p)):
                while right>=0 and p[left]*n[right]<=mid:
                    right -= 1
                cnt += len(n) - right - 1
        
        if cnt >= k:
            r = mid
        else:
            l = mid

    print(r)



if __name__ == '__main__':
    main()