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 (B-A)%2 == 0:
  answer = int((B-A)//2)
else:
  answer = min(int(A+B-1)//2, int(2*N-A-B+1)//2)
print(answer)

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

Solution (Python):

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

if (B-A) % 2 == 0:
    ansA = int((B-A)//2)
else:
    ansA = 10**19

if N-B > A-1:
    ans1 = A-1
    ans2 = int(((B-1) - (A-1))//2)
    ansB = ans1+1+ans2

elif N-B < A-1:
    ans1 = N-B
    ans2 = int(((N-A) - (N-B))//2)
    ansB = ans1+1+ans2
else:
    ans1 = N - B
    ans2 = int(((N - A) - (N - B)) // 2)
    if (B-A) % 2 == 0:
        ansB = ans1 + ans2
    else:
        ansB = ans1 +1+ans2

ans = min(ansA,ansB)
print(ans)

Solution (Python):
def main():
    n, a, b = map(int, input().split())
    ans = 0
    diff = b - a
    if diff % 2 == 0:
        ans = diff // 2
    else:
        ab = [a, b]
        len_to_opp = [0] * 2
        len_to_opp[0] = n - ab[0]
        len_to_opp[1] = ab[1] - 1
        ans = min(len_to_opp)

        len_to_self = [0] * 2
        len_to_self[0] = ab[0] - 1
        len_to_self[1] = n - ab[1]
        if len_to_self[0] < len_to_self[1]:
            ab[0] = ab[0] - (len_to_self[0] + 1) * 2
        else:
            ab[1] = ab[1] + (len_to_self[1] + 1) * 2
        temp_ans = abs(ab[0] - ab[1]) // 2
        ans = min(ans, temp_ans)

    print(ans)


if __name__ == '__main__':
    main()

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

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


print(answer)

Solution (Python):

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

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

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

print(int(ans))

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

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

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

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

Solution (Python):
[N, A, B] = [int(x) for x in input().split()]
 
dif = B-A
print((dif//2) if dif % 2== 0 else min(A-1, N-B)+ 1 + (dif-1)//2)

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

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

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

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

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

Solution (Python):


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

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

print(answer)

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


def main():
    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 - A - 1) // 2))


if __name__ == "__main__":
    main()

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

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-1)//2))

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

med = N / 2 + 0.5
Sub = B - A

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

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

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

Solution (Python):
n, a, b = (int(i) for i in input().split())

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

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 = a+((b-a-1)//2)
    elif (a-1) == (n-b):
        ans = n/2
    else:
        ans = n-b+1+((b-a-1)//2)

print(int(ans))

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

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


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

Solution (Python):
N,A,B=[int(x) for x in input().split()]

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

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

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
else:
    ans = (b-a)//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)//2
print(ans)

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


if diff % 2 == 0:
    print(diff // 2)
else:
    if N2B < A - 1:
        tmp = (N - (A + N2B))//2 + N2B
        if (N - A - N2B)%2 == 1:
            tmp = tmp + 1
        if N2A < tmp:
            print(N2A,"a")
        else:
            print(tmp)
    else:
        tmp = ((B + 1 - A) - 1)//2 + A - 1
        if ((B + 1 - A) - 1)%2 == 1:
            tmp = tmp + 1
        if B-1 < tmp: 
            print(B - 1)
        else:
            print(tmp)

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 = a+((b-a-1)//2)
    elif (a-1) == (n-b):
        ans = n/2
    else:
        ans = n-b+1+((b-a-1)//2)

print(int(ans))

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

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

Solution (Python):
from decimal import *
N,A,B = map(int, input().split())

N -= 1
A -= 1
B -= 1

ans = 0
distAB = B - A

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

print(int(ans))

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

def jud(n,a,b):
    distance_dic_before_a = []
    distance_dic_before_b = []
    distance_dic_before_a.append(a)
    distance_dic_before_b.append(b)

    turn_count = 1
    while True:
        distance_dic_after_a = []
        for a_dir in distance_dic_before_a:
            a_dir_plus = a_dir + 1
            a_dir_minus = a_dir - 1
            if a_dir_plus > n:
                a_dir_plus = n
            if a_dir_minus == 0:
                a_dir_minus = 1
            distance_dic_after_a.append(a_dir_plus)
            distance_dic_after_a.append(a_dir_minus)
        distance_dic_before_a = distance_dic_after_a

        distance_dic_after_b = []
        for a_dir in distance_dic_before_b:
            a_dir_plus = a_dir + 1
            a_dir_minus = a_dir - 1
            if a_dir_plus > n:
                a_dir_plus = n
            if a_dir_minus == 0:
                a_dir_minus = 1
            distance_dic_after_b.append(a_dir_plus)
            distance_dic_after_b.append(a_dir_minus)
        distance_dic_before_b = distance_dic_after_b

        set_a = set(distance_dic_after_a)
        set_b = set(distance_dic_after_b)
        print(set_a, set_b)
        result_set = set_a & set_b
        if len(result_set) > 0:
            return turn_count

        turn_count +=1

def jud_2(n,a,b):
    if abs(a-b) % 2 == 0:
        return abs(a-b) // 2
 
    x = n - a
    y = b - 1
 
    if x > y:
        choice_1 = a-1+1 + (y-a) // 2
        if choice_1 > y:
            return y
        else:
            return choice_1
    else:
        choice_2 = n-b+1 + (x-(n-b+1)) // 2
        if choice_2 > x:
            return x
        else:
            return choice_2

print(jud_2(n,a,b))

Solution (Python):



def main():
    (n, a, b) = map(int, input().split(" "))
    ans = abs(a - b)
    if ans % 2 == 0:
        ans //= 2
    else:
        ato1 = a - 1
        bton = n - b
        if ato1 <= bton:
            
            b = b - ato1
            if b % 2 == 0:
                ans = b // 2 + ato1
            else:
                ans = b // 2 + ato1 + 1
        else:
            
            a = a + bton
            if abs(n - a) % 2 == 0:
                ans = (n - a) // 2 + bton
            else:
                ans = (n - a) // 2 + bton + 1
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
n, a, b = map(int, input().split())
if (a - 1) >= (n - b):
    count = (n-b)
    a = a + (n - b)
    b = n
else:
    count = (a - 1)
    b = b - (a - 1)
    a = 1

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

Solution (Python):
n, a, b = map(int, input().split())
if (a - 1) >= (n - b):
    count = (n-b)
    a = a + (n - b)
    b = n
else:
    count = (a - 1)
    b = b - (a - 1)
    a = 1

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

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(N-A,B-1,C,D))

Solution (Python):
n, a, b = map(int, input().split())
if (a - 1) >= (n - b):
    count = (n-b)
    a = a + (n - b)
    b = n
else:
    count = (a - 1)
    b = b - (a - 1)
    a = 1

if ((b - a) % 2 == 0):
    print(min(min(b-1,n-a),(b-a)//2))
elif a == 1 and (b - a) % 2 != 0:
    print(min(min(b - 1, n - a), (b - 1 - a) // 2 + 1) + count)
    
elif b == n and (b - a) % 2 != 0:
    print(min(min(b - 1, n - a), (b - 1 - a) // 2 + 1)+count)
elif (b - a) == 3:
    print(min(b - 1, n - a) - 1+count)
elif (b - a) >= 5 and (b - a) % 2 != 0:
    print(min(b - 1, n - a) - 2+count)
else:
    print(min(b-1,n-a)+count)

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

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

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

    if B-A == 1:
        print(B-1)

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

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

Solution (Python):
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 + (N - (A + (N - B) + 1)) // 2))

Solution (Python):
def main():
  s = input().split()
  n = int(s[0])
  a = int(s[1])
  b = int(s[2])
  
  if (b - a) % 2 == 0:
    print((b - a) // 2)
    return
  
  if a - 1 <= n - b:
    print(a + (b - a - 1) // 2)
    return
  
  print(n - b + 1 + (b - a - 1) // 2)
  
main()

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

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

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

Solution (Python):
n, a, b = [int(x) for x in input().split()]
c = b - a
if c % 2 == 0:
    print(c // 2)
    exit()
d = n - a
e = b - 1
f = ((n - b) + 1) + ((n - ((n - b) + 1 + a)) // 2)
g = a + ((b - a) // 2)
print(min([d, e, f, g]))

Solution (Python):




'''
条件に合うものを絞り込む
data = [1, 2, 3]
s = [x for x in data if x % 3 == 0]
'''

'''
文字配列を数値に
l_si = ['-10', '0', '100']

l_si_i = [int(s) for s in l_si]
'''

'''
a = [2, 4, 6, 8]
b = [3, 6, 9]

print(list(set(a) | set(b)))  
print(list(set(a) & set(b)))  
'''

'''
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
count = 0
while len([x for x in A if x % 2 == 0]) == N:
    A = list(map(lambda y: y / 2, A))
    count += 1
print(count)
'''

'''
.append(要素)
.extend(要素)
.insert(場所,要素)
del 配列名[場所]
-1で末尾で末尾から一つ前
'''
'''
間に空白追加
' '.join(lis)
'''
'''
copy.copy(配列名)6

'''
'''
sort()50
sorted(reverse=true)
'''
'''
2分探索
bisect.bisect_left(リスト, 要素)
'''


from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
from decimal import *
l_si_i = [int(s) for s in stdin.readline().rstrip().split()]
n = l_si_i[0]
a = l_si_i[1]
b = l_si_i[2]

a = Decimal(a)
b = Decimal(b)
n = Decimal(n)
num = b - a


if num % 2 == 0:
    res = Decimal(num)/Decimal(2)
    print(res)
elif num % 2 == 1:

    res1 = a - 1
    b1 = b - (a - 1)
    a1 = 1
    num1 = b1 - a1
    if num1 % 2 != 0:
        res1 += 1
        b1 -= 1
    res1 += (b1 - a1)/2

    res2 = n - b
    a2 = n-b+a
    b2 = n
    num2 = b2 - a2
    if num2 % 2 != 0:
        res2 += 1
        a2 += 1
    res2 += (b2 - a2) / 2
    res = 0
    if res1 <= res2:
        res = res1
    else:
        res = res2
    print(int(res))

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

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

Solution (Python):
from sys import stdin
N,A,B = [int(x) for x in stdin.readline().rstrip().split()]
if (B - A) % 2 == 0:
    print((B-A)//2)
else:
    ans1 = 0
    a1 = A
    b1 = B
    ans1 += (a1-1)
    b1 -= (a1-1)
    a1 = 1
    
    if b1 % 2 == 0:
        b1 -= 1
        ans1 += 1
    ans1 += ((b1 -1)//2)
    
    ans2 = 0
    a2 = A
    b2 = B
    ans2 += (N-B)
    a2 += (N-B)
    b2 += (N-B)
    if (a2 % 2) != (b2 % 2):
        a2 += 1
        ans2 += 1
    ans2 += ((b2 - a2)//2)
    print(min(ans1,ans2,B-1,N-A))

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

Solution (Python):


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

if (B-A) % 2 == 0:
    C=(B-A)//2
else:
    if A-1 > N-B:
        C1=N-B
        C2=(N-A-C1) // 2
        C= C1 + C2 + 1
    else:
        C1=A-1
        C2=(B-1-C1) // 2
        C= C1 + C2 + 1

print(C)

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

if (b - a)%2 == 0:
  ans = int((b - a)//2)
else:
  ans4 = int(int(a) + int((b-a-1)//2))
  ans5 = int(int(N-b+1) + int((b-a-1)//2))
  ans = int(min(ans4,ans5))
  
print(ans)

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

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

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

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

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

if (b-a)%2 == 0:
    print((b-a)//2)
elif n-a < b-1:
    al = n-b+1
    b = n
    a += al
    r = (b-a)//2+al
    print(max(r, 1))
else:
    be = a
    b -= a
    a = 1
    r = (b-a)//2+be
    print(max(r, 1))

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

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

Solution (Python):
def main():
    N, A, B = map(int, input().split())
    result = N
    if (A % 2 == 0 and B % 2 == 0) or  (A % 2 == 1 and B % 2 == 1):
        result = abs(A - B) // 2
    else:
        if A - 1 < N - B:
            result = ((B - 1) - (A - 1 + 1)) // 2 + (A - 1 + 1)
        else:
            result = ((N - A) - (N - B + 1)) // 2 + (N - B + 1)

    print(int(result))

if __name__ == '__main__':
    main()

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

if (b - a) % 2 == 0:
  print((b - a) // 2)
else:
  anses = [b - 1, n - a]
  x = (a - 1) + 1
  y = (n - b) + 1
  if (b - x) - 1 > 0:
    anses.append(x + ((b - x) - 1) // 2)
  if n - (a + y) > 0:
    anses.append(y + (n - (a + y)) // 2)
  print(min(anses))

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

Solution (Python):

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

Solution (Python):
n, a, b = [int(_) for _ in input().split()]

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

Solution (Python):
n, a, b = (int(i) for i in input().split()) 
dif = b-a

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

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

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

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

Solution (Python):

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

Solution (Python):
a = list(map(int,input().split()))
N = a[0]
A = a[1]
B = a[2]

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

Solution (Python):
n, a, b = list(map(int, input().rstrip().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)

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

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

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

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

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

Solution (Python):


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

if (a - b) % 2 == 0:
    if a - b > 0:
        print((a-b)//2)
    else:
        print((b-a)//2)
else:
    d = 0
    if a - b > 0:
        d = a - b
    else:
        d = b - a
    min_x = 0
    top_a = a - 1
    top_b = b - 1
    if top_a < top_b:
        min_x = top_a + (d + 1)//2 
    else:
        min_x = top_b + (d + 1)//2 
    
    bot_a = n - a
    bot_b = n - b
    if bot_a < bot_b:
        min_x1 = bot_a + (d + 1)//2 
    else:
        min_x1 = bot_b + (d + 1)//2 
    if min_x > min_x1:
        min_x = min_x1
    print(min_x)

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

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

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

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

a_length=a-1
b_length=n-b

if not (b-a)%2:
    print((b-a)//2)
elif b_length>=a_length:
    print(a+(b-a-1)//2)
elif b_length<a_length:
    print(n-b+1+(b-a-1)//2)

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

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

        c = 0
        if 1 < A:
            c += A - 1
        c += 1
        B1 = B - c
        A1 = 1
        X = abs(A1 - ((A1 + B1) // 2)) + c
        if B1 < A1:
            X = 9999999999999999999999999999

        c = 0
        if B < N:
            c += N - B
        c += 1
        A2 = A + c
        B2 = N
        Z = abs(A2 - ((A2 + B2) // 2)) + c
        if B2 < A2:
            Z = 9999999999999999999999999999

        print(min(Y, X, Z))


main()

Solution (Python):
n, a, b = map(int, input().split())
 
ab = b-a
nb = n-b
if ab%2 == 0:
  print(ab//2)
else:
  if n-a > b-1:
    t = a-1
    b_i = b-t
    if(b_i-1)%2 == 0:
      print((b_i-1)//2 + t)
    else:
      print((b_i-2)//2 + t+1)
  else:
    t = n-b
    a_i = a + t
    if (n- a_i)%2 ==0:
      print((n- a_i)//2 + t)
    else:
      print( (n-(a_i+1))//2 +t+1 )

Solution (Python):
N, a, b = map(int,input().split())
if (b-a)%2 == 0:
    print((b-a)//2)
else:
    a0 = a
    b0 = b
    ans = 10 ** 18
    tmp = 0
    t = a-1
    tmp += t
    a -= t
    b -= t
    b -= 1
    tmp += 1
    tmp += (b-a)//2
    ans = min(tmp, ans)
    tmp = 0
    t = N-b0
    tmp += t
    b0 += t
    a0 += t
    a0 += 1
    tmp += 1
    tmp += (b0-a0)//2
    ans = min(tmp, ans)
    print(ans)

Solution (Python):
import sys
bbn=1000000007
	

		
def main():
	n, a, b= map(int, input().split())
	
	k=b-a
	if k % 2 ==0:
		return k // 2
		
	to=a+((b-a-1)//2)
	tn=(n-b+1)+(n-(a+(n-b+1)))//2
	return min(to,tn)
	
	

isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

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

Solution (Python):
n, a, b = [int(i) for i in input().split()]

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

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


if(diff%2==0):
    print(diff//2)
else:

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

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

Solution (Python):
N, A, B = [int(x) for x in input().split(' ')]
absdist = abs(A - B)
maxdist1 = max(A-1, B-1)
maxdistN = max(N-A, N-B)

if absdist % 2 == 1:
    edgedist = min(A-1, B-1, N-A, N-B)
    returndist = (absdist + 1) // 2 + edgedist
    print(min(maxdist1, maxdistN, returndist))
else:    
    print(absdist // 2)

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

ans1 = 10000000000000000000


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


ans2 = min(b-1, n-a)



c = 0
ans3 = 10000000000000000000
if (b-a)%2 == 1:
    if a-1 <= n-b:
        c = a - 1
        a, b = 1, b-c
        ans3 = c + (b-2)//2 + 1
    else:
        c = n - b
        a, b = a + c, n
        ans3 = c + (n-(a+1))//2 +1
print(min(ans1, ans2, ans3))

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

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

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

sho=min(a,b)
dai=max(a,b)

if((dai-sho)%2==0):
    print((dai-sho)//2)
else:
    sa=[0]*2
    sa[0]=sho+dai-2
    sa[1]=2*n-sho-dai
    if(sa[0]<sa[1]):
        print((sa[0]+1)//2)
    else:
        print((sa[1]+1)//2)

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

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

Solution (Python):

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

diff = abs(b-a)
result = 0
if diff % 2 == 0:
    result = diff // 2
else:
    if a < (n-b+1):
        n_a = 1
        n_b = b - a
        result = a
        tmp = (n_b-1)//2
        result += tmp
    else:
        n_a = a + n - b + 1
        n_b = n
        result = n-b+1
        tmp = (n-n_a)//2
        result += tmp

print(result)

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

    print(min(first, last))

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


if (b - a) % 2 == 0:
    print((b - a) // 2)
else:
    test = (b - a) // 2
    left = a - 1
    right = n - b
    if left >= right:
        print(n - a - test)
    else:
        print(b - 1 - test)

Solution (Python):

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


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

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

if abs(b-a)%2==0:
    print(abs(b-a)//2)
elif abs(b-a)%2==1:
    lst = [a-1,n-b]
    if lst[0]>lst[1]:
        print((n-b+1)+(n-(a+(n-b+1)))//2)
    elif lst[0]<lst[1]:
        print((a-1+1)+(b-a-1)//2)
    elif lst[0]==lst[1]:
        print((a-1+1)+(b-a-1)//2)