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:
def main2():
    N, A, B = map(int, input().split())

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

if __name__ == "__main__":
    main2()

Submission status: Wrong Answer

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

if(b < a):
    swap(a, b)
ans = (b - a + 1) // 2 + ((a % 2) ^ (b % 2))

print(ans)

Submission status: Wrong Answer

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

if a == b+1:
    ans = b

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

Submission status: Wrong Answer

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

if a+1 == b:
    ans = b-1

else:
    ans = (b-a)//2
print(ans)

Submission status: Wrong Answer

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

if a+1 == b:
    ans = b-1

else:
    ans = (b+1-a)//2
print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
print(2**20)

Submission status: Wrong Answer

Solution code:

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

margin = abs(a-b)

if (a % 2 == 0 and b % 2 == 0) or (a % 2 == 1 and b % 2 == 1):
    print(margin//2)
else:
    left = max(a,b) -1
    right = min(a,b)
    print(min(left, right))

Submission status: Wrong Answer

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

if A>B:
  A,B=B,A

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

Submission status: Wrong Answer

Solution code:
def TableTennisTraining():

    num = list(map(int,input().split()))

    if abs(num[1] - num[2]) % 2 == 0:
        
        print(int(abs(num[1] - num[2])/2))
    
    else:
        
        right = max([num[0] - num[1], num[0] - num[2]])
        
        left = max([num[1] - 1, num[2] - 1])
        
        print(min([right, left]))

if __name__ == '__main__':
    TableTennisTraining()

Submission status: Wrong Answer

Solution code:
def TableTennisTraining():

    num = list(map(int,input().split()))

    if (num[1] - num[2]) % 2 == 0:
        
        print(int(abs(num[1] - num[2])/2))
    
    else:
        
        right = max([num[0] - num[1], num[0] - num[2]])
        
        left = max([num[1] - 1, num[2] - 1])
        
        print(min([right, left]))

if __name__ == '__main__':
    TableTennisTraining()

Submission status: Wrong Answer

Solution code:
def TableTennisTraining():

    num = list(map(int,input().split()))

    if (num[1] - num[2]) % 2 == 0:
        
        print(abs(num[1] - num[2])/2)
    
    else:
        
        right = max([num[0] - num[1], num[0] - num[2]])
        
        left = max([num[1] - 1, num[2] - 1])
        
        print(min([right, left]))

if __name__ == '__main__':
    TableTennisTraining()

Submission status: Wrong Answer

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

if (B-A) % 2 == 0:
    ans = (B-A+2)//2-1
else:
    if min(A-1, N-B) == A-1:
        ans = B-1
        B -= A
        A = 1
    else:
        ans = N-A
        A += N-B+1
        B = N
    if A != B:
        ans = (B-A+2)//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)//2-1
else:
    if min(A-1, N-B)==A-1:
        ans=B-1
        B-=A
        A=1
    else:
        ans=N-A
        A+=N-B+1
        B=N
    print(A,B)
    if A!=B:
        ans = (B-A+2)//2-1
    
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([B-1,N-A]))

Submission status: Wrong Answer

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

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: 
  print(min([max([A-1,B-1]),max([N-A,N-B])]))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

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

else:

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

    t = [t1, t2, t3, t4]

    ti = t.index(min(t))

    if ti == 0 or ti == 2:
        res = A + (abs(A - B) - 1) // 2
    else:
        res = B + (abs(A - B) - 1) // 2
    
    print(res)

Submission status: Wrong Answer

Solution code:
import math

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

if (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:
def main():
    N, A, B = map(int, input().split())

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if (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:
def count(x,y):
    return abs((x-y)/2)

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


if (A-B)%2==0:
    ans=count(A,B)

else:
    
    if (A-1)<(N-B):
        ans=A
        A=1
        B=B-ans
    else:
        ans=N-B+1
        A=A+ans
        B=N
    
    ans+=count(A,B)

print(int(ans))

Submission status: Wrong Answer

Solution code:
def count(x,y):
    return abs((x-y)/2)

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


if (A-B)%2==0:
    ans=count(A,B)

else:
    if A>B:
        A1=A
        B1=B
        A=B1
        B=A1
    
    
    if (A-1)<(N-B):
        ans=A
        A=1
        B=B-ans
    else:
        ans=N-B+1
        A=A+ans
        B=N
    
    ans+=count(A,B)

print(int(ans))

Submission status: Wrong Answer

Solution code:
def count(x,y):
    return abs((x-y)/2)

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


if (A-B)%2==0:
    ans=count(A,B)

else:
    if A>B:
        A1=A
        B1=B
        A=B1
        B=A1
    
    
    if (A-1)<(N-B):
        ans=A
        A=1
        B=B-ans
    else:
        ans=B
        A=A+ans
        B=N
    
    ans+=count(A,B)

print(int(ans))

Submission status: Wrong Answer

Solution code:
import math
import sys
import bisect
readline = sys.stdin.readline


def main():
    n, a, b = map(int, readline().rstrip().split())
    if (b - a) % 2 == 0:
        print((b - a) // 2)
        return
    print(min(max(a-1, b-1), max(n-a, n-b)))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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:
    ans = A + (B-A-1)/2
  else:
    ans = N-B+1 + (N-(A+N-B+1))/2
    
print(int(ans))

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<N-B:
    ans = A + (B-A-1)/2
  else:
    ans = N-B+1 + (N-(A+N-B+1))/2
    
print(int(ans))

Submission status: Wrong Answer

Solution code:
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    n,a,b = map(int,input().split())
    ans=0
    if (b-a) % 2 == 0:
        print((b-a) // 2)
    else:
        #bから1までの移動回数
        X = b-1
        #aからnまでの移動回数
        Y = n-a+1
        print(min(X, Y))

if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
N, A, B = [ int(v) for v in input().split(" ") ]


# AとBの距離が偶数のとき
distance_A_to_B = float("inf")
if (A-B) % 2 == 0:
  if (A-B) < 0:
    distance_A_to_B = int((A-B) * -1 / 2)
  else:
    distance_A_to_B = int((A-B) / 2)

distance_A_to_start = A - 1
distance_B_to_start = B - 1
distance_A_to_end = N - A
distance_B_to_end = N - B

distance_start = 0
distance_end = 0

if distance_A_to_start > distance_B_to_start:
  distance_start = distance_A_to_start
else:
  distance_start = distance_B_to_start

if distance_A_to_end > distance_B_to_end:
  distance_end = distance_A_to_end
else:
  distance_end = distance_B_to_end

result = []
result.append(distance_A_to_B)
result.append(distance_start)
result.append(distance_end)

print(min(result))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline


def main():
    n,a,b = [int(i) for i in input().strip().split()]
    if (b-a) % 2 == 0:
        print(abs(b - a) // 2)
    else:
        ans = min(a - 1, n - b) - 1 + (b - a - 1) // 2
        print(ans)
    return 



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

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

    if a==b:
        print(0)
    elif a==1:
        print(str(b))
    elif b==1:
        print(str(a))
    else:
        if a > b:
            print(a-b)
        else:
            print(b-a)

if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline


def main():
    n,a,b = [int(i) for i in input().strip().split()]
    if abs(a - b) % 2 == 0:
        print(abs(a - b) // 2)
    else:
        ans = min(a - 1, n - b) - 1 + (a - b - 1) // 2
        print(ans)
    return 



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline


def main():
    n,a,b = [int(i) for i in input().strip().split()]
    if abs(a - b) % 2 == 0:
        print(abs(a - b) // 2)
    else:
        left = min(a, b)
        right = max(a, b)
        ans = min(right - 1, n - left)
        print(ans)
    return 



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

a = 0

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

Submission status: Wrong Answer

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

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

if (N-A) > (B-1):
  print(B-1)
else:
  print(N-A)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

print(ans)

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:
    if A > B:
        A, B = B, A
    print(min(B-1, N-A))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
res = 0
if abs(a-b)%2:
    La = abs(1-a)
    Ra = abs(10-a)
    Lb = abs(1-b)
    Rb = abs(10-b)
    if min(La,Ra) < min(Lb,Rb):
        if La < Ra:
            res = La+1
            a = 1
            b-=res
        else:
            res = Ra+1
            a = 10
            b+=res
    else:
        if Lb < Rb:
            res = Lb+1
            b = 1
            a -= res
        else:
            res = Rb+1
            b = 10
            a += res
print(res+abs(a-b)//2)

Submission status: Wrong Answer

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

if res % 2:
    print(res//2+1)
else:
    print(res//2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

if n - b < a - 1:
    p = n - b
    a += n - b
    b = n
    print(math.ceil(abs(a - b) / 2) + p)
else:
    p = a - 1
    b -= a - 1
    a = 1
    print(math.ceil(abs(a - b) / 2) + p)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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 = int((b-a-1)/2) + min(a-1, n-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 = int((b-a)/2) + min(a-1, n-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 = int((b-a)/2) + min(a-1, n-b) + 1

print(ans)

Submission status: Wrong Answer

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

ans = int((b-a)/2) + ((b-a)%2==1)*2
print(ans)

Submission status: Wrong Answer

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

ans = int((b-a)/2)+((b-a)%2==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(b-1, n-a)
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(b-1, n-a+1)
print(ans)

Submission status: Wrong Answer

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

    if (A-1)>=(N-B):
      B=2*N-B+1
      return int((B-A)/2)
    

print(find(N,A,B))

Submission status: Wrong Answer

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

    if (A-1)>(N-B):
      B=2*N-B+1
      return int((B-A)/2)
    

print(find(N,A,B))

Submission status: Wrong Answer

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

    if (A-1)>(N-B):
      B=2*N-B
      return int((B-A)/2)
    

print(find(N,A,B))

Submission status: Wrong Answer

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

    if (A-1)>(N-B):
      B=2*N-B
      return int((B-A)/2)
    
  else:
    return int((B-A)/2+2)
print(find(N,A,B))

Submission status: Wrong Answer

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

    if (A-1)<(N-B):
      B=2*N-B
      return int((B-A)/2)
    
  else:
    return int((B-A)/2+2)
print(find(N,A,B))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
n, a, b = [int(w) for w in input().split()]
if (a + b) % 2 == 0:
    ans = (b - a) // 2
else:
    if b - 1 > n - a:
        ans = a - 1
        ans += (b-a)//2
    else:
        ans = n - b
        ans += (b-a)//2
print(ans)

Submission status: Wrong Answer

Solution code:
n, a, b = [int(w) for w in input().split()]
if (a + b) % 2 == 0:
    ans = (b - a) // 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((b-a)//2)
else:
    print(min(b-1,n-a))

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:
    print(min(b-1, n-a))

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:
    print(min(abs(1-b), abs(n-a)))

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:
    print(max(abs(1-a), abs(1-b)))

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:
    print(min(n-a, n-b))

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:
    if n-a < n-b:
        print(n-a)
    else:
        print(n-b)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n, a, b = map(int, input().split())
if (b - a) % 2 < 1:
    print((b - a) // 2)
else:
    print(min((a + b - 1) // 2, (2 * n - a - b + 1)))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n, a, b = map(int, input().split())
if (b - a) % 2 < 1:
    print((b - a) // 2)
else:
    print(min(max(a - 1, b - 1), max(n - a, n - b)))

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
c = a % 2
d = b % 2

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    n,a,b=map(int,input().split())
    di = 0
    if (b-a)%2==1:
        w = a-1
        l = n-b
        di = (w - l)
        if di < 0:
            di -= 1
        else:
            di += 1
        a += di
        if a < 1:
            a = 1
        b += di
        if b > n:
            b = n
    #print(a,b,di)
    print((b-a)//2 + abs(di))
    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n,a,b=map(int,input().split())
    di = 0
    if (b-a)%2==1:
        w = a-1
        l = n-b
        di = (w - l)
        if di < 0:
            di -= 1
        elif di > 0:
            di += 1
        a += di
        if a < 1:
            a = 1
        b += di
        if b > n:
            b = n
    print((b-a)//2 + abs(di))
    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n,a,b=map(int,input().split())
    di = 0
    if (b-a)%2==1:
        w = a-1
        l = n-b
        di = w - l
        if di < 0:
            di -= 1
        else:
            di += 1
        a += di
        if a < 1:
            a = 1
        b += di
        if b > n:
            b = n
    print(b-(a+b)//2 + abs(di))
    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(500000)
MOD = 10**9+7

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

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

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

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

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N, A, B = [int(_) for _ in input().split()]
d = B - A
if d % 2:
    print(min(N - A, B - 1))
else:
    print(d // 2)

Submission status: Wrong Answer

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

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

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:
    print(abs(A - B)//2 + 1)

Submission status: Wrong Answer

Solution code:
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

MOD = 10 ** 4 + 7

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

if (B - A) % 2 == 0:
    print((B - A) // 2)
else:
    ans = []
    l = (A - 1)
    r = B - l - 1
    x = l + 1 + (r - 1) // 2
    ans.append(x)
    r = (N - B)
    l = A + r
    x = r + 1 + (r - l + 1) // 2
    ans.append(x)
    print(min(ans))

Submission status: Wrong Answer

Solution code:
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

MOD = 10 ** 4 + 7

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

if (B - A) % 2 == 0:
    print((B - A) // 2)
else:
    ans = [B - 1, N - A]
    l = (A - 1)
    r = B - l - 1
    x = l + 1 + (r - 1) // 2
    ans.append(x)
    r = (N - B)
    l = A + r
    x = r + 1 + (r - l + 1) // 2
    ans.append(x)
    print(min(ans))

Submission status: Wrong Answer

Solution code:
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

MOD = 10 ** 4 + 7

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

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

Submission status: Wrong Answer

Solution code:
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

MOD = 10 ** 4 + 7

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

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