Harryxun/stf_run huggingface dataset:
import numpy as np
i8 = np.int64
i4 = np.int32

def calc(dp1, dp2, k):
    dp2[k:] += dp1[:-k]
    dp2[:-k] += dp1[k:]

def solve(z, dp):
    zero = dp.shape[2] // 2
    dp[0, 0, zero + z[0, 0]] = 1
    dp[0, 0, zero - z[0, 0]] = 1
    for x in range(1, z.shape[1]):
        calc(dp[0, x - 1], dp[0, x], z[0, x])
    for y in range(1, z.shape[0]):
        calc(dp[y - 1, 0], dp[y, 0], z[y, 0])
        for x in range(1, z.shape[1]):
            calc(dp[y, x - 1], dp[y, x], z[y, x])
            calc(dp[y - 1, x], dp[y, x], z[y, x])
    for i in range(zero, dp.shape[2]):
        if dp[dp.shape[0] - 1, dp.shape[1] - 1, i] > 0:
            return i - zero
    return -1


def main2():
    stdin = open('/dev/stdin')
    H, W = map(int, stdin.readline().split())
    a = np.empty((H, W), i8)
    b = np.empty((H, W), i8)
    for i in range(H):
        for j, c in enumerate(map(int, stdin.readline().split())):
            a[i, j] = c
    for i in range(H):
        for j, c in enumerate(map(int, stdin.readline().split())):
            b[i, j] = c
    z = np.abs(a - b)
    if H > W:
        z = z.T.copy()
    dp = np.zeros((H, W, 80 * 80 * 80*2 + 1), i8)
    ans = solve(z, dp)
    print(ans)

main2()

### FIXED CODE ###

import numpy as np
i8 = np.int64
i4 = np.int32

def calc(dp1, dp2, k):
    dp2[k:] += dp1[:dp1.shape[0]-k]
    dp2[:dp2.shape[0]-k] += dp1[k:]

def solve(z, dp):
    zero = dp.shape[2] // 2
    dp[0, 0, zero + z[0, 0]] = 1
    dp[0, 0, zero - z[0, 0]] = 1
    for x in range(1, z.shape[1]):
        calc(dp[0, x - 1], dp[0, x], z[0, x])
    for y in range(1, z.shape[0]):
        calc(dp[y - 1, 0], dp[y, 0], z[y, 0])
        for x in range(1, z.shape[1]):
            calc(dp[y, x - 1], dp[y, x], z[y, x])
            calc(dp[y - 1, x], dp[y, x], z[y, x])
            if (x + y) % 10 == 0:
                dp[y, x] = dp[y, x] > 0
    for i in range(zero, dp.shape[2]):
        if dp[dp.shape[0] - 1, dp.shape[1] - 1, i] > 0:
            return i - zero
    return -1

def main2():
    stdin = open('/dev/stdin')
    H, W = map(int, stdin.readline().split())
    a = np.empty((H, W), i8)
    b = np.empty((H, W), i8)
    for i in range(H):
        for j, c in enumerate(map(int, stdin.readline().split())):
            a[i, j] = c
    for i in range(H):
        for j, c in enumerate(map(int, stdin.readline().split())):
            b[i, j] = c
    z = np.abs(a - b)
    dp = np.zeros((H, W, 80 * 80 *2 + 1), i8)
    ans = solve(z, dp)
    print(ans)


main2()
from collections import deque
ans=deque()
ans.append(input())
c=0
qu=[input().split() for i in range(int(input()))]
c=0
for i in qu:
    if i[0]=='1':
        c+=1
    else:
        if c%2==0:
            if i[1]=='1':
                ans.appendleft(i[2])
            else:
                ans.append(i[2])
        else:
            ans=ans[::-1]
            if i[1]=='1':
                ans.appendleft(i[2])
            else:
                ans.append(i[2])
            
print(''.join(ans))

### FIXED CODE ###

from collections import deque
S = deque(input())
N = int(input())
is_inversed = False
for i in range(N):
    Q = input()
    if Q[0] == '1':
        is_inversed = not (is_inversed)
    else:
        if (Q[2] == '1' and is_inversed) or (Q[2] == '2' and not (is_inversed)):
            S.append(Q[4])
        else:
            S.appendleft(Q[4])
if is_inversed:
    print(''.join(list(S)[::-1]))
else:
    print(''.join(S))
N = int(input())
arr = [ list(map(int, input().split())) for i in range(N)]
res = 'Yes'

for i in range(N-1):
    x = arr[i+1][1] - arr[i][1]
    y = arr[i+1][2] - arr[i][2]
    t = arr[i+1][0] - arr[i][0]
    
    if x+y <= t:
        if (x+y-t)%2 == 0:
            pass
        else:
            res = 'No'
            break
    else:
        res = 'No'
        break
        
print(res)

### FIXED CODE ###

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

if (a*b)%2 == 0:
    print('Even')

else:
    print('Odd')
cin=input().split()
N=int(cin[0])
M=int(cin[1])


result={}
ac=0
wa=0
for i in range(M):
    cin=input().split()
    p=int(cin[0])
    S=str(cin[1])

    log=result.get(p,None)
    if S == "AC" and log != "AC":
        ac+=1
        result[p]="AC"

    if S == "WA" and log != "AC":
        wa+=1

print(f"{ac} {wa}")

### FIXED CODE ###

cin=input().split()
N=int(cin[0])
M=int(cin[1])


result={}
ac=0
was={}
for i in range(M):
    cin=input().split()
    p=int(cin[0])
    S=str(cin[1])

    log=result.get(p,None)
    if S == "AC" and log != "AC":
        ac+=1
        result[p]="AC"

    if S == "WA" and log != "AC":
        was[p]=was.get(p,0)+1

wa=0
for k,v in result.items():
    if v == "AC":
        wa+=was.get(k,0)
print(str(ac)+" "+str(wa))
answer = 'Odd'
if int(a)*int(b)%2 == 0:
  answer = 'Even'
print(answer)

### FIXED CODE ###

a,b = input().split()
answer = "Odd"
if (int(a)*int(b)%2) == 0:
  answer = "Even"
print(answer)
N, M = map(int, input().split())
a_list = list(map(int, input().split()))

items = {
    1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6
}
dp = [0] * (N + 1)

for a in a_list:
    need = items[a]
    dp[need] = a

for i in range(2, N+1):
    for j in range(M):
        if i - items[a_list[j]] + 1 >= 0:
                if dp[i - items[a_list[j]]] != 0:
                    dp[i] = max(dp[i - items[a_list[j]]] * 10 + a_list[j], dp[i])

print(dp[N])


### FIXED CODE ###

N, M = map(int, input().split())
a_list = list(map(int, input().split()))

items = {
    1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6
}

dp = [-float("inf")] * (N + 1)
b_list = []
for a in a_list:
    need = items[a]
    if need <= N:
        dp[need] = 1
        b_list.append(a)

M = len(b_list)
dp[0] = 0
for i in range(N + 1):
    for b in b_list:
        if i - items[b] >= 0:
            if dp[i - items[b]] != -float("inf"):
                dp[i] = max(dp[i], dp[i - items[b]] + 1)

b_list.sort(reverse=True)
ans = ""

for i in range(dp[N]):
    for b in b_list:
        if dp[N - items[b]] == dp[N] - 1:
            ans += str(b)
            N -= items[b]
            break
print(ans)
x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p.sort()
q.sort()
r.sort()
pcount=0
qcount=0
rcount=0
ans=[]
for i in range(x):
  ans.append(p[-1-i])
for i in range(y):
  ans.append(q[-1-i])
ans.sort()
for i in range(c):
  if rcount<len(r)-1 and ans[i]<=r[-1-rcount]:
    ans[i]=r[-1-rcount]
    rcount+=1
print(sum(ans))
  

### FIXED CODE ###

x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p.sort()
q.sort()
r.sort(reverse=True)
rcount=0
ans=[]
for i in range(x):
  ans.append(p[-1-i])
for i in range(y):
  ans.append(q[-1-i])
ans.sort()
for i in range(min(len(ans),c)):
  if ans[i]<=r[rcount]:
    ans[i]=r[rcount]
    rcount+=1
print(sum(ans))
import math

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
 
    divisors.sort()
    return divisors
  
N = int(input())
Nlist = make_divisions(N)
L = len(Nlist)
if L%2==0:
    print(Nlist[int(L/2)]+Nlist[int(L/2)-1]-2)
else:
    print(int(math.sqrt(N)*2-2)

### FIXED CODE ###

import math
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
N = int(input())
Nlist = make_divisors(N)
L = len(Nlist)
if L%2==0:
    print(Nlist[int(L/2)]+Nlist[int(L/2)-1]-2)
else:
    print(int(math.sqrt(N)*2-2))
s = input()
answer_1 = answer_2 = -1

for i in range(len(s)):
  if s[i] == s[i+1]:
    answer_1 = i + 1
    answer_2 = i + 2
    break
  
  elif s[i] == s[i+2]:
    answer_1 = i + 1
    answer_2 = i + 3
    break

print(str(answer_1) + " " + str(answer_2))

### FIXED CODE ###

s = input()
answer_1 = answer_2 = -1

for i in range(len(s) - 1):
  if s[i] == s[i+1]:
    answer_1 = i + 1
    answer_2 = i + 2
    break
  
  elif i != len(s) - 2 and s[i] == s[i+2]:
    answer_1 = i + 1
    answer_2 = i + 3
    break

print(str(answer_1) + " " + str(answer_2))
n = int(input())
h = list(map(int,input().split()))
counter =[]
cnt = 0
for i in range(n-1):
  if h[i] >= h[i+1]:
    cnt += 1
  else:
    counter.append(cnt)
    cnt = 0
print(max(counter))

### FIXED CODE ###

n = int(input())
h = list(map(int,input().split()))
counter =[]
cnt = 0
for i in range(n-1):
  if h[i] >= h[i+1]:
    cnt += 1
  else:
    counter.append(cnt)
    cnt = 0
counter.append(cnt)
print(max(counter))
import sys
import itertools
import heapq
import numpy as np
stdin = sys.stdin
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N,K=nm()
A=[0]*K
for i in range(K):
    d=int(input())
    tmp=nl()
    for j in range(d):
        A[tmp[j]-1]+=1
c=0
for i in range(N):
        if(A[i]==0):
            c+=1

print(c)

### FIXED CODE ###

import sys
import itertools
stdin = sys.stdin
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N,K=nm()
A=[0 for i in range(N)]
for i in range(K):
    d=int(input())
    tmp=nl()
    for j in range(d):
        A[tmp[j]-1]+=1
c=0
for i in range(N):
        if(A[i]==0):
            c+=1

print(c)
n = input().int()
s = input().str()

ans = 0
for i in range(0, n):
    if s[i]=="I":
        ans+=1
    else:
        ans-=1
print(ans)

### FIXED CODE ###

n = int(input())
s = input()

ans = 0
x = 0
for i in range(n):
    if s[i]=="I":
        ans+=1
        x = max(ans, x)
    else:
        ans-=1
        x = max(ans, x)
print(x)
from collections import deque
D1 = {i:chr(i+96) for i in range(1,27)}
D2 = {val:key for key,val in D1.items()}

N = int(input())
heap = deque([(D[1],1)])
A = []
while heap:
    a,n = heap.popleft()
    if n<N:
        j = D2[a[-1]]
        for i in range(1,min(j+1,26)+1):
            heap.append((a+D1[i],n+1))
    if n==N:
        A.append(a)
A = sorted(A)
for i in range(len(A)):
    print(A[i])

### FIXED CODE ###

from itertools import combinations
def g(i):
    return chr(i+96)
def f(n,i):
    global Ind
    if n==0:
        B.append("".join(A))
        return
    if n==1:
        j = Ind.pop()
        A[j] = g(i)
        B.append("".join(A))
        A[j]=0
        Ind.append(j)
        Ind = sorted(Ind)
        return
    j0 = Ind.pop(0)
    Ind1 = Ind[:]
    A[j0] = g(i)
    for k in range(n):
        for x in combinations(Ind1,n-1-k):
            tmp = []
            for j in range(n-1-k):
                A[x[j]] = g(i)
                tmp.append(x[j])
            for j in tmp:
                Ind.remove(j)
            f(k,i+1)
            for j in tmp:
                A[j] = 0
                Ind.append(j)
            Ind = sorted(Ind)
    Ind.append(j0)
    Ind = sorted(Ind)
    
N = int(input())
A = [0 for _ in range(N)]
Ind = list(range(N))
B = []
f(N,1)
B = sorted(B)
for b in B:
    print(b)
def main():
    h,w,n=map(int,input().split(' '))
    draw_list=[]
    for i in range(n):
        draw=tuple(map(int,input().split(' ')))
        for j in range(3):
            for k in range(3):
                if 0<draw[0]-j<=h-2 and 0<draw[1]-k<=w-2:
                    draw_list.append((draw[0]-j,draw[1]-k))
    ans = [0]*9
    sorted_draw = sorted(draw_list)
    tmp = sorted_draw[0]
    ans_num = 0
    for i in range(len(sorted_draw)-1):
        if sorted_draw[i] == sorted_draw[i+1]:
            ans_num += 1
        else:
            ans[ans_num] += 1
            ans_num = 0
    if ans_num:
        ans[ans_num]+=1

    print((h-2)*(w-2)-sum(ans))
    for i in ans:
        print(i)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    h,w,n=map(int,input().split(' '))
    if n==0:
        print((h-2)*(w-2))
        for i in range(9):
            print(0)
        exit()
    draw_list=[]
    for i in range(n):
        draw=tuple(map(int,input().split(' ')))
        for j in range(3):
            for k in range(3):
                if 0<draw[0]-j<=h-2 and 0<draw[1]-k<=w-2:
                    draw_list.append((draw[0]-j,draw[1]-k))
    ans = [0]*9
    sorted_draw = sorted(draw_list)
    for n,i in enumerate(sorted_draw):
        if not n:
            ans_num=0
            tmp = i
            continue
        if tmp == i:
            ans_num+=1
        else:
            ans[ans_num] += 1
            tmp = i
            ans_num = 0
    ans[ans_num] += 1
    print((h-2)*(w-2)-sum(ans))
    for i in ans:
        print(i)



if __name__ == '__main__':
    main()
print('Hello World!'')

### FIXED CODE ###

x = list(map(lambda y: int(y),input().split(" ")))

if x[0]<9 and x[1]<9:
	print("Yay!")
else:
	print(":(")
float R = input()
S = R * 3.14*2
print(S)

### FIXED CODE ###

import math
R = int(input())
print(2*math.pi*R)
A,B=int(input())
if A>B:
  print(">")
elif A<B:
  print("<")
else:
  print("=")

### FIXED CODE ###

S=input()
A=ord(S[0])
B=ord(S[2])

if A>B:
  print(">")
elif A<B:
  print("<")
else:
  print("=")
'''
ITP-1_4-C
 ?¨???????
???????????´??° a, b ??¨?????????????????? op ?????????????????§???a op b ????¨??????????????????°?????????????????????????????????
????????????????????? op ??????"+"(???)???"-"(???)???"*"(???)???"/"(???)???????????¨?????????????????§????????????????????´?????????
?°???°?????\??????????????¨????????????????¨????????????¨????????????
???Input
??\???????????°????????????????????????????§???????????????????????????????????????????????????¢????????\????????¨????????§??????
 a op b
op ??? '?' ?????¨??? ??\?????????????????????????????????????????±???????????????????????£????????????????????????
???Output
?????????????????????????????????????¨??????????????????????????????????????????????
'''
# import
import sys

# ?????°??????????????????
for inputData in sys.stdin:
    a, op, b = map(int,input().split())
#    a, b, op = int(inputData[0]), int(inputData[2]), inputData[1]
    retVal = 0

    # 0?????´??? ????????????
    if op == '?':
        # exec end
        break
    elif op == '+':
        retVal = int(a) + int(b)
    elif op == '-':
        retVint(a)l = int(a) - int(b)
    elif op == '*':
        retVal = int(a) * int(b)
    elif op == '/':
        retVal = int(a) / int(b)
    else:
        retVal = 0

    # ????????????
    print(retVal)

### FIXED CODE ###

'''
ITP-1_4-C
 ?¨???????
???????????´??° a, b ??¨?????????????????? op ?????????????????§???a op b ????¨??????????????????°?????????????????????????????????
????????????????????? op ??????"+"(???)???"-"(???)???"*"(???)???"/"(???)???????????¨?????????????????§????????????????????´?????????
?°???°?????\??????????????¨????????????????¨????????????¨????????????
???Input
??\???????????°????????????????????????????§???????????????????????????????????????????????????¢????????\????????¨????????§??????
 a op b
op ??? '?' ?????¨??? ??\?????????????????????????????????????????±???????????????????????£????????????????????????
???Output
?????????????????????????????????????¨??????????????????????????????????????????????
'''
# import
import sys

# ?????°??????????????????
for inputData in sys.stdin:
    inputList = inputData.split()
    a, op, b = int(inputList[0]), inputList[1], int(inputList[2])
    retVal = 0

    # 0?????´??? ????????????
    if op == '?':
        # exec end
        break
    elif op == '+':
        retVal = a + b
    elif op == '-':
        retVal = a - b
    elif op == '*':
        retVal = a * b
    elif op == '/':
        retVal = a // b
    else:
        retVal = 0

    # ????????????
    print(retVal)
import sys
input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))

H, W = inpl()
A = [inpl() for _ in range(H)]
B = [inpl() for _ in range(W)]

DP = [[0 for _ in range(W+1)] for _ in range(H+1)]
DP[0][0] = 1 << 12800

for h in range(H):
    for w in range(W):
        d = abs(A[h][w] - B[h][w])
        DP[h+1][w] |= DP[h][w] >> d
        DP[h+1][w] |= DP[h][w] << d
        DP[h][w+1] |= DP[h][w] >> d
        DP[h][w+1] |= DP[h][w] << d
l = 1 << 12800
r = 1 << 12800
for i in range(12801):
    if (DP[-1][-2]& l) | (DP[-1][-2] & r):
        print(i)
        break
    l = l << 1
    r = r >> 1

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
from itertools import product
from collections import Counter, defaultdict
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))

A = inpl()
if sum(A) >= 22:
    print("bust")
else:
    print("win")
n = int(input())
in_list = []
for i in range(n):
    in_list.append(list(map(int, input().split())))

matrices = [["0" for _ in range(n)] for _ in range(n)]

for i in range(n):
    inp = in_list[i]
    u = inp[0]
    k = inp[1]
    for j in range(k):
        m = inp[j+2]
        matrices[i][m-1] = "1"

for i in range(n):
    print(" ".join(matrices[i]))


### FIXED CODE ###

import bisect

n = int(input())
a_list = [int(input()) for i in range(n)]


def lis(n, A):
    L = [0 for i in range(n + 1)]
    L[0] = A[0]
    length = 1
    for i in range(1, n):
        if L[length - 1] < A[i]:
            L[length] = A[i]
            length += 1
        else:
            index = bisect.bisect_left(L, A[i], 0, length - 1)
            L[index] = A[i]
    return length


print(lis(n, a_list))
a = []
i = 0 //????????????

while True:
	n = input()
	if n == 0:
		break
	i += 1//?????????????????????
	print("Case {0} : {1}".format(i,n))

### FIXED CODE ###


i = 0 #????????????

while True:
	n = input()
	if n == '0':
		break
	i += 1#?????????????????????
	print('Case {}: {}'.format(i,n))
a = int(input())
b = int(input())
if(a+b > a * b and a+b > a-b):
    print(a+b)
elif(a*b > a + b and a*b > a - b):
    print(a*b)
else:
    print(a-b)

### FIXED CODE ###

a, b = map(int, input().split())
c = max([a +b, a-b, a*b])
print(c)
import math

a, b, x = map(int, input().split())

y = b - (x / a**2)
z = (4 * y**2 + a**2)**0.5

cos = (a**2 - 4*y**2 - z**2) / (-4 * y * z)

theta = math.degrees(math.acos(cos))

print(90 - theta)

### FIXED CODE ###

import math

a, b, x = map(int, input().split())

if x <= b * a**2 / 2:
    theta = math.degrees(math.atan2(b, 2*x/a/b))
else:
    theta = math.degrees(math.atan2(2*(a*b-x/a)/a, a))

print(theta)
import numpy as np

n = int(input())
a = []
lcm = 1
for i in range(n - 1):
    t = int(input())
    a.append(t)

lc = mp.lcm.reduce(a)

res = 0
for i in range(n - 1):
    res = res + lc / a[i]
    res = res % 1000000007

print(res)



### FIXED CODE ###

import fractions
def LCM(a, b):
    return(a // fractions.gcd(a, b) * b)

n = int(input())
a = list(map(int, input().split()))
lc = 1;

for i in range(n):
    lc = LCM(lc, a[i])

res = 0;
for i in range(n):
    res = res + (lc // a[i])

print(res % 1000000007)
import math
N = int(input())
print(math.factorial(N) % (10**9+7)

### FIXED CODE ###

import math
N = int(input())
print(math.factorial(N)%(10**9+7))
import sys

sys.setrecursionlimit(int(1e6))


class BIT:
	def __init__(self, n):
		self.n = n
		self.data = [0] * (n + 1)

	def get_sum(self, i):
		ret = 0
		while i > 0:
			ret += self.data[i]
			i -= (i & -i)
		return ret

	def add(self, i, w):
		if i == 0:
			return
		while i <= self.n:
			self.data[i] += w
			i += (i & -i)

def dfs(u, cnt):
	cnt += 1
	l[u] = cnt
	for c in tree[u]:
		cnt = dfs(c, cnt)
	cnt += 1
	r[u] = cnt
	return cnt

n = int(input())
l, r = [0] * n, [0] * n
tree = [set(map(int, input().split()[1:])) for _ in range(n)]

bit = BIT(dfs(0, 1))

q = int(input())
for _ in range(q):
	line = list(map(int, input().split()))
	if line[0]:
		print(bit.get_sum(r[line[1]] - 1))
	else:
		bit.add(l[line[1]], line[2])
		bit.add(r[line[1]], -line[2])


### FIXED CODE ###

import sys

sys.setrecursionlimit(int(1e6))


class BIT:
	def __init__(self, n):
		self.n = n
		self.data = [0] * (n + 1)

	def get_sum(self, i):
		ret = 0
		while i > 0:
			ret += self.data[i]
			i -= (i & -i)
		return ret

	def add(self, i, w):
		if i == 0:
			return
		while i <= self.n:
			self.data[i] += w
			i += (i & -i)

def dfs(u, cnt):
	cnt += 1
	l[u] = cnt
	for c in tree[u]:
		cnt = dfs(c, cnt)
	cnt += 1
	r[u] = cnt
	return cnt

n = int(input())
l, r = [0] * n, [0] * n
tree = [set(map(int, input().split()[1:])) for _ in range(n)]

bit = BIT(dfs(0, 1))

q = int(input())
for _ in range(q):
	line = list(map(int, input().split()))
	if line[0]:
		print(bit.get_sum(r[line[1]] - 1))
	else:
		bit.add(l[line[1]], line[2])
		bit.add(r[line[1]], -line[2])
import sys
from itertools import permutations, combinations, combinations_with_replacement, product

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N, K, *A = map(int, read().split())

ans = [0] * (N * (N - 1) // 2)
for i, p in enumerate(combinations(A, 2)):
    ans[i] = p[0] * p[1]

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


### FIXED CODE ###

import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)


def count(x):
    cnt = 0
    if x >= 0:
        cnt += N * len(zero)
    cnt += np.searchsorted(A, x // pos, side='right').sum()
    cnt += N * len(neg) - np.searchsorted(A, -(-x // neg), side='left').sum()
    cnt -= np.count_nonzero(A * A <= x)

    return cnt // 2


N, K, *A = map(int, read().split())
A = np.array(A)
A.sort()

neg = A[A < 0]
zero = A[A == 0]
pos = A[A > 0]

r = 10**18
l = -r

while r - l > 1:
    m = (r + l) // 2
    if count(m) >= K:
        r = m
    else:
        l = m

print(r)
import math
n = int(input())
s = int(input())
def solve(n, s):
    if n == s:
        return n+1
    for b in range(2, math.floor(n**0.5)+1):
        tmp = n
        res = 0
        while tmp>=b:
            res+=tmp%b
            tmp //=b
        res += tmp
        if res == s:
            return b
    for p in range(int(n**0.5), 0, -1):
        r = s-p
        if r<0:
            continue
        if (n-r)%p == 0:
            b = (n-r)//p
            if r<b and b*b>n:
                return b
    return -1
print(solve(n, s))

### FIXED CODE ###

n, a = map(int, input().split())
x=list(map(lambda x: int(x)-a, input().split()))
k=[[0]*3000 for i in range(60)]
for i in range(3000):
    k[0][i]=0
k[0][x[0]+1500]+=1
k[0][1500]+=1
for i in range(1, n):
    for j in range(3000):
        if 3000>j-x[i]>=0:
            k[i][j]=k[i-1][j-x[i]]+k[i-1][j]
        else:
            k[i][j]=k[i-1][j]
print(k[n-1][1500]-1)
import math

N, M = map(int, input().split())
S = input()
T = input()

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

d = math.gcd(N,M)
l = lcm(N,M)

s = [0 for i in range(0,d)]
t = [0 for i in range(0,d)]

for i in range(0,d):
    s[i] = S[i*(l//M)]
    t[i] = T[i*(l//N)]

if s == t:
    print(l)
else:
    print(-1)

### FIXED CODE ###

N, M = map(int, input().split())
S = input()
T = input()

def gcd(m,n):
    x = max(m,n)
    y = min(m,n)
    if x%y == 0:
        return y
    else:
        while x%y != 0:
            z = x%y
            x = y
            y = z
        else:
            return z

def lcm(m,n):
    return int(m * n /gcd(m,n))

d = gcd(N,M)
l = lcm(N,M)

s = [0 for i in range(0,d)]
t = [0 for i in range(0,d)]

a = int(l/M)
b = int(l/N)

for i in range(0,d):
    s[i] = S[i*a]
    t[i] = T[i*b]

if s == t:
    print(l)
else:
    print(-1)