Harryxun/stf_run huggingface dataset:
X, Y = map(int, input().split())
mod = 10**9+7
b = (2*Y-X)//3
a = Y - 2*b
max_num = a + b + 5
facts = [1 for i in range(max_num)]
invs = [1 for i in range(max_num)]
 
def inv(x):
    return pow(x,mod-2,mod)
 
for i in range(1,max_num):
    facts[i] = facts[i-1]*i%mod
    invs[i] = inv(facts[i])
 
def nCk(n,k):
    return facts[n]*invs[k] * invs[n-k] % mod

if (X+Y)%3 == 0:
    print(nCk(a+b, a))
else:
    print(0)

### FIXED CODE ###

def sq(a, b, mod):  # aのb乗を剰余,kは初期値#20191116-D-Knight
    if b == 0:
        return 1
    elif b % 2 == 0:
        return sq(a, b // 2, mod)**2 % mod
    else:
        return sq(a, b - 1, mod) * a % mod


def nCk(n, k, mod=10**9 + 7):
    x = max(k, n - k)
    y = min(k, n - k)
    kkai = 1
    for i in range(2, y + 1):
        kkai = (kkai * i) % mod
    nkkai = 1
    for i in range(x + 1, n + 1):
        nkkai = (nkkai * i) % mod
    answer = sq(kkai, mod - 2, mod) * nkkai % mod
    return answer


from sys import exit
X, Y = map(int, input().split())
if (X + Y) % 3 != 0:
    print(0)
    exit()

if X % 2 == 0:
    syurui = X - (X // 2) + 1
else:
    syurui = X - (X // 2)
for i in range(syurui):
    two = i
    one = X - two * 2
    if (two + one * 2) == Y:
        print(nCk(two + one, two))
        exit()
print(0)
words = input().split(",")
for word in words:
    for w in word:
       if w.isalpha == True:
           if w.isupper() == True:
               w.lower()
            elif w.islower == True:
                w.upper()
print(",".join(words))

    

### FIXED CODE ###

print(input().swapcase())
N, K = map(int, input().split())
A = list(map(int, input().split()))
visited = [False for _ in range(N)]

i = 1
c = 0
jun = []

if K <= N:
    while True:
        K -= 1
        i = A[i-1]
        if K == 0:
            print(i)
            exit()


while True:
    if i == A[i-1]:
        print(i)
        exit()
    if visited[i-1]:
        lp = i
        break
    else:
        visited[i - 1] = True
        jun.append(i)
        i = A[i-1]
        c += 1
ji = jun.index(lp)
K -= len(jun[:ji])
jun = jun[lp:]

kai = K % c

if kai == len(jun) + 1:
    print(jun[0])
else:
    print(jun[kai-1])

### FIXED CODE ###

from itertools import combinations

N, M, X = map(int, input().split())
box = [list(map(int, input().split())) for _ in range(N)]

ans = -1

for j in range(1, N+1):
    for i in combinations(box, j):
        kakaku = 0
        rika = [0 for _ in range(M)]
        for el in i:
            kakaku += el[0]
            for n, k in enumerate(el[1:]):
                rika[n] += k

        if all(p >= X for p in rika):
            if ans == -1:
                ans = kakaku
            else:
                ans = min(kakaku, ans)

print(ans)
t = input()
if(t[0] == '?'):
    if  (t[1] == 'D'): t = "".join(['P' , t[1:]])
    elif(t[1] == '?'): t = "".join(['PD', t[2:]])
    else:              t = "".join(['D' , t[1:]])
if(t[-1] == '?'):
    t = "".join([t[:-1], 'D'])
for i in range(len(t)):
    if(t[i] == '?'):
        if(t[i-1] == 'P'):    t = "".join([t[:i], 'D' , t[i+1:]])
        elif(t[i+1] == 'D'):  t = "".join([t[:i], 'P' , t[i+1:]])
        elif(t[i+1] == 'P'):  t = "".join([t[:i], 'D' , t[i+1:]])
        elif(t[i+1] == '?'):  t = "".join([t[:i], 'PD', t[i+2:]])
print(t)

### FIXED CODE ###

t = input()
if(len(t) == 1):
    if (t[0] == '?'): t = "D"
if(t[0] == '?'):
    if  (t[1] == 'D'): t = "".join(['P' , t[1:]])
    elif(t[1] == '?'): t = "".join(['PD', t[2:]])
    else:              t = "".join(['D' , t[1:]])
if(t[-1] == '?'):
    t = "".join([t[:-1], 'D'])
for i in range(len(t)-1):
    if(t[i] == '?'):
        if(t[i-1] == 'P'):    t = "".join([t[:i], 'D' , t[i+1:]])
        elif(t[i+1] == 'D'):  t = "".join([t[:i], 'P' , t[i+1:]])
        elif(t[i+1] == 'P'):  t = "".join([t[:i], 'D' , t[i+1:]])
        elif(t[i+1] == '?'):  t = "".join([t[:i], 'PD', t[i+2:]])
print(t)
import itertools
N, M, Q = map(int,input().split())
L = []
for _ in range(Q):
    L.append(list(map(int,input().split())))

A = itertools.combinations_with_replacement([i for i in range(1,M+1)], N)
count = []
for a in A:
    temp = 0
    for l in l:
        if a[l[1]-1] - a[l[0]-1] == l[2]:
            temp += l[3]
    count.append(temp)
print(max(count))

### FIXED CODE ###

import itertools
N, M, Q = map(int,input().split())
L = []
for _ in range(Q):
    L.append(list(map(int,input().split())))

A = itertools.combinations_with_replacement([i for i in range(1,M+1)], N)
count = []
for a in A:
    temp = 0
    for l in L:
        if a[l[1]-1] - a[l[0]-1] == l[2]:
            temp += l[3]
    count.append(temp)
print(max(count))
def cmb(n, r):
    if n <= 0 or n < r:
        return 0
    if n == r or r == 0:
        return 1
    if r == 1:
        return n
    return cmb(n-1,r-1) + cmb(n-1,r)
def main():
    n = int(input())
    a = list(map(int, input().split()))
    cnts = [0]*(n+1)
    for v in a:
        cnts[v] += 1
    buf = 0
    for i in range(n+1):
        if cnts[i] > 0:
            buf += cmb(cnts[i], 2)
    for i in range(n):
        x = a[i]
        if cnts[x] <= 1:
            print(buf)
        else:
            ans = buf
            ans -= cmb(cnts[x], 2)
            print(ans + cmb(cnts[x]-1, 2))

if __name__ == "__main__":
    main()

### FIXED CODE ###

def perm(n, r):
    rtn = 1
    for i in range(r):
        rtn *= n-i
    return rtn

def cmb(n, r):
    return perm(n, r) // perm(r, r)

def main():
    n = int(input())
    a = list(map(int, input().split()))
    cnts = [0]*(2*10**5 + 1)
    for v in a:
        cnts[v] += 1
    buf = 0
    for i in range(2*10**5 + 1):
        if cnts[i] > 0:
            buf += cmb(cnts[i], 2)
    for i in range(n):
        x = a[i]
        if cnts[x] <= 1:
            print(buf)
        else:
            ans = buf
            ans -= cmb(cnts[x], 2)
            print(ans + cmb(cnts[x]-1, 2))

if __name__ == "__main__":
    main()
inp=input()
former=int(inp[0]+inp[1])
latter=int(inp[2]+inp[3])

if 0=< former <=12 and 0=< latter <=12:
	print("AMBIGUOUS")
elif 0=< former <=12 and 12=< latter:
	print("MMYY")
elif 0=< latter <=12 and 12=< former:
	print("YYMM")

else:
	print("NA")

### FIXED CODE ###

inp=input()
former=int(inp[0]+inp[1])
latter=int(inp[2]+inp[3])

if 0< former <=12 and 0< latter <=12:
	print("AMBIGUOUS")
elif 0< former <=12 :
	print("MMYY")
elif 0< latter <=12 :
	print("YYMM")
else:
	print("NA")
L,R=map(int,input().split())
if (R-L)>=2018:
  print(0)
else:
  ans=2019
  for i in range(L,R):
    for j in range(i+1,R+1):
      ans=min(ans,I*j//2019)
print(ans)
  

### FIXED CODE ###

L,R=map(int,input().split())
if (R-L)>=2018:
  print(0)
else:
  ans=2019
  for i in range(L,R):
    for j in range(i+1,R+1):
      ans=min(ans,(i*j)%2019)
  print(ans)
import sys
input = sys.stdin.readline

N, Q = map(int, input().split())
edges = [[] for _ in range(N)]
edges[0] = 0
for _ in range(N-1):
    a, b = map(int, input().split())
    edges[b-1] = a-1

counts = [0]*N
for _ in range(Q):
    p, x = map(int, input().split())
    counts[p-1] += x

print(counts[0], end=' ')
for i in range(1, N):
    counts[i] += counts[edges[i]]
    print(counts[i], end=' ')

### FIXED CODE ###

from collections import deque
import sys
input = sys.stdin.readline

def main():
    N, Q = map(int, input().split())
    # edges = [None]*N
    edges = [[] for _ in range(N)]
    # edges[0] = 0
    # edges[0].append = 0
    for _ in range(N-1):
        a, b = map(int, input().split())
        edges[b-1].append(a-1)
        edges[a-1].append(b-1)

    counts = [0]*N
    for _ in range(Q):
        p, x = map(int, input().split())
        counts[p-1] += x

    parent_nodes = deque()
    parent_nodes.append(0)
    visited_nodes = set()
    while parent_nodes:
        parent = parent_nodes.popleft()
        if parent in visited_nodes:
            continue
        visited_nodes.add(parent)
        for child in edges[parent]:
            if child in visited_nodes:
                continue
            counts[child] += counts[parent]
            parent_nodes.append(child)

    print(' '.join(list(map(str, counts))))

if __name__ == "__main__":
    main()
from collections import defaultdict

n = int(input())
arr = map(int, input().split())
arr = tuple(sorted(enumerate(arr), key=lambda tpl: -tpl[1]))

dp = defaultdict(int)

def cal(ln, rn):
  if ln + rn > n:
    return

  if ln > 0 or rn > 0:
    idx = ln + rn - 1
    p, a = arr[idx]
    val_l = dp[ln - 1, rn] + a * abs(p - (ln - 1)) if ln > 0 else 0
    val_r = dp[ln, rn - 1] + a * abs(p - (n - rn)) if rn > 0 else 0

    dp[ln, rn] = max(val_l, val_r)

  cal(ln + 1, rn)
  cal(ln, rn + 1)

cal(0, 0)

print(max([dp[i, n - i] for i in range(n + 1)]))


### FIXED CODE ###


def main():

  n = int(input())
  arr = map(int, input().split())
  arr = tuple(sorted(enumerate(arr), key=lambda tpl: -tpl[1]))

  dp = [[0] * (n + 1) for _ in range(n + 1)]
  for i, (p, a) in enumerate(arr):
    for l in range(i + 1):
      dp[i + 1][l] = max(dp[i + 1][l], dp[i][l] + a * abs(p - (n - (i - l) - 1)))
      dp[i + 1][l + 1] = max(dp[i + 1][l + 1], dp[i][l] + a * abs(p - l))

  print(max(dp[n]))

main()
import numpy as np
N, Q = list(map(int, input().split()))
S = input()
for i in range(Q):
  l, r = list(map(int, input().split()))
  print(np.sum([1 for i in range(len(S)) if S[i:i+1] == "AC"])

### FIXED CODE ###

import numpy as np
N, Q = list(map(int, input().split()))
S = input()
t = [0] * N
for j in range(1, N):
  t[j] = t[j-1] + 1 if S[j-1:j+1] == "AC" else t[j-1]
for i in range(Q):
  l, r = list(map(int, input().split()))
  print(t[r-1]-t[l-1])
import math

def better_gcd(a,b,c):
    tup = set((a,b,c))
    kinds = len(tup)
    if kinds == 3:
        return math.gcd(a, math.gcd(b, c)) * 6
    elif kinds == 2:
        return math.gcd(*tup) * 3
    else:
        return a

ans = 0
cands = list(itertools.combinations_with_replacement(range(200), 3))
for c in cands:
    ans += better_gcd(*c)
print(ans)

### FIXED CODE ###

K = int(input())
# K = 2
import math
import itertools

def better_gcd(a,b,c):
    tup = set((a,b,c))
    kinds = len(tup)
    if kinds == 3:
        return math.gcd(a, math.gcd(b, c)) * 6
    elif kinds == 2:
        return math.gcd(*tup) * 3
    else:
        return a

ans = 0
cands = list(itertools.combinations_with_replacement(range(1,K+1), 3))
for c in cands:
    ans += better_gcd(*c)
print(ans)
A,B=map(int,input())
m = max(A*B, A+B, A-B)
print(m)

### FIXED CODE ###

A, B = map(int,input().split(" "))
m = max(A*B, A+B, A-B)
print(m)
from functools import reduce
from collections import Counter
n = int(input())
c = Counter(int(s) for s in input().split())
ds = [0] * max(c.keys() + 1)
for k, v in c.items():
  ds[k] = v
print(reduce(lambda x, y: x * y, (x ** y for x, y in zip(ds[:-1], ds[1:])), 1) if ds[0] == 1 else 0)

### FIXED CODE ###

from collections import Counter
from functools import reduce
n = int(input())
d = (int(s) for s in input().split())
if next(d) != 0:
    print(0)
    quit(0)
c = Counter(d)
if c[0] != 0:
    print(0)
    quit(0)
print(reduce(lambda x, y: x * y, (c[k - 1] ** x if k > 1 else 1 for k, x in c.items()), 1) % 998244353)
n = int(input())
ans = 0
cnt = 0

for i in range(1,n+1):
  for j in range(1,n+1):
    if i%j = 0:
      ans += 1
    if ans = 8:
      cnt += 1

print(cnt)
      

### FIXED CODE ###

N=int(input())

result=0
for i in range(1,N+1):
    if i%2!=0:
        divisor=0
        for j in range(1,i+1):
            if i%j==0:
                divisor+=1
        if divisor==8:
            result+=1
print(result)
def main():
  out = 0
  for i in range(1, n+1):
    if dp[i]:
        di = dp[i]
        if di > out:
            out = di
    else:
        di = cal(i)
        if di > out:
            out = di
  print(out)

def cal(a):
  if xy[a]:
    ans = []
    for b in xy[a]:
      num = cal(b)
      dp[b] = num
      ans.append(num+1)
    return max(ans)
  return 0

if __name__ == "__main__":
  sys.setrecursionlimit(100000)
  n, m = map(int, input().split())
  xy = [set() for _ in range(n+1)]
  dp = [None]*(n+1)
  for _ in range(m):
    x, y = map(int, input().split())
    xy[x].add(y)
  main()

### FIXED CODE ###

import sys

def main():
  out = 0
  for i in range(1, n+1):
    if dp[i]:
        di = dp[i]
        if di > out:
            out = di
    else:
        di = cal(i)
        if di > out:
            out = di
  print(out)

def cal(a):
  if xy[a]:
    ans = 0
    for b in xy[a]:
      if dp[b]:
        num = dp[b]
      else:
        num = cal(b)
        dp[b] = num
      if num+1 > ans:
        ans = num+1
    return ans
  return 0

if __name__ == "__main__":
  sys.setrecursionlimit(100000)
  n, m = map(int, input().split())
  xy = [set() for _ in range(n+1)]
  dp = [None]*(n+1)
  for _ in range(m):
    x, y = map(int, input().split())
    xy[x].add(y)
  main()
nums = [1, 1]
def step_div(n):
	i = len(nums)
	while i <= n:
		nums.append(nums[i-1] * i)
		i += 1
	return nums[n]

n, m = map(int, input().split(" "))

remain = abs(n-m)
if remain <= 1:
	print((step_div(n) * step_div(m) * 2) % (10**9+7))
else:
	print(0)


### FIXED CODE ###

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

if 0 <= a - b:
    print("delicious")
elif b - a <= x:
    print("safe")
else:
    print("dangerous")
mod = 1e9 + 7
def comb(n, r):
    if n == 0 or r == 0:
        return 1
    elif n < r:
        return 0
    else:
        m = n - r
        u = max(m, r)
        mul_sum = 1
        for j in range(u):
            loc_sum = (m - j) / (j + 1)
            mul_sum = mul_sum * loc_sum
        asr = int(mul_sum % mod)
        return asr



n, k = map(int, input().split())
ans = 0
red = n - k


for i in range(k):
    b_c = comb(k-1, i)
    r_c = comb(red+1, i+1)
    mlt = int(b_c * r_c)
    ans = mlt % mod
    print(int(ans))


### FIXED CODE ###

S = [s for s in input()]

SS = sorted(S)

if SS[0] == SS[1] and SS[2] == SS[3] and SS[0] != SS[2]:
    print("Yes")
else:
    print("No")
a=int(input())
a= a % 10
 
if a in ［ 3］:
  print("bon")
elif a in ［ 0,1,6,8］:
  print("pon")
else:
  print("hon")

### FIXED CODE ###

n = int(input())
c = n % 10
 
if c in [3]:
  print("bon")
elif c in [0,1,6,8]:
  print("pon")
else:
  print("hon")
A = []
for _ in range(3):
    A = list(map(int, input().split()))
N = int(input())
B = [int(input()) for i in range(N)]
for i in range(N):
    for j in range(9):
        if B[i] ==  A[j] :
            A[j] = 'a'
if A[0]==A[1]==A[2]=='a' or A[3]==A[4]==A[5]=='a' or A[6]==A[7]==A[8]=='a' or A[0]==A[3]==A[6]=='a' or A[1]==A[4]==A[7]=='a' or A[2]==A[5]==A[8]=='a' or  A[0]==A[4]==A[8]=='a' or A[2]==A[4]==A[6]=='a' :
    print('Yes')
else:
    print('No')

### FIXED CODE ###

A = []
for _ in range(3):
    A += list(map(int, input().split()))
N = int(input())
B = [int(input()) for i in range(N)]

for i in range(0,N):
    for j in range(9):
        if B[i] ==  A[j]:
            A[j] = 0

if A[0]==A[1]==A[2]==0 or A[3]==A[4]==A[5]==0 or A[6]==A[7]==A[8]==0 or A[0]==A[3]==A[6]==0 or A[1]==A[4]==A[7]==0 or A[2]==A[5]==A[8]==0 or  A[0]==A[4]==A[8]==0 or A[2]==A[4]==A[6]==0 :
    print('Yes')
else:
    print('No')
import sys
l=[t for t in sys.stdin]
i=0
while 1:
    pt=[i.find("1") for i in l[9*i:9*(i+1)] if i.find("1")!=-1]
    if not pt:break
    if len(pt)==1:print("C")
    elif len(pt)==2
        if pt[0]==pt[1]:print("A")
        elif pt[0]<pt[1]:print("E")
        elif pr[0]>pt[1]:print("G")
    elif len(pt)==3
        if pt[0]>pt[1]:print("D")
        elif pt[0]<pt[1]:print("F")
    else: print("B")
    i+=1



### FIXED CODE ###

t=[{(0,1),(1,0),(1,1)},
   {(1,0),(2,0),(3,0)},
   {(0,1),(0,2),(0,3)},
   {(1,-1),(1,0),(2,-1)},
   {(0,1),(1,1),(1,2)},
   {(1,0),(1,1),(2,1)},
   {(0,1),(1,-1),(1,0)}
]

while 1:
    l=[input() for _ in range(8)]
    pos=sorted([(i,j) for i in range(8) for j in range(8) if l[i][j]=="1"])
    cv=lambda v:tuple([v[0]-pos[0][0],v[1]-pos[0][1]])
    pt=set(map(cv,pos))
    [print(chr(65+i)) for (i,j) in enumerate(t) if pt&j==j]
    try:
        input()
    except:
        break
if __name__ == '__main__':
    n = int(input())
    ps = [int(x) for x in input().split()]

    dis = []

    for n, p in enumerate(ps):
        if n + 1 != p:
            dis.append(p)

    if len(dis) == 2 or len(dis) == 0:
        print("YES")
    else:
        print("NO")

### FIXED CODE ###

ab = input().split()
a = int(ab[0])
b = int(ab[1])
 
if (a + b) % 2 == 0:
    print((a + b) // 2)
else:
    print("IMPOSSIBLE")
input()
    S = input()
    x = 0
    max_x = 0
    for elem in S:
    	if elem == 'I':
    		x += 1
    	elif elem == 'D':
    		x -= 1
    	if x > max_x:
    		max_x = x
    print(max_x)

### FIXED CODE ###

input()
S = input()
x = 0
max_x = 0
for elem in S:
    if elem == "I":
        x += 1
    elif elem == "D":
        x -= 1
    if x > max_x:
        max_x = x
print(max_x)
import math
I = input().split()
A = int(I[0])
B = int(I[1])
N = int(I[2])
def fl(x):
    return math.floor((A*x)/B) - A*math.floor(x/B)

if B > N :
    An =fl(N)
else :
    for i in range(B,N) :
        if i >= 2 and fl(i) < fl(i-1) :
            An = fl(i-1)
            break
        else:
            An = fl(N)


print(str(An))

### FIXED CODE ###

I = [input() for i in range(2)]
K = int(I[0])
S = I[1].split()
A = int(S[0])
B = int(S[1])

na = A//K
nb = B//K

la = A%K
lb = B%K

#print(na)
#print(nb)

if na < nb or la == 0 or lb == 0 :
    ans = 'OK'
else:
    ans = 'NG'

print(ans)
import math

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

def list_gcd(numbers):
    tmp=numbers[0]
    for i in range(len(numbers)-1):
        tmp=min(tmp,math.gcd(numbers[i],numbers[i+1]))
    return(tmp)

maxgcd = 0
for i in range(N):
    Atmp=A[0:i]
    if i < N-1:
        Atmp.extend(A[i+1:N])
    #print(Atmp)
    tmpgcd=list_gcd(Atmp)
    #print(tmpgcd)
    if tmpgcd > maxgcd:
        maxgcd = tmpgcd

print(maxgcd)

### FIXED CODE ###

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

def myGCD(a,b):
    if a == 0:
        return b
    while b!=0:
        a,b = b,a%b
    return a

L=[]
R=[]
for i in range(N):
    L.append(0)
    R.append(0)

for i in range(N-1):
    L[i+1]=myGCD(L[i],A[i])

for i in range(N-2,-1,-1):
    #print(i)
    R[i] = myGCD(R[i+1],A[i+1])

M=[]
for i in range(N):
    M.append(myGCD(R[i],L[i]))
#print(L)
#print(R)

print(max(M))
# -*- coding: utf-8 -*-

print(' '.join(sorted([input().split()], reverse=True)))

### FIXED CODE ###

# -*- coding: utf-8 -*-
l = [int(e) for e in input().split()]
print(' '.join(str(e) for e in sorted(l, reverse=True)))
N, A, B = (int(i) for i in input().split())

def f(A, B):
  return int((B - A) / 2)
  
def f2(N, A, B):
    if (B - A) % 2 == 0:
        ans = f(A, B)
    else:
        # Aが1に向かうとき
        ans_a = A + f(1, B - A)
        # BがNに向かうとき
        if (A + N - B +1) <  N:
            ans_b = (N - B + 1) + f(A + N - B +1, N)
            ans_b = N
            
        ans = min(ans_a, ans_b)
    
    return ans
  
print(f2(N, A, B))

### FIXED CODE ###

N, A, B = map(int, input().split())

t = float('inf')
if abs(A - B) % 2 == 0:
    t = min(abs(A - B) // 2, t)
    
t = min(B - 1, t)
t = min(N - A, t)
t = min((A - 1 + 1) + (B - A - 1) // 2, t)
t = min((N - B + 1) + (N - (A + (N - B + 1))) // 2, t)

print(t)
# if a > b return true
def compare(a, b): # a also b are both string
	l = max(len(a), len(b))
	a_ = a.rjust(l, '0')
	b_ = b.rjust(l, '0')
	return a_ > b_


def divide(num, den): # den is integer
	quo = ''; resi = 0
	digit = len(num) if int(num[0]) >= den else len(num)-1
	for i in range(len(num)):
		temp = (int(num[i])+resi*10)//den
#		print('temp', temp)
		resi = (int(num[i])+resi*10)%den
#		print('resi', resi)
		quo += str(temp) if temp != 0 else ''
	return quo.ljust(digit, '0')

def multi(a, n):
	s = ''; resi = 0
	for i in range(len(a))[::-1]:
		temp = (int(a[i])*n + resi)%10
#		print('temp', temp)
		resi = (int(a[i])*n + resi)//10
#		print('resi', resi)
		s = str(temp) + s
	return s


def plus(a, b):
	l = max(len(a), len(b))
	a_ = a.rjust(l, '0')
	b_ = b.rjust(l, '0')

	s = ''; resi = 0
	for i in range(l)[::-1]:
		temp = (int(a_[i]) + int(b_[i]) + resi)%10
#		print('temp', temp)
		resi = (int(a_[i]) + int(b_[i]) + resi)//10
#		print('resi', resi)
		s = str(temp) + s
	return s

# a is higher than b
def minus(a, b):
	l = max(len(a), len(b))
	a_ = a.rjust(l, '0')
	b_ = b.rjust(l, '0')

	s = ''; bollow = 0
	for i in range(l)[::-1]:
		temp = int(a_[i]) - int(b_[i]) - bollow
#		print('temp', temp)
		bollow = 0
		if temp >= 0:
			s = str(temp) + s
		else:
			bollow = 1
			s = str(temp + 10) + s
	return s

if compare(s, divide(c, 2)) or s == c:
	print(divide(c, 2))
else:
	print(plus(s, divide(minus(c, multi(s, 2)), 4)))



### FIXED CODE ###

s, c = input().split()
s = int(s); c = int(c)
if s >= c//2:
	print(c//2)
else:
	print(s+(c-s*2)//4)
def imp_kai(n):
    ac = 1
    for i in range(n):
        ac *= i + 1
        ac = ac % (1e9 + 7)
    return ac % (1e9 + 7)
-
n = int(input())
print(imp_kai(n))


### FIXED CODE ###

def imp_kai(n):
    ac = 1
    for i in range(n):
        ac *= i + 1
        ac = ac % (1e9 + 7)
    return ac % (1e9 + 7)

n = int(input())
print(int(imp_kai(n)))
n=int(input())
s=input()
c=0
for i in range(1,N):
  x=s[:i]
  y=s[i:]
  a = set(x) & set(y)
  an=len(a)
  if an>c:
    c=an
print(c)


### FIXED CODE ###

n=int(input())
s=input()
c=0
for i in range(1,n):
  x=set(s[:i])
  y=set(s[i:])
  a = len(x & y)
  if a > c:
    c = a
print(c)
n = int(input())
a = list(map(int, input().split()))
b = []
def f(a):
  c = 0
  for i in range(n-1):
    if a[i-1] ^ a[i+1] == a[i]:
      c += 1
    else:
      c = -1
      break
  if a[0] ^ a[n-2] == a[n-1] and c > -1:
    return True
  else:
    return False
for i in range(n):
  b.append(f(a))
  c = a.pop(a[0])
  a.append(c)
if any(b):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
b = 0
for i in range(n):
  b = b^a[i]

if b == 0:
  print("Yes")
else:
  print("No")
while True:
   (H, W) =[int(i) for i in input(). split()]
  if H == W ==0:
      break

  for a in range(H):
      for b in range(W):
          if (a + b) % 2 == 0:
          print('#', end='')
      else:
          print('.',end='')
      print()
  print()

### FIXED CODE ###

while True:
  ( H, W) = [ int(i) for i in input().split()]
  if H == W == 0:
    break
  
  for h in range( H):
    for w in range( W):
      if h == 0 or h == H-1:
        print( '#', end='')
      elif w == 0 or w == W-1:
        pass
        print( '#', end='')
      else:
        print( '.', end='')
    print()
  print()
import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def cnt(x,A,An,Ap,N,Nz):
    res = 0
    if x >= 0:
        res += N * Nz
    res += np.searchsorted(A,x//Ap,side='right').sum()
    res += N * len(An) - np.searchsorted(A,-(-x//An),side='left').sum()
    res -= np.count_nonzero(A*A<=x)
    return res//2


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

    print(len(A))

    A = np.array(A)
    A.sort()

    An = A[A<0]
    Az = A[A==0]
    Ap = A[A>0]

    Nz = np.count_nonzero(A==0)

    INF = 10 ** 18

    l = - INF - 1
    r = INF

    while r-l > 1:
        m = (l+r)//2
        if cnt(m,A,An,Ap,N,Nz) >= K:
            r = m
        else:
            l = m

    print(r)





main()


### FIXED CODE ###

import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def cnt(x,A,An,Ap,N,Nz):
    res = 0
    if x >= 0:
        res += N * Nz
    res += np.searchsorted(A,x//Ap,side='right').sum()
    res += N * len(An) - np.searchsorted(A,-(-x//An),side='left').sum()
    res -= np.count_nonzero(A*A<=x)
    return res//2


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

    A = np.array(A)
    A.sort()

    An = A[A<0]
    Az = A[A==0]
    Ap = A[A>0]

    Nz = np.count_nonzero(A==0)

    INF = 10 ** 18

    l = - INF - 1
    r = INF

    while r-l > 1:
        m = (l+r)//2
        if cnt(m,A,An,Ap,N,Nz) >= K:
            r = m
        else:
            l = m

    print(r)





main()