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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
n, a, b = map(int, input().split())
print(math.ceil(abs(a-b)/n))

Submission status: Wrong Answer

Solution code:
N, A, B = [int(_) for _ in 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 = [int(x) for x in input().split()];
#print(A);
#print(B);
#print(N);
#lm = int(A + (B-A-1)/2);
lm = A + int((B-A-1)/2);
#print(lm);
#rm = int(N-B+1 + (B-A-1)/2);
rm = N-B+1 + int((B-A-1)/2);
#print(rm);
if (B-A)%2 == 0 :
    print(int((B-A)/2));
else :
    print(min(lm,rm));

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

l = B-1;
lm = int(A + (B-A-1)/2);
r = N-A;
rm = int(N-B+1 + (B-A-1)/2);
if (B-A)%2 == 0 :
    print(int((B-A)/2));
else :
    print(min(lm,rm));

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
N,A,B = map(int, input().split())
ans = min(B-1,N-A) 
if (B-A)%2 == 0:
    #真ん中でも会える
    ans = min(ans,(B-A)//2)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n, a, b = MI()
    d = b - a
    ans = 0
    if d%2:
        ans = min(n-a, b-1)
    else:
        ans = d//2
    print(ans)

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
ans1,ans2=10**18,10**18
if (A-B)%2==0:
  ans1=abs(A-B)//2
else:
  tmp2=max(N-A,N-B)
  tmp1=max(A-1,B-1)
  ans2=min(tmp1,tmp2)
ans=min(ans1,ans2)
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:
  tmp2=max(N-A,N-B)
  tmp1=max(A-1,B-1)
  ans=min(tmp1,tmp2)
print(ans)

Submission status: Wrong Answer

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

else:
    ans1=B-1
    ans2=N-A
    print(min(ans1,ans2))

Submission status: Wrong Answer

Solution code:
import math
n, a, b = map(int,input().split())
ans = (abs(a - b) + 1) // 2
print(ans)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
def min(a, b):
  if a < b:
    return a
  return b

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

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
def min(a, b):
  if a < b:
    return a
  return b

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

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
key=B-A
if key%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())
key=B-A
if key%2==0:
  print((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:
  s = a-1
  b -=s
  c = (b-1)//2+1+s
  
  t = n-b
  a += t
  d = (n-a)//2+1+t
  print(min(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(n-a,b-1))

Submission status: Wrong Answer

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

df = abs(A - B)
dA = N - A
dB = B - 1

if df % 2 == 0:
    print(int(df // 2))
else:
    if A == 1 or B == N:
        print(((df - 1) // 2)+1)
    else:
        if dA > dB:
            print(dB)
        else:
            print(dA)

Submission status: Wrong Answer

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

df = abs(A - B)
dA = N - A
dB = B - 1

if df % 2 == 0:
    print(int(df / 2))
else:
    if dA > dB:
        print(dB)
    else:
        print(dA)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n,a,b = readInts()

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())
top = N-A
bottom = B-1
m = (B-A)//2 if (B-A)%2 == 0 else 10e9
print(min(top, bottom, m))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
N,A,B=map(int,input().split())
key=B-A
if key%2==0:
  print(int(key/2))
else:
  Key=math.ceil(key%2)
  print(int(Key+1))

Submission status: Wrong Answer

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


resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    N, A, B = [int(i) for i in input().split()]
    if (B - A) % 2 == 0:
        print((B - A) // 2)
        return
    # A->1 or B->N
    elif A - 1 < N - B:
        # A->1
        if B - (A - 1) == 2:
            print(A - 1 + 1)
        elif (B - (A - 1) - 1) % 2 == 0:
            print(A - 1 + ((B - (A - 1) - 1) // 2))
        else:
            print(A - 2 + ((B - (A - 2) - 1) // 2))
    else:
        if A + (N - B) == N - 1:
            print(N - B + 1)
        elif (N - A + (N - B)) % 2 == 0:
            print(N - B + ((N - A + (N - B)) // 2))
        else:
            print(N - B + 1 + ((N - A + (N - B + 1)) // 2))
    return


resolve()

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-min(a,b),max(a,b)-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(n-min(a,b),max(a,b)-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:
  if n-min(a,b)<max(a,b)-1:
    print(n-min(a,b))
  else:
    print(max(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(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:
  s = max(abs(A-N), abs(B-N))
  t = max(abs(A-1), abs(B-1))
  print(min(s, t))

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

def f(n,a,b):
    if (a + b) % 2:
        return min(max(a,b) - 1, n - min(a,b))
    else:
        d = b-a
        return d//2

def main():
    N,A,B = map(int,input().split())
    print(f(N,A,B))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def f(n,a,b):
    if (a + b) % 2:
        return max(a,b) - 1
    else:
        return abs(a-b)//2

def main():
    N,A,B = map(int,input().split())
    print(f(N,A,B))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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-A+1)//2+min(A-1, N-B))

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-A-1)//2+min(A-1, N-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((B-A-1)//2+min(A, N-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(max(b,a)-1,n-min(a,b)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from fractions import gcd
#from itertools import combinations # (string,3) 3回
#from collections import deque
#from collections import defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,a,b = readInts()
if abs(b-a)%2 == 0:
    print(abs(b-a)//2)
else:
    print(min(abs(1-max(a,b)),abs(n-min(a,b))))

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(A-1,2*N-B))

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,2*N-A))

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-a)//2)
else:
    left = a+((b-a)-1)//2
    right = (n-b+1)+(n-a+(n-b+1))//2
    print(min(right,left))

Submission status: Wrong Answer

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

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

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:
#!/usr/bin/env python3
import sys


def solve(N: int, A: int, B: int):
    if A > B:
        tmp = A
        A = B
        B = A
    
    count = 0
    while True:
        if (B - A) % 2 == 0:
            count += (B - A) // 2
            break
        elif A != 1 and B != N:
            if B-1 < N-A:
                count += A-1
                A = 1
                B = B - (A-1)

            else:
                count += N-B
                A = A + (N-B)
                B = N
        else:
            if A == 1:
                count += 1
                B -= 1
                
            elif B == N:
                count += 1
                A += 1
    print(count)
    return


# Generated by 1.1.7.1 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:
#!/usr/bin/env python3
import sys


def solve(N: int, A: int, B: int):
    if A > B:
        tmp = A
        A = B
        B = A
    
    count = 0
    while True:
        if (B - A) % 2 == 0:
            count += (B - A) // 2
            break
        elif A != 1 or B != N:
            if B-1 < N-A:
                count += A-1
                A = 1
                B = B - (A-1)

            else:
                count += N-B
                A = A + (N-B)
                B = N
        else:
            if A == 1:
                count += 1
                B -= 1
                
            elif B == N:
                count += 1
                A += 1


    print(count)
    return


# Generated by 1.1.7.1 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:
#!/usr/bin/env python3
import sys


def solve(N: int, A: int, B: int):
    if A > B:
        tmp = A
        A = B
        B = A
    
    count = 0
    while True:
        if (B - A) % 2 == 0:
            count += (B - A) // 2
            break
        else:
            if B-1 < N-A:
                count += A-1
                A = 1
                B = B - (A-1)

            else:
                count += N-B
                A = A + (N-B)
                B = N


    print(count)
    return


# Generated by 1.1.7.1 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:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline
from collections import defaultdict
from heapq import heappop, heappush

from decimal import *

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

##### 累乗 #####
# pow(x, y, z) -> x**y % z

##### 割り算の切り上げ #####
# tmp = -(-4 // 3)

##### dict の for文 #####
# for k, v in d.items():
#     print(k, v)

##### 進数の変換 #####
# bin_str = bin(i)[2:]
# oct_str = oct(i)[2:]
# hex_str = hex(i)[2:]

##### とても大きな数 と 小数の計算誤差 #####
# 「Decimal」は計算誤差を 0にできる。必要に応じて粒度を設定せよ。
# getcontext().prec = 100
#
# tmp = Decimal(i)
# A,B = map(Decimal, input().split())
# ans = A * B

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	N,A,B = inputMap()

	tmp = abs(A-B)
	if tmp % 2 == 0:
		print(tmp // 2)
	else:
		tmp1 = abs(1-A)
		tmp2 = abs(1-B)

		tmp3 = abs(N-A)
		tmp4 = abs(N-B)

		print(min(max(tmp1,tmp2), max(tmp3,tmp4)))



#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# 2分検索のリバース
def bisect_left_reverse(a, x):
    if a[0] <= x:
        return 0
    if x < a[-1]:
        return len(a)
    # 二分探索
    ok = len(a) - 1
    ng = 0
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if a[mid] <= x:
            ok = mid
        else:
            ng = mid
    return ok

def bisect_right_reverse(a, x):
    if a[0] < x:
        return 0
    if x <= a[-1]:
        return len(a)
    # 二分探索
    ok = len(a) - 1
    ng = 0
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if a[mid] < x:
            ok = mid
        else:
            ng = mid
    return ok

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# 2分検索
# 存在しない場合: None 存在する場合: その値
def binary_search(list, item):
    low = 0
    high = len(list) - 1

    while low <= high:
        mid = (low + high) //2
        guess = list[mid]
        if guess == item:
            return mid
        if guess > item:
            high = mid -1
        else:
            low = mid + 1
    return None

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# N 個のボールを K グループに分ける場合のパターン数
def sunuke(N, K, mod=10**9+7):
	if N < K or K-1 < 0:
		return 0
	else:
		return combination(N-1, K-1, mod)

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# nCr mod m
# rがn/2に近いと非常に重くなる
def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

# mを法とするaの乗法的逆元
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# nHr mod m
# 問題によって、combination()を切り替えること
def H(n, r, mod=10**9+7):
	# comb = Combination(n+r-1, mod)
	# return comb(n+r-1, r)
    return combination(n+r-1, r, mod)


class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# dfs のサンプル
def dfs(graph,parent,counter,edge):
    stk = []
    stk.append(edge)
    while len(stk) > 0:
        p = stk.pop()
        for e in graph[p]:
            if parent[p] == e:
                continue
            else:
                parent[e] = p
                counter[e] += counter[p]
                stk.append(e)

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()