Buggy python submission (verdict: Runtime Error):
[x,y]=list(map(int,input().split()))
if ((x%3)+(y%3))%3!=0:
	print(0)
else:
	n=int((x+y)/3)
	r=y-n
	if r<0 or r>n:
		print(0)
	else:
		if r>n-r:
			r=n-r
		mod=1000000007
		kaijo=[1]
		for i in range(1,n+1):
			kaijo.append(kaijo[-1]*i%mod) #これで、kaijo[i]=i!となる。
		gyakugen=[pow(kaijo[n-r],mod-2,mod)]
		for i in reversed(range(1,n-r)):
			gyakugen.append(gyakugen[-1]*i) #これで、gyakugen[i]=n-r-iの逆元となる
		kotae=kaijo[n]*gyakugen[0]*gyakugen[n-2*r]%mod

		print(kotae)

Fixed submission:
[x,y]=list(map(int,input().split()))
if ((x%3)+(y%3))%3!=0:
	print(0)
else:
	n=int((x+y)/3)
	r=y-n
	if r<0 or r>n:
		print(0)
	else:
		if r>n-r:
			r=n-r
		mod=1000000007
		kaijo=[1]
		for i in range(1,n+1):
			kaijo.append(kaijo[-1]*i%mod) #これで、kaijo[i]=i!となる。
		gyakugen=[pow(kaijo[n-r],mod-2,mod)]
		for i in reversed(range(1,n-r+1)):
			gyakugen.append(gyakugen[-1]*i%mod) #これで、gyakugen[i]=n-r-iの逆元となる
		kotae=kaijo[n]*gyakugen[0]*gyakugen[n-2*r]%mod

		print(kotae)

Buggy python submission (verdict: Runtime Error):
[x,y]=list(map(int,input().split()))
if ((x%3)+(y%3))%3!=0:
	print(0)
else:
	n=int((x+y)/3)
	r=y-n
	if r<0 or r>n:
		print(0)
	else:
		if r>n-r:
			r=n-r
		mod=1000000007
		kaijo=[1]
		for i in range(1,n+1):
			kaijo.append(kaijo[-1]*i%mod) #これで、kaijo[i]=i!となる。
		gyakugen=[pow(kaijo[n-r],mod-2,mod)]
		for i in reversed(range(1,n-r)):
			gyakugen.append(gyakugen[-1]*i%mod) #これで、gyakugen[i]=n-r-iの逆元となる
		kotae=kaijo[n]*gyakugen[0]*gyakugen[n-2*r]%mod

		print(kotae)

Fixed submission:
[x,y]=list(map(int,input().split()))
if ((x%3)+(y%3))%3!=0:
	print(0)
else:
	n=int((x+y)/3)
	r=y-n
	if r<0 or r>n:
		print(0)
	else:
		if r>n-r:
			r=n-r
		mod=1000000007
		kaijo=[1]
		for i in range(1,n+1):
			kaijo.append(kaijo[-1]*i%mod) #これで、kaijo[i]=i!となる。
		gyakugen=[pow(kaijo[n-r],mod-2,mod)]
		for i in reversed(range(1,n-r+1)):
			gyakugen.append(gyakugen[-1]*i%mod) #これで、gyakugen[i]=n-r-iの逆元となる
		kotae=kaijo[n]*gyakugen[0]*gyakugen[n-2*r]%mod

		print(kotae)

Buggy python submission (verdict: Runtime Error):
[x,y]=list(map(int,input().split()))
if ((x%3)+(y%3))%3!=0:
	print(0)
else:
	n=int((x+y)/3)
	r=y-n
	if r<0 or r>n:
		print(0)
	else:
		if r>n-r:
			r=n-r
		mod=1000000007
		kaijo=[1]
		for i in range(1,n+1):
			kaijo.append(kaijo[-1]*i) #これで、kaijo[i]=i!となる。
		gyakugen=[pow(kaijo[n-r],mod-2,mod)]
		for i in reversed(range(1,n-r)):
			gyakugen.append(gyakugen[-1]*i%mod) #これで、gyakugen[i]=n-r-iの逆元となる
		kotae=kaijo[n]*gyakugen[0]*gyakugen[n-2*r]%mod

		print(kotae)

Fixed submission:
[x,y]=list(map(int,input().split()))
if ((x%3)+(y%3))%3!=0:
	print(0)
else:
	n=int((x+y)/3)
	r=y-n
	if r<0 or r>n:
		print(0)
	else:
		if r>n-r:
			r=n-r
		mod=1000000007
		kaijo=[1]
		for i in range(1,n+1):
			kaijo.append(kaijo[-1]*i%mod) #これで、kaijo[i]=i!となる。
		gyakugen=[pow(kaijo[n-r],mod-2,mod)]
		for i in reversed(range(1,n-r+1)):
			gyakugen.append(gyakugen[-1]*i%mod) #これで、gyakugen[i]=n-r-iの逆元となる
		kotae=kaijo[n]*gyakugen[0]*gyakugen[n-2*r]%mod

		print(kotae)

Buggy python submission (verdict: Runtime Error):
[x,y]=list(map(int,input().split()))
if ((x%3)+(y%3))%3!=0:
	print(0)
else:
	n=int((x+y)/3)
	r=y-n
	if r<0 or r>n:
		print(0)
	else:
		if r>n-r:
			r=n-r
		mod=1000000007
		kaijo=[1]
		for i in range(1,n+1):
			kaijo.append(kaijo[-1]*i) #これで、kaijo[i]=i!となる。
		gyakugen=[pow(kaijo[n-r],mod-2,mod)]
		for i in reversed(range(1,n-r)):
			gyakugen.append(gyakugen[-1]*i%mod) #これで、gyakugen[i]=n-r-iの逆元となる
		kotae=kaijo[n]*gyakugen[0]*gyakugen[n-2*r]

		print(kotae)

Fixed submission:
[x,y]=list(map(int,input().split()))
if ((x%3)+(y%3))%3!=0:
	print(0)
else:
	n=int((x+y)/3)
	r=y-n
	if r<0 or r>n:
		print(0)
	else:
		if r>n-r:
			r=n-r
		mod=1000000007
		kaijo=[1]
		for i in range(1,n+1):
			kaijo.append(kaijo[-1]*i%mod) #これで、kaijo[i]=i!となる。
		gyakugen=[pow(kaijo[n-r],mod-2,mod)]
		for i in reversed(range(1,n-r+1)):
			gyakugen.append(gyakugen[-1]*i%mod) #これで、gyakugen[i]=n-r-iの逆元となる
		kotae=kaijo[n]*gyakugen[0]*gyakugen[n-2*r]%mod

		print(kotae)

Buggy python submission (verdict: Time Limit Exceeded):
[x,y]=list(map(int,input().split()))
if ((x%3)+(y%3))%3!=0:
	print(0)
else:
	dansu=int((x+y)/3)
	r=y-dansu
	if r>dansu-r:
		r=dansu-r
	mod=1000000007
	d=1
	rr=1
	nr=1
	for i in range(1,dansu+1):
		d=d*(i%mod)
	for i in range(1,r+1):
		rr=rr*(i%mod)
	for i in range(1,dansu-r+1):
		nr=nr*(i%mod)
	rr2=rr*rr
	nr2=nr*nr
	rrinv=1
	nrinv=1
	modd=mod
	mod2=[]
	while modd>0:
		mod2.append(modd%2)
		modd=modd//2
	for i in range(len(mod2)-1):
		if mod2[i]==1:
			rrinv=rrinv*(rr2**(len(mod2)-i-1))
			nrinv=nrinv*(nr2**(len(mod2)-i-1))
	rrinv*=rr
	nrinv*=nr
	kotae=int((d%mod)*(rrinv%mod)*(nrinv%mod))
	kotae=int(kotae%(10**9+7))
	
	print(kotae)

Fixed submission:
[x,y]=list(map(int,input().split()))
if ((x%3)+(y%3))%3!=0:
	print(0)
else:
	n=int((x+y)/3)
	r=y-n
	if r<0 or r>n:
		print(0)
	else:
		if r>n-r:
			r=n-r
		mod=1000000007
		kaijo=[1]
		for i in range(1,n+1):
			kaijo.append(kaijo[-1]*i%mod) #これで、kaijo[i]=i!となる。
		gyakugen=[pow(kaijo[n-r],mod-2,mod)]
		for i in reversed(range(1,n-r+1)):
			gyakugen.append(gyakugen[-1]*i%mod) #これで、gyakugen[i]=n-r-iの逆元となる
		kotae=kaijo[n]*gyakugen[0]*gyakugen[n-2*r]%mod

		print(kotae)

Buggy python submission (verdict: Time Limit Exceeded):
[x,y]=list(map(int,input().split()))
if ((x%3)+(y%3))%3!=0:
	print(0)
else:
	dansu=int((x+y)/3)
	r=y-dansu
	if r>dansu-r:
		r=dansu-r
	mod=1000000007
	d=1
	rr=1
	nr=1
	for i in range(1,dansu+1):
		d=d*(i%mod)
	for i in range(1,r+1):
		rr=rr*(i%mod)
	for i in range(1,dansu-r+1):
		nr=nr*(i%mod)
	rr2=rr*rr
	nr2=nr*nr
	rrinv=1
	nrinv=1
	modd=mod
	mod2=[]
	while modd>0:
		mod2.append(modd%2)
		modd=modd//2
	for i in range(len(mod2)-1):
		if mod2[i]==1:
			rrinv=rrinv*(rr2**(len(mod2)-i-1))
			nrinv=nrinv*(nr2**(len(mod2)-i-1))
	rrinv*=rr
	nrinv*=nr
	kotae=int((d%mod)*(rrinv%mod)*(nrinv%mod))
	kotae=int(kotae%(10**9+7))
	
	print(kotae)

Fixed submission:
[x,y]=list(map(int,input().split()))
if ((x%3)+(y%3))%3!=0:
	print(0)
else:
	n=int((x+y)/3)
	r=y-n
	if r<0 or r>n:
		print(0)
	else:
		if r>n-r:
			r=n-r
		mod=1000000007
		kaijo=[1]
		for i in range(1,n+1):
			kaijo.append(kaijo[-1]*i%mod) #これで、kaijo[i]=i!となる。
		gyakugen=[pow(kaijo[n-r],mod-2,mod)]
		for i in reversed(range(1,n-r+1)):
			gyakugen.append(gyakugen[-1]*i%mod) #これで、gyakugen[i]=n-r-iの逆元となる
		kotae=kaijo[n]*gyakugen[0]*gyakugen[n-2*r]%mod

		print(kotae)

Buggy python submission (verdict: Runtime Error):
[x,y]=list(map(int,input().split()))
if ((x%3)+(y%3))%3!=0:
	print(0)
else:
	dansu=int((x+y)/3)
	r=y-dansu
	if r>dansu-r:
		r=dansu-r
	mod=1000000007
	d=1
	rr=1
	nr=1
	for i in range(1,dansu+1):
		d=d*(i%mod)
	for i in range(1,r+1):
		rr=rr*(i%mod)
	for i in range(1,dansu-r+1):
		nr=nr*(i%mod)
	rrinv=rr
	nrinv=nr
	for i in range(29):
		rrinv=(rrinv%mod)**2
		nrinv=(nrinv%mod)**2
		if i==26:
			a=rrinv
			b=nrinv
		if i==27:
			c=rrinv
			d=nrinv
	rrinv=rrinv*a*c*rr**60475911
	nrinv=nrinv*a*dnr**60475911
	kotae=int((d%mod)*(rrinv%mod)*(nrinv%mod))
	kotae=int(kotae%(10**9+7))
	
	print(kotae)

Fixed submission:
[x,y]=list(map(int,input().split()))
if ((x%3)+(y%3))%3!=0:
	print(0)
else:
	n=int((x+y)/3)
	r=y-n
	if r<0 or r>n:
		print(0)
	else:
		if r>n-r:
			r=n-r
		mod=1000000007
		kaijo=[1]
		for i in range(1,n+1):
			kaijo.append(kaijo[-1]*i%mod) #これで、kaijo[i]=i!となる。
		gyakugen=[pow(kaijo[n-r],mod-2,mod)]
		for i in reversed(range(1,n-r+1)):
			gyakugen.append(gyakugen[-1]*i%mod) #これで、gyakugen[i]=n-r-iの逆元となる
		kotae=kaijo[n]*gyakugen[0]*gyakugen[n-2*r]%mod

		print(kotae)

Buggy python submission (verdict: Runtime Error):
[x,y]=list(map(int,input().split()))
if ((x%3)+(y%3))%3!=0:
	print(0)
else:
	dansu=int((x+y)/3)
	r=y-dansu
	if r>dansu-r:
		
	mod=1000000007
	d=1
	rr=1
	nr=1
	for i in range(1,dansu+1):
		d=d*(i%mod)
	for i in range(1,r+1):
		rr=rr*(i%mod)
	for i in range(1,dansu-r+1):
		nr=nr*(i%mod)
	rrinv=rr
	nrinv=nr
	for i in range(29):
		rrinv=(rrinv%mod)**2
		nrinv=(nrinv%mod)**2
		if i==26:
			a=rrinv
			b=nrinv
		if i==27:
			c=rrinv
			d=nrinv
	rrinv=rrinv*a*c*rr**60475911
	nrinv=nrinv*a*dnr**60475911
	kotae=int((d%mod)*(rrinv%mod)*(nrinv%mod))
	kotae=int(kotae%(10**9+7))
	
	print(kotae)

Fixed submission:
[x,y]=list(map(int,input().split()))
if ((x%3)+(y%3))%3!=0:
	print(0)
else:
	n=int((x+y)/3)
	r=y-n
	if r<0 or r>n:
		print(0)
	else:
		if r>n-r:
			r=n-r
		mod=1000000007
		kaijo=[1]
		for i in range(1,n+1):
			kaijo.append(kaijo[-1]*i%mod) #これで、kaijo[i]=i!となる。
		gyakugen=[pow(kaijo[n-r],mod-2,mod)]
		for i in reversed(range(1,n-r+1)):
			gyakugen.append(gyakugen[-1]*i%mod) #これで、gyakugen[i]=n-r-iの逆元となる
		kotae=kaijo[n]*gyakugen[0]*gyakugen[n-2*r]%mod

		print(kotae)

Buggy python submission (verdict: Time Limit Exceeded):
[x,y]=list(map(int,input().split()))
if ((x%3)+(y%3))%3!=0:
	print(0)
else:
	dansu=int((x+y)/3)
	r=y-dansu
	if r>dansu-r:
		r=dansu-r
	mod=1000000007
	d=1
	rr=1
	nr=1
	for i in range(1,dansu+1):
		d=d*i
	for i in range(1,r+1):
		rr=rr*i
	for i in range(1,dansu-r+1):
		nr=nr*i
	
	kotae=int((d%mod)*pow(rr,mod-2,mod)*pow(nr,mod-2,mod))
	kotae=int(kotae%(10**9+7))
	
	print(kotae)

Fixed submission:
[x,y]=list(map(int,input().split()))
if ((x%3)+(y%3))%3!=0:
	print(0)
else:
	n=int((x+y)/3)
	r=y-n
	if r<0 or r>n:
		print(0)
	else:
		if r>n-r:
			r=n-r
		mod=1000000007
		kaijo=[1]
		for i in range(1,n+1):
			kaijo.append(kaijo[-1]*i%mod) #これで、kaijo[i]=i!となる。
		gyakugen=[pow(kaijo[n-r],mod-2,mod)]
		for i in reversed(range(1,n-r+1)):
			gyakugen.append(gyakugen[-1]*i%mod) #これで、gyakugen[i]=n-r-iの逆元となる
		kotae=kaijo[n]*gyakugen[0]*gyakugen[n-2*r]%mod

		print(kotae)

Buggy python submission (verdict: Time Limit Exceeded):
[x,y]=list(map(int,input().split()))
if ((x%3)+(y%3))%3!=0:
	print(0)
else:
	dansu=int((x+y)/3)
	r=y-dansu
	if r>dansu-r:
		r=dansu-r
	mod=1000000007
	d=1
	rr=1
	nr=1
	for i in range(1,dansu+1):
		d=d*(i%mod)
	for i in range(1,r+1):
		rr=rr*(i%mod)
	for i in range(1,dansu-r+1):
		nr=nr*(i%mod)
	
	kotae=int((d%mod)*pow(rr,mod-2,mod)*pow(nr,mod-2,mod))
	kotae=int(kotae%(10**9+7))
	
	print(kotae)

Fixed submission:
[x,y]=list(map(int,input().split()))
if ((x%3)+(y%3))%3!=0:
	print(0)
else:
	n=int((x+y)/3)
	r=y-n
	if r<0 or r>n:
		print(0)
	else:
		if r>n-r:
			r=n-r
		mod=1000000007
		kaijo=[1]
		for i in range(1,n+1):
			kaijo.append(kaijo[-1]*i%mod) #これで、kaijo[i]=i!となる。
		gyakugen=[pow(kaijo[n-r],mod-2,mod)]
		for i in reversed(range(1,n-r+1)):
			gyakugen.append(gyakugen[-1]*i%mod) #これで、gyakugen[i]=n-r-iの逆元となる
		kotae=kaijo[n]*gyakugen[0]*gyakugen[n-2*r]%mod

		print(kotae)

Buggy python submission (verdict: Time Limit Exceeded):
[x,y]=list(map(int,input().split()))
if ((x%3)+(y%3))%3!=0:
	print(0)
else:
	dansu=int((x+y)/3)
	r=y-dansu
	if r>dansu-r:
		r=dansu-r
	mod=1000000007
	d=1
	rr=1
	nr=1
	for i in range(1,dansu+1):
		d=d*(i%mod)
	for i in range(1,r+1):
		rr=rr*(i%mod)
	for i in range(1,dansu-r+1):
		nr=nr*(i%mod)
	
	kotae=int((d%mod)*pow(rr,mod-2,mod)*pow(nr,mod-2,mod))
	kotae=int(kotae%(10**9+7))
	
	print(kotae)

Fixed submission:
[x,y]=list(map(int,input().split()))
if ((x%3)+(y%3))%3!=0:
	print(0)
else:
	n=int((x+y)/3)
	r=y-n
	if r<0 or r>n:
		print(0)
	else:
		if r>n-r:
			r=n-r
		mod=1000000007
		kaijo=[1]
		for i in range(1,n+1):
			kaijo.append(kaijo[-1]*i%mod) #これで、kaijo[i]=i!となる。
		gyakugen=[pow(kaijo[n-r],mod-2,mod)]
		for i in reversed(range(1,n-r+1)):
			gyakugen.append(gyakugen[-1]*i%mod) #これで、gyakugen[i]=n-r-iの逆元となる
		kotae=kaijo[n]*gyakugen[0]*gyakugen[n-2*r]%mod

		print(kotae)

Buggy python submission (verdict: Time Limit Exceeded):
[x,y]=list(map(int,input().split()))
if ((x%3)+(y%3))%3!=0:
	print(0)
else:
	dansu=int((x+y)/3)
	r=y-dansu
	mod=1000000007
	d=1
	rr=1
	nr=1
	for i in range(1,dansu+1):
		d=d*(i%mod)
	for i in range(1,r+1):
		rr=rr*(i%mod)
	for i in range(1,dansu-r+1):
		nr=nr*(i%mod)
	
	kotae=int((d%mod)*pow(rr,mod-2,mod)*pow(nr,mod-2,mod))
	kotae=int(kotae%(10**9+7))
	
	print(kotae)

Fixed submission:
[x,y]=list(map(int,input().split()))
if ((x%3)+(y%3))%3!=0:
	print(0)
else:
	n=int((x+y)/3)
	r=y-n
	if r<0 or r>n:
		print(0)
	else:
		if r>n-r:
			r=n-r
		mod=1000000007
		kaijo=[1]
		for i in range(1,n+1):
			kaijo.append(kaijo[-1]*i%mod) #これで、kaijo[i]=i!となる。
		gyakugen=[pow(kaijo[n-r],mod-2,mod)]
		for i in reversed(range(1,n-r+1)):
			gyakugen.append(gyakugen[-1]*i%mod) #これで、gyakugen[i]=n-r-iの逆元となる
		kotae=kaijo[n]*gyakugen[0]*gyakugen[n-2*r]%mod

		print(kotae)

Buggy python submission (verdict: Time Limit Exceeded):
[x,y]=list(map(int,input().split()))
if ((x%3)+(y%3))%3!=0:
	print(0)
else:
	dansu=int((x+y)/3)
	r=y-dansu
	mod=1000000007
	d=1
	rr=1
	nr=1
	for i in range(1,dansu+1):
		d=d*(i%mod)
	for i in range(1,r+1):
		rr=rr*(i%mod)
	for i in range(1,dansu-r+1):
		nr=nr*(i%mod)
	
	kotae=int((d%mod)*((rr**(mod-2))%mod)*((nr**(mod-2))%mod))
	kotae=int(kotae%(10**9+7))
	
	print(kotae)

Fixed submission:
[x,y]=list(map(int,input().split()))
if ((x%3)+(y%3))%3!=0:
	print(0)
else:
	n=int((x+y)/3)
	r=y-n
	if r<0 or r>n:
		print(0)
	else:
		if r>n-r:
			r=n-r
		mod=1000000007
		kaijo=[1]
		for i in range(1,n+1):
			kaijo.append(kaijo[-1]*i%mod) #これで、kaijo[i]=i!となる。
		gyakugen=[pow(kaijo[n-r],mod-2,mod)]
		for i in reversed(range(1,n-r+1)):
			gyakugen.append(gyakugen[-1]*i%mod) #これで、gyakugen[i]=n-r-iの逆元となる
		kotae=kaijo[n]*gyakugen[0]*gyakugen[n-2*r]%mod

		print(kotae)

Buggy python submission (verdict: Time Limit Exceeded):
[x,y]=list(map(int,input().split()))
if ((x%3)+(y%3))%3!=0:
	print(0)
else:
	dansu=int((x+y)/3)
	r=y-dansu
	mod=1000000007
	d=1
	rr=1
	nr=1
	for i in range(1,dansu+1):
		d=d*(i%mod)
	for i in range(1,r+1):
		rr=rr*(i%mod)
	for i in range(1,dansu-r+1):
		nr=nr*(i%mod)
	
	kotae=int(d*(rr**(mod-2))*(nr**(mod-2)))
	kotae=int(kotae%(10**9+7))
	
	print(kotae)

Fixed submission:
[x,y]=list(map(int,input().split()))
if ((x%3)+(y%3))%3!=0:
	print(0)
else:
	n=int((x+y)/3)
	r=y-n
	if r<0 or r>n:
		print(0)
	else:
		if r>n-r:
			r=n-r
		mod=1000000007
		kaijo=[1]
		for i in range(1,n+1):
			kaijo.append(kaijo[-1]*i%mod) #これで、kaijo[i]=i!となる。
		gyakugen=[pow(kaijo[n-r],mod-2,mod)]
		for i in reversed(range(1,n-r+1)):
			gyakugen.append(gyakugen[-1]*i%mod) #これで、gyakugen[i]=n-r-iの逆元となる
		kotae=kaijo[n]*gyakugen[0]*gyakugen[n-2*r]%mod

		print(kotae)

Buggy python submission (verdict: Runtime Error):
import math
[x,y]=list(map(int,input().split()))
if ((x%3)+(y%3))%3!=0:
	print(0)
else:
	dansu=int((x+y)/3)
	r=y-dansu
	# d=1
	# rr=1
	# nr=1
	# for i in range(1,dansu+1):
		# d=d*(i%(10**9+7))
	# for i in range(1,r+1):
		# rr=rr*(i%(10**9+7))
	# for i in range(1,dansu-r+1):
		# nr=nr*(i%(10**9+7))
	
	# kotae=int(d/(rr*nr))
	kotae=math.factorial(dansu)/(math.factorial(dansu-r)*math.factorial(r))
	kotae=int(kotae%(10**9+7))
	
	print(kotae)

Fixed submission:
[x,y]=list(map(int,input().split()))
if ((x%3)+(y%3))%3!=0:
	print(0)
else:
	n=int((x+y)/3)
	r=y-n
	if r<0 or r>n:
		print(0)
	else:
		if r>n-r:
			r=n-r
		mod=1000000007
		kaijo=[1]
		for i in range(1,n+1):
			kaijo.append(kaijo[-1]*i%mod) #これで、kaijo[i]=i!となる。
		gyakugen=[pow(kaijo[n-r],mod-2,mod)]
		for i in reversed(range(1,n-r+1)):
			gyakugen.append(gyakugen[-1]*i%mod) #これで、gyakugen[i]=n-r-iの逆元となる
		kotae=kaijo[n]*gyakugen[0]*gyakugen[n-2*r]%mod

		print(kotae)

Buggy python submission (verdict: Runtime Error):
import math
[x,y]=list(map(int,input().split()))
if ((x%3)+(y%3))%3!=0:
	print(0)
else:
	dansu=int((x+y)/3)
	r=y-dansu
	# d=1
	# rr=1
	# nr=1
	# for i in range(1,dansu+1):
		# d=d*(i%(10**9+7))
	# for i in range(1,r+1):
		# rr=rr*(i%(10**9+7))
	# for i in range(1,dansu-r+1):
		# nr=nr*(i%(10**9+7))
	
	# kotae=int(d/(rr*nr))
	kotae=math.factorial(dansu)/(math.factorial(dansu-r)*math.factorial(r))
	kotae=kotae%(10**9+7)
	
	print(kotae)

Fixed submission:
[x,y]=list(map(int,input().split()))
if ((x%3)+(y%3))%3!=0:
	print(0)
else:
	n=int((x+y)/3)
	r=y-n
	if r<0 or r>n:
		print(0)
	else:
		if r>n-r:
			r=n-r
		mod=1000000007
		kaijo=[1]
		for i in range(1,n+1):
			kaijo.append(kaijo[-1]*i%mod) #これで、kaijo[i]=i!となる。
		gyakugen=[pow(kaijo[n-r],mod-2,mod)]
		for i in reversed(range(1,n-r+1)):
			gyakugen.append(gyakugen[-1]*i%mod) #これで、gyakugen[i]=n-r-iの逆元となる
		kotae=kaijo[n]*gyakugen[0]*gyakugen[n-2*r]%mod

		print(kotae)

Buggy python submission (verdict: Runtime Error):
import math
[x,y]=list(map(int,input().split()))
if ((x%3)+(y%3))%3!=0:
	print(0)
else:
	dansu=int((x+y)/3)
	r=y-dansu
	# d=1
	# rr=1
	# nr=1
	# for i in range(1,dansu+1):
		# d=d*(i%(10**9+7))
	# for i in range(1,r+1):
		# rr=rr*(i%(10**9+7))
	# for i in range(1,dansu-r+1):
		# nr=nr*(i%(10**9+7))
	
	# kotae=int(d/(rr*nr))
	kotae=math.factorial(dansu)//(math.factorial(dansu-r)*math.factorial(r))
	kotae=kotae%(10**9+7)
	
	print(kotae)

Fixed submission:
[x,y]=list(map(int,input().split()))
if ((x%3)+(y%3))%3!=0:
	print(0)
else:
	n=int((x+y)/3)
	r=y-n
	if r<0 or r>n:
		print(0)
	else:
		if r>n-r:
			r=n-r
		mod=1000000007
		kaijo=[1]
		for i in range(1,n+1):
			kaijo.append(kaijo[-1]*i%mod) #これで、kaijo[i]=i!となる。
		gyakugen=[pow(kaijo[n-r],mod-2,mod)]
		for i in reversed(range(1,n-r+1)):
			gyakugen.append(gyakugen[-1]*i%mod) #これで、gyakugen[i]=n-r-iの逆元となる
		kotae=kaijo[n]*gyakugen[0]*gyakugen[n-2*r]%mod

		print(kotae)

Buggy python submission (verdict: Time Limit Exceeded):
[x,y]=list(map(int,input().split()))
if ((x%3)+(y%3))%3!=0:
	print(0)
else:
	dansu=int((x+y)/3)
	r=(x+y-dansu)-x
	d=1
	rr=1
	nr=1
	for i in range(1,dansu+1):
		d=d*(i%(10**9+7))
	for i in range(1,r+1):
		rr=rr*(i%(10**9+7))
	for i in range(1,dansu-r+1):
		nr=nr*(i%(10**9+7))
	
	kotae=int(d/(rr*nr))
	kotae=kotae%(10**9+7)
	
	print(kotae)

Fixed submission:
[x,y]=list(map(int,input().split()))
if ((x%3)+(y%3))%3!=0:
	print(0)
else:
	n=int((x+y)/3)
	r=y-n
	if r<0 or r>n:
		print(0)
	else:
		if r>n-r:
			r=n-r
		mod=1000000007
		kaijo=[1]
		for i in range(1,n+1):
			kaijo.append(kaijo[-1]*i%mod) #これで、kaijo[i]=i!となる。
		gyakugen=[pow(kaijo[n-r],mod-2,mod)]
		for i in reversed(range(1,n-r+1)):
			gyakugen.append(gyakugen[-1]*i%mod) #これで、gyakugen[i]=n-r-iの逆元となる
		kotae=kaijo[n]*gyakugen[0]*gyakugen[n-2*r]%mod

		print(kotae)