peterverebics/CodeNet_Python_118 huggingface dataset:
n, a, b = (int(x) for x in 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)
N,A,B = map(int,input().split())
if abs(A-B)%2 == 1:
    print(min(A-1,N-B)+1+(B-A-1)//2)
else:
    print(abs(A-B)//2)
n,a,b = map(int,input().split())
d = b-a
if d%2==0:
    ans=d//2
else:
    ans = min((b+a-1)//2,(2*n-a-b+1)//2)
print(ans)
N, A, B = map(int, input().split())

diff = B - A
if diff % 2 == 0:
    print(diff // 2)
else:
    print(min(A - 1, N - B) + 1 + ((diff - 1) // 2))
n, a, b = [int(i) for i in input().split()]
if (b - a) % 2 == 0:
    print((b - a) // 2)
else:
    print(min(a - 1, n - b) + 1 + (b - a - 1) // 2)
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 // 2)
N,A,B = map(int,input().split())
if (B-A) % 2 == 0:
  print((B-A)//2)
elif A-1 <= N-B:
  print((A+B-1)//2)
else:
  print(N+1-(B+A+1)//2)
n,a,b = map(int, input().split())

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

if (B - A) % 2 == 0:
    print((B - A) // 2)
else:
    # Aが左に到着
    ans1 = 0
    ans1 += A - 1 + 1
    a = 1
    b = B - A
    ans1 += (b - a) // 2

    # Bが右に到着
    ans2 = 0
    ans2 += N - B + 1
    a = A + (N - B + 1)
    b = N
    ans2 += (b - a) // 2

    ans = min(ans1, ans2)
    print(ans)
n, a, b = map(int, input().split())
print([(b-a)//2, min(a-1, n-b) + 1 + (b-a-1)//2][a%2-b%2])
n,a,b = map(int,input().split())

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

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

    print(ans)


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

#距離
d = b-a
c = 0
if d % 2 == 0:
    c = d // 2
else:
    # 端っこに近い方に行く
    c = min(n-b, a-1)
    # 一試合距離を縮める
    c += 1
    d -= 1
    # お互い近づく
    c += (d // 2)

print(c)
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, a, b = map(int, input().split())
if abs(a - b) % 2 == 0:
    print(abs(a - b) // 2)
else:
    small, big = min(a, b), max(a, b)
    print(min(
        (small - 1) + 1 + ((big - (small - 1) - 1 - 1) // 2),
        (n - big) + 1 + ((n - (small + (n - big) + 1)) // 2)
    ))
n,a,b = map(int,input().split())
if (b-a)%2==0:
    print(int((b-a)//2))
else:
    print(int(min(a-1,n-b)+1+(b-1-a)//2))
import sys
input = sys.stdin.readline

def main():
    N, A, B = map(int, input().split())
    tmp = B - A
    if tmp&1:
        ans = min(A - 1, N - B)
        ans += (tmp + 1) // 2
    else:
        ans = tmp // 2
    
    print(ans)


if __name__ == "__main__":
    main()
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))
import sys
input = sys.stdin.readline

# A - Table Tennis Training
def move_left():
	return A + (B-A-1)//2


def move_right():
	return  N - B + 1 + (B-A-1)//2	


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

if (B-A) % 2 == 0:
	print(int((B-A)//2))
else:
	l = move_left()
	r = move_right()
	print(min(l, r))
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)
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)
n,a,b = map(int, input().split())
t = (b-a)//2
if (b-a)%2: t += min(a-1,n-b)+1
print(t)
n,a,b = list(map(int, input().split()))
if abs(b-a)%2==0:
    print(abs(b-a)//2)
else:
    #卓1に行くコスト
    c1=max(a,b)-1
    #卓Nに行くコスト
    c2=n-min(a,b)
    
    ans=0
    cost=min(c1,c2)
    if c1<c2:
        ans+=min(a,b)-1
    else:
        ans+=n-max(a,b)
    cost-=ans
    ans+=(cost+1)//2
    print(ans)
N, A, B = map(int, input().split())
if (A - B) % 2 == 0:
    print((B - A) // 2)
else:
    print(min(A - 1, N - B) + 1 + (B - A - 1) // 2)
n, a, b = map(int,input().split())

if (max(a,b)- min(a,b))%2 ==0:
  print(abs(a-b)//2)
  exit()
  
distance = min(n-a + n -b, a-1+b-1)
print((distance +1)//2)
n,a,b = map(int,input().split())
if (b-a)%2==0:
  print(int((b-a)//2))
else:
  s = a-1
  b1 = b-s
  c = (b1-1)//2+s+1
  
  t = n-b
  a1 = a+t
  d = (n-a1-1)//2+1+t
  print(min(c,d))
# input
N, A, B = map(int, input().split())

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

# output
print(ans)
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)
N, A, B = [int(x) for x in input().split()]

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

    A, B = N - B + 1, N - A + 1
    res2 = A+(B-A-1)//2
    return min(res1, res2)


if __name__ == "__main__":
    N, A, B = map(int, input().split())
    ans = main(N, A, B)
    print(ans)
n, a, b = map(int, input().split())
ans = (b - a) // 2 if (b - a) % 2 == 0 else min(a - 1, n - b) + (b - a - 1) // 2 + 1
print(ans)
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) // 2)))
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)
N,A,B=map(int,input().split())
ans=min(A-1,N-B)+1+(B-A-1)//2
sum=0
if (B-A)%2==0:
    sum=(B-A)//2
    ans=min(sum,ans)
print(ans)
n, a, b = map(int, input().split())
ans = [max(a-1, b-1), max(n-a, n-b)]
dis = abs(a-b)
if dis % 2 == 0:
    ans.append(dis//2)
else:
    if abs(a-b) > 2:
        cto = min(a, b)
        ans.append((dis-1)//2+cto)
        ctn = min(n-a, n-b)
        ans.append((dis-1)//2+ctn+1)
print(min(ans))
n,a,b = [int(x) for x in input().split()]
if (b-a)%2==0:
    print((b-a)//2)
else:
    print(min(a+(b-a-1)//2,n-b+1+(b-1-a)//2))
n, a, b = map(int, input().split())

if b > a:
    a, b = b, a

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

d = B - A

if (d % 2 == 0):
    ans = d // 2
else:
    left = B - 1
    right = N - A
    mini_1 = min(left, right)
    
    kado = min(A - 1, N - B)
    mini_2 = kado + 1 + (d - 1) // 2
    
    ans = min(mini_1, mini_2)

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

if(b < a):
    swap(a, b)

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

else:
    x = a + (b - a) // 2
    a = n - a + 1
    b = n - b + 1
    y = a + (b - a) // 2
    ans = min(x, y)

print(ans)
N,A,B=map(int,input().split())
if (B-A)%2==0:
    print((B-A)//2)
else:
    tmp=A-1+(B-A+1)//2
    a=A+(N-B);b=N
    tmpp=N-B+(b-a+1)//2
    print(min(tmp,tmpp))
import sys

input = sys.stdin.readline


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

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

    print(ans)


if __name__ == "__main__":
    main()
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)
n,a,b=map(int,input().split())
if a>b:a,b=b,a
if (a+b)%2:
  print(min(a+b-1,(n-a)+(n-b)+1)//2)
else:print((b-a)//2)
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
        print(ans)
    elif N-B > A-1:
        ans += A
        print(ans)
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()
N,A,B = map(int,input().split())
a = min(A,B)
b = max(A,B)
d = b - a

#差が偶数の時：d/2
#差が奇数の時：どちらかの端で一回稼ぐ

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

if (b-a) % 2 == 0:
    print(rs)
else:
    if a==1 and b==n:
        print(n//2)
    elif (a-1) > (n-b):
        print(rs+(n-b+1))
    else:
        print(rs+a)
def is_even(num):
    if num % 2 == 0:
        return True
    else:
        return False


n, a, b = map(int, input().split())
tables = [n] * 2
if is_even(a) and is_even(b):
    print(abs(a - b) // 2)
elif not is_even(a) and not is_even(b):
    print(abs(a - b) // 2)
else:
    print(min(abs(1 - a), abs(b - n)) + 1 + (b - a - 1) // 2)
n,a,b = map(int,input().split())
if (b-a)%2 == 0:
  print(min((b-a)//2,b-1,n-a))
else:
  print(min(b-1,n-a,a+(b-a-1)//2,n-b+1+(b-a-1)//2))
def main():
    N,A,B = map(int,input().split())
    if abs(A-B)%2==1:
        print(min(A-1,N-B)+1+(B-A-1)//2)
    else:
        print(abs(A-B)//2)

if __name__ == '__main__':
    main()
import sys
n, a, b = map(int, input().split())

# 2で割って余り1ならすれ違わない
if (b - a) % 2 == 0:
    print((b - a) // 2)

else:
    # 左で折り返す場合
    left = ((a - 1) + (b - 1) + 1) // 2

    # 右で折り返す場合
    right = ((n - b) + (n - a) + 1) // 2

    print(min(left, right))
n, a, b = map(int, input().split())
if (b-a)%2 == 0 :
    print((b-a)//2)
else :
    print((b-a)//2 + min(a-1,n-b) + 1)
n, a, b = map(int, input().split())
if a % 2 == b % 2:
    print(abs(a-b)//2)
else:
    print(min(a-1, n-b)+1+((b-a)//2))
    # print(min(a-1, n-b))
    # print(1)
    # print(((b-a)//2))
def main():
    N, A, B = map(int, input().split())

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


if __name__ == '__main__':
    main()
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)
n, a, b = map(int, input().split())
# 偶奇一致
if a % 2 == b % 2:
    print((b - a) // 2)
else:
    # left = a - 1
    # right = n - b

    # if left > right:
    #     cnt = right + 1
    #     left = min(a + cnt, n)
    #     print((n - left) // 2 + cnt)
    # else:
    #     cnt = left + 1
    #     right = max(b - cnt, 1)
    #     print((right - 1) // 2 + cnt)

    print(min(a - 1, n - b) + 1 + (b - a - 1) // 2)
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))
N, A, B = list(map(int, input().split()))

diff = B - A

if diff % 2 == 0:
    ans = diff // 2
else:
    # d1 = A - 1
    # ans1 = d1 + (diff - 1) / 2 + 1

    # d2 = N - B
    # ans2 = d2 + (diff - 1) / 2 + 1

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

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

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

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

def F(n,a,b):
    #ab間にある要素の数が偶数
    if (b-a)%2==0:
        return (b-a)//2
    #左端で止まる
    tmp = []
    #左側からみて
    x = (a-1)+(b-1)+1
    tmp.append(x//2)
    #右側からみて
    x = (n-a)+(n-b)+1
    tmp.append(x//2)
    return min(tmp)

print(F(n,a,b))
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)
def main():

    N, A, B = map(int, input().split())
    if (B-A) % 2 == 0:
        return  (B-A) // 2
    else:
        a = A-1 + (B-A+1)//2
        b = N-B+1 + (B-A-1) // 2
        return min([a, b])

if __name__ == '__main__':
    print(main())
import sys
n, a, b = map(int, sys.stdin.readline().split())
c = b - a
if c % 2:
  d = min(a - 1, n - b)
  e = 1
  f = (b - a - 1) // 2
  print(d + e + f)
else:
  print(c // 2)
n,a,b = map(int, input().split())
if (a-b) % 2 == 0:
  print(abs(a-b)//2)
else:
  print(min(a + (b - a - 1) // 2, n - b + 1 + (b - a - 1) // 2))
n,a,b = [int(i) for i in input().split()]
if (b - a)%2:
  print((b-a)//2 + 1 + min(a-1,n-b))
else:
  print((b-a)//2)
N,A,B = list(map(int,input().split()))
if (B-A)%2 == 0:
    print((B-A)//2)
    exit()
A1 = A
B1 = B
A2 = A
B2 = B
count1 = N-B1
ans1 = 0
A1 += (N-B1)
B1 = N
if (B1-A1)%2 == 0:
    ans1 = count1+(B1-A1)//2
else:
    ans1 = count1+1+(B1-A1)//2

count2 = A2-1
ans2 = 0
B2 -= (A2-1)
A2 = 1
if (B2-A2)%2 == 0:
    ans2 = count2+(B2-A2)//2
else:
    ans2 = count2+1+(B2-A2)//2
print(min(ans1,ans2))
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)
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)
N, A, B = map(int, input().split())
if (B-A) % 2 == 0:
    print((B-A) // 2)
else:
    n1 = (A + B - 1) // 2
    n2 = N - n1
    print(min(n1, n2))
def main():
    N, A, B = map(int, input().split())
    diff = abs(A-B)
    if diff%2 == 0:
        ans = diff//2
    else:
        # 端に行く
        # 一回端のままになる => 偶数のときと同じ
        ans = min(A-1, N-B)
        diff -= 1; ans += 1
        ans += diff//2
    print(ans)

if __name__ == "__main__":
    main()
n,a,b = map(int,input().split())
if abs(a-b)%2:
    print(abs(a-b)//2+1+min((abs(1-a),abs(n-a),abs(1-b),abs(n-b))))
else:
    print(abs(a-b)//2)
import math
n, a, b = [int(w) for w in input().split()]
if (a + b) % 2 == 0:
    ans = (b - a) // 2
else:
    ans = min(a - 1, n - b)
    ans += 1 + (b - a) // 2
print(ans)
N,A,B = map(int,input().split())

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

if (b-a)%2==0 :
    print(((b-a)//2))
else:
    print(min(b-1,N-a,int(N-b+(b-a+1)//2),int(a+(b-a-1)//2)))
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()
N,A,B=map(int,input().split())
if (B-A)%2:
    print(min(A-1,N-B)+1+(B-A-1)//2)
else:
    print((B-A)//2)
N,A,B=map(int,input().split())
if (B-A)%2==0:
    ans=(B-A)//2
else:
    #2人のどちらかが卓1,Nのいずれかに到達するのに必要なラウンド数
    #1は偶奇を調整するためのラウンド
    #(B-A-1)/2は偶奇の調整後に2人が出会うまでのラウンド数
    ans=min(A-1,N-B)+1+(B-A-1)//2 
print(ans)
N, A, B = map(int,input().split(" "))
ans = 0
diff = abs(A-B)

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

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

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

print(ans)
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)
import sys

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

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

else:
    ans1 = min(A, B) + (max(A, B)-min(A, B)-1)//2
    ans2 = N-max(A, B)+1 + (N-min(A, B) - (N-max(A, B)) -1)//2
    print(min(ans1, ans2))
n,a,b = map(int, input().split())
if a > b : a,b = b,a #swap
### 差が偶数
if (b-a)%2 == 0:
    print((b-a)//2)
if (b-a)%2 == 1:
    ### 1側で調整
    ichi = a + (b-a-1)//2
    ### n側で調整
    b = n-b
    a = n-a
    enu = b + 1 + (a-b-1)//2
    print(min(ichi,enu))
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))
n, a, b = map(int ,input().split())

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

	if b-a == 1:
		ans = min(ans_2_1, ans_2_2)
	else:


		ans_3_1 = (a-1) + 1 + (b-a+1-1-1)//2
		ans_3_2 = (n-b) + 1 + (n-(a+n-b+1))//2

		ans = min(ans_2_1,ans_2_2,ans_3_1,ans_3_2)

print(ans)
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+(b-a-1)//2)
n,a,b = map(int,input().split())
x = b-a
if x % 2 == 0 : 
  print(x//2)
else:
  m = (a-1)+1+((b-a-1)//2)
  l = (n-b)+1+((b-a-1)//2)
  print(min(m,l))
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inl = lambda: [int(x) for x in sys.stdin.readline().split()]
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))


def solve():
    n, a, b = inl()
    if (b - a) % 2 == 0:
        return (b - a) // 2

    k = min(a - 1, n - b)
    return k + 1 + (b - a) // 2


print(solve())
n,a,b=map(int,input().split())
if (b-a)%2==0:
    print((b-a)//2);exit()
a-=1;b-=1
# print(min(b,n-1-a))
ans1=0; ans2=0
ans1+= a
aa=0 ; bb=b-a 
ans1+= (bb//2+1)

ans2=n-1-b 
b=n-1
a+=ans2
ans2+= (b-a)//2+1

print(min(ans1,ans2))
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)
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)
N,A,B = map(int,input().split())
if((B-A+1)%2==1):
    print((B-A)//2)
else:
    print(min(A-1,N-B)+1+(B-A-1)//2)
# 2020/08/08
# AtCoder Beginner Contest 174 - A

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

# Calc
sa = abs(b - a)

if sa % 2 == 0:
    ans = sa // 2
else:
    # B go Right and 1 lose
    bgr = n - b + 1
    bgra = a + bgr
    rans = (n - bgra) // 2 + bgr
    
    # A go Left and 1 lose
    agl = a - 1 + 1
    aglb = b - agl
    lans = (aglb - 1) // 2 + agl
    ans = min(rans, lans)

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

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

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

p = b-a-1

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

    print(ans + (p+1)//2)
else:
    print((p+1)//2)
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)
n, a, b = map(int, input().strip().split())

if (b - a) % 2 == 1:
    dt1 = a - 1
    dt1 += 1
    b1 = b - dt1
    t1 = dt1 + (b1 - 1) // 2

    dt2 = n - b
    dt2 += 1
    a1 = a + dt2
    t2 = dt2 + (n - a1) // 2
    print(min(t1, t2))
else:
    print((b - a) // 2)
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))
def main():
    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)


if __name__ == "__main__":
    main()
N,A,B = (int(x) for x in input().split())
if (B - A) % 2 == 0:
    print((B-A)//2)
else:
    if B - A == 1:
        if A == 1 or B == N:
            print('1')
        else:
            print('2')
    else:
        if A <= N-B:
            print((A+B-1)//2)
        else:
            print((2*N-A-B+1)//2)
from collections import defaultdict

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n,a,b = readInts()

if (b-a)%2==0:
	print((b-a)//2)
else:
	print(min(b-1,n-a,a+(b-a-1)//2,n-(a+b-1)//2))
n, a, b = map(int, input().split())
if (a - b) % 2 == 0:
  print(abs((a - b) // 2))
else:
  ans = min(a - 1, n - b) + 1 + ((b - a - 1) // 2)
  print(ans)
#!/usr/bin/env python3

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

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

print(int(ans))
N, A, B = [int(i) for i in input().split()]
if (B-A) % 2 == 0:
    print((B-A)//2)
else:
    x = min(A-1, N-B)
    print((B-A-1)//2+x+1)
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)
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,a,b = map(int, input().split())
if (b-a)%2==0:
    ans = (b-a)//2
else:
    m = b-1
    M = n-a
    m1 = (n-b) + 1 + (b-a-1)//2
    m2 = (a-1) + 1 + (b-a-1)//2
    ans = min(m,M, m1, m2)
print(ans)
n,a,b=map(int,input().split())
if a%2==b%2:
  print(abs((a+b)//2-a))
else:
  k=min(a-1,n-b)
  if a-1<n-b:
    flag=0
  else:
    flag=1
  if flag==0:
    if b-k-1>=0:
      print(k+1+abs(b-k-1-(1+b-k-1)//2))
    else:
      print(k+1)
  else:
    if a+k+1<=n:
      print(k+1+abs(a+k+1-(n+a+k+1)//2))
    else:
      pritn(k+1)
N, A, B = map(int, input().split())
if (B-A)%2 ==0:
  ans = (B-A)//2
else:
  tmp = min(N-B, A-1)
  ans = tmp + 1 + (B-A-1)//2
print(ans)
import sys
input = sys.stdin.buffer.readline

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