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

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

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

c = 0
check = 0
X_k, Y_k = X, Y
while c < max([X, Y]):
    if (X_k / 2) == Y_k:
        check = 1
        c_r = Y_k
        break
    else:
        X_k -= 1
        Y_k -= 2
        c += 1

N = c + c_r
r = min([c, c_r])
fact = [1, 1]
inv = [0, 1] 
factinv = [1, 1]
p = 10 ** 9 + 7
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)
print(fact[N] * factinv[r] * factinv[N-r] % p)

Fixed submission:
import sys

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

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

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

N = int(n + m)
r = int(min([n, m]))
p = 10**9 + 7
fact = [1, 1]
inv = [0, 1]
factinv = [1, 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)

print(fact[N] * factinv[r] * factinv[N-r] % p)

Buggy python submission (verdict: Runtime Error):
X, Y = map(int, input().split())

c = 0
check = 0
X_k, Y_k = X, Y
while c < max([X, Y]):
    if (X_k / 2) == Y_k:
        check = 1
        c_r = Y_k
        break
    else:
        X_k -= 1
        Y_k -= 2
        c += 1

if ((X + Y) % 3) != 0:
    print(0)
else:
    N = c + c_r
    r = min([c, c_r])
    fact = [1, 1]
    inv = [0, 1] 
    factinv = [1, 1]
    p = 10 ** 9 + 7
    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)
    print(fact[N] * factinv[r] * factinv[N-r] % p)

Fixed submission:
import sys

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

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

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

N = int(n + m)
r = int(min([n, m]))
p = 10**9 + 7
fact = [1, 1]
inv = [0, 1]
factinv = [1, 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)

print(fact[N] * factinv[r] * factinv[N-r] % p)

Buggy python submission (verdict: Runtime Error):
X, Y = map(int, input().split())

c = 0
check = 0
X_k, Y_k = X, Y
while c < max([X, Y]):
    if (X_k / 2) == Y_k:
        check = 1
        c_r = Y_k
        break
    else:
        X_k -= 1
        Y_k -= 2
        c += 1

if check == 0:
    print(0)
else:
    N = c + c_r
    r = min([c, c_r])
    fact = [1, 1]
    inv = [0, 1] 
    factinv = [1, 1]
    p = 10 ** 9 + 7
    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)
    print(fact[N] * factinv[r] * factinv[N-r] % p)

Fixed submission:
import sys

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

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

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

N = int(n + m)
r = int(min([n, m]))
p = 10**9 + 7
fact = [1, 1]
inv = [0, 1]
factinv = [1, 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)

print(fact[N] * factinv[r] * factinv[N-r] % p)

Buggy python submission (verdict: Runtime Error):
X, Y = map(int, input().split())

c = 0
check = 0
X_k, Y_k = X, Y
while c < max([X, Y]):
    if (X_k / 2) == Y_k:
        check = 1
        c_r = Y_k
        break
    else:
        X_k -= 1
        Y_k -= 2
        c += 1

if check == 0:
    print(0)
else:
    N = c + c_r
    r = min([c, c_r])
    fact = [1, 1]
    inv = [0, 1] 
    factinv = [1, 1]
    p = 10 ** 9 + 7
    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)

print(fact[N] * factinv[r] * factinv[N-r] % p)

Fixed submission:
import sys

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

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

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

N = int(n + m)
r = int(min([n, m]))
p = 10**9 + 7
fact = [1, 1]
inv = [0, 1]
factinv = [1, 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)

print(fact[N] * factinv[r] * factinv[N-r] % p)