ZhenlongDai/ACPR huggingface dataset:
Problem: p03449
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))

ans = 0

for i in range(n):
    tmp = sum(a1[0:i]) + sum(a2[i:n-1])
    ans = max(tmp, ans)

print(ans)


Failing test case input:
1
2
1

Expected output:
3


Actual output:
0


Fixed submission (verdict: Accepted):
n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))

ans = 0

for i in range(n):
    tmp = sum(a1[0:i+1]) + sum(a2[i:n])
    ans = max(tmp, ans)

print(ans)

Problem: p03449
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a1.append(0)
suml = []
for i in range(n):
    suml.append([sum(a1[:-i - 1]) + sum(a2[-i - 1:])])
print(max(suml))


Failing test case input:
7
3 8 2 4 3 6 2
11 6 5 4 1 2 3

Expected output:
35


Actual output:
[35]


Fixed submission (verdict: Accepted):
n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a1.append(0)
suml = []
for i in range(n):
    suml.append([sum(a1[:-i - 1]) + sum(a2[-i - 1:])])
print(max(suml)[0])

Problem: p03449
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = [list(map(int,input().split())) for i in range(2)]
ans = 0
su1 = [0]*n
su2 = [0]*n
su1[0],su2[0] = a[0][0],a[1][0]
for i in range(n):
    if i>0:
        su1[i] = su1[i-1]+a[0][i]
        su2[i] = su2[i - 1] + a[1][i]


for i in range(n):
    temp = su1[i]+su2[n-1]-su2[i-1]
    ans = max(ans, temp)
print(ans)

Failing test case input:
7
0 14 -1 -1 2 6 2
77 2 0 4 1 -1 11

Expected output:
94


Actual output:
33


Fixed submission (verdict: Accepted):
n = int(input())
a = [list(map(int,input().split())) for i in range(2)]
ans = 0
su1 = [0]*n
su2 = [0]*n
su1[0],su2[0] = a[0][0],a[1][0]
for i in range(n):
    if i>0:
        su1[i] = su1[i-1]+a[0][i]
        su2[i] = su2[i - 1] + a[1][i]


for i in range(n):
    temp = su1[i]+su2[n-1]-(su2[i-1] if i>0 else 0)
    ans = max(ans, temp)
print(ans)

Problem: p03449
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def C_Candies():
    N=int(input())
    a=list(map(int,input().split()))
    b=list(map(int,input().split()))
    print(a)
    print(b)
    count=0
    for i in range(N):
        if sum(a[i+1:N])<sum(b[i:N-1]):
            break
        count = count +1
        
    print(count)
    print(sum(a[0:count+1])+sum(b[count:N]))
C_Candies()

Failing test case input:
4
1 1 0 1
1 1 1 1

Expected output:
5


Actual output:
[1, 1, 0, 1]
[1, 1, 1, 1]
0
5


Fixed submission (verdict: Accepted):
def C_Candies():
    N=int(input())
    a=list(map(int,input().split()))
    b=list(map(int,input().split()))
    count=0
    for i in range(N):
        if count < sum(a[0:i+1])+sum(b[i:N+1]):
            count =sum(a[0:i+1])+sum(b[i:N+1])
    print(count)
C_Candies()
Problem: p03449
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
A=[list(map(int,input().split())) for _ in range(2)]

print(A)
ans=A[0][0]
for i in range(1,n+1):
  ans2=sum(A[0][:i])+sum(A[1][i-1:])
  ans=max(ans,ans2)
print(ans)

Failing test case input:
7
-2 -1 0 0 1 23 1
73 -1 0 0 -8 -1 2

Expected output:
63


Actual output:
[[-2, -1, 0, 0, 1, 23, 1], [73, -1, 0, 0, -8, -1, 2]]
63


Fixed submission (verdict: Accepted):
n=int(input())
A=[list(map(int,input().split())) for _ in range(2)]

ans=A[0][0]
for i in range(1,n+1):
  ans2=sum(A[0][:i])+sum(A[1][i-1:])
  ans=max(ans,ans2)
print(ans)
Problem: p02862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
x,y=map(int,input().split())
mod=10**9+7
def nCr_mod(n,r,mod):
  x=1
  y=1
  for i in range(r):
    x=(x*(n-i)) % mod
    y=(y*(i+1)) % mod
  return (x * pow(y, mod - 2, mod)) % mod
if x*y%3!=0:
  print(0)
else:
  m=(2*x-y)/3
  n=(2*y-x)/3
  if m<0 or n<0:
    print(0)
  else:
    print(nCr_mod(int(m+n),int(n),mod))


Failing test case input:
123395 134890

Expected output:
905248722


Actual output:
0


Fixed submission (verdict: Accepted):
x,y=map(int,input().split())
mod=10**9+7
def nCr_mod(n,r,mod):
  x=1
  y=1
  for i in range(r):
    x=(x*(n-i)) % mod
    y=(y*(i+1)) % mod
  return (x * pow(y, mod - 2, mod)) % mod
if (x+y)%3!=0:
  print(0)
else:
  m=int((2*x-y)/3)
  n=int(x-2*m)
  if m<0 or n<0:
    print(0)
  else:
    print(nCr_mod(m+n,n,mod))

Problem: p02862
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
m = 10 ** 9 + 7
def cmb(x,y):
    r=1
    for i in range(1,y+1):
        r=(r*(x-i+1)*pow(i,m-2,m))%m
    return r

x, y = map(int, input().split())
if (2 * x - y) % 3 == 0 and (2 * y - x) % 3 == 0:
    print(cmb(int((x + y) / 3), int((2 * y - x) / 3)))

Failing test case input:
1 1107

Expected output:
0


Actual output:

Fixed submission (verdict: Accepted):
m = 10 ** 9 + 7
def cmb(x,y):
    r = 1
    for i in range(1, y + 1):
        r = (r * (x - i + 1) * pow(i, m-2, m)) % m
    return r

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

a = (2 * x - y) / 3
b = (2 * y - x) / 3
if (x + y) % 3 == 0 and a >= 0 and b >= 0:
    print(cmb(int((x + y) / 3), int(a)))
else:
    print(0)

Problem: p02862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
x, y = map(int, input().split())


def comb(n, k, mod, frac):
    a=frac[n]
    b=frac[k]
    c=frac[n-k]
    return (a * pow(b, mod-2, mod) * pow(c, mod-2, mod)) % mod

if 2*y-x <= 0 or 2*x-y <= 0:
  print(0)
elif (2*y-x)%3 != 0 or (2*x -y) % 3 != 0:
  print(0)
else:
  a = (2*y-x)
  b = (2*x-y)
  mod = 10**9 + 7
  frac = [1]
  for i in range(a+b):
      frac.append(frac[i]*(i+1)%mod)
  print(comb(a + b, a, mod, frac))

Failing test case input:
728601 999999

Expected output:
197453690


Actual output:
195563563


Fixed submission (verdict: Accepted):
x, y = map(int, input().split())


def comb(n, k, mod, frac):
    a=frac[n]
    b=frac[k]
    c=frac[n-k]
    return (a * pow(b, mod-2, mod) * pow(c, mod-2, mod)) % mod

if 2*y-x < 0 or 2*x-y < 0:
  print(0)
elif (2*y-x)%3 != 0 or (2*x -y) % 3 != 0:
  print(0)
else:
  a = int((2*y-x)
  b = int((2*x-y)
  mod = 10**9 + 7
  frac = [1]
  for i in range(a+b):
      frac.append(frac[i]*(i+1)%mod)
  print(comb(a + b, a, mod, frac))
Problem: p02862
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from functools import reduce
from operator import mul
MOD = 10 ** 9 + 7


def combination(n, r, mod=None):
    r = min(n - r, r)
    if r == 0:
        return 1
    elif n < r:
        return 0
    if mod is None:
        over = reduce(mul, range(n, n - r, -1))
        under = reduce(mul, range(1, r + 1))
        return over 
    else:
        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


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

if not ((X + Y) / 3).is_integer():
    print(0)
    exit(0)


a = (X + Y) 
b = Y - a

ans = combination(a, b, mod=MOD)
print(ans)

Failing test case input:
444316 841058

Expected output:
356692425


Actual output:
1


Fixed submission (verdict: Accepted):
from functools import reduce
from operator import mul
MOD = 10 ** 9 + 7

def combination(n, r, mod=None):
    r = min(n - r, r)
    if r == 0:
        return 1
    elif n < r:
        return 0
    if mod is None:
        over = reduce(mul, range(n, n - r, -1))
        under = reduce(mul, range(1, r + 1))
        return over 
    else:
        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


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





a = (2 * X - Y) / 3
b = (2 * Y - X) / 3

if a < 0 or b < 0 or not a.is_integer() or not b.is_integer():
    print(0)
    exit(0)

ans = combination(int(a + b), int(a), mod=MOD)
print(ans)

Problem: p02862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import itertools
X, Y=map(int, input().split())  
MOD = 10**9 + 7
if (X+Y)%3 != 0:
    print(0)
else:

    n = int((2*Y-X)/3)
    m = int((2*X-Y)/3)

    

    if n<0 or m<0:
        print(0)
    else:
        ret = 1
        for i in range(m):
            ret = ret * ((X+Y) - i) % MOD * pow(i + 1, MOD-2, MOD) % MOD
        print(ret)

Failing test case input:
416331 672735

Expected output:
823076059


Actual output:
408132758


Fixed submission (verdict: Accepted):
import itertools
X, Y=map(int, input().split())  
MOD = 10**9 + 7
if (X+Y)%3 != 0:
    print(0)
else:

    n = int((2*Y-X)/3)
    m = int((2*X-Y)/3)

    

    if n<0 or m<0:
        print(0)
    else:
        ret = 1
        for i in range(m):
            ret = ret * ((X+Y)
        print(ret)

Problem: p02862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
M=10**9+7
x,y=map(int,input().split())
d,m=divmod(x+y,3)
if m: print(0); exit()
x-=d
y-=d
s=t=1
for i in range(min(x,y)):
  s=s*(x+y-i)%M
  t=t*(i+1)%M
print(s*pow(t,M-2,M)%M)

Failing test case input:
278628 570840

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
M=10**9+7
x,y=map(int,input().split())
d,m=divmod(x+y,3)
if m or y>2*x or x>2*y: print(0); exit()
x-=d
y-=d
s=t=1
for i in range(min(x,y)):
  s=s*(x+y-i)%M
  t=t*(i+1)%M
print(s*pow(t,M-2,M)%M)
Problem: p02862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
x,y=map(int,input().split())
mod=10**9+7
def nCr_mod(n,r,mod):
  x=1
  y=1
  for i in range(r):
    x=(x*(n-i)) % mod
    y=(y*(i+1)) % mod
  return (x * pow(y, mod - 2, mod)) % mod
if x*y%3!=0:
  print(0)
else:
  m=(2*x-y)
  n=(2*y-x)
  if m<0 or n<0:
    print(0)
  else:
    print(nCr_mod(m+n,n,mod))


Failing test case input:
999999 999999

Expected output:
151840682

Actual output:
541097174


Fixed submission (verdict: Accepted):
x,y=map(int,input().split())
mod=10**9+7
def nCr_mod(n,r,mod):
  x=1
  y=1
  for i in range(r):
    x=(x*(n-i)) % mod
    y=(y*(i+1)) % mod
  return (x * pow(y, mod - 2, mod)) % mod
if (x+y)%3!=0:
  print(0)
else:
  m=int((2*x-y)/3)
  n=int(x-2*m)
  if m<0 or n<0:
    print(0)
  else:
    print(nCr_mod(m+n,n,mod))

Problem: p02862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
x,y=map(int,input().split())
mod=10**9+7
def nCr_mod(n,r,mod):
  x=1
  y=1
  for i in range(r):
    x=(x*(n-i)) % mod
    y=(y*(i+1)) % mod
  return (x * pow(y, mod - 2, mod)) % mod
m = (-x+2*y)
n = (2*x-y)
if (x*y)%3!=0 or m*n<0:
  print(0)
else:
  print(nCr_mod(m+n,n,mod))


Failing test case input:
1279413 999999

Expected output:
825914746


Actual output:
25233356


Fixed submission (verdict: Accepted):
x,y=map(int,input().split())
mod=10**9+7
def nCr_mod(n,r,mod):
  x=1
  y=1
  for i in range(r):
    x=(x*(n-i)) % mod
    y=(y*(i+1)) % mod
  return (x * pow(y, mod - 2, mod)) % mod
if (x+y)%3!=0:
  print(0)
else:
  m=int((2*x-y)/3)
  n=int(x-2*m)
  if m<0 or n<0:
    print(0)
  else:
    print(nCr_mod(m+n,n,mod))

Problem: p02862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
X, Y = map(int, input().split())

a, b = divmod(2*X-Y, 3)
c, d = divmod(2*Y-X, 3) 
if (not b == d == 0) or (2*a < c) or (2*c < a):
  print(0)
else:
  m, n = 1, 1
  mod = 10**9+7
  for i in range(1, min(a, c)+1):
    m = (m * (a+c-i+1)) % mod
    n = (n * i) % mod
  ans = (m * pow(n, mod-2, mod)) % mod
  print(ans)

Failing test case input:
416331 256674

Expected output:
825258565


Actual output:
0


Fixed submission (verdict: Accepted):
X, Y = map(int, input().split())

a, b = divmod(2*X-Y, 3)
c, d = divmod(2*Y-X, 3) 
if (not b == d == 0) or (2*X < Y) or (2*Y < X):
  print(0)
else:
  m, n = 1, 1
  mod = 10**9+7
  for i in range(1, min(a, c)+1):
    m = (m * (a+c-i+1)) % mod
    n = (n * i) % mod
  ans = (m * pow(n, mod-2, mod)) % mod
  print(ans)
Problem: p02862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math

def main():
    X,Y = map(int,input().split())
    MOD = 10**9+7
    K = (2*X-Y)/3
    L = (2*Y-X)/3
    if K == int(K) and L == int(L):
        A = int(K)+int(L)
        B = min(int(K),int(L))
        num = num_ = 1
        for i in range(1,B+1):
            num = num * (A+1-i) % MOD
            num_ = num_ * i % MOD
        ans = num * pow(num_,MOD-2,MOD) % MOD
        print(ans)

    else:
        print(0)

if __name__ == "__main__":
    main()

Failing test case input:
24 207936

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
import math

def main():
    X,Y = map(int,input().split())
    MOD = 10**9+7
    K = 2*X-Y
    L = 2*Y-X
    if K>=0 and L>=0 and (K+L)%3 == 0:
        A = K
        B = min(K
        num = num_ = 1
        for i in range(1,B+1):
            num = num * (A+1-i) % MOD
            num_ = num_ * i % MOD
        ans = num * pow(num_,MOD-2,MOD) % MOD
        print(ans)

    else:
        print(0)

if __name__ == "__main__":
    main()

Problem: p02862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
x,y=map(int,input().split())
mod=10**9+7
def nCr_mod(n,r,mod):
  x=1
  y=1
  for i in range(r):
    x=(x*(n-i)) % mod
    y=(y*(i+1)) % mod
  return (x * pow(y, mod - 2, mod)) % mod
if x*y%3!=0:
  print(0)
else:
  m=int((2*x-y)/3)
  n=int(x-2*m)
  if m<0 or n<0:
    print(0)
  else:
    print(nCr_mod(m+n,n,mod))


Failing test case input:
524173 402356

Expected output:
660181343


Actual output:
0


Fixed submission (verdict: Accepted):
x,y=map(int,input().split())
mod=10**9+7
def nCr_mod(n,r,mod):
  x=1
  y=1
  for i in range(r):
    x=(x*(n-i)) % mod
    y=(y*(i+1)) % mod
  return (x * pow(y, mod - 2, mod)) % mod
if (x+y)%3!=0:
  print(0)
else:
  m=int((2*x-y)/3)
  n=int(x-2*m)
  if m<0 or n<0:
    print(0)
  else:
    print(nCr_mod(m+n,n,mod))

Problem: p02862
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
MOD = 10 ** 9 + 7

x, y = map(int, input().split())
n = int((2 * x - y) / 3)
m = int(x - 2 * n)

def nCr(n, r, mod):
    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

if n > 0 and m > 0:
    print(nCr(n + m, n, MOD))
else:
    print(0)


Failing test case input:
246688 128826

Expected output:
0


Actual output:
55187137


Fixed submission (verdict: Accepted):
MOD = 10 ** 9 + 7

x, y = map(int, input().split())
n = int((2 * x - y) / 3)
m = int(x - 2 * n)

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

def nCr(n, r, mod):
    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

if n >= 0 and m >= 0:
    print(nCr(n + m, n, MOD))
else:
    print(0)
Problem: p02862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
x,y=map(int,input().split())
mod=10**9+7

def comb(n,k):
    if n<k:
        return 0
    if n-k<k:
        k=n-k
    comb=1
    for x in range(n-k+1,n+1):
        comb=(comb*x)%mod
    d=1
    for x in range(1,k+1):
        d =(d*x)%mod
    comb*=pow(d,mod-2,mod)
    return comb%mod

ans=0
if (x+y)%3==0:
    n=int(x/3+y/3)
    r=int(2*x/3-y/3)
    if n-r>=0 and r>=0:
        ans=comb(n,r)%mod
print(ans)

Failing test case input:
123395 134890

Expected output:
905248722


Actual output:
43810499


Fixed submission (verdict: Accepted):
x,y=map(int,input().split())
mod=10**9+7

def comb(n,k):
    if n<k:
        return 0
    if n-k<k:
        k=n-k
    comb=1
    for x in range(n-k+1,n+1):
        comb=(comb*x)%mod
    d=1
    for x in range(1,k+1):
        d =(d*x)%mod
    comb*=pow(d,mod-2,mod)
    return comb%mod

ans=0
if (x+y)%3==0:
    n=int((x+y)/3)
    r=int((2*x-y)/3)
    if n-r>=0 and r>=0:
        ans=comb(n,r)%mod
print(ans)

Problem: p02862
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
X, Y = map(int, input().split())

MOD = 1000000007
if (2*X-Y)%3!=0:
    print(0)
    sys.exit()

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

if A<0 or B<0:
    print(0)
    sys.exit()

ans = 1
inv = 1
for i in range(B):
    ans = ans * (A+B-i) %MOD
    inv = inv * (i+1) %MOD

ans = ans * pow(inv, MOD-2, MOD) %MOD
print(ans)


Failing test case input:
416331 770049

Expected output:
761225640


Actual output:
54668725


Fixed submission (verdict: Accepted):
import sys
X, Y = map(int, input().split())

MOD = 1000000007
if (2*X-Y)%3!=0:
    print(0)
    sys.exit()

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

if A<0 or B<0:
    print(0)
    sys.exit()

ans = 1
inv = 1
for i in range(B):
    ans = ans * (A+B-i) %MOD
    inv = inv * (i+1) %MOD

ans = ans * pow(inv, MOD-2, MOD) %MOD
print(ans)

Problem: p02862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b=map(int,input().split())
mod=10**9+7
def nCr_mod(n,r,mod):
  x=1
  y=1
  for i in range(r):
    x=(x*(n-i)) % mod
    y=(y*(i+1)) % mod
  return (x * pow(y, mod - 2, mod)) % mod
m = (-a+2*b)
n = (2*a-b)
if (a*b)%3!=0 or m*n<0:
  print(0)
else:
  print(nCr_mod(m+n,n,mod))


Failing test case input:
999999 999999

Expected output:
151840682

Actual output:
541097174


Fixed submission (verdict: Accepted):
x,y=map(int,input().split())
mod=10**9+7
def nCr_mod(n,r,mod):
  x=1
  y=1
  for i in range(r):
    x=(x*(n-i)) % mod
    y=(y*(i+1)) % mod
  return (x * pow(y, mod - 2, mod)) % mod
if (x+y)%3!=0:
  print(0)
else:
  m=int((2*x-y)/3)
  n=int(x-2*m)
  if m<0 or n<0:
    print(0)
  else:
    print(nCr_mod(m+n,n,mod))
Problem: p02862
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):

X,Y = map(int,input().split())
b = (2*X -Y) 
a = X - 2 * b
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


ans = combination(a+b,a)

print(ans)


Failing test case input:
741 352596

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):

X,Y = map(int,input().split())
b = (2*X -Y) / 3
if b != int(b):
    print(0)
    quit()
b = int(b)
a = X - 2 * b
if a < 0 or b < 0:
    print(0)
    quit()


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


ans = combination(a+b,a)

print(ans)

Problem: p02862
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
X, Y = map(int, input().split())
mod = 10**9+7

small = min(X, Y)

plus = X+Y

if not plus%3==0:
    print(0)
else:
    row = plus
    col = Y-row+1
    l, r = 1, 1
    for c in range(col):
        l = (l*(row-1-c))%mod
        r = r*(c+1)%mod
    print((l*pow(r, mod-2, mod))%mod)

Failing test case input:
999999 999999

Expected output:
151840682

Actual output:
1


Fixed submission (verdict: Accepted):
X, Y = map(int, input().split())
mod = 10**9+7

plus = X+Y

if not plus%3==0:
    print(0)
elif abs(X-Y)>plus
    print(0)
else:
    row = plus
    col = Y-row
    l, r = 1, 1
    for c in range(col):
        l = (l*(row-c))%mod
        r = r*(c+1)%mod
    print((l*pow(r, mod-2, mod))%mod)

Problem: p02862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b = map(int, input().split())

aa=int(0)
x=max([a, b])
y=min([a, b])

if (x+y)%3 ==0 and x < y*2:
    aa=int(1)

n=int((x+y)/3)
k=int((n-(x-y))/2)


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


print(comb(n,k))


Failing test case input:
1 1792

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):

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

aa=int(0)
x=max([a, b])
y=min([a, b])

if (x+y)%3 ==0 and x <= y*2:
    aa=int(1)

n=int((x+y)/3)
k=int((n-(x-y))/2)


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

if aa==1:
    print(comb(n,k))
else:
    print(aa)
Problem: p02862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
x,y=map(int,input().split())
mod=10**9+7
def nCr_mod(n,r,mod):
  x=1
  y=1
  for i in range(r):
    x=(x*(n-i)) % mod
    y=(y*(i+1)) % mod
  return (x * pow(y, mod - 2, mod)) % mod
if (x*y)%3!=0:
  print(0)
else:
  n=(2*x-y)
  m=(2*y-x)
  if m*n<0:
    print(0)
  else:
    print(nCr_mod(m+n,n,mod))


Failing test case input:
278628 251617

Expected output:
0


Actual output:
370952806


Fixed submission (verdict: Accepted):
x,y=map(int,input().split())
mod=10**9+7
def nCr_mod(n,r,mod):
  x=1
  y=1
  for i in range(r):
    x=(x*(n-i)) % mod
    y=(y*(i+1)) % mod
  return (x * pow(y, mod - 2, mod)) % mod
if (x+y)%3!=0:
  print(0)
else:
  m=int((2*x-y)/3)
  n=int(x-2*m)
  if m<0 or n<0:
    print(0)
  else:
    print(nCr_mod(m+n,n,mod))

Problem: p02862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

import sys
import math

MOD = 10**9+7  

def combi_count(n, r):
    x = 1
    y = 1
    for i in range(1, r+1):
        x = x * (n-i) % MOD
        y = y * i % MOD

    
    

    
    
    

    return x * pow(y, MOD-2, MOD) % MOD

def solve(X: int, Y: int):
    a = int((2*Y - X)/3)
    b = int((2*X - Y)/3)
    if ((2*Y - X)%3 != 0) and ((2*X - Y)%3 != 0):
        ans = 0
    else:
        ans = combi_count(a+b+1, min(a, b))
    print(ans)


def main():
    X, Y = map(int, input().split())
    solve(X, Y)

if __name__ == '__main__':
    main()


Failing test case input:
1 30845

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):

import sys
import math

MOD = 10**9+7  

def combi_count(n, r):
    x = 1
    y = 1
    for i in range(1, r+1):
        x = x * (n-i) % MOD
        y = y * i % MOD

    
    

    
    
    

    return x * pow(y, MOD-2, MOD) % MOD

def solve(X: int, Y: int):
    a = int((2*Y - X)/3)
    b = int((2*X - Y)/3)
    if ( ((2*Y - X)%3 != 0) and ((2*X - Y)%3 != 0) )  or ((a<0) or (b<0)):
        ans = 0
    else:
        ans = combi_count(a+b+1, min(a, b))
    print(ans)


def main():
    X, Y = map(int, input().split())
    solve(X, Y)

if __name__ == '__main__':
    main()

Problem: p02862
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
X, Y = map(int, input().split())

MOD = 1000000007
if (2*X-Y)%3!=0:
    print(0)
    sys.exit()

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

ans = 1
inv = 1
for i in range(B):
    ans = ans * (A+B-i) %MOD
    inv = inv * (i+1) %MOD

ans = ans * pow(inv, MOD-2, MOD) %MOD
print(ans)


Failing test case input:
416331 672735

Expected output:
823076059


Actual output:
965386478


Fixed submission (verdict: Accepted):
import sys
X, Y = map(int, input().split())

MOD = 1000000007
if (2*X-Y)%3!=0:
    print(0)
    sys.exit()

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

if A<0 or B<0:
    print(0)
    sys.exit()

ans = 1
inv = 1
for i in range(B):
    ans = ans * (A+B-i) %MOD
    inv = inv * (i+1) %MOD

ans = ans * pow(inv, MOD-2, MOD) %MOD
print(ans)
Problem: p02862
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
x,y = map(int,input().split())
s = (2 * y -x) / 3
t = (2 * x -y) / 3
if s.is_integer() and t.is_integer():
    def comb(n, r, mod=10 ** 9 + 7):
        a = 1
        b = 1
        r = min(r, n - r)
        for i in range(r):
            a = a * (n - i) % mod
            b = b * (i + 1) % mod
        return a * pow(b, mod - 2, mod) % mod
    s = int(s)
    t = int(t)
    print(comb(s + t, t, mod=10 ** 9 + 7))
else:
    print(0)

Failing test case input:
219 384429

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
x,y = map(int,input().split())
s = (2 * y -x) / 3
t = (2 * x -y) / 3
if s.is_integer() and t.is_integer() and s >= 0 and t >= 0:
    def comb(n, r, mod=10 ** 9 + 7):
        a = 1
        b = 1
        r = min(r, n - r)
        for i in range(r):
            a = a * (n - i) % mod
            b = b * (i + 1) % mod
        return a * pow(b, mod - 2, mod) % mod
    s = int(s)
    t = int(t)
    print(comb(s + t, t, mod=10 ** 9 + 7))
else:
    print(0)

Problem: p02862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
X, Y = map(int, input().split())

a, b = divmod(2*X-Y, 3)
c, d = divmod(2*Y-X, 3) 
if not b==d==0:
  print(0)
else:
  m, n = 1, 1
  mod = 10**9+7
  for i in range(1, min(a, c)+1):
    m = (m * (a+c-i+1)) % mod
    n = (n * i) % mod
  ans = (m * pow(n, mod-2, mod)) % mod
  print(ans)

Failing test case input:
0 45

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
X, Y = map(int, input().split())

a, b = divmod(2*X-Y, 3)
c, d = divmod(2*Y-X, 3) 
if (not b == d == 0) or (2*X < Y) or (2*Y < X):
  print(0)
else:
  m, n = 1, 1
  mod = 10**9+7
  for i in range(1, min(a, c)+1):
    m = (m * (a+c-i+1)) % mod
    n = (n * i) % mod
  ans = (m * pow(n, mod-2, mod)) % mod
  print(ans)

Problem: p02862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from itertools import permutations, combinations,combinations_with_replacement,product

x, y = map(int, input().split())
MOD = 1000000007

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

m = int((2 * y - x) / 3)
n = int((2 * x - y) / 3)

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

print(int(combination(m + n, n)) % MOD)


Failing test case input:
1 1931

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
from itertools import permutations, combinations,combinations_with_replacement,product

x, y = map(int, input().split())
MOD = 1000000007

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

m = int((2 * y - x) / 3)
n = int((2 * x - y) / 3)

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

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

print(int(combination(m + n, n)) % MOD)
Problem: p02862
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):

X,Y = map(int,input().split())
b = (2*X -Y) / 3
if b != int(b):
    print(0)
    quit()
b = int(b)
a = X - 2 * b



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


ans = combination(a+b,a)

print(ans)


Failing test case input:
1 30845

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):

X,Y = map(int,input().split())
b = (2*X -Y) / 3
if b != int(b):
    print(0)
    quit()
b = int(b)
a = X - 2 * b
if a < 0 or b < 0:
    print(0)
    quit()


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


ans = combination(a+b,a)

print(ans)

Problem: p02862
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
mod = 10 ** 9 + 7
def cmb(n, r, mod):
    r = min(r, n-r)
    numer = denom = 1

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

x, y = map(int, input().split())
if (x + y) % 3 == 0 and (2 * y - x) % 3 == 0:
    print(cmb(int((x + y) / 3), int((2 * y - x) / 3), mod))
else:
    print(0)

Failing test case input:
1 25631

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
m = 10 ** 9 + 7
def cmb(x,y):
    r = 1
    for i in range(1, y + 1):
        r = (r * (x - i + 1) * pow(i, m-2, m)) % m
    return r

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

a = (2 * x - y) / 3
b = (2 * y - x) / 3
if (x + y) % 3 == 0 and a >= 0 and b >= 0:
    print(cmb(int((x + y) / 3), int(a)))
else:
    print(0)

Problem: p02862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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

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

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

x,xm = divmod(X*2-Y, 3)
y,ym = divmod(-X+Y*2, 3)
if (xm == 0) & (ym==0):
    print(combination(x+y, x, mod))
else:
    print(0)



Failing test case input:
278628 570840

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
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

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

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

x,xm = divmod(X*2-Y, 3)
y,ym = divmod(-X+Y*2, 3)
if (xm == 0) & (ym==0)& (x>=0) & (y>=0):
    print(combination(x+y, x, mod))
else:
    print(0)
Problem: p02862
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
MOD = 10 ** 9 + 7

x, y = map(int, input().split())
n = int((2 * x - y) / 3)
m = int(x - 2 * n)

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

def nCr(n, r, mod):
    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(n, m)
if n >= 0 and m >= 0:
    print(nCr(n + m, n, MOD))
else:
    print(0)


Failing test case input:
148134 75438

Expected output:
292408683


Actual output:
73610 914
292408683


Fixed submission (verdict: Accepted):
MOD = 10 ** 9 + 7

x, y = map(int, input().split())
n = int((2 * x - y) / 3)
m = int(x - 2 * n)

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

def nCr(n, r, mod):
    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

if n >= 0 and m >= 0:
    print(nCr(n + m, n, MOD))
else:
    print(0)

Problem: p02862
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
X, Y = map(int, input().split())

MOD = 1000000007
if (2*X-Y)%3!=0 or (2*X-Y)<0:
    print(0)
    sys.exit()

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

ans = 1
inv = 1
for i in range(B):
    ans = ans * (A+B-i) %MOD
    inv = inv * (i+1) %MOD

ans = ans * pow(inv, MOD-2, MOD) %MOD
print(ans)


Failing test case input:
502635 840600

Expected output:
416438521


Actual output:
259903496


Fixed submission (verdict: Accepted):
import sys
X, Y = map(int, input().split())

MOD = 1000000007
if (2*X-Y)%3!=0:
    print(0)
    sys.exit()

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

if A<0 or B<0:
    print(0)
    sys.exit()

ans = 1
inv = 1
for i in range(B):
    ans = ans * (A+B-i) %MOD
    inv = inv * (i+1) %MOD

ans = ans * pow(inv, MOD-2, MOD) %MOD
print(ans)

Problem: p02862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
x,y=map(int,input().split())
mod=10**9+7
def nCr_mod(n,r,mod):
  x=1
  y=1
  for i in range(r):
    x=(x*(n-i)) % mod
    y=(y*(i+1)) % mod
  return (x * pow(y, mod - 2, mod)) % mod
if (x*y)%3!=0:
  print(0)
else:
  m=(2*x-y)
  n=(2*y-x)
  if m<0 or n<0:
    print(0)
  else:
    print(nCr_mod(m+n,m,mod))


Failing test case input:
593126 1184107

Expected output:
321508604


Actual output:
0


Fixed submission (verdict: Accepted):
x,y=map(int,input().split())
mod=10**9+7
def nCr_mod(n,r,mod):
  x=1
  y=1
  for i in range(r):
    x=(x*(n-i)) % mod
    y=(y*(i+1)) % mod
  return (x * pow(y, mod - 2, mod)) % mod
if (x+y)%3!=0:
  print(0)
else:
  m=int((2*x-y)/3)
  n=int(x-2*m)
  if m<0 or n<0:
    print(0)
  else:
    print(nCr_mod(m+n,n,mod))
Problem: p02862
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
MOD = 10 ** 9 + 7
 
x, y = map(int, input().split())
n = int((2 * x - y) / 3)
m = int(x - 2 * n)

def nCr(n, r, mod):
    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 + m, n, MOD))

Failing test case input:
324 384429

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
MOD = 10 ** 9 + 7

x, y = map(int, input().split())
n = int((2 * x - y) / 3)
m = int(x - 2 * n)

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

def nCr(n, r, mod):
    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

if n >= 0 and m >= 0:
    print(nCr(n + m, n, MOD))
else:
    print(0)

Problem: p02862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
X, Y = map(int, input().split())
n, mod = divmod(X + Y, 3)


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


if mod != 0:
    print(0)
else:
    r = Y - n
    print(combination(n, r))

Failing test case input:
2659 318152

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
X, Y = map(int, input().split())
n, mod = divmod(X + Y, 3)


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


if mod != 0 or not (X <= 2 * Y and Y <= 2 * X):
    print(0)
else:
    r = Y - n
    print(combination(n, r))

Problem: p02862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
X, Y = map(int,input().split())

if (2*X-Y)/3 % 3 != 0 or (2*Y-X)/3 % 3 != 0:
    print(0)
    exit()

n = int((2*Y-X)/3)
m = int((2*X-Y)/3)

mod = 10**9+7


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

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

Failing test case input:
165 234

Expected output:
304315521


Actual output:
0


Fixed submission (verdict: Accepted):
X, Y = map(int,input().split())

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

n = int((2*Y-X)/3)
m = int((2*X-Y)/3)

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

mod = 10**9+7


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

print(comb(n+m, n, mod))
Problem: p02862
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
mod = 10**9+7

def fact(n):
    ans = 1
    for i in range(2,n+1):
        ans *= i
        ans %= mod
    return ans
    
X,Y = list(map(int,input().split()))







a = (2*Y-X)/3
b = (2*X-Y)/3 

if not a.is_integer() or not b.is_integer():
    print(0)
    exit(0)


print(fact(int(a+b)) * pow(fact(int(a)),mod-2,mod) * pow(fact(int(b)),mod-2,mod) % mod)

Failing test case input:
24 207936

Expected output:
0


Actual output:
978888521


Fixed submission (verdict: Accepted):
mod = 10**9+7

def fact(n):
    ans = 1
    for i in range(2,n+1):
        ans *= i
        ans %= mod
    return ans
    
X,Y = list(map(int,input().split()))







a = (2*Y-X)/3
b = (2*X-Y)/3 

if (X+Y)%3 != 0 or a<0 or b<0:
    print(0)
    exit(0)


print(fact(int(a+b)) * pow(fact(int(a)),mod-2,mod) * pow(fact(int(b)),mod-2,mod) % mod)

Problem: p02862
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
X, Y = map(int, input().split())

A = (2*Y - X)/3
B = (2*X - Y)/3
if X % 3 != 0 or Y % 3 != 0:
    ans = 0
    print(ans)
else:
    A = int(A)
    B = int(B)
    p = 10**9 + 7
    def comb(n, r, p):
        num1, num2 = 1, 1
        for i in range(r):
            num1 *= n-i
            num2 *= i+1
            num1 %= p
            num2 %= p
        return int(num1 * pow(num2, p-2, p))
    ans = comb(A+B, A, p)
    print(ans % p)


Failing test case input:
123395 134890

Expected output:
905248722


Actual output:
0


Fixed submission (verdict: Accepted):
X, Y = map(int, input().split())

A = (2*Y - X)/3
B = (2*X - Y)/3
if (2*Y - X) % 3 != 0 or (2*X - Y) % 3 != 0 or A < 0 or B < 0:
    ans = 0
    print(ans)
else:
    A = int(A)
    B = int(B)
    p = 10**9 + 7
    def comb(n, r, p):
        num1, num2 = 1, 1
        for i in range(r):
            num1 *= n-i
            num2 *= i+1
            num1 %= p
            num2 %= p
        return int(num1 * pow(num2, p-2, p))
    ans = comb(A+B, A, p)
    print(ans % p)

Problem: p02862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
x,y=map(int,input().split())
mod=10**9+7
def nCr_mod(n,r,mod):
  x=1
  y=1
  for i in range(r):
    x=(x*(n-i)) % mod
    y=(y*(i+1)) % mod
  return (x * pow(y, mod - 2, mod)) % mod
if x*y%3!=0:
  print(0)
else:
  m=(2*x-y)
  n=x-2*m
  if m<0 or n<0:
    print(0)
  else:
    print(nCr_mod(m+n,n,mod))


Failing test case input:
524173 402356

Expected output:
660181343


Actual output:
0


Fixed submission (verdict: Accepted):
x,y=map(int,input().split())
mod=10**9+7
def nCr_mod(n,r,mod):
  x=1
  y=1
  for i in range(r):
    x=(x*(n-i)) % mod
    y=(y*(i+1)) % mod
  return (x * pow(y, mod - 2, mod)) % mod
if (x+y)%3!=0:
  print(0)
else:
  m=int((2*x-y)/3)
  n=int(x-2*m)
  if m<0 or n<0:
    print(0)
  else:
    print(nCr_mod(m+n,n,mod))
Problem: p02862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
x,y=map(int,input().split())
mod=10**9+7

def comb(n,k):
    if n<k:
        return 0
    if n-k<k:
        k=n-k
    comb=1
    for x in range(n-k+1,n+1):
        comb=(comb*x)%mod
    d=1
    for x in range(1,k+1):
        d =(d*x)%mod
    comb*=pow(d,mod-2,mod)
    return comb%mod

if (x+y)%3==0:
    n=int(x/3+y/3)
    r=int(2*x/3-y/3)
    if n-r>=0 and r>=0:
        print(comb(n,r)%mod)
    else:
        print(0)
else:
    print(0)

Failing test case input:
123395 134890

Expected output:
905248722


Actual output:
43810499


Fixed submission (verdict: Accepted):
x,y=map(int,input().split())
mod=10**9+7

def comb(n,k):
    if n<k:
        return 0
    if n-k<k:
        k=n-k
    comb=1
    for x in range(n-k+1,n+1):
        comb=(comb*x)%mod
    d=1
    for x in range(1,k+1):
        d =(d*x)%mod
    comb*=pow(d,mod-2,mod)
    return comb%mod

ans=0
if (x+y)%3==0:
    n=int((x+y)/3)
    r=int((2*x-y)/3)
    if n-r>=0 and r>=0:
        ans=comb(n,r)%mod
print(ans)

Problem: p02862
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def nCr(n, r):
    num, den = 1, 1
    for i in range(n, n-r, -1):
        num = num * i % M       
    for i in range(1, r+1):
        den = den * i % M       
    den_inv = pow(den, -1, M)   
    return num * den_inv % M

def is_comb():
    a = 1/3 * (2*X - Y)
    b = 1/3 * (-X + 2*Y)
    if a.is_integer() and b.is_integer():
        return int(a), int(b)
    return 0, 0

M = 10**9 + 7
X, Y  = map(int, input().split())
a, b = is_comb()
if a==b==0:
    print(0)
else:
    n, r  = a+b, a
    print(nCr(n, r))


Failing test case input:
0 195945

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
def nCr(n, r):
    num, den = 1, 1
    for i in range(n, n-r, -1):
        num = num * i % M       
    for i in range(1, r+1):
        den = den * i % M       
    den_inv = pow(den, -1, M)   
    return num * den_inv % M

def is_comb():
    a = 1/3 * (2*X - Y)
    b = 1/3 * (-X + 2*Y)
    if a>=0 and b >= 0 and a.is_integer() and b.is_integer():
        return int(a), int(b)
    return 0, 0

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

a, b = is_comb()   
if a==b==0:
    print(0)
else:
    n, r  = a+b, a
    print(nCr(n, r))
Problem: p02862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
X, Y = map(int, input().split())
mod = pow(10, 9) + 7

m = (2*Y - X)/3
n = (2*X - Y)/3

if m.is_integer() == False or n.is_integer() == False:
  print(0)
  exit()
if m < 0 or n < 0:
  print(0)
  exit()
if n == 0 or m == 0:
  print(1)
  exit()

def comb(n, k):
  if k > n - k:
    comb(n, n - k)
    return
  mul, div = 1, 1
  for i in range(k):
    mul = mul * (n - i) % mod
    div = div * (k - i) % mod
  return mul * pow(div, mod-2, mod) % mod

ans = comb(int(n+m), int(n))
print(ans)

Failing test case input:
792369 652215

Expected output:
207959518


Actual output:
None


Fixed submission (verdict: Accepted):
X, Y = map(int, input().split())
mod = pow(10, 9) + 7

m = (2*Y - X)/3
n = (2*X - Y)/3

if m.is_integer() == False or n.is_integer() == False:
  print(0)
  exit()
if m < 0 or n < 0:
  print(0)
  exit()

def comb(n, k):
  if k > n - k:
    return comb(n, n - k)
  mul, div = 1, 1
  for i in range(k):
    mul = mul * (n - i) % mod
    div = div * (k - i) % mod
  return mul * pow(div, mod-2, mod) % mod

ans = comb(int(n+m), int(n))
print(ans)

Problem: p02862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
X,Y = map(int,input().split())
mod = pow(10,9)+7
if X>Y:X,Y = Y,X
n,m = -1,-1
for i in range(X):
    if (X-i) == 2*(Y-2*i):
        n,m = i,Y-2*i
        break
if n==-1:print(n,m)
else:
    if n>m:n,m = m,n
    a,b,m=1,1,n+m
    for i in range(1,n+1):
        a=(a*m)%mod
        b=(b*i)%mod
        m-=1
    b = pow(b,mod-2,mod)
    print((a*b)%mod)

Failing test case input:
741 352596

Expected output:
0


Actual output:
-1 -1


Fixed submission (verdict: Accepted):
X,Y = map(int,input().split())
mod = pow(10,9)+7
n,m = -1,-1
for i in range(X+1):
    if (X-i)==2*(Y-2*i):
        n,m = i,Y-2*i
if n==-1:print(0)
else:
    a,b,m = 1,1,n+m
    for i in range(1,n+1):
        a=(a*m)%mod
        b=(b*i)%mod
        m-=1
    b = pow(b,mod-2,mod)
    print((a*b)%mod)

Problem: p02862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def mod_comb(n, r, m):
  n = n+1
  r = min(r, n-r)
  numer = 1
  denom = 1
  for i in range(1, r+1):
    numer = (numer * (n - i)) % m
    denom = (denom * i) % m
  output = numer * pow(denom, m-2, m) % m
  return output

x, y = map(int, input().split())
c_up = (2*y-x)/3
c_do = (2*x-y)/3
if c_up.is_integer() and c_do.is_integer():
  c_up = int(c_up)
  c_do = int(c_do)
  result = mod_comb((c_up+c_do), c_up, 7+10**9)
else:
  result = 0
print(result)


Failing test case input:
502635 840600

Expected output:
416438521


Actual output:
553149956


Fixed submission (verdict: Accepted):
def mod_comb(n, r, m):
  nn = n+1
  r = min(r, n-r)
  numer = 1
  denom = 1
  for i in range(1, r+1):
    numer = (numer * (nn - i)) % m
    denom = (denom * i) % m
  output = numer * pow(denom, m-2, m) % m
  return output

x, y = map(int, input().split())
if not (x <= 2*y and y <= 2*x):
  result = 0
else:
  c_up = (2*y-x)/3
  c_do = (2*x-y)/3
  if c_up.is_integer() and c_do.is_integer():
    c_up = int(c_up)
    c_do = int(c_do)
    result = mod_comb((c_up+c_do), c_up, 7+10**9)
  else:
    result = 0
print(result)
Problem: p02862
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import math
mod=10**9+7
def mul(a, b):
    return ((a % mod) * (b % mod)) % mod
def div(a, b):
    return mul(a, pow(b, mod-2,mod))
x,y=map(int,input().split())
x,y=min(x,y),max(x,y)
s=y-x
if (x+y)%3!=0:
  print(0)
else:
  a=x
  b=x
  A=1
  B=1
  C=1
  for i in range(1,a+b+1):
    A*=i
    A%=mod
  for i in range(1,a+1):
    B*=i
    B%=mod
  for i in range(1,b+1):
    C*=i
    C%=mod
  print(div(A,mul(B,C)))

Failing test case input:
0 277998

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
import math
mod=10**9+7
def mul(a, b):
    return ((a % mod) * (b % mod)) % mod
def div(a, b):
    return mul(a, pow(b, mod-2,mod))
x,y=map(int,input().split())
x,y=min(x,y),max(x,y)
s=y-x
if (x-s)<0 or 3*((x-s)
  print(0)
else:
  a=(x-s)
  b=(y-2*s)
  A=1
  B=1
  C=1
  for i in range(1,a+b+1):
    A*=i
    A%=mod
  for i in range(1,a+1):
    B*=i
    B%=mod
  for i in range(1,b+1):
    C*=i
    C%=mod
  print(div(A,mul(B,C)))

Problem: p02862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
X, Y = map(int, input().split())
mod = pow(10, 9) + 7

m = (2*Y - X)/3
n = (2*X - Y)/3

if m.is_integer() == False or n.is_integer() == False:
  print(0)
  exit()
if m < 0 or n < 0:
  print(0)
  exit()

def comb(n, k):
  if k > n - k:
    comb(n, n - k)
    return
  mul, div = 1, 1
  for i in range(k):
    mul = mul * (n - i) % mod
    div = div * (k - i) % mod
  return mul * pow(div, mod-2, mod) % mod

ans = comb(int(n+m), int(n))
print(ans)

Failing test case input:
533212 442868

Expected output:
19537917


Actual output:
None


Fixed submission (verdict: Accepted):
X, Y = map(int, input().split())
mod = pow(10, 9) + 7

m = (2*Y - X)/3
n = (2*X - Y)/3

if m.is_integer() == False or n.is_integer() == False:
  print(0)
  exit()
if m < 0 or n < 0:
  print(0)
  exit()

def comb(n, k):
  if k > n - k:
    return comb(n, n - k)
  mul, div = 1, 1
  for i in range(k):
    mul = mul * (n - i) % mod
    div = div * (k - i) % mod
  return mul * pow(div, mod-2, mod) % mod

ans = comb(int(n+m), int(n))
print(ans)

Problem: p02862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
X, Y = map(int, input().split())

a, b = divmod(2*X-Y, 3)
c, d = divmod(2*Y-X, 3) 
if (not b == d == 0) or (2*a < b) or (2*b < a):
  print(0)
else:
  m, n = 1, 1
  mod = 10**9+7
  for i in range(1, min(a, c)+1):
    m = (m * (a+c-i+1)) % mod
    n = (n * i) % mod
  ans = (m * pow(n, mod-2, mod)) % mod
  print(ans)

Failing test case input:
416331 770049

Expected output:
761225640


Actual output:
0


Fixed submission (verdict: Accepted):
X, Y = map(int, input().split())

a, b = divmod(2*X-Y, 3)
c, d = divmod(2*Y-X, 3) 
if (not b == d == 0) or (2*X < Y) or (2*Y < X):
  print(0)
else:
  m, n = 1, 1
  mod = 10**9+7
  for i in range(1, min(a, c)+1):
    m = (m * (a+c-i+1)) % mod
    n = (n * i) % mod
  ans = (m * pow(n, mod-2, mod)) % mod
  print(ans)
Problem: p02862
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
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

x,y=map(int,input().split())
if (2*x-y)%3==0 and (2*y-x)%3==0:
  l=int((2*x-y)/3)
  k=int((2*y-x)/3)
  ans=c_mod(l+k,k)

else:
  ans=0
print(ans)


Failing test case input:
0 45

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
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

x,y=map(int,input().split())
if (2*x-y)%3==0 and (2*y-x)%3==0 and (2*x-y)>=0 and (2*y-x)>=0 :
  l=int((2*x-y)/3)
  k=int((2*y-x)/3)
  ans=c_mod(l+k,k)

else:
  ans=0
print(ans)

Problem: p02862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

import sys
X, Y = map(int, input().split())

mod = 10 ** 9 + 7

a = (2 * Y - X) / 3
b = (2 * X - Y) / 3
if a < 0 or b < 0 or a < 1 and b < 1:
    print(0)
    sys.exit()

a = int(a)
b = int(b)
N = a + b
f = [1]
for i in range(1,a+b+1):
    f.append((f[-1] * i) % mod)
ans = f[a+b] * (pow(f[a], mod-2, mod) * pow(f[b], mod-2, mod) % mod) % mod
print(ans)

Failing test case input:
278628 251617

Expected output:
0


Actual output:
613462848


Fixed submission (verdict: Accepted):

import sys
X, Y = map(int, input().split())

mod = 10 ** 9 + 7

a = (2 * Y - X) / 3
b = (2 * X - Y) / 3
if a < 0 or b < 0 or (X + Y) % 3 != 0:
    print(0)
    sys.exit()

a = int(a)
b = int(b)
N = a + b
f = [1]
for i in range(1,a+b+1):
    f.append((f[-1] * i) % mod)
ans = f[a+b] * (pow(f[a], mod-2, mod) * pow(f[b], mod-2, mod) % mod) % mod
print(ans)

Problem: p02862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b=map(int,input().split())
aa=a
bb=a
x=0
y=0
while aa>0 and bb>0:
	if aa>bb:
		aa-=1
		x+=1
	else:
		bb-=1
		y+=1
	aa-=1
	bb-=1
if aa!=0 or bb!=0:
	print(0)
	exit()
mod=10**9+7
fac=[1]
for i in range(max(a,b)):
	fac.append(fac[i]*(i+1)%mod)
x+=y
r=pow(fac[y]*fac[x-y]%mod,mod-2,mod)
print(fac[x]*r%mod)


Failing test case input:
792369 652215

Expected output:
207959518


Actual output:
474326957


Fixed submission (verdict: Accepted):
a,b=map(int,input().split())
aa=a
bb=b
x=0
y=0
while aa>0 and bb>0:
	if aa>bb:
		aa-=1
		x+=1
	else:
		bb-=1
		y+=1
	aa-=1
	bb-=1
if aa!=0 or bb!=0:
	print(0)
	exit()
mod=10**9+7
fac=[1]
for i in range(max(a,b)):
	fac.append(fac[i]*(i+1)%mod)
x+=y
r=pow(fac[y]*fac[x-y]%mod,mod-2,mod)
print(fac[x]*r%mod)