Problem:
 Score : 300 points    Problem Statement 2N players are running a competitive table tennis training on N tables numbered from 1 to N .  The training consists of rounds .
In each round, the players form N pairs, one pair per table.
In each pair, competitors play a match against each other.
As a result, one of them wins and the other one loses.  The winner of the match on table X plays on table X-1 in the next round,
except for the winner of the match on table 1 who stays at table 1 .  Similarly, the loser of the match on table X plays on table X+1 in the next round,
except for the loser of the match on table N who stays at table N .  Two friends are playing their first round matches on distinct tables A and B .
Let's assume that the friends are strong enough to win or lose any match at will.
What is the smallest number of rounds after which the friends can get to play a match against each other?      Constraints  2 \leq N \leq 10^{18}  1 \leq A < B \leq N  All input values are integers.         Input Input is given from Standard Input in the following format:  N  A  B       Output Print the smallest number of rounds after which the friends can get to play a match against each other.        Sample Input 1 5 2 4      Sample Output 1 1  If the first friend loses their match and the second friend wins their match, they will both move to table 3 and play each other in the next round.       Sample Input 2 5 2 3      Sample Output 2 2  If both friends win two matches in a row, they will both move to table 1 .

Solution (Python):
n,a,b = map(int, input().split())
if abs(a-b)%2 ==0:
    print(abs(a-b)//2)
else:
    to_one_or_n = min(min(a,b) -1, n - max(a,b))
    wait = 1
    face_to_face = (abs(a-b) - 1)//2
    print(to_one_or_n + wait + face_to_face)

Solution (Python):
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)

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

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

Solution (Python):
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)

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

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

Solution (Python):
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))

Solution (Python):
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))

Solution (Python):
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)

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

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

Solution (Python):
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)

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

Solution (Python):
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)

Solution (Python):
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) + (- A + B + 1)//2
        return min(x, y)

print(main())

Solution (Python):
def main():
    N, A, B = list(map(int, input().split()))
    if (A ^ B) & 1:
        return min((A - 1) + 1 + (B - A - 1) // 2,
                   (N - B) + 1 + (N - (A + N - B + 1)) // 2)
    return (B - A) // 2

print(main())

Solution (Python):
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)

Solution (Python):
n, a, b = map(int, input().split())
if (a+b)%2:
  if a-1 <= n-b:
    print(a+(b-a-1)//2)
  else:
    print(n-b+1+(n-(a+n-b+1))//2)
else:
  print((b-a)//2)

Solution (Python):
n,a,b=map(int,input().split())
if a>b: a,b=b,a

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

Solution (Python):

import sys


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



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = int(next(tokens))  
    B = int(next(tokens))  
    solve(N, A, B)

if __name__ == '__main__':
    main()

Solution (Python):
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)

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

Solution (Python):
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)

Solution (Python):
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)
    
print(ans)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
n, a, b = [int(i) for i in input().split()]
a_distance = a-1
b_distance = n-b
ab_distance = b - a

if ab_distance % 2 == 0:
  result = ab_distance//2
else:
  if a_distance < b_distance:
    result = a_distance + (ab_distance-1)//2 + 1
  else:
    result = b_distance + (ab_distance-1)//2 + 1
print(result)

Solution (Python):



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

N_given,A_given,B_given = input_multiple_number()

cnt = 0
while True:
    if (B_given - A_given)%2 == 0:
        print(cnt + (B_given-A_given)//2)
        exit(0)
    else:
        if (N_given - B_given) > (A_given-1):
            cnt += (A_given-1)
            cnt += 1
            A_given = 1
            B_given -= cnt
        else:
            cnt += (N_given - B_given)
            cnt += 1
            B_given = N_given
            A_given += cnt

Solution (Python):
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))

Solution (Python):
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)

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

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

Solution (Python):
n,a,b = map(int,input().split())
if a % 2 == b % 2:
    print(abs(a-b)//2)
else:
    left = (a+b-1)//2
    right = (n*2-a-b+1)//2
    print(min(left,right))

Solution (Python):
N, A, B = map(int, input().split())
d = A - B if A > B else B - A
d2 = d // 2
d3 = d % 2
if d3 == 0:
  ans = d2
else:
  bigger = B
  smaller = A
  if A > B:
    bigger = A
    smaller = B
  shortest = smaller if N - bigger + 1 > smaller else N - bigger + 1
  ans = shortest + d2
  
  

print(ans)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)//2)

Solution (Python):
import sys
input = sys.stdin.readline




'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''

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

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

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

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

print(ans)

Solution (Python):
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)

Solution (Python):
"""
AtCoder Grand Contest 039  A - Connection and Disconnection


Sの中で、隣り合う文字が同じ場合、連続しないよう書き換える
・abba -> abca
・abbba -> abcba：奇数個連続している場合、（連続してる個数）// 2 書き換える
・abbbba -> abcbca：偶数個連続している場合、（連続してる個数）// 2 書き換える。奇数個と同じ

また、Sを並べていく中で、「Sの末尾の文字群」と「Sの先頭の文字群」が同じ場合も、書き換えが必要。
S = abcda
SSSSS = abcda abcda abcda abcda abcda

文字列の両端は、普通に処理するのでなく、同じ文字であれば合算する形で処理したい
aaabcdaaa aaabcdaaa aaabcdaaa aaabcdaaa aaabcdaaaだと、間にaが6こ続くパターンと、全体の両端にaaaがある、みたいな。

Sが全部同じ文字だと、話がちょっと違って、交互に違う文字が出るように変える。これがコーナーケースかな？


（被らせないために）使えない文字は多くても2文字なので、書き換え先について悩むことはない。
"""
"""
AtCoder Grand Contest 041  A - Table Tennis Training

勝った人がX-1の卓、負けた人がX+1の卓で、引き分けはないから、±1のどちらかが絶対におこる
A,Bの間の距離が偶数の時、一方が勝ち一方が負けることで、差が2埋まるから、(B-A)/2回の試合後に、二人が試合できるはず
距離が奇数だと、
・端っこの卓で出会う
・一方が一回端っこの卓で足踏みしてからお互いの距離が縮まるように勝敗を決める
だと思う→一回端っこで足踏みしたら、そこで待つ必要もないので、端っこで出会うはなくていいかも。
二人の距離が奇数かつ、差が1なら両端のどちらかで出会うし、そうでなければ、一回足踏みののち、出会う方向に移動する形か

A側で一回足踏みするなら、足踏みが終わるまでにかかる試合数がa回で、そこから出会うまでが、(b-a-1) / 2回
B側で一回足踏みするなら、足踏みが終わるまでにかかる試合数がN-b+1回で、そこから出会うまでが、(N-(a+N-b+1)) / 2 = (b-a-1) / 2回
"""

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)

Solution (Python):
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)

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

Solution (Python):
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()

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

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

Solution (Python):
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)

Solution (Python):
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)

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

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

Solution (Python):
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))

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

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

Solution (Python):
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)

Solution (Python):

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


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


print(ans)

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

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

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

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

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

else:
    answer_1 = ((N - A) + (N - B) + 1) // 2
    answer_2 = ((A - 1) + (B - 1) + 1) // 2

    print(min(answer_1, answer_2))

Solution (Python):
n, a, b = (int(x) for x in input().split())
if (b - a) % 2 == 0:
  ans = (b - a) // 2
elif (a - 1) < (n - b):
  ans = (a - 1) + 1 + (b - a - 1) // 2
else:
  ans = (n - b) + 1 + (b - a -1) // 2
print(ans)

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

Solution (Python):
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))

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

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

Solution (Python):
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))

Solution (Python):

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()

Solution (Python):
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()

Solution (Python):
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)

Solution (Python):
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+(b-a-1)//2)
    else:
        print(n-b+1+(b-a-1)//2)

Solution (Python):
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()

Solution (Python):
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()

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
def main():
    n, a, b = map(int, input().split())

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

    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
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)

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

Solution (Python):

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

Solution (Python):
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))

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
n, a, b = [int(i) for i in input().split()]
res = (b-a) // 2 if (b-a) % 2 == 0 else min(a-1, n-b) + 1 + (b-a-1)//2
print(res)

Solution (Python):
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))

Solution (Python):
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)

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

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

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


if __name__ == '__main__':
    main()

Solution (Python):
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)

Solution (Python):
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))

Solution (Python):

[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)

Solution (Python):
[N,A,B] = list(map(int,input().split()))
if A%2==B%2:
    output = int(abs(A-B)//2)
else:
    if A-1<=N-B:
        output = A-1+1
        B = B-(A-1+1)
        output += int(abs(1-B)//2)
    else:
        output = N-B+1
        A =  A+(N-B+1)
        output += int(abs(A-N)//2)
print(output)

Solution (Python):
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))

Solution (Python):









import sys



ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, a, b = list(map(int,ipti().split()))

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


if __name__ == '__main__':
    main()

Solution (Python):
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)

Solution (Python):

import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, A: int, B: int):
    from math import ceil
    if (B-A)%2 == 0:
        print((B-A)//2)
        
    else:
        print(min(A-1, N-B)+1+(B-A-1)//2)


    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = int(next(tokens))  
    B = int(next(tokens))  
    solve(N, A, B)

if __name__ == '__main__':
    main()

Solution (Python):
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)

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

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

ans = 1e18

if A%2 != B%2:
  work = A
  b = B-A
  a = 1
  work += (b-a) // 2
  
  ans = min(ans,work)

  work = N-B+1
  a = A+N-B+1
  b = N
  work += (b-a) // 2
  
  ans = min(ans,work)
else:
  work = (B-A) // 2
  ans = min(ans,work)
  
print(ans)

Solution (Python):
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)

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

Solution (Python):
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()

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

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

Solution (Python):


import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

n, a, b = na()

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

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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]))

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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))

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
n, a, b = map(int, input().split())
d = abs(a-b)
if d % 2 == 0:
    print(d//2)
else:
    import math
    res = min(a-1, n - b)
    res += (d+1)//2
    print(res)

Solution (Python):
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)

Solution (Python):
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

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

    ans = min(ans1, ans2)

print(ans)

Solution (Python):
N, A, B = list(map(int, input().split()))

diff = B - A

if diff % 2 == 0:
    ans = diff // 2
else:
    
    

    
    

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

print(ans)

Solution (Python):
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)

Solution (Python):
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)))

Solution (Python):
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))

Solution (Python):
N, A, B = map(int, input().split())
diff = B - A
if diff % 2 == 0:
    print(diff//2)
else:
    tmp1 = (B - A + 1) // 2
    tmp1 = B - tmp1
    tmp2 = (2 * N - B + A + 1) // 2 
    tmp2 = tmp2 - A
    print(min(N-A, B-1, tmp1, tmp2))

Solution (Python):
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))

Solution (Python):
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)

Solution (Python):
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))

Solution (Python):
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)

Solution (Python):
n, a, b = list(map(int, input().split()))
k = b - a
if k % 2 == 1:
    print(min(a-1, n-b)+1+(k-1)//2)
else:
    print(k//2)

Solution (Python):
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))

Solution (Python):
n,a,b = list(map(int,input().split()))
z=b-a
if z%2==1:
    print(min(a-1,n-b)+1+(z-1)//2)
else:
    print(z//2)

Solution (Python):
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)

Solution (Python):
from decimal import Decimal
n, a, b = map(Decimal, input().split())
if (a+b) % 2 == 1:
  if a+b < 1+n:
    a = 1 - a
  else:
    a = 2 * n + 1 - a
print(abs((a-b)/2))

Solution (Python):
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)

Solution (Python):
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)

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

Solution (Python):
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)

Solution (Python):
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)

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

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

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

if (a+b) % 2 == 0:
  print(dev)
else:
  print(adjust)

Solution (Python):
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)

Solution (Python):
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()

Solution (Python):
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
ans1 = b-1+(a-b+1)//2
ans2 = (n-a) + (n-(b+n-a)+1)//2

print(min(ans1,ans2))