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 sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

from math import ceil

def solve():
    n, a, b = MI()
    # a -= 1
    # b -= 1

    left = max(a-1, b-1)
    right = max(n-a, n-b)

    center = INF
    sa = abs(b - a) - 1
    if sa % 2 != 0:
        center = ceil(sa / 2)
    else:
        t = min(a-1, n-b)
        center = t + ceil((sa - 1) / 2) + 1
    # print(left, right, center)
    print(min([left, right, center]))


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

from math import ceil

def solve():
    n, a, b = MI()
    # a -= 1
    # b -= 1

    left = max(a-1, b-1)
    right = max(n-a, n-b)

    center = INF
    r = abs(b - a) - 1
    if r % 2 != 0:
        center = ceil(r / 2)
    # print(left, right, center)
    print(min([left, right, center]))


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

def solve():
    n, a, b = MI()
    # a -= 1
    # b -= 1

    left = max(a-1, b-1)
    right = max(n-a, n-b)

    center = INF
    r = abs(a - b + 1)
    if r % 2 != 0:
        center = r // 2 + 1
    # print(left, right, center)
    print(min([left, right, center]))


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

N, A, B = map(int,input().split(" "))
ans = 0
diff = abs(A-B)

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

print(int(ans))

Submission status: Wrong Answer

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


if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:

N, A, B = map(int,input().split(" "))
ans = 0
diff = abs(A-B)

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

N, A, B = map(int,input().split(" "))
ans = 0
diff = abs(A-B)
if diff % 2 == 0:
    ans = diff / 2
else:
    ans = B - 1
print(int(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,A,B = map(int,input().split())
sa = B-A
iti=int((B-A+1)/2 +A-1)
enu=int((B-A+1)/2 +N-B)

#print(iti,enu)

if( sa%2 == 0):
   print( int(sa/2) )
elif(iti<enu):
  print(iti)
else:
  print(enu)

Submission status: Wrong Answer

Solution code:
n,a,b = list(map(int, input().split()))
if abs(b-a)%2==0:
    print(abs(b-a)//2)
else:
    #卓1に行くコスト
    c1=max(a,b)-1
    #卓Nに行くコスト
    c2=n-min(a,b)
    print(min(c1,c2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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())
sa = (A-B) if A>B else (B-A)
iti=(B-A-1)/2 +A
enu=(B-A-1)/2 +N-B+1
if( sa%2 == 0):
   print( int(sa/2) )
else:
  print(int(iti) if iti<=enu else int(enu))

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

Submission status: Wrong Answer

Solution code:
# For taking integer inputs.
def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


N, A, B = invr()

A = min(A, B)
B = max(A, B)
res = 0

avg = (A+B) // 2
res = max((avg-A), (B-avg))
if B - A == 1:
    res = 2

print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce, lru_cache  # @lru_cache(None)
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return (int(x) for x in input().split())
def LI(): return list(Is())
def TI(): return tuple(Is())
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(S())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #


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

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce, lru_cache  # @lru_cache(None)
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return (int(x) for x in input().split())
def LI(): return list(Is())
def TI(): return tuple(Is())
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(S())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #


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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce, lru_cache  # @lru_cache(None)
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return (int(x) for x in input().split())
def LI(): return list(Is())
def TI(): return tuple(Is())
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(S())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #


n, a, b = Is()
if (a + b) % 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:
  ans=int(abs(A-B)/2)
elif (A-1)<(N-B):
  ans=int((B-A-1)/2+A)
elif (A-1)>=(N-B):
  ans=int((N-B+1)+(B-A-1)/2)
print(ans)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

#一人目と二人目の間に奇数人存在
if (B-A+1)%2!=0:
    print(B-A-1)
    exit()

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

Submission status: Wrong Answer

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

sa = (A-B) if A>B else (B-A)

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

Submission status: Wrong Answer

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

sa = (A-B) if A>B else (B-A)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n, a, b = [int(i) for i in 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())

right = max([A,B])
left = min([A,B])

if (right-left)%2 == 0:
    ans = [N-left,(right-left)//2,right-1]
    print(min(ans))
else:
    x = ((N-right)+1)
    y = ((left-1)+1)
    ans = [N-left,right-1,((N-left+x)//2)+x,((right-y-1)//2)+y]
    print(min(ans))

Submission status: Wrong Answer

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

right = max([A,B])
left = min([A,B])

if (right-left)%2 == 0:
    ans = [N-left,(right-left)//2,right-1]
    print(min(ans))
else:
    x = ((N-right)+1)
    y = ((left-1)+1)
    ans = [N-left,right-1,((N-A+x)//2)+x,((B-y-1)//2)+y]
    print(min(ans))

Submission status: Wrong Answer

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

right = max([A,B])
left = min([A,B])

if (right-left)%2 == 0:
    ans = [N-left,(right-left)//2,right-1]
    print(min(ans))
else:
    ans = [N-left,right-1]
    print(min(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n , l ,  r = list( map( int ,input().split() ))
a = 10**18
if (r - l) % 2 == 0:
  a = (r - l) //2
a = min( a , min( r -1 , n - l ))
print(a)

Submission status: Wrong Answer

Solution code:
n , l ,  r = list( map( int ,input().split() ))
a = 10**18
if (l - r % 2) == 0:
  a = (l - r) //2
a = min( a , min( r -1 , n - l ))
print(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(N-A,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((B-A)//2)
else:
  print(min(N-A,B-1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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:
s = list(map(int, input().split()))
N = s[0]
A = s[1]
B = s[2]

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

Submission status: Wrong Answer

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

if abs(A-B) % 2 == 0:
  print(int(abs(A-B) / 2))
elif abs(A-B) % 2 != 0:
  print(int(min(abs(A-1),abs(B-N)) + abs(A-B)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**8)
def ii(): 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 li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

N, A, B = mi()

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