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

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

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

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

if (A + B)%2 == 0:
    print(abs(A - B)//2)
else:
    print(min(A-1,N-B)+abs(A-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(A-1,N-B)+1+abs(A-B+1)//2)
Buggy code:
n, a, b = list(map(int, input().split()))

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


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

if (a-b) % 2 == 0:
    print(abs(a-b)//2)
else:
    x = ((a-1) + (b-1) + 1)//2
    y = ((n-a) + (n-b) + 1)//2
    print(min(x, y))
Buggy code:
N, a, b = map(int, input().split())
num = b - a
if num%2 == 0:
    half = num//2
    print(half)
else:
    edge = min(N-a, b-1)
    print(min((b-a-1)//2), edge)

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

Fixed code:
n,a,b=map(int,input().split())
if (b-a)%2==0:
    print(int((b-a)//2))
else:
    if a-1<n-b:
        #if a+int((b-a-1)/2)<b-1:        
        print(a+int((b-a-1)//2))
        #else:
         #   print(b-1)
    else:
       # if n-b+1+int((n-(a+n-b+1))/2)<n-a:
        print(n-b+1+int((n-(a+n-b+1))//2))
        #else:
         #   print(n-a)
Buggy code:
n,a,b=map(int,input().split())
if (b-a-1)%2==1:
    print((b-a-1)//2+1)
else:
    print(min(a-1,n-b)+1+(b-a-1)//2+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) // 2 + 1)
Buggy code:
# https://atcoder.jp/contests/agc041/tasks/agc041_a¥

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

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

Fixed code:
# https://atcoder.jp/contests/agc041/tasks/agc041_a¥

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

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

Fixed code:
n, a, b = map(int, input().split())
if (a-b)%2 == 0:
    print(abs(a-b)//2)
else:
    if a+b>=n+1:
        print(min([n-a, n-b])+1+(abs(a-b)-1)//2)
    else:
        print(min([a, b])+(abs(a-b)-1)//2)
Buggy code:
from sys import stdin
n,a,b = [int(x) for x in stdin.readline().rstrip().split()]

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

Fixed code:
from sys import stdin

n,a,b = [int(x) for x in stdin.readline().rstrip().split()]

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

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

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

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


Fixed code:
ma = lambda :map(int,input().split())

n,a,b = ma()
if (b-a)%2 ==0:
    print((b-a)//2)
else:
    print(min(a+ (b-a-1)//2, (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:
  l=[n-a,b-1]
  print(min(l))

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

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

if (b - a) % 2 == 1:
    print(min(b-1, n-a))
else:
    print((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 - 1, n - a, a + (b - a - 1) // 2, n - b + 1 + (b - a - 1) // 2))
Buggy code:
n,a,b = map(int,input().split())

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

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

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

if a % 2 == b % 2:
  print((b - a) / 2)
else:
  print(min(a + (b - a - 1) / 2, n - b + 1 + (n - (a + (n - 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) + (b-a)//2 + 1)
Buggy code:
import sys
input = sys.stdin.readline


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



if __name__ == "__main__":
    main()

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


def main():
    n,a,b = [int(i) for i in input().strip().split()]
    if (b-a) % 2 == 0:
        print(abs(b - a) // 2)
    else:
        ans = min(a - 1, n - b) + 1 + (b - a - 1) // 2
        print(ans)
    return 



if __name__ == "__main__":
    main()
Buggy code:
N, A, B = map(int,input().split())

if (A-B) % 2 == 0:
    ans = (B-A) / 2
else:
    if (A-1) < (N-B) or (A-1) == (N-B):
        count = A
        a = 1
        b = B - count
        count += (b-a)/2
    else:
        count = (N-B) + 1
        a = A + count
        b = N
        count += (b-a)/2
    ans = count

print(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):
        count = A
        a = 1
        b = B - count
        count += (b-a)//2
    else:
        count = (N-B) + 1
        a = A + count
        b = N
        count += (b-a)//2
    ans = count

print(ans)
Buggy code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

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


Fixed code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

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

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


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



Fixed code:
N, A, B = map(int, input().split())
C=B-A
D=min(A-1,N-B)+1 + (B - A - 1)//2
if C%2==1:
    print (D)
else:
    print(C//2)
Buggy code:
N,A,B = list(map(int,input().split()))
diff = B - A
N2B = N - B
N2A = N - A
sumN = N2A + N2B
sumAB = A + B
if diff % 2 == 0:
    print(diff // 2)
else:
    tmp = diff // 2
    if sumN < sumAB:
        if N2A < tmp:
            print(N2A)
        else:
            print(tmp + 1)
    else:
        if B-1 < tmp: 
            print(B - 1)
        else:
            print(tmp + 1)

Fixed code:
N,A,B = list(map(int,input().split()))
diff = B - A
N2B = N - B
N2A = N - A
sumN = N2A + N2B 
sumAB = A + B 


if diff % 2 == 0:
    print(diff // 2)
else:
    if N2B < A - 1:
        tmp = (N - (A + N2B))//2 + N2B
        if (N - A - N2B)%2 == 1:
            tmp = tmp + 1
        if N2A < tmp:
            print(N2A,"a")
        else:
            print(tmp)
    else:
        tmp = ((B + 1 - A) - 1)//2 + A - 1
        if ((B + 1 - A) - 1)%2 == 1:
            tmp = tmp + 1
        if B-1 < tmp: 
            print(B - 1)
        else:
            print(tmp)
Buggy code:
N, A, B = map(int, input().split())

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


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

if (B-A)%2 == 0:
    print((B-A)//2)
else:
    ans1 = A + (B-A-1)//2
    ans2 = N-B+1 + (N-(A+N-B+1))//2
    print(min(ans1, ans2))
Buggy code:
n, a, b = map(int, input().split())
if abs(a-b)%2 == 0:
  print((a-b)//2)
else:
  print(min((a+b)//2,(2*n-a-b+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+b)//2,(2*n-a-b+1)//2))
Buggy code:
N, A, B = map(int, input().split())

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

tmp1 = A
b = B - A
tmp1 += (B - 1) // 2

tmp2 = N - B
a = A + tmp2
tmp2 += (N - a) // 2

print (min(tmp1, tmp2) + 1)

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

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

tmp1 = A - 1
b = B - tmp1
tmp1 += (b - 1) // 2

tmp2 = N - B
a = A + tmp2
tmp2 += (N - a) // 2

print (min(tmp1, tmp2) + 1)
Buggy code:
N,A,B = map(int, input().split(" "))
distance = abs(B - A)
res=0
if distance % 2 == 0:
  res = distance/2
else:
  a,b = min(A,B), max(A,B)
  res = distance//2 + min(a-1, N-b)+1
print(res)

Fixed code:
N,A,B = map(int, input().split(" "))
distance = abs(B - A)
res=0
if distance % 2 == 0:
  res = distance//2
else:
  res = distance//2 + min(min(A,B)-1, N-max(A,B))+1
print(res)
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:
	print( (B-A) // 2 )
else:
	print(min([1+N-B+(B-A)//2, A+(B-A)//2]))
Buggy code:
n,a,b = map(int,input().split())
if (b-a)%2 == 0:
  print(min(b-a)//2,n-a,b-1))
else:
  print(min(n-a,b-1))

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

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

    print(min(first, last))

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

    print(min(first, last))
Buggy code:
N, A, B = map(int, input().split())
if (B - A) % 2 == 0:
    print((B - A) // 2)
else:
    if B - A == 1: 
        print(min(N-A, B-1))
    elif A == 1:
        print(1+(B-1-A)//2)
    elif B == N:
        print(1+(B-A-1)//2)
    else:
        print(min((A+(B-A-1)//2, 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(A-1, N-B)+1+(B-A-1)//2)
Buggy code:
n,a,b=map(int,input().split())
c=min(a,b)
d=max(a,b)
e=min(2*n-a-b,a+b-2)
f=min(c-1,n-d)
if d-c==1:
  print(f+1)
elif d-c%2==0:
  print((d-c)//2)
else:
  print((e+1)//2)

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

l = max(a,b)
s = min(a,b)

if (l-s)%2 == 0:
  print((l-s)//2)
else:
  t = s - 1
  b = n - l
  pre = min(t-b)
  ans = pre + 1 + (l-s-1)//2
  print(ans)
  

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

l = max(a,b)
s = min(a,b)

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


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


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

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

if (A%2==0 and A%2==0) or (A%2==1 and A%2==1):
  print((B-A)/2)

elif (A-1)<=(N-B):
  print(int(A-1+(B-A-1)/2))

else:
  print(int(N-B+(B-A-1)/2))

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

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

elif (A-1)<=(N-B):
  print(int(A+(B-A-1)//2))

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

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


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

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

print(answer)
Buggy code:
x,y,z = map(int, input().split())
if (z+y)%2==1:
  	d = min(y + z - 2, 2*x-y-z)+1; 
	print(d//2)
else:
	print((abs(y-z)+1)//2)


Fixed code:
x,y,z = map(int, input().split())
if (z+y)%2==1:
        d = min(y + z - 2, 2*x-y-z)+1
        print(d//2)
else:
	print((abs(y-z)+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+(b-a)//2,n-b+(b-a)//2))


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

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

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

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

if (b - a)% == 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())
diff = abs(a-b)
if diff % 2 == 0:
    print(diff // 2)
else:
    print(min(a-1, n-b) + 1 + (diff-1)//2)
Buggy code:
n, a, b = map(int, input().split())


if (b - a)%2 == 0:
    ans = (b - a) /2
    print(ans)
else:
    ans = min(a - 1, n - 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, n - b + 1) + (b - a - 1) // 2)
Buggy code:
N, A, B = map(int, input().split())
        
Y = int(B-A)

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


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

if Y%2 == 0:
    print(int(Y//2))
else:
    if A-1>=N-B:
        print(N-B+int((B-A-1)//2)+1)
    else:
        print(A-1+int((B-A-1)//2)+1)
Buggy code:
N,A,B=map(int,input().split(" ")) 
#N,A,B=map(float,input().split(" ")) 
if (B-A)%2==0:
    print(int(int(B-A)//2))
else:
    a1=int(min(int(N-1-A),int(B-1)))
    a2=int(int(A-1)+1+int(B-A-1)//2)
    a3=int(int(N-1-B)+1+int(B-A-1)//2)
    print(a1,a2,a3)
    print(min(a1,a2,a3))


Fixed code:
N,A,B=map(int,input().split(" ")) 
if (B-A)%2==0:
    print(int(int(B-A)//2))
else:
    a1=int(min(N-A,B-1))
    a2=int(int(A-1)+1+int(B-A-1)//2)
    a3=int(int(N-B)+1+int(B-A-1)//2)
    print(min(a1,a2,a3))
Buggy code:
n,a,b = map(int,input().split())
if not b-a % 2:
    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())
print((b-a)//2 + min(a-1,n-b) + 1 if (b-a)%2 else (b-a)//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 abs(b-a)%2==0:
  print(abs(b-a)//2)
else:
  print(min(min(a,b) + (b-a)//2, n-max(a,b) + (b-a)//2 + 1))
Buggy code:
n, a, b = map(int, input().split())

if (b - a) % 2 == 0:
    print(b - (a + b) // 2)
else:
    if a <= b - a:
        print(b - 1)
    else:
        print(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())
ans = 0

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

print(ans)

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

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

print(ans)

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

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

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

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

if (b - a) % 2:
  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 (a-b) % 2 == 0:
         print((b-a)//2)
else:
         print(min(a-1,n-b)+((b-a)//2)+1)
Buggy code:
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, a, b = list(map(int, readline().split()))
    if (b - a) % 2 == 0:
        print((b - a) // 2)
    else:
        if abs(a - n) < abs(n - b):
            c = a - 1
            b -= c
            a -= c
            if (b - a) % 2 == 0:
                print((b - a) // 2 + c)
            else:
                print(b - 1 + c)
        else:
            c = n - b
            a -= c
            b -= c
            if (b - a) % 2 == 0:
                print((b - a) // 2 + c)
            else:
                print(n - a + c)


if __name__ == '__main__':
    solve()


Fixed code:
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, a, b = list(map(int, readline().split()))
    if (b - a) % 2 == 0:
        print((b - a) // 2)
    else:
        print(min(a - 1, n - b) + (b - a - 1) // 2 + 1)


if __name__ == '__main__':
    solve()
Buggy code:
strings = input().split(' ')
N = int(strings[0])
A = int(strings[1])
B = int(strings[2])

distance = B - A
moves = 0
if distance % 2 ==1:
    distance_B2W = N - B
    distance_A2W = A - 1
    moves = moves + min(distance_A2W,distance_B2W) + 1
    if distance != 1:
        moves = moves + (distance - 1) // 2
    else:
        moves = moves + 1
    print(moves)
else:
    print(distance // 2)

    

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

distance = B - A
moves = 0
if distance % 2 ==1:
    distance_B2W = N - B
    distance_A2W = A - 1
    moves = moves + min(distance_A2W,distance_B2W) + 1
    moves = moves + (distance - 1) // 2
    print(moves)
else:
    print(distance // 2)
Buggy code:
N, A, B = map(int, input().split())
dis = B-A
min1 = min(abs(1-B), N-A)
ans = min1 + 1 + int((B-A-1)/2)
print(int((B-A)/2)) if (B-A)%2==0 else print(ans)

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

if a == b+1:
    ans = b

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

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

ans = (b-a)//2
if a%2 == b%2:
    print(ans)
else:
    if a-1 >= n-b:
        ans += n-b+1
        a = a+n-b+1
        b = n
        print(ans)
    elif n-b > a-1:
        ans += a
        b = b-a
        a = 1
        print(ans)
Buggy code:
def main():
    n = 10**18
    a = 10**18
    b = 10**18
    print(n, a, b)
    n, a, b = map(int, input().split())

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

    else:
        print((b-a)//2)


if __name__ == '__main__':
    main()


Fixed code:
def main():
    n = 10**18
    a = 10**18
    b = 10**18
    n, a, b = map(int, input().split())

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


if __name__ == '__main__':
    main()
Buggy code:
N, A, B = map(int, input().split())

if (B - A) % 2 == 0:
    print((B - A) // 2)
else:
    a = abs(A - (N // 2))
    b = abs(B - (N // 2))

    if a > b:
        print(A + (B - A - 1) // 2)

    else:
        print((N - B) + 1 + (B - A - 1) // 2)


Fixed code:
import sys

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

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

    else:
        print((N - B) + 1 + ((B - A - 1) // 2))