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

if (X*2 - Y)%3 != 0 or (Y*2 - X)%3 != 0:
    print(0)
    exit()
else:
    X, Y = (X*2 - Y)//3, (Y*2 - X)//3
    waru = 1000000007
    Xfac = math.factorial(X)
    Yfac = math.factorial(Y)
    XYfac = math.factorial(X+Y)
    p = (XYfac // Xfac // Yfac) % waru
    print(p)

Fixed submission:
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def combinations_mod(n, r, mod=1000000007):
    """Returns nCr in mod."""
    r = min(r, n - r)
    combs = 1
    for i, j in zip(range(n - r + 1, n + 1), range(1, r + 1)):
        combs *= (i % mod) * pow(j, mod - 2, mod)
        combs %= mod
    return combs


def main():
    X, Y = NMI()
    if (2*Y - X)%3 or (2*X - Y)%3:
        print(0)
        exit()

    A = (2*Y - X) // 3
    B = (2*X - Y) // 3
    if A < 0 or B < 0:
        print(0)
        exit()
    print(combinations_mod(A+B, A))


if __name__ == "__main__":
    main()

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

if (X*2 - Y)%3 != 0 or (Y*2 - X)%3 != 0:
    print(0)
    exit()
else:
    X, Y = (X*2 - Y)//3, (Y*2 - X)//3
    p = [[0 for i in range(Y+2)]for j in range(X+2)]
    waru = 1000000007

    p[0][0]=1
    for y in range(Y+1):
       for x in range(X+1):
            p[x+1][y] = (p[x+1][y] + p[x][y]) % waru
            p[x][y+1] = (p[x][y+1] + p[x][y]) % waru

    print(p[X][Y]%waru)

Fixed submission:
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def combinations_mod(n, r, mod=1000000007):
    """Returns nCr in mod."""
    r = min(r, n - r)
    combs = 1
    for i, j in zip(range(n - r + 1, n + 1), range(1, r + 1)):
        combs *= (i % mod) * pow(j, mod - 2, mod)
        combs %= mod
    return combs


def main():
    X, Y = NMI()
    if (2*Y - X)%3 or (2*X - Y)%3:
        print(0)
        exit()

    A = (2*Y - X) // 3
    B = (2*X - Y) // 3
    if A < 0 or B < 0:
        print(0)
        exit()
    print(combinations_mod(A+B, A))


if __name__ == "__main__":
    main()

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

if (X*2 - Y)%3 != 0 or (Y*2 - X)%3 != 0:
    print(0)
    exit()
else:
    X, Y = (X*2 - Y)//3, (Y*2 - X)//3
    p = [[0 for i in range(Y+2)]for j in range(X+2)]
    waru = 1000000007

    p[0][0]=1
    for y in range(Y+1):
        for x in range(X+1):
            p[x+1][y] += p[x][y] % waru
            p[x][y+1] += p[x][y] % waru

    print(p[X][Y]%waru)

Fixed submission:
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def combinations_mod(n, r, mod=1000000007):
    """Returns nCr in mod."""
    r = min(r, n - r)
    combs = 1
    for i, j in zip(range(n - r + 1, n + 1), range(1, r + 1)):
        combs *= (i % mod) * pow(j, mod - 2, mod)
        combs %= mod
    return combs


def main():
    X, Y = NMI()
    if (2*Y - X)%3 or (2*X - Y)%3:
        print(0)
        exit()

    A = (2*Y - X) // 3
    B = (2*X - Y) // 3
    if A < 0 or B < 0:
        print(0)
        exit()
    print(combinations_mod(A+B, A))


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
X, Y = map(int, input().split())

p = [[0 for i in range(Y+2)]for j in range(X+2)]
waru = 1000000007

p[0][0]=1

for y in range(Y):
    for x in range(X):
        p[x+1][y+2] += p[x][y] % waru
        p[x+2][y+1] += p[x][y] % waru

print(p[X][Y] % waru)

Fixed submission:
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def combinations_mod(n, r, mod=1000000007):
    """Returns nCr in mod."""
    r = min(r, n - r)
    combs = 1
    for i, j in zip(range(n - r + 1, n + 1), range(1, r + 1)):
        combs *= (i % mod) * pow(j, mod - 2, mod)
        combs %= mod
    return combs


def main():
    X, Y = NMI()
    if (2*Y - X)%3 or (2*X - Y)%3:
        print(0)
        exit()

    A = (2*Y - X) // 3
    B = (2*X - Y) // 3
    if A < 0 or B < 0:
        print(0)
        exit()
    print(combinations_mod(A+B, A))


if __name__ == "__main__":
    main()