peterverebics/CodeNet_Python_118 huggingface dataset:
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)
n, a, b = [int(i) for i in input().split()]
a,b=max(a,b),min(a,b)

if (a - b) % 2 == 0:
    print((a - b) // 2)
else:
    c = b + (a -1- b) // 2
    d = n - a + 1 + (n - (n - a + 1) - b) // 2
    print(min(c,d))
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    n, a, b = geta(int)

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


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

D=B-A

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

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

Abs = B - A
if Abs % 2 == 0:
  ans = Abs // 2
else:
  a, b = A-1, N-B
  if a < b:
    ans, B = a+1, B-(a+1)
    ans += (B-1) // 2
  else:
    ans, A = b+1, A+(b+1)
    ans += (N-A) // 2
    
print(ans)
N, A, B = map(int, input().split())
if (B-A) % 2 == 0: print((B-A)//2)
else: print(min((A-1+B-1+1)//2, (N-A+N-B+1)//2))
def solve():
    N, A, B = [int(i) for i in input().split()]
    if (B - A) % 2 == 0:
        print((B - A) // 2)
    else:
        print(min(N - B, A - 1) + 1 + (B - A - 1) // 2)

if __name__ == "__main__":
    solve()
n,a,b = map(int, input().split())

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

print(min(a-1,n-b) +1+ (b-a-1)//2)
import math

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

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

else:

    t1 = A - 1
    t2 = B - 1
    t3 = N - A
    t4 = N - B

    t = min(t1, t2, t3, t4)

    res = t + 1 + (abs(A - B) - 1) // 2
    
    print(res)
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)
import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))


n,a,b = readints()

if (b-a)%2==0:
    print((b-a)//2)
else:
    print(min(n-b+(b-a)//2+1,a-1+(b-a)//2+1))
# Function for calc
def match(n, a, b):
    if (b - a)% 2 == 0:
        print((b-a)/2)
    else:
        if (n - b) >= a:
            print((a)+((b-(a+1))/2))
        else:
            x=(n-b+1)
            print(x+((n-(a+x))/2))
# Run match
in_string = raw_input()
[N, A, B] = [int(v) for v in in_string.split()]
match(N, A, B)
N, A, B = map(int, input().split())


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

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

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


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

if (B - A) % 2 == 0:
    print((B - A) // 2)
else:
    ans = min(A, N - B + 1) + (B - A - 1) // 2
    print(ans)
import numpy as np
N,A,B = map(int,input().split())
x=abs(A-B)
    

if x%2==0:
    print(x//2)
else:
    y,z=max(N-A,N-B),max(A-1,B-1)
    a,b=min(A-1,B-1),min(N-A,N-B)
    c,d=max(A-1,B-1)-a,max(N-A,N-B)-b
    e,f=c//2+a+1,d//2+b+1
    if y>z:
        print(min(z,e,f))
    else:
        print(min(y,e,f))
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)
def solve(N, A, B):
    if A % 2 == B % 2:
        return (B - A) // 2
    return min(A-1, N-B) + 1 + (B - A -1)//2

if __name__ == "__main__":
    n, a, b = map(int, input().split())
    print(solve(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())

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

if __name__ == '__main__':
    main()
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

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

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

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

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

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

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

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

if (a + b) % 2 == 0:
    print((b - a) // 2)
    exit()
else:
    if b - 1 < n - a:
        print(b - 1 - ((b - a) // 2))
    else:
        print(n - a - ((b - a) // 2))
n, a, b = map(int, input().split())
ans = -1
if (b-a) % 2 == 0:
    ans = (b-a) // 2
else:
    diff_left = a - 1
    diff_right = n - b
    if diff_left <= diff_right:
        ans = diff_left
        ans += 1
        ans += (b-a-1) // 2
    else:
        ans = diff_right
        ans += 1
        ans += (b-a-1) // 2


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


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

print(ans)
N,A,B=map(int,input().split())
if (B-A)%2==0:
    ans =(B-A)//2
else:
    if A-1 > N-B:
        ans = N-B+1
        A+=ans
        ans+=(N-A)//2
    else:
        ans =A
        B-=ans
        ans+=(B-1)//2
print(ans)
n, a, b = map(int, input().split())
if a%2==b%2:
    print((b-a)//2); exit()
ans1 = 0
c = a
aa = 1
bb = b-a
ans1 = c
if aa!=bb:
    ans1 += (bb-aa)//2
ans2 = 0
c = n-b+1
bb = n
aa = a+c
ans2 = c
if aa!=bb:
    ans2 += (bb-aa)//2
print(min(ans1, ans2))
def main():
    N, A, B = list(map(int, input().split(' ')))
    assert 1 <= A < B <= N
    if (B - A) % 2 == 0:
        print((B - A) // 2)
    else:
        if B - 1 <= N - A:
            print(A + max([0, B - A - 1]) // 2)
        else:
            print(N - B + 1 + max([0, B - A - 1]) // 2)


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

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

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

    A_btm = N - A
    B_btm = N - B
    btm = (
        B_btm + (N - A - B_btm) // 2 if A_btm > B_btm else A_btm + (N - B - A_btm) // 2
    )
    print(min(top, btm) + 1)
n,a,b = map(int, input().split())
d = b - a
if d%2==0: ans = d//2 # AB間偶数
else: ans = min(a, n-b+1) + (d-1)//2 # 端寄せを一回多く行えば AB間が１つ詰まって偶数
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)//2)
def resolve():
    n, a, b = map(int, input().split())
    if a%2 == b%2: #偶奇が同じだと同じ場所で会える
        print((b-a)//2)
    else:#偶奇が違う→1 or Nで調整する
        print(min(a-1, n-b) + 1 + (b-a-1)//2)
resolve()
N,A,B = map(int,input().split())
if(abs(A-B)%2 == 0):
  print(abs(A-B)//2)
else:
  print(min( A + (abs(A-B) - 1)// 2,  N - B + 1 + (abs(A-B)-1)//2  ))
n,a,b = map(int,input().split())
if (a % 2 + b % 2) % 2 == 0:
    print(abs(a - b) // 2)
    exit(0)

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

main()
import sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,A,B = LI()
if (A+B)%2==0:
    ans = (B-A)//2
else:
    count_move = min(A-1,N-B)
    ans = count_move+1
    ans += (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)//2,(2*n-a-b+1)//2))
N,A,B = map(int, input().split())

ans = 1e18
# 一致してないとどっちかがエッジまでいって一回消費してe/oをマッチさせる必要がある
if A%2 != B%2:
  work = A
  b = B-A
  a = 1
  work += (b-a) // 2
  #print(work,a,b)
  ans = min(ans,work)

  work = N-B+1
  a = A+N-B+1
  b = N
  work += (b-a) // 2
  #print(work,a,b)
  ans = min(ans,work)
else:
  work = (B-A) // 2
  ans = min(ans,work)
  
print(ans)
N, A, B = map(int, input().split())

d = B - A

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

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

mid = (B - A)//2
left = ((A-1+B-1)+1)//2
right = ((N-B+N-A)+1)//2

if (B - A)%2==0:
    print(mid)
else:
    print(min(left, right))
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)
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

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

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

print(ans)
n, a, b = map(int, input().split())
if (b - a) % 2 == 0:
    print((b-a) // 2)
    exit()
else:
    c = min(a - 1, n - b)
    print(c + (b - a + 1) // 2)
    exit()
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(a,b)+(abs(a-b)-1)//2)
  else:
    print(min(n+1-a,n+1-b)+(abs(a-b)-1)//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)
#!/usr/bin/env python3

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

ans = 10**18+1

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

# print(a, b)
ans = []
ans.append(max(a-1, b-1))
ans.append(max(n-a, n-b))

if abs(a-b) % 2 == 0:
    ans.append(abs(a-b)//2)
else:
    a_tmp, b_tmp = 1, b-a
    ans.append(a + abs(b_tmp-a_tmp)//2)

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

mid = b - a

if mid % 2 == 0:
    print(mid // 2)
else:
    print(min(a - 1, n - b) + 1 + (mid - 1)//2)
N, A, B = map(int, input().split())
if B%2 == A%2:
    print((B-A)//2)
else:
    print(min(A-1, N-B)+1+(B-A-1)//2)
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

MOD = 10 ** 4 + 7

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

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

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

dif = abs(A-B)
if(dif%2 == 0):
  ans = dif//2
else:
  A1_diff = A-1
  #B1_diff = B-1
  #AN_diff = N-A
  BN_diff = N-B
  ans = min(A1_diff, BN_diff)+1+(dif-1)//2
print(ans)
n, a, b = map(int, input().split())
if abs(b - a) & 1:
    l = (a - 1) + (b - 1) + 1
    r = (n - a) + (n - b) + 1
    x = min(l, r)
else:
    x = abs(b - a)
print(x // 2)
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:
  print((B-A)//2)
elif (B-1)>=(N-A):#Nに近づいたほうが早い時
  #ans+=N-B+1
  #B=N
  #A+=(N-B)+1
  print(((B-A-1)//2)+(N-B+1))
else:#1に近づいたほうが早い時
  #ans=A-1+1
  #A=1
  #B-=A
  print(((B-A-1)//2)+A)
N, A, B = map(int, input().split())

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

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

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

result = (abs(a-b)//2)
if (a-b)%2==1:
    # min distance to top or bottom
    dist = min(a-1,b-1,n-a,n-b)
    result += dist + 1

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

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

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

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


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

df = abs(A - B)
dA = A - 1
dB = N - B
ans = 0

if df % 2 == 0:
    ans = int(df // 2)
    print(ans)
else:
    if dA > dB:
        #端までの距離
        ans += dB + 1 + ((B-A) // 2)
        print(ans)
    else:
        ans += dA + 1 + ((B-A) // 2)
        print(ans)
n, a, b = map(int, input().split())
d = min((b - a - 1) // 2 + a, (n - b + 1 + (b - a - 1) // 2))
 
if (b - a) % 2 == 0:
    d = (b - a) // 2
    
print(d)
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-2)//2+1)
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)
from decimal import *
def resolve():

    tn,ta, tb = map(int, input().split())
    n=Decimal(tn)
    a=Decimal(ta)
    b=Decimal(tb)
    if (b-a)%2 == 1:
        ans=min(a-1,n-b)+1+(b-a-1)/2
    else:
        ans=(b-a)/2

    print(int(ans))

resolve()
import math

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

sa = B - A + 1;

if sa % 2 == 1 :
	ans = min(N - A, B - 1);
	#chmin(ans, (B - A) / 2);
	ans = min(ans, (B - A) // 2)

	print(ans)
else :
	ans = 10**30;

	# A を 1 に移動させて1勝
	ca = A
	cb = B

	ca = 1;
	cb -= A;

	cand = (cb - ca) // 2 + A;
	ans = min(ans, cand);

	# B を N に移動させて1敗
	ca = A
	cb = B
	cb = N;
	ca += N - B + 1;
	cand = (cb - ca) // 2 + (N - B + 1);

	ans = min(ans, cand);


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

dist = b - a
if dist % 2 == 0:
    print(dist//2)
elif a - 1 < n - b:
    print(a-1 + 1 +(b-a-1)//2)
else:
    print(n - b + 1 +(b-a-1)//2)
import sys
n, a, b = [int(i) - 1 for i in sys.stdin.readline().split()]
if (a - b) % 2 == 0:
    print((b - a) // 2)
else:
    if n - b > a:
        print(a + 1 + (b - a - 1) // 2)
    else:
        print(n - b + 1 + (b - a - 1) // 2)
n,a,b = map(int, input().split())

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

ans = 0

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

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

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


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

if (B-A)%2 == 0:
    #真ん中で会う
    ans = (B-A)//2
else:
    if N-B < A-1:
        #まずBがNへ行く
        temp_ans = N-B
        A += N-B
        ans = temp_ans + 1 + (N-A)//2
    else:
        #まずAが1へ行く
        temp_ans = A-1
        B -= A-1
        ans = temp_ans + 1 + (B-1)//2
print(ans)
#!/usr/bin python3
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline

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

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

result = 0

if (A-B)%2 == 0:
    #差が偶数
    result = (B - A) // 2
else:
    #差が奇数
    result = min(A-1,N-B)+1+(B-A-1)//2

print(int(result))
def solve():
  N, A, B = map(int, input().split())
  if (A-B)%2==0:
    return abs(A-B)//2
  ans = min((B+A-1)//2,N-(A+B-1)//2)
  return ans
print(solve())
N, A, B = map(int, input().split())

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

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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


if __name__ == '__main__':
    resolve()
N, A, B = map(int, input().split())
if abs(A-B)%2 == 0:
    print(abs(A-B)//2)
else:
    if A - 1 <= N - B:
        print(A + (B - A - 1) // 2)
    else:
        tmp = N - B + 1
        A += tmp
        tmp += (N - A + 1) // 2
        print(tmp)
#!/usr/bin/env python3
n, a, b = map(lambda x: int(x) - 1, input().split())
if (b - a) % 2 == 0:
    print((b - a) // 2)
else:
    m = min(a, n - b)
    print(m + (b - a + 1) // 2)
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-a-b+1)//2))
n, a, b = map(int, input().split())

dist = b - a
if dist & 1:
  print(min(a - 1, n - b) + 1 + (dist - 1)//2)
else:
    print(dist//2)
#!/usr/bin/env python
# coding: utf-8

# In[10]:


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


# In[17]:


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


# In[ ]: