CodeEff/ECCO huggingface dataset:
# Original solution
X, Y = [int(_) for _ in input().split()]
mod = 10**9 + 7

#a(1, 2) + b(2, 1) = (X, Y)
#a=(2*Y-X)//3
#b=(2*X-Y)//3

if (2 * Y - X) % 3 == (2 * X - Y) % 3 == 0:
    a = (2 * Y - X) // 3
    b = (2 * X - Y) // 3
    if a < 0 or b < 0:
        print((0))
        exit()
    f = [1] * (a + b + 1)
    for i in range(1, a + b + 1):
        f[i] = i * f[i - 1] % mod
    fi = [1] * (a + b + 1)
    fi[-1] = pow(f[-1], mod - 2, mod)
    for i in range(a + b - 1, 1, -1):
        fi[i] = (i + 1) * fi[i + 1] % mod

    def comb(x, y):
        return (f[x] * fi[y] * fi[x - y]) % mod

    print((comb(a + b, b)))
    exit()
print((0))


# Optimized solution
X, Y = [int(_) for _ in input().split()]
mod = 10**9 + 7

#a(1, 2) + b(2, 1) = (X, Y)
a = (2 * Y - X) // 3
b = (2 * X - Y) // 3

if (2 * Y - X) % 3 == (2 * X - Y) % 3 == 0 and a * b >= 0:
    f = [1] * (a + b + 1)
    for i in range(1, a + b + 1):
        f[i] = i * f[i - 1] % mod
    fi = [1] * (a + b + 1)
    fi[-1] = pow(f[-1], mod - 2, mod)
    for i in range(a + b - 1, 1, -1):
        fi[i] = (i + 1) * fi[i + 1] % mod

    def comb(x, y):
        return (f[x] * fi[y] * fi[x - y]) % mod

    print((comb(a + b, b)))
    exit()
print((0))
# Original solution
X, Y = [int(_) for _ in input().split()]
mod = 10**9 + 7

#a(1, 2) + b(2, 1) = (X, Y)
a = (2 * Y - X) // 3
b = (2 * X - Y) // 3

if (2 * Y - X) % 3 == (2 * X - Y) % 3 == 0 and a * b >= 0:
    f = [1] * (a + b + 1)
    for i in range(1, a + b + 1):
        f[i] = i * f[i - 1] % mod
    fi = [1] * (a + b + 1)
    fi[-1] = pow(f[-1], mod - 2, mod)
    for i in range(a + b - 1, 1, -1):
        fi[i] = (i + 1) * fi[i + 1] % mod

    def comb(x, y):
        return (f[x] * fi[y] * fi[x - y]) % mod

    print((comb(a + b, b)))
    exit()
print((0))


# Optimized solution
X, Y = [int(_) for _ in input().split()]
mod = 10**9 + 7

#a(1, 2) + b(2, 1) = (X, Y)
a = (2 * Y - X) // 3
b = (2 * X - Y) // 3

if (2 * Y - X) % 3 == (2 * X - Y) % 3 == 0 and a * b >= 0:
    f = [1] * (a + b + 1)
    for i in range(1, a + b + 1):
        f[i] = i * f[i - 1] % mod
    fi = [1] * (a + b + 1)
    fi[-1] = pow(f[-1], mod - 2, mod)
    for i in range(a + b - 1, 1, -1):
        fi[i] = (i + 1) * fi[i + 1] % mod
    print(((f[a + b] * fi[a] * fi[b]) % mod))
else:
    print((0))
# Original solution
mod = 10**9 + 7

class Combination:
    def __init__(self, n):
        self.facts = [1 for i in range(n+1)]
        self.invs = [1 for i in range(n+1)]
        
        for i in range(1, n+1):
            self.facts[i] = self.facts[i-1] * i % mod
            self.invs[i] = pow(self.facts[i], mod-2, mod)

    def ncr(self, n, r):
        return self.facts[n] * self.invs[r] * self.invs[n-r] % mod

    def nhr(self, n, r): 
        return self.ncr(n+r-1, n-1)

X, Y = list(map(int, input().split()))

comb = Combination(max(X, Y))

if 2*Y - X < 0 or 2*X - Y < 0 or (2*Y - X) % 3 != 0 or (2*X - Y) % 3 != 0:
    print("0")
else:
    M = (2*Y - X) // 3
    N = (2*X - Y) // 3
    print((comb.ncr(M+N,M)))


# Optimized solution
mod = 10**9 + 7

def ncr(n, r):
    r = min(r, n-r)
    x, y = 1, 1
    for i in range(r):
        x = (x * (n-i)) % mod
        y = (y * (i+1)) % mod
    
    return x * pow(y, mod-2, mod) % mod


X, Y = list(map(int, input().split()))


if 2*Y - X < 0 or 2*X - Y < 0 or (2*Y - X) % 3 != 0 or (2*X - Y) % 3 != 0:
    print("0")
else:
    M = (2*Y - X) // 3
    N = (2*X - Y) // 3
    print((ncr(M+N,N)))
# Original solution
import math

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 
N = 10**6
g1 = [1, 1] 
g2 = [1, 1] 
inverse = [0, 1] 

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

X, Y = [int(i) for i in input().split()]

if (2*Y - X) % 3 != 0:
    print((0))
elif (2*X - Y) % 3 != 0:
    print((0))
else:
    x = (2*X - Y) // 3
    y = (2*Y - X) // 3
    print((cmb(x+y, x , mod)))


# Optimized solution
import math

def cmb(n, r, mod):
    r = min(r, n-r)

    a = 1
    b = 1
    for i in range(r):
        a = (a * (n-i)) % mod
        b = (b * (i+1)) % mod
    
    return a * pow(b, mod-2, mod) % mod

X, Y = [int(i) for i in input().split()]
mod = 10**9+7 
x_tmp = 2*X - Y
y_tmp = 2*Y - X

if x_tmp < 0 or y_tmp < 0:
    ans = 0
elif x_tmp % 3 != 0 or y_tmp % 3 != 0:
    ans = 0
else:
    x = x_tmp // 3
    y = y_tmp // 3
    ans = cmb(x + y, y, mod)

print(ans)
# Original solution
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

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

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

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

    return result

def main():
    
    x, y = list(map(int, readline().split()))
    if (x+y)%3!=0:
        print((0))
        return
    n = (x+y)//3
    a, b = (2*y-x)//3, (2*x-y)//3
    if a<0 or b<0:
        print((0))
        return
    o = cmb(n, a)
    o = o % (10**9+7)
    print(o)

if __name__ == "__main__":
    main()


# Optimized solution
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def extgcd(a, b):
    if b == 0:
        return [1, 0, a]
    x, y, g = extgcd(b, a % b)
    return [y, x - a//b * y, g]


def mod_inverse(a, m):
    x, _, _ = extgcd(a, m)
    return (m + x % m) % m


def mod_comb(n, k, mod):
    mul, div = 1, 1
    for i in range(k):
        mul *= (n-i)
        div *= (i+1)
        mul %= mod
        div %= mod
    return mul * mod_inverse(div, mod) % mod


def main():
    
    x, y = list(map(int, readline().split()))
    if (x+y)%3!=0:
        print((0))
        return
    n = (x+y)//3
    a, b = (2*y-x)//3, (2*x-y)//3
    if a<0 or b<0:
        print((0))
        return
    print((mod_comb(n, min(a, b), (10**9+7))))

if __name__ == "__main__":
    main()
# Original solution
import math
M = 10**9+7
X,Y = list(map(int,input().split()))
if (X+Y)/3 != (X+Y)//3:
    print((0))
    exit()
n = (X+Y)//3
r = Y-n
if r<0 or r>n:
    print((0))
    exit()
#互いに素なa,bについて、a*x+b*y=1の一つの解
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

res = 1
for i in range(1,n+1):
    res = res*i%M
for i in range(1,r+1):
    res = res*mod_inv(i,M)%M
for i in range(1,n-r+1):
    res = res*mod_inv(i,M)%M
print(res)

# Optimized solution
import math
M = 10**9+7
X,Y = list(map(int,input().split()))
if (X+Y)/3 != (X+Y)//3:
    print((0))
    exit()
n = (X+Y)//3
r = Y-n
if r<0 or r>n:
    print((0))
    exit()


#nCr and Mod
def nCr(n, r, mod=10**9+7):
    r = min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n+1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod

print((nCr(n,r,M)))
# Original solution
def com(n,r,mod):
    k=min(r,n-r)
    C=1
    for i in range(1,k+1):
        C=(C*(n+1-i)*pow(i,mod-2,mod))%mod
    return C

x, y = list(map(int,input().split()))
mod = 10 ** 9 + 7
n = (2 * y - x) // 3 if (2 * y - x) % 3 == 0 else -1
m = (2 * x - y) // 3 if (2 * x - y) % 3 == 0 else -1

if n >= 0 and m >= 0:
    print((com(n + m, n, mod)))
else:
    print((0))

# Optimized solution
def com(n,r,mod):
    k=min(r,n-r)
    C=1
    for i in range(1,k+1):
        C=(C*(n+1-i)*pow(i,mod-2,mod))%mod
    return C

x, y = list(map(int,input().split()))
mod = 10 ** 9 + 7

m = 2 * x - y
n = 2 * y - x
if m >= 0 and n >= 0 and m % 3 == 0 and n % 3 == 0:
    print((com((n + m) // 3, n // 3, mod)))
else:print((0))
# Original solution
X, Y = list(map(int, input().split()))
mod = 10**9+7

if (X+Y) % 3 != 0:
    print((0))
else:
    n = (2*Y-X)//3
    m = (2*X-Y)//3
    '''
    n*(1,2) + m*(2,1) = (x, y)
    x = n+2m
    y = 2n+m
    2x = 2n+4m
    2x-y = 3m
    m = (2x-y)/3
    n = (2y-x)/3 
    '''
    if 0 > n or 0 > m:
        print((0))
    else:
        ans = 1
        for i in range(1,n+1):
            ans *= (n+m+1-i)*pow(i,mod-2,mod)
            ans %= mod
        print(ans)


# Optimized solution
X, Y = list(map(int, input().split()))

m, r = divmod(2*Y-X, 3)
if r != 0:
    print((0))
    exit()

n = Y - 2*m

if n < 0 or m < 0:
    print((0))
    exit()

def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n-i) * modinv(i+1, mod) % mod
    return res

print((combination(n+m, n)))
# Original solution
def ncr(n, r):
    return fac[n] * facinv[r] * facinv[n - r] % MOD


MOD = 10 ** 9 + 7
X, Y = list(map(int, input().split()))

N = 10 ** 6
fac = [1, 1]
facinv = [1, 1]
inv = [0, 1]
for i in range(2, N + 1):
    fac.append(fac[i - 1] * i % MOD)
    inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
    facinv.append((facinv[-1] * inv[-1]) % MOD)

if (X + Y) % 3 or Y > 2 * X or Y < X // 2:
    print((0))
    exit()
d = (X + Y) // 3
print((ncr(d, X - (X + Y) // 3)))


# Optimized solution
MOD = 10 ** 9 + 7
X, Y = list(map(int, input().split()))

if (X + Y) % 3 or Y > 2 * X or Y < X // 2:
    print((0))
    exit()

n = (X + Y) // 3
r = X - (X + Y) // 3
num, den = 1, 1
if n - r < r:
    r = n - r
for i in range(1, r + 1):
    num *= n - i + 1
    num %= MOD
    den *= i
    den %= MOD

print(((num * pow(den, MOD - 2, MOD)) % MOD))
# Original solution
MOD = 10 ** 9 + 7
X, Y = list(map(int, input().split()))

if (X + Y) % 3 or Y > 2 * X or Y < X // 2:
    print((0))
    exit()

n = (X + Y) // 3
r = X - (X + Y) // 3
num, den = 1, 1
if n - r < r:
    r = n - r
for i in range(1, r + 1):
    num *= n - i + 1
    num %= MOD
    den *= i
    den %= MOD

print(((num * pow(den, MOD - 2, MOD)) % MOD))

# Optimized solution
def ncr(n, r):
    num, den = 1, 1
    if n - r < r:
        r = n - r
    for i in range(1, r + 1):
        num *= n - i + 1
        num %= MOD
        den *= i
        den %= MOD
    return num * pow(den, MOD - 2, MOD) % MOD


MOD = 10 ** 9 + 7
X, Y = list(map(int, input().split()))
Z = X + Y

if Z % 3 or Y > 2 * X or Y < X // 2:
    print((0))
else:
    print((ncr(Z // 3, X - Z // 3)))
# Original solution
X, Y =list(map(int, input().split()))
mod = 1000000007

import sys
if (X + Y) % 3 != 0:
    print((0))
    sys.exit()
offset = (X+Y)//3
X, Y = X-offset, Y-offset

if X<0 or Y<0:
    print((0))
    sys.exit()
    
X, Y = max(X, Y), min(X, Y)

def C(n, r, mod):
    num = 1
    den = 1
    for i in range(r):
        num*=n-i
        num%=mod
        den*=i+1
        den%=mod
    return (num*pow(den, mod-2, mod))%mod

print((C(X+Y, Y, mod)))


# Optimized solution
X, Y = list(map(int, input().split()))
if (X+Y) % 3 != 0:
    print((0))
    
else:
    # 経路
    def C(n, r, mod):
        num = 1
        den = 1
        for i in range(r):
            num *= n-i
            num %= mod
            den *= i+1
            den %= mod
        return (num * pow(den, mod-2, mod)) % mod
    mod = 10**9 + 7
    minimun = (X+Y)/3
    if X >= minimun and Y >= minimun:
        X -= minimun 
        Y -= minimun
        print((C(int(X+Y), int(X), mod)))
    else:
        print((0))
# Original solution
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6 + 10
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

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

n = (2 * x - y) / 3
m = (2 * y - x) / 3
mod = 10 ** 9 + 7

if int(n) == n and int(m) == m:
    n = int(n)
    m = int(m)
    ans = cmb(n + m, n, mod)
    ans %= mod
    print(ans)

else:
    print((0))


# Optimized solution
x, y = list(map(int, input().split()))
mod = 10 ** 9 + 7

cnt1 = cnt2 = 0
for i in range(x + 1):
    x_left = x - i
    y_left = y - 2 * i
    if x_left == y_left * 2:
        cnt1 = i
        cnt2 = y_left

if cnt1 == cnt2 == 0:
    ans = 0
else:
    ans = 1
    for i in range(1, cnt1 + 1):
        ans *= (cnt1 + cnt2 - i + 1)
        ans %= mod
        ans *= pow(i, mod - 2, mod)
        ans %= mod

print(ans)
# Original solution
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


a,s=list(map(int,input().split()))
if (2*a-s)%3==0 and max(a,s)<=2*min(a,s):
  n=(a+s)//3
  r=(2*a-s)//3
  print(((cmb(n,r))%(10**9+7)))
else:print((0))

# Optimized solution
x,y=list(map(int,input().split()))
if (x+y)%3:print((0))
else:
    sab=(x+y)//3
    a=y-sab
    b=sab-a
    if a<0 or b<0:print((0));exit()
    mod=10**9+7
    fact=[1]*(sab+1)
    inv=[1]*(sab+1)
    for i in range(2,sab+1):
        fact[i]=i*fact[i-1]%mod
    inv[-1]=pow(fact[-1],mod-2,mod)
    for i in range(sab,1,-1):
        inv[i-1]=inv[i]*i%mod
    def comb(x,y):return fact[x]*inv[y]%mod*inv[x-y]%mod if x>=y>=0 else 0
    print((comb(sab,a)))
# Original solution
def cmb(n,r,mod):
    if r<0 or r>n:return 0
    r=min(r,n-r)
    return g1[n]*g2[r]*g2[n-r]%mod


mod=10**9+7
x,y=list(map(int,input().split()))
g1=[1,1]
g2=[1,1]
inverse=[0,1]

n,m=(2*y-x)//3,(2*x-y)//3
if (x+y)%3!=0 or n<0 or m<0:print((0));exit()

for i in range(2,n+m+1):
    g1.append((g1[-1]*i)%mod)
    inverse.append((-inverse[mod%i]*(mod//i))%mod)
    g2.append((g2[-1]*inverse[-1]%mod))

print((cmb(n+m,n,mod)))

# Optimized solution
mod=10**9+7
x,y=list(map(int,input().split()))

X,Y=(2*y-x)//3,(2*x-y)//3
if X<0 or Y<0 or (x+y)%3!=0:print((0));exit()


def cmb(n,r,mod):
    if r<0 or r>n:return 0
    return g1[r]*g2[r]%mod


n=X+Y
k=max(X,Y)
g1=[1,n]
g2=[1,1]
inverse=[0,1]

for i,j in enumerate(range(n-1,((n-k+1)-1),-1)):
    i=i+2
    g1.append((g1[-1]*j)%mod)
    inverse.append((-inverse[mod%i]*(mod//i))%mod)
    g2.append((g2[-1]*inverse[-1]%mod))

print((cmb(n,k,mod)))
# Original solution
X,Y=list(map(int,input().split()))
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
mod = 10**9+7
N = 10**6
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
if (X+Y)%3!=0:
  print((0))
else:
  n=2*Y-X
  m=2*X-Y
  if n<0 or m<0:
    print((0))
  else:
    n=int(n/3)
    m=int(m/3)
    print((cmb(n+m,m,mod)))

# Optimized solution
X,Y=list(map(int,input().split()))
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
if (X+Y)%3!=0:
  print((0))
else:
  n=2*Y-X
  m=2*X-Y
  mod=10**9+7
  if n<0 or m<0:
    print((0))
  else:
    n=int(n/3)
    m=int(m/3)
    print((cmb(n+m,m)%mod))
# Original solution
x,y = list(map(int,input().split()))
mod = 10**9 + 7
if (x+y)%3 != 0:
    print((0))
    exit()
if (2*y-x)%3 !=0 or (2*x-y)%3 != 0 or 2*y-x <0 or 2*x-y<0:
    print((0))
    exit()

a = (2*y-x)//3
b = (2*x-y)//3

def inverse(a,p):
    return pow(a,p-2,p)

def combination_modp(n, r, p): # nCr modpを求める
    r = min(n-r, r)
    result = 1
    for i in range(n, n-r, -1):
        result *= i
        result %=p
    for i in range(1, r+1):
        result *= inverse(i,p)
        result %= p
    return result

ans = combination_modp(a+b,a,mod)
print(ans)

# Optimized solution
def combination_modp(n, r, p): # nCr modpを求める
    r = min(n-r, r)
    result = 1
    for i in range(n, n-r, -1):
        result *= i
        result %=p
    for i in range(1, r+1):
        result *= pow(i,p-2,p)
        result %= p
    return result

x,y = list(map(int,input().split()))
mod = 10**9 + 7

if (x+y)%3 != 0 or 2*y-x <0 or 2*x-y<0:
    print((0))
    exit()

a = (2*y-x)//3
b = (2*x-y)//3

ans = combination_modp(a+b,a,mod)
print(ans)
# Original solution
x,y=list(map(int,input().split()))
a3=2*x-y
b3=2*y-x
MOD=10**9+7

def cmb(n, r, mod):
  if ( r<0 or r>n ):
    return 0
  r = min(r, n-r)
  return g1[n] * g2[r] * g2[n-r] % mod

if a3%3!=0 or b3%3!=0:
  print((0))
else:
  a=a3//3
  b=b3//3
  if a>b:
    a,b=b,a
  
  N=a+b

  g1 = [1, 1]
  g2 = [1, 1]
  inverse = [0, 1]

  for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % MOD )
    inverse.append( ( -inverse[MOD % i] * (MOD//i) ) % MOD )
    g2.append( (g2[-1] * inverse[-1]) % MOD )

  ans = cmb(N,a,MOD)
  print((ans%MOD))

# Optimized solution
X,Y=list(map(int,input().split()))

# (i+1,j+2)の移動をa回
# (i+2,j+1)の移動をb回
# X=a+2b
# Y=2a+b
# となるa,bが存在するか？
# b=(2X-Y)/3が整数となればOK

b=(2*X-Y)/3
if not float.is_integer(b):
  print((0))
  exit(0)
  
b=int(b)
a=X-2*b

# aとbの回数が決まったので、a+bCmin(a,b)をやればいい

DIV=10**9+7
from functools import reduce
def nCr(n,r,DIV):
  if r<n-r:
    r=n-r
  if r==0:
    return 1
  f=lambda x,y:x*y%DIV
  X=reduce(f,list(range(n-r+1,n+1)))
  Y=reduce(f,list(range(1,r+1)))
  return X*pow(Y,DIV-2,DIV)%DIV

print((nCr(a+b,b,DIV)))
# Original solution
X, Y = list(map(int, input().split()))
mod = 10 ** 9 + 7


# modしながらコンビネーションを求める
def mod_cmb(n, r, mod):
    p, q = 1, 1
    for i in range(r):
        p = p * (n - i) % mod
        q = q * (i + 1) % mod
    return p * mod_inverse(q, mod) % mod


# modしたa^bを求める
def mod_pow(a, p, mod):
    if p == 0:
        return 1
    elif p % 2 == 1:
        return a * mod_pow(a, p - 1, mod)
    else:
        return (mod_pow(a, p // 2, mod) % mod) ** 2 % mod


# aで割りたいときはa^(p-2)をかければよい（pは素数かつmodで使うやつ）
def mod_inverse(a, mod):
    return mod_pow(a, (mod - 2), mod)


# 移動1, 2を使う回数
n, m = 0, 0

for i in range(10 ** 6):
    if X - i == (Y - 2 * i) * 2 == 0 or X - i == (Y - 2 * i) * 2 != 0:
        n = i
        m = Y - 2 * n
        break
else:
    print((0))
    exit()

print((mod_cmb(n + m, n, mod)))

# Optimized solution
X, Y = list(map(int, input().split()))
mod = 10 ** 9 + 7


# modしながらコンビネーションを求める
def mod_cmb(n, r, mod):
    p, q = 1, 1
    for i in range(r):
        p = p * (n - i) % mod
        q = q * (i + 1) % mod
    return p * mod_inverse(q, mod) % mod


# modしたa^bを求める
def mod_pow(a, p, mod):
    if p == 0:
        return 1
    elif p % 2 == 1:
        return a * mod_pow(a, p - 1, mod)
    else:
        return (mod_pow(a, p // 2, mod) % mod) ** 2 % mod


# aで割りたいときはa^(p-2)をかければよい（pは素数かつmodで使うやつ）
def mod_inverse(a, mod):
    return mod_pow(a, (mod - 2), mod)


if (X + Y) % 3 != 0:
    print((0))
    exit()

# 移動1, 2を使う回数
n = (2 * Y - X) // 3
m = (2 * X - Y) // 3

if n < 0 or m < 0:
    print((0))
    exit()

print((mod_cmb(n + m, n, mod)))
# Original solution
x,y = list(map(int,input().split()))
if x > y*2 or y > x*2 or (x+y)%3 != 0:
  print((0))
  exit()
n = (x+y)//3
r = min(x-n,2*n-x)

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7
N = 10**6
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

print((cmb(n,r,mod)))

# Optimized solution
x,y = list(map(int,input().split()))
if (x+y)%3 != 0:
    print((0))
    quit()
elif x < (x+y)//3 or y < (x+y)//3:
    print((0))
    quit()
else:
    n = (x+y)//3
    r = x-n

mod = 10**9+7
def cmb(n,r,mod):
    r = min(r, n-r)
    return (fact[n] * factinv[r] * factinv[n-r]) % mod
def makefact(n,mod):
    fact = [1,1]
    factinv = [1,1]
    inv = [0,1]
    for i in range(2,n+1):
        fact.append((fact[-1]*i) % mod)
        inv.append(-inv[mod%i]*(mod//i)%mod)
        factinv.append((factinv[-1]*inv[-1])%mod)
    return fact,factinv
fact,factinv = makefact(n,mod)

print((cmb(n,r,mod)))
# Original solution
import math
mod = 10**9 + 7
x, y = list(map(int, input().split()))

if (x+y)%3 != 0:
    print((0))
    exit()

if x == 0 or y == 0:
    print((0))
    exit()

X = max(x,y)
Y = min(x,y)

all_move = (X+Y)//3
diff = (X-Y)
y_move = (all_move - diff)//2


def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

n = int(all_move)
r = int(y_move)
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, n + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


print((cmb(n,r,mod)))


# Optimized solution
import math
MOD = 10**9 + 7 #　素数
x, y = list(map(int, input().split()))

if (x+y)%3 != 0:
    print((0))
    exit()

if x == 0 or y == 0:
    print((0))
    exit()

X = max(x,y)
Y = min(x,y)

all_move = (X+Y)//3
diff = (X-Y)
Y_move = (all_move - diff)//2


def mod_cmb(n, r, mod): # nCr mod p
    g1 = [1, 1]
    g2 = [1, 1]
    inverse = [0, 1]

    for i in range( 2, n + 1 ):
        g1.append( ( g1[-1] * i ) % mod )
        inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
        g2.append( (g2[-1] * inverse[-1]) % mod )

    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

print((mod_cmb(all_move, Y_move,MOD)))
# Original solution
def d_knight():
    X, Y = [int(i) for i in input().split()]

    if (abs(X) + abs(Y)) % 3 != 0 or Y > 2 * X or 2 * Y < X:
        return 0

    n = (abs(X) + abs(Y)) // 3
    k = -1
    for x in range(n, 2 * n + 1):
        if Y == 3 * n - x:
            k = x - n
            break

    class Combination(object):
        """参考: https://harigami.net/contents?id=5f169f85-5707-4137-87a5-f0068749d9bb"""
        __slots__ = ['mod', 'factorial', 'inverse']

        def __init__(self, max_val_arg: int = 10**6, mod: int = 10**9 + 7):
            fac, inv = [1], []
            fac_append, inv_append = fac.append, inv.append

            for i in range(1, max_val_arg + 1):
                fac_append(fac[-1] * i % mod)

            inv_append(pow(fac[-1], mod - 2, mod))

            for i in range(max_val_arg, 0, -1):
                inv_append((inv[-1] * i) % mod)

            self.mod, self.factorial, self.inverse = mod, fac, inv[::-1]

        def combination(self, n, r):
            if n < 0 or r < 0 or n < r:
                return 0
            return self.factorial[n] * self.inverse[r] * self.inverse[n - r] % self.mod
    return Combination().combination(n, k)

print((d_knight()))

# Optimized solution
def d_knight():
    X, Y = [int(i) for i in input().split()]

    def combination(n, r, mod):
        r = min(r, n - r)
        numerator, denominator = 1, 1
        for i in range(1, r + 1):
            numerator = (numerator * (n + 1 - i)) % mod
            denominator = (denominator * i) % mod
        return numerator * pow(denominator, mod - 2, mod) % mod

    if not (X <= 2 * Y and Y <= 2 * X):
        return 0

    n, m = (-X + 2 * Y) / 3, (2 * X - Y) / 3
    if not (n.is_integer() and m.is_integer()):
        return 0

    n, m = int(n), int(m)
    return combination(n + m, n, 10**9 + 7)

print((d_knight()))