Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())
li = list(map(int,input().split()))
lis = []
lis.append(0)
for hoge in li:
    lis.append(hoge)
lis.append(0)
sumpo = 0
sumpo += abs(li[0])
for i in range(0,n):
    sumpo += abs(li[i]-li[i+1])
for i in range(1,n+1):
    print(sumpo + abs(li[i+1]-li[i-1]) - (abs(li[i]-li[i-1])+abs(li[i+1]-li[i])))


Fixed submission:
n = int(input())
li = list(map(int,input().split()))
lis = []
lis.append(0)
for hoge in li:
    lis.append(hoge)
lis.append(0)
sumpo = 0
sumpo += abs(li[0])
for i in range(1,n+1):
    sumpo += abs(lis[i]-lis[i+1])
for i in range(1,n+1):
    print(sumpo + abs(lis[i+1]-lis[i-1]) - (abs(lis[i]-lis[i-1])+abs(lis[i+1]-lis[i])))
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
a -= b
print(a%c)

Fixed submission:
a = (int)(input())
b = (int)(input())
c = (int)(input())
a-=b
print(a%c)
Buggy python submission (verdict: Runtime Error):
p,a,b = map(int,input().split())
if(a<=b):
  print(-1)
else:
  p-=a
  up=a-b
  if(p<=0):
    print(1)
  else
  	num=p//up+(p%up!=0)
  	print(num*2+1)


Fixed submission:
p,a,b = map(int,input().split())
if(a<=b):
  if(a>=p):
    print(1)
  else:
  	print(-1)
else:
  p-=a
  up=a-b
  if(p<=0):
    print(1)
  else:
  	num=p//up+(p%up!=0)
  	print(num*2+1)
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
print(100*b+pow(2,m)*1900)

Fixed submission:
a,b = map(int,input().split())
print(100*(a-b)*pow(2,b)+pow(2,b)*1900*b)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
if(c-b and b-a):
    print("YES")
else:
    print("NO")


Fixed submission:
a,b,c = map(int,input().split())
if(c-b == b-a):
    print("YES")
else:
    print("NO")

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
if c-b and b-a:
    print("YES")
else:
    print("NO")


Fixed submission:
a,b,c = map(int,input().split())
if(c-b == b-a):
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
s2 = input()
s3 = input()
alp = "abcdefghijklmnopqrstuvwxyz"
ans = ""
for a in alp:
  for i in range(min(s.count(a),s2.count(a),s3.count(a))):
    ans += a
print(ans)


Fixed submission:
n = int(input())
s = []
for i in range(n):
    s.append(input())
alp = "abcdefghijklmnopqrstuvwxyz"
ans = ""
for a in alp:
    cnt = 1e10
    for ss in s:
        cnt = min(cnt,ss.count(a))
    for i in range(cnt):
        ans += a
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
s2 = input()
s3 = input()
alp = "abcdefghijklmnopqrstuvwxyz"
ans = ""
for a in alp:
  for i in range(min(s.count(a),s2.count(a),s3.count(a))):
    ans += a
print(ans)

Fixed submission:
n = int(input())
s = []
for i in range(n):
    s.append(input())
alp = "abcdefghijklmnopqrstuvwxyz"
ans = ""
for a in alp:
    cnt = 1e10
    for ss in s:
        cnt = min(cnt,ss.count(a))
    for i in range(cnt):
        ans += a
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = 0
li = []
for i in range(n):
    a,b = map(int,input().split())
    li.append(map(int,input().split()))
for (a,b) in li[::-1]:
    ans += (b-((a+ans)%b))%b
print(ans)


Fixed submission:
n = int(input())
ans = 0
li = []
for i in range(n):
    a,b = map(int,input().split())
    li.append((a,b))
li = li[::-1]
for (a,b) in li:
    ans += (b-((a+ans)%b))%b
print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
ans = 0
for i in range(1,n):
    if(s[i]!=s[i-1]):
        ans += 1
print(ans)



Fixed submission:
s = input()
ans = 0
for i in range(1,len(s)):
    if(s[i]!=s[i-1]):
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
print(eval("'ACL'*input()"))

Fixed submission:
print(eval("'ACL'*"+input()))
Buggy python submission (verdict: Runtime Error):
def calc_score(sch):
    d=[0]*26
    score=0
    for i in range(dur):
        j=sch[i]-1
        s=S[i]
        score+=s[j]+c[j]*(i+1-d[j])+sum([-c[k]*(i+1-d[k]) for k in range(26)])
        d[j]=i+1
    return score

def greedy(dur,c,S,r):
    sch=[]
    d=[0]*26
    for i in range(dur):
        t=0
        s=S[i]
        m=-1<<64
        for j in range(26):
            alt=s[j]+r*c[j]*(i+1-d[j])+sum([-r*c[k]*(i+1-d[k]) for k in range(26)])
            #alt=s[j]-(-c[j]*(i+1-d[j])+sum([c[k]*(i+1-d[k]) for k in range(26)]))**r
            if alt>m:
                m=alt
                t=j
        sch.append(t+1)
        d[t]=i+1
    return sch

dur=int(input())
c=list(map(int,input().split()))
S=[list(map(int,input().split())) for i in range(dur)]

T=50
a,b=1,8
R=1
tmp=-inf

for r in [a+i*(b-a)/T for i in range(T)]:
    alt_sch=greedy(dur,c,S,r)
    alt=calc_score(alt_sch)
    if tmp<alt:
        tmp=alt
        sch=alt_sch
        R=r

for i in sch:
    print(i)



Fixed submission:
for i in range(365):print((19-i)%26+1)

Buggy python submission (verdict: Runtime Error):
import random
dur=int(input())
c=list(map(int,input().split()))
cM=max(c)
for i in range(26):
  if c[i]==cM:M=i
d=[0]*26
for i in range(dur):
  t=0
  s=list(map(int,input().split()))
  m=-1<<64
  for j in range(26):
    alt=s[j]+c[j]*(i+1-d[j])+sum([-c[k]*(i+1-d[k]) for k in range(26)])
    if alt>m:
      m=alt
      t=j
  r=randint(1,1000)
  if r<50:
    print(M+1)
    d[M]=i+1
  else:
    print(t+1)
    d[t]=i+1


Fixed submission:
for i in range(365):print((19-i)%26+1)

Buggy python submission (verdict: Runtime Error):
d=int(input())
c=map(int,input().split())
d=[0]*26
for i in range(365):
  s=map(int,input().split())
  m=-1<<64
  for j in range(26):
    alt=s[j]+c[j](i+1-d[j])+sum([-c[k]*(i+1-d[k]) for k in range(26)])
    if alt>m:
      m=alt
      t=j
  print(j+1)
  d[j]=i+1


Fixed submission:
for i in range(365):print((19-i)%26+1)
Buggy python submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
a=sorted(map(int,input().split()))
b=sorted(map(int,input().split()))
x=sum(a)
z=n

r=0

for l in range(n):
    if x>k:
        x-=a.pop()
        z-=1
        continue
    else:
        while r<m and x+b[r]<=k:
            x+=b[r]
            r+=1
            z+=1
        ans=max(z,ans)
        #show(a,z,r)
        x-=a.pop()
        z-=1

print(ans)



Fixed submission:
ans=0

n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
x=sum(a)
z=n

r=0

for l in range(n):
    
        while r<m and x+b[r]<=k:
            x+=b[r]
            r+=1
            z+=1
        if x<=k:ans=max(z,ans)
        #show(a,z,r)
        x-=a.pop()
        z-=1

while r<m and x+b[r]<=k:
    x+=b[r]
    r+=1
    z+=1
ans=max(z,ans)

print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=(int(i) for i input().split())
b=0
for i in a:b^=i
print(*(i^b for i in a))

Fixed submission:
input()
a=[int(i) for i in input().split()]
b=0
for i in a:b^=i
print(*[i^b for i in a])
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
for i in rep(k,n+1+1):
    l=(i-1)*i//2
    r=(n-i+1+n)*i//2
    ans+=(r-l+1)
    ans%=10**9+7
print(ans)

Fixed submission:
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
import sys,bisect,string,math,time,functools,random
def Golf():*a,=map(int,open(0))
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[];g=[[] for i in range(n)]
    for i in range(E):
        inp=LI();org_inp.append(inp)
        if index==0:inp[0]-=1;inp[1]-=1
        if len(inp)==2:
            a,b=inp;g[a].append(b)
            if not Directed:g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp;aa=(inp[0],inp[2]);bb=(inp[1],inp[2]);g[a].append(bb)
            if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[1]*(w+2);found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[1]+[mp_def[j] for j in s]+[1]
    mp+=[1]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)];rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)

YN=['YES','NO'];Yn=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
#sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()

class Comb:
    def __init__(self,n,mo=10**9+7):
        self.fac=[0]*(n+1)
        self.inv=[1]*(n+1)
        self.fac[0]=1
        self.fact(n)
        for i in range(1,n+1):
            self.fac[i]=i*self.fac[i-1]%mo
            self.inv[n]*=i
            self.inv[n]%=mo
        self.inv[n]=pow(self.inv[n],mo-2,mo)
        for i in range(1,n):
            self.inv[n-i]=self.inv[n-i+1]*(n-i+1)%mo
        return
    
    def fact(self,n):
        return self.fac[n]
        
    def invf(self,n):
        return self.inv[n]

    def comb(self,x,y):
        if y<0 or y>x:
            return 0
        return self.fac[x]*self.inv[x-y]*self.inv[y]%mo

show_flg=False
show_flg=True

ans=0

n,k=LI()

for i in range(k,n+1+1):
    #r=(n+n-k+1)*k//2-(k-1)*k//2+1
    r=(n+n-i+1)*i//2-(i-1)*i//2+1
    r%=mo
    ans+=r
    #show(i,r)


print(ans%mo)
Buggy python submission (verdict: Runtime Error):
K=4000
S=[input()for i in R(3)]
A,B,C=S
a,b,c=len(A),len(B),len(C)
def F(S,T):
 R=[1]*(K*2+1)
 for i in R(-len(T),len(S)):
  for j in range(max(i,0),min(len(S),len(T)+i)):
   if S[j]!=T[j-i]and S[j]!="?"and T[j-i]!="?":
    R[i]=0
    break
 return R
AB=F(A,B)
AC=F(A,C)
BC=F(B,C)
i=K*3
for i in range(-K,K+1):
 if A[i]!=0:
  for i in range(-K,K+1):
   if A[c]==0 or B[i-i]==0:
    m=min(m,max(b+b,c+c,a)-min(b,c,0))
print(m)

Fixed submission:
print('YNeos'[1-(input()in['hi'*i for i in range(11)])::2])

Buggy python submission (verdict: Runtime Error):
K=4000
S=[input()for i in R(3)]
A,B,C=S
la,lb,lc=len(A),len(B),len(C)
def F(S,T):
 R=[1]*(K*2+1)
 for i in R(-len(T),len(S)):
  for j in range(max(i,0),min(len(S),len(T)+i)):
   if S[j]!=T[j-i]and S[j]!="?"and T[j-i]!="?":
    R[i]=0
    break
 return R
AB=F(A,B)
AC=F(A,C)
BC=F(B,C)
mi=K*3
for ib in range(-K,K+1):
 if AB[ib]!=0:
  for ic in range(-K, K+1):
   if AC[ic]==0 or BC[ic-ib]==0:
    mi=min(mi,max(ib+lb,ic+lc,la)-min(ib,ic,0))
print(mi)


Fixed submission:
print('YNeos'[1-(input()in['hi'*i for i in range(11)])::2])
Buggy python submission (verdict: Runtime Error):
from collections import Counter
n,p=map(int,input().split())
s=input()[::-1]
a=0
t=0
d=1
m=[0]*p
m=[0]
for i in range(n):
  x=int(s[i])*d%p
  m.append((m[-1]+x)%p)
  d=(d*10)%p
c=Counter(m)
for i,j in c.items():
  a+=j*(j-1)//2

if p==2 or p==5:
  a=0
  for i in range(n):
    if s[n-1-i]%p==0:
      a+=n-1-i
  print(a)
else:
  print(a)


Fixed submission:
from collections import Counter
n,p=map(int,input().split())
s=input()[::-1]
a=0
t=0
d=1
m=[0]*p
m=[0]
for i in range(n):
  x=int(s[i])*d%p
  m.append((m[-1]+x)%p)
  d=(d*10)%p
c=Counter(m)
for i,j in c.items():
  a+=j*(j-1)//2

if p==2 or p==5:
  a=0
  for i in range(n):
    x=int(s[i])
    if x%p==0:
      a+=n-i
  print(a)
else:
  print(a)
Buggy python submission (verdict: Runtime Error):
print 2**len(bin(input()))//4-1

Fixed submission:
a=int(input())
k=2
while a>=k:k*=2
print(k-1)

Buggy python submission (verdict: Runtime Error):
print 2**len(bin(input()))/4-1

Fixed submission:
a=int(input())
k=2
while a>=k:k*=2
print(k-1)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[[0]*10 for i in range(10)]
for i in range(1,n+1):
    a[int(str(i)[0])][i%10]+=1
def N(x,y): # no of x...y < n
    return a[x][y]

ans=0
for x in range(1,10):
    ans+=N(x,x)*N(x,x)
    for y in range(x+1,10):
        ans+=N(x,y,n)*N(y,x,n)*2
print(ans)

Fixed submission:
def N(x,y,n): # no of x...y < n
    if n<100:
        r=0
        for i in range(1,n+1):
            if str(i)[0]==str(x) and str(i)[-1]==str(y):
                r+=1
        return r
    
    r=N(x,y,99)
    d=len(str(n))
    for i in range(1,d-2):
        r+=10**i
    top=int(str(n)[0])
    if top<x:
        r+=0
    elif top==x:
        r+=int(str(n)[1:-1])
        if str(n)[-1]>=str(y):
            r+=1
    else:
        r+=10**(d-2)

        
    return r


ans=0
n=int(input())
for x in range(1,10):
    for y in range(1,10):
        ans+=N(x,y,n)*N(y,x,n)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def N(x,y,n): # no of x...y < n
    r=0
    for i in range(1,n+1):
        if str(i)[0]==str(x) and str(i)[-1]==str(y):
            r+=1
    return r

ans=0
n=int(input())
for x in range(1,10):
    for y in range(1,10):
        ans+=N(x,y,n)*N(y,x,n)
        
print(ans)

Fixed submission:
def N(x,y,n): # no of x...y < n
    if n<100:
        r=0
        for i in range(1,n+1):
            if str(i)[0]==str(x) and str(i)[-1]==str(y):
                r+=1
        return r
    
    r=N(x,y,99)
    d=len(str(n))
    for i in range(1,d-2):
        r+=10**i
    top=int(str(n)[0])
    if top<x:
        r+=0
    elif top==x:
        r+=int(str(n)[1:-1])
        if str(n)[-1]>=str(y):
            r+=1
    else:
        r+=10**(d-2)

        
    return r


ans=0
n=int(input())
for x in range(1,10):
    for y in range(1,10):
        ans+=N(x,y,n)*N(y,x,n)
print(ans)

Buggy python submission (verdict: Runtime Error):

ans=0
n=int(input())
for x in range(1,10):
    for y in range(1,10):
        ans+=N(x,y,n)*N(y,x,n)
        

print(ans)


Fixed submission:
def N(x,y,n): # no of x...y < n
    if n<100:
        r=0
        for i in range(1,n+1):
            if str(i)[0]==str(x) and str(i)[-1]==str(y):
                r+=1
        return r
    
    r=N(x,y,99)
    d=len(str(n))
    for i in range(1,d-2):
        r+=10**i
    top=int(str(n)[0])
    if top<x:
        r+=0
    elif top==x:
        r+=int(str(n)[1:-1])
        if str(n)[-1]>=str(y):
            r+=1
    else:
        r+=10**(d-2)

        
    return r


ans=0
n=int(input())
for x in range(1,10):
    for y in range(1,10):
        ans+=N(x,y,n)*N(y,x,n)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[int(i) for i in input().split()]
ans=0
for i in range(64):
    x,y=0,0
    for j in a:
        if j>>i&1:
            y+=1
        else:
            x+=1
    ans+=x*y*(1<<i)
    ans%=10**9+7
print(ans)


Fixed submission:
n=int(input())
a=[int(i) for i in input().split()]
ans=0
for i in range(64):
    x,y=0,0
    for j in a:
        if j>>i&1:
            y+=1
        else:
            x+=1
    ans+=x*y*(1<<i)
    ans%=10**9+7
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[2**66+int(i) for i in input().split()]
ans=0
for i in range(64):
    x,y=0,0
    for j in a:
        if bin(j)[-i-1]=='1':
            y+=1
        else:
            x+=1
    ans+=x*y*(1<<i)
    ans%=10**9+7
print(ans)

Fixed submission:
n=int(input())
a=[int(i) for i in input().split()]
ans=0
for i in range(64):
    x,y=0,0
    for j in a:
        if j>>i&1:
            y+=1
        else:
            x+=1
    ans+=x*y*(1<<i)
    ans%=10**9+7
print(ans)
Buggy python submission (verdict: Runtime Error):
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
#import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**6)
input=lambda: sys.stdin.readline().rstrip()

show_flg=False
show_flg=True

n=I()
g=[[] for i in range(n)]
c=[]
dc={}
for i in range(n-1):
    a,b=LI_()
    c.append((a,b))
    g[a].append(b)
    g[b].append(a)
    dc[(a,b)]=0

mxd=0
mxi=0
for i in range(n):
    m=len(g[i])
    if m=1:
        mxd=m
        mxi=i
        
#vには最短距離をセット & -1 で未訪問フラグ

v=[-1]*(n)

def bfs(x):
    p=deque()
    p.append(x)
    v[x]=0
    while p:
        c=p.popleft()
        col=0
        for i in g[c]:
            if v[i]==-1:
                if v[c]==col:col+=1
                p.append(i)
                v[i]=col
                dc[(c,i)]=col
                col+=1
    return

bfs(mxi)
print(mxd)
for i,j in c:
    print(dc[(i,j)]+1)
    
#show(v)


Fixed submission:
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
#import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**6)
input=lambda: sys.stdin.readline().rstrip()

show_flg=False
show_flg=True

n=I()
g=[[] for i in range(n)]
c=[]
dc={}
for i in range(n-1):
    a,b=LI_()
    c.append((a,b))
    g[a].append(b)
    g[b].append(a)
    dc[(a,b)]=0

mxd=0
mxi=0
for i in range(n):
    m=len(g[i])
    if m==1:
        mxd=m
        mxi=i
        
#vには最短距離をセット & -1 で未訪問フラグ

v=[-1]*(n)

def bfs(x):
    p=deque()
    p.append(x)
    v[x]=0
    while p:
        c=p.popleft()
        col=0
        for i in g[c]:
            if v[i]==-1:
                if v[c]==col and c!=x:col+=1
                p.append(i)
                v[i]=col
                dc[(c,i)]=col
                dc[(i,c)]=col
#                show(i,c,col)
                col+=1
    return

bfs(mxi)
print(max(v)+1)
for i,j in c:
    print(dc[(i,j)]+1)
    
#show(v)
Buggy python submission (verdict: Runtime Error):
m=int(input())
s,c=0,0
for i in range(m):
  d,c=map(int,input().split())
  s+=d*c
  k+=c
print(k-1+(s-1)//9)

Fixed submission:
m=int(input())
s,k=0,0
for i in range(m):
  d,c=map(int,input().split())
  s+=d*c
  k+=c
print(k-1+(s-1)//9)
Buggy python submission (verdict: Time Limit Exceeded):
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
#import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
ts=time.time()
sys.setrecursionlimit(10**6)
#input=sys.stdin.readline().rstrip
show_flg=False
#show_flg=True

class Comb:
    def __init__(self,n,mo=10**9+7):
        self.fac=[0]*(n+1)
        self.inv=[1]*(n+1)
        self.fac[0]=1
        self.fact(n)
        for i in range(2,n+1):
            self.inv[n]*=i
            self.inv[n]%=mo
        self.inv[n]=pow(self.inv[n],mo-2,mo)
        for i in range(1,n):
            self.inv[n-i]=self.inv[n-i+1]*(n-i+1)%mo
        return
    
    def fact(self,n):
        if self.fac[n]!=0:
            return self.fac[n]
        self.fac[n]=n*self.fact(n-1)%mo
        return self.fac[n]

    def invf(self,n):
        return self.inv[n]

    def comb(self,x,y):
        if y<0 or y>x:
            return 0
        return self.fac[x]*self.inv[x-y]*self.inv[y]%mo
        
ans=0

s,t=LI()
a=(2*t-s)//3
b=(2*s-t)//3
if (2*t-s)%3!=0 or (2*s-t)%3!=0:
    print(0)
    show(a,b)
    exit()

cm=Comb(a+b+1+1)
ans=cm.comb(a+b,min(a,b))
print(ans)



Fixed submission:
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
#import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
ts=time.time()
sys.setrecursionlimit(10**6)
#input=sys.stdin.readline().rstrip
show_flg=False
show_flg=True

class Comb:
    def __init__(self,n,mo=10**9+7):
        self.fac=[0]*(n+1)
        self.inv=[1]*(n+1)
        self.fac[0]=1
        self.fact(n)
        for i in range(1,n+1):
            self.fac[i]=i*self.fac[i-1]%mo
            self.inv[n]*=i
            self.inv[n]%=mo
        self.inv[n]=pow(self.inv[n],mo-2,mo)
        for i in range(1,n):
            self.inv[n-i]=self.inv[n-i+1]*(n-i+1)%mo
        return
    
    def fact(self,n):
        return self.fac[n]
        
    def invf(self,n):
        return self.inv[n]

    def comb(self,x,y):
        if y<0 or y>x:
            return 0
        return self.fac[x]*self.inv[x-y]*self.inv[y]%mo
        
ans=0

s,t=LI()
a=(2*t-s)//3
b=(2*s-t)//3


if (2*t-s)%3!=0 or (2*s-t)%3!=0:
    print(0)
    exit()

cm=Comb(a+b+1+1)
ans=cm.comb(a+b,min(a,b))
print(ans)
Buggy python submission (verdict: Runtime Error):
0from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
#import math
#import time
#import random  # randome is not available at Codeforces
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
#eps=10**(-10)
#ts=time.time()
#sys.setrecursionlimit(10**6)
input=lambda: sys.stdin.readline().rstrip()

show_flg=False
show_flg=True

a,b=MI()
print(max(0,a-2*b))

Fixed submission:
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
#import math
#import time
#import random  # randome is not available at Codeforces
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
#eps=10**(-10)
#ts=time.time()
#sys.setrecursionlimit(10**6)
input=lambda: sys.stdin.readline().rstrip()

show_flg=False
show_flg=True

a,b=MI()
print(max(0,a-2*b))