Buggy python submission (verdict: Time Limit Exceeded):
import sys
INF = 10**18+5
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    a = sorted(a)
    plus = 0
    minus = 0
    zero = 0
    for i in range(n):
        if a[i] > 0:
            plus += 1
        elif a[i] < 0:
            minus += 1
        else:
            zero += 1

    mc = minus*plus
    zc = (zero*(zero-1)/2) + (zero * (plus+minus))
    pc = (plus*(plus-1)/2) + (minus*(minus-1)/2)
    if mc >= k:
        l = -INF
        r = 0
        while(l+1 < r):
            x = (l+r)//2
            total = 0
            for i in range(n):
                if a[i] < 0:
                    l2 = minus+zero-1
                    r2 = n
                    while(l2+1 < r2):
                        x2 = (l2+r2)//2
                        if a[x2]*a[i] >= x:
                            l2 = x2
                        else:
                            r2 = x2
                    total += n-r2
                else:
                    l2 = -1
                    r2 = minus
                    while(l2+1 < r2):
                        x2 = (l2+r2)//2
                        if a[x2]*a[i] < x:
                            l2 = x2
                        else:
                            r2 = x2
                    total += r2
                if a[i]*a[i] < x:
                    total -= 1
            total //= 2
            if total < k:
                l = x
            else:
                r = x
        ans = l
    elif mc + zc >= k:
        ans = 0
    else:
        l = 0
        r = INF
        while(l+1 < r):
            x = (l+r)//2
            total = 0
            for i in range(n):
                if a[i] < 0:
                    l2 = -1
                    r2 = minus
                    while(l2+1 < r2):
                        x2 = (l2+r2)//2
                        if a[x2]*a[i] >= x:
                            l2 = x2
                        else:
                            r2 = x2
                    total += n-r2
                else:
                    l2 = minus+zero-1
                    r2 = n
                    while(l2+1 < r2):
                        x2 = (l2+r2)//2
                        if a[x2]*a[i] < x:
                            l2 = x2
                        else:
                            r2 = x2
                    total += r2
                if a[i]*a[i] < x:
                    total -= 1
            total //= 2
            if total < k:
                l = x
            else:
                r = x
        ans = l

    print(ans)


main()


Fixed submission:
import sys
import numpy as np
INF = 10**18+5
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    a = np.sort(a)
    ap = a[a > 0]
    an = a[a < 0]
    zc = n * (n - ap.size - an.size)

    l = -INF
    r = INF
    while(l+1 < r):
        x = (l+r)//2

        total = (n-np.searchsorted(a, -(-x // an), side='left')).sum()
        if x >= 0:
            total += zc
        total += np.searchsorted(a, x // ap, side='right').sum()
        total -= a[a*a <= x].size
        total //= 2
        if total < k:
            l = x
        else:
            r = x

    print(r)


main()

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

INF = 10**18+5


def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    a = sorted(a)
    l = -INF
    r = INF

    while(l+1 < r):
        x = (l+r)//2
        total = 0
        for i in range(n):
            if a[i] < 0:
                l2 = -1
                r2 = n
                while(l2+1 < r2):
                    x2 = (l2+r2)//2
                    if a[x2]*a[i] >= x:
                        l2 = x2
                    else:
                        r2 = x2
                total += n-r2
            else:
                l2 = -1
                r2 = n
                while(l2+1 < r2):
                    x2 = (l2+r2)//2
                    if a[x2]*a[i] < x:
                        l2 = x2
                    else:
                        r2 = x2
                total += r2
            if a[i]*a[i] < x:
                total -= 1
        total //= 2
        if total < k:
            l = x
        else:
            r = x

    print(l)


main()


Fixed submission:
import sys
import numpy as np
INF = 10**18+5
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    a = np.sort(a)
    ap = a[a > 0]
    an = a[a < 0]
    zc = n * (n - ap.size - an.size)

    l = -INF
    r = INF
    while(l+1 < r):
        x = (l+r)//2

        total = (n-np.searchsorted(a, -(-x // an), side='left')).sum()
        if x >= 0:
            total += zc
        total += np.searchsorted(a, x // ap, side='right').sum()
        total -= a[a*a <= x].size
        total //= 2
        if total < k:
            l = x
        else:
            r = x

    print(r)


main()

Buggy python submission (verdict: Time Limit Exceeded):
INF = 10**18+5


def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    a = sorted(a)
    l = -INF
    r = INF
    while(l+1 < r):
        x = (l+r)//2
        total = 0
        for i in range(n):
            if a[i] < 0:
                l2 = -1
                r2 = n
                while(l2+1 < r2):
                    x2 = (l2+r2)//2
                    if a[x2]*a[i] >= x:
                        l2 = x2
                    else:
                        r2 = x2
                total += n-r2
            else:
                l2 = -1
                r2 = n
                while(l2+1 < r2):
                    x2 = (l2+r2)//2
                    if a[x2]*a[i] < x:
                        l2 = x2
                    else:
                        r2 = x2
                total += r2
            if a[i]*a[i] < x:
                total -= 1
        total //= 2
        if total < k:
            l = x
        else:
            r = x
    print(l)


main()


Fixed submission:
import sys
import numpy as np
INF = 10**18+5
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    a = np.sort(a)
    ap = a[a > 0]
    an = a[a < 0]
    zc = n * (n - ap.size - an.size)

    l = -INF
    r = INF
    while(l+1 < r):
        x = (l+r)//2

        total = (n-np.searchsorted(a, -(-x // an), side='left')).sum()
        if x >= 0:
            total += zc
        total += np.searchsorted(a, x // ap, side='right').sum()
        total -= a[a*a <= x].size
        total //= 2
        if total < k:
            l = x
        else:
            r = x

    print(r)


main()

Buggy python submission (verdict: Runtime Error):
def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    table = [0] * (n*(n-1)//2+1)
    c = 0
    for i in range(n):
        for j in range(i+1, n):
            table[c] = a[i]*a[j]
            c += 1
    table = sorted(table)
    print(table[k])


main()


Fixed submission:
import sys
import numpy as np
INF = 10**18+5
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    a = np.sort(a)
    ap = a[a > 0]
    an = a[a < 0]
    zc = n * (n - ap.size - an.size)

    l = -INF
    r = INF
    while(l+1 < r):
        x = (l+r)//2

        total = (n-np.searchsorted(a, -(-x // an), side='left')).sum()
        if x >= 0:
            total += zc
        total += np.searchsorted(a, x // ap, side='right').sum()
        total -= a[a*a <= x].size
        total //= 2
        if total < k:
            l = x
        else:
            r = x

    print(r)


main()