Harryxun/stf_run huggingface dataset:
n=int(input())
a=[[int(x)-1 for x in input().split()] for _ in range(n)]

cnt=0
id=[[0]*n for _ in range(n)]
for i in range(n):
	for j in range(i+1,n):
		id[i][j] = cnt
		cnt+=1
def toid(x,y):
	return id[x][y] if x<y else id[y][x]

for i in range(n):
	for j in range(n-1):
		a[i][j] = toid(i,a[i][j])

nedge = n*(n-1)//2
g=[[]for _ in range(nedge)]

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

calced=[False]*nedge
visited=[False]*nedge
dp=[0]*nedge

def dfs(v):
	if visited[v]:
		if not calced[v]:
			return -1
		return dp[v]
	
	visited[v]=True
	dp[v]=1
	for u in g[v]:
		ret = dfs(u)
		if ret == -1:
			return -1
		dp[v] = max(dp[v],ret+1)
	
	calced[v]=True
	return dp[v]

ans = 0
for i in range(nedge):
	res = dfs(i)
	if res==-1:
		print(-1)
		exit()
	ans = max(ans,res)
print(ans)


### FIXED CODE ###

n=int(input())
a=[[int(x)-1 for x in input().split()] for _ in range(n)]

cnt=0
id=[[0]*n for _ in range(n)]
for i in range(n):
	for j in range(i+1,n):
		id[i][j] = cnt
		cnt+=1
def toid(x,y):
	return id[x][y] if x<y else id[y][x]

for i in range(n):
	for j in range(n-1):
		a[i][j] = toid(i,a[i][j])

nedge = n*(n-1)//2
g=[[]for _ in range(nedge)]
to = [0]*nedge
for i in range(n):
	for j in range(1,n-1):
		g[a[i][j-1]].append(a[i][j])
		to[a[i][j]]+=1

from collections import deque

dp=[1]*nedge
q=deque([])
cnt = 0
for i in range(nedge):
	if to[i]==0:
		q.append(i)
		cnt+=1

ans = 1
while(q):
	e = q.popleft()
	for ne in g[e]:
		dp[ne] = max(dp[ne],dp[e]+1)
		to[ne]-=1
		if to[ne]==0:
			q.append(ne)
			cnt+=1
	ans = max(ans,dp[e])

if cnt != nedge:
	print(-1)
else:
	print(ans)
N, M = map( int, input().split())
A = list( map( int, input().split()))
C = [0,2,5,5,4,5,6,3,7,6]
dp = [(0,0)]*(N+1)
for a in A:
    dp[C[a]] = (1,0)
Z = sorted( list( set( C[a] for a in A)))
for i in range(2,N+1):
    for z in Z:
        if i > z:
            if dp[i-z][0] == 1:
                dp[i] = (1, i-z)
                break
s = N
ANS = [0]*10
while s != 0:
    _, b = dp[s]
    ANS[s-b] += 1
    s = b
ans = ""
for i in range(9,0,-1):
    if ANS[C[i]] > 0:
        if i in A:
            ans = ans + str(i)*ANS[C[i]]
            ANS[C[i]] = 0
print( ans)

### FIXED CODE ###

N, M = map( int, input().split())
A = list( map( int, input().split()))
Needs = [0,2,5,5,4,5,6,3,7,6]
A.sort(reverse = True)
V = [0]*10
Check = []
for a in A:
    if V[Needs[a]] == 0:
        Check.append(Needs[a])
        V[Needs[a]] = a
Check.sort()
dp = [-100000]*(N+1)
dp[0] = 0

for x in Check:
    if x <= N:
        dp[x] = 1
for i in range(1,N):
    t = dp[i]
    for x in Check:
        if x + i <= N:
            if dp[x+i] < t + 1:
                dp[x+i] = t+1
ans = ""
t = N
W = [0]*10
while t > 0:
    for a in A:
        x = Needs[a]
        if t-x>=0:
            if dp[t-x]+1 == dp[t]:
                W[V[x]] += 1
                t -= x
                break
for i in range(9,0,-1):
    ans += str(i)*W[i]
print(ans)
import itertools
from collections import deque
import math
H, W = map(int,input().split())
#S=list(map(list,input().split()[6:]))
S = []
for i in range(H):
    a = list(map(str,input().split()))
    S.append(a)

#まずはスタートまたはゴールになりうるマス（外側のマス）を集める
start_or_goal = []
for i in range(H):
    a = S[i][0]
    b = S[i][W-1]
    c = []
    d = []
    if a == ".":
        c.append(i)
        c.append(0)
        if c not in start_or_goal:
            start_or_goal.append(c)
    if b == ".":
        d.append(i)
        d.append(W-1)
        if d not in start_or_goal:
            start_or_goal.append(d)
for i in range(W):
    a = S[0][i]
    b = S[H-1][i]
    c = []
    d = []
    if a == ".":
        c.append(0)
        c.append(i)
        if c not in start_or_goal:
            start_or_goal.append(c)
    if b == ".":
        d.append(H-1)
        d.append(i)
        if d not in start_or_goal:
            start_or_goal.append(d)
#スタートとゴールの組み合わせが分かった。
max_root = []
def bfs(h,w,sy,sx,gy,gx,maze):

    #maze=list(map(list,raw_input.split()[6:]))
    for y in range(h):
        for x in range(w):
            if maze[y][x]=='.':
                maze[y][x]=math.inf


    maze[sy-1][sx-1]=0
    que=deque([[sy-1,sx-1]])
    while que:
        y,x=que.popleft()
        for i,j in [(1,0),(0,1),(-1,0),(0,-1)]:
            nexty,nextx=y+i,x+j
            dist=maze[nexty][nextx]
            if dist!='#':
                if dist>maze[y][x]+1:
                    maze[nexty][nextx]=maze[y][x]+1
                    que.append([nexty,nextx])
    return maze[gy-1][gx-1]

s_to_g = list(itertools.combinations(start_or_goal,2))
for i in range(len(s_to_g)):
    sy = s_to_g[i][0][0]+1
    sx = s_to_g[i][0][1]+1
    gy = s_to_g[i][1][0]+1
    gx = s_to_g[i][1][1]+1
    ans = bfs(H,W,sy,sx,gy,gx,S)
    max_root.append(ans)
ans = max(max_root)
print(ans)

### FIXED CODE ###

from collections import deque

def bfs(maze,dist,sy,sx):
    #キューオブジェクトの生成
    queue = deque([[sy,sx]])
    dist[sy][sx] = 0
    md = 0
    l = []
    while queue:
        #先頭から要素を一つ削除する
        y,x = queue.popleft()
        for j, k in ([1,0],[-1,0],[0,1],[0,-1]):
            new_y, new_x = y+j, x+k
            #迷路内に収まっているか確かめる
            if 0 <= new_y < H and 0 <= new_x < W:
                #道かどうか確かめる
                if maze[new_y][new_x] == "." and dist[new_y][new_x] == -1:
                    dist[new_y][new_x] = dist[y][x] + 1
                    queue.append([new_y, new_x])
                    md = max(dist[new_y][new_x],md)
    return md
H, W = map(int,input().split())
maze = [input() for i in range(H)]

ans = 0
for i in range(H):
    for j in range(W):
        dist = [[-1]*W for j in range(H)]
        if maze[i][j] != "#":
            a = bfs(maze,dist,i,j)
            ans = max(a,ans)
print(ans)
# abc120_b.py
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)
def gcd_list(numbers):
    return reduce(math.gcd, numbers)

A, B, K = map(int,input().split())
cnt = 0
_max = gcd(A,B)
while _max>=0:
    if A%_max==0 and B%_max==0:
        cnt += 1
        if cnt == K:
            print(_max)
            exit()
    _max -=1


### FIXED CODE ###

# abc120_b.py
import fractions 
from functools import reduce
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

A, B, K = map(int,input().split())
cnt = 0
_max = gcd(A,B)
while _max>=0:
    if A%_max==0 and B%_max==0:
        cnt += 1
        if cnt == K:
            print(_max)
            exit()
    _max -=1
s=input().split()
money,num=int(s[0]),int(s[1])
no_list=input().split()
for i in range(money,100000):
  	flag=0
    for money_element in list(str(i)):
        if money_element in no_list:
            flag=1
            break
    if flag==0:
        print(i)
        break












### FIXED CODE ###

s=input().split()
money,num=int(s[0]),int(s[1])
no_list=input().split()
for i in range(money,100000):
    flag=0
    for money_element in list(str(i)):
        if money_element in no_list:
            flag=1
            break
    if flag==0:
        print(i)
        break
from collections import deque
n = int(input())

d = deque()

for _ in range(n):
    com = input()

    if (com[0] == 'i'):
        com ,i = com.split()
        d.appendleft(int(i))
    elif (com[0] == 'd'):
        if (com[7].isdigit()):
            com, i = com.split()
            d.remove(int(i))
        elif (com[6] == 'F'):
            d.popleft()
        elif (com[6] == 'L'):
            d.pop()
ans = map(str, d)
ans = " ".join(ans)
print(ans)

### FIXED CODE ###

from collections import deque
n = int(input())

d = deque()

for _ in range(n):
    com = input()
    if (com[0] == 'i'):
        com ,i = com.split()
        d.appendleft(int(i))
    elif (com[0] == 'd'):
        if (com[6] == ' '):
            com, i = com.split()
            try:
                d.remove(int(i))
            except ValueError:
                pass
        elif (com[6] == 'F'):
            d.popleft()
        elif (com[6] == 'L'):
            d.pop()
ans = map(str, d)
ans = " ".join(ans)
print(ans)
n = int(input())
s = str(input())
ans = 0
for i in range(1,len(s)):
    #print(t[:i], t[i:])
    left = set(list(t[:1]))
    right = set(list(t[i:]))
    kyoutuu = left & right
    ans = max(ans,kyoutuu)
print(y)

### FIXED CODE ###

n = int(input())
t = str(input())
ans = 0
for i in range(1,len(t)):
    #print(t[:i], t[i:])
    left = list(t[:i])
    right = list(t[i:])
    #print(left,right)
    kyoutuu = set(left) & set(right)
    j = len(list(kyoutuu))
    if ans < j:
        ans = j
print(ans)
l = input()
m = input()
z = l.split(" ")
M = int(z[1])
F = m.split(" ")
X = []
amount=0
for item in F:
  votes = int(item)
  amount = amount + votes
  X.append(votes)
  X.sort(reverse=True)
C = (1/4M)*amount
for i in range(M):
  if X[i]<C:
    print("No")
    return
print("Yes")


### FIXED CODE ###

l = input()
m = input()
z = l.split(' ')
M = int(z[1])
N = int(z[0])
F = m.split(' ')
X = []
 
for item in F:
  votes = int(item)
  X.append(votes)

S = sum(X)
C = (S/(4*M))
X.sort(reverse=True)
if X[M-1]<C:
  print("No")
else:
  print("Yes")
bound_num, line_length = map(int, input().split())
l = list(map(int, input().split()))

bound = 1
length_sum = 0
for i in range(bound_num + 1):
    if(i == bound_num + 1):
        bound += 1
        print(bound)
        exit()
    if(length_sum + l[i] <= line_length):
        bound += 1
    else:
        print(bound)
        exit()
    length_sum += l[i]


### FIXED CODE ###

bound_num, line_length = map(int, input().split())
l = list(map(int, input().split()))

bound = 1
length_sum = 0
for i in range(bound_num + 1):
    if(i == bound_num):
        print(len(l)+1)
        exit()
    if(length_sum + l[i] <= line_length):
        bound += 1
    else:
        print(bound)
        exit()
    length_sum += l[i]
s = list(map(int,input().split()))
cnt = 0
for i in range(3):
  if s[i]!=s[i+1]:
    cnt=i
    break
if cnt>=2:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

n = input()
mae_n = n[:-1]
ushiro_n = n[1:]
if (len(set(mae_n))==1)or(len(set(ushiro_n))==1):
  print("Yes")
else:
  print("No")
a,b=map(int,input().split())
import math
print(a*b//math.gcd(a,b))


### FIXED CODE ###

a,b=map(int,input().split())
import fractions
print(a*b//fractions.gcd(a,b))
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

if A - B == 0 and V != W:
    print('NO')
    exit()

if ((B - A) / (V - W)).is_integer() and ((B - A) / (V - W)) > 0:
    print('YES')
else:
    print('NO')


### FIXED CODE ###

A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

if V == W:
    print('NO')
    exit()

if 0 <= (abs(B - A) / (V - W)) <= T:
    print('YES')
else:
    print('NO')
import numpy as np
import itertools
 
H, W, K = list(map(int, input().split())) 
c = [input().split() for l in range(H)]
b=[]
d=[]
for m in range(len(c)):
  for item in c[m]:
    item_mod = item.replace("."  , "0")
    item_mod = item_mod.replace("#" , "1")
    b.append(item_mod)
  d.append(b)
  b=[]

C_arr = np.array(d , dtype = "int")
C_arr = C_arr.reshape((H, W))
 
In = np.array(list(itertools.product([0,1] , repeat=H)))
Out = np.array(list(itertools.product([0,1] , repeat=W)))
 
ans = 0
for i in range(2**H):
  for j in range(2**W):
    In_matrix = np.diag(In[i])
    Out_matrix = np.diag(Out[j])
 
    In_C = np.dot(In_matrix , C_arr)
    In_C_Out = np.dot(In_C , Out_matrix)
 
    ICO = In_C_Out.flatten()
    ICO = ICO.tolist()
 
    if ICO.count(1) == K:
      ans += 1
      
print(ans)

### FIXED CODE ###

H, W, K = list(map(int, input().split()))
 
c = [list(input()) for i in range(H)]
 
cnt = 0
for i in range(2**H):
    for j in range(2**W):
        cnt_black = 0
        for k in range(H):
            if (i >> k) & 1:
                continue
            for l in range(W):
                if (j >> l) & 1:
                    continue
                if c[k][l] == '#':
                    cnt_black += 1
        if cnt_black == K:
            cnt += 1
 
print(cnt)
a=input().split('')
print(int(a[0])*int(a[1]), end=' ')
print(int(a[0]*2+a[1]*2)

### FIXED CODE ###

a=input().split()
print(int(a[0])*int(a[1]), end=' ')
print(int(a[0])*2+int(a[1])*2)
n,q = map(int, input().split())
s = input()
t = []
for i in range(len(s)):
  if s[i] == "A" and s[i+1] == "C":
    t.append(i+1)
for i in range(q):
  l,r = map(int, input().split())
  print(len([1 for i in t if l <= i and i+1 <= r]))

### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
	t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
	l, r = map(int, input().split())
	print(t[r-1] - t[l-1])
n_in = int(input()) 
l = [int(input()) for i in range(n_in)] 

p = l[0]
for i in range(1, len(l)):
    q = l[i]

    if p >= q:
        m = p
        n = q
    else:
        m = q
        n = p

    while True:
        mod_value = m % n

        if mod_value  == 0:
            n = mod_value
            break

        m = n
        n = mod_value

    p = int(p*q/n)

print(p)

### FIXED CODE ###

n_in = int(input()) 
t = [int(input()) for i in range(n_in)] 

p = t[0]
for i in range(1, len(t)):
    q = t[i]

    if p >= q:
        m, n = p, q
    else:
        m, n = q, p

    while True:
        mod_value = m % n
        if mod_value  == 0:
            break

        m = n
        n = mod_value

    p = p//n * q

print(p)
import math
N, K = map(int, input().split())
L = N-K
M = 1e9+7

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



for i in range(K):
    i += 1 #iは1からkまで
    B_sla = cmb(K-1, i-1)
    R = L-(i-1)
    if R == 0:
        R_ire = 1
    elif R < 0:
        R_ire = 0
    else:
        R_ire = cmb(R+i, R)

    print(int(B_sla*R_ire%M))

### FIXED CODE ###

N, K = map(int, input().split())
#組み合わせ -------------------------------------------------
mod = int(1e9+7) #適宜変更
Max = 2001 #適宜変更
fac = [0]*(Max)
finv = [0]*(Max)
inv = [0]*(Max)
fac[0]=fac[1]=1
finv[0]=finv[1]=1
inv[1]=1
for i in range(2,Max):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod%i]*(mod//i)%mod
        finv[i] = finv[i-1]*inv[i]%mod
def Comb(n,r):
    if n < r:
        return 0
    if n < 0 or r < 0 :
        return 0
    return fac[n]*(finv[r]*finv[n-r]%mod)%mod

for i in range(K):
    i += 1 #iは1からkまで
    B_sla = Comb(K-1, i-1)
    R = N-K-(i-1)
    if R == 0:
        R_ire = 1
    elif R < 0:
        R_ire = 0
    else:
        R_ire = Comb(R+i, R)

    print(int(B_sla*R_ire%mod))
N = int(input())
cards = map(int, input().split())
A, B = 0, 0
for idx in range(N):
  if idx % 2 == 0:
    A += cards[idx]
  else:
    B += cards[idx]
print(A - B)

### FIXED CODE ###

N = int(input())
cards = sorted(list(map(int, input().split())), reverse=True)
A, B = 0, 0
for idx in range(N):
  if idx % 2 == 0:
    A += cards[idx]
  else:
    B += cards[idx]
print(A - B)
import math
from numba import njit
import numpy as np

@njit((i8, i8, i8, i8[:]), cache=True)
def solve():
    
    r,c,k = map(int,input().split())

    value = np.zeros((r,c), dtype=np.int64)
    for i in range(k):
        r_t,c_t,v_t = map(int,input().split())
        value[r_t-1][c_t-1] = v_t

    dp = np.zeros((r,c,4), dtype=np.int64)
    dp[0][0][0] = 0

    for i in range(r):
        for j in range(c):
            for m in range(4):
                if i + 1 < r:
                    dp[i+1][j][0] = max(dp[i+1][j][0],dp[i][j][m])
                if j + 1 < c:
                    dp[i][j+1][m] = max(dp[i][j+1][m],dp[i][j][m])
                if value[i][j] != 0 and m < 3:
                    if i + 1 < r:
                        dp[i+1][j][0] = max(dp[i+1][j][0],dp[i][j][m]+value[i][j])
                    if j + 1 < c:
                        dp[i][j+1][m+1] = max(dp[i][j+1][m+1],dp[i][j][m]+value[i][j])

    for m in range(2,-1,-1):
        dp[r-1][c-1][m+1] = max(dp[r-1][c-1][m+1],dp[r-1][c-1][m]+value[r-1][c-1])
    return max(dp[r-1][c-1])

print(solve())

### FIXED CODE ###

import math
from numba import jit
import numpy as np

@jit
def solve():
    
    r,c,k = map(int,input().split())

    value = np.zeros((r,c), dtype=np.int64)
    for i in range(k):
        r_t,c_t,v_t = map(int,input().split())
        value[r_t-1][c_t-1] = v_t

    dp = np.zeros((r,c,4), dtype=np.int64)
    dp[0][0][0] = 0

    for i in range(r):
        for j in range(c):
            for m in range(4):
                if i + 1 < r:
                    dp[i+1][j][0] = max(dp[i+1][j][0],dp[i][j][m])
                if j + 1 < c:
                    dp[i][j+1][m] = max(dp[i][j+1][m],dp[i][j][m])
                if value[i][j] != 0 and m < 3:
                    if i + 1 < r:
                        dp[i+1][j][0] = max(dp[i+1][j][0],dp[i][j][m]+value[i][j])
                    if j + 1 < c:
                        dp[i][j+1][m+1] = max(dp[i][j+1][m+1],dp[i][j][m]+value[i][j])

    for m in range(2,-1,-1):
        dp[r-1][c-1][m+1] = max(dp[r-1][c-1][m+1],dp[r-1][c-1][m]+value[r-1][c-1])
    return max(dp[r-1][c-1])

print(solve())
n, r = map(int(input()))
if n >= 10:
    rating = r
else:
    rating = 100 * (10 - n)
print(rating)

### FIXED CODE ###

n, r = map(int, input().split())
if n >= 10:
    rating = r
else:
    rating = r + 100 * (10 - n)
print(rating)
S = int(input())
h = S // 3600
m = (S - S // 3600 * 3600) // 60
s = (S - S // 3600 * 3600) - m * 60
print(h:,m:,s)

### FIXED CODE ###

S = int(input())
h = S // 3600
m = S % 3600 // 60
s = S % 3600 - m * 60
print("{0}:{1}:{2}".format(h,m,s))
o=input()
e=input()
O=len(o)
E=len(e)
ans=''
if O==E:
  for i in range(O):
    ans+=o[i]+e[i]
if O+1==E:
  for i in range(O):
    ans+=o[i]+e[i]
  ans+=e[-1]
if O-1==E:
  for i in range(O):
    ans+=o[i]+e[i]
  ans+=o[-1]
print(ans)

### FIXED CODE ###

o=input()
e=input()
O=len(o)
E=len(e)
ans=''
if O==E:
  for i in range(O):
    ans+=o[i]+e[i]
if O+1==E:
  for i in range(O):
    ans+=o[i]+e[i]
  ans+=e[-1]
if O-1==E:
  for i in range(E):
    ans+=o[i]+e[i]
  ans+=o[-1]
print(ans)
import math
a,b,c,d=map(int,input().split())
a-=1
bIka=b-b//c-b//d+b//(c*d//math.gcd(c,d))
aMiman=a-a//c-a//d+a//(c*d//math.gcd(c,d))
print(bIka-aMiman)

### FIXED CODE ###

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
a,b,c,d=map(int,input().split())
a-=1
bIka=b-b//c-b//d+b//(c*d//gcd(c,d))
aMiman=a-a//c-a//d+a//(c*d//gcd(c,d))
print(bIka-aMiman)
K, X = map(int,input().split())
for i in range(X-K+1, X+K-1):
    print(i," ",  end = "")
print(i+1)

### FIXED CODE ###

K, X = map(int,input().split())
if K == 1:
    print(X)
else:
    for i in range(X-K+1, X+K-1):
        print(i," ",  end = "")
    print(i+1)
from numpy import*
M=10**9+7
_,a=open(0)
a=int64(a.split())
print(sum(lcm.reduce(a)//a)%M)

### FIXED CODE ###

from fractions import*
from functools import*
M=10**9+7
_,a=open(0)
*a,=map(int,a.split())
s=reduce(lambda x,y:x//gcd(x,y)*y,a)%M
c=0
for i in a:
    c+=s*pow(i,M-2,M)
    c%=M
print(c)
a, b = map(int, input().split())
sum = a*b
if sum // 2 = 0:
  print("Even")
  
else:
  print("Odd")

### FIXED CODE ###

a, b = map(int, input().split())
sum = a*b
if sum % 2 == 0:
  print("Even")
  
else:
  print("Odd")
import sys

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()
l = nl()
f = list(filter(lambda x:x>0, l))
g = list(filter(lambda x:x<0, l))
f.sort(); g.sort(reverse=True)
pl = len(f); mi = len(g)
ze = n - pl - mi
tomi = pl*mi
if tomi >= k:
    def jud(z):
        ret = 0
        i = mi
        for x in f:
            while i and x*g[i-1] <= z: i -= 1
            ret += mi - i
        return ret
    ok,ng = 0,max(f)*min(g)-1
    while ok - ng > 1:
        mid = (ok+ng)//2
        if jud(mid) < k:
            ng = mid
        else:
            ok = mid
    print(ok)
    exit(0)

tomi += ze*(n-ze) + (ze-1)*ze//2
if tomi >= k:
    print(0); exit(0)

else:
    k -= tomi
    def jud2(z):
        ret = 0
        i = pl
        for e,x in enumerate(f):
            while i and f[i-1]*x > z: i -= 1
            ret += i - (e<=i-1)
        i = mi
        for e,x in enumerate(g):
            while i and g[i-1]*x > z: i -= 1
            ret += i - (e<=i-1)
        return ret//2
    ok,ng = 0,max(max(f)**2, min(g)**2)
    while ng - ok > 1:
        mid = (ok+ng)//2
        if jud2(mid) < k:
            ok = mid
        else:
            ng = mid
    print(ng)


### FIXED CODE ###

import sys

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()
l = nl()
f = list(filter(lambda x:x>0, l))
g = list(filter(lambda x:x<0, l))
f.sort(); g.sort(reverse=True)
pl = len(f); mi = len(g)
ze = n - pl - mi
tomi = pl*mi
if tomi >= k:
    def jud(z):
        ret = 0
        i = mi
        for x in f:
            while i and x*g[i-1] <= z: i -= 1
            ret += mi - i
        return ret
    ok,ng = 0,max(f)*min(g)-1
    while ok - ng > 1:
        mid = (ok+ng)//2
        if jud(mid) < k:
            ng = mid
        else:
            ok = mid
    print(ok)
    exit(0)

tomi += ze*(n-ze) + (ze-1)*ze//2
if tomi >= k:
    print(0); exit(0)

else:
    k -= tomi
    def jud2(z):
        ret = 0
        i = pl
        for e,x in enumerate(f):
            while i and f[i-1]*x > z: i -= 1
            ret += i - (e<=i-1)
        i = mi
        for e,x in enumerate(g):
            while i and g[i-1]*x > z: i -= 1
            ret += i - (e<=i-1)
        return ret//2
    ok,ng = 0,max(max(f+[0])**2, min(g+[0])**2)
    while ng - ok > 1:
        mid = (ok+ng)//2
        if jud2(mid) < k:
            ok = mid
        else:
            ng = mid
    print(ng)