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

MOD = 10 ** 9 + 7

xx = 2 * Y - X
if (xx % 3 == 0 and Y - 2 * xx // 3 >= 0):
    a = xx // 3
    b = Y - 2 * a

    f = 1
    factorials = [1]
    for m in range(1, a + b + 1):
        f *= m
        f %= MOD
        factorials.append(f)

    print (a, b)
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (a + b + 1)
    invs[a + b] = inv
    for m in range(a + b, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv


    print (factorials[-1] * invs[a] * invs[b] % MOD)

    # print (math.factorial(a + b) // math.factorial(a) // math.factorial(b) %  MOD)


else:
    print (0)


Fixed submission:
import math
X, Y = map(int, input().split())

MOD = 10 ** 9 + 7

xx = 2 * Y - X
if (xx >= 0 and xx % 3 == 0 and Y - 2 * xx // 3 >= 0):
    a = xx // 3
    b = Y - 2 * a

    f = 1
    factorials = [1]
    for m in range(1, a + b + 1):
        f *= m
        f %= MOD
        factorials.append(f)

    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (a + b + 1)
    invs[a + b] = inv
    for m in range(a + b, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv


    print (factorials[-1] * invs[a] * invs[b] % MOD)

    # print (math.factorial(a + b) // math.factorial(a) // math.factorial(b) %  MOD)


else:
    print (0)

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

MOD = 10 ** 9 + 7

xx = 2 * Y - X
if (xx % 3 == 0 and Y - 2 * xx // 3 >= 0):
    a = xx // 3
    b = Y - 2 * a

    f = 1
    factorials = [1]
    for m in range(1, a + b + 1):
        f *= m
        f %= MOD
        factorials.append(f)

    print (a, b, inv)
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (a + b + 1)
    invs[a + b] = inv
    for m in range(a + b, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv


    print (factorials[-1] * invs[a] * invs[b] % MOD)

    # print (math.factorial(a + b) // math.factorial(a) // math.factorial(b) %  MOD)


else:
    print (0)


Fixed submission:
import math
X, Y = map(int, input().split())

MOD = 10 ** 9 + 7

xx = 2 * Y - X
if (xx >= 0 and xx % 3 == 0 and Y - 2 * xx // 3 >= 0):
    a = xx // 3
    b = Y - 2 * a

    f = 1
    factorials = [1]
    for m in range(1, a + b + 1):
        f *= m
        f %= MOD
        factorials.append(f)

    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (a + b + 1)
    invs[a + b] = inv
    for m in range(a + b, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv


    print (factorials[-1] * invs[a] * invs[b] % MOD)

    # print (math.factorial(a + b) // math.factorial(a) // math.factorial(b) %  MOD)


else:
    print (0)

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

MOD = 10 ** 9 + 7

xx = 2 * Y - X
if (xx % 3 == 0 and Y - 2 * xx // 3 >= 0):
    a = xx // 3
    b = Y - 2 * a

    f = 1
    factorials = [1]
    for m in range(1, a + b + 1):
        f *= m
        f %= MOD
        factorials.append(f)

    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (a + b + 1)
    invs[a + b] = inv
    for m in range(a + b, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    print (a, b, inv)

    print (factorials[-1] * invs[a] * invs[b] % MOD)

    # print (math.factorial(a + b) // math.factorial(a) // math.factorial(b) %  MOD)


else:
    print (0)


Fixed submission:
import math
X, Y = map(int, input().split())

MOD = 10 ** 9 + 7

xx = 2 * Y - X
if (xx >= 0 and xx % 3 == 0 and Y - 2 * xx // 3 >= 0):
    a = xx // 3
    b = Y - 2 * a

    f = 1
    factorials = [1]
    for m in range(1, a + b + 1):
        f *= m
        f %= MOD
        factorials.append(f)

    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (a + b + 1)
    invs[a + b] = inv
    for m in range(a + b, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv


    print (factorials[-1] * invs[a] * invs[b] % MOD)

    # print (math.factorial(a + b) // math.factorial(a) // math.factorial(b) %  MOD)


else:
    print (0)

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

MOD = 10 ** 9 + 7

xx = 2 * Y - X
if (xx % 3 == 0 and Y - 2 * xx // 3 >= 0):
    a = xx // 3
    b = Y - 2 * a

    f = 1
    factorials = [1]
    for m in range(1, a + b + 1):
        f *= m
        f %= MOD
        factorials.append(f)

    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (a + b + 1)
    invs[a + b] = inv
    for m in range(a + b, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    # print (a, b, inv)

    print (factorials[-1] * invs[a] * invs[b] % MOD)

    # print (math.factorial(a + b) // math.factorial(a) // math.factorial(b) %  MOD)


else:
    print (0)


Fixed submission:
import math
X, Y = map(int, input().split())

MOD = 10 ** 9 + 7

xx = 2 * Y - X
if (xx >= 0 and xx % 3 == 0 and Y - 2 * xx // 3 >= 0):
    a = xx // 3
    b = Y - 2 * a

    f = 1
    factorials = [1]
    for m in range(1, a + b + 1):
        f *= m
        f %= MOD
        factorials.append(f)

    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (a + b + 1)
    invs[a + b] = inv
    for m in range(a + b, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv


    print (factorials[-1] * invs[a] * invs[b] % MOD)

    # print (math.factorial(a + b) // math.factorial(a) // math.factorial(b) %  MOD)


else:
    print (0)