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



if (x+y)%3!=0:
    print(0)
    exit()

if x==0 and y==0:
    print(0)
    exit()


n=(2*y-x)/3
m=(2*x-y)/3



if m<0 or n<0:
    print(0)
    exit()

if n==0 and m==1:
    print(1)
    exit()
if n==1 and m==0:
    print(1)
    exit()
    

#n+mCm
#(n+m)!/m!


def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
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(n+m,m)

print(cmb(n+m, m, 10**9+7))

Fixed submission:
import sys
sys.setrecursionlimit(2147483647)
INF=float('inf')
MOD=10**9+7
input=sys.stdin.readline

x,y=map(int,input().split())



if (x+y)%3!=0:
    print(0)
    exit()

if x==0 and y==0:
    print(0)
    exit()


n=(2*y-x)//3
m=(2*x-y)//3


if m<0 or n<0:
    print(0)
    exit()

if n==0 and m==1:
    print(1)
    exit()
if n==1 and m==0:
    print(1)
    exit()
    

#n+mCm
#(n+m)!/m!


def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

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(cmb(n+m, m, 10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
import fractions

def main():
  x,y=map(int,input().split())
  mod=10**9+7

  if (2*x-y)%3==0 and (2*y-x)%3==0 and (2*x-y)>=0 and (2*y-x)>=0:
    a=(2*x-y)//3
    b=(2*y-x)//3
    #print(a,b)

    result=0.0
    bunbo=1
    bunshiA=set([])

    for i in range(min(a,b)):
      bunbo=bunbo*(a+b-i)
      temp=min(a,b)-i
      bunshiA.add(temp)
      for item in list(bunshiA):
        if bunbo%item==0:
          bunbo=bunbo//item
          bunshiA.discard(item)

    bunshi=1
    for item in bunshiA:
      bunshi=bunshi*item
      
    result=bunbo//bunshi%mod
    print(int(result))

  else:
    print(0)

if __name__ == '__main__':
    main()


Fixed submission:
import sys
sys.setrecursionlimit(2147483647)
INF=float('inf')
MOD=10**9+7
input=sys.stdin.readline

x,y=map(int,input().split())



if (x+y)%3!=0:
    print(0)
    exit()

if x==0 and y==0:
    print(0)
    exit()


n=(2*y-x)//3
m=(2*x-y)//3


if m<0 or n<0:
    print(0)
    exit()

if n==0 and m==1:
    print(1)
    exit()
if n==1 and m==0:
    print(1)
    exit()
    

#n+mCm
#(n+m)!/m!


def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

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(cmb(n+m, m, 10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
import fractions

def main():
  x,y=map(int,input().split())
  mod=10**9+7

  if (2*x-y)%3==0 and (2*y-x)%3==0 and (2*x-y)>=0 and (2*y-x)>=0:
    a=(2*x-y)//3
    b=(2*y-x)//3
    #print(a,b)

    result=0.0
    bunbo=1
    bunshi=1

    for i in range(min(a,b)):
      bunbo=bunbo*(a+b-i)
      temp=1+i
      
      if bunbo%temp==0:
        bunbo=bunbo//temp
      else:
        bunshi=bunshi*(1+i)
      while bunbo%2==0 and bunshi%2==0:
        bunbo=bunbo//2
        bunshi=bunshi//2
      while bunbo%3==0 and bunshi%3==0:
        bunbo=bunbo//3
        bunshi=bunshi//3
      while bunbo%5==0 and bunshi%5==0:
        bunbo=bunbo//5
        bunshi=bunshi//5
      while bunbo%7==0 and bunshi%7==0:
        bunbo=bunbo//7
        bunshi=bunshi//7
      while bunbo%11==0 and bunshi%11==0:
        bunbo=bunbo//11
        bunshi=bunshi//11
      while bunbo%13==0 and bunshi%13==0:
        bunbo=bunbo//13
        bunshi=bunshi//13
      while bunbo%17==0 and bunshi%17==0:
        bunbo=bunbo//17
        bunshi=bunshi//17
      #print(bunbo,bunshi)
      
    result=bunbo//bunshi%mod
    print(int(result))

  else:
    print(0)

if __name__ == '__main__':
    main()


Fixed submission:
import sys
sys.setrecursionlimit(2147483647)
INF=float('inf')
MOD=10**9+7
input=sys.stdin.readline

x,y=map(int,input().split())



if (x+y)%3!=0:
    print(0)
    exit()

if x==0 and y==0:
    print(0)
    exit()


n=(2*y-x)//3
m=(2*x-y)//3


if m<0 or n<0:
    print(0)
    exit()

if n==0 and m==1:
    print(1)
    exit()
if n==1 and m==0:
    print(1)
    exit()
    

#n+mCm
#(n+m)!/m!


def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

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(cmb(n+m, m, 10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
import fractions

def main():
  x,y=map(int,input().split())
  mod=10**9+7

  if (2*x-y)%3==0 and (2*y-x)%3==0 and (2*x-y)>=0 and (2*y-x)>=0:
    a=(2*x-y)//3
    b=(2*y-x)//3
    #print(a,b)

    result=0.0
    bunbo=1
    bunshi=1

    for i in range(min(a,b)):
      bunbo=bunbo*(a+b-i)
      temp=1+i
      
      if bunbo%temp==0:
        bunbo=bunbo//temp
      else:
        bunshi=bunshi*(1+i)
      while bunbo%2==0 and bunshi%2==0:
        bunbo=bunbo//2
        bunshi=bunshi//2
      while bunbo%3==0 and bunshi%3==0:
        bunbo=bunbo//3
        bunshi=bunshi//3
      while bunbo%5==0 and bunshi%5==0:
        bunbo=bunbo//5
        bunshi=bunshi//5
      #print(bunbo,bunshi)
      f=fractions.gcd(bunbo,bunshi)
      bunbo=bunbo//f
      bunshi=bunshi//f
      
    result=bunbo//bunshi%mod
    print(int(result))

  else:
    print(0)

if __name__ == '__main__':
    main()


Fixed submission:
import sys
sys.setrecursionlimit(2147483647)
INF=float('inf')
MOD=10**9+7
input=sys.stdin.readline

x,y=map(int,input().split())



if (x+y)%3!=0:
    print(0)
    exit()

if x==0 and y==0:
    print(0)
    exit()


n=(2*y-x)//3
m=(2*x-y)//3


if m<0 or n<0:
    print(0)
    exit()

if n==0 and m==1:
    print(1)
    exit()
if n==1 and m==0:
    print(1)
    exit()
    

#n+mCm
#(n+m)!/m!


def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

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(cmb(n+m, m, 10**9+7))

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




mod=10**9+7

if (2*x-y)%3==0 and (2*y-x)%3==0:
  a=(2*x-y)/3
  b=(2*y-x)/3
  #print(a,b)

  result=0.0
  bunbo=1
  bunshi=1
  for i in range(int(a)):
    bunbo=bunbo*(a+b-i)
    bunshi=bunshi*(1+i)
    #print(bunbo,bunshi)
  result=bunbo/bunshi%mod
  print(int(result))
  

  
else:
  print(0)

Fixed submission:
import sys
sys.setrecursionlimit(2147483647)
INF=float('inf')
MOD=10**9+7
input=sys.stdin.readline

x,y=map(int,input().split())



if (x+y)%3!=0:
    print(0)
    exit()

if x==0 and y==0:
    print(0)
    exit()


n=(2*y-x)//3
m=(2*x-y)//3


if m<0 or n<0:
    print(0)
    exit()

if n==0 and m==1:
    print(1)
    exit()
if n==1 and m==0:
    print(1)
    exit()
    

#n+mCm
#(n+m)!/m!


def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

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(cmb(n+m, m, 10**9+7))