Problem:


Score: 400 points

Problem Statement

We have N integers A_1, A_2, ..., A_N.

There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list?

Constraints

All values in input are integers.

2 \leq N \leq 2 \times 10^5

1 \leq K \leq \frac{N(N-1)}{2}

-10^9 \leq A_i \leq 10^9\ (1 \leq i \leq N)

Input

Input is given from Standard Input in the following format:

N K
A_1 A_2 \dots A_N

Output

Print the answer.

Sample Input 1

4 3
3 3 -4 -2

Sample Output 1

-6

There are six ways to form a pair. The products of those pairs are 9, -12, -6, -12, -6, 8.

Sorting those numbers in ascending order, we have -12, -12, -6, -6, 8, 9. The third number in this list is -6.

Sample Input 2

10 40
5 4 3 2 -1 0 0 0 0 0

Sample Output 2

6

Sample Input 3

30 413
-170202098 -268409015 537203564 983211703 21608710 -443999067 -937727165 -97596546 -372334013 398994917 -972141167 798607104 -949068442 -959948616 37909651 0 886627544 -20098238 0 -948955241 0 -214720580 277222296 -18897162 834475626 0 -425610555 110117526 663621752 0

Sample Output 3

448283280358331064



Sample input:
4 3
3 3 -4 -2


Sample output:
-6

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))

li = []
for i in range(N-1):
    for j in range(i, N):
        if i == j:
            continue
        li.append(A[i]*A[j])

li.sort()
print(li[K-1])

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations

N, K = [int(v) for v in input().strip().split()]
A = [int(v) for v in input().strip().split()]

items = []
for k1, k2 in combinations(range(N), 2):
    v = A[k1] * A[k2]
    if len(items) < K:
        items.append(v)
        items.sort()
    elif items[-1] > v:
        items.append(v)
        items.sort()
        items = items[:-1]
    else:
        continue
print(items[-1])

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = []
for i in range(0, n-1):
    for j in range(i+1, n):
        ans.append(a[i] * a[j])
ans.sort()
print(ans[k-1])

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations as cmb
n, k = map(int, input().split())
A = list(map(int, input().split()))

l = []
for v in cmb(A, 2):
  dot = v[0] * v[1]
  l.append(dot)
print(sorted(l)[k-1])

Submission status: Time Limit Exceeded

Solution code:
import itertools
N, K = map(int, input().split())
A = list(map(int, input().split()))

C = list(itertools.combinations(A, 2))
ans = []
for c in C:
    ans.append(c[0] * c[1])
ans.sort()
print(ans[K-1])

Submission status: Time Limit Exceeded

Solution code:
import heapq
import itertools


def main():
    n, k = map(int, input().split())
    a = sorted(map(int, input().split()))
    h = []

    for i in range(k):
        for j in range(i + 1, len(a)):
            heapq.heappush(h, a[i] * a[j])

    for i in range(k - 1):
        heapq.heappop(h)

    print(heapq.heappop(h))


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int, input().split())
A = list(map(int, input().split()))

l=[]

for i in range(N-1):
    for j in range(i+1,N):
        l.append(A[i]*A[j])
        
l.sort()

print(l[K-1])

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-

[N, K] = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

products = []
for i in range(len(A)):
    for j in range(i+1, len(A)):
        products.append(A[i] * A[j])

sorted_products = sorted(products)

print(sorted_products[K - 1])

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
from itertools import combinations


def solve(*args: str) -> str:
    n, k = map(int, args[0].split())
    A = list(map(int, args[1].split()))

    D = [a*b for a, b in combinations(A, 2)]
    D.sort()

    return str(D[k-1])


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

Submission status: Time Limit Exceeded

Solution code:
# AtCoder Beginner Contest 155: D (2020/02/16)
N, K = map(int, input().split())
l = input().split()
A = []
for i in range(N):
    A.append(int(l[i]))
B = []
for i in range(N-1):
    for j in range(i+1,N):
        B.append(A[i]*A[j])
B.sort()
print(B[K-1])

Submission status: Time Limit Exceeded

Solution code:
import itertools
N, K = map(int, input().split())
A = list(map(int, input().split()))
answer_list = []
for v in itertools.combinations(A, 2):
    # print(v)
    answer_list.append(v[0] * v[1])
answer_list.sort()
print(answer_list[K-1])

Submission status: Time Limit Exceeded

Solution code:
def get_comb(arr):
    res = []
    for i in range(len(arr)):
        for j in range(i + 1, len(arr)):
            res.append(arr[i] * arr[j])
    return res
N, K = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
products = sorted(get_comb(arr))
print(products[K - 1])

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-

n, g = map(int, input().split())
A = [int(i) for i in input().split()]

B = []
for j in range(n):
    for k in range(j+1, n):
        B.append(A[j]*A[k])

B.sort()
print(B[g-1])

Submission status: Time Limit Exceeded

Solution code:
def K2last_naive(N, K, A):
    products = []
    for i in range(N):
        for j in range(i + 1, N):
            products.append(A[i] * A[j])
    products.sort()
    return products[K - 1]

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    print(K2last_naive(N, K, A))

main()

Submission status: Time Limit Exceeded

Solution code:
N, K = [int(n) for n in input().split()]
A = [int(n) for n in input().split()]

B = []
for i in range(N - 1):
    for j in range(i+1,N):
        B.append(A[i] * A[j])

C = sorted(B)

print(C[K-1])

Submission status: Time Limit Exceeded

Solution code:
import itertools
n,m=map(int,input().split())
l = list(map(int,input().split()))
a=[]

for ll in itertools.combinations(l, 2):
  a.append(ll[0]*ll[1])
  
print(sorted(a)[m-1])

Submission status: Time Limit Exceeded

Solution code:
n,k = [ int(i) for i in input().split(" ")]
arr = [ int(i) for i in input().split(" ")]

tmp = []
for i in range(len(arr)):
  for j in range(i+1, len(arr)):
    tmp.append(arr[i] * arr[j])

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

Submission status: Time Limit Exceeded

Solution code:
import itertools
N, K = map(int, input().split())
A = list(map(int, input().split()))

L = [i*j for i,j in itertools.combinations(A,2)]

L.sort()

print(L[K-1])

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
out=[]

for i in range(n-1):
    for j in range(i+1,n):
        out.append(a[i]*a[j])
out.sort()
print(out[k-1])

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
b = a[::-1]

ok, ng = -10**19, 10**19
while abs(ng-ok) > 1:
	x = (ng+ok)//2
	res = 0
	for c in a:
		if c*c < x:
			res -= 1
		if c == 0:
			if x > 0:
				res += n
		elif c > 0:
			#res += bisect(a, x/c - 1e-18)
			if c * a[0] >= x:
				pass
			else:
				l, r = 0, n
				while r-l > 1:
					y = (l+r)//2
					if a[y]*c < x:
						l = y
					else:
						r = y
				res += l+1
		else:
			#res += n - bisect(a, x/c + 1e-18)
			if c * b[0] >= x:
				pass
			else:
				l, r = 0, n
				while r-l > 1:
					y = (l+r)//2
					if b[y]*c < x:
						l = y
					else:
						r = y
				res += l+1
	res //= 2
	#print(x, res)
	if res < k:
		ok = x
	else:
		ng = x

print(ng-1)

Submission status: Time Limit Exceeded

Solution code:
defined = list(map(int, input().split()))
numbers = list(map(int, input().split()))

order = defined[1]

answers = list()
for i1 in range(0, len(numbers)):
    for i2 in range(0, len(numbers)):
        if(i1 < i2):
            answers.append(numbers[i1]*numbers[i2])

answers.sort()
print(answers[order-1])

Submission status: Time Limit Exceeded

Solution code:
import itertools
N, K = map(int, input().split())
A = [int(x) for x in input().split()]
products = []
for (n, m) in itertools.combinations(range(N),2):
    tmp = A[n]*A[m]
    products.append(tmp)
products.sort()
print(products[K-1])

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
arr=sorted([a[i]*a[j] for i in range(n) for j in range(i+1,n) if i!=j])

print(arr[k-1])

Submission status: Time Limit Exceeded

Solution code:
import itertools
n,k = map(int,input().split())
l=list(map(int,input().split()))
l=list(itertools.combinations(l,2))
a=[]
for i in l:
    x,y=map(int,i)
    a.append(x*y)
print(sorted(a)[k-1])

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
i=0

result=[]
while i<n-1:
    j=i+1
    while j<n:
        result.append(a[i]*a[j])
        #print(a[i],a[j])
 #       print(result)
        j+=1
    i+=1

result.sort()
#print(a)
print(result[k-1])

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
b = []
for i in range(n-1):
  for j in range(i+1,n):
    b.append(a[i]*a[j])
b.sort()
print(b[k-1])

Submission status: Time Limit Exceeded

Solution code:
import itertools as it
import sys
input = sys.stdin.readline

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

for i in it.combinations(a, 2):
    cnt.append(i[0]*i[1])

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

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
aList = list(map(int, input().split()))
multipleList = []
for i in range(n):
  for j in range(i+1, n):
    multipleList.append(aList[i] * aList[j])
sortedList = sorted(multipleList)

print(sortedList[k-1])

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations
from functools import reduce

N, K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

C = combinations(A, 2)
print(sorted([reduce(lambda y, z: y * z, x) for x in C])[K - 1])

Submission status: Time Limit Exceeded

Solution code:
[N, K] = list(map(int, input().split()))
A = list(map(int, input().split()))
mul = []

for i in range(N):
  for j in range(i+1, N):
    mul.append(A[i]*A[j])
    
mul.sort()
print(mul[K-1])

Submission status: Time Limit Exceeded

Solution code:
import  bisect 

n,k = (int(x) for x in input().split())
a_list = [int(x) for x in input().split()]
res = []

for i,a1 in enumerate(a_list):
  for j,a2 in enumerate(a_list[i+1:]):
    bisect.insort_left(res, a1*a2)

print(res[k-1])

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int,input().split(" "))
A = map(int,input().split(" "))

import itertools

L = []

for x in itertools.combinations(A, 2):
    L.append(x[0]*x[1])

L.sort()

print(L[K-1])

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
from itertools import combinations
N, K = map(int, input().split())
A = map(int, input().split())
c = combinations(A, 2)
tmp = []
for i in c:
    tmp.append(i[0] * i[1])
tmp = sorted(tmp)
print(tmp[K-1])

Submission status: Time Limit Exceeded

Solution code:
import itertools
n, k = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
c = itertools.combinations(a, 2)

print(sorted([i[0]*i[1] for  i in c])[k-1])

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
a = [int(i) for i in input().split()]

l = []
len = len(a)
for i in range(len-1):
    for j in range(i+1,len):
        l.append(a[i]*a[j])


ll = sorted(l)

print(ll[k-1])

Submission status: Time Limit Exceeded

Solution code:
from bisect import bisect_left
from itertools import combinations
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
R = []
for i, j in combinations(A, 2):
    p = i * j
    idx = bisect_left(R, p)
    R.insert(idx, p)
print(R[K-1])

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())

a=list(map(int,input().split()))
l=[]
for i in range(n):
    for j in range(i+1,n):
        l+=(a[i]*a[j]),
        
print(sorted(l)[k-1])#,len(l))

Submission status: Time Limit Exceeded

Solution code:
a, *D, = [list(map(int, s.split())) for s in open(0)] 
D = D[0]
results = []
for i in range(len(D)):
    for j in range(i + 1, len(D)):
        results.append(D[i]*D[j])
    else:
        continue
    break
print(sorted(results)[a[1] - 1])

Submission status: Time Limit Exceeded

Solution code:
import itertools
N, K = map(int, input().split())
A = list(map(int, input().split()))

L = [i*j for i,j in itertools.combinations(A,2)]
L.sort()
print(L[K-1])

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations

def run():
  N, K = map(int, input().split())
  As = list(map(int, input().split()))
  ans_li = []
  for A1, A2 in combinations(As, 2):
    ans_li.append(A1*A2)
  print(sorted(ans_li)[K-1])

if __name__ == '__main__':
  run()

Submission status: Time Limit Exceeded

Solution code:
#coding: utf-8


N, K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

B = []
for i in range(N-1):
    for j in range(i+1, N):
        B.append(A[i] * A[j])

B.sort()
print(B[K-1])

Submission status: Time Limit Exceeded

Solution code:
import itertools

N, K = map(int, input().split())
An = list(map(int, input().split()))

comb = itertools.combinations(An, 2)
ans = []
for c in comb:
    ans.append(c[0]*c[1])

ans.sort()
print(ans[K-1])

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))

alist = []
for i in range(N):
    for j in range(i+1, N):
        alist.append(A[i]*A[j])

alist.sort()
#print(alist)
print(alist[K-1])

Submission status: Time Limit Exceeded

Solution code:
import itertools

N, K = map(int,input().split())
l = list(map(int,input().split()))

tmp = list(itertools.combinations(l,2))
new_list = [i * n for i, n in tmp]

print(sorted(new_list)[K - 1])

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations
N, K = map(int, input().split())
A = list(map(int,input().split()))

result = []
for (x, y) in combinations(A, 2):
  result.append(x * y)

result.sort()

print(result[K-1])

Submission status: Time Limit Exceeded

Solution code:
import itertools
n,k = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]


lst = []
for v in itertools.combinations(a,2):
    lst.append(v[0]*v[1])

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

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations 
def rSubset(arr, r): 
    return list(combinations(arr, r)) 
n,k=map(int,input().split())
arr=list(map(int,input().split()))
x=rSubset(arr,2)
ans=[]
for ar in x:
    prod=1
    for i in ar:
        prod*=i
    ans.append(prod)
ans.sort()
print(ans[k-1])

Submission status: Time Limit Exceeded

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

ans = list()
for i in range(n - 1):
    for j in range(i + 1, n):
        ans.append(a[i] * a[j])
ans.sort()

print(ans[k - 1])

Submission status: Time Limit Exceeded

Solution code:
import itertools

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

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

a.sort()

li = itertools.combinations(a, 2)

b = []

for x, y in li:
    b.append(x*y)

b.sort()

print(b[k-1])

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
n, k = map(int, input().split())
li = list(map(int, input().split()))

import itertools

li_c = list(itertools.combinations(li, 2))
li_x = [c[0]*c[1] for c in li_c]
li_x.sort()

print(li_x[k-1])

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations
from bisect import bisect_left
import sys
sys.setrecursionlimit(10 ** 6)
 

def main():
    N,K = map(int, input().split())
    A = list(map(int, input().split()))
    r = []
    for com in list(combinations(A,2)):
        r.append(com[0]*com[1])
    r.sort()
    print(r[K-1])
    
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
a = [int(x) for x in input().split()]

ans = []
for idx in range(0,n-1):
    for idx2 in range(idx+1,n):
        ans.append(a[idx]*a[idx2])
ans.sort()
print(ans[k-1])

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
A=list(map(int,input().split()))
ans_list=[]

for i in range(0,N-1):
  for j in range(i+1,N):
    ans_list.append(A[i]*A[j])
    
ans_list.sort()
print(ans_list[K-1])

Submission status: Time Limit Exceeded

Solution code:
import heapq
import itertools


def main():
    n, k = map(int, input().split())
    a = map(int, input().split())
    h = []

    for a, b in itertools.combinations(a, 2):
        heapq.heappush(h, a * b)

    for i in range(k - 1):
        heapq.heappop(h)
        
    print(heapq.heappop(h))


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import heapq

N, K = map(int, input().split())
A = list(map(int, input().split()))
# print(N, K, A)

h = []
for i in range(N - 1):
    for j in range(i + 1, N):
        heapq.heappush(h, A[i] * A[j])
# print(h)
# print(h[K - 1])

count = 0
ans = 0
while count < K:
    ans = heapq.heappop(h)
    count += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
#from math import sqrt
from heapq import heappush, heappop
#from collections import deque

n, k = [int(v) for v in input().split()]
a = [int(v) for v in input().split()]

q = []

for i in range(n - 1):
    a1 = a[i]
    for j in range(i + 1, n):
        a2 = a[j]
        aa = a1 * a2
        heappush(q, aa)

i = 0

while i < k:
    v = heappop(q)
    i += 1
print(v)

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
a=list(map(int,input().split()))
ansl=[]
for i in range(n-1):
    for j in range(i+1,n):
        ansl.append(a[i]*a[j])
ansl.sort()
print(ansl[k-1])

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int,input().split())
A = list(map(int,input().split()))
product = []

for i in range(N-1):
  for j in range(N-1-i):
    p = A[i] * A[i+j+1]
    product.append(p)
else:
  product.sort()
  print(product[K-1])

Submission status: Time Limit Exceeded

Solution code:
N, K = list(map(int, input().split()))
a_list = list(map(int, input().split()))

multiple_list = []
for i in range(N):
    for j in range(i + 1, N):
        multiple_list.append(a_list[i] * a_list[j])

print(sorted(multiple_list)[K-1])

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())
alist=list(map(int,input().split()))
xlist=[]
for i in range(n-1):
  icheck=alist[i]
  for j in range(i+1,n):
    xlist.append(icheck*alist[j])
xlist.sort()
print(xlist[k-1])

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
nums = list(map(int, input().split()))

ans = []
for i in range(len(nums)):
    for j in range(i+1, len(nums)):
        ans.append(nums[i] * nums[j])
ans.sort()
print(ans[K-1])

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())

numbers = list(map(int, input().split()))

res = []
s = 1
for i in range(n):
    for j in range(s, n):
        res.append(numbers[i] * numbers[j])
    s += 1

res.sort()

print(res[k - 1])

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int, input().split())
a = sorted(list(map(int, input().split())))
d = []
for i in range(n):
    for j in range(i):
        d.append(a[i]*a[j])
d.sort()
print(d[k-1])

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations

n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
l = sorted(map(lambda x: x[0] * x[1], combinations(a, 2)))
print(l[k-1])

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))

from itertools import combinations

A_seki = [combi[0]*combi[1] for combi in combinations(A, 2)]

A_seki.sort()
print(A_seki[K-1])

Submission status: Time Limit Exceeded

Solution code:
n,k = (int(x) for x in input().split())
a_list = [int(x) for x in input().split()]
res = []

for i,a1 in enumerate(a_list):
  for j,a2 in enumerate(a_list[i+1:]):
    res.append(a1*a2)

print(sorted(res)[k-1])

Submission status: Time Limit Exceeded

Solution code:
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

def select_median_of_medians(L, k):
    nL = len(L)
    if nL < 50:
        return sorted(L, reverse=True)[k-1]

    R = [sorted(L[i*5:(i+1)*5])[2] for i in range(int(nL/5))]
    m = select_median_of_medians(R, int(nL/10))

    L1 = [v for v in L if v > m]
    L2 = [v for v in L if v == m]
    L3 = [v for v in L if v < m]

    if k <= len(L1):
        return select_median_of_medians(L1, k)
    elif k <= len(L1)+len(L2):
        return m
    else:
        return select_median_of_medians(L3, k-len(L1)-len(L2))

L = []
for i in range(N-1):
    for j in range(i+1,N):
        L.append(-A[i]*A[j])
print(-select_median_of_medians(L, K))

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
array = list(map(int, input().split()))
products = sorted([array[x] * array[y] for x in range(N-1) for y in range(x+1,N)])
print(products[K-1])

Submission status: Time Limit Exceeded

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
A = LIST()

A.sort()
l = list(combinations(A ,2))

L = []
for k in l:
    a,b = k[0], k[1]
    L.append(a * b)
L.sort()



print(L[K-1])

Submission status: Time Limit Exceeded

Solution code:
import heapq

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

ans = []
for i in range(n):
    for j in range(n):
        if i > j:
            heapq.heappush(ans, A[i] * A[j])

for _ in range(k):
    a = heapq.heappop(ans)
print(a)

Submission status: Time Limit Exceeded

Solution code:
import itertools
l = list(map(lambda x: int(x), input().split(" ")))
n = l[0]
k = l[1]
values = list(map(lambda x: int(x), input().split(" ")))
com = itertools.combinations(values, 2)
res = list(map(lambda x: x[0] * x[1], com))
res.sort()
print(res[k - 1])

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
import itertools
AC = list(itertools.combinations(A,2))
ACS = []
for ac in AC:
    ACS.append(ac[0]*ac[1])
ACS.sort()
print(ACS[K-1])

Submission status: Time Limit Exceeded

Solution code:
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
A = lr()
A_np = np.array(A)
product = []
for i in range(N-1):
    l = A[i] * A_np[i+1:]
    product.extend(l)

product.sort()
print(product[K-1])

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

##### 無限 #####
# inf = float('inf')

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

inf = float('inf')

def main():
	N,K = inputMap()
	A = inputList()

	ans = []
	for i in range(N):
		for j in range(i+1,N):
			tmp = A[i] * A[j]
			ans.append(tmp)

	ans.sort()
	#print(ans)
	print(ans[K-1])

if __name__ == "__main__":
	main()

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n,k=mii()
arr=limii()
ans=[]
for v in combinations(arr, 2):
    ans.append(v[0]*v[1])
ans.sort()

print(ans[k-1])

Submission status: Time Limit Exceeded

Solution code:
import heapq
n,k=map(int,input().split())
a=list(map(int,input().split()))
hq=[]
for i in range(n-1):
    for j in range(i+1,n):
        heapq.heappush(hq,a[i]*a[j])
for i in range(k):
    ans=heapq.heappop(hq)
print(ans)

Submission status: Time Limit Exceeded

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

ans = []

for i in range(n-1):
    for j in range(i+1,n):
        ans.append(a[i]*a[j])

ans.sort()

print(ans[k-1])

Submission status: Time Limit Exceeded

Solution code:
from bisect import bisect_left

import sys
input = lambda : sys.stdin.readline().strip()

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

def check(m):
    cnt = 0
    for ai in a:
        if ai == 0:
            if m >= 0:
                cnt += n-1
        elif ai < 0:
            x = -(-m//ai)
            cnt += n - bisect_left(a, x)
            if ai>= x:
                cnt -= 1
        else:
            x = m//ai
            cnt += bisect_left(a, x+1)
            if ai <= x:
                cnt -= 1
        if cnt//2 >= k:
            return True
    return False

left = -10**20
right = 10**20
while right-left>1:
    mid = (right+left)//2
    if check(mid):
        right = mid
    else:
        left = mid

print(right)

Submission status: Time Limit Exceeded

Solution code:
#D

n,k = map(int,input().split())
a = sorted(map(int,input().split()))
b = [[a[i]*a[j] for j in range(i+1,n)]for i in range(0,n)]
print(sorted(sum(b,[]))[k-1])

Submission status: Time Limit Exceeded

Solution code:
import math
import itertools
import fractions
import heapq
import collections
import bisect
import sys
import copy

sys.setrecursionlimit(10**9)
mod = 10**7+9
inf = 10**20

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

n,k = LI()
a = LI()
l = []

for i in range(n-1):
    for j in range(i+1,n):
        l.append(a[i]*a[j])

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

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split(' '))

a = list(map(int, input().split(' ')))

ans = []

for i in range(n - 1):
    for j in range(i + 1, n):
        ans.append(a[i] * a[j])

ans2 = sorted(ans)
print(ans2[k - 1])

Submission status: Time Limit Exceeded

Solution code:
n, k = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
ans = []
for i in range(n):
    for j in range(i+1,n):
        ans.append(A[i]*A[j])
print(sorted(ans)[k-1])

Submission status: Time Limit Exceeded

Solution code:
import sys
import itertools 
def input(): return sys.stdin.readline().rstrip()

def main():
    N, K = map(int, input().split())
    A = tuple(map(int, input().split()))
    sortedA = sorted([v[0] * v[1] for v in itertools.combinations(A, 2)])
    print(sortedA[K-1])

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import itertools
import heapq

N,K=[int(i) for i in input().split(" ")]
A=[int(i) for i in input().split(" ")]

q=[]
heapq.heapify(q)
for i in itertools.combinations(A,2):
    heapq.heappush(q,i[0]*i[1])


for i in range(K):
    a=heapq.heappop(q)

print(a)

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())
alist=list(map(int,input().split()))
xlist=[]
for i in range(n-1):
  for j in range(i+1,n):
    xlist.append(alist[i]*alist[j])
xlist.sort()
print(xlist[k-1])

Submission status: Time Limit Exceeded

Solution code:
def run():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    lst = []
    for i in range(n - 1):
        for j in range(i + 1, n):
            lst.append(a[i] * a[j])
    
    lst = sorted(lst)
    print(lst[k - 1])

if __name__ == "__main__":
    run()

Submission status: Time Limit Exceeded

Solution code:
from bisect import bisect_left

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

def check(m):
    cnt = 0
    for ai in a:
        if ai == 0:
            if m >= 0:
                cnt += n-1
        elif ai < 0:
            x = -(-m//ai)
            cnt += n - bisect_left(a, x)
            if ai>= x:
                cnt -= 1
        else:
            x = m//ai
            cnt += bisect_left(a, x+1)
            if ai <= x:
                cnt -= 1
    return cnt//2

left = -10**20
right = 10**20
while right-left>1:
    mid = (right+left)//2
    cnt = check(mid)
    if cnt >= k:
        right = mid
    else:
        left = mid

print(right)

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
import itertools
c=itertools.combinations(a,2)
c=list(c)

lis=[0]*((n*(n-1))//2)
for i in range((n*(n-1))//2) :
    lis[i]=c[i][0]*c[i][1]

lis=sorted(lis)
print(lis[k-1])