qyliang/CodeNanoFix huggingface dataset:
Buggy code:
k,s=map(int,input().split())
ans=0

for x in range(k+1):
    for y in range(k+1):
       if s-(x+y)<=k:
           ans+=1
print(ans)

Fixed code:
k,s=map(int,input().split())
ans=0

for x in range(k+1):
    for y in range(k+1):
       if 0<=s-(x+y)<=k:
           ans+=1
print(ans)
Buggy code:
import numpy as np

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

ans = 0
if np.sign(x) == np.sign(y):
    if x == y:
        ans = 0
    elif x < y:
        ans = abs(y) - abs(x)
    else:
        ans = abs(x) - abs(y) + 2
else:
    if x == -y:
        ans = 1
    elif x < y:
        ans = abs(y) - abs(x) + 1
    else:
        ans = abs(x) - abs(y) + 2

print(ans)

Fixed code:
import numpy as np
x,y = map(int,input().split())
if abs(x)<abs(y):
  if x<0 and y<0:
    print(abs(y)-abs(x)+2)
  elif x>=0 and y>=0:
    print(y-x)
  else:
    print(abs(y)-abs(x)+1)
elif abs(x)>abs(y):
  if x<0 and y<=0:
    print(abs(x)-abs(y))
  elif x>=0 and y>0:
    print(x-y+2)
  else:
    print(abs(x)-abs(y)+1)
else:
  if np.sign(x)==np.sign(y):
    print(0)
  else:
    print(1)
Buggy code:
x, y = map(int, input().split())
ans = 10 ** 9 + 3
if y >= x:
    ans = min(ans, abs(y - x))
if - y >= x:
    ans = min(ans, abs(-y - x) + 1)
if y >= -x:
    ans = min(ans, abs(y + x) + 1)
if - y >= -x:
    ans(min(ans, abs(-y + x) + 2))
print(ans)

Fixed code:
x, y = map(int, input().split())
ans = 10 ** 9 + 3
if y >= x:
    ans = min(ans, abs(y - x))
if - y >= x:
    ans = min(ans, abs(-y - x) + 1)
if y >= -x:
    ans = min(ans, abs(y + x) + 1)
if - y >= -x:
    ans=min(ans, abs(-y + x) + 2)
print(ans)
Buggy code:
x,y=map(int,input().split())

ans =0

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

print(ans)


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

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

if (x < 0) == (y > 0):
  ans += 1
elif (x > y):
  ans += 2

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

elif x > y and 0 >= y:
    if ay > ax and x >= 0:
        a = ay - x + 1
    elif ay > ax and x < 0:
        a = ay + x + 2
    else:
        a = 1
elif y > x and x < 0:
    if ay > ax:
        a = ay - ax + 1
else:
    a = y-x
print(a)

Fixed 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)
Buggy code:
x, y = map(int, input().split())
if x < y:
    print(min(y - x, abs(y) - abs(x) + 1))
else:
    print(min(abs(x) - y + 1, abs(y) - abs(x) + 2))


Fixed code:
x, y = map(int, input().split())
print(min(y-x, abs(y+x)+1) if x<y else min(-y+x+2, abs(y+x)+1))
Buggy code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    x, y = map(int, input().split())
    inf = float('inf')
    r1 = y - x if y - x > 0 else inf
    r2 = y - -x + 1 if y - -x > 0 else inf
    r3 = -y - x + 1 if -y - x > 0 else inf
    r4 = -y - -x + 2 if -y - -x > 0 else inf
    r = min(r1, r2, r3, r4)
    print(r)

if __name__ == '__main__':
    main()

Fixed code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    x, y = map(int, input().split())
    inf = float('inf')
    r1 = y - x if y - x >= 0 else inf
    r2 = y - -x + 1 if y - -x >= 0 else inf
    r3 = -y - x + 1 if -y - x >= 0 else inf
    r4 = -y - -x + 2 if -y - -x >= 0 else inf
    r = min(r1, r2, r3, r4)
    print(r)

if __name__ == '__main__':
    main()
Buggy code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    x, y = map(int, input().split())
    if x < y:
        if 0 < y and 0 < x:
            print(y - x)
        elif 0 < x and 0 < y:
            print(y - abs(x) + 1)
        elif y == 0:
            print(-x)
        elif x == 0:
            print(y)
        else:
            print(y - x)
    else:
        if 0 < y and 0 < x:
            print(x * 2 - (x - y) + 1)
        elif y < 0 and 0 < x:
            print(x - abs(y) + 1)
        elif y == 0:
            print(x + 1)
        elif x == 0:
            print(-y + 1)
        else:
            print((x - y) + 2)

if __name__ == '__mai

Fixed code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    x, y = map(int, input().split())
    if x < y:
        if y == 0:
            print(-x)
        elif x == 0:
            print(y)
        elif 0 < x and 0 < y:
            print(y - x)
        elif x < 0 and 0 < y:
            print(abs(y - abs(x)) + 1)
        else:
            print(y - x)
    else:
        if y == 0:
            print(x + 1)
        elif x == 0:
            print(-y + 1)
        elif 0 < y and 0 < x:
            print(x - y + 2)
        elif y < 0 and 0 < x:
            print(abs(x - abs(y)) + 1)
        else:
            print((x - y) + 2)

if __name__ == '__main__':
    main()
Buggy code:
x,y = map(int,input().split())
ans = 10000000000
for a,b,c in [(x,y,0)(x,-y,1)(-x,y,1)(-x,-y,2)]:
    if a < b:
        ans = min(ans,b-a+c)
print(ans)

Fixed code:
x,y = map(int,input().split())
ans = 10000000000
for a,b,c in [(x,y,0),(x,-y,1),(-x,y,1),(-x,-y,2)]:
    if a <= b:
        ans = min(ans,b-a+c)
print(ans)
Buggy code:
def main():
    x, y = map(int, input().split())

    if x == y:
        print(0)

    elif abs(x) == abs(y):
        print(1)

    elif x < y:
        c1 = y - x
        c2 = abs(x) - y  + 1
        print(min(c1, c2))

    elif x > y:
        if x <= 0 and y <= 0:
            c1 = abs(y) - x + 1
            c2 = abs(y) - abs(x) + 2
            print(min(c1, c2))

        elif x <= 0 and y >= 0:
            pass

        elif x >= 0 and y <= 0:
            print(max(abs(x), abs(y)) - min(abs(x), abs(y)) + 1)
            
        elif x >= 0 and y >= 0:
            print(x - y + 2)

if __name__ == "__main__":
    main()

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

    if x == y:
        print(0)

    elif abs(x) == abs(y):
        print(1)

    elif x < y:
        if x >= 0 and y >= 0:
            print(y - x)

        elif x >= 0 and y <= 0:
            pass

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

        elif x <= 0 and y <= 0:
            print(abs(x) - abs(y))

    elif x > y:
        if x <= 0 and y <= 0:
            c1 = abs(y) - x + 1
            c2 = abs(y) - abs(x) + 2
            print(min(c1, c2))

        elif x <= 0 and y >= 0:
            pass

        elif x >= 0 and y <= 0:
            print(max(abs(x), abs(y)) - min(abs(x), abs(y)) + 1)
            
        elif x >= 0 and y >= 0:
            print(x - y + 2)

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

count1 = abs(y + x) + 1
count2 = abs(y - x)
count3 = abs(x - y + 2)

print(min(count1, count2, count3))

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

count1 = abs(y + x) + 1
count2 = max(y - x, x - y + 2)

print(min(count1, count2))
Buggy code:
x, y = map(int, input().split())
if (x > 0 and y < 0) or (x < 0 and y > 0):
    print(abs(abs(x)-abs(y))+1)
else:
    print(abs(abs(x)-abs(y)))


Fixed code:
x, y = list(map(int, input().split()))
if x < y:
    if x < 0 and y > 0:
        res = abs(abs(x) - y) + 1
    else:
        res = y - x
else:
    res = abs(abs(x) - abs(y)) + 1 + int((x < 0 and y < 0) or (x > 0 and y > 0))
print(res)
Buggy code:
def resolve():
    '''
    code here
    '''
    x, y = [int(item) for item in input().split()]

    if abs(x) == abs(y):
        res = 1
    elif abs(x) > abs(y):
        if x < 0:
            res = abs(x) - abs(y)
            if y < 0:
                pass
            else:
                res += 1
        else:
            res = 1
            res += abs(x) - abs(y)
            if y < 0:
                res += 1
            else:
                pass
    else:
        if x < 0:
            res = 1
            res += abs(x) - abs(y)
            if y > 0:
                pass
            else:
                res += 1
        else:
            res = abs(x) - abs(y)
            if y < 0:
                res += 1
            else:
                pass
    print(res)

if __name__ == "__main__":
    resolve()


Fixed code:
def resolve():
    '''
    code here
    '''
    x, y = [int(item) for item in input().split()]
    res = 0

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

    res += abs(abs(x) - abs(y))


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

    print(res)

if __name__ == "__main__":
    resolve()
Buggy code:
x, y = map(int, input().split())
d = abs(abs(x) - abs(y))
if 0 <= x < y or x < y <= 0:
  print(d)
elif y <= 0 <= x or x < 0 < y:
  print(d+1)
else
  print(d+2)

Fixed code:
x, y = map(int, input().split())
d = abs(abs(x) - abs(y))
if 0 <= x < y or x < y <= 0:
  print(d)
elif y < 0 < x or x < 0 < y:
  print(d+1)
elif 0 < y < x or y < x < 0:
  print(d+2)
elif y == 0 < x or y < x == 0:
  print(d+1)
else:
  raise Exception
Buggy code:
x,y=map(int,input().split())
if x*y >0:
  k=2
else:
  k=1
if x==y:
  print(0)
elif x<y:
  print(min(y-x,abs(abs(y)-abs(x))+k))
else:
  print(min(x-y,abs(abs(y)-abs(x)) + k))

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

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

Fixed code:
def main():
    x, y = map(int, input().split())
    print(min(max(y-x, x-y+2), abs(x+y)+1))
if __name__ == '__main__':
    main()
Buggy code:
def main():
    x, y = map(int, input().split())
    print(min(x+y, ~x+y)+1)
if __name__ == '__main__':
    main()

Fixed code:
def main():
    x, y = map(int, input().split())
    print(min(abs(x+y), abs(~x+y))+1)
if __name__ == '__main__':
    main()
Buggy code:
def main():
    x, y = map(int, input().split())
    A = abs(abs(x) - abs(y))

    if x * y > 0:
        if x < y:
            B = 0
        else:
            B = 2
    elif x == 0:
        if x < y:
            B = 0
        else:
            B = 1
    elif y == 0:
        if x < y:
            B = 0
        else:
            B = 1

    print(A + B)


if __name__ == "__main__":
    main()


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

    if x * y > 0:
        if x < y:
            B = 0
        else:
            B = 2
    elif x == 0:
        if x < y:
            B = 0
        else:
            B = 1
    elif y == 0:
        if x < y:
            B = 0
        else:
            B = 1
    else:
        B = 1

    print(A + B)


if __name__ == "__main__":
    main()
Buggy code:
import math
import collections
import fractions
import itertools

def solve():
    a, b = map(int, input().split())
    if a < b:
        if abs(a) <= b and a < 0:
            print(1+b-abs(a))
        else:
            print(b - a)
    else:
        if a < 0:
            print(2+a-b)
        else:
            print(1+a-b)
    return 0

if __name__ == "__main__":
    solve()

Fixed code:
import math
import collections
import fractions
import itertools

def solve():
    a, b = map(int, input().split())
    if abs(a) < abs(b):
        ans = abs(b)-abs(a)
        if a < 0:
            ans += 1
        if b < 0:
            ans += 1
        print(ans)
    else:
        ans = abs(a)-abs(b)
        if 0 < a:
            ans += 1
        if 0 < b:
            ans += 1
        print(ans)
    return 0

if __name__ == "__main__":
    solve()
Buggy code:
a,b=map(int,input().split())
ans=abs(a-b)
if a*b<0:ans+=1
elif a*b>0 and a>b:ans+=2
print(ans)

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

ans += abs(abs(a) - abs(b))
print(ans)

Fixed code:
a,b = map(int,input().split())
val = 0
if a*b < 0:
    val += 1
elif (a>0 and b==0) or (a==0 and b<0):
    val += 1
elif b < a:
    val += 2
val += abs(abs(a)-abs(b))
print(val)
Buggy code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

x,y = iim()
'''
if y>=x:
    if x*y>=0:
        ans = y-x
    else:
        ans = y-abs(x)+1
else:
    if y == 0:
        ans = x+1
    elif x*y>0:
        ans = x-y+2
    else:
        ans = abs(y)-x+1
print(ans)
'''
if x==0:
    ans = abs(y)
    if y < 0:
        ans += 1
elif y==0:
    ans = abs(x)
    if x > 0:
        ans += 1
else:
    ans = abs(y-x)
    if x*y>0 and x>y:
        ans += 2
    elif x*y<0 and x>y:
        ans += 1
print(ans)

Fixed code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

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


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

if b > a >= 0 or a < b <= 0:
    print(abs(a-b))
elif a > b > 0 or 0 > a > b:
    print(abs(a-b)+2)
else:
    print(abs(abs(a)-abs(b))+1)
Buggy code:
import sys

x, y = map(int, input().split())
cnt = 0
if abs(x) == abs(y):
    print(1)
elif abs(x) < abs(y):
    while x <= 0:
        x *= -1
        cnt += 1
    while abs(x) != abs(y):
        x += abs(y) - abs(x)
        cnt += abs(y) - abs(x)
    if x == y:
        print(cnt)
    else:
        print(cnt+1)
else:
    while x >= 0:
        x *= -1
        cnt += 1
    while abs(x) != abs(y):
        x += abs(x) - abs(y)
        cnt += abs(x) - abs(y)
    if x == y:
        print(cnt)
    else:
        print(cnt+1)

Fixed code:
import sys

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

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

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

print(res)
Buggy code:
a,b = map(int, input().split())
ans = abs(abs(a) - abs(b))
sign = inc = 0
if a*b < 0:
    sign = 1
if a-b < 0:
    inc = 1

if a==0 and b==0:
    print(0)
    exit()
elif a==0:
    if inc == 1:
        ans += 1
        print(ans)
        exit()
else:
    if inc == 0:
        ans += 1
        print(ans)
        exit()

if sign == 0 and inc == 0:
    ans += 2
elif sign == 0 and inc == 1:
    pass
else:
    ans += 1
print(ans)

Fixed code:
a,b = map(int, input().split())
ans = abs(abs(a) - abs(b))
sign = inc = 0
if a*b < 0:
    sign = 1
if a-b < 0:
    inc = 1

if a==0 and b==0:
    print(0)
    exit()
elif a==0:
    if inc == 0:
        ans += 1
        print(ans)
        exit()
elif b==0:
    if inc == 0:
        ans += 1
        print(ans)
        exit()

if sign == 0 and inc == 0:
    ans += 2
elif sign == 0 and inc == 1:
    pass
else:
    ans += 1
print(ans)
Buggy code:
def main():
    x, y = list(map(int, input().split()))
    if x < y:
        if x >= 0 and y >= 0:
            ans = y - x
        elif x < 0 and y < 0:
            ans = y - x
        else:
            ans1 = y - x
            if abs(x) <= y:
                ans2 = y - abs(x) + 1
                ans = min(ans1, ans2)
            else:
                ans = ans1
    else:
        if x >= 0 and y >= 0:
            ans = x + y + 1
        elif x < 0 and y < 0:
            if abs(x) <= abs(y):
                ans = x - y + 2
            else:
                ans = abs(y - x) + 1
        else:
            ans = y - x + 1

    print(ans)


if __name__ == "__main__":
    main()

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


if __name__ == '__main__':
    main()
Buggy code:
X, Y = map(int, input().split())

if 0 < X < Y or X < Y < 0:
    print(Y-X)
elif 0 < Y < X or Y < X < 0:
    print(2+X-Y)
elif X < 0 < Y or Y < 0 < X:
    print(1+abs(X-Y))

if X == 0 and Y < 0:
    print(abs(Y)+1)
elif Y == 0 and X > 0:
    print(abs(X)+1)


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

if 0 <= X < Y or X < Y <= 0:
    print(Y-X)
elif 0 < Y < X or Y < X < 0:
    print(2+X-Y)
elif X < 0 < Y or Y < 0 < X:
    print(1+abs(X+Y))

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

ans = 10**18

if y - x >= 0:
    ans = min(ans, y-x)

x *= -1

if y - x >= 0:
    ans = min(ans, y-x)

x *= -1
y *= -1

if y - x >= 0:
    ans = min(ans, y-x)

x *= -1

if y - x >= 0:
    ans = min(ans, y-x)

print(ans)

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

ans = 10**18

if y - x >= 0:
    ans = min(ans, y-x)

x *= -1

if y - x >= 0:
    ans = min(ans, y-x+1)

x *= -1
y *= -1

if y - x >= 0:
    ans = min(ans, y-x+1)

x *= -1

if y - x >= 0:
    ans = min(ans, y-x+2)

print(ans)
Buggy code:
x, y = map(int, input().split())
ans = 0
x2 = -x
y2 = -y
L = [y - x, y - x2, y2 - x, y2 - x2]
Labs = [abs(y - x), abs(y - x2), abs(y2 - x), abs(y2 - x2)]
ans += min(Labs)
i = L.index(min(Labs))
print(i)
if i == 1 or i == 2:
    ans += 1
elif i == 3:
    ans += 2
print(ans)


Fixed code:
x, y = map(int, input().split())
ans = 0
x2 = -x
y2 = -y
L = [y - x, y - x2, y2 - x, y2 - x2]
Labs = [abs(y - x), abs(y - x2), abs(y2 - x), abs(y2 - x2)]
ans += min(Labs)
i = L.index(min(Labs))
if i == 1 or i == 2:
    ans += 1
elif i == 3:
    ans += 2
print(ans)
Buggy code:
x, y = map(int, input().split())
ans = 10 ** 10
for i in range(2):
    for j in range(2):
        a = x
        b = y
        cnt = 0
        if i == 1:
            a *= -1
            cnt = 1
        if j == 1:
            b *= -1
            cnt += 1
        if a >= b:
            continue
        cnt += b - a
        a += b - a¥
        if a == b:
            ans = min(ans, cnt)

print(ans)


Fixed code:
x, y = map(int, input().split())
ans = 10 ** 10
for i in range(2):
    for j in range(2):
        a = x
        b = y
        cnt = 0
        if i == 1:
            a *= -1
            cnt = 1
        if j == 1:
            b *= -1
            cnt += 1
        if a > b:
            continue
        cnt += b - a
        a += b - a
        #print(cnt, a, b)
        if a == b:
            ans = min(ans, cnt)

print(ans)
Buggy code:
def answer(x, y):
    absX = abs(x)
    absY = abs(y)
    a = abs(absY - absX)
    # 0인 경우는 좀 다르게 취급된다
    if x == 0:
        if y > 0:
            return y-x
        else:
            return -y+1
    if y == 0:
        if x > 0:
            return 1+x
        else:
            return -x
        
    # 둘다 양수
    if (x > 0 and y > 0):
        if absX < absY:
            return y-x
        else:
            return 1+(x-y)+1
    if (x < 0 and y > 0):
        if absX < absY:
            return 1+(y+x)
        else:
            return (y-x)
    if (x > 0 and y < 0):
        if absX < absY:
            return -(y+x)+1
        else:
            return 1+(x+y)
    if (x < 0 and y < 0):
        if absX < absY:
            return 1+(y+x)*-1+1
        else:
            return y-x

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

Fixed code:
def answer(x, y):
    absX = abs(x)
    absY = abs(y)
    a = abs(absY - absX)
    # 0인 경우는 좀 다르게 취급된다
    if x == 0:
        if y > 0:
            return y
        else:
            return -y+1
    if y == 0:
        if x > 0:
            return 1+x
        else:
            return -x
        
    # 둘다 양수
    if (x > 0 and y > 0):
        if absX < absY:
            return y-x
        else:
            return 1+(x-y)+1
    if (x < 0 and y > 0):
        if absX < absY:
            return 1+(y+x)
        else:
            return -(x+y)+1
    if (x > 0 and y < 0):
        if absX < absY:
            return -(y+x)+1
        else:
            return 1+(x+y)
    if (x < 0 and y < 0):
        if absX < absY:
            return 1+(x-y)+1
        else:
            return y-x

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


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

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

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

print(min(abs(y-x),abs(x+y)+1,abs(x-y)+2))


Fixed code:
x,y=map(int,input().split())
print(min(max(y-x,-y+x+2),abs(y+x)+1))