Buggy python submission (verdict: Runtime Error):
def powermod(a, p, mod):
    if p == 0:
        return 1
    elif p % 2 == 0:
        return (powermod(a, p//2, mod) ** 2) % mod
    else:
        return ((powermod(a, (p-1)//2, mod) ** 2) % mod) * a % mod

def combinationmod(n,r):
    mod = 10 ** 9 + 7
    factorial = 1
    for i in range(n):
        factorial = (factorial * (i+1)) % mod
        if i+1 == r:
            fact_1 = factorial
        if i+1 == n-r:
            fact_2 = factorial
        if i+1 == n:
            fact_0 = factorial
    return fact_0 * powermod(fact_1,mod-2,mod) % mod * powermod(fact_2,mod-2,mod) % mod
    
X,Y = map(int,input().split())
if (X + Y) % 3 == 0 and X <= 2 * Y and 2 * X >= Y:
    turns = (X + Y) // 3
    print(combinationmod(turns, min(X,Y) - turns))
else:
    print(0)

Fixed submission:
def powermod(a, p, mod):
    if p == 0:
        return 1
    elif p % 2 == 0:
        return (powermod(a, p//2, mod) ** 2) % mod
    else:
        return ((powermod(a, (p-1)//2, mod) ** 2) % mod) * a % mod

def combinationmod(n,r):
    if r == 0 or n == r:
        return 1
    mod = 10 ** 9 + 7
    factorial = 1
    for i in range(n):
        factorial = (factorial * (i+1)) % mod
        if i+1 == r:
            fact_1 = factorial
        if i+1 == n-r:
            fact_2 = factorial
        if i+1 == n:
            fact_0 = factorial
    return fact_0 * powermod(fact_1,mod-2,mod) % mod * powermod(fact_2,mod-2,mod) % mod
    
X,Y = map(int,input().split())
if (X + Y) % 3 == 0 and X <= 2 * Y and 2 * X >= Y:
    turns = (X + Y) // 3
    print(combinationmod(turns, min(X,Y) - turns))
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
def powermod(a, p, mod):
    if p == 0:
        return 1
    elif p % 2 == 0:
        return (powermod(a, p//2, mod) ** 2) % mod
    else:
        return ((powermod(a, (p-1)//2, mod) ** 2) % mod) * a % mod

def combinationmod(n,r):
    mod = 10 ** 9 + 7
    factorial = 1
    for i in range(n):
        factorial = (factorial * (i+1)) % mod
        if i+1 == r:
            fact_1 = factorial
        if i+1 == n-r:
            fact_2 = factorial
        if i+1 == n:
            fact_0 = factorial
    return fact_0 * powermod(fact_1,mod-2,mod) % mod * powermod(fact_2,mod-2,mod) % mod
    
X,Y = map(int,input().split())
if (X + Y) % 3 == 0:
    turns = (X + Y) // 3
    print(combinationmod(turns, min(X,Y) - turns))
else:
    print(0)

Fixed submission:
def powermod(a, p, mod):
    if p == 0:
        return 1
    elif p % 2 == 0:
        return (powermod(a, p//2, mod) ** 2) % mod
    else:
        return ((powermod(a, (p-1)//2, mod) ** 2) % mod) * a % mod

def combinationmod(n,r):
    if r == 0 or n == r:
        return 1
    mod = 10 ** 9 + 7
    factorial = 1
    for i in range(n):
        factorial = (factorial * (i+1)) % mod
        if i+1 == r:
            fact_1 = factorial
        if i+1 == n-r:
            fact_2 = factorial
        if i+1 == n:
            fact_0 = factorial
    return fact_0 * powermod(fact_1,mod-2,mod) % mod * powermod(fact_2,mod-2,mod) % mod
    
X,Y = map(int,input().split())
if (X + Y) % 3 == 0 and X <= 2 * Y and 2 * X >= Y:
    turns = (X + Y) // 3
    print(combinationmod(turns, min(X,Y) - turns))
else:
    print(0)