Buggy python submission (verdict: Runtime Error):
def solve_m(k, a_m, a_p):
    def syaku(mid):
        """mid以下になる組の数を数える"""
        rm = 0
        cnt = 0
        for lp, num in enumerate(a_p):
            while True:
                if rm >= len(a_m) or num * a_m[rm] > mid :
                    break
                else:
                    rm += 1
            cnt += rm
        return cnt
                
    ok, ng = 1, -10 ** 20
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if syaku(mid) >= k:
            ok = mid
        else:
            ng = mid
    return ok

    
def solve_p(k, a_m, a_p):
    print(aaa)
    def syaku(mid):
        """mid以下になる組の数を数える"""
        r = len(a_p)
        cnt = 0
        for l, num in enumerate(a_p):
            while True:
                if r == 0 or num * a_p[r - 1] <= mid:
                    break
                else:
                    r -= 1
            cnt += r
            if l <= r:
                cnt -= 1
        r = len(a_m)
        for l, num in enumerate(a_m):
            while True:
                if r == 0 or num * a_m[r - 1] <= mid:
                    break
                else:
                    r -= 1
            cnt += r
            if l <= r:
                cnt -= 1
        return cnt

    a_m = sorted([-num for num in a_m])
    ok, ng = 10 ** 20, -1
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if syaku(mid) >= k:
            ok = mid
        else:
            ng = mid
    return ok


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

cnt_p, cnt_m, cnt_0 = 0, 0, 0
tmp_p, tmp_m, tmp_0 = 0, 0, 0
for num in a:
    if num > 0:
        tmp_p += 1
    elif num < 0:
        tmp_m += 1
    else:
        tmp_0 += 1
cnt_p += tmp_p * (tmp_p - 1) // 2 + tmp_m * (tmp_m - 1) // 2
cnt_m += tmp_p * tmp_m
cnt_0 += (tmp_p + tmp_m) * tmp_0 + tmp_0 * (tmp_0 - 1) // 2
# print(cnt_p, cnt_m, cnt_0)

a_m = sorted([a[i] for i in range(n) if a[i] < 0])
a_p = sorted([a[i] for i in range(n) if a[i] > 0])

if k <= cnt_m:
    ans = solve_m(k, a_m, a_p)
elif cnt_m < k <= cnt_m + cnt_0:
    ans = 0
else:
    ans = solve_p(k - cnt_m - cnt_0, a_m, a_p)
      
print(ans)



Fixed submission:
def solve_m(k, a_m, a_p):
    def syaku(mid):
        """mid以下になる組の数を数える"""
        rm = 0
        cnt = 0
        for lp, num in enumerate(a_p):
            while True:
                if rm >= len(a_m) or num * a_m[rm] > mid :
                    break
                else:
                    rm += 1
            cnt += rm
        return cnt
                
    ok, ng = 1, -10 ** 20
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if syaku(mid) >= k:
            ok = mid
        else:
            ng = mid
    return ok

    
def solve_p(k, a_m, a_p):
    def syaku(mid):
        """mid以下になる組の数を数える"""
        r = len(a_p)
        cnt = 0
        for l, num in enumerate(a_p):
            while True:
                if r == 0 or num * a_p[r - 1] <= mid:
                    break
                else:
                    r -= 1
            cnt += r
            if l <= r - 1:
                cnt -= 1
        r = len(a_m)
        for l, num in enumerate(a_m):
            while True:
                if r == 0 or num * a_m[r - 1] <= mid:
                    break
                else:
                    r -= 1
            cnt += r
            if l <= r - 1:
                cnt -= 1
        return cnt // 2

    a_m = sorted([-num for num in a_m])
    ok, ng = 10 ** 20, -1
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if syaku(mid) >= k:
            ok = mid
        else:
            ng = mid
    return ok


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

cnt_p, cnt_m, cnt_0 = 0, 0, 0
tmp_p, tmp_m, tmp_0 = 0, 0, 0
for num in a:
    if num > 0:
        tmp_p += 1
    elif num < 0:
        tmp_m += 1
    else:
        tmp_0 += 1
cnt_p += tmp_p * (tmp_p - 1) // 2 + tmp_m * (tmp_m - 1) // 2
cnt_m += tmp_p * tmp_m
cnt_0 += (tmp_p + tmp_m) * tmp_0 + tmp_0 * (tmp_0 - 1) // 2
# print(cnt_p, cnt_m, cnt_0)

a_m = sorted([a[i] for i in range(n) if a[i] < 0])
a_p = sorted([a[i] for i in range(n) if a[i] > 0])

if k <= cnt_m:
    ans = solve_m(k, a_m, a_p)
elif cnt_m < k <= cnt_m + cnt_0:
    ans = 0
else:
    ans = solve_p(k - cnt_m - cnt_0, a_m, a_p)
      
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left, bisect_right
import sys
input = sys.stdin.readline


def solve(mid):
    # mid以下の通り数を求める
    cnt = 0
    if mid > 0:
        # 正と正の組み合わせ
        for i, num in enumerate(plus):
            tmp = mid // num
            ind = bisect_right(plus, tmp, lo=i+1)
            cnt += ind - (i + 1)
        # 負と負の組み合わせ
        for i, num in enumerate(minus_plus):
            tmp = mid // num
            ind = bisect_right(minus_plus, tmp, lo=i+1)
            cnt += ind - (i + 1)
    #print(cnt)

    if mid >= 0:
        # 正と負の組み合わせ
        cnt += cnt_minus
    #print(cnt)

    if mid < 0:
        # 正と負の組み合わせ
        if len(plus) > len(minus_plus):
            for i, num in enumerate(plus):
                tmp = -((mid) // num)
                ind = bisect_left(minus_plus, tmp)
                cnt += len(minus_plus) - ind
        else:
            for i, num in enumerate(minus_plus):
                tmp = -((mid) // num)
                ind = bisect_left(plus, tmp)
                cnt += len(plus) - ind
    #print(cnt)
    
    if mid >= 0:
        cnt += cnt_0
    #print(cnt)

    return cnt >= k


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

plus = []
minus_plus = []
cnt0 = 0
for i in range(n):
    if a[i] > 0:
        plus.append(a[i])
    elif a[i] < 0:
        minus_plus.append(-a[i])
    else:
        cnt0 += 1
plus = sorted(plus)
minus_plus = sorted(minus_plus)

# 答えが0になる場合
cnt_0 = (len(plus) + len(minus_plus)) * cnt0
cnt_0 += cnt0 * (cnt0 - 1) // 2

# 答えが負になるとき
cnt_minus = len(minus_plus) * len(plus)

ng = -10**18 - 1
ok = 10**18 + 1
while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    if solve(mid):
        ok = mid
    else:
        ng = mid
print(ok)
"""
tmp = []
for i in range(n):
    for j in range(i + 1, n):
        tmp.append(a[i] * a[j])
tmp = sorted(tmp)
print(tmp[0:10])
print(tmp[10:20])
print(tmp[20:30])
print(tmp[30:40])
print(tmp[40:50])"""

Fixed submission:
def solve_m(k, a_m, a_p):
    def syaku(mid):
        """mid以下になる組の数を数える"""
        rm = 0
        cnt = 0
        for lp, num in enumerate(a_p):
            while True:
                if rm >= len(a_m) or num * a_m[rm] > mid :
                    break
                else:
                    rm += 1
            cnt += rm
        return cnt
                
    ok, ng = 1, -10 ** 20
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if syaku(mid) >= k:
            ok = mid
        else:
            ng = mid
    return ok

    
def solve_p(k, a_m, a_p):
    def syaku(mid):
        """mid以下になる組の数を数える"""
        r = len(a_p)
        cnt = 0
        for l, num in enumerate(a_p):
            while True:
                if r == 0 or num * a_p[r - 1] <= mid:
                    break
                else:
                    r -= 1
            cnt += r
            if l <= r - 1:
                cnt -= 1
        r = len(a_m)
        for l, num in enumerate(a_m):
            while True:
                if r == 0 or num * a_m[r - 1] <= mid:
                    break
                else:
                    r -= 1
            cnt += r
            if l <= r - 1:
                cnt -= 1
        return cnt // 2

    a_m = sorted([-num for num in a_m])
    ok, ng = 10 ** 20, -1
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if syaku(mid) >= k:
            ok = mid
        else:
            ng = mid
    return ok


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

cnt_p, cnt_m, cnt_0 = 0, 0, 0
tmp_p, tmp_m, tmp_0 = 0, 0, 0
for num in a:
    if num > 0:
        tmp_p += 1
    elif num < 0:
        tmp_m += 1
    else:
        tmp_0 += 1
cnt_p += tmp_p * (tmp_p - 1) // 2 + tmp_m * (tmp_m - 1) // 2
cnt_m += tmp_p * tmp_m
cnt_0 += (tmp_p + tmp_m) * tmp_0 + tmp_0 * (tmp_0 - 1) // 2
# print(cnt_p, cnt_m, cnt_0)

a_m = sorted([a[i] for i in range(n) if a[i] < 0])
a_p = sorted([a[i] for i in range(n) if a[i] > 0])

if k <= cnt_m:
    ans = solve_m(k, a_m, a_p)
elif cnt_m < k <= cnt_m + cnt_0:
    ans = 0
else:
    ans = solve_p(k - cnt_m - cnt_0, a_m, a_p)
      
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left, bisect_right
import sys
input = sys.stdin.readline


def solve(mid):
    # mid以下の通り数を求める
    cnt = 0
    if mid > 0:
        # 正と正の組み合わせ
        for i, num in enumerate(plus):
            tmp = mid // num
            ind = bisect_right(plus, tmp, lo=i+1)
            cnt += ind - (i + 1)
        # 負と負の組み合わせ
        for i, num in enumerate(minus_plus):
            tmp = mid // num
            ind = bisect_right(minus_plus, tmp, lo=i+1)
            cnt += ind - (i + 1)
    #print(cnt)

    if mid >= 0:
        # 正と負の組み合わせ
        cnt += cnt_minus
    #print(cnt)

    if mid < 0:
        # 正と負の組み合わせ
        if len(plus) < len(minus_plus):
            for i, num in enumerate(plus):
                tmp = -((mid) // num)
                ind = bisect_left(minus_plus, tmp)
                cnt += len(minus_plus) - ind
        else:
            for i, num in enumerate(minus_plus):
                tmp = -((mid) // num)
                ind = bisect_left(plus, tmp)
                cnt += len(plus) - ind
    #print(cnt)
    
    if mid >= 0:
        cnt += cnt_0
    #print(cnt)

    if cnt >= k:
        return True
    else:
        return False


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

plus = []
minus_plus = []
cnt0 = 0
for i in range(n):
    if a[i] > 0:
        plus.append(a[i])
    elif a[i] < 0:
        minus_plus.append(-a[i])
    else:
        cnt0 += 1
plus = sorted(plus)
minus_plus = sorted(minus_plus)

# 答えが0になる場合
cnt_0 = (len(plus) + len(minus_plus)) * cnt0
cnt_0 += cnt0 * (cnt0 - 1) // 2

# 答えが負になるとき
cnt_minus = len(minus_plus) * len(plus)

ng = -10**18 - 1
ok = 10**18 + 1
while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    if solve(mid):
        ok = mid
    else:
        ng = mid
print(ok)
"""
tmp = []
for i in range(n):
    for j in range(i + 1, n):
        tmp.append(a[i] * a[j])
tmp = sorted(tmp)
print(tmp[0:10])
print(tmp[10:20])
print(tmp[20:30])
print(tmp[30:40])
print(tmp[40:50])"""

Fixed submission:
def solve_m(k, a_m, a_p):
    def syaku(mid):
        """mid以下になる組の数を数える"""
        rm = 0
        cnt = 0
        for lp, num in enumerate(a_p):
            while True:
                if rm >= len(a_m) or num * a_m[rm] > mid :
                    break
                else:
                    rm += 1
            cnt += rm
        return cnt
                
    ok, ng = 1, -10 ** 20
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if syaku(mid) >= k:
            ok = mid
        else:
            ng = mid
    return ok

    
def solve_p(k, a_m, a_p):
    def syaku(mid):
        """mid以下になる組の数を数える"""
        r = len(a_p)
        cnt = 0
        for l, num in enumerate(a_p):
            while True:
                if r == 0 or num * a_p[r - 1] <= mid:
                    break
                else:
                    r -= 1
            cnt += r
            if l <= r - 1:
                cnt -= 1
        r = len(a_m)
        for l, num in enumerate(a_m):
            while True:
                if r == 0 or num * a_m[r - 1] <= mid:
                    break
                else:
                    r -= 1
            cnt += r
            if l <= r - 1:
                cnt -= 1
        return cnt // 2

    a_m = sorted([-num for num in a_m])
    ok, ng = 10 ** 20, -1
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if syaku(mid) >= k:
            ok = mid
        else:
            ng = mid
    return ok


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

cnt_p, cnt_m, cnt_0 = 0, 0, 0
tmp_p, tmp_m, tmp_0 = 0, 0, 0
for num in a:
    if num > 0:
        tmp_p += 1
    elif num < 0:
        tmp_m += 1
    else:
        tmp_0 += 1
cnt_p += tmp_p * (tmp_p - 1) // 2 + tmp_m * (tmp_m - 1) // 2
cnt_m += tmp_p * tmp_m
cnt_0 += (tmp_p + tmp_m) * tmp_0 + tmp_0 * (tmp_0 - 1) // 2
# print(cnt_p, cnt_m, cnt_0)

a_m = sorted([a[i] for i in range(n) if a[i] < 0])
a_p = sorted([a[i] for i in range(n) if a[i] > 0])

if k <= cnt_m:
    ans = solve_m(k, a_m, a_p)
elif cnt_m < k <= cnt_m + cnt_0:
    ans = 0
else:
    ans = solve_p(k - cnt_m - cnt_0, a_m, a_p)
      
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
import sys
input = sys.stdin.readline


def solve(mid):
    # mid以下の通り数を求める
    cnt = 0
    if mid > 0:
        # 正と正の組み合わせ
        for i, num in enumerate(plus):
            tmp = mid // num
            ind = bisect.bisect_right(plus, tmp, lo=i+1)
            cnt += ind - (i + 1)
        # 負と負の組み合わせ
        for i, num in enumerate(minus_plus):
            tmp = mid // num
            ind = bisect.bisect_right(minus_plus, tmp, lo=i+1)
            cnt += ind - (i + 1)
    #print(cnt)

    if mid >= 0:
        # 正と負の組み合わせ
        cnt += len(minus_plus) * len(plus)
    #print(cnt)

    if mid < 0:
        # 正と負の組み合わせ
        if len(plus) > len(minus_plus):
            for i, num in enumerate(plus):
                tmp = -((mid) // num)
                ind = bisect.bisect_left(minus_plus, tmp)
                cnt += len(minus_plus) - ind
        else:
            for i, num in enumerate(minus_plus):
                tmp = -((mid) // num)
                ind = bisect.bisect_left(plus, tmp)
                cnt += len(plus) - ind
    #print(cnt)
    
    if mid >= 0:
        cnt += cnt_0
    #print(cnt)

    if cnt >= k:
        return True
    else:
        return False


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

plus = []
minus_plus = []
cnt0 = 0
for i in range(n):
    if a[i] > 0:
        plus.append(a[i])
    elif a[i] < 0:
        minus_plus.append(-a[i])
    else:
        cnt0 += 1
plus = sorted(plus)
minus_plus = sorted(minus_plus)

# 答えが0になる場合
cnt_0 = (len(plus) + len(minus_plus)) * cnt0
cnt_0 += cnt0 * (cnt0 - 1) // 2


ng = -10**20
ok = 10**20

while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    if solve(mid):
        ok = mid
    else:
        ng = mid
print(ok)
"""
tmp = []
for i in range(n):
    for j in range(i + 1, n):
        tmp.append(a[i] * a[j])
tmp = sorted(tmp)
print(tmp[0:10])
print(tmp[10:20])
print(tmp[20:30])
print(tmp[30:40])
print(tmp[40:50])"""

Fixed submission:
def solve_m(k, a_m, a_p):
    def syaku(mid):
        """mid以下になる組の数を数える"""
        rm = 0
        cnt = 0
        for lp, num in enumerate(a_p):
            while True:
                if rm >= len(a_m) or num * a_m[rm] > mid :
                    break
                else:
                    rm += 1
            cnt += rm
        return cnt
                
    ok, ng = 1, -10 ** 20
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if syaku(mid) >= k:
            ok = mid
        else:
            ng = mid
    return ok

    
def solve_p(k, a_m, a_p):
    def syaku(mid):
        """mid以下になる組の数を数える"""
        r = len(a_p)
        cnt = 0
        for l, num in enumerate(a_p):
            while True:
                if r == 0 or num * a_p[r - 1] <= mid:
                    break
                else:
                    r -= 1
            cnt += r
            if l <= r - 1:
                cnt -= 1
        r = len(a_m)
        for l, num in enumerate(a_m):
            while True:
                if r == 0 or num * a_m[r - 1] <= mid:
                    break
                else:
                    r -= 1
            cnt += r
            if l <= r - 1:
                cnt -= 1
        return cnt // 2

    a_m = sorted([-num for num in a_m])
    ok, ng = 10 ** 20, -1
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if syaku(mid) >= k:
            ok = mid
        else:
            ng = mid
    return ok


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

cnt_p, cnt_m, cnt_0 = 0, 0, 0
tmp_p, tmp_m, tmp_0 = 0, 0, 0
for num in a:
    if num > 0:
        tmp_p += 1
    elif num < 0:
        tmp_m += 1
    else:
        tmp_0 += 1
cnt_p += tmp_p * (tmp_p - 1) // 2 + tmp_m * (tmp_m - 1) // 2
cnt_m += tmp_p * tmp_m
cnt_0 += (tmp_p + tmp_m) * tmp_0 + tmp_0 * (tmp_0 - 1) // 2
# print(cnt_p, cnt_m, cnt_0)

a_m = sorted([a[i] for i in range(n) if a[i] < 0])
a_p = sorted([a[i] for i in range(n) if a[i] > 0])

if k <= cnt_m:
    ans = solve_m(k, a_m, a_p)
elif cnt_m < k <= cnt_m + cnt_0:
    ans = 0
else:
    ans = solve_p(k - cnt_m - cnt_0, a_m, a_p)
      
print(ans)

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


def solve(mid):
    # mid以下の通り数を求める
    cnt = 0
    if mid > 0:
        # 正と正の組み合わせ
        for i, num in enumerate(plus):
            tmp = mid // num
            ind = bisect.bisect_right(plus, tmp, lo=i+1)
            cnt += ind - (i + 1)
        # 負と負の組み合わせ
        for i, num in enumerate(minus_plus):
            tmp = mid // num
            ind = bisect.bisect_right(minus_plus, tmp, lo=i+1)
            cnt += ind - (i + 1)
    #print(cnt)

    if mid >= 0:
        # 正と負の組み合わせ
        cnt += len(minus_plus) * len(plus)
    #print(cnt)

    if mid < 0:
        # 正と負の組み合わせ
        for i, num in enumerate(plus):
            tmp = -((mid) // num)
            ind = bisect.bisect_left(minus_plus, tmp)
            cnt += len(minus_plus) - ind
    #print(cnt)
    
    if mid >= 0:
        cnt += cnt_0
    #print(cnt)

    if cnt >= k:
        return True
    else:
        return False


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

plus = []
minus_plus = []
cnt0 = 0
for i in range(n):
    if a[i] > 0:
        plus.append(a[i])
    elif a[i] < 0:
        minus_plus.append(-a[i])
    else:
        cnt0 += 1
plus = sorted(plus)
minus_plus = sorted(minus_plus)

# 答えが0になる場合
cnt_0 = (len(plus) + len(minus_plus)) * cnt0
cnt_0 += cnt0 * (cnt0 - 1) // 2


ng = -10**20
ok = 10**20

while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    if solve(mid):
        ok = mid
    else:
        ng = mid
print(ok)
"""
tmp = []
for i in range(n):
    for j in range(i + 1, n):
        tmp.append(a[i] * a[j])
tmp = sorted(tmp)
print(tmp[0:10])
print(tmp[10:20])
print(tmp[20:30])
print(tmp[30:40])
print(tmp[40:50])"""

Fixed submission:
def solve_m(k, a_m, a_p):
    def syaku(mid):
        """mid以下になる組の数を数える"""
        rm = 0
        cnt = 0
        for lp, num in enumerate(a_p):
            while True:
                if rm >= len(a_m) or num * a_m[rm] > mid :
                    break
                else:
                    rm += 1
            cnt += rm
        return cnt
                
    ok, ng = 1, -10 ** 20
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if syaku(mid) >= k:
            ok = mid
        else:
            ng = mid
    return ok

    
def solve_p(k, a_m, a_p):
    def syaku(mid):
        """mid以下になる組の数を数える"""
        r = len(a_p)
        cnt = 0
        for l, num in enumerate(a_p):
            while True:
                if r == 0 or num * a_p[r - 1] <= mid:
                    break
                else:
                    r -= 1
            cnt += r
            if l <= r - 1:
                cnt -= 1
        r = len(a_m)
        for l, num in enumerate(a_m):
            while True:
                if r == 0 or num * a_m[r - 1] <= mid:
                    break
                else:
                    r -= 1
            cnt += r
            if l <= r - 1:
                cnt -= 1
        return cnt // 2

    a_m = sorted([-num for num in a_m])
    ok, ng = 10 ** 20, -1
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if syaku(mid) >= k:
            ok = mid
        else:
            ng = mid
    return ok


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

cnt_p, cnt_m, cnt_0 = 0, 0, 0
tmp_p, tmp_m, tmp_0 = 0, 0, 0
for num in a:
    if num > 0:
        tmp_p += 1
    elif num < 0:
        tmp_m += 1
    else:
        tmp_0 += 1
cnt_p += tmp_p * (tmp_p - 1) // 2 + tmp_m * (tmp_m - 1) // 2
cnt_m += tmp_p * tmp_m
cnt_0 += (tmp_p + tmp_m) * tmp_0 + tmp_0 * (tmp_0 - 1) // 2
# print(cnt_p, cnt_m, cnt_0)

a_m = sorted([a[i] for i in range(n) if a[i] < 0])
a_p = sorted([a[i] for i in range(n) if a[i] > 0])

if k <= cnt_m:
    ans = solve_m(k, a_m, a_p)
elif cnt_m < k <= cnt_m + cnt_0:
    ans = 0
else:
    ans = solve_p(k - cnt_m - cnt_0, a_m, a_p)
      
print(ans)