Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
from math import factorial
N = 10**9+7
def combinations_count(n, r, N):
    ''' 組み合わせ '''
    return (factorial(n) // (factorial(n - r) * factorial(r)) ) % N

lis = list(range(1, a+1))
lis.remove(a)
lis.remove(b)

data1 = list(map(combinations_count, lis))
print(lis)
print(combinations_count(5, 2, N))

Fixed submission:
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

n,a,b = nm()
mod = 10**9 + 7
s = pow(2,n,mod) - 1

def fur(n,r):
    p,q = 1,1
    for i in range(r):
        p = p*(n-i)%mod
        q = q*(i+1)%mod
    return p * pow(q,mod-2,mod) % mod

print((s - fur(n,a) - fur(n,b)) % mod)
Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
A = N/1.08 
B = (N+1)/1.08 

if math.ceil(A) < math.ceil(B):
  print(ceil(A))
else:
  print(':(')


Fixed submission:
import math
N = int(input())
A = N/1.08 
B = (N+1)/1.08 

if math.ceil(N/1.08) < math.ceil((N+1)/1.08 ):
  print(math.ceil(N/1.08))
else:
  print(':(')
Buggy python submission (verdict: Runtime Error):
N = int(input())
if N==3 || N==5 || N==7:
  print "YES"
else:
  print"NO"

Fixed submission:
N = int(input())
if N ==3 or N==5 or N==7:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
a, b,c = map(str, input().split())
if a[-1]==b[1] and b[-1]==c[1]:
  print('YES')
  exit()
print('NO')

Fixed submission:
a, b,c = map(str, input().split())
if a[-1]==b[0] and b[-1]==c[0]:
  print('YES')
  exit()
print('NO')
Buggy python submission (verdict: Runtime Error):
#include<bits/stdc++.h>
using namespace std;
int main(){
	char a;
	cin>>a;
	switch(a){
		case "A":cout<<"T"<<endl;break;
		case "T":cout<<"A"<<endl;break;
		case "C":cout<<"G"<<endl;break;
		case "G":cout<<"C"<<endl;break;
	}
	return 0;
}


Fixed submission:
a = input()
if a == "T":
  print("A")
elif a=="A":
  print("T")
elif a=="C":
  print("G")
else:
  print("C")

Buggy python submission (verdict: Runtime Error):
#include<bits/stdc++.h>
using namespace std;
int main(){
	char a;
	cin>>a;
	switch(a){
		case "A":cout<<"T"<<endl;
		case "T":cout<<"A"<<endl;
		case "C":cout<<"G"<<endl;
		case "G":cout<<"C"<<endl;
	}
	return 0;
}


Fixed submission:
a = input()
if a == "T":
  print("A")
elif a=="A":
  print("T")
elif a=="C":
  print("G")
else:
  print("C")
Buggy python submission (verdict: Runtime Error):
impourt sys

count = 0
n, d = [int(i) for i in input().split()]
for i in range(n):
  x, y = [int(i) for i in input().split()]
  if x * x + y * y <= d * d:
    count += 1
print(count)


Fixed submission:
import sys

count = 0
n, d = [int(i) for i in input().split()]
for i in range(n):
  x, y = [int(i) for i in input().split()]
  if x * x + y * y <= d * d:
    count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
def main():
    N,D=map(int,input().split())
    ans=0
    for i in range(N):
        x,y=map(int,input().split())
        if x^2+y^2<=D^2:
            ans+=1
    print(ans)

main()



Fixed submission:
x = input()
x = int(x)
if x >= 30:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
def main():
    N,D=map(int,input().split())
    ans=0
    for _ in range(N):
        x,y=map(int,input().split())
        if x^2+y^2<=D^2:
            ans+=1
    print(ans)

main()


Fixed submission:
x = input()
x = int(x)
if x >= 30:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
K=int(input())
a=-1
b=0
for i in range(K):
    b+=7*10**i
    if(b%K==0):
        a=i+1
        break

print(a)

Fixed submission:
K=int(input())
a=-1
b=0

for i in range(K):
    b=(10*b+7)%K
    if(b==0):
        a=i+1
        break

print(a)
Buggy python submission (verdict: Runtime Error):
X = int(input())
if X >= 30:
  print('Yes')
else:
  print('No'9)

Fixed submission:
X = int(input())
if X >= 30:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
if X >= 30:
  print('Yes')
else :
  print('No')


Fixed submission:
X = int(input())
if X >= 30:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
def yesNo(X):
  if X <= 30:
    print('Yes')
  else:
    print('No')

yesNo(X)

Fixed submission:
X = int(input())
if X >= 30:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n,m,q = (int(x) for x in input().split())
l = []
a = [1,2,3,4,5,6,7,8,9,10]
b = []
c = []
d = []


for i in range(q):
    l.append([])
    l[i]=list(map(int, input().split()))
    
for i in itertools.combinations_with_replacement(a[:m], r=n):#考えられる数列
    if i not in b:
        b.append(i) 
        
    
for i in range(len(b)):#それぞれの数列の得点表
    d.append(0)

for i in range(q):
    w=l[i][0]-1#a
    x=l[i][1]-1#b
    y=l[i][2]#c
    z=l[i][3]#d
    for j in range(len(b)):
        if b[j][x]-b[j][w]==y:
            d[j]+=z

print(max(d))

Fixed submission:
import itertools
n,m,q = (int(x) for x in input().split())
l = []
a = [1,2,3,4,5,6,7,8,9,10]
b = []
c = []
d = []


for i in range(q):
    l.append([])
    l[i]=list(map(int, input().split()))
    
for i in itertools.combinations_with_replacement(a[:m], r=n):#考えられる数列
        b.append(i)        
    
for i in range(len(b)):#それぞれの数列の得点表
    d.append(0)

for i in range(q):
    w=l[i][0]-1#a
    x=l[i][1]-1#b
    y=l[i][2]#c
    z=l[i][3]#d
    for j in range(len(b)):
        if b[j][x]-b[j][w]==y:
            d[j]+=z

print(max(d))
Buggy python submission (verdict: Runtime Error):
s = input()
if s=="AAA" | s=="BBB":
    print("No")
else: 
    print("Yes")

Fixed submission:
s = input()
if (s in "AAA") | (s in "BBB"):
    print("No")
else: 
    print("Yes")
Buggy python submission (verdict: Runtime Error):
n = input()
if n%2==0:
    print(int(n/2))
else:
    print(int(n/2)+1)

Fixed submission:
n = int(input())
if n%2==0:
    print(int(n/2))
else:
    print(int(n/2)+1)
Buggy python submission (verdict: Runtime Error):
a,b,c = (int(x) for x in input().split())

if b-a=c-b:
    print("YES")
else:
    print("NO")

Fixed submission:
a,b,c = (int(x) for x in input().split())

if b-a==c-b:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
n = input()
if n >= 30:
  print(Yes)
else:
  print(No)

Fixed submission:
n = int(input())
if n >= 30:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	x,y,a,b,c = MI()
	p = np.array(LI())
	p = np.sort(p)[::-1]
	q = np.array(LI())
	r = np.array(LI())
	r = np.sort(r)[::-1]
	X = a
	ans = 0
	for X in range(min(a,x),-1,-1):
		Cx=0
		if(x > X):
			Cx = x-X
			s = np.concatenate([q,r[Cx-1:]], axis=0)
			s = np.sort(s)[::-1]
			ans = max(ans, np.sum(p[:X])+np.sum(r[:Cx])+np.sum(s[:y]))
		else:
			s = np.concatenate([q,r], axis=0)
			s = np.sort(s)[::-1]
			ans = max(ans, np.sum(p[:X])+np.sum(s[:y+Cx]))
	print(ans)

if __name__ == '__main__':
	main()

Fixed submission:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	x,y,a,b,c = MI()
	p = LI()
	p.sort(reverse=True)
	q = LI()
	q.sort(reverse=True)
	r = LI()

	p = p[:x]
	q = q[:y]
	pqr = p+q+r
	pqr.sort(reverse=True)
	print(sum(pqr[:x+y]))

if __name__ == '__main__':
	main()
Buggy python submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N = II()
	A = LI1()
	L = [0]*N
	b = [0]*N
	t = 1
	for i,a in enumerate(A):
		L[a]+=1
		if(i==0):
			b[0]=t
		else:
			b[i]=b[i-1]+t
		t+=1
	L_s = L.copy()
	L_s.sort(reverse=True)
	max_c = 0
	for l in L_s:
		if l <= 1:
			break
		else:
			max_c += b[l-2]
	ans = [max_c]*N
	for i,a in enumerate(A):
		if(L[a]>=2):
			ans[i]+=(-L[a]+1)
	printV(ans)


if __name__ == '__main__':
	main()

Fixed submission:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N = II()
	A = LI1()
	L = [0]*N
	b = [0]*N
	t = 1
	for i,a in enumerate(A):
		L[a]+=1
		if(i==0):
			b[0]=t
		else:
			b[i]=b[i-1]+t
		t+=1
	L_s = L.copy()
	L_s.sort(reverse=True)
	max_c = 0
	for l in L_s:
		if l <= 1:
			break
		else:
			max_c += b[l-2]
	ans = [max_c]*N
	for i,a in enumerate(A):
		if(L[a]>=2):
			ans[i]+=(-L[a]+1)
	printV(ans)


if __name__ == '__main__':
	main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np
from functools import lru_cache
input = sys.stdin.readline

sys.setrecursionlimit(1000000)

N,D,A = map(int,input().split())
XH = []
for i in range(N):
	x,h = map(int, input().split())
	XH.append([x,h])

XH.sort(key=lambda xh: xh[0])
XH = np.array(XH)

ans = 0 
while len(XH)>0:
	TRAGET = (XH[:,0] <= XH[0][0]+2*D)
	H = XH[0][1]
	if(0==H%A):
		a = H//A
	else:
		a = H//A+1
	XH[TRAGET] = XH[TRAGET] - [0,a*A]
	ans += a
	TRAGET = (XH[:,1] > 0)
	XH = XH[TRAGET]
print(ans)

Fixed submission:
import sys
from collections import deque
 
input = sys.stdin.readline
 
N,D,A = map(int,input().split())
XH = []
for i in range(N):
	x,h = map(int, input().split())
	XH.append([x,h])
 
XH.sort(key=lambda xh: xh[0])
que = deque()
D = 2*D
 
H = XH[0][1]
if(0==H%A): a = H//A
else: a = H//A+1
que.append([XH[0][0]+D,a*A])
tot = a * A
ans = a
for i in range(1,N):
	while XH[i][0] > que[0][0] :
		tot -= que[0][1]
		que.popleft()
		if(len(que)==0): break
	if(tot < XH[i][1]):
		H = XH[i][1]-tot
		if(0==H%A): a = H//A
		else: a = H//A+1
		ans += a
		que.append([XH[i][0]+D,a*A])
		tot += a*A
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np
from functools import lru_cache
input = sys.stdin.readline

sys.setrecursionlimit(1000000)

N,D,A = map(int,input().split())
XH = []
for i in range(N):
	x,h = map(int, input().split())
	XH.append([x,h])

XH.sort(key=lambda xh: xh[0])
XH = np.array(XH, dtype=np.int64)

ans = 0 
while len(XH)>0:
	TRAGET = (XH[:,0] <= XH[0][0]+2*D)
	H = XH[0][1]
	if(0==H%A):
		a = H//A
	else:
		a = H//A+1
	XH[TRAGET] = XH[TRAGET] - [0,a*A]
	ans += a
	TRAGET = (XH[:,1] > 0)
	XH = XH[TRAGET]
print(ans)

Fixed submission:
import sys
from collections import deque
 
input = sys.stdin.readline
 
N,D,A = map(int,input().split())
XH = []
for i in range(N):
	x,h = map(int, input().split())
	XH.append([x,h])
 
XH.sort(key=lambda xh: xh[0])
que = deque()
D = 2*D
 
H = XH[0][1]
if(0==H%A): a = H//A
else: a = H//A+1
que.append([XH[0][0]+D,a*A])
tot = a * A
ans = a
for i in range(1,N):
	while XH[i][0] > que[0][0] :
		tot -= que[0][1]
		que.popleft()
		if(len(que)==0): break
	if(tot < XH[i][1]):
		H = XH[i][1]-tot
		if(0==H%A): a = H//A
		else: a = H//A+1
		ans += a
		que.append([XH[i][0]+D,a*A])
		tot += a*A
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
from scipy.misc import comb



N,K = map(int, input().split())
lst_A = list(map(int, input().split()))
lst_A.sort()

fmax = 0
fmin = 0
for i in range(N):
	if(K-1<=N-1-i):
		fmin += lst_A[i] * comb(N-i-1, K-1)
	if(i>=K-1):
		fmax += lst_A[i] * comb(i,K-1)

print((fmax-fmin)% 1000000007)


Fixed submission:
import sys
input = sys.stdin.readline

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

N,K = map(int, input().split())
lst_A = list(map(int, input().split()))
lst_A.sort()

p = 10 ** 9 + 7
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)


fmax = 0
fmin = 0
for i in range(N):
	if(K-1<=N-1-i):
		fmin += lst_A[i] * cmb(N-i-1, K-1,p)
	if(i>=K-1):
		fmax += lst_A[i] * cmb(i,K-1,p)

print((fmax-fmin)% p)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np
import itertools

input = sys.stdin.readline

N,K = map(int, input().split())
lst_A = list(map(int, input().split()))
lst_A.sort()
lst_A = np.array(lst_A)

ans = 0
for i in list(itertools.combinations([j for j in range(N)], K)):
	S = lst_A[list(i)]
	ans += S[-1]-S[0]

print((ans)% 1000000007)

Fixed submission:
import sys
input = sys.stdin.readline

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

N,K = map(int, input().split())
lst_A = list(map(int, input().split()))
lst_A.sort()

p = 10 ** 9 + 7
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)


fmax = 0
fmin = 0
for i in range(N):
	if(K-1<=N-1-i):
		fmin += lst_A[i] * cmb(N-i-1, K-1,p)
	if(i>=K-1):
		fmax += lst_A[i] * cmb(i,K-1,p)

print((fmax-fmin)% p)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np
import itertools

input = sys.stdin.readline

N,K = map(int, input().split())
lst_A = np.array(list(map(int, input().split())))

ans = 0
for i in list(itertools.combinations([j for j in range(N)], K)):
	S = lst_A[list(i)]
	ans += max(S)%((10**9)+7)-min(S)

print((ans)% 1000000007)

Fixed submission:
import sys
input = sys.stdin.readline

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

N,K = map(int, input().split())
lst_A = list(map(int, input().split()))
lst_A.sort()

p = 10 ** 9 + 7
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)


fmax = 0
fmin = 0
for i in range(N):
	if(K-1<=N-1-i):
		fmin += lst_A[i] * cmb(N-i-1, K-1,p)
	if(i>=K-1):
		fmax += lst_A[i] * cmb(i,K-1,p)

print((fmax-fmin)% p)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline


x = int(input())

prime = [True] * (1000000)
prime[2] = True

def e_prime(x):
	i = 2
	flag = False
	while True:
		if prime[i]:
			if(flag==True):
				return i
			else:
				for j in range(i**2,len(prime),i):
					prime[j]=False
		i+=1
		if(i==x):flag=True

print(e_prime(x))

Fixed submission:
import sys
input=sys.stdin.readline

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

a_a =  0 if(a <= k) else a - k
if(a_a > 0):
	b_a = b
else:
	if(k-a>=b):
		b_a = 0
	else:
		b_a = b+a-k
print(a_a, b_a)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline


x = int(input())

prime = [True] * (100004)
prime[2] = True

def e_prime(x):
	i = 2
	flag = False
	if(i==x):flag=True
	while True:
		if prime[i]:
			if(flag==True):
				return i
			else:
				for j in range(i**2,len(prime),i):
					prime[j]=False
		i+=1

print(e_prime(x))


Fixed submission:
import sys
input = sys.stdin.readline


x = int(input())

prime = [True] * (100004)
prime[2] = True

def e_prime(x):
	i = 2
	flag = False
	while True:
		if(i==x):flag=True
		if prime[i]:
			if(flag==True):
				return i
			else:
				for j in range(i**2,len(prime),i):
					prime[j]=False
		i+=1

print(e_prime(x))

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline


x = int(input())

prime = [True] * (100004)
prime[2] = True

def e_prime(x):
	i = 2
	flag = False
	while True:
		if prime[i]:
			if(flag==True):
				return i
			else:
				for j in range(i**2,len(prime),i):
					prime[j]=False
		i+=1
		if(i==x):flag=True

print(e_prime(x))


Fixed submission:
import sys
input = sys.stdin.readline


x = int(input())

prime = [True] * (100004)
prime[2] = True

def e_prime(x):
	i = 2
	flag = False
	while True:
		if(i==x):flag=True
		if prime[i]:
			if(flag==True):
				return i
			else:
				for j in range(i**2,len(prime),i):
					prime[j]=False
		i+=1

print(e_prime(x))

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline


x = int(input())

prime = [True] * (1000000)
prime[2] = True

def e_prime(x):
	i = 2
	flag = False
	while True:
		if prime[i]:
			if(flag==True):
				return i
			else:
				for j in range(i**2,len(prime),i):
					prime[j]=False
		i+=1
		if(i==x):flag=True

print(e_prime(x))

Fixed submission:
import sys
input = sys.stdin.readline


x = int(input())

prime = [True] * (100004)
prime[2] = True

def e_prime(x):
	i = 2
	flag = False
	while True:
		if(i==x):flag=True
		if prime[i]:
			if(flag==True):
				return i
			else:
				for j in range(i**2,len(prime),i):
					prime[j]=False
		i+=1

print(e_prime(x))

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline


x = int(input())

prime = [True] * (1000000)
prime[2] = True

def e_prime(x):
	i = 2
	flag = False
	while True:
		if prime[i]:
			if(flag==True):
				return i
			else:
				for j in range(i**2,len(prime),i):
					prime[j]=False
		i+=1
		if(i==x):flag=True

print(e_prime(x))

Fixed submission:
import sys
input = sys.stdin.readline


x = int(input())

prime = [True] * (100004)
prime[2] = True

def e_prime(x):
	i = 2
	flag = False
	while True:
		if(i==x):flag=True
		if prime[i]:
			if(flag==True):
				return i
			else:
				for j in range(i**2,len(prime),i):
					prime[j]=False
		i+=1

print(e_prime(x))
Buggy python submission (verdict: Runtime Error):
import sys
from collections import deque
from scipy.special import comb

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	X,Y = MI()
	N3 = (2*Y-X)
	M3 = (2*X-Y)
	if(N3%3!=0 or M3%3!=0 or N3 < 0 or M3<0):
		print(0)
	else:
		N=N3//3
		M=M3//3

		K = min(N,M)

		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 #出力の制限
		L = 10**6
		g1 = [1, 1] # 元テーブル
		g2 = [1, 1] #逆元テーブル
		inverse = [0, 1] #逆元テーブル計算用テーブル

		for i in range( 2, L + 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,K,mod))


main()

Fixed submission:
import sys
from collections import deque

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	X,Y = MI()
	N3 = (2*Y-X)
	M3 = (2*X-Y)
	if(N3%3!=0 or M3%3!=0 or N3 < 0 or M3<0):
		print(0)
	else:
		N=N3//3
		M=M3//3

		K = min(N,M)

		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 #出力の制限
		L = 10**6
		g1 = [1, 1] # 元テーブル
		g2 = [1, 1] #逆元テーブル
		inverse = [0, 1] #逆元テーブル計算用テーブル

		for i in range( 2, L + 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,K,mod))


main()
Buggy python submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N = II()
	l = [False]*100
	for i in range(1,10):
		for j in range(1,10):
			l[i*j] = True
	if(l[N]):print("Yes")
	else:print('No')



main()

Fixed submission:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N = II()
	l = [False]*101
	for i in range(1,10):
		for j in range(1,10):
			l[i*j] = True
	if(l[N]):print("Yes")
	else:print('No')



main()