CodeEff/ECCO huggingface dataset:
# Original solution
#べき乗関数powを使った逆元の計算
def modinv2(a,m):
    return pow(a,m-2,m)

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

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

if (X+Y)%3 != 0 or X*2-Y < 0:
    ans = 0
else:
    a = (2*X-Y)//3
    b = (2*Y-X)//3
    m = 10**9+7
    ans = 1
    for i in range(1,a+b+1):
        ans = ans*i%m
    for i in range(1,a+1):
        ans = ans*modinv2(i,m)%m
    for i in range(1,b+1):
        ans = ans*modinv2(i,m)%m
print(ans)


# Optimized solution
#べき乗関数powを使った逆元の計算
def modinv2(a,m):
    return pow(a,m-2,m)

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

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

if (X+Y)%3 != 0 or X*2-Y < 0:
    ans = 0
else:
    a = (2*X-Y)//3
    b = (2*Y-X)//3
    m = 10**9+7
    ans = 1
    for i in range(b+1,a+b+1):
        ans = ans*i%m
    for i in range(1,a+1):
        ans = ans*modinv2(i,m)%m
print(ans)
# Original solution
#拡張ユークリッド互除法
#ax+by=1の1つの解(gcd(a,b)=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 modinv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m #負の値を返さないように

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

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

if (X+Y)%3 != 0 or X*2-Y < 0:
    ans = 0
else:
    a = (2*X-Y)//3
    b = (2*Y-X)//3
    m = 10**9+7
    ans = 1
    for i in range(b+1,a+b+1):
        ans = ans*i%m
    for i in range(1,a+1):
        ans = ans*modinv(i,m)%m
print(ans)


# Optimized solution
#拡張ユークリッド互除法
#ax+by=1の1つの解(gcd(a,b)=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 modinv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m #負の値を返さないように

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

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

if (X+Y)%3 != 0 or X*2-Y < 0:
    ans = 0
else:
    a = (2*X-Y)//3
    b = (2*Y-X)//3
    m = 10**9+7
    ans = 1
    for i in range(b+1,a+b+1):
        ans = ans*i%m
    for i in range(1,a+1):
        ans = ans*modinv(i,m)%m
print(ans)
# Original solution
def modinv(a,m):
    return pow(a,m-2,m)

x,y = list(map(int,input().split()))
if (x+y)%3 != 0 or 2*y-x < 0 or 2*x-y < 0:
    print((0))
else:
    a = (2*y-x)//3
    b = (2*x-y)//3
    ans = 1
    mod = 10**9+7
    for i in range(1,a+1):
        ans = ans*(i+b)*modinv(i,mod)%mod
    print(ans)


# Optimized solution
#nCrをmodで割った余りO(r)
def comb(n, r, mod):
    r = min(r, n-r)
    mol = 1
    deno = 1
    for i in range(1, r+1):
        mol = mol * (n-r+i) % mod
        deno = deno * i % mod
    ret = mol * pow(deno, mod-2, mod) % mod
    return ret

x,y = list(map(int,input().split()))
if (x+y)%3 != 0 or 2*y-x < 0 or 2*x-y < 0:
    print((0))
else:
    a = (2*y-x)//3
    b = (2*x-y)//3
    mod = 10**9+7
    print((comb(a+b,a,mod)))
# Original solution
def p_d():
    x, y = list(map(int, input().split()))
    if y > x:
        x, y = y, x
    if (x + y) % 3 != 0:
        print((0))
        exit()
    if x - y > (x + y) // 3:
        print((0))
        exit()
    x, y = x - (x + y) // 3, y - (x + y) // 3

    mod = 10 ** 9 + 7  # 出力の制限
    N = x + y
    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)

    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

    print((cmb(x + y, y, mod)))
    
p_d()

# Optimized solution
def p_d():
    x, y = list(map(int, input().split()))
    if y > x:
        x, y = y, x
    if (x + y) % 3 != 0:
        print((0))
        exit()
    if x - y > (x + y) // 3:
        print((0))
        exit()
    x, y = x - (x + y) // 3, y - (x + y) // 3

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

    print((c_mod(x + y, y)))
    
p_d()
# Original solution
X,Y = list(map(int,input().split()))
if X>Y:
    X,Y = Y,X
if(X+Y)%3:
    print((0))
    exit()
n = (X+Y)//3
if X < n:
    print((0))
    exit()

MOD = 10**9+7
r = X-n

maxn = n+5
fac = [1,1] + [0]*maxn
finv = [1,1] + [0]*maxn
inv = [0,1] + [0]*maxn
for i in range(2,maxn+2):
    fac[i] = fac[i-1] * i % MOD
    inv[i] = -inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD

def ncr(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

print((ncr(n,r)))

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

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

MAXN = r
inv = [0,1] + [0]*MAXN
for i in range(2,MAXN+2):
    inv[i] = -inv[MOD%i] * (MOD // i) % MOD
def comb(n,r):
    ret = 1
    for i in range(r):
        ret *= n-i
        ret *= inv[i+1]
        ret %= MOD
    return ret

print((comb(n,r)))
# Original solution
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 = list(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))


# Optimized solution
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


X, Y = list(map(int, input().split()))
if (X + Y) % 3 != 0:
    print((0))
else:
    n = (2 * Y - X) // 3
    m = (2 * X - Y) // 3
    if n < 0 or m < 0:
        print((0))
    else:
        print((nCk(n + m, n)))
# Original solution
#D
def main():
    mod=1000000007
    x,y=list(map(int,input().split()))
    k=min(x,y//2)
    l=min(x//2,y)
    n=k+l
    
    Fact=[1]
    for i in range(1,n+1):
        Fact.append(Fact[i-1]*i%mod)
    Finv=[0]*(n+1) #階乗の逆元
    Finv[-1]=pow(Fact[-1],mod-2,mod)
    for i in range(n-1,-1,-1):
        Finv[i]=Finv[i+1]*(i+1)%mod
    def comb(n,r):
        if n<r:
            return 0
        return Fact[n]*Finv[r]*Finv[n-r]%mod
    
    ans=0
    for a in range(k+1):
        if (x-a)%2!=0:
            continue
        if (x-a)//2==y-2*a:
            b=(x-a)//2
            ans+=comb(a+b,a)
            ans%=mod
    print(ans)
    
if __name__=='__main__':
    main()

# Optimized solution
def main():
    mod=1000000007
    x,y=list(map(int,input().split()))
    if (x+y)%3:
        return 0
    
    n=(x+y)//3
    Fact=[1]
    for i in range(1,n+1):
        Fact.append(Fact[i-1]*i%mod)
    Finv=[0]*(n+1)
    Finv[-1]=pow(Fact[-1],mod-2,mod)
    for i in range(n-1,-1,-1):
        Finv[i]=Finv[i+1]*(i+1)%mod
    def comb(n,r):
        if n<r:
            return 0
        return Fact[n]*Finv[r]*Finv[n-r]%mod
    
    a=(-x+2*y)//3
    b=(x*2-y)//3
    if a<0 or b<0:
        return 0
    return comb(a+b,a)
    
if __name__=='__main__':
    print((main()))
# Original solution
import sys

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

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

MOD = 10**9 + 7

MAX = max(x,y)
MIN = min(x,y)

if (2*MAX - MIN) % 3 != 0 or MAX / MIN > 2:
	print((0))
	sys.exit()

c1 = (2*MAX - MIN) // 3
c2 = MAX - 2*c1

c1 %= MOD
c2 %= MOD

ans = cmb(c1 + c2 , c1)
print((ans%MOD))


# Optimized solution
import math
import sys

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])
			result %= MOD

	return result

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

min_xy = min(x,y)
max_xy = max(x,y)

MOD = 10**9+7

if max_xy / min_xy == 2.0:
	print((1))
	sys.exit()
if max_xy / min_xy > 2.0:
	print((0))
	sys.exit()
if max_xy == min_xy and max_xy % 3 != 0:
	print((0))
	sys.exit()
if max_xy == min_xy and max_xy % 3 == 0:
	print((cmb(2 * max_xy//3, max_xy//3)))
	sys.exit()

for i in range(min_xy//3+1):
	if (max_xy-3*i) / (min_xy-3*i) == 2.0:
		print((cmb(2*i + (min_xy-3*i),i)%MOD))
		sys.exit()

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

from math import factorial 
from math import floor
P = int(1e9)+7
def c(n, m, P):
       ch = 1
       for i in range(m):
           ch *= (n-i)
           ch %= P
       b = factorial(m) 
       b = pow(b, P-2, P)
       return ch*b%P
def main():
    x, y = list(map(int, readline().split()))
    a = (2*y-x)/3
    b = (2*x-y)/3
    if (a < 0) or (b < 0):
        print((0))
        return
    if floor(a)-a != 0: 
        print((0))
        return
    if floor(b)-b != 0:
        print((0))
        return

    a = int(a)
    b = int(b)
    print((c(a+b, a, P))) 
if __name__ == '__main__':
    main()


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

from math import factorial 
def main():
    x, y = list(map(int, readline().split()))
    if ((2*y-x)%3) or ((2*x-y)%3):
        print((0))
        return
    a = (2*y-x)//3
    b = (2*x-y)//3
    if a < 0:
        print((0))
        return
    if b < 0:
        print((0))
        return
    P = int(1e9)+7
    def c(n, m):
        ch = 1
        for i in range(m):
            ch *= (n-i)
            ch %= P
        b = factorial(m) 
        b = pow(b, P-2, P)
        return ch*b%P
    print((c(a+b, a))) 
if __name__ == '__main__':
    main()
# Original solution
mod=10**9+7
##mod,nについての制約は自分でいかに記入する
def pow_cal(x,n,mod):
    if n==0:
        return 1
    elif n==1:
        return x%mod
    elif n>=2:
        if n%2==0:
            return (pow_cal(x,n//2,mod)**2)%mod
        else:
            return (x*pow_cal(x,n//2,mod)**2)%mod

def find_power(n,mod):
    # 0!からn!までのびっくりを出してくれる関数(ただし、modで割った値に対してである）
    powlist=[0]*(n+1)
    powlist[0]=1
    powlist[1]=1
    for i in range(2,n+1):
        powlist[i]=powlist[i-1]*i%(mod)
    return powlist
 
def find_inv_power(n,mod):
    #0!からn!までの逆元を素数modで割ったあまりリストを作る関数
    c=1
    uselist=[0 for i in range(n+1)]
    for i in range(1,n+1):
        c*=i
        c%=mod
    first=pow_cal(c,mod-2,mod)
    uselist[n]=first
    for i in range(n,0,-1):
        uselist[i-1]=(uselist[i]*i)%(mod)
    return uselist
    
A=find_power(10**6,mod)
B=find_inv_power(10**6,mod)

def combi(n,r,mod):
    if n<r:
        return 0
    elif n>=r:
        return (A[n]*B[r]*B[n-r])%(mod)
x,y=list(map(int,input().split()))
if (x+y)%3!=0:
    print((0))
else:
    J=(2*y-x)//3
    K=(2*x-y)//3
    if J>=0 and K>=0:
        print((combi(J+K,J,mod)))
    else:
        print((0))    

# Optimized solution
def find_power(n):
    # 0!からn!までのびっくりを出してくれる関数
    powlist=[0]*(n+1)
    powlist[0]=1
    powlist[1]=1
    for i in range(2,n+1):
        powlist[i]=powlist[i-1]*i%(10**9+7)
    return powlist
def find_inv_power(n):
    #0!からn!までの逆元を10**9+7で割ったあまりリストを作る関数
    powlist=find_power(n)
    check=powlist[-1]
    first=1
    uselist=[0]*(n+1)
    secondlist=[0]*30
    secondlist[0]=check
    secondlist[1]=check**2
    for i in range(28):
        secondlist[i+2]=(secondlist[i+1]**2)%(10**9+7)
    a=format(10**9+5,"b")
    for j in range(30):
        if a[29-j]=="1":
            first=(first*secondlist[j])%(10**9+7)
    uselist[n]=first
    for i in range(n,0,-1):
        uselist[i-1]=(uselist[i]*i)%(10**9+7)
    return uselist
def combi(a,b,n,r,mod):
    if n<r:
        return 0
    elif n>=r:
        return (a[n]*b[r]*b[n-r])%(mod)
          
x,y=list(map(int,input().split()))
power=find_power(666670)
invpower=find_inv_power(666670)
if (2*x-y)%3==0 and (2*y-x)%3==0:
    if (2*x-y)>=0 and (2*y-x)>=0:
        a=(2*y-x)//3
        b=(2*x-y)//3
        print((combi(power,invpower,a+b,b,10**9+7)))
    else:
        print((0))
else:
    print((0))
# Original solution
mod = 10**9 + 7
_factorial = [1]
def fact(n):
    ''' n! % mod '''
    if n >= mod:
        return 0
    _size = len(_factorial)
    if _size < n+1:
        for i in range(_size, n+1):
            _factorial.append(_factorial[i-1]*i % mod)
    return _factorial[n]
    
_factorial_inv = [1]
def fact_inv(n):
    ''' n!^-1 % mod '''
    if n >= mod:
        raise ValueError('Modinv is not exist! arg={}'.format(n))
    _size = len(_factorial)
    if _size < n+1:
        for i in range(_size, n+1):
            _factorial.append(_factorial[i-1]*i % mod)
    _size_inv = len(_factorial_inv)
    if _size_inv < n+1:
        for i in range(_size_inv, n+1):
            _factorial_inv.append(modinv(_factorial[i]))
    return _factorial_inv[n]
    
def comb(n, r):
    ''' nCr % mod '''
    if r > n:
        return 0
    t = fact(n) * fact_inv(n-r) % mod
    t = t * fact_inv(r) % mod
    return t

def xgcd(a, b):
    x0, x1, y0, y1 = 0, 1, 1, 0
    while a != 0:
        (q, a), b = divmod(b, a), a
        y0, y1 = y1, y0 - q * y1
        x0, x1 = x1, x0 - q * x1
    return b, x0, y0

def modinv(n):
    g, x, _ = xgcd(n, mod)
    if g != 1:
        raise ValueError('Modinv is not exist! arg={}'.format(n))
    return x % mod        

x, y = sorted(map(int, input().split()))
q, r = divmod(x+y, 3)
if r != 0:
    print((0))
else:
    print((comb(q, y-q)))


# Optimized solution
mod = 10**9 + 7
_factorial = [1]
def fact(n):
    ''' n! % mod '''
    if n >= mod:
        return 0
    _size = len(_factorial)
    if _size < n+1:
        for i in range(_size, n+1):
            _factorial.append(_factorial[i-1]*i % mod)
    return _factorial[n]
    
_factorial_inv = [1]
def fact_inv(n):
    ''' n!^-1 % mod '''
    if n >= mod:
        raise ValueError('Modinv is not exist! arg={}'.format(n))
    _size = len(_factorial)
    if _size < n+1:
        for i in range(_size, n+1):
            _factorial.append(_factorial[i-1]*i % mod)
    _size_inv = len(_factorial_inv)
    if _size_inv < n+1:
        for i in range(_size_inv, n+1):
            _factorial_inv.append(modinv(_factorial[i]))
    return _factorial_inv[n]
    
def comb(n, r):
    ''' nCr % mod '''
    if r > n:
        return 0
    t = fact(n) * modinv(fact(n-r)) % mod
    t = t * modinv(fact(r)) % mod
    return t

def xgcd(a, b):
    x0, x1, y0, y1 = 0, 1, 1, 0
    while a != 0:
        (q, a), b = divmod(b, a), a
        y0, y1 = y1, y0 - q * y1
        x0, x1 = x1, x0 - q * x1
    return b, x0, y0

def modinv(n):
    g, x, _ = xgcd(n, mod)
    if g != 1:
        raise ValueError('Modinv is not exist! arg={}'.format(n))
    return x % mod        

x, y = sorted(map(int, input().split()))
q, r = divmod(x+y, 3)
if r != 0:
    print((0))
else:
    print((comb(q, y-q)))
# Original solution
MOD = 10**9+7
X, Y = list(map(int, input().split()))
x, y = X, Y
while 0 <= y:
    if x == 2*y:
        break
    x += 1
    y -= 1
else:
    print((0))
    exit()


def com(n, r):
    X = Y = 1
    if r < 0 or n < r:
        return 0
    if n-r < r:
        r = n-r
    for i in range(1, r+1):
        Y = Y*i % MOD
        X = X*(n-i+1) % MOD
    Y = pow(Y, MOD-2, MOD)
    return X*Y


print((com(x//2, x-X) % MOD))


# Optimized solution
MOD = 10**9+7
x, y = list(map(int, input().split()))
n, r1 = divmod(2*y-x, 3)
m, r2 = divmod(2*x-y, 3)


def com(n, r):
    X = Y = 1
    if r < 0 or n < r:
        return 0
    if n-r < r:
        r = n-r
    for i in range(1, r+1):
        Y = Y*i % MOD
        X = X*(n-i+1) % MOD
    Y = pow(Y, MOD-2, MOD)
    return X*Y


if r1 or r2:
    print((0))
else:
    print((com(n+m, n) % MOD))
# Original solution
X, Y = list(map(int, input().split()))
if (X+Y)%3 != 0:
  print((0))
  exit()
N = (X+Y)//3
# C_N_X-N

MAX = 3000000
MOD = 1000000007
fac = [0]*MAX
finv = [0]*MAX
inv = [0]*MAX
fac[0] = 1
fac[1] = 1
finv[0] = 1
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 COM(n, k):
  if n < 0 or k < 0 or n < k:
    return 0
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD
r = COM(N, X-N)
print(r)


# Optimized solution
X, Y = list(map(int, input().split()))
if (X+Y)%3 != 0:
  print((0))
  exit()
N = (X+Y)//3
# C_N_X-N
MAX = 700000
MOD = 1000000007
fac = [0]*MAX
finv = [0]*MAX
inv = [0]*MAX
fac[0] = 1
fac[1] = 1
finv[0] = 1
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 COM(n, k):
  if n < 0 or k < 0 or n < k:
    return 0
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD
r = COM(N, X-N)
print(r)
# 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 = 2*10**6 + 1
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()))

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

A = (2*Y - X) // 3
B = (2*X - Y) // 3

print((cmb(A+B, A, mod)))


# Optimized 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
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()))

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

A = (2 * Y - X) // 3
B = (2 * X - Y) // 3

print((cmb(A+B, A, mod)))
# Original solution
X, Y = list(map(int, input().split()))
MOD = 10 ** 9 + 7

def createFacArr(n, mod):
    fac = [0] * n
    finv = [0] * n
    inv = [0] * n
    fac[0], fac[1] = 1, 1
    finv[0], finv[1] = 1, 1
    inv[1] = 1
    for i in range(2, n):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod%i] * (mod // i) % mod
        finv[i] = finv[i-1] * inv[i] % mod
    return fac, finv, inv

def comb(n ,k, mod, fac, finv, inv):
    '''
    二項係数の計算
    '''
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod

def main():
    if (X + Y) % 3 != 0:
        return 0
    # 移動回数を求める
    m = (2 * X - Y) // 3
    n = X - 2 * m
    fac, finv, inv = createFacArr(10**6*2, MOD)
    return comb(m+n, n, MOD, fac, finv, inv)

print((main()))


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


def calc_comb(n, k, mod):
    '''
        n が大きい場合に使う
    '''
    a = 1
    b = 1
    for i in range(1,k+1):
        a *= i
        a %= mod
        b *= n
        n -= 1
        b %= mod
    return b * pow(a, mod-2, mod) % mod

if (X+Y) % 3 != 0:
    print((0))
else:
    total_move = (X+Y) // 3
    # 右に2つ動くことを選択しなければいけない回数
    right_move =  min(X,Y) - total_move
    if right_move >= 0:
        print((calc_comb(total_move, right_move, MOD)))
    else:
        print((0))
# Original solution
import sys


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
    return [w[0], w[1]]


def mod_inv(a, m):
    x = extgcd(a, m)[0]
    return (m + x % m) % m


def main():
    X, Y = list(map(int, input().split()))
    C = 10**9 + 7

    if (X + Y) % 3 != 0:
        print((0))
        sys.exit()
    cnt = [0, 0]
    if Y / X >= 1:
        (i, j) = (1, 2)
        cnt[0] += 1
    else:
        (i, j) = (2, 1)
        cnt[1] += 1

    while (i, j) != (X, Y):
        if Y * i > X * j:
            i += 1
            j += 2
            cnt[0] += 1
        else:
            i += 2
            j += 1
            cnt[1] += 1

    ans = 1
    for i in range(1, sum(cnt) + 1):
        ans *= i
        ans %= C
    for i in range(1, cnt[0] + 1):
        ans *= mod_inv(i, C)
        ans %= C
    for i in range(1, cnt[1] + 1):
        ans *= mod_inv(i, C)
        ans %= C

    print(ans)


main()


# Optimized solution
import sys


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
    return [w[0], w[1]]


def mod_inv(a, m):
    x = extgcd(a, m)[0]
    return (m + x % m) % m


def main():
    X, Y = list(map(int, input().split()))
    C = 10**9 + 7

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

    cnt = [0, 0]
    cnt[0] = (2 * X - Y) // 3
    cnt[1] = (-X + 2 * Y) // 3

    if cnt[0] < 0 or cnt[1] < 0:
        print((0))
        sys.exit()

    ans = 1
    for i in range(1, sum(cnt) + 1):
        ans *= i
        ans %= C
    for i in range(1, cnt[0] + 1):
        ans *= mod_inv(i, C)
        ans %= C
    for i in range(1, cnt[1] + 1):
        ans *= mod_inv(i, C)
        ans %= C

    print(ans)


main()
# Original solution
mod = 10 ** 9 + 7

fact = [1]
fact_inv = [1]
for i in range(10 ** 6):
    new_fact = fact[-1] * (i + 1) % mod
    fact.append(new_fact)
    fact_inv.append(pow(new_fact, mod - 2, mod))

def mod_comb_k(n, k, mod):
    return fact[n] * fact_inv[k] % mod * fact_inv[n-k] % mod

def solve():
    X, Y = list(map(int, input().split()))
    if (2 * X - Y) % 3 == 0:
        s = (2 * Y - X) // 3
        t = (2 * X - Y) // 3
        ans = mod_comb_k(s + t, s, mod)
        print(ans)
    else:
        print((0))

solve()

# Optimized solution
def mod_comb(n, k, p):
    if k > n - k:
        k = n - k
    
    numerator = 1
    denominator = 1
    for i, j in zip(list(range(n - k + 1, n + 1)), list(range(1, k + 1))):
        numerator = (numerator * i) % p
        denominator = (denominator * j) % p
    
    return (numerator * pow(denominator, p - 2, p)) % p

def solve():
    mod = 10 ** 9 + 7
    X, Y = list(map(int, input().split()))
    s = 2 * Y - X
    t = 2 * X - Y
    if s >= 0 and s % 3 == 0 and t >= 0 and t % 3 == 0:
        s //= 3
        t //= 3
        print((mod_comb(s + t, s, mod)))
    else:
        print((0))

solve()