qyliang/CodeNanoFix huggingface dataset:
Buggy code:
x, y = map(int, input().split(" "))
if x * y > 0:
  if x > 0:
    if y > x:
      print(y - x)
    else:
      print(x - y + 2)
  else:
    if y > x:
      print(y - x)
    else:
      print(-(y + x) + 1)
elif x * y < 0:
  if x > 0:
    print((y * -1) - x + 1)
  else:
    print(y-x)
else:
  if (x == 0 and y > 0) or (x < 0 and y == 0):
    print(y - x)
  elif (x == 0 and y < 0) or (x > 0 and y == 0):
    print(x + y + 1 )
  

Fixed code:
x, y = map(int, input().split(" "))
if x * y > 0:
  if x > 0:
    if y > x:
      print(y - x)
    elif y < x:
      print(x - y + 2)
    else:
      print(0)
  else:
    if y > x:
      print(y - x)
    elif y < x:
      print(-(y - x) + 2)
    else:
      print(0)
elif x * y < 0:
  if x > 0:
    if x > -y:
      print(x + y + 1)
    elif x < -y:
      print((y * -1) - x + 1)
    else:
      print(1)
  else:
    if -x > y:
      print(-x - y + 1)
    elif -x < y:
      print(x + y + 1)
    else:
      print(1)
else:
  if (x == 0 and y > 0) or (x < 0 and y == 0):
    print(y - x)
  elif (x == 0 and y < 0) or (x > 0 and y == 0):
    print(x - y + 1 )
  else:
    print(0)
Buggy code:
x,y=map(int,input().split())
x0=x
y0=y
X=[1,1,-1,-1]
Y=[1,-1,1,-1]
l=[]
for i in range(4):
    x=x*X[i]
    y=y*Y[i]
    if y-x>=0:
      q=y-x
      if X[i]==-1:
        q+=1
      if Y[i]==-1:
        q+=1
    l.append(q)
    x=x0
    y=y0  
print(min(l))

Fixed code:
x,y=map(int,input().split())
x0=x
y0=y
X=[1,1,-1,-1]
Y=[1,-1,1,-1]
l=[]
for i in range(4):
    x=x*X[i]
    y=y*Y[i]
    q=10**10
    if y-x>=0:
      q=y-x
      if X[i]==-1:
        q+=1
      if Y[i]==-1:
        q+=1
    l.append(q)
    x=x0
    y=y0
    
print(min(l))
Buggy code:
x,y=map(int,input().split())

X=abs(x)
Y=abs(y)

if x<y:
    if x*y>0:
        print(y-x)
    elif x*y==0:
        print(abs(X-Y))
    else:
        print(abs(X-Y)+1)
else:
    if x*y>=0:
        print(abs(X-Y)+2)
    elif x*y=0:
        print(abs(X-Y)+1)
    else:
        print(abs(X-Y)+1)

Fixed code:
x,y=map(int,input().split())
X=abs(x)
Y=abs(y)
if X<Y:
    if x<y:
        if x*y>=0:
            p=y-x
        else:
            p=y-(-x)+1      
    else:
        if x*y>0:
            p=(-y)-(-x)+2
        else:
            p=(-y)-x+1

else:
    if x<y:
        if x*y>=0:
            p=y-x
        else:
            p=(-y)-x+1
    else:
        if x*y>0:
            p=(-y)-(-x)+2
        else:
            p=y-(-x)+1
print(p)
Buggy code:
x,y = map(int,input().split())
ans = 1<<35
if x<=y: ans = min(ans,y-x)
if -x<=y: ans = min(ans,1+y-(-x))
if x<=-y: ans = min(ans,-y-x+1)
if -x<=-y: ans = min(ans,-y-(-x)+1)
print(ans)


Fixed code:
x, y = map(int, input().split())

ans = 1 << 35
 
# x to y
if x <= y: ans = min(ans, y - x)
# -x to y
if -x <= y: ans = min(ans, 1 + y - (-x))
# x to -y
if x <= -y: ans = min(ans, -y - x + 1)
# -x to -y
if -x <= -y: ans = min(ans, 1 + -y - (-x) + 1)

print(ans)
Buggy code:
a,b = map(int,input().split())
ans = abs(a-b)
if a*b<0:ans+=1
if b<a<0 or 0<b<a:ans+=2
if a==0 and b<0:ans+=1
if b==0 and 0<a:ans+=1
print(ans)

Fixed code:
a,b = map(int,input().split())
ans = abs(abs(a)-abs(b))
if a*b<0:ans+=1
if b<a<0 or 0<b<a:ans+=2
if a==0 and b<0:ans+=1
if b==0 and 0<a:ans+=1
print(ans)
Buggy code:
x,y = map(int,input().split())
ans = 0

if(y > 0):
    if(x > y):
        ans += 1
        ans += -y +x
    elif(x >= 0):
        ans += y -x
    elif(x > -y):
        ans += 1
        ans += y + x
    else:
        ans += 1
        ans += -y -x
else:
    if(x > -y):
        ans += 1
        ans += y + x
    elif(x >= 0):
        ans += 1
        ans += -y -x
    elif(x > y):
        ans += 1
        ans += -y +x
        ans += 1
    else:
        ans += y -x

if(x == 0 and y == 0) ans = 0
print(ans)


Fixed code:
x,y = map(int,input().split())
ans = 0
if(y > 0):
    if(x > y):
        ans += 1
        ans += -y +x
        ans += 1
    elif(x >= 0):
        ans += y -x
    elif(x > -y):
        ans += 1
        ans += y + x
    else:
        ans += 1
        ans += -y -x
else:
    if(x > -y):
        ans += 1
        ans += y + x
    elif(x >= 0):
        ans += 1
        ans += -y -x
    elif(x > y):
        ans += 1
        ans += -y +x
        ans += 1
    else:
        ans += y -x

if(x == 0 and y == 0):
    ans = 0
print(ans)
Buggy code:
x,y = map(int,input().split())
ax = abs(x)
ay = abs(y)
if ax == ay and x != y:
    a = 1
elif x > y and 0 < y:
    a = ax - ay + 2
elif x > y and y = 0:
    a = ax - ay + 1
elif x > y and 0 > y:
    if ay > ax and x >= 0:
        a = ay - ax + 1
    elif ay > ax and x < 0:
        a = ay - ax + 2
    elif ax > ay:
        a = ax - ay + 1
elif y > x and x < 0 and ay > ax:
    a = ay - ax + 1
elif y > x and x < 0 and y > 0 and ax > ay:
    a = ax - ay + 1
else:
    a = y-x
print(a)

Fixed code:
x, y = map(int, input().split())
ax = abs(x)
ay = abs(y)
if ax == ay:
    print(int(x != y))
elif ax > ay:
    if y <= 0:
        if x > 0:
            print(1 + ax - ay)
        else:
            print(ax - ay)
    else:
        if x > 0:
            print(2 + ax - ay)
        else:
            print(1 + ax - ay)
else:
    if y > 0:
        if x >= 0:
            print(ay - ax)
        else:
            print(1 + ay - ax)
    else:
        if x >= 0:
            print(1 + ay - ax)
        else:
            print(2 + ay - ax)
Buggy code:
a, b = map(int, input().split())

def cal(a,b):
    if a < b:
        dist1 = b - a
        dist2 = abs(b + a) + 1
        return min(dist1, dist2)
    elif a > b:
        if a >= 0 and b < 0:
            return abs(a+b) + 1
        else:
            dist1 = a - b + 2
        return min(dist1, dist2)

print(cal(a,b))
    

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

def cal(a,b):
    if a < b:
        dist1 = b - a
        dist2 = abs(b + a) + 1
        return min(dist1, dist2)
    elif a > b:
        if a >= 0 and b <= 0:
            return abs(a+b) + 1

        else:
            return a - b + 2

print(cal(a,b))
Buggy code:
x, y = map(int, input().split())

l = []

if x <= y:
  l.appen(y-x)
  
if -x <= y:
  l.append(y + x + 1)
  
if x <= -y:
  l.append(-y-x+1)
  
if -x <= -y:
  l.append(-y+x+2)
  
print(min(l))

Fixed code:
x, y = map(int, input().split())

l = []

if x <= y:
  l.append(y-x)
  
if -x <= y:
  l.append(y + x + 1)
  
if x <= -y:
  l.append(-y-x+1)
  
if -x <= -y:
  l.append(-y+x+2)
  
print(min(l))
Buggy code:
def main():
    x,y = map(int,input().split())
    ans = 0
    if x <0 and y < 0:
        if x <= y:
            print(abs(y-x))
            return
        else:
            print(abs(x-y)+2)
            return
    elif x > 0 and y > 0:
        print(abs(x-y) +1)
        return
    else:
        print(abs(x-y))
    #
    # if x * y < 0:
    #     ans += 1
    # elif x< 0 and y < 0:
    #     ans += 2
    # ans += abs(y) - abs(x)
    # print(ans)

if __name__ == '__main__':
    main()


Fixed code:
def main():
    x,y = map(int,input().split())
    ans = 0
    if x==0 :
        ans = abs(x-y)
        if y < 0:
            ans +=1
        print(ans)
        return
    elif y == 0:
        ans = abs(x-y)
        if x> 0:
            ans += 1
        print(ans)
    elif (x>=0 and y >= x) or (y<=0 and x<=y):
        print(abs(y-x))
        return
    elif (y>=0 and x >= y) or (x<=0 and y<=x):
        print(abs(y-x) + 2)
        return
    elif (x>0 and y<0)or(x<0 and y>0):
        print(abs(abs(y)-abs(x))+1)
    # print(ans)
if __name__ == '__main__':
    main()
Buggy code:
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

X, Y = lr()
answer = 10 ** 10
if X <= Y:
    answer = Y-X
if -X < Y:
    answer = min(answer, 1+X+Y)
if X < -Y:
    answer = min(answer, 1-Y-X)
if -X < -Y:
    answer = min(answer, 2-Y+X)

print(answer)


Fixed code:
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

X, Y = lr()
answer = 10 ** 10
if X <= Y:
    answer = Y-X
if -X <= Y:
    answer = min(answer, 1+X+Y)
if X <= -Y:
    answer = min(answer, 1-Y-X)
if -X <= -Y:
    answer = min(answer, 2-Y+X)

print(answer)
Buggy code:
x,y = map(int,input().split())

a = y-x if y-x >= 0 else float("inf")
b = y+x+1
c = x-y+2 if x-y >=0 else float('inf')

print(min(a,b,c))



Fixed code:
x,y = map(int,input().split())

a = y-x if y-x >= 0 else float("inf")
b = y+x+1 if y+x >= 0 else float("inf")
c = x-y+2 if x-y >=0 else float('inf')
d = -(y+x)+1 if x+y <=0 else float('inf')

print(min(a,b,c,d))
Buggy code:
x,y = map(int, input().split())

ans = abs(abs(x)-abs(y))
if x > y and abs(x) != abs(y) and x*y > 0:
	ans+=2
elif x*y < 0 or (x>y and x==0) or (x>y and y==0):
	ans+=1a

print(ans)


Fixed code:
x,y = map(int, input().split())

ans = abs(abs(x)-abs(y))
if x > y and abs(x) != abs(y) and x*y > 0:
	ans+=2
elif x*y < 0 or (x>y and x==0) or (x>y and y==0):
	ans+=1

print(ans)
Buggy code:
x,y=map(int,input().split())
ans=float('inf')
if x<=y: ans=min(ans,y-x)
elif -x<=y: ans=min(ans,y+x+1)
elif x<=-y: ans=min(ans,-y-x+1)
elif -x<=-y: ans=min(ans,-y+x+2)
print(ans)


Fixed code:
x, y = map(int, input().split())
ans = float('inf')
if x <= y:
    ans = min(ans, y - x)
if (-1) * x <= y:
    ans = min(ans, y + x + 1)
if x <= (-1) * y:
    ans = min(ans, -y - x + 1)
if (-1) * x <= (-1) * y:
    ans = min(ans, -y + x + 2)
print(ans)
Buggy code:
x,y=map(int,input().split())
ans=10**10
for i in range(2):
  for j in range(2):
    x*=(1-2*i)
    y*=(1-2*j)
    if x<=y:
      if ans>y-x+i+j:
        ans=y-x+i+j
print(ans)

Fixed code:
X,Y=map(int,input().split())
ans=10**10
for i in range(2):
  for j in range(2):
    x=(1-2*i)*X
    y=(1-2*j)*Y
    if x<=y:
      if ans>y-x+i+j:
        ans=y-x+i+j
print(ans)
Buggy code:
x,y=map(int,input().split())
z=abs(abs(x)-abs(y))
if z==0:print(1)
elif abs(x)>abs(y):
    if x>0 and y>0:print(z+2)
    elif (x==0 and y>0) and (x<0 and y==0) and (x<0 and y<0):print(z)
    else:print(z+1)
else:
    if x<0 and y<0:print(z+2)
    elif (x==0 and y>0) and (x<0 and y==0) and (x>0 and y>0):print(z)
    else:print(z+1)

Fixed code:
x,y=map(int,input().split())

z=abs(abs(x)-abs(y))

if x * y < 0 :
    print(z+1)
elif x *y ==0:
    if y > x :
        print(z)
    else:
        print(z+1)
elif y >= x:
    print(z)
else:
    print(z+2)
Buggy code:
x,y = map(int,input().split())

if y<x<0 or 0<y<x:
    print(abs(x-y)+2)
elif y<x=0 or 0=y<x:
    print(abs(x-y)+1)
elif x<=y<=0 or 0<=x<=y:
    print(abs(x-y))
elif x<0<y or y<0<x:
    print(abs(abs(x)-abs(y))+1)

Fixed code:
x,y=map(int,input().split())
cnt=0
if x<0<y or y<=0<=x:
    cnt=1
elif 0<y<x or y<x<0:
    cnt=2
print(abs(abs(x)-abs(y))+cnt)
Buggy code:
# -*- coding: utf-8 -*-
x, y = map(int, input().split())
ans = 0
if x == y:
    print(ans)

elif x > 0 and y > 0:
    if x < y:
        ans = y - x
        print(ans)
    
    else:
        ans = x - y + 2
        print(ans)
    
elif x < 0 and y < 0:
    if x <= y:
        ans = abs(x) - abs(y)
        print(ans)
    
    else:
        ans = abs(x) - abs(y) + 2
        print(ans)

elif x > 0 and y < 0:
    if x <= abs(y):
        ans = abs(y) - x + 1
        print(ans)
    else:
        ans = x - abs(y) + 1
        print(ans)
    
elif x < 0 and y > 0:
    if abs(x) <= y:
        ans = y - abs(x) + 1
        print(ans)
    else:
        ans = abs(x) - y + 1
        print(ans)
    
elif x == 0 and y != 0:
    if y > 0:
        ans = y
        print(ans)
    else:
        ans = abs(y) + 1
        print(ans)
    
elif x != 0 and y == 0:
    if x > 0:
        ans = x + 1
        print(ans)
    else:
        ans = abs(y)
        print(ans)

Fixed code:
# -*- coding: utf-8 -*-
x, y = map(int, input().split())
ans = 0
if x == y:
    print(ans)

elif x > 0 and y > 0:
    if x < y:
        ans = y - x
        print(ans)
    
    else:
        ans = x - y + 2
        print(ans)
    
elif x < 0 and y < 0:
    if x <= y:
        ans = abs(x) - abs(y)
        print(ans)
    
    else:
        ans = abs(y) - abs(x) + 2
        print(ans)

elif x > 0 and y < 0:
    if x <= abs(y):
        ans = abs(y) - x + 1
        print(ans)
    else:
        ans = x - abs(y) + 1
        print(ans)
    
elif x < 0 and y > 0:
    if abs(x) <= y:
        ans = y - abs(x) + 1
        print(ans)
    else:
        ans = abs(x) - y + 1
        print(ans)
    
elif x == 0 and y != 0:
    if y > 0:
        ans = y
        print(ans)
    else:
        ans = abs(y) + 1
        print(ans)
    
elif x != 0 and y == 0:
    if x > 0:
        ans = x + 1
        print(ans)
    else:
        ans = abs(x)
        print(ans)
Buggy code:
x, y = map(int, input().split())

px = 0
if x >= 0:
    px = 1
    
py = 0
if y >= 0:
    py = 1

x = abs(x)
y = abs(y)
ans = max(x,y) - min(x,y)
if px and py:
    if x or y == 0:
        ans += 1
    elif x > y:
        ans += 2
elif px or py:
    ans += 1
else:
    if x < y:
        ans += 2
print(ans)

Fixed code:
x, y = map(int, input().split())

px = 0
if x >= 0:
    px = 1
    
py = 0
if y >= 0:
    py = 1

x = abs(x)
y = abs(y)
ans = max(x,y) - min(x,y)
if x == 0 and py or px == 0 and y == 0:
    pass
elif px and py:
    if y == 0:
        ans += 1
    elif x > y:
        ans += 2
elif px or py:
    ans += 1
else:
    if x < y:
        ans += 2
print(ans)
Buggy code:
def main():
    x,y = map(int,input().split())
    ans = 0
    if x>y and y > 0:
        ans +=1
    elif x< y and y < 0:
        ans+=2
    elif x> 0 and y < 0:
        
        ans += 1
    ans += abs(x) - abs(y)
    print(ans)
if __name__ == '__main__':
    main()


Fixed code:
def main():
    x, y = map(int, input().split())

    if 0 <= x <= y or x <= y <= 0:
        ans = abs(abs(x) - abs(y))

    elif x <= 0 <= y or y <= 0 <= x:
        ans = abs(abs(x) - abs(y)) + 1

    elif y < x < 0 or 0 < y < x:
        ans = abs(abs(x) - abs(y)) + 2

    print(ans)


if __name__ == "__main__":
    main()
Buggy code:
x,y = (int(i) for i in input().split())

case = [(x*1,y*1,0),(x*(-1),y*1,1),(x*1,y*(-1),1),(x*(-1),y*(-1),2)]
ans = float('inf')

for c in case:
    x,y = c[0],c[1]
    print(x,y)
    if y>=x: ans = min(ans,y-x+c[2])
print(ans)


Fixed code:
x,y = (int(i) for i in input().split())

case = [(x*1,y*1,0),(x*(-1),y*1,1),(x*1,y*(-1),1),(x*(-1),y*(-1),2)]
ans = float('inf')

for c in case:
    x,y = c[0],c[1]
    if y>=x: ans = min(ans,y-x+c[2])
print(ans)
Buggy code:
x, y = map(int, input().split())
diff = abs(abs(x)-abs(y))

if x*y > 0:
  diff += 2
elif x+y < 0:
  diff += 1
elif abs(x) == abs(y):
  if x*y < 0:
    diff = 1
  

print(diff)

Fixed code:
x, y = map(int,input().split())
diff = abs(abs(x)-abs(y))
sgn = 0
if x == 0 or y == 0:
    if x > y:
        sgn += 1
elif x*y < 0:
    sgn += 1
elif x > y:
    sgn += 2

print(diff + sgn)
Buggy code:
x, y = map(int, input().split())
dist = abs(abs(x) - abs(y))
if x <= y:
  x, y = y, x
if x + dist == y:
  ans = dist
elif - x + dist == y:
  ans = dist + 1
elif - x + dist == -y:
  ans = dist + 2
elif x + dist == -y:
  ans = dist + 1
print(ans)

Fixed code:
x, y = map(int, input().split())
dist = abs(abs(x) - abs(y))

if x + dist == y:
  ans = dist
elif - x + dist == y:
  ans = dist + 1
elif x + dist == -y:
  ans = dist + 1
elif - x + dist == -y:
  ans = dist + 2

print(ans)
Buggy code:
x,y=map(int,input().split())
if x=0:print(abs(y)+(y<0))
elif y=0:print(abs(x)+(x>0))
elif 0<x<y or x<y<0:print(abs(y-x))
elif 0<y<x or y<x<0:print(2+abs(x-y))
else:print(abs(abs(x)-abs(y))+1)

Fixed code:
x, y = map(int, input().split())

if x <= y:
    if x >= 0 or y <= 0:
        cnt = abs(abs(x) - abs(y))
    else:
        cnt = abs(abs(x) - abs(y)) + 1
else:
    if x < 0 or y > 0:
        cnt = abs(abs(x) - abs(y)) + 2
    else:
        cnt = abs(abs(x) - abs(y)) + 1

print(cnt)
Buggy code:
x, y = map(int,input().split())
if x <= y:
    ans = y - x
else:
    x = -x
    ans = 1
    ans += min((abs(y) - abs(x)), abs(x - y) + 1)

print(ans)

Fixed code:
x, y = map(int, input().split())
if x < y:
    ans = min(y - x,  abs(x + y) + 1)
else:
    ans = min(abs(x + y) + 1, (x - y) + 2)
print(ans)
Buggy code:
x,y=map(int,input().split())
ans=float('inf')
if x<=y: ans=min(ans,y-x)
elif -x<=y: ans=min(ans,y+x+1)
elif x<=-y: ans=min(ans,-y-x+1)
else: ans=min(ans,-y+x+2)
print(ans)


Fixed code:
x, y = map(int, input().split())

ans = float("inf")
if x < y:
    ans = min(ans, y - x,  abs(x + y) + 1)
else:
    ans = min(ans, abs(x + y) + 1, (x - y) + 2)

print(ans)
Buggy code:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    x,y=map(int,input().split())
    if x==-y:
        print(1)
    elif x*y>0:
        if x<y:
            print(y-x)
        else:
            print(x-y+2)
    elif x*y<0
        print(abs(x+y)+1)
    else:
        if x>0:
            print(x+1)
        elif x<0:
            print(-x)
        elif y>0:
            print(y)
        else:
            print(-y+1)

if __name__=='__main__':
    main()

Fixed code:
import sys
input=sys.stdin.readline

def main():
    x,y = map(int,input().split())
    if x == y:
        print(0)
    elif x >= 0:
        if y > 0:
            if y > x:
                print(y-x)
            else:
                print(x-y+2)
        else:
            print(1+abs(abs(x)-abs(y)))
    else:
        if y > 0:
            if abs(y) > abs(x):
                print(1+y-abs(x))
            else:
                print(1+(abs(x)-y))
        else:
            if x < y:
                print(y-x)
            else:
                print(2+x-y)

if __name__ == '__main__':
    main()
Buggy code:
x,y=map(int,input().split())
if abs(x)==abs(y):
  print(1)
elif if x<y:
  print(abs(x-y))
else:
  print(abs(x-y)+2)
  

Fixed code:
x, y = map(int, input().split())
if 0 <= x <= y:
  r = y-x
elif x <= y <= 0:
  r = y-x
elif x <= 0 <= y:
  r = 1+abs(x+y)
elif y <= 0 <= x:
  r = 1+abs(x+y)
elif 0 <= y < x:
  r = 2+x-y
elif y < x <= 0:
  r = 2+x-y
else:
  r = -1
print(r)
Buggy code:

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


if y > x:
	if abs(x) > abs(y):
		a = y-x
	else:
		a = min(y-x, y-abs(x)+1)
else:
	a = abs(abs(x) - abs(y)) + 1

print (a)




Fixed code:
x,y=map(int,input().split())
if y>x:
    a=y-x
else:
    a=x-y+2
if y>=-x:
    a=min(a,y+x+1)
else:
    a=min(a,-y-x+1)
print(a)
Buggy code:
x, y = map(int, input().split())
ans = []
if x < y:
    ans.append(y - x)
x *= -1
if x < y:
    ans.append(y - x + 1)
y *= -1
if x < y:
    ans.append(y - x + 2)
print(min(ans))


Fixed code:
X,Y=map(int,input().split())
ans=[]
x=X
y=Y
if x<=y:
    ans.append(y-x)
x*=-1
if x<=y:
    ans.append(y-x+1)
y*=-1
if x<=y:
    ans.append(y-x+2)
x*=-1
if x<=y:
    ans.append(y-x+1)
print(min(ans))
Buggy code:
# 2019/08/14

x,y=map(int,input().split())
ans=abs(abs(x)-abs(y))
if (x<0 and y<0) or (x>0 and y>0):
    if x>y:ans+=2
else:
    if abs(x)!=abs(y):
        ans+=1
print(ans)

Fixed code:
# 2019/08/14

x,y=map(int,input().split())
ans=abs(abs(x)-abs(y))

if (x<0 and y<0) or (x>0 and y>0):
    if x>y :ans+=2
elif x!=0 and y!=0:
    ans+=1
else:
    if y<=0 and x>y:
        ans+=1

print(ans)
Buggy code:
x, y = map(int, input().split())
ans = 0
if abs(x) == abs(y):
    if x * y > 0:
        ans = 0
    elif x < 0 and y > 0:
        ans = 1
    else:
        ans += y - x
elif abs(x) < abs(y):
    if x >= 0 and y >= 0:
       ans = y - x
    elif x >= 0 and y < 0:
        ans += abs(y) - x
        ans += 1
    elif x < 0 and y >= 0:
        ans += y - x
    else:
        ans += 1
        ans += x - y
        ans += 1
else:
    if x >= 0 and y > 0:
        ans += 1
        ans += x - y
        ans += 1
    elif x >= 0 and y <= 0:
        ans += 1
        ans += x + y
    elif x < 0 and y >= 0:
        ans += 1
        ans += y + x
    else:
        ans += y - x
print(ans)

Fixed code:
x, y = map(int,input().split())

ans = abs(abs(x)-abs(y))
if x * y > 0 and y >= x:
    pass
elif x * y < 0:
    ans += 1
elif x * y == 0:
    if x > y:
        ans += 1
else:
    ans += 2
print(ans)
Buggy code:
x,y = map(int,input().split())
if x <= y:
    ans = y - x
if x <= -y:
    ans = -y-x+1
if -x <= y:
    ans = y + x + 1
if -x <= -y:
    ans = -y + x + 2
print(ans)


Fixed code:
x, y= map(int,input().split())
ans = 10000000000
if x <= y:
    ans = y-x
if -x <= y:
    ans = min(y+x+1,ans)
if x <= -y:
    ans = min(-y-x+1,ans)
if -x <= -y:
    ans = min(-y+x+2,ans)
print(ans)
Buggy code:
x,y=map(int,input().split())
a=abs(x)
b=abs(y)
if a>b:
    if x>0:
        if y>0:
            print(a-b+2)
        elif y==0:
            print(1+a)
        else:
            print(1+a-b)
    elif x==0:
        print(0)
    else:
        if y>0:
            print(a-b+1)
        elif y==0:
            print(a)
        else:
            print(a-b)
elif a<b:
    if x>0:
        if y>0:
            print(b-a)
        else:
            print(b-a+1)
    elif x==0:
        if y>0:
            print(b)
        else:
            print(b+1)
    else:
        if y>0:
            print(1+b-a)
        else:
            print(1+b-a+1)

Fixed code:
x,y=map(int,input().split())
if(abs(y)>=abs(x)):
    a=abs(y)-abs(x)
    if(x>=0):
        if(y<0):
            a+=1
    else:
        if(y>0):
            a+=1
        else:
            a+=2
else:
    a=abs(x)-abs(y)
    if(x>=0):
        if(y<=0):
            a+=1
        else:
            a+=2
    else:
        if(y>0):
            a+=1
print(a)
Buggy code:
from sys import stdin
import numpy as np
x,y = [int(x) for x in stdin.readline().rstrip().split()]
ans = [(y-x),(y-(-x))+1, (y-x)+2, (x-(-y))+1]
ans = np.array(ans)
ans = ans[ans > 0]
print(min(ans))

Fixed code:
from sys import stdin
import numpy as np
x,y = [int(x) for x in stdin.readline().rstrip().split()]
ans = [(y-x),(y-(-x))+1, (-y+x)+2, (-x-y)+1]
ans = np.array(ans)
ans = ans[ans > 0]
print(min(ans))
Buggy code:
x,y = map(int, input().split())
m = 10**9
for i in (0,1):
  for j in (0,1):
    if y*j-x*i>=0:
      cur = y*j-x*i + i + j
      if m>cur:
        m = cur
print(m)

Fixed code:
x,y = map(int, input().split())
m = 10**10
for i in (0,1):
  for j in (0,1):
    if y*(-1)**j-x*(-1)**i>=0:
      cur = y*(-1)**j-x*(-1)**i + i + j
      if m>cur:
        m = cur
print(m)
Buggy code:
x,y = map(int,input().split())
k = abs(abs(x)-abs(y))
if x < 0 and y <= 0 or x >= 0 and y > 0:
  if x > y:
    ans += 2
else:
  ans += 1
print(ans)

Fixed code:
x, y = map(int, input().split())
ans = 0
ans = abs(abs(x) - abs(y))
if x == y:
    print(0)
    exit()
if ans == 0:
    print(1)
    exit()
if x < 0 and y == 0:
    print(ans)
    exit()
if x > 0 and y == 0:
    print(ans + 1)
    exit()
if (x < 0 and y < 0) or (x >= 0 and y >= 0):
    if x > y:
        ans += 2
else:
    ans += 1

print(ans)
Buggy code:
a ,b= map(int,input().split())
ans ,x , y ,c= 0 ,int(math.sqrt(a * a)) ,int(math.sqrt(b * b)),0
if x == 0:
    x = 1
    c += 1
    if b < 0:
        c += 1 
elif y == 0:
    y = 1
    c += 1
if (a < 0 and b < 0) and (a > b):
    ans = abs(x - y)
    c += 2
elif (a < 0 and b > 0) or (a > 0 and b < 0):
    ans = abs(x - y)
    c += 1
else:
    ans = abs(x - y)
print(ans + c)

Fixed code:
import math
a ,b= map(int,input().split())
ans ,x , y ,c = 0 ,int(math.sqrt(a * a)) ,int(math.sqrt(b * b)),0
if x == 0:
    if b < a:
         c += 1 
elif y == 0:
    c += 1
    if a < b:
        c -= 1
if (a < 0 and b < 0) and (a > b):
    ans = abs(x - y)
    c += 2
elif (a < 0 and b > 0) or (a > 0 and b < 0):
    ans = abs(x - y)
    c += 1
else:
    ans = abs(x - y)
    if a > b and a > 0 and b > 0:
        c += 2
print(ans + c)
Buggy code:
x,y = map(int,input().split())

if x*y<0:print(abs(abs(x)-abs(y))+1)
elif x>=0 and x<y:print(y-x)
elif x>=0 and y>=0 and y<x:print(x-y+2)
elif x<y<=0:print(y-x)
elif y<x<=0:print(abs(x)-abs(y)+2)



Fixed code:
x,y = map(int, input().split())

ans = abs(abs(x)-abs(y))

if x*y>0 and y<x:
    ans += 2
elif x*y<0 or y<x:
    ans += 1

print(ans)
Buggy code:
x,y = map(int,input().split())

if y<x<0 or 0<y<x:
    print(abs(x-y)+2)
elif (y<x and x=0) or (y=0 and y<x):
    print(abs(x-y)+1)
elif x<=y<=0 or 0<=x<=y:
    print(abs(x-y))
elif x<0<y or y<0<x:
    print(abs(abs(x)-abs(y))+1)

Fixed code:
x,y=map(int,input().split())
ans=abs(abs(x)-abs(y))
if x*y<0:
  ans+=1
elif 0<y<x or y<x<0:
  ans+=2
elif x*y==0 and y<x:
  ans+=1
print(ans)