Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
plst = []
nlst = []
p = 0
z = 0
n = 0
for i in map(int,input().split()):
    if i > 0:
        p += 1
        plst.append(i)
    elif i == 0:
        z += 1
    else:
        n += 1
        nlst.append(i)
plst.sort()
nlst.sort()
zp = (p+n)*z + z*(z-1)//2
np = p*n
if K <= np:
    l = -10**18-1
    r = 0
    while l+1 < r:
        m = (l+r)//2
        total = 0
        idx = 0
        for i in range(p):
            while idx < n:
                if plst[i] * nlst[idx] < m:
                    idx += 1
                else:
                    total += idx
                    break
            else:
                total += idx
        if total < K:
            l = m
        else:
            r = m
    ans = l
elif K <= np+zp:
    ans = 0
else:
    l = 0
    r = 10**18+1
    while l+1 < r:
        m = (l+r)//2
        total = np+zp
        tmp = 0
        idx = 0
        for i in range(p)[::-1]:
            while idx < p:
                if plst[i] * plst[idx] < m:
                    idx += 1
                else:
                    tmp += idx
                    break
            else:
                tmp += idx
            if plst[i] * plst[i] < m: tmp -= 1
        tmp //= 2
        total += tmp
        tmp = 0
        idx = 0 
        for i in range(n):
            while idx < n:
                if nlst[i] * nlst[-idx-1] < m:
                    idx += 1
                else:
                    tmp += idx
                    break
            else:
                tmp += idx
            if nlst[i] * nlst[i] < m: tmp -= 1
        tmp //= 2
        total += tmp
        if total < K:
            l = m      
        else:
            r = m
    ans = l
print(ans)

Fixed submission:
N,K = map(int,input().split())
plst = []
nlst = []
p = 0
z = 0
n = 0
for i in map(int,input().split()):
    if i > 0:
        p += 1
        plst.append(i)
    elif i == 0:
        z += 1
    else:
        n += 1
        nlst.append(i)
plst.sort()
nlst.sort()
zp = (p+n)*z + z*(z-1)//2
np = p*n
if K <= np:
    l = -10**18-1
    r = 0
    while l+1 < r:
        m = (l+r)//2
        total = 0
        idx = 0
        for i in range(p):
            while idx < n:
                if plst[i] * nlst[idx] < m:
                    idx += 1
                else:
                    total += idx
                    break
            else:
                total += idx
        if total < K:
            l = m
        else:
            r = m
    ans = l
elif K <= np+zp:
    ans = 0
else:
    l = 0
    r = 10**18+1
    while l+1 < r:
        m = (l+r)//2
        total = np+zp
        tmp = 0
        idx = 0
        for i in range(p)[::-1]:
            while idx < p:
                if plst[i] * plst[idx] < m:
                    idx += 1
                else:
                    tmp += idx
                    break
            else:
                tmp += idx
            if plst[i] * plst[i] < m: tmp -= 1
        tmp //= 2
        total += tmp
        tmp = 0
        idx = 0 
        for i in range(n):
            while idx < n:
                if nlst[i] * nlst[-idx-1] < m:
                    idx += 1
                else:
                    tmp += idx
                    break
            else:
                tmp += idx
            if nlst[i] * nlst[i] < m: tmp -= 1
        tmp //= 2
        total += tmp
        if total < K:
            l = m      
        else:
            r = m
    ans = l
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
a = [int(i) for i in input().split()]
a.sort()
L = -10**18-1
R = 10**18+1
while L+1 < R:
    M = (L+R)//2
    total = 0
    for i in range(n):
        l = -1
        r = n
        if a[i] < 0:
            while l+1 < r:
                m = (l+r)//2
                if a[m] * a[i] < M:
                    r = m
                else:
                    l = m
            total += n-r
        else:
            while l+1 < r:
                m = (l+r)//2
                if a[m] * a[i] < M:
                    l = m
                else:
                    r = m
            total += r
        if a[i]*a[i] < M: total -= 1
    total //= 2
    if total < k:
        L = M
    else:
        R = M
print(L)

Fixed submission:
N,K = map(int,input().split())
plst = []
nlst = []
p = 0
z = 0
n = 0
for i in map(int,input().split()):
    if i > 0:
        p += 1
        plst.append(i)
    elif i == 0:
        z += 1
    else:
        n += 1
        nlst.append(i)
plst.sort()
nlst.sort()
zp = (p+n)*z + z*(z-1)//2
np = p*n
if K <= np:
    l = -10**18-1
    r = 0
    while l+1 < r:
        m = (l+r)//2
        total = 0
        idx = 0
        for i in range(p):
            while idx < n:
                if plst[i] * nlst[idx] < m:
                    idx += 1
                else:
                    total += idx
                    break
            else:
                total += idx
        if total < K:
            l = m
        else:
            r = m
    ans = l
elif K <= np+zp:
    ans = 0
else:
    l = 0
    r = 10**18+1
    while l+1 < r:
        m = (l+r)//2
        total = np+zp
        tmp = 0
        idx = 0
        for i in range(p)[::-1]:
            while idx < p:
                if plst[i] * plst[idx] < m:
                    idx += 1
                else:
                    tmp += idx
                    break
            else:
                tmp += idx
            if plst[i] * plst[i] < m: tmp -= 1
        tmp //= 2
        total += tmp
        tmp = 0
        idx = 0 
        for i in range(n):
            while idx < n:
                if nlst[i] * nlst[-idx-1] < m:
                    idx += 1
                else:
                    tmp += idx
                    break
            else:
                tmp += idx
            if nlst[i] * nlst[i] < m: tmp -= 1
        tmp //= 2
        total += tmp
        if total < K:
            l = m      
        else:
            r = m
    ans = l
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
a = [int(i) for i in input().split()]
a.sort()
L = -10**18-1
R = 10**18+1
while L+1 < R:
    M = (L+R)//2
    total = 0
    for i in range(n):
        l = -1
        r = n
        if a[i] < 0:
            while l+1 < r:
                m = (l+r)//2
                if a[m] * a[i] < M:
                    r = m
                else:
                    l = m
            total += n-r
        else:
            while l+1 < r:
                m = (l+r)//2
                if a[m] * a[i] < M:
                    l = m
                else:
                    r = m
            total += r
        if a[i]*a[i] < M: total -= 1
    total //= 2
    if total < k:
        L = M
    else:
        R = M
print(L)

Fixed submission:
N,K = map(int,input().split())
plst = []
nlst = []
p = 0
z = 0
n = 0
for i in map(int,input().split()):
    if i > 0:
        p += 1
        plst.append(i)
    elif i == 0:
        z += 1
    else:
        n += 1
        nlst.append(i)
plst.sort()
nlst.sort()
zp = (p+n)*z + z*(z-1)//2
np = p*n
if K <= np:
    l = -10**18-1
    r = 0
    while l+1 < r:
        m = (l+r)//2
        total = 0
        idx = 0
        for i in range(p):
            while idx < n:
                if plst[i] * nlst[idx] < m:
                    idx += 1
                else:
                    total += idx
                    break
            else:
                total += idx
        if total < K:
            l = m
        else:
            r = m
    ans = l
elif K <= np+zp:
    ans = 0
else:
    l = 0
    r = 10**18+1
    while l+1 < r:
        m = (l+r)//2
        total = np+zp
        tmp = 0
        idx = 0
        for i in range(p)[::-1]:
            while idx < p:
                if plst[i] * plst[idx] < m:
                    idx += 1
                else:
                    tmp += idx
                    break
            else:
                tmp += idx
            if plst[i] * plst[i] < m: tmp -= 1
        tmp //= 2
        total += tmp
        tmp = 0
        idx = 0 
        for i in range(n):
            while idx < n:
                if nlst[i] * nlst[-idx-1] < m:
                    idx += 1
                else:
                    tmp += idx
                    break
            else:
                tmp += idx
            if nlst[i] * nlst[i] < m: tmp -= 1
        tmp //= 2
        total += tmp
        if total < K:
            l = m      
        else:
            r = m
    ans = l
print(ans)

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

lst.sort()
print(lst[k-1])

Fixed submission:
N,K = map(int,input().split())
plst = []
nlst = []
p = 0
z = 0
n = 0
for i in map(int,input().split()):
    if i > 0:
        p += 1
        plst.append(i)
    elif i == 0:
        z += 1
    else:
        n += 1
        nlst.append(i)
plst.sort()
nlst.sort()
zp = (p+n)*z + z*(z-1)//2
np = p*n
if K <= np:
    l = -10**18-1
    r = 0
    while l+1 < r:
        m = (l+r)//2
        total = 0
        idx = 0
        for i in range(p):
            while idx < n:
                if plst[i] * nlst[idx] < m:
                    idx += 1
                else:
                    total += idx
                    break
            else:
                total += idx
        if total < K:
            l = m
        else:
            r = m
    ans = l
elif K <= np+zp:
    ans = 0
else:
    l = 0
    r = 10**18+1
    while l+1 < r:
        m = (l+r)//2
        total = np+zp
        tmp = 0
        idx = 0
        for i in range(p)[::-1]:
            while idx < p:
                if plst[i] * plst[idx] < m:
                    idx += 1
                else:
                    tmp += idx
                    break
            else:
                tmp += idx
            if plst[i] * plst[i] < m: tmp -= 1
        tmp //= 2
        total += tmp
        tmp = 0
        idx = 0 
        for i in range(n):
            while idx < n:
                if nlst[i] * nlst[-idx-1] < m:
                    idx += 1
                else:
                    tmp += idx
                    break
            else:
                tmp += idx
            if nlst[i] * nlst[i] < m: tmp -= 1
        tmp //= 2
        total += tmp
        if total < K:
            l = m      
        else:
            r = m
    ans = l
print(ans)