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

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

print(ans)
N,A,B = [int(i) for i in input().split()]
if A%2 == B%2:
    print(abs(A - B) // 2)
    exit()

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

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

print(int(ans))
#!/usr/bin/python3
import sys
import re
from decimal import *

l = sys.stdin.readline()
l = l.split(' ')
l = [int(str) for str in l]

n = Decimal(l[0])
a = Decimal(l[1])
b = Decimal(l[2])

pre = 10**19
if(abs(a-b)%2==0):
	pre = int(abs(a -b)/2)
smax = ( a + b - 2 + 1) / 2
emax = ( n - a + n - b + 1) / 2
tmin = min( smax, emax)
v = int(tmin)
print(min(v,pre))

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

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

input = sys.stdin.readline
MOD = 1000000007

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

def solve(n,a,b):
  diff = b - a
  if diff % 2 == 0:
    return (diff + 1) // 2
  
  # foward to "1" table and A stay 1 round
  root_a = a
  # A kicks back to B
  root_a += diff // 2
  # foward to "N" table B stay 1 round
  root_b = n - b + 1
  # B kicks back to A
  root_b += diff // 2
  
  return min(root_a, root_b)

n, a, b = map(int,input().split())
ans = solve(n,a,b)
print(ans)
import sys
input = sys.stdin.readline
N, A, B = map(int, input().split())

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

if abs(b-a)%2 == 0:
    print(abs(b-a)//2)
else:
    print(min((max(a,b)+min(a,b))//2, (2*n-max(a,b)-min(a,b)+1)//2))
n, a, b = map(int, input().split())
c = b-a
if c%2 == 0:
    print(c//2)
else:
    print(min(a-1, n-b)+1+(c-1)//2)
from sys import stdin
import math
import re
import queue

input = stdin.readline

MOD = 1000000007

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

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

if (b-a)%2 == 0:
    ans = (b-a) // 2
else:
    ans = min((2*n-a-b+1)//2, (a+b-1)//2)
    
print(ans)
n,a,b=map(int,input().split())
if (b-a)%2==0:
    print((b-a)//2)
else:
    ans1=min(b-1,n-a)
    ans2=0
    kyori=b-a-1
    ans2+=min(a-1,n-b)+1
    ans2+=kyori//2
    print(min(ans1,ans2))
import sys
input = sys.stdin.readline

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

if (B-A) % 2 == 0:
    ans = (B-A) // 2
else:
    ans = min(A, N-B+1) + (B-A-1)//2
print(ans)
[N,A,B] = list(map(int,input().split()))
AA = A-1
BB = N-B
sa = B - A
if sa%2==0:  #偶数
    out=sa//2

else:  #奇数
    if AA<BB:
        out = AA + 1 + (sa-1)//2
    else:
        out = BB + 1 + (sa-1)//2

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

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

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

dif = b-a
if dif%2 == 0:
    print(dif//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:
    ans = abs(a - b) // 2
else:
    if abs(a - 1) > abs(n - b):
        a, b = n + 1 - b, n + 1 - a
    b -= a
    ans = abs(b - 1) // 2 + a
print(ans)
N,A,B=map(int,input().split())
ans=0
if (B-A)%2==0:
  ans=(B-A)//2
else:
  ans=min(A,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:
    left=A-1
    right=N-B
    print(min(left,right)+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,N-B)+1+(B-A-1)//2)
n, a, b = map(int, input().split())
if (b-a)%2 != 0:
    if a-1 <= n-b:
        ans = (b - a -1)//2 + 1 + a-1
    else:
        ans = (b - a - 1)//2 + 1 + n-b
else:
    ans = min((b - a) // 2, b-1, n-a)
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)
N,A,B=map(int,input().split())
if (B-A)%2 == 0:
    print((B-A)//2)
else:
    d = min(A-1, N-B)
    print(d + 1 + (B-A)//2)
N,A,B = map(int,input().split())
if (B-A)%2 == 0:
    print((B-A)//2)
    exit()
print(min(A+(B-A-1)//2,N-B+1+(B-A-1)//2))
import sys
input = sys.stdin.readline

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

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

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


if __name__ == "__main__":
    main()
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 (A-B)%2==0:
    print((B-A)//2)
    exit()

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:
    n = (B-A-1)//2
    print(n+min(A,N-B+1))
N,A,B=map(int,input().split())
if (B-A)%2==0:
    print((B-A)//2)
else:
    if A<=N-B:
        print(A+(B-A)//2)
    else:
        print(N-B+1+(B-A)//2)
N,A,B=map(int,input().split());C=B-A;print(C//2+C%2*min(A,N-B+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)
n, a, b= map(int,input().split())
if (b-a) % 2 == 0:
    print((b-a)//2)
elif (b-a) % 2 == 1:
    print(min(a-1+1+(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)
else:
    if (A-1)<=(N-B):
        print(A+(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((B - A) // 2)
else:
    left = B - 1
    right = N - A
    if abs(A - B) < 3:
        print(min(left, right))
    else:
        if left < right:
            print((B - A - 1) // 2 + A)
        else:
            print((B - A - 1) // 2 + N - B + 1)
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((n-b+n-a+1)//2)
    else:
        print((a-1+b-1+1)//2)
n,a,b = map(int,input().split())
s = a + b
if s % 2 == 0:
  s //= 2
  print(s - a)
else:
  print(min(a - 1,n - b) + 1 + (b - a - 1) // 2)
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)
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n, a, b = LI()
    a, b = min(a,b), max(a,b)
    ans = 0
    if (b-a)%2 == 0:
        ans = (b-a)//2
    else:
        ans = min(a+(b-a-1)//2, n-b+1+(n-(a+n-b+1))//2)
    print(ans)
main()
n, a, b = map(int,input().split())
tmp = abs(a-b)

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


def LI():
    return list(map(int, input().split()))


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

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

    print(roundTime)



tableTennis()
# coding: utf-8
# Your code here!
N,A,B=map(int,input().split())

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

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

else:
    if a - 1 <= n - b:
        kaisuu = (a - 1) + 1 + (1 + b - a) // 2 - 1
        print(kaisuu)
    else:
        kaisuu = (n - b) + 1 + (n + (a + (n - b + 1))) // 2 - (a + n - b + 1)
        print(kaisuu)
N, A, B = map(int, input().split())
if A % 2 == B % 2:
    ans = (B - A) // 2
else:
    ans = min(A - 1, N - B) + 1 + (B - A - 1) // 2
print(ans)
ans=0
def solution(a,b,c):
    if (a%2==0 and b%2==0) or (a%2!=0 and b%2!=0):
        ans=(b-a)//2
    else:
        ans=min(a-1,c-b)+1+(b-a)//2
    return ans

c,a,b=map(int,input().split())
print(solution(a,b,c))
n,a,b = map(int,input().split())
dif1 = abs(a-b)

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

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

print (result)
N,A,B = list(map(int,input().split()))
a = A - 1
b = N - B
c = B - A
if c%2==0:
  res = c/2
elif a<b:
  res = (B + a)/2
else:
  res = (N - (A - b) + 1) /2
print(int(res))
N, A, B = map( int, input().split() )

if ( A + B ) % 2 == 0:
  print( (abs( A - B ) + 1) // 2 )
else:
  print( min( max( A, B ) - 1, max( N - A, N - B ) - 1 ))
#agc041 a
n,a,b=map(int,input().split())
ans=0
if (b-a)%2==0:
    ans=(b-a)/2
else:
    left=b-1
    right=n-a
    ans=min(left,right)
print(int(ans))
import sys
N,A,B = map(int,input().split())
if (A-B) % 2 == 0:
  print((A-B)//2)
  sys.exit(0)
else:
  if A == 1 or B == 1:
    print(B-A)
  else:
    print(B-A+1)
n, a, b = map(int, input().split())
result = 0
if (b - a)%2 == 1:
    temp1 = b - 1
    temp2 = n - a
    if temp1 < temp2:
        result = temp1
    else:
        result = temp2
else:
    result = (b - a) // 2
print(result)
N, A, B = map(int, input().split())

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

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

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

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

else:
    print(min(b-1,n-a))
#!/usr/bin/env python3

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

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

print(ans)
N,A,B = map(int,input().split())
iti=(B-A+1)/2 +A-1
enu=(B-A+1)/2 +N-B
if( (B-A)%2 == 0):
   print( int( (B-A)/2 ) )
else:
  print(int(iti) if A-1<=N-B else int(enu))
N, A, B = [int(item) for item in input().split()]
if (B-A) % 2 == 0:
    print(int((B-A)/2))
else:
    d = min(N-B, A-1)
    print(int(d+1+(B-A-1)/2))
N,A,B=map(int,input().split())

if A%2==B%2:
    print(int((B-A)/2))
else:
    print(min(A-1,N-B)+1+int((B-A-1)/2))
N, A, B = input().split(' ')
N = int(N)
A = int(A)
B = int(B)
if (B-A)%2 == 0:
  Count = (B-A)/2
  print(int(Count))
else:
  if (N-A)<(B-1):
    print(int(N-A))
  else:
    print(int(B-1))
n,a,b = map(int,input().split())
print(min(abs(a-b),max(a-1,b-1),max(n-a,n-b)))
N,A,B = [int(x) for x in input().split()]
if abs(A-B)%2==0:
  print(abs(A-B)//2)
else:
  print(min(A-1+B-1,N-A+N-B))
N, A, B = map(int, input().split())

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

#一人目と二人目の間に奇数人存在
if (B-A+1)%2!=0:
    print(B-A-1)
    exit()

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

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

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

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

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

if (B-A) % 2 == 0:
	print( (B-A) // 2 )
else:
	print( min([N-A, B-1]) )
n, a, b = 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))
def solve(N, A, B):
    if A % 2 == B % 2:
        return (B - A) // 2
    return int(min(A-1, N-B) + 1 + (B - A -1)/2)

if __name__ == "__main__":
    n, a, b = map(int, input().split())
    print(int(solve(n, a, b)))
import sys
input = sys.stdin.readline

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

if ((B-A)+1)%2==0:
    print(B-1)
else:
    print((B-A)/2)
N, A, B = map(int, input().split())
x = A - 1
y = B - A - 1
z = N -B 

if y % 2 == 1:
  ans = (y + 1) / 2
else:
  if x >= z:
    ans = y + z + 1
  else:
    ans = y + x + 1
print(int(ans))
n, a, b = map(int, input().split())

x = a//2 + 1 if a%2 == 0 else (a+1)//2
y = b//2 + 1 if b%2 == 0 else (b+1)//2

print(2 if x == y else y-x)
def main():
    N, A, B = map(int, input().split())

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


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

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

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


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

ans = INF = 1 << 60

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

# 左で落ち合う
ans = min(ans, b - 1)

# 右で落ち合う
ans = min(ans, n - a)

print(ans)
N,A,B = [int(x) for x in input().split()];

l = max(A-1,B-1);
r = max(N-B,N-A);
if (B-A)%2 == 0 :
    print(min(int((B-A)/2),l,r));
else :
    print(min(l,r));
import sys
input = sys.stdin.readline

# A - Table Tennis Training
N, A, B = map(int, input().split())

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

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

if (b-a)%2 == 0:
    print(int((b-a)/2))
else:
    print(min(a,n-b+1)+int((b-a)/2))
import sys
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

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


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

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

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

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

if (B-A)%2==0:
    print((B-A)//2)
else:
    left=B-1
    right=N-A
    print(min(left,right))
N, A, B = map(int, input().split())

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

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