Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
from math import factorial as fact

MOD = 10 ** 9 + 7


def inv(x):
    return pow(x, MOD - 2, MOD)


def comb(n, r):
    return (fact(n) * inv(fact(n - r)) * inv(fact(r))) % MOD


def main():
    X, Y = [int(x) for x in input().split()]

    y = (X - 2 * Y) // (-3)
    x = (X - y) // 2

    print(x, y)
    if X == x * 2 + y and Y == x + 2 * y:
        a = comb(x + y, x)
        print(a % MOD)
    else:
        print(0)









if __name__ == '__main__':
    main()



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

def modPow(a, x, p):
    res = 1
    while x > 0:
        if x % 2 != 0:
            res = res * a % p
        a = a * a % p
        x = x // 2
    return res

def modInverse(a, p):
    return modPow(a, p - 2, p)

def modBinomial(n, k, p):
    numerator = 1
    for i in range(k):
        numerator = (numerator * (n - i)) % p

    denominator = 1
    for i in range(1, k + 1):
        denominator = (denominator * i) % p

    return (numerator * modInverse(denominator, p)) % p


def main():
    X, Y = [int(x) for x in input().split()]

    MOD = 10 ** 9 + 7
    y = (X - 2 * Y) // (-3)
    x = (X - y) // 2

    if y < 0 or x < 0:
        print(0)
        exit()
    if X == x * 2 + y and Y == x + 2 * y:
        print(modBinomial(x + y, x, MOD))
    else:
        print(0)









if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
from math import factorial as fact

MOD = 10 ** 9 + 7


def inv(x):
    return pow(x, MOD - 2, MOD)


def comb(n, r):
    return (fact(n) * inv(fact(n - r)) * inv(fact(r))) % MOD




def main():
    X, Y = [int(x) for x in input().split()]

    y = (X - 2 * Y) // (-3)
    x = (X - y) // 2

    print(x, y)
    if X == x * 2 + y and Y == x + 2 * y:
        a = comb(x + y, x)
        print(a % MOD)
    else:
        print(0)









if __name__ == '__main__':
    main()



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

def modPow(a, x, p):
    res = 1
    while x > 0:
        if x % 2 != 0:
            res = res * a % p
        a = a * a % p
        x = x // 2
    return res

def modInverse(a, p):
    return modPow(a, p - 2, p)

def modBinomial(n, k, p):
    numerator = 1
    for i in range(k):
        numerator = (numerator * (n - i)) % p

    denominator = 1
    for i in range(1, k + 1):
        denominator = (denominator * i) % p

    return (numerator * modInverse(denominator, p)) % p


def main():
    X, Y = [int(x) for x in input().split()]

    MOD = 10 ** 9 + 7
    y = (X - 2 * Y) // (-3)
    x = (X - y) // 2

    if y < 0 or x < 0:
        print(0)
        exit()
    if X == x * 2 + y and Y == x + 2 * y:
        print(modBinomial(x + y, x, MOD))
    else:
        print(0)









if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline


def main():
    X, Y = [int(x) for x in input().split()]
    MOD = 10 ** 9 + 7


    dp = [[0 for i in range(X + 1)] for j in range(Y + 1)]
    dp[0][0] = 1

    for i in range(X + 1):
        for j in range(Y + 1):
            x = j - 1
            y = i - 2
            if x >= 0 and y >= 0:
                dp[j][i] += dp[x][y]
            x = j - 2
            y = i - 1
            if x >= 0 and y >= 0:
                dp[j][i] += dp[x][y]

    print(dp[Y][X] % MOD)







if __name__ == '__main__':
    main()



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

def modPow(a, x, p):
    res = 1
    while x > 0:
        if x % 2 != 0:
            res = res * a % p
        a = a * a % p
        x = x // 2
    return res

def modInverse(a, p):
    return modPow(a, p - 2, p)

def modBinomial(n, k, p):
    numerator = 1
    for i in range(k):
        numerator = (numerator * (n - i)) % p

    denominator = 1
    for i in range(1, k + 1):
        denominator = (denominator * i) % p

    return (numerator * modInverse(denominator, p)) % p


def main():
    X, Y = [int(x) for x in input().split()]

    MOD = 10 ** 9 + 7
    y = (X - 2 * Y) // (-3)
    x = (X - y) // 2

    if y < 0 or x < 0:
        print(0)
        exit()
    if X == x * 2 + y and Y == x + 2 * y:
        print(modBinomial(x + y, x, MOD))
    else:
        print(0)









if __name__ == '__main__':
    main()