Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    input = sys.stdin.readline
    n, k = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()
 
    import bisect
    def ok(x):
        # x以下になる組み合わせがk個以上
        cnt = 0
        for a in A:
            if a*a <= x:
                cnt -= 1
            if a > 0:
                c = x//a
                cnt += bisect.bisect_right(A, c)
            elif a < 0:
                c = (-x-1)//(-a)
                cnt += n - bisect.bisect_right(A, c)
            else:
                if x >= 0:
                    cnt += n
        cnt = cnt//2
        if cnt >= k:
            return True
        else:
            return False
 
    l = -10**18-1
    r = 10**18+1
    while l+1 < r:
        m = (l+r)//2
        if ok(m):
            r = m
        else:
            l = m
    print(r)
 
if __name__ == '__main__':
    main()

Fixed submission:
import sys
#sys.setrecursionlimit(10**9)
input = sys.stdin.readline

import numpy as np

n, k = map(int, input().split())
A = np.array(input().split(), np.int64)
A = np.sort(A)

P = A[A>0]
Z = A[A==0]
N = A[A<0]

#t = n*(n-1)//2

def ok(x):
    # x以下になる組み合わせがk個以上
    cnt = 0
    #cnt += np.searchsorted(A, np.ceil(x/P), side='right').sum()
    cnt += np.searchsorted(A, x//P, side='right').sum()
    #cnt += n-np.searchsorted(A, np.floor(x/N), side='left').sum()
    cnt += (n-np.searchsorted(A, (-x-1)//(-N), side='right')).sum()
    if x >= 0:
        cnt += len(Z)*n
    cnt -= np.count_nonzero(A*A <= x)
    cnt = cnt//2
    if cnt >= k:
        return True
    else:
        return False

l = -10**18-1
r = 10**18+1
while l+1 < r:
    c = (l+r)//2
    if ok(c):
        r = c
    else:
        l = c
print(r)

Buggy python submission (verdict: Time Limit Exceeded):

def main():
    import sys
    input = sys.stdin.readline
    n, k = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()

    import bisect
    def ok(x):
        # x以下になる組み合わせがk個以上
        cnt = 0
        for a in A:
            if a*a <= x:
                cnt -= 1
            if a > 0:
                c = x//a
                cnt += bisect.bisect_right(A, c)
            elif a < 0:
                c = (-x-1)//(-a)
                cnt += n - bisect.bisect_right(A, c)
            else:
                if x >= 0:
                    cnt += n
        cnt = cnt//2
        if cnt >= k:
            return True
        else:
            return False

    l = -10**18-1
    r = 10**18+1
    while l+1 < r:
        m = (l+r)//2
        if ok(m):
            r = m
        else:
            l = m
    print(r)

if __name__ == '__main__':
    main()


Fixed submission:
import sys
#sys.setrecursionlimit(10**9)
input = sys.stdin.readline

import numpy as np

n, k = map(int, input().split())
A = np.array(input().split(), np.int64)
A = np.sort(A)

P = A[A>0]
Z = A[A==0]
N = A[A<0]

#t = n*(n-1)//2

def ok(x):
    # x以下になる組み合わせがk個以上
    cnt = 0
    #cnt += np.searchsorted(A, np.ceil(x/P), side='right').sum()
    cnt += np.searchsorted(A, x//P, side='right').sum()
    #cnt += n-np.searchsorted(A, np.floor(x/N), side='left').sum()
    cnt += (n-np.searchsorted(A, (-x-1)//(-N), side='right')).sum()
    if x >= 0:
        cnt += len(Z)*n
    cnt -= np.count_nonzero(A*A <= x)
    cnt = cnt//2
    if cnt >= k:
        return True
    else:
        return False

l = -10**18-1
r = 10**18+1
while l+1 < r:
    c = (l+r)//2
    if ok(c):
        r = c
    else:
        l = c
print(r)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
#sys.setrecursionlimit(10**9)
input = sys.stdin.readline
n, k = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

import bisect
def ok(x):
    # x以下になる組み合わせがk個以上
    cnt = 0
    for a in A:
        if a*a <= x:
            cnt -= 1
        if a > 0:
            c = x//a
            cnt += bisect.bisect_right(A, c)
        elif a < 0:
            c = (-x-1)//(-a)
            cnt += n - bisect.bisect_right(A, c)
        else:
            if x >= 0:
                cnt += n
    cnt = cnt//2
    if cnt >= k:
        return True
    else:
        return False

l = -10**18-1
r = 10**18+1
while l+1 < r:
    m = (l+r)//2
    if ok(m):
        r = m
    else:
        l = m
print(r)


Fixed submission:
import sys
#sys.setrecursionlimit(10**9)
input = sys.stdin.readline

import numpy as np

n, k = map(int, input().split())
A = np.array(input().split(), np.int64)
A = np.sort(A)

P = A[A>0]
Z = A[A==0]
N = A[A<0]

#t = n*(n-1)//2

def ok(x):
    # x以下になる組み合わせがk個以上
    cnt = 0
    #cnt += np.searchsorted(A, np.ceil(x/P), side='right').sum()
    cnt += np.searchsorted(A, x//P, side='right').sum()
    #cnt += n-np.searchsorted(A, np.floor(x/N), side='left').sum()
    cnt += (n-np.searchsorted(A, (-x-1)//(-N), side='right')).sum()
    if x >= 0:
        cnt += len(Z)*n
    cnt -= np.count_nonzero(A*A <= x)
    cnt = cnt//2
    if cnt >= k:
        return True
    else:
        return False

l = -10**18-1
r = 10**18+1
while l+1 < r:
    c = (l+r)//2
    if ok(c):
        r = c
    else:
        l = c
print(r)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
#sys.setrecursionlimit(10**9)
input = sys.stdin.readline
n, k = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

import bisect
def ok(x):
    # x以下になる組み合わせがk個以上
    cnt = 0
    for a in A:
        if a > 0:
            c = x//a
            cnt += bisect.bisect_right(A, c)
        elif a < 0:
            c = (-x-1)//(-a)
            cnt += n - bisect.bisect_right(A, c)
        else:
            if x >= 0:
                cnt += n
    for a in A:
        if a*a <= x:
            cnt -= 1
    cnt = cnt//2
    if cnt >= k:
        return True
    else:
        return False

l = -10**18-1
r = 10**18+1
while l+1 < r:
    m = (l+r)//2
    if ok(m):
        r = m
    else:
        l = m
print(r)


Fixed submission:
import sys
#sys.setrecursionlimit(10**9)
input = sys.stdin.readline

import numpy as np

n, k = map(int, input().split())
A = np.array(input().split(), np.int64)
A = np.sort(A)

P = A[A>0]
Z = A[A==0]
N = A[A<0]

#t = n*(n-1)//2

def ok(x):
    # x以下になる組み合わせがk個以上
    cnt = 0
    #cnt += np.searchsorted(A, np.ceil(x/P), side='right').sum()
    cnt += np.searchsorted(A, x//P, side='right').sum()
    #cnt += n-np.searchsorted(A, np.floor(x/N), side='left').sum()
    cnt += (n-np.searchsorted(A, (-x-1)//(-N), side='right')).sum()
    if x >= 0:
        cnt += len(Z)*n
    cnt -= np.count_nonzero(A*A <= x)
    cnt = cnt//2
    if cnt >= k:
        return True
    else:
        return False

l = -10**18-1
r = 10**18+1
while l+1 < r:
    c = (l+r)//2
    if ok(c):
        r = c
    else:
        l = c
print(r)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
#sys.setrecursionlimit(10**9)
input = sys.stdin.readline

import numpy as np

n, k = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

import bisect
def ok(x):
    # x以下になる組み合わせがk個以上
    cnt = 0
    for a in A:
        if a > 0:
            c = x//a
            cnt += bisect.bisect_right(A, c)
        elif a < 0:
            c = (-x-1)//(-a)
            cnt += n - bisect.bisect_right(A, c)
        else:
            if x >= 0:
                cnt += n
    for a in A:
        if a*a <= x:
            cnt -= 1
    cnt = cnt//2
    if cnt >= k:
        return True
    else:
        return False

l = -10**18-1
r = 10**18+1
while l+1 < r:
    m = (l+r)//2
    if ok(m):
        r = m
    else:
        l = m
print(r)


Fixed submission:
import sys
#sys.setrecursionlimit(10**9)
input = sys.stdin.readline

import numpy as np

n, k = map(int, input().split())
A = np.array(input().split(), np.int64)
A = np.sort(A)

P = A[A>0]
Z = A[A==0]
N = A[A<0]

#t = n*(n-1)//2

def ok(x):
    # x以下になる組み合わせがk個以上
    cnt = 0
    #cnt += np.searchsorted(A, np.ceil(x/P), side='right').sum()
    cnt += np.searchsorted(A, x//P, side='right').sum()
    #cnt += n-np.searchsorted(A, np.floor(x/N), side='left').sum()
    cnt += (n-np.searchsorted(A, (-x-1)//(-N), side='right')).sum()
    if x >= 0:
        cnt += len(Z)*n
    cnt -= np.count_nonzero(A*A <= x)
    cnt = cnt//2
    if cnt >= k:
        return True
    else:
        return False

l = -10**18-1
r = 10**18+1
while l+1 < r:
    c = (l+r)//2
    if ok(c):
        r = c
    else:
        l = c
print(r)

Buggy python submission (verdict: Runtime Error):
import sys
#sys.setrecursionlimit(10**9)
input = sys.stdin.readline

n, k = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

t = n*(n-1)//2

import bisect
import math
def ok(x):
    # x以上になる組み合わせがt-k+1個以上ある
    cnt = 0
    for a in A:
        if a > 0:
            b = math.ceil(x/a)
            c = n - bisect.bisect_left(A, b)
            if a*a >= x:
                c -= 1
        elif a == 0:
            if x <= 0:
                c = n-1
        else:
            b = math.floor(x/a)
            c = bisect.bisect_right(A, b)
            if a*a >= x:
                c -= 1
        cnt += c
    cnt //= 2
    if cnt >= t-k+1:
        return True
    else:
        return False

l = -10**18-1
r = 10**18+1
while l+1 < r:
    c = (l+r)//2
    if ok(c):
        l = c
    else:
        r = c
print(l)


Fixed submission:
import sys
#sys.setrecursionlimit(10**9)
input = sys.stdin.readline

import numpy as np

n, k = map(int, input().split())
A = np.array(input().split(), np.int64)
A = np.sort(A)

P = A[A>0]
Z = A[A==0]
N = A[A<0]

#t = n*(n-1)//2

def ok(x):
    # x以下になる組み合わせがk個以上
    cnt = 0
    #cnt += np.searchsorted(A, np.ceil(x/P), side='right').sum()
    cnt += np.searchsorted(A, x//P, side='right').sum()
    #cnt += n-np.searchsorted(A, np.floor(x/N), side='left').sum()
    cnt += (n-np.searchsorted(A, (-x-1)//(-N), side='right')).sum()
    if x >= 0:
        cnt += len(Z)*n
    cnt -= np.count_nonzero(A*A <= x)
    cnt = cnt//2
    if cnt >= k:
        return True
    else:
        return False

l = -10**18-1
r = 10**18+1
while l+1 < r:
    c = (l+r)//2
    if ok(c):
        r = c
    else:
        l = c
print(r)

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

n, k = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

t = n*(n-1)//2

import bisect
import math
def ok(x):
    # x以上になる組み合わせがt-k+1個以上ある
    cnt = 0
    for a in A:
        if a > 0:
            b = math.ceil(x/a)
            c = n - bisect.bisect_left(A, b)
            if a >= b:
                c -= 1
        elif a == 0:
            if x <= 0:
                c = n-1
        else:
            b = math.floor(x/a)
            c = bisect.bisect_right(A, b)
            if a <= b:
                c -= 1
        cnt += c
    cnt //= 2
    if cnt >= t-k+1:
        return True
    else:
        return False

l = -10**18-1
r = 10**18+1
while l+1 < r:
    c = (l+r)//2
    if ok(c):
        l = c
    else:
        r = c
print(l)

Fixed submission:
import sys
#sys.setrecursionlimit(10**9)
input = sys.stdin.readline

import numpy as np

n, k = map(int, input().split())
A = np.array(input().split(), np.int64)
A = np.sort(A)

P = A[A>0]
Z = A[A==0]
N = A[A<0]

#t = n*(n-1)//2

def ok(x):
    # x以下になる組み合わせがk個以上
    cnt = 0
    #cnt += np.searchsorted(A, np.ceil(x/P), side='right').sum()
    cnt += np.searchsorted(A, x//P, side='right').sum()
    #cnt += n-np.searchsorted(A, np.floor(x/N), side='left').sum()
    cnt += (n-np.searchsorted(A, (-x-1)//(-N), side='right')).sum()
    if x >= 0:
        cnt += len(Z)*n
    cnt -= np.count_nonzero(A*A <= x)
    cnt = cnt//2
    if cnt >= k:
        return True
    else:
        return False

l = -10**18-1
r = 10**18+1
while l+1 < r:
    c = (l+r)//2
    if ok(c):
        r = c
    else:
        l = c
print(r)