Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict,deque
import math
def main():
    n = input()
    tmp = 0
    for i in range(len(n)):
        tmp += int(n)
        tmp%=9 
    if(tmp%9==0):
        print("Yes")
    else:
        print("No")
if __name__ == '__main__':
    main()


Fixed submission:
from collections import defaultdict,deque
import math
def main():
    n = input()
    tmp = 0
    for i in range(len(n)):
        tmp += int(n[i])
        tmp%=9
    if(tmp%9==0):
        print("Yes")
    else:
        print("No")
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict,deque
import math
def main():
    n = input()
    tmp = 0
    for i in range(len(n)):
        tmp += int(n)
    if(tmp%9==0):
        print("Yes")
    else:
        print("No")
if __name__ == '__main__':
    main()


Fixed submission:
from collections import defaultdict,deque
import math
def main():
    n = input()
    tmp = 0
    for i in range(len(n)):
        tmp += int(n[i])
        tmp%=9
    if(tmp%9==0):
        print("Yes")
    else:
        print("No")
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict,deque
import math
import copy
def main():
    x,k,d=map(int, input().split())
    res = float('inf')
    l = 0
    r = k+1
    tmp_res = 0
    while(l+1!=r):
        mid = (l+r)//2
        tmp_res = copy.deepcopy(res)
        if((k-mid)%2==1):
         	res = min(res, abs(abs(x)-(mid+1)*d))
            res = min(res, abs(abs(x)-(mid-1)*d))
            mid+=1
        if((k-mid)%2==0):
            res = min(res, abs(abs(x)-mid*d))
            res = abs(res)
        if(abs(abs(x)-mid*d) > x):
            r = mid
        else:
            l = mid
        if tmp_res == res:
            break

    print(res)




if __name__ == '__main__':
    main()



Fixed submission:
from collections import defaultdict,deque
import math
import copy
def main():
    x,k,d=map(int, input().split())
    res = float('inf')
    x = abs(x)

    if(k*d <= x):
        print(x-k*d)
    else:
        if(k%2 == x//d%2):
            print(x%d)
        else:
            print(d-x%d)




if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
from collections import defaultdict,deque
import math
import copy
def main():
    x,k,d=map(int, input().split())
    res = float('inf')
    l = 0
    r = k+1
    tmp_res = 0
    while(l+1!=r):
        mid = (l+r)//2
        tmp_res = copy.deepcopy(res)
        if((k-mid)%2==1):
         	res = min(res, abs(abs(x)-(mid+1)*d))
            res = min(res, abs(abs(x)-(mid-1)*d))
            mid+=1
        if((k-mid)%2==0):
            res = min(res, abs(abs(x)-mid*d))
            res = abs(res)
        if(abs(abs(x)-mid*d) > x):
            r = mid
        else:
            l = mid
        if tmp_res == res:
            break

    print(res)




if __name__ == '__main__':
    main()


Fixed submission:
from collections import defaultdict,deque
import math
import copy
def main():
    x,k,d=map(int, input().split())
    res = float('inf')
    x = abs(x)

    if(k*d <= x):
        print(x-k*d)
    else:
        if(k%2 == x//d%2):
            print(x%d)
        else:
            print(d-x%d)




if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict,deque
import math
def gcd(a,b):
    return b if not a%b else gcd(b,a%b)
def lcm(a,b):
    return (a*b)//gcd(a,b)

def main():
    n,k=map(int, input().split())
    a=[int(i) for i in input().split()]
    tmp = 0
    res = []
    tmp = 1
    tmp2 = a[0]
    for i in range(k):
        tmp*=a[i]
    res.append(tmp)
    ind = 0
    for i in range(k,n):
        tmp/=tmp2
        tmp*=a[i]
        ind+=1
        tmp2 = a[ind]
        res.append(tmp)

    for i in range(1,len(res)):
        if(res[i] > res[i-1]):
            print("Yes")
        else:
            print("No")


if __name__ == '__main__':
    main()


Fixed submission:
from collections import defaultdict,deque
import math
def gcd(a,b):
    return b if not a%b else gcd(b,a%b)
def lcm(a,b):
    return (a*b)//gcd(a,b)

def main():
    n,k=map(int, input().split())
    a=[int(i) for i in input().split()]
    tmp = 0
    res = []
    ind = 0
    for i in range(n-k):
        if(a[ind] < a[ind+k]):
            res.append(1)
        else:
            res.append(0)
        ind += 1

    for i in range(0,len(res)):
        if(res[i]):
            print("Yes")
        else:
            print("No")


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict,deque
import math
def gcd(a,b):
    return b if not a%b else gcd(b,a%b)
def lcm(a,b):
    return (a*b)//gcd(a,b)

def main():
    n,k=map(int, input().split())
    a=[int(i) for i in input().split()]
    tmp = 0
    res = []
    for i in range(k-1,n):
        past=0
        tmp = 1
        for j in range(i,i-k,-1):
            tmp*=a[j]

        res.append(tmp)

    for i in range(1,len(res)):
        if(res[i] > res[i-1]):
            print("Yes")
        else:
            print("No")


if __name__ == '__main__':
    main()


Fixed submission:
from collections import defaultdict,deque
import math
def gcd(a,b):
    return b if not a%b else gcd(b,a%b)
def lcm(a,b):
    return (a*b)//gcd(a,b)

def main():
    n,k=map(int, input().split())
    a=[int(i) for i in input().split()]
    tmp = 0
    res = []
    ind = 0
    for i in range(n-k):
        if(a[ind] < a[ind+k]):
            res.append(1)
        else:
            res.append(0)
        ind += 1

    for i in range(0,len(res)):
        if(res[i]):
            print("Yes")
        else:
            print("No")


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    n = int(input())
    res = [0]*(n+1)

    for i in range(1,100):
        for j in range(1,100):
            for k in range(1,100):
                if(i**2 + j**2 + k**2 +i*j+j*k + k*i<=n):
                    res[i**2 + j**2 + k**2 +i*j+j*k + k*i]+=1
                    
    for i in range(1,n+1):
        print(res[i])
if __name__ == '__main__':
    main()


Fixed submission:
def main():
    l,r,d=map(int, input().split())
    res = 0
    for i in range(l,r+1):
        if(i%d==0):
            res+=1
    print(res)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
def main():

    n = int(input())
    table = [0]*(n+1)
    x = input()
    k = x.count("1")
    for i in range(1,n+1):
        tmp=str(bin(i)).count("1")
        table[i]=i%tmp
    tmp = 0
    j=n
    for i in range(n):
        if(x[i]=="1"):
            tmp += 2**(j-1)
        j-=1
    j=n
    res = [0]*n
    for i in range(n):
        tmp2=k#1の数
        tmp3 = tmp#１０進数表記
        if(x[i]=="1"):
            tmp2-=1
            tmp3 -= (2**(j-i-1))
        else:
            tmp2+=1
            tmp3 += 2**(j-i-1)
        next = tmp3%tmp2

        if(next==0):
            res[i]=1
        else:
            res[i]+=1
            while(next!=0):
                res[i]+=1
                next = table[next]

    for i in range(n):
        print(res[i])


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    l,r,d=map(int, input().split())
    res = 0
    for i in range(l,r+1):
        if(i%d==0):
            res+=1
    print(res)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import itertools
def main():
    n,m,k=map(int, input().split())
    a=[int(i) for i in input().split()]
    b=[int(i) for i in input().split()]

    ia = n-1
    res = n
    ib = 0
    time = sum(a)

    while(ia>=0 and ib<m):

      if(time > k):
            time -= (a[ia])
            res-=1
            ia-=1
        elif(time+b[ib]<=k):
            time += (b[ib])
            res+=1
            ib+=1
        else:
            break

    print(res)

if __name__ == '__main__':
    main()


Fixed submission:
import itertools
def main():
    n,m,k=map(int, input().split())
    a=[int(i) for i in input().split()]
    b=[int(i) for i in input().split()]
    a = [0]+list(itertools.accumulate(a))
    b = [0]+list(itertools.accumulate(b))
    res = 0
    j = m
    best=0
    for i in range(n+1):
        if(a[i]>k):
            break
        while(b[j] > k-a[i]):
            j-=1
        res = max(res,i+j)
    print(res)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
from collections import deque
from itertools import accumulate
import math
def main():
    a,b=map(float, input().split())
    print(int((a*(b*100))//100))


if __name__ == '__main__':
    main()


Fixed submission:
import math
from collections import defaultdict
def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
          n /= i
          table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
def main():
    dd = defaultdict(int)
    n = int(input())
    pri = factorization(n)
    res = 0
    i  = len(pri)-1
    ans = 0

    for i in pri:
        k = i[1]
        i=1
        tmp=2
        cnt = 0
        while i<=k:
            i+=tmp
            tmp+=1
            cnt+=1
        ans+=cnt
    if len(pri)==1 and pri[0][1]==1:
        ans=1
    if n==1:
        ans = 0
    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import collections
x = int(input())
dd = collections.defaultdict(int)
for i in range(-100,100,1):
    dd[i**5]=i
for i in range(x):
    if(dd[i**5-x]!=0):
        print(i, dd[(i**5-x)])
        exit()


Fixed submission:
x = int(input())
a = [0]*1000
for i in range(1000):
    tmp = i**5
    a[i] = tmp
for i in range(1000):
    for j in range(1000):
        if((a[i]-x) == (a[j])):
            print(i,j)
            exit()
        elif(x-a[i]==a[j]):
            print(i,-j)
            exit()

Buggy python submission (verdict: Runtime Error):
import collections
x = int(input())
dd = collections.defaultdict(int)
for i in range(-100,100,1):
    dd[i**5]=i
for i in range(-sqrt(x),sqrt(x),1):
    if(dd[i**5-x]!=0):
        print(i, dd[(i**5-x)])
        exit()


Fixed submission:
x = int(input())
a = [0]*1000
for i in range(1000):
    tmp = i**5
    a[i] = tmp
for i in range(1000):
    for j in range(1000):
        if((a[i]-x) == (a[j])):
            print(i,j)
            exit()
        elif(x-a[i]==a[j]):
            print(i,-j)
            exit()

Buggy python submission (verdict: Time Limit Exceeded):
import collections
x = int(input())
dd = collections.defaultdict(int)
for i in range(-100,100,1):
    dd[i**5]=i
for i in range(x):
    if(dd[i**5-x]!=0):
        print(i, dd[(i**5-x)])
        exit()


Fixed submission:
x = int(input())
a = [0]*1000
for i in range(1000):
    tmp = i**5
    a[i] = tmp
for i in range(1000):
    for j in range(1000):
        if((a[i]-x) == (a[j])):
            print(i,j)
            exit()
        elif(x-a[i]==a[j]):
            print(i,-j)
            exit()
Buggy python submission (verdict: Runtime Error):
import math
import collections
def f(a,b,x):
    return math.floor((a*x)/b) - a*math.floor(x/b)
a,b,n=map(int, input().split())
dd = collections.defaultdict(int)

print(f(a,b,min(b-1,x)))


Fixed submission:
import math
import collections
def f(a,b,x):
    return math.floor((a*x)/b) - a*math.floor(x/b)
a,b,n=map(int, input().split())
dd = collections.defaultdict(int)

print(f(a,b,min(b-1,n)))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
from collections import deque

s=input()
n=len(s)
dd = defaultdict(int)
q = deque()
if n<4:
    print(0)
    exit()
ans=0
for i in range(4):
    q.append(s[i])
if(int(''.join(q))%2019)==0:
    ans+=1

for i in range(0, n-3):
    for j in range(5, n+1, 3):
        if i+j<n+1:
            dd[(i,i+j)]+=1
            if(int(s[i:i+j])%2019==0) and dd[(i,i+j)]==1:
                ans+=1
                i=i+j
                break
            if j>n-4:
                for k in range(3):
                    if i+j+k<n:
                        dd[(i,i+j+k)]+=1
                        if int(s[i:i+j+k])%2019==0 and dd[(i,i+j+k)]==1:
                            ans+=1

print(ans)


Fixed submission:
from collections import defaultdict
dd = defaultdict(int)
S = list(input().rstrip())
tmp = 0
dd[0]+=1
r=1
for s in S[::-1]:
    tmp+=int(s)*r
    r*=10

    tmp%=2019
    r%=2019
    dd[tmp]+=1
su=0
for i in dd.values():
    su+=(i*(i-1))//2
print(su)

Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
from collections import deque

s=input()
n=len(s)
dd = defaultdict(int)
q = deque()
ans=0
for i in range(4):
    q.append(s[i])
if(int(''.join(q))%2019)==0:
    ans+=1

for i in range(0, n-3):
    for j in range(5, n+1, 3):
        if i+j<n+1:
            dd[(i,i+j)]+=1
            if(int(s[i:i+j])%2019==0) and dd[(i,i+j)]==1:
                ans+=1
            if j>n-4:
                for k in range(3):
                    if i+j+k<n:
                        dd[(i,i+j+k)]+=1
                        if int(s[i:i+j+k])%2019==0 and dd[(i,i+j+k)]==1:
                            ans+=1

print(ans)


Fixed submission:
from collections import defaultdict
dd = defaultdict(int)
S = list(input().rstrip())
tmp = 0
dd[0]+=1
r=1
for s in S[::-1]:
    tmp+=int(s)*r
    r*=10

    tmp%=2019
    r%=2019
    dd[tmp]+=1
su=0
for i in dd.values():
    su+=(i*(i-1))//2
print(su)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
n=int(input())
dd = defaultdict(int)
A=[int(i) for i in input().split()]
for i in A:
    dd[i]+=1
ans = 0
for i in range(n):
    for j in dd:
        if A[i]==j:
            ans+=(((dd[j]-1)*(dd[j]-2))//2)
        else:
            ans+=(dd[j]*(dd[j]-1))//2
    print(ans)
    ans=0


Fixed submission:
from collections import defaultdict
n=int(input())
dd = defaultdict(int)
A=[int(i) for i in input().split()]
for i in A:
    dd[i]+=1
memo = [0]*(n+1)
for i in dd:
    memo[i]=(dd[i]*(dd[i]-1))//2
ans = sum(memo)
done = [-1]*(n+1)
for i in range(n):
    if done[A[i]]==-1:
        done[A[i]]=(int(ans-memo[A[i]]+(memo[A[i]])*((dd[A[i]]-2)/dd[A[i]])))
        print(done[A[i]])

    else:
        print(done[A[i]])
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int, input().split())
A=[((int(i)*(int(i)+1))/2)/int(i) for i in input().split()]
ans=0
for i in range(n-k+1):ans=max((sum(A[i:i+k])), ans)
print(ans)


Fixed submission:
from itertools import accumulate
n,k=map(int, input().split())
A=[((int(i)*(int(i)+1))/2)/int(i) for i in input().split()]
al = list(accumulate(A))
ans = al[k-1]
for i in range(k, n):ans=max(ans, al[i]-al[i-k])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int, input().split())
A=[((int(i)*(int(i)+1))/2)/int(i) for i in input().split()]
ans=0
for i in range(n-k+1):ans=max((sum(A[i:i+k])), ans)
print(ans)


Fixed submission:
from itertools import accumulate
n,k=map(int, input().split())
A=[((int(i)*(int(i)+1))/2)/int(i) for i in input().split()]
al = list(accumulate(A))
ans = al[k-1]
for i in range(k, n):ans=max(ans, al[i]-al[i-k])
print(ans)
Buggy python submission (verdict: Runtime Error):
n,k,s=map(int, input().split())
lis = [s]*k
if s==10**9:for i in range(n-k):lis.append(1)
else:for i in range(n-k):lis.append(s+1)
print(*lis)


Fixed submission:
n,k,s=map(int, input().split())
lis = [s]*k
if s==10**9:
    for i in range(n-k):
        lis.append(1)
else:
    for i in range(n-k):
        lis.append(s+1)
print(*lis)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
h,w = map(int, input().split())
grid = []
for i in range(h):
    s = list(input().rstrip())
    grid.append(s)
dxdy = [[0, 1], [1,0], [-1, 0], [0, -1]]
visited = [[0]*w for _ in range(h)]
dist = [[0]*w for _ in range(h)]
for i in range(h):
    for j in range(w):
        if grid[i][j]==".":
            y = i
            x = j
            break

que=deque()
que.append([x,y])
while que:
    v=que.popleft()
    x = v[0]
    y = v[1]
    visited[y][x]=1
    for i in dxdy:
        dx = i[0]
        dy = i[1]
        if((x+dx<w and y+dy<h) and ((x+dx)>-1)and(y+dy)>-1) and not visited[y+dy][x+dx]:
            dist[y+dy][x+dx]=dist[y][x]+1
            que.append([x+dx, y+dy])
max_dist = [0, []]
def max1(a,b):
    if a[0]>b[0]:
        return a
    else:
        return b
for i in range(h):
    for j in range(w):
        max_dist = max1(max_dist, [dist[i][j], i,j])
visited = [[0]*w for _ in range(h)]
dist = [[0]*w for _ in range(h)]

que2 = deque()
que2.append([max_dist[2], max_dist[1]])
while que2:
    v=que2.popleft()
    x = v[0]
    y = v[1]
    visited[y][x]=1
    for i in dxdy:
        dx = i[0]
        dy = i[1]
        if((x+dx<w and y+dy<h) and ((x+dx)>-1)and(y+dy)>-1) and not visited[y+dy][x+dx] and grid[y+dy][x+dx]==".":
            dist[y+dy][x+dx]=dist[y][x]+1
            que2.append([x+dx, y+dy])
for i in range(h):
    for j in range(w):
        max_dist = max1(max_dist, [dist[i][j], i,j])
print(max_dist[0])


Fixed submission:
from collections import deque

h,w = map(int, input().split())
grid = []
for i in range(h):
    s = list(input().rstrip())
    grid.append(s)
dydx = [[0, 1], [1,0], [-1, 0], [0, -1]]

def find_longest_path(xy):
    visited = [[0]*w for _ in range(h)]
    dist = [[0]*w for _ in range(h)]
    visited[xy[1]][xy[0]]=1
    que = deque()
    que.append(xy)
    while que:
        v = que.popleft()
        x,y = v[0],v[1]
        for i in dydx:
            dx = i[0]
            dy = i[1]
            if ((x+dx<w and y+dy<h) and ((x+dx)>-1)and(y+dy)>-1) and not visited[y+dy][x+dx]:
                if(grid[y+dy][x+dx]=="."):
                    que.append([x+dx, y+dy])
                    visited[y+dy][x+dx]=1
                    dist[y+dy][x+dx]=dist[y][x]+1
                    u,k = x+dx, y+dy
                    r = dist[y+dy][x+dx]

    return r

def main():
    k=0
    for i in range(h):
        for j in range(w):
            if grid[i][j]==".":
                k = max(k, find_longest_path([j,i]))
    print(k)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
from collections import deque,defaultdict
def gcd(a,b):
    return b if not a%b else gcd(b,a%b)
def lcm(a,b):
    return (a*b)//gcd(a,b)
n,m=map(int, input().split())
A=[int(i) for i in input().split()]
tmp = A[0]
for i in range(1,n):
    tmp = lcm(tmp,A[i])
#tmpの２分の１と1.5倍が何個入るかに帰着
#m//tmp +
ans = m//tmp
if(m//(tmp)*tmp+tmp//2<=m):
    ans += 1
if(tmp//2 in A or tmp*1.5 in A):
    ans=0
print(ans)


Fixed submission:
from collections import deque,defaultdict
def gcd(a,b):
    return b if not a%b else gcd(b,a%b)
def lcm(a,b):
    return (a*b)//gcd(a,b)
n,m=map(int, input().split())
A=[int(i) for i in input().split()]
tmp = A[0]
for i in range(1,n):
    tmp = lcm(tmp,A[i])
ans = m//tmp
lis = set()
for i in A:
    r = i
    k=0
    while(r%2==0):
        k+=1
        r//=2
    lis.add(k)
if(m//(tmp)*tmp+tmp//2<=m):
    ans += 1
if(len(lis)!=1):
    ans=0

print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
def main2():
    ketaone = [0]*61
    MOD = 10**9 + 7
    n = int(input())
    A=[int(i) for i in input().split()]

    for i in A:
        for j in range(61):
            if i&(1<<j):
                ketaone[j]+=1
    res = 0

    for i in range(61):
        res = res + (ketaone[i]*(n-ketaone[i])*(2**i))%MOD
        res%=MOD
    print(res)


def main1():
    n = int(input())
    lis = [[] for _ in range(n)]
    for i in range(n):
        a = int(input())
        for j in range(a):
            lis[i].append(list(map(int, input().split())))
    res = 0

    for i in range(1<<n):
        f = True
        uso=set()
        syo=set()
        tmp=0
        for j in range(n):
            if(i&(1<<j)):
                tmp+=1
                for k in lis[j]:
                    if (i&(1<<(k[0]-1))) and k[1]==0:
                        f=False
                    if k[1]==1 and not (i&(1<<k[0]-1)):
                        f=False
        if f:
            res = max(res,tmp)
    print(res)


if __name__ == '__main__':
    main2()


Fixed submission:

def main1():
    n,m,c=map(int, input().split())
    if(n+m+c>21):print("bust")
    else:print("win")


if __name__ == '__main__':
    main1()
Buggy python submission (verdict: Runtime Error):
n = int(input())
A=[int(i) for i in input().split()]
MOD = 1000000007
ans = 1
cnt = [0]*n
cnt[0]=3

for i in range(n):
    ans = ans * cnt[A[i]] %MOD
    cnt[A[i]]-=1
    cnt[A[i]+1]+=1
    if ans==0:
        break
print(ans)


Fixed submission:
n = int(input())
A=[int(i) for i in input().split()]
MOD = 1000000007
ans = 1
cnt = [0]*(n+1)
cnt[0]=3

for i in range(n):
    ans = ans * cnt[A[i]] %MOD
    cnt[A[i]]-=1
    cnt[A[i]+1]+=1
    if ans==0:
        break
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
A=[int(i) for i in input().split()]
MOD = 1000000007
ans = 1
cnt = [0]*n
cnt[0]=3

for i in range(n):
    ans = ans * cnt[A[i]] %MOD
    cnt[A[i]]-=1
    cnt[A[i]+1]+=1

print(ans if not 0 else 0)


Fixed submission:
n = int(input())
A=[int(i) for i in input().split()]
MOD = 1000000007
ans = 1
cnt = [0]*(n+1)
cnt[0]=3

for i in range(n):
    ans = ans * cnt[A[i]] %MOD
    cnt[A[i]]-=1
    cnt[A[i]+1]+=1
    if ans==0:
        break
print(ans)
Buggy python submission (verdict: Runtime Error):
X,Y=map(int, input().split())

MOD = 10**9 + 7
def prepare(n, MOD):

    # 1! - n! の計算
    f = 1
    factorials = [1]  # 0!の分
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    return factorials, invs
if (X+Y)%3!=0:
    print(0)
else:
    #最初に行き方を決めて、使う移動方法の個数を求めて、重複組み合わせ
    #決め打ちしてから n:2x+yの移動　m:x+2yの移動
    n = (2*X-Y)//3
    m = (2*Y-X)//3


    fac, invs = prepare((n+m), MOD)


    print(fac[n+m]*invs[n]*invs[m]%MOD)


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

MOD = 10**9 + 7
def prepare(n, MOD):

    # 1! - n! の計算
    f = 1
    factorials = [1]  # 0!の分
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    return factorials, invs
if (X+Y)%3!=0:
    print(0)
else:
    #最初に行き方を決めて、使う移動方法の個数を求めて、重複組み合わせ
    #決め打ちしてから n:2x+yの移動　m:x+2yの移動
    n = (2*X-Y)//3
    m = (2*Y-X)//3

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


    fac, invs = prepare((n+m), MOD)


    print(fac[n+m]*invs[n]*invs[m]%MOD)