qyliang/CodeNanoFix huggingface dataset:
Buggy code:
n,a,b=map(int,input().split())
ans=0
if (b-a)%2 == 0:
	ans = (b-a)//2
else:
	ans = min(n-a, b-1, (b-a-1)//2
print(ans)

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

if (b-a)%2 == 0:
  print((b-a)//2)
else:
  print(min(a-1,n-b)+1+(b-a-1)//2)
Buggy code:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,a,b=map(int,input().split())
    if (b-a)%2==0:print((b-a)//2)
    else:print(min((b-a+1)//2,(2*n-b+1-a)//2))

if __name__=='__main__':
    main()

Fixed code:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,a,b=map(int,input().split())
    if (b-a)%2==0:print((b-a)//2)
    else:print(min((b+a-1)//2,(2*n-b+1-a)//2))

if __name__=='__main__':
    main()
Buggy code:
N,A,B = map(int, input().split())
if A-B%2 ==0:
  print(A/B/2)
else:
  print(min(A-1,N-B)+1+(B-A-1)/2)


Fixed code:
N, A, B = map(int, input().split())

if abs(A - B) % 2 == 0:
    print(abs(A - B) // 2)
else:
    print(min(A-1, N-B) + 1 + (B-A-1)//2)
Buggy code:
N, A, B = map(int, input().split())

if abs(A - B)%2 == 0:
    print(abs(A - B)//2)
else:
    print(abs(A - B)//2 + 1)




Fixed code:
N, A, B = map(int, input().split())

dist = abs(A - B)
if dist % 2 == 0:
    print(dist//2)
else:  
    print(min(A - 1, N - B) + 1 + (dist - 1)//2)
Buggy code:
N,A,B = map(int,input().split())

C = B-A

if C % 2 == 0:
    print(C//2)
else:
    a = min(A-1, N-B) + 1 + (B-A+1)//2
    print(a)



Fixed code:
N, A,B = map(int,input().split())
if (A-B)%2 == 0:
    print((B-A)//2)
else:
    print(min((N-A),(B-1),(N-B+1+(B-A-1)//2),(B-A-1)//2+A))
Buggy code:
n, a, b = map(int, input().split())

if (b - a) % 2 == 0:
    print(int((b-a)/2))
else:
    print(min(b-1, n-a)+1+int((b-a-1)/2))

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

s = (b - a) // 2

if (b - a) % 2 == 0:
  print(s)

if (b - a) % 2 == 1:
  print(min(a-1,n-b) + s + 1)
Buggy code:
n, a, b = map(int, input().split())

ans = float('inf')
if (b - a) % 2 == 0:
    ans = min(ans, (b - a) // 2)
else:
    ans = min(ans, b - 1)
    ans = min(ans, n - a)
    ans = min(ans, (b - a - 1) // 2)
print(ans)


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

ans = float('inf')
if (b - a) % 2 == 0:
    ans = min(ans, (b - a) // 2)
else:
    ans = min(ans, b - 1)
    ans = min(ans, n - a)
    ans = min(ans, (b - a - 1) // 2 + n - b + 1)
    ans = min(ans, (b - a - 1) // 2 + a)
print(ans)
Buggy code:
N, *AB = [int(x) for x in input().split()]
A, B = sorted(AB)
print(A, B)
if (B - A) % 2 == 0:
    ans = (B - A) // 2
else:
    ans = (B - A + 2 * min(N - B, A - 1) + 1) // 2
print(ans)

Fixed code:
N, *AB = [int(x) for x in input().split()]
A, B = sorted(AB)
if (B - A) % 2 == 0:
    ans = (B - A) // 2
else:
    ans = (B - A + 2 * min(N - B, A - 1) + 1) // 2
print(ans)
Buggy code:
N, A, B = map(int, input().split())

if A % 2 == B % 2:
    print((A - B)  // 2)
else:
    print(min(B-1, N-A))

Fixed code:
N, A, B = map(int, input().split())
if (B - A) % 2:
    print(min(A - 1, N - B) + (B + 1 - A) // 2)
else:
    print((B - A) // 2)
Buggy code:
# coding: utf-8


def main():
    N, A, B = map(int, input().split())

    ans = (B - A) / 2 if (B - A) % 2 == 0 else min(A - 1, N - B) + 1 + (B - A - 1) / 2

    print(ans)

if __name__ == "__main__":
    main()


Fixed code:
# coding: utf-8


def main():
    N, A, B = map(int, input().split())

    ans = (B - A) // 2 if (B - A) % 2 == 0 else min(A - 1, N - B) + 1 + (B - A - 1) // 2

    print(ans)

if __name__ == "__main__":
    main()
Buggy code:
n,a,b=map(int,input().split())
if (a+b)%2==0:
    print(abs(a-b))
else:
    
    temp=min(b-1,n-a)
    print(temp)

Fixed code:
n,a,b=map(int,input().split())
if (a+b)%2==0:
    print(abs(a-b)//2)
else:
    
    temp=min(b-1,n-a)
    if temp==b-1:
        ans=(b+a-1)//2
    else:
        
        ans=(n+1-b+n+1-a-1)//2
    print(ans)
Buggy code:
n,a,b = map(int,input().split())

d = b - a
if d % 2 == 0:
  print(d//2)
else:
  ans = min(a,n-b)+d//2
  if d == 1:
    ans += 1
  print(ans)

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

d = b - a
if d % 2 == 0:
  print(d//2)
else:
  ans = min(a,n-b+1)+d//2
  print(ans)
Buggy code:

n,a,b = map(int,input().split())
diff = abs(a-b)
if diff%2==0:
    print(diff//2)
else:
    print(min(a-1,n-b)+1+(b-a-1)/2)


Fixed code:
n,a,b=map(int,input().split())
if (a-b)%2==0:
    print(abs(a-b)//2)
else:
    print(min(a,b,n-a+1,n-b+1)+(abs(a-b)-1)//2)
Buggy code:
X = input().split()
N = int(X[0])
A = int(X[1])
B = int(X[2])

if (B - A) % 2 == 0:
    print((B - A) // 2)
elif 2*B < N:
    print(B-1)
elif 2*A > N:
    print(N - A)
else:
    if N-A <= B-1:
        m = N - B + 1 + ((B-A-1)//2)
    else:
        m = A - 1 + 1 +((B -A - 1)//2)

Fixed code:
X = input().split()
N = int(X[0])
A = int(X[1])
B = int(X[2])

if (B - A) % 2 == 0:
    print((B - A) // 2)
elif 2*B < N:
    print( A + ((B-A-1)//2) )
elif 2*A > N:
    print( N - B + 1 + ((B-A-1)//2) )
else:
    if (N-A <= B-1):
        print( N - B + 1 + ((B-A-1)//2) )
    else:
        print( A + ((B-A-1)//2) )
Buggy code:
N,A,B = map(int,input().split())
if (B-A)%2 == 0:
  print((B-A)//2)
else:
  print((B-A)//2 +1 )

Fixed code:
N, A, B = map(int, input().split())

if (B-A) % 2 == 1:
    print(min(A-1, N-B)+1+(B-A-1)//2)
else:
    print((B-A)//2)
Buggy code:
N, A, B = map(int, input().split())
D = B - A
if D % 2 == 0:
    print(D // 2)
else:
    print(D // 2 + 1)


Fixed code:
N, A, B = map(int, input().split())
D = B - A
if D % 2 == 0:
    print(D // 2)
else:
    print((D - 1) // 2 + min(A - 1, N - B) + 1)
Buggy code:
N,A,B=[int(x) for x in input().split()]

if (B-A)%2==0:
    print(int((B-A)/2))

else:
    if min(N-A,B-1) < min((B-A-1)/2 + A, (N-(A+N-(B+1))/2 + N-B+1)):
        print(int(min(N-A,B-1)))
    if min(N-A,B-1) > min((B-A-1)/2 + A, (N-(A+N-(B+1))/2 + N-B+1)):
        print(int(min((B-A-1)/2 + A, (N-(A+N-(B+1))/2 + N-B+1))))


Fixed code:
N,A,B=[int(x) for x in input().split()]

if (B-A)%2==0:
    print(int((B-A)//2))

else:
    if B-1 <= N-A:
        print(int(min((B-A-1)//2+A,B-1)))
    if B-1 > N-A:
        print(int(min(N-A, (N-(A+N-B+1))//2 + N-B+1)))
Buggy code:
n,a,b=map(int,input().split())
if (a-b)%2==0:
  print(abs((a-b)//2))
else:
  c = max(n-a,n-b)
  d = max(a-1,b-1)
  e = min(n-a,n-b)
  f = min(a-1,b-1)
  g = min(e,f)
  h = g + (abs(a-b)+1)//2
  print(min(c,d,g))

Fixed code:
n,a,b=map(int,input().split())
if (a-b)%2==0:
  print(abs((a-b)//2))
else:
  c = max(n-a,n-b)
  d = max(a-1,b-1)
  e = min(n-a,n-b)
  f = min(a-1,b-1)
  g = min(e,f)
  h = g + (abs(a-b)+1)//2
  print(min(c,d,h))
Buggy code:
N , A , B = map(int, input().split())
c = 0

if A%2 == B%2:
    print((B-A)//2)
else:
    if N - B > A-1:
        c += N - B
        c += 1
        c += (B-A-1)//2
        print(c)
    else:
        c += A-1
        c += 1
        c += (B-A-1)//2
        print(c)


Fixed code:
N , A , B = map(int, input().split())
c = 0

if A%2 == B%2:
    print((B-A)//2)
else:
    if N - B < A-1:
        c += N - B
        c += 1
        c += (B-A-1)//2
        print(c)

    else:
        c += A-1
        c += 1
        c += (B-A-1)//2
        print(c)
Buggy code:
N, A, B = map(int, input().split())

if (B-A)%2==0:
  ans = (B-A)/2
else:
  if A<N-B:
    ans = A + (B-A-1)/2
  else:
    ans = N-B+1 + (N-(A+N-B+1))/2
    
print(int(ans))

Fixed code:
N, A, B = map(int, input().split())

if (B-A)%2==0:
  ans = (B-A)//2
else:
  if A-1<N-B:
    ans = A + (B-A-1)//2
  else:
    ans = N-B+1 + (N-(A+N-B+1))//2
    
print(ans)
Buggy code:
n,a,b = map(int,input().split())
s = abs(a-b)
if s % 2 == 0:
    print(s // 2)
else:
    print(s // 2 + 1)

Fixed code:
n,a,b = map(int,input().split())
s = abs(a-b)
if s % 2 == 0:
    print(s // 2)
else:
    print(min(a-1,n-b)+1+((b-a-1) // 2))
Buggy code:
n,a,b = map(int,input().split())
if (a+b)%2==0:
    print(diff//2)
else:
    print(min(a-1,n-b)+1+(b-a-1)//2)


Fixed code:
n,a,b = map(int,input().split())
diff = abs(a-b)
if diff%2==0:
    print(diff//2)
else:
    print(min(a-1,n-b)+1+(b-a-1)//2)
Buggy code:
    N, A, B = [int(i) for i in input().split()]
    ans = []
    if (B-A)%2 == 0:
        print(int((B-A)/2))
    else:
        print(int((B-A)//2+1+min([A-1,N-B])))

Fixed code:
N, A, B = [int(i) for i in input().split()]
ans = (B-A)//2
if (B-A) % 2 == 1:
    ans += min(A-1, N-B)+1
print(ans)
Buggy code:
n,a,b = list(map(int, input().split()))
sa = b-a-1

if sa%2!=0:
  print(min(b-1, n-a))
else:
  print(int(sa/2))

Fixed code:
n,a,b = list(map(int, input().split()))
sa = b-a
if sa%2==0:
  print(int(sa//2))
else:
  print(min(a-1,n-b) + 1 + int((sa-1)//2))
Buggy code:
n,a,b = list(map(int, input().split()))
sa = b-a
if sa%2==0:
  print(int(sa/2))
else:
  print(int(sa/2)+1+min(b-1,n-a))

Fixed code:
n,a,b = list(map(int, input().split()))
if (b-a)%2==0:
  print(int((b-a)//2))
else:
  print(min(a-1,n-b) + 1 + int((b-a-1)//2))
Buggy code:
N,A,B = map(int,input().split())
if(abs(A-B)%2 == 0):
  print(abs(A-B)//2)
else:
  print((abs(A-B)+1)//2)

Fixed code:
N, A, B = map(int, input().split())

if (B - A) % 2 == 0:
    print((B-A) // 2)
else:
    print(min(A - 1, N - B) + 1 + (B-A) // 2)
Buggy code:
n, a, b = map(int, input().split())
if a>b:
  a, b = b, a;
r = b-a
if r%2==0:
  print(r//2)
else:
  res = min(a-1, n-b) + r+1
  print(res)
  

Fixed code:
n, a, b = map(int, input().split())
if a>b:
  a, b = b, a;
r = b-a
if r%2==0:
  print(r//2)
else:
  r = (b-a-1)//2
  res = min(a-1, n-b) + r+1
  print(res)
Buggy code:
N,A,B=map(int,input().split())
if (A-B)%2==0:
  ans=int((A-B)/2)
else:
  ans=min(B-1,N-A)
print(ans)

Fixed code:
N,A,B = map(int, input().split())
if (B-A)%2 == 0:
    print((B-A)//2)
else:
    print(min(A,N-B+1)+(B-A)//2)
Buggy code:
n,a,b=map(int,input().split())
d=b-a-1
if d%2:print(-(-d//2))
else:
    print(min(n-b,a-1)+1+(d-1)//2)

Fixed code:
n,a,b=map(int,input().split())
d=b-a
if d%2==0:print(-(-d//2))
else:
    print(min(n-b,a-1)+1+(d-1)//2)
Buggy code:
n, a, b = map(int, input().split())

if (b - a) % 2 == 0:
  print((b-a)//2)
else:
  print(min(a-1, n-b) + 1 + ((b-a-1)//2)

Fixed code:
n,a,b = map(int, input().split())
if (b-a)%2==0:
    ans = (b-a)//2
else:
    ans = min(n-a, b-1)
    ans = min(ans, min(a-1, n-b) + (b-a-1)//2 + 1)
    # ans = ((b-a)+2-1)//2 + 1
print(ans)
Buggy code:
N,A,B=map(int,input().split())
if (B-A)%2==1:
   a=min(A-1,N-B)+1
   b=(B-A)-1//2
   print(a+b)

elif (B-A)%2==0:
   print((B-A)//2)

Fixed code:
N,A,B=map(int,input().split())
if (B-A)%2==1:
   a=min(A-1,N-B)+1
   b=((B-A)-1)//2
   print(a+b)

elif (B-A)%2==0:
   print((B-A)//2)
Buggy code:
N,A,B = map(int, input().split())

if abs(A-B)%2 == 0:
	print(abs(A-B)//2)
else:
	ans = min(
		max(A-1,B-1),
		max(N-A, N-B),
		A-1 + abs(A-1-(B-(A-1)))//2,
		N-B + abs(N-B-(A+(N-B)))//2
	)
	ans = min(
		max(A-1,B-1),
		max(N-A, N-B),
		A-1 + abs(A-1-(B-(A-1)-1))//2,
		N-B + abs(N-B-(A+(N-B)))//2
	)
	print(ans)

Fixed code:
N,A,B = map(int, input().split())

if abs(A-B)%2 == 0:
	print(abs(A-B)//2)
else:
	ans = min(
		A-1 + (B-A-1)//2 +1,
		N-B + (B-A-1)//2 +1
	)
	print(ans)
Buggy code:
N,A,B = [int(x) for x in input().split()];
print(A);
print(B);
print(N);
#lm = int(A + (B-A-1)/2);
lm = A + int((B-A-1)/2);
#print(lm);
#rm = int(N-B+1 + (B-A-1)/2);
rm = N-B+1 + int((B-A-1)/2);
#print(rm);
if (B-A)%2 == 0 :
    print(int((B-A)/2));
else :
    print(min(lm,rm));

Fixed code:
N,A,B = [int(x) for x in input().split()];
#print(A);
#print(B);
#print(N);
#lm = int(A + (B-A-1)/2);
lm = A + (B-A-1)//2;
#print(lm);
#rm = int(N-B+1 + (B-A-1)/2);
rm = N-B+1 + (B-A-1)//2;
#print(rm);
if (B-A)%2 == 0 :
    print((B-A)//2);
else :
    print(min(lm,rm));
Buggy code:
N, A, B = map(int, input().split())

if (B - A)%2 == 0:
    print((B - A)//2)
else:
    if A - 1 > N - B and B - A - 1 != 0:
        print((B - A - 1)//2 + A - 1)
    elif  A - 1 <= N - B and B - A - 1 != 0:
        print((B - A - 1)//2 + N - B)
    elif A - 1 > N - B:
        print(A)
    else:
        print(N - B + 1)


Fixed code:
N, A, B = map(int, input().split())

if (B - A)%2 == 0:
    print((B - A)//2)
else:
    if A - 1 > N - B and B - A - 1 != 0:
        print((B - A + 1)//2 + N - B)
    elif  A - 1 <= N - B and B - A - 1 != 0:
        print((B - A + 1)//2 + A - 1)
    elif A - 1 > N - B and B - A - 1 == 0:
        print(N - B + 1)
    else:
        print(A)
Buggy code:
N, A, B = map(int, input().split())

if abs(A-B) % 2 == 0:
    print(abs(A-B)//2)
else:
    top = (B-A-1)//2 + A-1
    low = (B-A-1)//2+N-B
    print(min(top, low))


Fixed code:
N, A, B = map(int, input().split())

if abs(A-B) % 2 == 0:
    print(abs(A-B)//2)
else:
    top = (B-A-1)//2 + A-1
    low = (B-A-1)//2+N-B
    print(min(top, low)+1)
Buggy code:
n,a,b=map(int,input().split())
if (b-a)%2==0:
  print(int((b-a)/2))

  print(int((b-a-1)/2+a))
else:
  print(int((b-a-1)/2+min(a-1,n-b)+1))

Fixed code:
n,a,b=map(int,input().split())
if abs(a-b)%2==0:
  print(abs(a-b)//2)
else:
  print(min(a-1,b-1,n-a,n-b)+(abs(a-b)+1)//2)
Buggy code:
n, a, b = map(int, input().split())

if (b - a) % 2 == 0:
  print(int(b - (a+b)/2))
else:
  if (a - 1) >= (n - b):
    print((n-b) + 1 + int(n - (n+a+(n-b)+1)/2))
  else:
    print("a")
    print((a-1) + 1 + int(b-(a-1)-1 - (b-(a-1)-1 + 1)/2))
    

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

if (b - a) % 2 == 0:
  print(b - (a+b)//2)
else:
  if (a - 1) > (n - b):
    print((n-b) + 1 + (b-a-1)//2)
  else:
    print((a-1) + 1 + (b-a-1)//2)
Buggy code:
N, A, B = map(int, input().split())

if abs(B - A) % 2 == 0:
    print(abs(B - A))
else:
    print(max(A - 1, N - B) + 1 + (B - A - 1) / 2)


Fixed code:
N, A, B = map(int, input().split())

if abs(B - A) % 2 == 0:
    print(abs(B - A) // 2)
else:
    print(min(A - 1, N - B) + 1 + (B - A - 1) // 2)
Buggy code:
N, A, B = map(int, input().split())

if abs(B - A) % 2 == 0:
    print(abs(B - A) / 2)
else:
    print(min(A - 1, N - B) + 1 + (B - A - 1) / 2)


Fixed code:
N,A,B=map(int,input().split())
if (B-A)%2==0:
    print((B-A)//2)
else:
    print(min((B+A-1)//2,((2*N-B+1-A)//2)))
Buggy code:
N,A,B= map(int,input().split())
if (B-A)%2 == 0:
  print((B-A)//2)
else:
  print(min(A,B-N)+1+(B-A-1)//2)


Fixed code:
N, A, B = map(int, input().split())
if (B - A) % 2:
    d = min(A - 1, N - B)
    print(d + 1 + (B - A - 1) // 2)

else:
    print((B - A) // 2)
Buggy code:
in_string = input()
in_arr = in_string.split()
N = in_arr[0]
A = in_arr[1]
B = in_arr[2]

if ((B-A) % 2) == 0:
    print((B-A)/2)
else:
    if (N-B) > A-1:
        print(int(A+((B-A)-1)/2))
    else:
        print(int(N-B+1+((N-(A+N-B+1))/2)))
        

Fixed code:
in_string = input()
in_arr = in_string.split()
N = int(in_arr[0])
A = int(in_arr[1])
B = int(in_arr[2])

if ((B-A) % 2) == 0:
    print(int((B-A)//2))
else:
    if (N-B) > A-1:
        print(int(A+(B-A-1)//2))
    else:
        print(int(N-B+1+((N-(A+N-B+1))//2)))
Buggy code:
N, A, B = map(int, input().split())

if (B - A) % 2 == 0:
    print((B-A) // 2)
else:
    if A-1 <= N-B:
        A = 1
        B = B - A
        print((B-A) // 2 + A)
    else:
        A = A + (N-B+1)
        B = N
        print((B-A) // 2 + (N-B+1))

Fixed code:
N, A, B = map(int, input().split())

if (B - A) % 2 == 0:
    print((B-A) // 2)
else:
    if A-1 <= N-B:
        count = A
        A = 1
        B = B - count
        print((B-A) // 2 + count)
    else:
        count = (N-B+1)
        A = A + count
        B = N
        print((B-A) // 2 + count)
Buggy code:
N, A, B = map(int,input().split())
if (B-A)%2 == 0:
  answer = int((B-A)/2)
else:
  answer = min(A-1, N-B)+1+int(B-A-1)/2

print(answer)

Fixed code:
N, A, B = map(int,input().split())

if abs(A - B) % 2 == 0:
    print(abs(A - B) // 2)
else:
    print(min(A-1, N-B) + 1 + (B-A-1) // 2)
Buggy code:
n,a,b = map(int,input().split())
if (b-a)%2==0:
    print((b-a)//2)
else:
    ret1 = a+(b-a+1)//2
    ret2 = n-b+1+(b-a-1)//2
    print(min(ret1, ret2))

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

if (b-a)%2 == 0:
    print((b-a)//2)
else:
    print(min(a-1, n-b) + 1 + (b-a-1)//2)
Buggy code:
N, A, B = map(int,input().split())
if (B-A)%2 == 0:
  answer = int(B-A/2)
else:
  answer = min(int((A+B-1)/2), int((2*N-A-B+1)/2))

print(answer)

Fixed code:
N, A, B = map(int,input().split())
if (B-A)%2 == 0:
  answer = int((B-A)//2)
else:
  answer = min(int(A+B-1)//2, int(2*N-A-B+1)//2)
print(answer)
Buggy code:
N, A, B = map(int,input().split())
if (B-A)%2 == 0:
  answer = int((B-A)/2)
else:
  #answer = min(int(N-A), int(B-1))
  answer = int(N-A)
  
print(answer)

Fixed code:
N, A, B = map(int,input().split())
if (B-A)%2 == 0:
  answer = int((B-A)//2)
else:
  answer = min(A-1, N-B)+1+int((B-A-1)//2)

print(answer)
Buggy code:
N,A,B=map(int,input().split())
if (A-B)%2==0:
  print((A-B)/2)
  exit()

print(min((A+B-1)//2,(N-B+N-A+1)//2))

Fixed code:
N,A,B=map(int,input().split())
if (A-B)%2==0:
  print((B-A)//2)
  exit()

print(min((A+B-1)//2,(N-B+N-A+1)//2))
Buggy code:
n, a, b = map(int, input().split())

if a - b % 2 == 0:
    print(abs(a-b)//2)
else:
    print(min(b-1, n-a))

Fixed code:
n,a,b=map(int,input().split())
if (b-a)%2 == 0:
 print((b-a)//2)
else:
 print(min(a-1,n-b)+1+(b-a-1)//2)
Buggy code:
n,a,b=map(int,input().split())
if (b-a)%2 == 0:
 print((b-a)/2)
else:
 print(min(a-1,n-b))


Fixed code:
n, a, b = map(int, input().split())
if (b-a)%2==0:
    print((b-a)//2)
else:
    t_eg = min(a-1,n-b)
    print(t_eg+1+(b-a-1)//2)
Buggy code:
n, a, b = map(int, input().split())

if (b-a) % 2 == 0:
    ans = (b-a)/2
else:
    if a-1 = n-b:
        ans = a+((b-a-1)/2)
    elif a-1 == n-b:
        ans = n/2
    else:
        ans = n-b+1+((b-a-1)/2)

print(int(ans))

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

if (b-a) % 2 == 0:
    ans = (b-a)//2
else:
    if (a-1) < (n-b):
        ans = a+((b-a-1)//2)
    elif (a-1) == (n-b):
        ans = n/2
    else:
        ans = n-b+1+((b-a-1)//2)

print(int(ans))
Buggy code:
N,A,B=map(int,input().split())

if A%2==B%2:
    print(int(abs(A-B)/2))
else:
    print(min(int((N-A-B)/2),int((A+B-1)/2)))

Fixed code:
N, A, B = map(int, input().split())
if abs(A - B) % 2 == 0:
    ans = (abs(A - B)) // 2
else:
    ans = min(A - 1, N - B) + 1 + (abs(A - B) - 1) // 2
print(ans)
Buggy code:
n, a, b = map(int, input().split())
if (a - b) % 2 == 0:
    print(abs(a - b) // 2)
else:
    print(min((n - a + n - b + 1) // 2, (a - 1 + b - 1) // 2))


Fixed code:
n, a, b = map(int, input().split())
if (a - b) % 2 == 0:
    print(abs(a - b) // 2)
else:
    print(min((n - a + n - b + 1) // 2, (a - 1 + b - 1 + 1) // 2))
Buggy code:
def main():
    N, A, B = [int(i) for i in input().split()]
    diff = B - A
    if diff % 2 == 0:
        ans = diff // 2
    else:
        ans = min(B - 1, N - A, (A - 1) + 1 + (diff - 1) // 2, (N - B) + 1 (diff - 1) // 2)
    print(ans)


if __name__ == '__main__':
    main()


Fixed code:
def main():
    N, A, B = [int(i) for i in input().split()]
    diff = B - A
    if diff % 2 == 0:
        ans = diff // 2
    else:
        ans = min(B - 1, N - A, (A - 1) + 1 + (diff - 1) // 2, (N - B) + 1 + (diff - 1) // 2)
    print(ans)


if __name__ == '__main__':
    main()
Buggy code:
N,A,B = map(int,input().split()) 
if abs(A-B)%2==0 :
	print((B-A)/2)
else:
	print(min(N-A,B-1))

Fixed code:
N,A,B = map(int,input().split()) 
if abs(A-B)%2==0 :
	print((B-A)//2)
else:
	print((B-A-1)//2+min(A,N-B+1))
Buggy code:
N, A, B = map(int, input().split())

if ((B-A)+1)%2==0:
    print(B-1)
else:
    print((B-A)/2)


Fixed code:
N,A,B = map(int,input().split())
if (A-B)%2==0:
  print((B-A)//2)
else:
  print(min((A+B)//2,(N*2-A-B)//2+1))
Buggy code:
n,a,b=map(int,input().split())
if (b-a)%2==0:
  print((b-a)//2)
else:
  c=min(b-1,n-a)
  d=(b-a-1)//2+1
  print(min(c,d))

Fixed code:
n,a,b=map(int,input().split())
if (b-a)%2==0:
  print((b-a)//2)
else:
  c=min(b-1,n-a)
  e=min(a-1,n-b)
  d=(b-a-1)//2+e+1
  print(min(c,d))
Buggy code:
n,a,b = map(int, input().split())
if ((a+b)%2 == 0):
    print(int((max(a,b) - min(a,b))/2))
else:
    print(min(n-max(a,b),min(a,b)-1))

Fixed code:
n,a,b = map(int,input().split())
if (b-a)%2==0:
  print((b-a)//2)
else:
  print(min((a-1)+1+(b-a-1)//2,(n-b)+1+(b-a-1)//2))
Buggy code:
N, A, B = map(int, input().split(' '))


# N, A, B = 10 ** 18, 1, 10 ** 18
# N, A, B = 5, 2, 5


def main(n, a, b):
    # print(n, a, b)
    distance = b - a

    if distance % 2 == 0:
        return distance // 2
    else:
        if a == 1:
            return b
        if b == n:
            return n - a
        else:
            if (a + b) / 2 <= n / 2:
                return b
            else:
                return a

print(main(N, A, B))


Fixed code:
N, A, B = map(int, input().split(' '))


# N, A, B = 10 ** 18, 2, 10 ** 18
# N, A, B = 9, 5, 8


def main(n, a, b):
    distance = b - a

    if distance % 2 == 0:
        return distance // 2
    else:
        return min(a-1, n-b) + 1 + (distance - 1) //2

        # if a - 1 == n - b:
        #     return b - 1
        # if a < n - b + 1:
        #     return (a - 1) + (b - a) // 2 + 1
        # if n - a > n - b:
        #     return (n - b) + (b - a) // 2 + 1


print(main(N, A, B))
Buggy code:
N, A, B = map(int, input().split())
ans = 0
if (B - A) % 2 == 0:
	ans = (B - A) // 2
else:
	if N - A >= B - 1:
		dis = N - B + 1
		ans = dis + (N - (A+dis)) //2
	else:
		dis = A - 1 + 1
		ans = dis + ((B-dis) - 1) //2
print(ans)

Fixed code:
N, A, B = map(int, input().split())
ans = 0
if (B - A) % 2 == 0:
	ans = (B - A) // 2
else:
	if N - A >= B - 1:
		dis = A - 1 + 1
		ans = dis + ((B-dis) - 1) //2
		
		
	else:
		
		dis = N - B + 1
		ans = dis + (N - (A+dis)) //2

print(ans)
Buggy code:
strargs = input()

n, a, b = map(lambda x: int(x), strargs.split())

if (b - a) % 2 == 0:
  print((b - a)//2)
  
elif a - 1 < n - b:
  mid = (b - a) - 1
  print(a + mid - 1)

else:
  newA = (a + (n - b + 1))
  mid = newA + (n - newA)//2
  print((n - b + 1) + (n - newA)//2)

Fixed code:
strargs = input()

n, a, b = map(lambda x: int(x), strargs.split())

if (b - a) % 2 == 0:
  print((b - a)//2)
  
elif a - 1 < n - b:
  newB = b - a
  print(a + (newB-1)//2)

else:
  newA = (a + (n - b + 1))
  print((n - b + 1) + (n - newA)//2)
Buggy code:
strargs = input()

n, a, b = map(lambda x: int(x), strargs.split())

if (b - a) % 2 == 0:
  print((b - a)//2)
  
elif a - 1 < n - b:
  mid = (b - a) - 1
  print(a + mid -1)

else:
  mid = n - (a + (n - b + 1))
  print(n - b + 1 + n - mid)

Fixed code:
strargs = input()

n, a, b = map(lambda x: int(x), strargs.split())

if (b - a) % 2 == 0:
  print((b - a)//2)
  
elif a - 1 < n - b:
  newB = b - a
  mid = (newB - 1)//2 + 1
  print(a + mid - 1)

else:
  newA = (a + (n - b + 1))
  mid = newA + (n - newA)//2
  print((n - b + 1) + (n - newA)//2)
Buggy code:
N, A, B = map(int, input().split())
sa = B - A
if sa % 2 == 0:
  print(int(sa/2))
else:
  print(min(N -A, B -1) -1)

Fixed code:
N, A, B = map(int, input().split())
sa = B - A
if sa % 2 == 0:
   print(int(sa//2))
else:
   print(int(min(A -1,N -B) + 1 + (B- A)//2))
Buggy code:
n , a , b = map(int, input().split())

if abs(b-a) % 2 == 0:
    print(abs(b-a)//2)
else:
    print(abs(b-a)//2 + (a + b)//2 - 1)

Fixed code:
n, a, b = map(int, input().split(' '))
if (a - b) % 2 == 0:
    print(abs(a - b) // 2)
else:
    print((b - a - 1) // 2 + (b - a) % 2 + min(n - b, a - 1))
Buggy code:
n,a,b=map(int,input().split())
if (b-a)%2==0:
    print((b-a)//2)
else:
    print(min(n-a,a-1))

Fixed code:
n , a , b = map(int, input().split())
 
if (b-a) % 2 == 0:
    print((b-a)//2)
else:
    print(min(a-1, n-b) + (b-a-1)//2 +1)
Buggy code:
import math
N, a, b = map(int, input().strip().split())

if (b-a)%2==0:
    ans=int(math.raound((b-a)/2))
else:
    ans=min(a-1,N-b)+math.ceil((b-a)/2)
print(ans)

Fixed code:
import math
N, a, b = map(int, input().strip().split())

if (b-a)%2==0:
    ans=(b-a)//2
else:
    ans=min(a-1,N-b)+1+(b-a)//2
print(ans)
Buggy code:
N,A,B=map(int,input().split())
C=A+B

if C%2==0:
  print(C/2/)
else:
  dist_a=A-1
  dist_b=N-B
  base=min(dist_a,dist_b)
  print(base+(B-A+1)//2)

Fixed code:
N,A,B=map(int,input().split())
C=B-A

if C%2==0:
  print(C//2)
else:
  dist_a=A-1
  dist_b=N-B
  base=min(dist_a,dist_b)
  print(base+(B-A+1)//2)
Buggy code:
n,a,b=[int(x) for x in input().split()]

if (a-b)%2==0:
  print((a-b)//2)
else:
  print(min(a-1,n-b)+1+(b-a-1)//2)

Fixed code:
n,a,b=[int(x) for x in input().split()]

if (a+b)%2==0:
  print((b-a)//2)
else:
  print(min(a-1,n-b)+1+(b-a-1)//2)