Harryxun/stf_run huggingface dataset:
from sys import stdin, stdout
from collections import deque

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def main():
	n, m, x = rli()
	A = []
	for _ in range(n):
		A.append(list(rli()))
	mask = 0
	for i in range(n):
		mask |= (1 << i)

	opt = INF

	def process(s):
		nonlocal opt
		i = 0
		cost = 0
		algs = [0 for _ in range(m)]
		while s:
			s, bit = divmod(s, 2)
			if bit:
				cost += A[i][0]
				for j in range(1, m+1):
					algs[j-1] += A[i][j]
			i += 1
		if all(skill >= x for skill in algs):
			opt = min(opt, cost)

	process(mask)
	s = mask
	while s > 0:
		process(s)
		s = (s-1) & mask

	print(opt if opt < INF else -1)
	stdout.close()

if __name__ == "__main__":
	main()

### FIXED CODE ###

from sys import stdin, stdout

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def main():
	n, m, x = rli()
	A = []
	for _ in range(n):
		A.append(list(rli()))
	mask = 0
	for i in range(n):
		mask |= (1 << i)

	opt = INF

	def process(s):
		nonlocal opt
		i = 0
		cost = 0
		algs = [0 for _ in range(m)]
		while s:
			s, bit = divmod(s, 2)
			if bit:
				cost += A[i][0]
				for j in range(1, m+1):
					algs[j-1] += A[i][j]
			i += 1
		if all(skill >= x for skill in algs):
			opt = min(opt, cost)

	process(mask)
	s = mask
	while s > 0:
		process(s)
		s = (s-1) & mask

	print(opt if opt < INF else -1)
	stdout.close()

if __name__ == "__main__":
	main()
n,k=map(int,input().split())
o=n//k
p=0
if (k%2==0) p=(n+(k//2))//k
print(o**3+p**3)


### FIXED CODE ###

n,k=map(int,input().split())
o=n//k
p=0
if (k%2==0): p=(n+(k//2))//k
print(o**3+p**3)
n = int(input())

# コピー
m = n

# 素因数分解
a = []
while n % 2 == 0:
    a.append(2)
    n //= 2
f = 3
while f * f <= n:
    if n % f == 0:
        a.append(f)
        n //= f
    else:
        f += 2
if n != 1:
    a.append(n)


x=1

for i in a[::-1]:
  x *= i
  if x*x >= m:
    break

y = m // x
ans = x + y -2

print(ans)



### FIXED CODE ###

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

if a <= 9 and b <= 9:
  print(a*b)
else:
  print(-1)
s=sum(map(int,input().split()));
sl=sum(map(int,input().split()[:2]))
if sl>s/2:
  m='Left'
elif sl==s/2:
  m='Balanced'
else:
  m='Right'
print(m)

### FIXED CODE ###

o=input().split();s=sum(map(int,o));sl=sum(map(int,o[:2]))
if sl>s/2:
  m='Left'
elif sl==s/2:
  m='Balanced'
else:
  m='Right'
print(m)
N=int(input())
d=list(map(int,input().split() for i in range(N)))
a=[]
for i in range(d):
  for j in range(d):
  a.append(set(i*j))
print(sum(a))

### FIXED CODE ###

N=int(input())
d=list(map(int,input().split()))
s=0
for i in range(0,N-1):
  s+=d[i]*sum(d[i+1:N])
print(s)
a= list(map(int,input()))
a.sort()
print(a[2] * 10 + a[1] + a[0])

### FIXED CODE ###

a= list(map(int,input().split()))
a.sort()
print(a[2] * 10 + a[1] + a[0])
for e in iter(input,'0'):
 e=int(e)
 print(sum(e//5**i)for i in range(1,6)))


### FIXED CODE ###

for e in iter(input,'0'):print(sum(int(e)//5**i for i in range(1,7)))
N = int(input_[0])

ans = 0
for c in range(1,N):
    N_ = N-c
    sq_N_ = int(N_**(1/2))
    for a in range(1,sq_N_+1):
        if N_ % a == 0:
            b = N_//a
            ans += 2
        if a == b:
            ans -= 1
print(ans)

### FIXED CODE ###

N = int(input())
 
ans = 0
for a in range(1,N):
    ans += (N-1)//a
        
print(ans)
rom collections import Counter

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

A = []
B = []
for i in range(n):
    if i % 2 == 0:
        A.append(v[i])
    else:
        B.append(v[i])

C = Counter(A)
D = Counter(B)

E = C.most_common()
F = D.most_common()

E += [(-1,0)]
F += [(-1,0)]

if E[0][0] != F[0][0]:
    print(n-E[0][1]-F[0][1])
else:
    print(n-max(E[0][1]+F[1][1],E[1][1]+F[0][1]))

### FIXED CODE ###

from collections import Counter

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

A = []
B = []
for i in range(n):
    if i % 2 == 0:
        A.append(v[i])
    else:
        B.append(v[i])

C = Counter(A)
D = Counter(B)

E = C.most_common()
F = D.most_common()

E += [(-1,0)]
F += [(-1,0)]

if E[0][0] != F[0][0]:
    print(n-E[0][1]-F[0][1])
else:
    print(n-max(E[0][1]+F[1][1],E[1][1]+F[0][1]))
from fractions import Fraction

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

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

print(lcm(a, b))


### FIXED CODE ###

from fractions import gcd

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

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

print(lcm(a, b))
from collections import Counter

h, w = map(int, input().split())
arr = [list(map(str, input().rstrip())) for _ in range(h)]

arr = sum(arr, [])

c = Counter(arr)
c = list(c.values())

if h % 2 == 0 and w % 2 == 0:
    ans = all([x % 4 == 0 for x in c])  # 全て4個セットならOK

elif h % 2 == 1 and w % 2 == 1:
    even = (h + w) // 2 - 1  # 2個セットを許容できる個数
    odd_cnt = len([x for x in c if x % 2 == 1])
    if odd_cnt != 1:
        print("No")
        sys.exit()
    odd = sum([x for x in c if x % 2 == 1])
    if odd % 4 == 3:
        even -= 1
    c.remove(odd)
    # 2個セットが許容数以下か
    ans = True if sum([x % 4 == 2 for x in c]) <= even else False
    ans &= all([x % 4 == 0 for x in c if x % 4 != 2])  # 残り全て4個セットか

else:
    even = h // 2 if h % 2 == 0 else w // 2  # 2個セットを許容できる個数
    # 2個セットが許容数以下か
    ans = True if sum([x % 4 == 2 for x in c]) <= even else False
    ans &= all([x % 4 == 0 for x in c if x % 4 != 2])  # 残り全て4個セットか

print("Yes" if ans else "No")

### FIXED CODE ###

from collections import Counter
import sys

h, w = map(int, input().split())
arr = [list(map(str, input().rstrip())) for _ in range(h)]

arr = sum(arr, [])

c = Counter(arr)
c = list(c.values())

if h % 2 == 0 and w % 2 == 0:
    ans = all([x % 4 == 0 for x in c])  # 全て4個セットならOK

elif h % 2 == 1 and w % 2 == 1:
    even = (h + w) // 2 - 1  # 2個セットを許容できる個数
    odd_cnt = len([x for x in c if x % 2 == 1])
    if odd_cnt != 1:
        print("No")
        sys.exit()
    odd = sum([x for x in c if x % 2 == 1])
    if odd % 4 == 3:
        even -= 1
    c.remove(odd)
    # 2個セットが許容数以下か
    ans = True if sum([x % 4 == 2 for x in c]) <= even else False
    ans &= all([x % 4 == 0 for x in c if x % 4 != 2])  # 残り全て4個セットか

else:
    even = h // 2 if h % 2 == 0 else w // 2  # 2個セットを許容できる個数
    # 2個セットが許容数以下か
    ans = True if sum([x % 4 == 2 for x in c]) <= even else False
    ans &= all([x % 4 == 0 for x in c if x % 4 != 2])  # 残り全て4個セットか

print("Yes" if ans else "No")
def dfs(v,p):
    for i in tree[v]:
        if i==p:
            continue
        res[i]+=res[v]
        dfs(i,v)

n,q = map(int, input().split())
tree = [[] for _ in range(n)]
for i in range(n-1):
    a,b = map(int,input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

res = [0]*n
for i in range(q):
    p,x = map(int,input().split())
    res[p-1] += x

dfs(0,-1)
print(*res)

### FIXED CODE ###

a = int(input())
s=input()

if a>=3200:
    print(s)
else:
    print("red")
x,y=map(int,input()).split())
tr,km,flag=0,0,0
for i in range(x):
  tr+=1
  for l in range(x-tr):
    km +=1
    if tr+km==y:
      flag=1
if frag==1:
  print("Yes")
else flag ==0:
  print("No")

### FIXED CODE ###

x,y=map(int,input().split())
tr,km,flag=0,0,0

for i in range(x+1):
  z=x-i
  if i*2+z*4==y:
    flag=1
if flag==1:
  print("Yes")
else:
	print("No")
a=list(map(int,input()))
a.sort()
print("Yes") if max(a[2]==a[1]+a[0]) else print("No")

### FIXED CODE ###

a=list(map(int,input().split()))
a.sort()
print("Yes") if a[0]+a[1]==a[2] else print("No")
print(a+a*a+a*a*a)

### FIXED CODE ###

a=int(input())
print(a+a*a+a*a*a)
n,m = map(int,input().split())
H = list(map(int,input().split()))

l = [1] * N

for i in range(n):
  A,B = map(int,input().split())
  if H[A-1] > h[B-1]:
    l[B - 1] = 0
  elif H[A - 1] < H[B - 1]:
    l[A - 1] = 0
  elif H[A - 1] == H[B - 1]:
    l[A - 1], l[B - 1] = 0, 0
print(l.count(1))


### FIXED CODE ###

N, M = map(int, input().split())
H = list(map(int, input().split()))
l = [1] * N
for i in range(M):
    A, B = map(int, input().split())
    if H[A - 1] > H[B - 1]:
        l[B - 1] = 0
    elif H[A - 1] < H[B - 1]:
        l[A - 1] = 0
    elif H[A - 1] == H[B - 1]:
        l[A - 1], l[B - 1] = 0, 0
print(l.count(1))
Z=[]
Y=[]
for i in range(5):
    a=int(input())
    if a% 10!=0:
        Z.append(10-a % 10+a)
        Y.append(a % 10)
    else:
        Z.append(a)

print(sum(Z)-(10-min(Y)))

### FIXED CODE ###

Z=[]
Y=[]
for i in range(5):
    a=int(input())
    if a% 10!=0:
        Z.append(10-a % 10+a)
        Y.append(a % 10)
    else:
        Z.append(a)
if len(Y)==0:
    H=10
else:
    H=min(Y)

print(sum(Z)-(10-H))
N, M = map(int, input().split())
dp = [0 for _ in range(N+1)]
skip = {}

for _ in range(M):
    skip[int(input())] = 1

dp[1] = 1
dp[2] = 2

if 1 in skip:
    dp[1] = 0
    dp[2] = 1
if 2 in skip:
    dp[2] = 0

for i in range(3, N+1):
    if i in skip:
        continue
    else:
        dp[i] = (dp[i-1] + dp[i-2]) % 1000000007

print(dp[N])


### FIXED CODE ###

N, M = map(int, input().split())
dp = [0 for _ in range(N+1)]
skip = {}

for _ in range(M):
    skip[int(input())] = 1

dp[0] = 1
if 1 not in skip:
    dp[1] = 1

for i in range(2, N+1):
    if i in skip:
        continue
    dp[i] += (dp[i-1] + dp[i-2]) % 1000000007

print(dp[N])
def main():
    #from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #r = input()
    #n = int(input())
    #a, b = map(int, input().split())
    #s, y = input().split()
    #a = input().split()
    #a = list(map(int, input().split()))
    #a = [list(input().split()) for i in range(n)]
    #a = [int(input()) for i in range(n)]
    #a = [list(map(int, input().split())) for i in range(n)]
    #a = [int(s) - 1 for s in input().split()]
    #l=[int(input()) for _ in range(int(input()))]
    #res = 0
    x,y,a,b,c=map(int,input().split())
    p=sorted(list(map(int,input().split())), reverse=True)
    q=sorted(list(map(int,input().split())), reverse=True)
    r=sorted(list(map(int,input().split())), reverse=True)

    ptn1 = 0
    ptn2 = 0
    ptn1 = sum(q[:y])
    ptn2 = sum(p[:x])
    idxr = 0
    idxp = 0
    for i in range(x):
        if r[idxr] > p[idxp]:
            ptn1 += r[idxr]
            idxr += 1
        else:
            ptn1 += p[idx]
            idxq += 1
    idxr = 0
    idxq = 0
    for i in range(y):
        if r[idxr] > q[idxq]:
            ptn2 += r[idxr]
            idxr += 1
        else:
            ptn2 += q[idxq]
            idxq += 1

    print(max(ptn1,ptn2))
if __name__ == '__main__':
    main()



### FIXED CODE ###

def main():
    #from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #r = input()
    #n = int(input())
    #a, b = map(int, input().split())
    #s, y = input().split()
    #a = input().split()
    #a = list(map(int, input().split()))
    #a = [list(input().split()) for i in range(n)]
    #a = [int(input()) for i in range(n)]
    #a = [list(map(int, input().split())) for i in range(n)]
    #a = [int(s) - 1 for s in input().split()]
    #l=[int(input()) for _ in range(int(input()))]
    #res = 0
    x,y,a,b,c=map(int,input().split())
    p=sorted(list(map(int,input().split())), reverse=True)[:x]
    q=sorted(list(map(int,input().split())), reverse=True)[:y]
    r=sorted(list(map(int,input().split())), reverse=True)
    print(sum(sorted((p+q+r), reverse=True)[:x+y]))

if __name__ == '__main__':
    main()
s=input()
n=len(s)
res = -1
leng = 0
for i in range(n-2):
    if s[i] == s[i+1]:
        res = i+1
        leng = 2
        break
    elif s[i] == s[i+2]:
        res = i+1
        leng = 3
        break
if s[-2] == s[-1]:
    res = i+1
    leng = 2

if res == -1:
    print("-1 -1")
elif leng == 2:
    print(str(res)+" "+str(res+1))
else:
    print(str(res)+" "+str(res+2))

### FIXED CODE ###

s=input()
n=len(s)
res = -1
leng = 0
for i in range(n-2):
    if s[i] == s[i+1]:
        res = i+1
        leng = 2
        break
    elif s[i] == s[i+2]:
        res = i+1
        leng = 3
        break
if s[-2] == s[-1]:
    res = n-1
    leng = 2

if res == -1:
    print("-1 -1")
elif leng == 2:
    print(str(res)+" "+str(res+1))
else:
    print(str(res)+" "+str(res+2))
N = int(input())
INF = 10**6
dp = [INF] * (N+1)
for i in range(10):
  if i < 6:
    dp[i] = i
  elif i < 9:
    dp[i] = i%6+1
  else:
    dp[i] = 1
for i in range(N):
  n = m = 1
  while i+9*n > N:
    dp[i+9*n] = min(dp[i+9*n], dp[i] + 1)
    n += 1
  while i+6*m > N:
    dp[i+6*m] = min(dp[i+6*m], dp[i] + 1)
    m += 1
print(dp[N])
    


### FIXED CODE ###

N = int(input())
INF = 10**6
dp = [INF] * (max(9, N)+1)
dp[0] = 0
for i in range(N):
  n = m = 0
  while i+9**n <= N:
    dp[i+9**n] = min(dp[i+9**n], dp[i] + 1)
    n += 1
  while i+6**m <= N:
    dp[i+6**m] = min(dp[i+6**m], dp[i] + 1)
    m += 1
print(dp[N])
a,b,c = input().split()

a = int(a)
b = int(b)
c = int(c)

import math

if abs(math.sqrt(c) - math.sqrt(b) - math.sqrt(a)) > 1e-30:
    if math.sqrt(c) - math.sqrt(b) - math.sqrt(a) > 0:
        print('Yes')
    else:
        print('No')
else:
    t = random.random()
    if t > 0.5:
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

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

if 4 * a * b < (c - a- b)**2 and c - a- b > 0:
    print("Yes")
else:
    print("No")
import math

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

print(a * b // math.gcd(a, b))

### FIXED CODE ###

import fractions

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

print(a * b // fractions.gcd(a, b))
s,t=input().split()
a,b=map(int,input()split())
u=input()
if u==s:
    a--
elif u==t:
    b--
print("{} {}".format(a,b))

### FIXED CODE ###

s, t = input().split()
a, b = map(int, input().split())
u = input()
if u == s:
    a-= 1
else: b -= 1
print(a, b)
from collections import deque
    n, m = map(int, input().split())
    dat_m = [deque([]) for x in range(n + 1)]

    for i in range(m):
        a, b = map(int, input().split())
        dat_m[a].append(b)

    c = False
    for i in dat_m[1]:
        if n in dat_m[i]:
            c = True

    print("POSSIBLE" if c else "IMPOSSIBLE")

### FIXED CODE ###

n, m = map(int, input().split())
dat = []
dat_m = [[]] * (n+1)
dat_finish = [False] * (n+1)

for i in range(m):
    a,b = map(int, input().split())
    dat.append( (a,b) )

#print(dat)
for i in range(m):
    a,b = dat[i]
    if b == n:
        dat_finish[a] = True
#print(dat_finish)

c = False
for i in range(m):
    a,b = dat[i]
    if a == 1:
        if dat_finish[b]:
            c = True

print("POSSIBLE" if c else "IMPOSSIBLE")
s = input()
for i in s:
  if i == ',':
    i = ' ':
print(s)

### FIXED CODE ###

s = input()
for i in s:
  if i == ',':
    i = ' '
  print(i,end="")

print()
import math
N = int(input())
p = [int(N/1.08), math.ceil(N/1.08)]

for n in p:
    if int(n*1.08)==N:
        print(n)
        sys.exit()

print(":(")

### FIXED CODE ###

import math, sys
N = int(input())
p = [int(N/1.08), math.ceil(N/1.08)]

for n in p:
    if int(n*1.08)==N:
        print(n)
        sys.exit()

print(":(")
mport sys
a,b = map(int,sys.stdin.readline().split())

d = a % b
r = a - b * d
f = a / b

print(d,r,f)

### FIXED CODE ###

import sys
a,b = map(int,sys.stdin.readline().split())

d = a // b
r = a % b
f = a / b

print("{0} {1} {2:0.7f}".format(d,r,f))
a,p=input().split()
print((3*a+p)//2)

### FIXED CODE ###

a,p=map(int,input().split())
print((3*a+p)//2)
S = raw_input()
if S.index("HA") == -1 and S.index("H") > 0:
    S = S.replace("H", "HA")
if S.index("BA") == -1 and S.index("B") > 0:
    S = S.replace("B", "BA")
if S.index("RA") == -1 and S.index("R") > 0:
    S = S.replace("R", "HA")
if S[0] != "A":
    S = "A" + S
if S == "AKIHABARA":
    print "YES"
else:
    print "NO"



### FIXED CODE ###

S = raw_input()
if "HA" not in S and "H" in S:
    S = S.replace("H", "HA")
if "BA" not in S and "B" in S:
    S = S.replace("B", "BA")
if "RA" not in S and "R" in S:
    S = S.replace("R", "RA")
if S[0] != "A":
    S = "A" + S
if S == "AKIHABARA":
    print "YES"
else:
    print "NO"
X,Y=map(input().split())
if X%Y==0:
    print(-1)
else:
    X2=X
    while X2>10**18:
        X2+=X
        if X2%Y!=0:
            print(X2)
            exit()
print(-1)

### FIXED CODE ###

X,Y=map(int,input().split())
if X%Y==0:
    print(-1)
    exit()
else:
    X2=X
    while X2<=10**18:
        X2+=X
        if X2%Y!=0:
            print(X2)
            exit()
print(-1)
from math import pi

r = int(input())
print("{:.6f} {:.6f}".format(pi*r*r, 2*pi*r))

### FIXED CODE ###

from math import pi

r = float(input())
print("{:.6f} {:.6f}".format(pi*r*r, 2*pi*r))
N = map(int,input().split())
A = map(int,input().split())

if N%500 <=A:
  print('YES')

else:
  print('NO')

### FIXED CODE ###

N = int(input())
A = int(input())
         
if N%500 <=A:
  print('Yes')
         
else:
  print('No')
N, T = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]

AB.sort()
dp = [0] * T
#print("AB:", AB)

answer = 0
for a, b in AB:
  for t in range(T-1, -1, -1):
    if dp[t]:
      if  a + t < T:
        dp[a + t] = max(dp[a + t], dp[t] + b)
        answer = max(answer, dp[a + t])
      else:
        answer = max(answer, dp[t] + b)
  if a < T:
    dp[a] = max(dp[a], b)
  answer = max(answer, b)
  #print("dp:", dp)
print(answer)      N, T = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]

AB.sort()
dp = [0] * T
#print("AB:", AB)

answer = 0
for a, b in AB:
  for t in range(T-1, -1, -1):
    if dp[t]:
      if  a + t < T:
        dp[a + t] = max(dp[a + t], dp[t] + b)
        answer = max(answer, dp[a + t])
      else:
        answer = max(answer, dp[t] + b)
  if a < T:
    dp[a] = max(dp[a], b)
  answer = max(answer, b)
  #print("dp:", dp)
print(answer)      

### FIXED CODE ###

N, T = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]

AB.sort()
dp = [0] * T
#print("AB:", AB)

answer = 0
for a, b in AB:
  for t in range(T-1, -1, -1):
    if dp[t]:
      if  a + t < T:
        dp[a + t] = max(dp[a + t], dp[t] + b)
        answer = max(answer, dp[a + t])
      else:
        answer = max(answer, dp[t] + b)
  if a < T:
    dp[a] = max(dp[a], b)
  answer = max(answer, b)
  #print("dp:", dp)
print(answer)
class UnionFind():
    def __init__(self,n):
        self.root = [-1]*n
        self.rank = [1]*n
    def find(self,x):
        if self.root[x]==-1:
            return x
        else:
            return self.find(self.root[x])
    def union(self,x,y):
        root_x,root_y = self.find(x),self.find(y)
        if self.rank[root_x]<self.rank[root_y]:
            root_x,root_y = root_y,root_x
        self.rank[root_x] += self.rank[root_y]
        self.root[root_y] = root_x

N,M = map(int,input().split())
P = list(map(lambda x:int(x)-1,input().split()))
T = UnionFind(N)
for i in range(M):
    x,y = map(lambda x:int(x)-1,input().split())
    T.union(x,y)
cnt = 0
for i in range(N):
    p = P[i]
    if T.find(i)==T.find(p):
        cnt+=1
print(cnt)

### FIXED CODE ###

import sys
sys.setrecursionlimit(pow(10,9))
class UnionFind():
    def __init__(self,n):
        self.root = [-1]*n
        self.rank = [1]*n
    def find(self,x):
        if self.root[x] < 0:
            return x
        else:
            self.root[x] = self.find(self.root[x])
            return self.find(self.root[x])
    def union(self,x,y):
        x,y = self.find(x),self.find(y)
        if x == y:return
        if self.rank[x]<self.rank[y]:
            x,y = y,x
        self.rank[x] += self.rank[y]
        self.root[y] = x

N,M = map(int,input().split())
P = list(map(lambda x:int(x)-1,input().split()))
T = UnionFind(N)
for i in range(M):
    x,y = map(lambda x:int(x)-1,input().split())
    T.union(x,y)
cnt = 0
for i in range(N):
    p = P[i]
    if T.find(i)==T.find(p):
        cnt+=1
print(cnt)
# nCk(mod p)の計算
from math import factorial
X, Y = map(int, input().split())
MOD = 10**9+7
MAX = 10**6+1

 # a!のテーブルfact
fact = [0] * MAX
# (a!)^-1のテーブルfinv
finv = [0] * MAX

def comb_init():
    # a!と(a!)^-1のテーブルを作る
    # 累積積のイメージ
    fact[0] = fact[1] = 1
    finv[0] = finv[1] = 1
    for i in range(2, MAX):
        fact[i] = i * fact[i-1] % MOD
        finv[i] = pow(i, -1, MOD) * finv[i-1] % MOD

def comb(n, r):
    return fact[n] * (finv[n-r] * finv[r] % MOD) % MOD    


if (X+Y) % 3 != 0:
    print(0)
else:
    num = (X+Y)//3
    p = (Y - X + num) // 2
    q = (X + num - Y) // 2
    if not num >= min(p, q) >= 0:
        print(0)
        exit()
    comb_init()
    print(comb(num, min(p, q)))

### FIXED CODE ###

# nCk(mod p)の計算
from math import factorial
X, Y = map(int, input().split())
MOD = 10**9+7
MAX = 10**6+1

 # a!のテーブルfact
fact = [0] * MAX
# (a!)^-1のテーブルfinv
finv = [0] * MAX

def comb_init():
    # a!と(a!)^-1のテーブルを作る
    # 累積積のイメージ
    fact[0] = fact[1] = 1
    finv[0] = finv[1] = 1
    for i in range(2, MAX):
        fact[i] = i * fact[i-1] % MOD
        finv[i] = pow(i, MOD-2, MOD) * finv[i-1] % MOD

def comb(n, r):
    return fact[n] * (finv[n-r] * finv[r] % MOD) % MOD    

n = (X+Y)//3
r = X-n
if not 0 <= r <= n:
    print(0)
    exit()

if (X+Y) % 3 != 0:
    print(0)
else:
    num = (X+Y)//3
    p = (Y - X + num) // 2
    q = (X + num - Y) // 2
    comb_init()
    print(comb(num, p))
t=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
x,y=[(a[0]-b[0])*t[0],(a[1]-b[1])*t[1]]

if x+y==0:
    print("infinity")
#elif (x<0 and y<0) or (x>0 and y>0):
#    print(0)
#elif (x<0 and x+(x+y)>0) or (x>0 and x+(x+y)<0):
#    print(1)

#elif x<0 and x+y>0:
#    print((abs(x)//(x+y))*2+[0,1][abs(x)%(x+y)>0])
#elif x<0 and x+y<0:
#    print((y//abs(x+y))*2)
#elif x>0 and x+y<0:
#    print((x//abs(x+y))*2+[0,1][x%abs(x+y)>0])
elif x>0 and x+y>0 and abs(y)%(x+y)==0
    print((abs(y)//(x+y))*2)
else:
    print(hhh)

### FIXED CODE ###

T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())
 
P = (A1 - B1) * T1
Q = (A2 - B2) * T2
if P > 0:
	P *= -1
	Q *= -1
 
if P + Q < 0:
	print(0)
elif P + Q == 0:
	print("infinity")
else:
	S = (-P) // (P + Q)
	T = (-P) % (P + Q)
	if T != 0:
		print(S * 2 + 1)
	else:
		print(S * 2)
while True:
    h,w=map(int, input().split())
    if h==w== 0:break
    for x in (h+1):
        if h%2==1:print('#.'*(w//2) + '\n')
        else:print('.#'*(w//2) + '\n')

### FIXED CODE ###

while 1:
    h,w = map(int, input().split())
    if h==w==0:break
    for y in range(h):
        for x in range(w):
            if (x+y)%2==0:print('#',end='')
            if (x+y)%2==1: print('.',end='')
        print()
    print()
from bisect import bisect_left, bisect_right
s = input()
t = input()
n_s = len(s)
n_t = len(t)

for i in range(n_t):
    if t[i] not in s:
        print(-1)
        exit()

idx = [[] for _ in range(26)]
#print(ord("a"))
#print(ord("z"))

def a_idx(a):
    idx = ord(a)
    idx -= 97
    return idx


for i in range(n_s):
    idx[a_idx(s[i])].append(i)

t_junnban = []
for i in range(n_t):
    t_junnban.append(idx[a_idx(t[i])])
print(t_junnban)

now = 0
ans = 0
for i in range(n_t):
    ni = bisect_right(t_junnban[i], now)
    if ni >= len(t_junnban[i]):
        now = 0
        ans += n_s
        ni = bisect_right(t_junnban[i], now)
        now = t_junnban[i][ni-1]
    else:
        now = t_junnban[i][ni]
ans += now+1
print(ans)

### FIXED CODE ###

from bisect import bisect_left, bisect_right
s = input()
t = input()
n_s = len(s)
n_t = len(t)


idx = [[] for _ in range(26)]
#print(ord("a"))
#print(ord("z"))

def a_idx(a):
    idx = ord(a)
    idx -= 97
    return idx


for i in range(n_s):
    idx[a_idx(s[i])].append(i)

t_syutugenkasyo = []
for i in range(n_t):
    t_syutugenkasyo.append(idx[a_idx(t[i])])
#print(t_syutugenkasyo)

now = -1
ans = 0
for i in range(n_t):
    if len(t_syutugenkasyo[i]) == 0:
        print(-1)
        exit()
    ni = bisect_right(t_syutugenkasyo[i], now)
    if ni >= len(t_syutugenkasyo[i]):
        ans += n_s
        now = -1
        ni = bisect_right(t_syutugenkasyo[i], now)
        now = t_syutugenkasyo[i][ni]
    else:
        now = t_syutugenkasyo[i][ni]
ans += now+1
print(ans)
a,b=map(int,print().split())
print(max(a-b*2,0))


### FIXED CODE ###

a,b=map(int,input().split())
print(max(a-b*2,0))