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()))

sa = list(sorted(a))

r = []
for i, si in enumerate(sa):
  for b in sa[i+1:len(a)]:
    r.append(si*b)
    
sr = sorted(r)
print(sr[k-1])

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

INPUT = LIST()
N = INPUT[0]
K = INPUT[1]

A = LIST()

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import itertools as it
N,K=map(int,input().split())
A=list(map(int,input().split()))
B=[]
T=list(it.combinations(A,2))
for i in range(len(T)):
    B.append(T[i][0]*T[i][1])
b=sorted(B)
print(b[K-1])

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

print(ans[K-1])

Submission status: Time Limit Exceeded

Solution code:
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import pdb
import sys
F = sys.stdin

N, K = map(int,F.readline().split())
A = list(map(int,F.readline().rstrip().split()))
ans = []

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

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

Submission status: Time Limit Exceeded

Solution code:
import itertools
N, K = [int(n) for n in input().rstrip().split(' ')]

A = [int(n) for n in input().rstrip().split(' ')]

comb_A = list(itertools.combinations(A, 2))

multi = []

for A_pair in comb_A:
  multi.append(A_pair[0]*A_pair[1])

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int,input().split())
a = list(map(int,input().split()))
b = []
for i in range(len(a)):
    for j in range(len(a)):
        if i < j:
            break
        if i == j:
            continue
        b.append(a[i]*a[j])
c = sorted(b)
print(c[k-1])

Submission status: Time Limit Exceeded

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

# 全探索
seki_list = []
for i in range(n):
    for j in range(n):
        if i == j:
            pass
        elif j < i:
            pass
        else:
#            print (i,j)
            seki_list.append(a[i]*a[j])

#print (sorted(seki_list))
print (sorted(seki_list)[k-1])

Submission status: Time Limit Exceeded

Solution code:
cnt, ind = map(int, input().split())
values = list(map(int, input().split()))

pow = []
for i in range(0, cnt - 1):
    pow.extend([values[i] * values[j] for j in range(i + 1, cnt)])

pow.sort()
print(pow[ind - 1])

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations

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

comb = combinations(A, 2)

ans = []
for i in list(comb):
    ans.append(i[0]*i[1])

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

Submission status: Time Limit Exceeded

Solution code:
import itertools


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

nums = [i for i in range(N)]
comb = [i for i in itertools.combinations(nums, 2)]

seki = sorted([A[i[0]] * A[i[1]] for i in comb])


print(seki[K - 1])

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations


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

prods = [i * j for i, j in combinations(A, 2)]
prods.sort()
print(prods[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(len(a)-1):
  for j in range(i+1,len(a)):
    if i==j:
      pass
    else:
      l.append(a[i]*a[j])

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

Submission status: Time Limit Exceeded

Solution code:
nk = list(map(int, input().split()))
n = nk[0]
k = nk[1]
li = list(map(int, input().split()))
le = len(li)
an = []
for i in range(le):
    for j in range(i, le):
        if i == j:
            continue
        an.append(li[i]*li[j])
an.sort()
print(an[k-1])

Submission status: Time Limit Exceeded

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

import itertools


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

products = []
for a1, a2 in itertools.combinations(alist, 2):
    products.append(a1 * a2)

products_sorted = sorted(products)
print(products_sorted[k-1])

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys
from collections import deque as deq

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):
        n = A[i] * A[j]
        l.append(n)

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import itertools
N,K = map(int, input().split())
Combi = list(itertools.combinations(list(map(int, input().split())), 2))
products = []
for combi in Combi:
  products.append(combi[0]*combi[1])
products.sort()
print(products[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()]
minA=[int(i) for i in A if i <0]
larA=[int(i) for i in A if i >=0]
lis=[]
if K<=len(minA)*len(larA):
	for n in minA:
		for m in larA:
			lis+=[n*m]
	lis.sort()
	print(lis[K-1])
else:
	for n in range(len(minA)):
		for m in range(n):
			if n!=m:
				lis+=[minA[n]*minA[m]]
	for n in range(len(larA)):
		for m in range(n):
			if n!=m:
				lis+=[larA[n]*larA[m]]
	lis.sort()
	print(lis[K-len(minA)*len(larA)-1])

Submission status: Time Limit Exceeded

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

from itertools import permutations, combinations,combinations_with_replacement,product
#print(list(permutations(A)))
comb=list(combinations(A,2))
#print(comb)

mul=[]
for i in comb:
  mul.append(i[0]*i[1])
#print(mul)
sol = sorted(mul)
#print(sol)
print(sol[K-1])

Submission status: Time Limit Exceeded

Solution code:
# python3
# -*- coding: utf-8 -*-
import sys
import math
#from math import gcd
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint

INF = float('inf')

ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
sys.setrecursionlimit(1000000000)


def lcm(a, b):
    return (a * b) // gcd(a, b)


# main
N, K = mis()
A = lmis()

plist = []

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

plist.sort()

print(plist[K-1])

Submission status: Time Limit Exceeded

Solution code:
import itertools

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

t=[]

for a,b in itertools.combinations(s,2):
  t.append(a*b)

t.sort()

print(t[k-1])

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!

import sys
readline = sys.stdin.readline
read = sys.stdin.read

#n,*a = [int(i) for i in read().split()]
#a = [int(i) for i in readline().split()]
#n = int(input())

from bisect import bisect_right, bisect_left

n,k,*a = [int(i) for i in read().split()]
a.sort()

#v = [a[i]*a[j] for i in range(n) for j in range(i+1,n)]
#v.sort()
#print(v)
#print(v[k-1])

l = bisect_left(a,0)
r = bisect_right(a,0)

a_neg = [-i for i in a[:l][::-1]]
a_pos = a[r:]

if k <= l*(n-r): # negative
    def check(x): #x 以上は k 個以上あるか？
        res = 0
        for i in a_neg:
            res += (n-r)-bisect_left(a_pos,(x+i-1)//i)
        return res >= k

    ok = 0
    ng = 10**18
    while ng-ok > 1:
        mid = (ok+ng)//2
        if check(mid): ok = mid
        else: ng = mid

    print(-ok)

elif k <= n*(n-1)//2 - l*(l-1)//2 - (n-r)*(n-r-1)//2:
    print(0)

else:
    k -= n*(n-1)//2 - l*(l-1)//2 - (n-r)*(n-r-1)//2

    def check(x): #x 以下は k 個以上あるか？
        res = 0
        for i,ai in enumerate(a_neg):
            res += max(bisect_right(a_neg,x//ai)-i-1,0)
        for i,ai in enumerate(a_pos):
            res += max(bisect_right(a_pos,x//ai)-i-1,0)
        return res >= k
    
    ng = 0
    ok = 10**18
    while ok-ng > 1:
        mid = (ok+ng)//2
        if check(mid): ok = mid
        else: ng = mid

    print(ok)

Submission status: Time Limit Exceeded

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

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

p.sort()
# print(p)
# p = list(set(p))
print(p[K-1])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import bisect

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

# eager

A.sort()

ret = []

for i in range(len(A) - 1):
  for j in range(i + 1, len(A)):
    bisect.insort(ret, A[i] * A[j])

print(ret[K - 1])

Submission status: Time Limit Exceeded

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

from itertools import combinations

g = sorted(x[0] * x[1]  for x in combinations(xs, 2))
print(g[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(n-i-1):
        ans.append(a[i]*a[j+i+1])
ans=sorted(ans)
print(ans[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()))
com = combinations(a, 2) 
res = []
for a,b in com:
    res.append(a*b)
print(sorted(res)[k-1])

Submission status: Time Limit Exceeded

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

l = [int(i) for i in input().split()]

p = list(itertools.combinations(l,2))

ans = []
for x,y in p:
    bisect.insort(ans,x*y)

print(ans[k-1])

Submission status: Time Limit Exceeded

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

import itertools
import heapq

l = []
heapq.heapify(l)

for ai in itertools.combinations(A, 2):
    heapq.heappush(l, ai[0]*ai[1])

for ki in range(K):
    ans = heapq.heappop(l)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math

import itertools

#import bisect

import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]



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

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())
*a,=map(int,input().split())
ans=[]
from itertools import combinations
con=list(combinations(a,2))
for i in range(len(con)):
    ans.append(con[i][1]*con[i][0])
ans=sorted(ans)
print(ans[k-1])

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import itertools
import sys
input = sys.stdin.readline


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

    ans = list()
    for i in itertools.combinations(a, 2):
        ans.append(i[0] * i[1])

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


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import copy
N,K = map(int,input().split())
L = list(map(int,input().split()))
Lc = copy.copy(L)
R1 = []
for x in L:
    Lc.remove(x)
    for xx in Lc:
        R1.append(x*xx)
print(list(sorted(R1))[K-1])

Submission status: Time Limit Exceeded

Solution code:
cnt, ind = map(int, input().split())
values = list(map(int, input().split()))

pow = []
for i in range(0, cnt - 1):
    pow.extend(values[i] * values[j] for j in range(i + 1, cnt))

pow = sorted(pow)
print(pow[ind - 1])

Submission status: Time Limit Exceeded

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

import itertools

lst = []
for x, y in list(itertools.combinations(A, 2)):
    lst.append(x * y)
    
lst.sort()
print(lst[K-1])

Submission status: Time Limit Exceeded

Solution code:
from bisect import bisect_right
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_right(R, p)
    if idx < K:
        R.insert(idx, p)
print(R[K-1])

Submission status: Time Limit Exceeded

Solution code:
import itertools                        
                                        
n, k = map(int, input().split())        
A = [int(i) for i in input().split()]   
p = itertools.combinations(A,2)         
AA = [v[0] * v[1] for v in p]           
#print(sorted(AA))                      
print(sorted(AA)[k-1])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


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

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

Submission status: Time Limit Exceeded

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

import itertools

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

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

Submission status: Time Limit Exceeded

Solution code:
import heapq
import itertools

N, K = map(int, input().split())
A = [int(a) for a in input().split()]
A.sort()
queue = []
streams = map(lambda i: sorted(A[i] * A[j] for j in range(i + 1, N)), range(N))
stream = heapq.merge(*streams)
print([suv for suv in itertools.islice(stream, K)][-1])

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int, input().split())
A = 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:
NK = input().split()
N = int(NK[0])
K = int(NK[1])

AN = input().split()
AN = [int(a) for a in AN]
AN2 = [AN]*N

import numpy as np
AN = np.array([AN])
AN2 = np.array(AN2)
AN = AN.reshape(N,-1)
pro = AN * AN2
pro2 = []
for i in range(N-1):
  pro2.extend(pro[i][i+1:N])
pro2 = np.sort(pro2, kind='quick_sort')
print(pro2[K-1])

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import collections

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

B = []
for i in range(N):
  for j in range(N-i):
    if i==N-1-j:
      continue
    else:
      B.append(A[i]*A[N-1-j])
c= sorted(B)
print(c[K-1])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

dones = set()
scores = []

for i in range(n):
    for j in range(i + 1, n):
        scores.extend([items[i] * items[j]])
srt = sorted(scores)
print(srt[k - 1])

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
listo = list(map(int, input().split()))
prod = []
for i in range(N):
    for j in range(i+1, N):
        prod.append(listo[i] * listo[j])
prod.sort()
print(prod[K-1])

Submission status: Time Limit Exceeded

Solution code:
#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    N, K = iim()
    A = list(iim())

    x = 0

    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])



if __name__ == "__main__":
    resolve()

Submission status: Time Limit Exceeded

Solution code:
import itertools

nk = list(map(int,input().split()))
arr_d = list(map(int,input().split()))

product = []

for v in itertools.combinations(arr_d, 2):
  product.append(v[0] * v[1])

product.sort()

print(product[int(nk[1])-1])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import itertools
N,K = list(map(int,input().split()))
A = sorted(list(map(int,input().split())))
B = sorted([i*j for i,j in itertools.combinations(A,2)])
print(B[K-1])

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(" ")))
res = list(map(lambda x: x[0] * x[1], itertools.combinations(values, 2)))
res.sort()
print(res[k - 1])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations
def main():
    # Failed to predict input format
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))

    lst = []

    combs = combinations(A, 2)

    for a, b in combs:
        lst.append(a*b)

    lst.sort()
    # print(lst)
    print(lst[K-1])
    pass

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
from itertools import *

n, k = map(int, input().split())
a = list(map(int, input().split()))
c = list(combinations(a, 2))
p = []

for i in range(len(c)):
    p.append(c[i][0] * c[i][1])

# print(c)
# print(p)
p.sort()

print(p[k-1])

Submission status: Time Limit Exceeded

Solution code:
N = [int(i) for i in input().split()]
As = [int(i) for i in input().split()]
Ws = []
for i in range(N[0]-1):
  for j in range(i+1, N[0]):
    Ws.append(As[i]*As[j])
print(sorted(Ws)[N[1]-1])

Submission status: Time Limit Exceeded

Solution code:
import itertools
N,K,*A=map(int,open(0).read().split())
l=[]
for i in itertools.combinations(A,2):
    l.append(i[0]*i[1])
l.sort()
print(l[K-1])

Submission status: Time Limit Exceeded

Solution code:
import itertools
n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = []
for i in itertools.combinations(a, 2):
    res = i[0] * i[1]
    ans.append(res)
ans.sort()
print(ans[k-1])

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations

def check(s,A):
    N,K = map(int, s.split())
    A = [int(i) for i in A.split()]
    seki = []
    for a,b in combinations(A, 2):
        seki.append(a*b)
    print(sorted(seki)[K-1])
    
s = input()
A = input()
check(s,A)

Submission status: Time Limit Exceeded

Solution code:
import sys

n, k = map(int, sys.stdin.readline().strip().split(" "))
a = list(map(int, sys.stdin.readline().strip().split(" ")))

pairs = []
for i in range(len(a)):
    for j in range(len(a)):
        if j <= i:
            continue
        pairs.append(a[i] * a[j])
print(sorted(pairs)[k-1])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python
from collections import deque, defaultdict
import bisect


def comb(a, b):
    result = 1
    for i in range(b):
        result *= (a - i) / (i + 1)
    return result


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

    A = []
    for i in range(len(As)):
        for j in range(i+1, len(As)):
            prod = As[i] * As[j]
            if len(A) < K or A[-1] > prod:
                index = bisect.bisect_left(A, prod)
                A.insert(index, prod)
            if len(A) > K:
                A.pop(-1)

    print(A[-1])


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

ans = []
for i in range(N - 1):
    # print(i)
    for j in range(i + 1, N):
        # print("\t" + str(j))
        ans.append(A[i] * A[j])

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

Submission status: Time Limit Exceeded

Solution code:
import itertools
def main(n,k,a):
    lst = []
    for i in itertools.combinations(a, 2):
        lst.append(i[0] * i[1])
    lst.sort()
    return lst[k-1]

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

Submission status: Time Limit Exceeded

Solution code:
import itertools


def ACC(a_list):
    result_list = list()
    for a, b in itertools.combinations(a_list, 2):
        result_list.append(a * b)
    return sorted(result_list)


def main():
    N, K = map(int, input().split(' '))
    A_list = list(map(int, input().split(' ')))
    print(ACC(A_list)[K-1])


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import pdb
import sys
F = sys.stdin

N, K = map(int,F.readline().split())
A = list(map(int,F.readline().rstrip().split()))
ans = []

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

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

Submission status: Time Limit Exceeded

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

k = k - 1

arr = [int(i) for i in input().split()]

ans = []

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

ans = sorted(ans)

print(ans[k])

Submission status: Time Limit Exceeded

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

s.sort()
print(s[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()]
v = []
for i in range(n-1):
    for j in range(i+1,n):
        v.append(a[i]*a[j])
sorted_v = sorted(v)
print(sorted_v[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()))
X = list(combinations(A, 2))
ans = []
for x in X:
    ans.append(x[0]*x[1])
ans.sort()
print(ans[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:
from itertools import product,combinations
N,K = map(int,input().split())
A = sorted(list(map(int,input().split())))
ap = [i for i in A if i > 0]
am = [i for i in A if i < 0]
lenp = len(ap)
lenm = len(am)
azero = N -lenp - lenm
zerocomb = azero*(N-azero) + azero*(azero-1)//2
minus = lenp*lenm
if minus >= K:
    ans = []
    for a,b in product(ap,am):
        ans.append(a*b)
    ans.sort()
    print(ans[K-1])
elif K <= minus+zerocomb:
    print(0)
else:
    ans = []
    for a,b in combinations(ap,2):
        ans.append(a*b)
    for a,b in combinations(am,2):
        ans.append(a*b)
    ans.sort()
    print(ans[K-1-minus-zerocomb])

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations
a,b = map(int,input().split())
l = list(map(int,input().split()))
l2 = []
m = 0
for x,y in combinations(l,2):
  m = x*y
  l2.append(m)
  
l2.sort()
print(l2[b-1])

Submission status: Time Limit Exceeded

Solution code:
#n = int(input())
import itertools
n,k = map(int,input().split())
a_L = list(map(int,input().split()))

c = list(itertools.combinations(a_L,2))

ans = []

for k1,k2 in c:
    ans.append(k1*k2)
#print(ans)
ans = sorted(ans)

print(ans[k-1])

Submission status: Time Limit Exceeded

Solution code:
cnt, ind = map(int, input().split())
values = list(map(int, input().split()))

pow = []
for i in range(0, len(values) - 1):
    for j in range(i + 1, len(values)):
        pow.append(values[i] * values[j])

pow = sorted(pow)
print(pow[ind - 1])

Submission status: Time Limit Exceeded

Solution code:
#

def main():
    N,K=(int(x) for x in input().split())
    a=[int(x) for x in input().split()]
    ans=[]
    for i in range(N-1):
        for j in range(i+1,N):
            ans.append(a[i]*a[j])
    ans=sorted(ans)
    print(ans[K-1])

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import itertools
import heapq

N, K = map(int, input().split())
A = list(map(int, input().split()))
hq = []
for a1, a2 in itertools.combinations(A, 2):
    heapq.heappush(hq, a1 * a2)
for i in range(K):
    res = heapq.heappop(hq)
print(res)

Submission status: Time Limit Exceeded

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

s = []

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

sx = sorted(s)
#print(sx)
print(sx[k - 1])

Submission status: Time Limit Exceeded

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

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

L.sort()

print(L[K-1])

Submission status: Time Limit Exceeded

Solution code:
NK = input().split()
N = int(NK[0])
K = int(NK[1])

AN = input().split()
AN = [int(a) for a in AN]
AN2 = [AN]*N

import numpy as np
AN = np.array([AN])
AN2 = np.array(AN2)
AN = AN.reshape(N,-1)
pro = AN * AN2
pro2 = []
for i in range(N-1):
  pro2.extend(pro[i][i+1:N])
pro2.sort()
print(pro2[K-1])

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations

def multiply(A):
    return(A[0]*A[1])

N, K = map(int,input().split())
A = map(int, input().split())
print(sorted(list(map(multiply, list(combinations(A, r =2)))))[K-1])

Submission status: Time Limit Exceeded

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

d = {}

for i in range(N-1):
    for j in range(i+1, N):
        n = A[i]*A[j]
        if n not in d:
            d[n] = 0
        d[n] += 1

key = list(d.keys())
key.sort()

for k in key:
    K -= d[k]
    if K <= 0:
        print(k)
        break