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.



Sample input:
5 2 4


Sample output:
1

Submission status: Wrong Answer

Solution code:
i = input()
N, A, B = i.split()

N = int(N)
A = int(A)
B = int(B)

if (B-A)%2 == 0:
  print((B-A)/2)
else:
  e = int(min(A-1, B))
  d = abs(A-B) // 2
  print(e - d)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
i = input()
N, A, B = i.split()

N = int(N)
A = int(A)
B = int(B)

if (B-A)%2 == 0:
  print((B-A)/2)
else:
  e = int(min(max(A-1, B-1), max(N-A, N-B)))
  d = (B-A) // 2 
  print(e - d)

Submission status: Wrong Answer

Solution code:
def min_steps_v2(n, a, b):
    if (b - a) % 2 == 0:
        return int((b - a) / 2)
 
    # odd case
    a_diff = a - 1
    b_diff = n - b
 
    if a_diff > b_diff:
      steps_to_even = n - b + 1
      remain_steps = int((n - (a + steps_to_even)) / 2)
    else:
      steps_to_even = a
      remain_steps = int(((b - steps_to_even) - 1) / 2)
 
    return steps_to_even + remain_steps
 
numbers = input().split(' ')
 
n = int(numbers[0])
a = int(numbers[1])
b = int(numbers[2])
 
print(min_steps_v2(n, a, b))

Submission status: Wrong Answer

Solution code:
N, A,B = map(int, input().split())
ab = abs(A-B)
ab_ = (A+B)/2
if ab%2 ==0:
  print(ab//2)
else:
  if (A+B-2) <= (2*N -A -B):#left
    if A > B:
      print(A-1)
    else:
      print(B-1)
  else:#right
    if A > B:
      print(N-B)
    else:
      print(N-A)

Submission status: Wrong Answer

Solution code:
def min_steps_v2(n, a, b):
    if (b - a) % 2 == 0:
        return int((b - a) / 2)

    # odd case
    a_diff = a - 1
    b_diff = n - b

    if a_diff > b_diff:
      steps_to_even = n - b + 1
      remain_steps = int((n - (a + steps_to_even)) / 2)
      print(steps_to_even, remain_steps)
    else:
      steps_to_even = a
      remain_steps = int(((b - steps_to_even) - 1) / 2)

    return steps_to_even + remain_steps

numbers = input().split(' ')
 
n = int(numbers[0])
a = int(numbers[1])
b = int(numbers[2])

print(min_steps_v2(n, a, b))

Submission status: Wrong Answer

Solution code:
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:
  mid = (b - a) - 1
  print(a + mid - 1)

else:
  newA = (a + (n - b + 1))
  mid = newA + (n - newA)//2
  print((n - b + 1) + (n - newA)//2)

Submission status: Wrong Answer

Solution code:
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:
  mid = (b - a) - 1
  print(a + mid -1)

else:
  mid = n - (a + (n - b + 1))
  print(n - b + 1 + n - mid)

Submission status: Wrong Answer

Solution code:
N, A,B = map(int, input().split())
ab = abs(A-B)
ab_ = (A+B)/2
if ab%2 ==0:
  print(ab//2)
else:
  if (A+B-2) <= (2*N -A -B):
    if A > B:
      print(A-1)
    else:
      print(B-1)
  else:
    if A > B:
      print(N-B)
    else:
      print(N-A)

Submission status: Wrong Answer

Solution code:
i = input()
N, A, B = i.split()

N = int(N)
A = int(A)
B = int(B)

if abs(A-B)%2 == 0:
  print(int(abs(A-B)/2))
elif abs(A-B) == 1:
  e = int(min(max(A-1, B-1), max(N-A, N-B)))
  print(e - 1)
else:
  e = int(min(max(A-1, B-1), max(N-A, N-B)))
  d = abs(A-B) // 2
  print(e - d)

Submission status: Wrong Answer

Solution code:
N, A,B = map(int, input().split())
ab = abs(A-B)
ab_ = (A+B)/2
if ab%2 ==0:
  print(ab//2)
else:
  if (A+B-2) < (2*N -A -B):
    if A > B:
      print(A-1)
    else:
      print(B-1)
  else:
    if A > B:
      print(N-B)
    else:
      print(N-A)

Submission status: Wrong Answer

Solution code:
i = input()
N, A, B = i.split()

N = int(N)
A = int(A)
B = int(B)

if abs(A-B)%2 == 0:
  print(int(abs(A-B)/2))
else:
  e = int(min(max(A-1, B-1), max(N-A, N-B)))
  d = abs(A-B) // 2
  print(e - d)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
strargs = input()

n, a, b = map(lambda x: int(x), strargs.split())

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

else:
  print(b - 1)

Submission status: Wrong Answer

Solution code:
inp = list(map(int, input().split()))
n = inp[0]
a = inp[1]
b = inp[2]

d = b - a
if d < 0:
    d *= -1

count = 0
flag = 0
if d == 0:
    count = 0
elif d % 2 == 0:
    count = d / 2
else:
    if a < b:
        if b - 1 > n - a:
            if (n - b) - (n - a) >= 3 or (n-b) - (n-a) <= -3:
                count = ((b - a - 1) / 2) + (n - b + 1)
            else:
                count = n - a
        else:
            if (n-b) - (n-a) >= 3 or (n-b) - (n-a) <= -3:
                count = ((b - a - 1) / 2) + a
            else:
                count = b - 1
    else:
        if a - 1 > n - b:
            if (n - a) - (n - b) >= 3 or (n-a) - (n-b) <= -3:
                count = ((a - b - 1) / 2) + (n - a + 1)
            else:
                count = n - b
        else:
            if (n - a) - (n - b) >= 3 or (n-a) - (n-b) <= -3:
                count = ((a - b - 1) / 2) + b
            else:
                count = a - 1

print(int(count))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
N, A, B = [int(str) for str in input().strip().split()]

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

Submission status: Wrong Answer

Solution code:
import sys
N,A,B = map(int,input().split())
if (B-A) % 2 == 0:
  print((B-A)//2)
  sys.exit(0)
else:
  print(B-A-1)

Submission status: Wrong Answer

Solution code:
inp = list(map(int, input().split()))
n = inp[0]
a = inp[1]
b = inp[2]

d = b - a
if d < 0:
    d *= -1

count = 0
flag = 0
if d == 0:
    count = 0
elif d % 2 == 0:
    count = d / 2
else:
    if a < b:
        if b - 1 > n - a:
            if (n - b) - (n - a) >= 3 or (n-b) - (n-a) <= -3:
                count = ((b - a - 1) / 2) + (n - b + 1)
            else:
                count = n - a
        else:
            if (n-b) - (n-a) >= 3 or (n-b) - (n-a) <= -3:
                count = ((b - a - 1) / 2) + a
            else:
                count = b - 1
    else:
        if a - 1 > n - b:
            if (n - a) - (n - b) >= 3 or (n-b) - (n-a) <= -3:
                count = ((a - b - 1) / 2) + (n - a + 1)
            else:
                count = n - b
        else:
            if (n - a) - (n - b) >= 3 or (n-b) - (n-a) <= -3:
                count = ((a - b - 1) / 2) + b
            else:
                count = a - 1

print(int(count))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
N,A,B = map(int,input().split())
if (A-B) % 2 == 0:
  print((A-B)//2)
  sys.exit(0)
else:
	print(B-A-1)

Submission status: Wrong Answer

Solution code:
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)
    sys.exit(0)
  else:
    print(B-A+1)

Submission status: Wrong Answer

Solution code:
i = input()
N, A, B = i.split()

N = int(N)
A = int(A)
B = int(B)

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

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
i = input()
N, A, B = i.split()

N = int(N)
A = int(A)
B = int(B)

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

Submission status: Wrong Answer

Solution code:
numbers = input().split(' ')                                                                                                                                                                                 
                                                                                                                                                                                                             
n = int(numbers[0])                                                                                                                                                                                          
a = int(numbers[1])                                                                                                                                                                                          
b = int(numbers[2])                                                                                                                                                                                          
                                                                                                                                                                                                             
def even_diff(A, B):                                                                                                                                                                                         
  return int((B - A) / 2)                                                                                                                                                                                    
                                                                                                                                                                                                             
                                                                                                                                                                                                             
def odd_diff(N, A, B):                                                                                                                                                                                       
  a_diff = A - 1                                                                                                                                                                                             
  b_diff = N - B                                                                                                                                                                                             
                                                                                                                                                                                                             
  if a_diff > b_diff:                                                                                                                                                                                        
    return N - A                                                                                                                                                                                             
  else:                                                                                                                                                                                                      
    return int(B - 1)                                                                                                                                                                                        
                                                                                                                                                                                                             
if (a - b) % 2 == 0:                                                                                                                                                                                         
  result = even_diff(a, b)                                                                                                                                                                                   
else:                                                                                                                                                                                                        
  result = odd_diff(n, a, b)                                                                                                                                                                                 
                                                                                                                                                                                                             
print(result)

Submission status: Wrong Answer

Solution code:
inp = list(map(int, input().split()))
n = inp[0]
a = inp[1]
b = inp[2]

d = b - a
if d < 0:
    d *= -1

count = 0
flag = 0
if d == 0:
    count = 0
elif d % 2 == 0:
    count = d / 2
else:
    if a < b:
        if b - 1 > n - a:
            count = n - a
        else:
            count = b - 1
    else:
        if a - 1 > n - b:
            count = n - b
        else:
            count = a - 1

print(int(count))

Submission status: Wrong Answer

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


d = B-A
if d%2 == 1:
    d = min((B + (N-B)*2 + 1) - A, B - (1 - (A-1)*2 -1))

ans = d//2
print(ans)

Submission status: Wrong Answer

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


d = B-A
if d%2 == 1:
    d = min((B + (N-B)*2 + 1) - A, B - (-A-1))

ans = d//2
print(ans)

Submission status: Wrong Answer

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


d = B-A
if d%2 == 1:
    d = min((B + (N-B)*2) - A, B - (-A))

ans = d//2
print(ans)

Submission status: Wrong Answer

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

d = abs(A-B)
if d%2 == 1:
    d = min((A + (N-A)*2) - B, B - (-A))

ans = d//2
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import math
import string
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
from bisect import bisect, bisect_left, bisect_right

MOD = 10 ** 9 + 7
INF = float('inf')
input = lambda: sys.stdin.readline().strip()

sys.setrecursionlimit(10 ** 8)

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

Submission status: Wrong Answer

Solution code:
import sys
import math
import string
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
from bisect import bisect, bisect_left, bisect_right

MOD = 10 ** 9 + 7
INF = float('inf')
input = lambda: sys.stdin.readline().strip()

sys.setrecursionlimit(10 ** 8)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if (B-A) % 2 == 0:
    ans = (B-A) / 2
else:
    if (A-1) < (N-B) or (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)

Submission status: Wrong Answer

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

if (A-B) % 2 == 0:
    ans = (B-A) / 2
else:
    if (A-1) < (N-B) or (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)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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)
    else:
        print(n - a)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

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

if abs(A-B)%2==0:
	print(int(abs(A-B)//2))
else:
	print(min(6-min(A,B),max(A,B)-1))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
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 + int(distance)

print(ans)

Submission status: Wrong Answer

Solution code:


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


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

print(ans)

Submission status: Wrong Answer

Solution code:


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


distance = B - A
ans = 0
while (distance % 2 != 0 and distance != 1):
    A_dis= A - 1
    B_dis= N - B

    if( distance < A_dis and distance < B_dis):
        A += 1
        B -= 1
    elif(A_dis < B_dis):
        if(A != 1 ):
            A = 1
        B -= 1
    else:
        if(B != N):
            B = N
        A += 1
    ans += 1
    distance = B - A


if(distance%2==0):
    ans += distance//2
else:
    ans+=2

print(ans)

Submission status: Wrong Answer

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


distance = B - A
ans = 0
while (distance % 2 != 0 and distance != 1):
    c = 1
    c=distance//2
    A += c
    B -= c
    ans += c
    distance = B - A


if(distance%2==0):
    ans += distance//2
else:
    ans+=2

print(ans)

Submission status: Wrong Answer

Solution code:


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


distance = B - A
ans = 0
while (distance % 2 != 0 and distance != 1):
    A_dis= A - 1
    B_dis= N - B
    c=1

    if( distance < A_dis and distance < B_dis):
        c=distance//2
        A += c
        B -= c
    elif(A_dis < B_dis):
        if(A != 1 ):
            c = A_dis
            A = 1
        B -= c
    else:
        if(B != N):
            c = B_dis
            B = N
        A += c
    ans += c
    distance = B - A


if(distance%2==0):
    ans += distance//2
else:
    ans+=2

print(ans)

Submission status: Wrong Answer

Solution code:


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


distance = B - A
ans = 0
while distance % 2 != 0 and distance != 1:
    A_dis= A - 1
    B_dis= N - B
    c=1

    if( distance < A_dis and distance < B_dis):
        c=distance//2
        A += c
        B -= c
    elif(A_dis < B_dis):
        if(A != 1 ):
            c = A_dis
            A = 1
        B -= c
    else:
        if(B != N):
            c = B_dis
            B = N
        A += c
    ans += c
    distance = B - A


if(distance%2==0):
    ans += distance//2
else:
    ans+=2

print(ans)

Submission status: Wrong Answer

Solution code:


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


distance = B - A
ans = 0
while distance % 2 != 0 and distance != 1:
    A_dis= A - 1
    B_dis= B - N
    
    if(A_dis < B_dis):
        if(A != 1 ):
            A -= 1
        B -= 1
    else:
        if(B != N):
            A += 1
        B += 1
    ans += 1
    distance = B - A


if(distance%2==0):
    ans += distance//2
else:
    ans+=2

print(ans)

Submission status: Wrong Answer

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


distance = B - A
ans = 0
while distance % 2 != 0 and distance != 1:
    A_dis= A - 1
    B_dis= B - N
    if( A_dis <= B_dis ):
        if(A != 1 ):
            A -= 1
            B -= 1
    else:
        if(B != N):
            A += 1
            B += 1
    ans += 1
    distance = B - A


if(distance%2==0):
    ans += distance//2
else:
    ans+=2

print(ans)

Submission status: Wrong Answer

Solution code:
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))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def main():
    N, A, B = map(int, input().split())
    if A % 2 == B % 2:
        return abs(A - B)//2
    else:
        x = A + 1 + (B - A - 1)//2
        y = (N - B + 1) + (- A + B + 1)//2
        return min(x, y)

print(main())

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(main())

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(main())

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans=[]
if (A-B)%2==0:
    ans.append((B-A)//2)
ans.append(B-1)
ans.append(N-A)

print(min(ans))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys


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


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, A, B)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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))

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
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))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
if (A-B)%2==0:
  ans=int(abs(A-B)/2)
else:
  C=max(A,B)
  tmp1=C-1
  D=min(A,B)
  tmp2=N-D
  ans=min(tmp1,tmp2)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,A,B = map(int,input().split())
dif = abs(A-B)
if dif%2 == 0:
  print(int(dif/2))
elif B-1 < N-A:
  print(B-1)
else:
  print(N-A)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
x,y,z = map(int,input().split())

if (z-y)%2==0:
    print((z-y)//2)
else:
    ans = min(z-1, x-y)
    print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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