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())
if (a-b)%2 == 0:
    print(abs(a-b)//2)
else:
    if a+b>=n+1:
        print(max([n-a, n-b]))
    else:
        print(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 a+b>=n+1:
        print(max([n-a, n-b]))
    else:
        print(max([a, b]))

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

if b-a % 2:
    ans = max(abs(1-a), abs(b-n))
else:
    ans = b-a-1

print(ans)

Submission status: Wrong Answer

Solution code:
n = list(map(int,input().split()))
ans = 0
if (n[2] - n[1]) % 2 == 0:
  ans = (n[2] - n[1]) // 2
else:
  if n[0] - n[2] <= n[1] - 1:
    ans = n[0] - n[1]
  else:
    ans = n[2] - 1

print(ans)

Submission status: Wrong Answer

Solution code:
n = list(map(int,input().split()))
ans = 0
if (n[1] + n[2]) % 2 == 0:
  ans = n[2] + n[1]
  ans = ans // 2
  print(ans - n[1])
else:
  if n[0] - n[2] <= n[1] - 1:
    ans = n[0] - n[1]
  else:
    ans = n[2] - 1
  print(ans)

Submission status: Wrong Answer

Solution code:
n = list(map(int,input().split()))
ans = 0
if n[1] % 2 == 0 and n[2] % 2 == 0:
  ans = n[2] + n[1]
  ans = ans // 2
  print(ans - n[1])
elif n[1] % 2 == 1 and n[2] % 2 == 1:
  ans = n[2] + n[1]
  ans = ans // 2
  print(ans - n[1])
else:
  if n[0] - n[2] <= n[1] - 1:
    ans = n[0] - n[1]
  else:
    ans = n[2] - 1
  print(ans)

Submission status: Wrong Answer

Solution code:
n = list(map(int,input().split()))
ans = 0
if n[1] % 2 == 0 and n[2] % 2 == 0:
  ans = n[2] + n[1]
  ans = ans // 2
  print(ans - n[1])
elif n[1] % 2 == 1 and n[2] % 2 == 1:
  ans = n[2] + n[1]
  ans = ans // 2
  print(ans - n[1])
else:
  if n[0] - n[2] < n[1] - 1:
    ans = n[0] - n[1]
  else:
    ans = n[2] - 1
  print(ans)

Submission status: Wrong Answer

Solution code:
n = list(map(int,input().split()))
ans = 0
if n[1] % 2 == 0 and n[2] % 2 == 0:
  ans = n[2] + n[1]
  ans = ans // 2
  print(ans - n[1])
else:
  if n[0] - n[2] < n[1] - 1:
    ans = n[0] - n[1]
  else:
    ans = n[2] - 1
  print(ans)

Submission status: Wrong Answer

Solution code:
n = list(map(int,input().split()))
ans = 0
if n[1] % 2 == 0 and n[2] % 2 == 0:
  ans = n[2] - n[1]
  print(ans//2)
else:
  if n[0] - n[2] < n[1] - 1:
    ans = n[0] - n[1]
  else:
    ans = n[2] - 1
  print(ans)

Submission status: Wrong Answer

Solution code:
n = list(map(int,input().split()))
ans = 0
if n[1] % 2 == 0 and n[2] % 2 == 0:
  ans = n[2] - n[1]
  print(ans//2)
else:
  ans = n[2] - 1
  print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())  # 複数数値入力　「A B」みたいなスペース空いた入力のとき
s=abs(a-b)
if s%2==0:
    s=s/2
elif s%2==1:
    if min(a,b)-1 < n-max(a,b):
        s=max(a,b)-1
    elif min(a,b)-1 > n-max(a,b):
        s=n-min(a,b)
    else:
        s=n
print(int(s))

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
i = 0
if (b - a)%2 == 0:
    print((b-a)//2)
else:
    ans = 0
    if a-1 >= n-b:
        while a!=b:
            i += 1
            a += 1
            if b < n:
                b += 1
            if (b-a)%2 == 0:
                if a != b:
                    print((b-a)//2)
                else:
                    print(i)
                exit()
            
    else:
        while a!=b:
            i += 1
            if 1 < a:
                a -= 1
            b -= 1
            if (b-a)%2 == 0:
                if a != b:
                    print((b-a)//2)
                else:
                    print(i)
                exit()

Submission status: Wrong Answer

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

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

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

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
input_line = input().split(" ")
input_value = [float(i) for i in input_line]

if abs(input_value[1] - input_value[2]) % 2 == 0:
  print( int(abs(input_value[1] - input_value[2]) / 2))
  
else:
  print(int(max(input_value[1:2]) -1))

Submission status: Wrong Answer

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

diff = abs(A - B)

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

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

TableTennis()

Submission status: Wrong Answer

Solution code:

def TableTennis():
    N, A, B = map(int, input().split())
    ans = 0
    if (A - B) % 2 == 0:
        ans = abs(A - B) / 2
    else:
        len_1 = max(A, B) - 1
        len_2 = N - min(A, B)
        ans = min(len_1, len_2)
    print(int(ans))

TableTennis()

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
N,A,B = map(int,input().split())
A_pos = A
B_pos = B
count = 0
while not A_pos == B_pos:
  if A_pos == B_pos -1:
    B_pos += 1
    count += 1
    continue
  A_pos = A_pos +1
  B_pos = B_pos -1
  count += 1
print(count)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N,A,B=map(int,input().split())

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N,A,B=map(int,input().split())

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

check = abs(a-b)

if check%2 == 0:
    print(check//2)
    exit()

temp = min(max(a,b) - 1, n - min(a,b))

print(temp)

Submission status: Wrong Answer

Solution code:
N, A, B = tuple(map(int, input().split()))
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 = tuple(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:
    C=N+1-B
    D=N+1-A
    print(min(A + (B-A-1)//2,D + (D-C-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:
s = input().split()
n=int(s[0])
a=int(s[1])
b=int(s[2])

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

Submission status: Wrong Answer

Solution code:
s = input().split()
n=int(s[0])
if int(s[1])>=n/2:
    if (int(s[2])-int(s[1])) % 2 == 1:
        print(int((int(s[2])-int(s[1]))/2)+int(s[0])-int(s[2])+1)
    else:

        print(int((int(s[2])-int(s[1]))/2))
else:
    if (int(s[2])-int(s[1]))%2==1:
        print(int((int(s[2])-int(s[1]))/2)+int(s[1]))
    else:
        
        print(int((int(s[2])-int(s[1]))/2))

Submission status: Wrong Answer

Solution code:
s = input().split()
n=int(s[0])
if (int(s[2])-int(s[1]))%2==1:
    print(int(s[2])-int(s[1])+1)
else:
    print(int((int(s[2])-int(s[1]))/2))

Submission status: Wrong Answer

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

result = 0
if (a-b)==0:
    result = 0
elif (a-b)%2==0:
    result = (abs(a-b)//2)
elif (a-b)%2==1:
    # min distance to top or bottom
    top = max(a-1,b-1)
    bot = max(n-a,n-b)
    dist = min(top,bot)
    result = dist

print (result)

Submission status: Wrong Answer

Solution code:

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

result = 0
if (a-b)==0:
    result = 0
elif (a-b)%2==0:
    result = (abs(a-b)//2)
elif (a-b)%2==1:
    # min distance to top or bottom
    top = max(a,b)
    bot = max(n-a,n-b)
    dist = min(top,bot)
    result = dist-1

print (result)

Submission status: Wrong Answer

Solution code:
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
sys.setrecursionlimit(10**9)
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i: divisors.append(n//i)
    return divisors
def is_prime(n):
    if n == 1: return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0: return False 
    return True
def primes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n + 1, i): is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]
def sieve_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N,A,B = imn()

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

Submission status: Wrong Answer

Solution code:
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
sys.setrecursionlimit(10**9)
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i: divisors.append(n//i)
    return divisors
def is_prime(n):
    if n == 1: return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0: return False 
    return True
def primes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n + 1, i): is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]
def sieve_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N,A,B = imn()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
if (B-A)%2==0:
    ans=(B-A)/2
else:
    #2人のどちらかが卓1,Nのいずれかに到達するのに必要なラウンド数
    #1は偶奇を調整するためのラウンド
    #(B-A-1)/2は偶奇の調整後に2人が出会うまでのラウンド数
    ans=min(A-1,N-B)+1+(B-A-1)/2 
print(int(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n, a, b = LI()
    if a & 1 == b & 1:
        print((b - a) // 2)
    else:
        print(min(b - 1, n - a))
    return


#main
if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
from math import ceil
N, A, B = [int(num) for num in input().split(' ')]

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, raw_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:
n,a,b = list(map(int,input().split()))

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


print(ans)

Submission status: Wrong Answer

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

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


print(ans)

Submission status: Wrong Answer

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

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


print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b=input().split()
n,a,b=int(n),int(a),int(b)
c=max(a,b)
d=min(a,b)
sa=c-d
if sa%2==0:
    an=sa/2
else:
    if n-d>=c-1: #n-dが卓Nで待ち合わせ、c-1が卓1で待ち合わせ
        an=c-1
    else:
        an=n-d
an=int(an)
print(an)

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,a,b = LI()
    if a % 2 == b % 2:
        return abs(a-b) // 2

    return min(b-1, n-a-1)


print(main())

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,a,b = LI()
    if a % 2 == b % 2:
        return abs(a-b) // 2

    return min(b-1, n-a)


print(main())

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# AGC041A - Table Tennis Training
def main():
    N, A, B = map(int, input().split())
    if (B - A) // 2:
        ans = (B - A) // 2
    else:
        ans = min(N - A, B - 1)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,c =input().split()
N=int(a)
A=int(b)
B=int(c)
A_B=abs(A-B)
if A_B%2==0:
    print(int(A_B/2))
else:
# ONE(1)   A  B  N
    B_ONE=B-1
    A_N=N-A
    ans=0
    if (B-1)<=N-A:
        ans+=N-B+1
        ans+=int((A_B-1)/2)
        
    else:
        ans+=A
        ans+=int((A_B-1)/2)
    print(ans)

Submission status: Wrong Answer

Solution code:
a,b,c =input().split()
N=int(a)
A=int(b)
B=int(c)
A_B=abs(A-B)
if A_B%2==0:
    print(int(A_B/2))
else:
# ONE(1)   A  B  N
    B_ONE=B-1
    A_N=N-A
    ans=0
    if (B-1)<=N-A:
        ans+=A
        ans+=int((A_B-1)/2)
        
    else:
        ans+=N-B+1
        ans+=int((A_B-1)/2)
    print(ans)

Submission status: Wrong Answer

Solution code:
a,b,c =input().split()
N=int(a)
A=int(b)
B=int(c)
sa=abs(A-B)
if sa%2==0:
    print(int(sa/2))
else:
    nm_1=1
    nm_2=N
    B_1=B-nm_1
    A_N=nm_2-A
    if B_1>=A_N:

        print(A_N)
    else:
        print(B_1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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:
    if n - b <= a - 1:
        ans = int((n - a) // 2) + (n - b)
    else:
        ans = int((b - 1) // 2) + (a - 1)

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

Submission status: Wrong Answer

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

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