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:
n,a,b=map(int,input().split())
ans =0

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

Submission status: Wrong Answer

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

if abs(a-b)%2:
    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 =0

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    N,A,B=map(int,readline().split())
    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:
import sys

input = sys.stdin.readline
MOD = 1000000007

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

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

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline
MOD = 1000000007

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

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

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+(b-a-1)//2
 
print(ans)

Submission status: Wrong Answer

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

#場合分けで考える
#b-aが偶数の場合、お互いに移動すればよい
#b-aが奇数の場合、末端に近いほうが端まで移動し、その後いターン消費して、距離をお互いに詰める

if (b-a)%2==0:
    ans = int((b-a)/2)
else:
    #端までの距離が近いほうの移動ステップ
    #端まで移動した際のお互いの距離は変化していない、そこから1ターン消費する
    #距離が偶数になるのでお互いに移動する
    ans = 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())

#場合分けで考える
#b-aが偶数の場合、お互いに移動すればよい
#b-aが奇数の場合、末端に近いほうが端まで移動し、その後いターン消費して、距離をお互いに詰める

if (b-a)%2==0:
    ans = (b-a)//2
else:
    #端までの距離が近いほうの移動ステップ
    #端まで移動した際のお互いの距離は変化していない、そこから1ターン消費する
    #距離が偶数になるのでお互いに移動する
    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())

#場合分けで考える
#b-aが偶数の場合、お互いに移動すればよい
#b-aが奇数の場合、末端に近いほうが端まで移動し、その後いターン消費して、距離をお互いに詰める

if (b-a)%2==0:
    ans = int((b-a)/2)
else:
    #端までの距離が近いほうの移動ステップ
    #端まで移動した際のお互いの距離は変化していない、そこから1ターン消費する
    #距離が偶数になるのでお互いに移動する
    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())

#場合分けで考える
#b-aが偶数の場合、お互いに移動すればよい
#b-aが奇数の場合、末端に近いほうが端まで移動し、その後いターン消費して、距離をお互いに詰める

if (b-a)%2==0:
    ans = int((b-a)/2)
else:
    #端までの距離が近いほうの移動ステップ
    #端まで移動した際のお互いの距離は変化していない、そこから1ターン消費する
    #距離が偶数になるのでお互いに移動する
    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())

#場合分けで考える
#b-aが偶数の場合、お互いに移動すればよい
#b-aが奇数の場合、末端に近いほうが端まで移動し、その後いターン消費して、距離をお互いに詰める

if (b-a)%2==0:
    ans = int((b-a)/2)
else:
    #端までの距離が近いほうの移動ステップ
    #端まで移動した際のお互いの距離は変化していない、そこから1ターン消費する
    #距離が偶数になるのでお互いに移動する
    ans = int(min(a-1,n-b)+1+(b-a-1)/2)

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    n, a, b = MII()
    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=[int(x) for x in 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=[int(x) for x in 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 B - A <= 1:
    print(min(max(A - 1, B - 1), max(N - A, N - B)))
elif (A - B) % 2 == 0:
    print((B - A) // 2)
else:
    print(B - A + 1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
d=max(a,b)-min(a,b)-1
if d%2:print(-(-d//2))
else:
    print(min(max(n-a,n-b),max(a-1,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:
    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:
    # left = a - 1
    # right = n - b

    # if left > right:
    #     cnt = right + 1
    #     left = min(a + cnt, n)
    #     print((n - left) // 2 + cnt)
    # else:
    #     cnt = left + 1
    #     right = max(b - cnt, 1)
    #     print((right - 1) // 2 + cnt)

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

    if left > right:
        cnt = right + 1
        left = min(left + cnt, n)
        print((n - left) // 2 + cnt)
    else:
        cnt = left + 1
        right = max(right - cnt, 1)
        print((right - 1) // 2 + cnt)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
# 偶奇一致
if a % 2 == b % 2:
    print((b - a) // 2)
else:
    left = a - 1
    right = n - b

    if left > right:
        cnt = right + 1
        left += cnt
        print((n - left) // 2 + cnt)
    else:
        cnt = left + 1
        right = max(right - cnt, 1)
        print((right - 1) // 2 + cnt)

Submission status: Wrong Answer

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

if a == 1 and b-a <= 2:
    print(1)
elif b == n and b-a <= 2:
    print(1)


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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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

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


if __name__ == '__main__':
    resolve()

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

def readInts():
  return list(map(int,input().split()))
def main():
    n,a,b = readInts()
    ab = abs(a-b)
    if n % 2 != 0 and ab % 2 == 0:
        print(ab//2)
    elif n % 2 != 0 and ab % 2 == 1:
        print((a+b-2)//2)
    elif n % 2 == 0 and ab % 2 == 0:
        print(ab//2)
    else: # n % 2 != 0 and ab % 2 == 1:
        print(n-(a+b-1)//2)

if __name__ == '__main__':
  main()

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

def readInts():
  return list(map(int,input().split()))
def main():
    n,a,b = readInts()
    ab = abs(a-b)
    if n % 2 != 0 and ab % 2 == 0:
        print(ab//2)
    elif n % 2 != 0 and ab % 2 == 1:
        print((a+b-1)//2)
    elif n % 2 == 0 and ab % 2 == 0:
        print(ab//2)
    else: # n % 2 != 0 and ab % 2 == 1:
        print(n-(a+b-1)//2)

if __name__ == '__main__':
  main()

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

def readInts():
  return list(map(int,input().split()))
def main():
    n,a,b = readInts()
    ab = abs(a-b)
    if n % 2 != 0 and ab % 2 == 0:
        print(ab//2)
    elif n % 2 != 0 and ab % 2 == 1:
        print((a+b)//2)
    elif n % 2 == 0 and ab % 2 == 0:
        print(ab//2)
    else: # n % 2 != 0 and ab % 2 == 1:
        print(n-(a+b-1)//2)

if __name__ == '__main__':
  main()

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

def readInts():
  return list(map(int,input().split()))
def main():
    n,a,b = readInts()
    ab = abs(a-b)
    if n % 2 != 0 and ab % 2 == 0:
        print(ab//2)
    elif n % 2 != 0 and ab % 2 == 1:
        print((a+b)//2)
    elif n % 2 == 0 and ab % 2 == 0:
        print(ab//2)
    else: # n % 2 != 0 and ab % 2 == 1:
        print(min(max(n-a,n-b), max(a,b)))

if __name__ == '__main__':
  main()

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

def readInts():
  return list(map(int,input().split()))
def main():
    n,a,b = readInts()
    ab = abs(a-b)
    if ab % 2 == 0:
        print(ab//2)
    else:
        print(max(abs(1-a),abs(1-b)))
if __name__ == '__main__':
  main()

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())
d=B-A
if d%2==0:
    ans=d//2
else:
    # left
    ans=min(A-1,B-1)
    if d==1:
        ans+=1
    elif d>=2:
        ans+=d-2
        ans+=1
    # right
    tmp=N-max(A,B)
    if d==1:
        tmp+=1
    elif d>=2:
        tmp+=d-2
        tmp+=1
    # print(ans,tmp)
    ans=min(ans,tmp)
print(ans)

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
d=abs(B-A)
if d%2==0:
    ans=d//2
else:
    # left
    ans=min(A-1,B-1)
    if d==1:
        ans+=1
    elif d>=2:
        ans+=d-2
        d=2
        ans+=1
    # right
    tmp=N-max(A,B)
    if d==1:
        tmp+=1
    elif d>=2:
        tmp+=d-2
        d=2
        tmp+=1
    # print(ans)
    ans=min(ans,tmp)
print(ans)

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
d=B-A
if d%2==0:
    ans=d//2
else:
    # left
    ans=min(A-1,B-1)
    if d==1:
        ans+=1
    elif d>=2:
        ans+=d-2
        d=2
        ans+=1
    # right
    tmp=N-max(A,B)
    if d==1:
        tmp+=1
    elif d>=2:
        tmp+=d-2
        d=2
        tmp+=1
    ans=min(ans,tmp)
print(ans)

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if (b - a) & 1 == 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())
k = abs(a - b)


def dist(x):
    return max(abs(a-x), abs(b-x))


if k & 1 == 0:
    print(k // 2)
else:
    print(min(dist(1), dist(n)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
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)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))

Submission status: Wrong Answer

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

# A - Table Tennis Training
def move_left():
	return A + (B-A-1)//2


def move_right():
	return  N - B + 1 + (B-A-1)//2	


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

if (B-A) % 2 == 0:
	print(int((B-A)/2))
else:
	l = move_left()
	r = move_right()
	print(min(l, r))

Submission status: Wrong Answer

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

# A - Table Tennis Training
def move_left():
	f = A + (B-A-1)/2
	return int(f)


def move_right():
	f = N - B + 1 + (B-A-1)/2	
	return int(f)

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

if (B-A) % 2 == 0:
	print(int((B-A)/2))
else:
	l = move_left()
	r = move_right()
	print(min(l, r))

Submission status: Wrong Answer

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

# A - Table Tennis Training
N, A, B = map(int, input().split())
ans = min(B - 1, N - A)

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

Submission status: Wrong Answer

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

# A - Table Tennis Training
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())
if (b - a)%2 == 0:
    x = (b - a)//2
    y = min(max(a-1,b-1),max(n-a,n-b))
    print(min(x,y))
else:
    p = max(a-1,b-1)
    q = max(n-a,n-b)
    r = a-1+1+(b-(a-2)-1)//2
    s = n-b+1+(n-(n-b+1)-a)//2
    #print(p,q,r,s)
    print(min(p,q,r,s))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def myAnswer(N:int,A:int,B:int) -> int:
   ans = 0
   BN = N - B
   A1 = A - 1
   while True:
      if((B - A) % 2== 0):
         ans += (B - A)//2
         break
      elif(A == 0 or B == N):
         ans += (B - A)
         break
      else:
         if(BN > A1):
            ans +=A1
            B -= A1
            A = 0
         else:
            ans += BN
            A += BN
            B = N
   return ans

def modelAnswer():
   tmp=1
def main():
   N,A,B = map(int,input().split())
   print(myAnswer(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, B-1)+1+(B-A-1)//2)
else:
    print((B-A)//2)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
s = min([A, B])
l = max([A, B])

if abs(A-B) % 2 == 1:
    ans = min([N-s, l-1])
    print(ans)
else:
    print((A+B)//2-s)

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n,a,b = map(int,input().split()) 

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

print(ans)

Submission status: Wrong Answer

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = True

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