Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
import math
a, b = [int(x) for x in stdin.readline().rstrip().split()]
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
g = gcd(a,b)
h = []
answer = 0
for i in range(g):
    if g % (i+1) == 0:
        n = int(math.sqrt(i+1))
        t = 1
        for j in range(n):
            if j != 0:
                if (i+1) % (j+1) == 0:
                    t = 0
        if t == 1:
            answer += 1
print(answer)
            

Fixed submission:
from sys import stdin
import math
a, b = [int(x) for x in stdin.readline().rstrip().split()]
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct
g = gcd(a,b)
answer = factorize(g)
answer = list(set(answer))
print(len(answer) + 1)

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
import math
a, b = [int(x) for x in stdin.readline().rstrip().split()]
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
g = gcd(a,b)
h = []
answer = 0
for i in range(g):
    if g % (i+1) == 0:
        h.append(i+1)
for i in range(len(h)):
    if i == 0:
        answer += 1
    else:
        t = 1
        for j in range(i):
            if j != 0:
                if h[i] % h[j] == 0:
                    t = 0
        if t == 1:
            answer += 1
print(answer)
            

Fixed submission:
from sys import stdin
import math
a, b = [int(x) for x in stdin.readline().rstrip().split()]
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct
g = gcd(a,b)
answer = factorize(g)
answer = list(set(answer))
print(len(answer) + 1)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
ans=int
ans=n/m
print(int(ans)+1)


Fixed submission:
n,m=map(int,input().split())
ans=float
ans=n/m
if ans == 0:
    print(1)
elif ans == int(ans):
    print(int(ans))
else:
    print(int(ans)+1)
Buggy python submission (verdict: Runtime Error):
a = input()
print(a+a**2+a**3)


Fixed submission:
a = int(input())
print(a+a**2+a**3)
Buggy python submission (verdict: Runtime Error):
a = input()
b = input()
cnt = 0
for i in range(len(a)):
	if a[i] != b[i]:
    	cnt+=1
print(cnt)

Fixed submission:
a = input()
b = input()
cnt = 0
for i in range(len(a)):
    if a[i] != b[i]:
        cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
from math import gcd
A,B = map(int, input().split())
print(A * B // gcd(A,B))

Fixed submission:
def gcd(x,y):
    if x==0:
        return y
    elif y==0:
        return x
    
    if x<y:
        x,y = y,x
    return gcd(y, x%y)

A,B = map(int, input().split())
print( (A * B) // gcd(A,B))
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
ans = {i:0 for i in range(1,N+1)}
ans[1] = 10000000
route = {i:[] for i in range(1,N+1)}
for _ in range(M):
    a,b = map(int,input().split())
    route[a].append(b)
    route[b].append(a)
x = [1]
for _ in range(M):
    for i in x:
        tmp = []
        for j in route[i]:
            #print(j)
            count = 0
            if ans[j] == 0:
                ans[j] = i
                count += 1
            tmp.append(j)
    x = tmp
    #print(ans,x)
    if count = 0:
        break
print('Yes')
for i in ans.keys():
    if i != 1:
        print(ans[i])

Fixed submission:
N,M = map(int,input().split())
ans = {i:0 for i in range(1,N+1)}
ans[1] = 10000000
route = {i:set() for i in range(1,N+1)}
for _ in range(M):
    a,b = map(int,input().split())
    route[a].add(b)
    route[b].add(a)
x = {1}
for _ in range(N+1):
    tmp = set()
    count = 0
    for i in x:
        for j in route[i]:
            #print(j)
            if ans[j] == 0:
                ans[j] = i
                count += 1
                tmp.add(j)
    x = tmp
    #print(ans,x)
    if count == 0:
        break
check = 0
for i in ans.keys():
    if i != 1:
        if ans[i] == 0:
            check = 1
if check == 1:
    print('No')
else:
    print('Yes')
    for i in ans.keys():
        if i != 1:
            print(ans[i])
Buggy python submission (verdict: Runtime Error):
#### 逆元リストいらない
mod = 998244353
fact = [1]
fact_inv = [1]
for i in range(10**5+5):
    new_fact = fact[-1]*(i+1)%mod
    fact.append(new_fact)
    fact_inv.append(pow(new_fact,mod-2,mod))
def mod_comb_k(n,k,mod):
    return fact[n] * fact_inv[k] % mod * fact_inv[n-k] %mod
def power_func(a,n,p):
  bi=str(format(n,"b"))#2進表現に
  res=1
  for i in range(len(bi)):
    res=(res*res) %p
    if bi[i]=="1":
      res=(res*a) %p
  return res

N,M,K = map(int,input().split())
ans = 0
for i in range(K+1):
    X = mod_comb_k(N-1,i,mod)
    Z = power_func(M-1,N-(i+1),mod)
    #print(X,Z)
    ans += X * M * Z % mod
ans %= mod
print(ans)


Fixed submission:
#### 逆元リストいらない
mod = 998244353
fact = [1]
fact_inv = [1]
for i in range(2*10**5+2):
    new_fact = fact[-1]*(i+1)%mod
    fact.append(new_fact)
    fact_inv.append(pow(new_fact,mod-2,mod))
def mod_comb_k(n,k,mod):
    return fact[n] * fact_inv[k] % mod * fact_inv[n-k] %mod
def power_func(a,n,p):
  bi=str(format(n,"b"))#2進表現に
  res=1
  for i in range(len(bi)):
    res=(res*res) %p
    if bi[i]=="1":
      res=(res*a) %p
  return res
N,M,K = map(int,input().split())
ans = 0
for i in range(K+1):
    X = mod_comb_k(N-1,i,mod)
    Z = power_func(M-1,N-(i+1),mod)
    #print(X,Z)
    ans += X * M * Z % mod
ans %= mod
print(ans)
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
H = list(map(int,input().split()))
W = [1 for i in range(N)]
for i in range(M):
    a,b = map(int,input().split())
    if H[a-1] >= H[b-1]:
        W[b-1] = 0
    if H[b-1] >= H[a]:
        W[a-1] = 0
ans = 0
for i in W:
    ans += i
print(ans)

Fixed submission:
N,M = map(int,input().split())
H = list(map(int,input().split()))
W = [1 for i in range(N)]
for i in range(M):
    a,b = map(int,input().split())
    if H[a-1] >= H[b-1]:
        W[b-1] = 0
    if H[b-1] >= H[a-1]:
        W[a-1] = 0
ans = 0
for i in W:
    ans += i
print(ans)

Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
H = list(map(int,input().split()))
W = [1 for i in range(N)]
for i in range(M):
    a,b = map(int,input().split())
    if H[a-1] >= H[b-1]:
        W[b-1] = 0
    if H[b-1] >= H[a]:
        W[a-1] = 0
ans = 0
for i in W:
    ans += i
print(ans)

Fixed submission:
N,M = map(int,input().split())
H = list(map(int,input().split()))
W = [1 for i in range(N)]
for i in range(M):
    a,b = map(int,input().split())
    if H[a-1] >= H[b-1]:
        W[b-1] = 0
    if H[b-1] >= H[a-1]:
        W[a-1] = 0
ans = 0
for i in W:
    ans += i
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
mod = 10 ** 9 + 7
#約数の和（自分自身も含む)
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    # divisors.sort()
    return divisors
N,K = map(int,input().split())
ans = K ** N
divdic = {1:1} 
for i in range(2,K+1):
    A = make_divisors(i)
    A.remove(i)
    X = i
    for j in A:
        X -= divdic[j]
    divdic[i] = X
    Y = K // i
    Z = (X * Y ** N) % mod
    #print(i,X,Y,Z)
    ans = (ans + Z) % mod
print(ans)

Fixed submission:
mod = 10 ** 9 + 7
#約数の和（自分自身も含む)
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    # divisors.sort()
    return divisors
def power_func(a,n,p):
  bi=str(format(n,"b"))#2進表現に
  res=1
  for i in range(len(bi)):
    res=(res*res) %p
    if bi[i]=="1":
      res=(res*a) %p
  return res
N,K = map(int,input().split())
ans = K ** N
divdic = {1:1} 
for i in range(2,K+1):
    A = make_divisors(i)
    A.remove(i)
    X = i
    for j in A:
        X -= divdic[j]
    divdic[i] = X
    Y = K // i
    Z = X * (power_func(Y,N,mod)) % mod
    #print(i,X,Y,Z)
    ans = (ans + Z) % mod
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,a,b = map(int,input().split())
mod = 10 ** 9 + 7
fact = [1]
fact_inv = [1]
for i in range(2*(10**5)+5):
    new_fact = fact[-1]*(i+1)%mod
    fact.append(new_fact)
    fact_inv.append(pow(new_fact,mod-2,mod))
fact2 = 1
for i in range(n,n-a,-1):
    fact2 = fact2 * i %mod
fact3 = fact2
for i in range(n-a,n-b,-1):
    fact3 = fact3 * i %mod
#print(fact2,fact3,fact_inv[a],fact_inv[b])
ans = (2 ** n - 1) % mod
ans -= fact2 * fact_inv[a] % mod
if ans < 0:
    ans += mod
ans -= fact3 * fact_inv[b] % mod
if ans < 0:
    ans += mod
print(ans)

Fixed submission:
n,a,b = map(int,input().split())
mod = 10 ** 9 + 7
fact = [1]
fact_inv = [1]
for i in range(2*(10**5)+5):
    new_fact = fact[-1]*(i+1)%mod
    fact.append(new_fact)
    fact_inv.append(pow(new_fact,mod-2,mod))
fact2 = 1
for i in range(n,n-a,-1):
    fact2 = fact2 * i %mod
fact3 = fact2
for i in range(n-a,n-b,-1):
    fact3 = fact3 * i %mod
#print(fact2,fact3,fact_inv[a],fact_inv[b])
ans = (2 ** n - 1) % mod
ans -= fact2 * fact_inv[a] % mod
if ans < 0:
    ans += mod
ans -= fact3 * fact_inv[b] % mod
if ans < 0:
    ans += mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,a,b = map(int,input().split())
mod = 10 ** 9 + 7
fact = [1]
fact_inv = [1]
for i in range(2*(10**5)+5):
    new_fact = fact[-1]*(i+1)%mod
    fact.append(new_fact)
    fact_inv.append(pow(new_fact,mod-2,mod))
fact2 = 1
for i in range(n,n-a,-1):
    fact2 = fact2 * i %mod
fact3 = fact2
for i in range(n-a,n-b,-1):
    fact3 = fact3 * i %mod
def mod_comb_k(n,k,mod):
    return fact[n] * fact_inv[k] % mod * fact_inv[n-k] %mod
#print(fact2,fact3,fact_inv[a],fact_inv[b])
ans = (2 ** n - 1) % mod
ans -= fact2 * fact_inv[a] % mod
ans -= fact3 * fact_inv[b] % mod
if ans < 0:
    ans += mod
print(ans)

Fixed submission:
n,a,b = map(int,input().split())
mod = 10 ** 9 + 7
fact = [1]
fact_inv = [1]
for i in range(2*(10**5)+5):
    new_fact = fact[-1]*(i+1)%mod
    fact.append(new_fact)
    fact_inv.append(pow(new_fact,mod-2,mod))
fact2 = 1
for i in range(n,n-a,-1):
    fact2 = fact2 * i %mod
fact3 = fact2
for i in range(n-a,n-b,-1):
    fact3 = fact3 * i %mod
#print(fact2,fact3,fact_inv[a],fact_inv[b])
ans = (2 ** n - 1) % mod
ans -= fact2 * fact_inv[a] % mod
if ans < 0:
    ans += mod
ans -= fact3 * fact_inv[b] % mod
if ans < 0:
    ans += mod
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
Y = list(str(N))
Z =[]
for i in Y:
    Z.append(int(i))
K = int(input())
m = len(str(N))
def nn(Z,K,m):
    ans = 0
    if K == 1:
        y = Z[0]
        ans += (m-1) * 9 + y
        #print(ans)
    elif K == 2:
        #0 
        ans += ((m-1) * (m-2) // 2) * 9 * 9
        #print(ans)
        #mid
        ans += (Z[0]-1) * (m-1) * 9
        #print(ans)
        #max
        K -= 1
        m -= 1
        Z = Z[1:]
        ans += nn(Z,K,m)
        #print(ans)
    elif K == 3:
        #0 
        ans += ((m-1) * (m-2) * (m-3) // 6) * 9 * 9 * 9
        #print(ans)
        #mid
        ans += (Z[0]-1) * ((m-1) * (m-2) // 2) * 9 * 9
        #print(ans)
        #max
        K -= 1
        m -= 1
        Z = Z[1:]
        ans += nn(Z,K,m)
    return ans
ans = nn(Z,K,m)        
print(ans)

Fixed submission:
N = int(input())
Y = list(str(N))
Z =[]
for i in Y:
    Z.append(int(i))
K = int(input())
m = len(str(N))
def nn(Z,K,m):
    ans = 0
    if m < K:
        return ans
    else:
        if K == 1:
            y = Z[0]
            ans += (m-1) * 9 + y
            #print(ans)
        elif K == 2:
            #0 
            ans += ((m-1) * (m-2) // 2) * 9 * 9
            #print(ans)
            #mid
            ans += (max(0,Z[0]-1)) * (m-1) * 9
            #print(ans)
            #max
            K -= 1
            m -= 1
            Z = Z[1:]
            for _ in range(100):
                if Z[0] == 0:
                    m -= 1
                    Z = Z[1:]   
                else:
                    break
                if len(Z) == 0:
                    break            
            ans += nn(Z,K,m)
            #print(ans)
        elif K == 3:
            #0 
            ans += ((m-1) * (m-2) * (m-3) // 6) * 9 * 9 * 9
            #print(ans)
            #mid
            ans += (max(0,Z[0]-1)) * ((m-1) * (m-2) // 2) * 9 * 9
            #print(ans)
            #max
            K -= 1
            m -= 1
            Z = Z[1:]
            for _ in range(100):
                if Z[0] == 0:
                    m -= 1
                    Z = Z[1:]   
                else:
                    break
                if len(Z) == 0:
                    break
            ans += nn(Z,K,m)
        return ans
if len(str(N)) < K:
    ans = 0
else:
    ans = nn(Z,K,m)        
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
H,N = map(int,input().split())
X = []
for _ in range(N):
    a,b = map(int,input().split())
    X.append([a,b])
dp = [10000000000000 for i in range(H+1)] 
dp[0] = 0
for i in range(1,H+1):
    for j in range(N):
        a = X[j][0]
        b = X[j][1]
        dp[i] = min(dp[i],dp[max(0,i-a)] + b)
#print(dp)
print(dp[H])

Fixed submission:
H,N = map(int,input().split())
X = []
for _ in range(N):
    a,b = map(int,input().split())
    X.append([a,b])
dp = [10000000000000 for i in range(H+1)] 
dp[0] = 0
for i in range(1,H+1):
    for j in range(N):
        a = X[j][0]
        b = X[j][1]
        dp[i] = min(dp[i],dp[max(0,i-a)] + b)
#print(dp)
print(dp[H])
Buggy python submission (verdict: Runtime Error):
import fractions
N = int(input())
A = list(map(int,input().split()))
mod = 10 ** 9 + 7
def mul(a, b):
    return ((a % mod) * (b % mod)) % mod
def div(a, b):
    return mul(a, pow(b,mod-2,mod))
lcm = A[0] * A[1] // fractions.gcd(A[0],A[1])
for i in range(2,N):
    lcm = div((lcm * A[i]),fractions.gcd(lcm,A[i]))
ans = 0
for i in range(N):
    b = div(lcm,A[i])
    ans += b 
    ans %= mod 
    #print(ans)
#print(lcm)
print(ans)


Fixed submission:
import fractions
N = int(input())
A = list(map(int,input().split()))
mod = 10 ** 9 + 7
def mul(a, b):
    return ((a % mod) * (b % mod)) % mod
def div(a, b):
    return mul(a, pow(b,mod-2,mod))
if N == 1:
    ans = 1
else:
    lcm = A[0] * A[1] // fractions.gcd(A[0],A[1])
    for i in range(2,N):
        #lcm = div((lcm * A[i]),fractions.gcd(lcm,A[i]))
        lcm = lcm * A[i] // fractions.gcd(lcm,A[i])
    ans = 0
    for i in range(N):
        b = div(lcm,A[i])
        ans += b 
        ans %= mod 
    #print(ans)
    #print(lcm)
print(ans)
Buggy python submission (verdict: Runtime Error):
def main():
    N = int(input())
    X = tuple(map(int,input().split()))
    MOD = 10 ** 9 + 7
    goal = X[-1]
    ans = goal - X[0]
    x = 1
    count = 2
    for i in X[1:N-1]:
       tmp = goal - i
       ans = ((ans * count % MOD) + ((x*tmp)%MOD)) % MOD
       x *= count % MOD
       count += 1
    print(ans)
if __name__ == '__main__':
    main()

Fixed submission:
N = int(input())
st = []
for i in range(N):
    s = list(map(str,input().split()))
    st.append(s)
X = input()
check = 0
ans = 0
for i in st:
    if check == 1:
        ans += int(i[1])
    if i[0] == X:
        check = 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())
prime = []
for i in range(2,2*x):
    prime_check = 0
    for j in prime:
        if i % j == 0:
            prime_check = 1
            break
    if prime_check == 0:
        if i >= x:
            ans = i
            break
        else:
            prime.append(i)
print(ans)

Fixed submission:
x = int(input())
prime = []
for i in range(2,2*x):
    prime_check = 0
    for j in prime:
        if i % j == 0:
            prime_check = 1
            break
    if prime_check == 0:
        if i >= x:
            ans = i
            break
        else:
            prime.append(i)
print(ans)
Buggy python submission (verdict: Runtime Error):
import math

a,b = map(int,input().split())
print(a * b // math.gcd(a, b))



Fixed submission:
a,b = map(int,input().split())

for i in range(1,10000000):
    c = a * i
    if c % b == 0:
        print(c)
        break
Buggy python submission (verdict: Runtime Error):
n = int(input())
x = list(map(int,input().split()))
mod = 10 ** 9 + 7
ans = 0
m = 1　#1の桁のbitからスタート
for _ in range(60):
    bit = sum(a & m for a in x) #フラグが立ってる桁を合計
    bit //= m #1の個数を数えるためにmで割る
    non_bit = n - bit #0の個数を出す
    ans = (ans + bit * non_bit * m) % mod #桁の合計出す
    m <<= 1 #桁を1増やす
print(ans)




Fixed submission:
n = int(input())
x = list(map(int,input().split()))
mod = 10 ** 9 + 7
ans = 0
m = 1
for _ in range(60):
    bit = sum(a & m for a in x) #フラグが立ってる桁を合計
    bit //= m #1の個数を数えるためにmで割る
    non_bit = n - bit #0の個数を出す
    ans = (ans + bit * non_bit * m) % mod #桁の合計出す
    m <<= 1 #桁を1増やす
print(ans)

Buggy python submission (verdict: Runtime Error):
import numpy as np
n = int(input())
mod = 10 ** 9 + 7
a = [list(bin(int(i))[2:].zfill(60)) for i in input().split()]
a = np.array(a)
x = a.T
x = x.tolist()
#print(x)
ans = 0
for i in range(60):
    y = x[i].count('0')
    z = x[i].count('1')
    tmp = ( (n * (n - 1) // 2) - (y * (y - 1) // 2) - (z * (z - 1) // 2) ) % mod
    tmp2 = 1
    for j in range(60 - i - 1):
        tmp2 = tmp2 * 2 % mod
    #print(tmp,tmp2)
    
    ans = (ans + tmp2 * tmp) % mod
print(ans)
    
    

Fixed submission:
n = int(input())
x = list(map(int,input().split()))
mod = 10 ** 9 + 7
ans = 0
m = 1
for _ in range(60):
    bit = sum(a & m for a in x) #フラグが立ってる桁を合計
    bit //= m #1の個数を数えるためにmで割る
    non_bit = n - bit #0の個数を出す
    ans = (ans + bit * non_bit * m) % mod #桁の合計出す
    m <<= 1 #桁を1増やす
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n = int(input())
mod = 10 ** 9 + 7
a = [list(bin(int(i))[2:].zfill(60)) for i in input().split()]
a = np.array(a)
x = a.T
x = x.tolist()
#print(x)
ans = 0
for i in range(60):
    y = x[i].count('0')
    z = x[i].count('1')
    tmp = ( (n * (n - 1) // 2) - (y * (y - 1) // 2) - (z * (z - 1) // 2) ) % mod
    tmp2 = 1
    for j in range(60 - i - 1):
        tmp2 = tmp2 * 2 % mod
    #print(tmp,tmp2)
    
    ans = (ans + tmp2 * tmp) % mod
print(ans)
    
    

Fixed submission:
n = int(input())
x = list(map(int,input().split()))
mod = 10 ** 9 + 7
ans = 0
m = 1
for _ in range(60):
    bit = sum(a & m for a in x) #フラグが立ってる桁を合計
    bit //= m #1の個数を数えるためにmで割る
    non_bit = n - bit #0の個数を出す
    ans = (ans + bit * non_bit * m) % mod #桁の合計出す
    m <<= 1 #桁を1増やす
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = str(input())

S10 = [0 for i in range(10)]
S100 = [list(S10) for i in range(10)]
S1000 =[list([list(S10) for i in range(10)]) for i in range(10)]

for n in S:
    for i in range(10):
        for j in range(10):
            if list(S100)[i][j] == 1:
                S1000[i][j][int(n)] = 1
        if list(S10)[i] == 1:
            S100[i][int(n)] = 1
    S10[int(n)] = 1
    


ans = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            if S1000[i][j][k] == 1:
                ans += 1

print(ans)


Fixed submission:
N = int(input())
S = str(input())

S10 = [0 for i in range(10)]
S100 = [list(S10) for i in range(10)]
S1000 =[list([list(S10) for i in range(10)]) for i in range(10)]

for n in S:
    for i in range(10):
        for j in range(10):
            if list(S100)[i][j] == 1:
                S1000[i][j][int(n)] = 1
        if list(S10)[i] == 1:
            S100[i][int(n)] = 1
    S10[int(n)] = 1
    


ans = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            if S1000[i][j][k] == 1:
                ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
mod = 1000000007
def power(x, y):
    if   y == 0     : 
        return 1
    elif y == 1     : 
        return x % mod
    elif y % 2 == 0 : 
        return power(x, y//2)**2 % mod
    else            : 
        return power(x, y//2)**2 * x % mod
X,Y = (int(i) for i in input().split())

Z = X + Y
A = max(X,Y)
B = min(X,Y)
C = A - B

if Z % 3 != 0:
    print(0)
else:
    N = Z // 3
    if (N - C) % 2 != 0:
        print(0)
    else:
        M = (N - C) // 2


        a = 1
        b = 1
        for i in range(M):
            a = (a * (i + 1)) % mod
            c = power(a, mod-2)
        for i in range(M):
            b = (b * (N-i)) % mod
        ans = b * c % mod

        print(ans)

Fixed submission:
mod = 1000000007
def power(x, y):
    if   y == 0     : 
        return 1
    elif y == 1     : 
        return x % mod
    elif y % 2 == 0 : 
        return power(x, y//2)**2 % mod
    else            : 
        return power(x, y//2)**2 * x % mod
X,Y = (int(i) for i in input().split())

Z = X + Y
A = max(X,Y)
B = min(X,Y)
C = A - B

if Z % 3 != 0:
    print(0)
elif A > 2*B :
    print(0)
else:
    N = Z // 3
    if (N - C) % 2 != 0:
        print(0)
    else:
        M = (N - C) // 2


        a = 1
        b = 1
        for i in range(M):
            a = (a * (i + 1)) % mod
            b = (b * (N-i)) % mod
        c = power(a, mod-2)
        ans = b * c % mod

        print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = list(map(int,input().split()))
L.sort()
ans = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if L[k] < L[i] + L[j]:
                ans += 1
            else:
                break
print(ans)

Fixed submission:
N = int(input())
L = list(map(int,input().split()))
L.sort()
ans = 0
x = []
for i in range(N-2):
    check = 0
    for j in range(i+1,N-1):
        for k in range(j+1+check,N):
            if L[k] < L[i]+L[j]:
                check += 1
            else:
                break
        ans += check
        check -= 1
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = [int(i) for i in input().split()]

ans = 0
max = 0
T = H[0]
for i in range(N-1):
    if H[i] >= H[i+1]:
        ans + = 1
        if ans >= max :
            max = ans
    
    else:
        ans = 0
        

print(max)

Fixed submission:
N = int(input())
H = [int(i) for i in input().split()]

ans = 0
max = 0
T = H[0]
for i in range(N-1):
    if H[i] >= H[i+1]:
        ans += 1
        if ans >= max :
            max = ans
    
    else:
        ans = 0
        

print(max)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ans = 0
for i in range(N):
    ans += i

print(ans)

Fixed submission:
N = int(input())
 
    
ans = (N  * (N - 1))
ans = ans // 2

print(ans)