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:
# 2019/12/28

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

Submission status: Wrong Answer

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

D = B - A

ans = float('inf')
if D % 2 == 0:
    ans = D//2
else:
    # 左端まで行く
    move = A - 1
    L = 1
    R = B - move
    D = R - L
    if D % 2 == 0:
        ans = min(ans, D//2 + move)
    else:
        ans = min(ans, D//2+1 + move)
    # 右端まで行く
    move = N - A
    L = A + move
    R = N
    D = R - L
    if D % 2 == 0:
        ans = min(ans, D//2 + move)
    else:
        ans = min(ans, D//2+1 + move)

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

Submission status: Wrong Answer

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

n,a,b=map(int,input().split())
res = []
if (b-a)%2==0:
    print(abs(b-a)//2)
    exit()
else:
    if min(a-1,n-b)==a-1:
        res.append(b-1)
        if n%2==0:
            res.append((b-a-1)//2+a)
    else:
        res.append(n-a)
        if n%2==0:
            res.append((b-a-1)//2+n-b+1)
print(min(res))

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

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

diff = abs(A - B)

if diff % 2 == 0:
    x = diff/2
else:
    small = min(A, B)
    big = max(A, B)
    x1 = N - small
    x2 = big - 1
    x3 = min(x1, x2)

    # 端に近い方が端で数を合わせ、真ん中で再開するパターン
    diff_small = small - 1
    diff_big = N - big
    x4 = (diff + 1)/2 + min(diff_small, diff_big)

    x = min(x3, x4)


print(int(x))

Submission status: Wrong Answer

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

ans = []
if abs(a-b) % 2 == 0:
    ans.append(abs(a-b) // 2)
x = abs(1 - max(a,b))
y = abs(n - min(a,b))
ans.append(min(x, y))
print(min(ans))

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(c)

Submission status: Wrong Answer

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

if (A-B)%2 == 0:
  Ans=int(abs(A-B)/2)
  print(Ans)
else:
  if A > B:
    print(A-1)
  else:
    print(B-1)

Submission status: Wrong Answer

Solution code:
import numpy as np

val = input().split(' ')
N = int(val[0])
A = int(val[1])
B = int(val[2].strip())

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

Submission status: Wrong Answer

Solution code:
n, a, b = [int(x) for x in input().split(' ')]

diff = abs(a - b)
if diff % 2 == 0:
    print(diff // 2)
else:
    x1 = max(a, b) - 1
    x2 = max(n - a, n - b)
    x3 = ((max(a, b) - min(a, b)) - 1) // 2 + min(a, b)
    x4 = ((max(n - a, n - b) - min(n - a, n - b)) - 1) // 2 + min(n - a, n - b)
    print(min(x1, x2, x3, x4))

Submission status: Wrong Answer

Solution code:
N, A, B = [int(i) for i in input().split()]
a = A - 1
b = N - B
if a == b:
    print(a)
else:
    print(a if a > b else b)

Submission status: Wrong Answer

Solution code:
import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush,heapify
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n,a,b = MAP()

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 = abs(A - (N // 2))
    b = abs(B - (N // 2))

    if a > b:
        print(A + (B - A - 1) // 2)

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

Submission status: Wrong Answer

Solution code:
import math

n, a, b = [int(i) for i in input().split()]

num_play = (b - a) / 2

if num_play.is_integer():
  print(int(num_play))
else:
  if b - 1 < n - a:
    print(b - 1)
  else:
    print(n - a)

Submission status: Wrong Answer

Solution code:
import sys
import math

stdin = sys.stdin

na = lambda: list(map(int, ns().split()))
ns = lambda: stdin.readline()

N, a, b = na()

mod = int(abs(b-a) % 2)
if mod == 0:
    print(abs(a-b)/2)
elif mod == 1:
    if a+b <= (N-a)+(N-b):
        print(max(a-1, b-1))
    elif a+b > (N-a)+(N-b):
        print(max(N-a, N-b))

Submission status: Wrong Answer

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

ans = 0

if (b - a) % 2 == 0:
    ans = (b - a) // 2
else:
    first_move = (b - a) // 2
    p = (a + b) // 2
    second_move = min(p, n - p)
    ans = first_move + second_move
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:
    a, b = min(a, b), max(a, b)
    ans1 = a - 1
    if b - a == 1:
        ans1 += 1
    else:
        ans1 += (b - (a - 2)) // 2 + 1
    ans2 = n - b
    if b - a == 1:
        ans2 += 1
    else:
        ans2 += (n - (a + (n - b) + 1)) // 2 + 1
    print(min(ans1, ans2))

Submission status: Wrong Answer

Solution code:
import sys
import math

(N, A, B) = [int(e) for e in (input().split(" "))]
print(math.ceil((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:
    if ((B-A) != 1):
        print((B-A)//2 + 1)
    else:
        print(min(B - 1,N - A))

Submission status: Wrong Answer

Solution code:
li = list(map(int,input().split()))


if (li[2]-li[1])%2==0:
    print(int((li[2]-li[1])/2))
else:
    x=min(li[0]-li[2],li[1]-1)
    y=int((li[2]-li[1]-1)/2)+1
    print(x+y)

Submission status: Wrong Answer

Solution code:
from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
l_si_i = [int(s) for s in stdin.readline().rstrip().split()]
n = l_si_i[0]
a = l_si_i[1]
b = l_si_i[2]

num = b - a
if num % 2 == 0 and num != 1:
    print(int(num/2))

elif num == 1 and a == 1:
    print(1)

elif num == 1 and b == n:
    print(1)

elif num == 1:
    difA = a - 1
    difB = n - b
    if difA <= difB:
        print(a)
    else:
        print(b)

Submission status: Wrong Answer

Solution code:
nc, ac, bc = map(int, input().split())

n = nc - 1
a = ac - 1
b = bc - 1

if abs(a - b) % 2 == 0:
    print(abs(a - b) // 2)
else:
    left = a
    right = n - b
    if left <= right:
        print(b)
    else:
        print(n - left)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# 21:01
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())
num = abs(a-b)

if num%2 == 0:
    half = num//2
else:
    half = N+1
edge = min(N-min(a,b), max(a,b)-1)

print(min(half, edge))

Submission status: Wrong Answer

Solution code:
N, A, B = [int(x) for x in 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())
sa = B - A
if sa % 2 == 0:
  print(int(sa/2))
else:
  print(min(N -A, B -1) -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:
    if (max(a,b)-1)<(n-min(a,b)):
        print(max(a,b)-1)
    else:
        print(n-min(a,b))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N, A, B = map(int, input().split())
if A > B: A, B = B, A
x = max(abs(1 - A), abs(1 - B))
y = max(abs(N - A), abs(N - B))
z = abs(A - (A + B) // 2)
res = 0
if (A + B) % 2:
  if abs(1 - A) < abs(N - B):
    res += abs(1 - A) + 1
    B -= abs(1 - A)
    A = 1
  else:
    res += abs(N - B) + 1
    A -= abs(N - B)
    B = N

  x = max(abs(1 - A), abs(1 - B))
  y = max(abs(N - A), abs(N - B))
  z = abs(A - (A + B) // 2)
print(min(x, y, z) + res)

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

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
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 input(): return sys.stdin.readline().strip()
def INT(): return int(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()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

# 最小公倍数
def gcd(a, b):
  if a < b:
      a, b = b, a
  while a % b != 0:
      a, b = b, a % b
  return b
 
# 最大公約数 
def lcm(a, b):
    y = a*b / gcd(a, b)
    return int(y)

# N = INT()
# print(N)
N, A, B = MAP()
# guusuu
if (A - B) % 2 == 0:
  s = B - A
  ans = s // 2
  print(ans)
# kisuu
else:
  k = B - A
  ans = min(N - A, B)
  print(ans - k)
  # if A <= N - B:
  #   print(B - A)
  # else:
  #   print(B - A)
  # # k = B - A
  # ans = k+min(N - A, N - B)
  # B - min(N - A, N - B)
  # print(ans)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

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

diff = abs(A - B)

if diff == 0:
    print(0)
elif diff % 2 == 0:
    # diffが偶数ならdiff/2回で同じ卓に来る
    print(int(diff / 2))
else:
    # diffが奇数なら以下の3ステップで同じ卓に来る
    # 1. 1もしくはNの近いほうの端に寄る
    total = min(A-1, B-1, N-A, N-B)

    # 2. 偶数になるまで一回待つ
    diff -= 1
    total += 1

    # 3. あとは偶数と一緒
    total += diff / 2

    print(int(total))

Submission status: Wrong Answer

Solution code:
import numpy as np

val = input().split(' ')
N = int(val[0])
A = int(val[1])
B = int(val[2].strip())

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

Submission status: Wrong Answer

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

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N,A,B = map(int,input().split()) #intでインプット
dif=abs(A-B)
if dif%2==0:
    print(int(dif/2))
elif dif%2==1:
    min=min(A, B)
    max=max(A, B)
    if (min-1)>=(N-max):
        print(N-min)
    elif (N-max)>(min-1):
        print(max-1)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
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())

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

Submission status: Wrong Answer

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

output = 0
if d % 2 == 0:
  output = int(d / 2)
else:
  if a-1 <= n-b:
    output = b - 1
  else:
    output = n - a
print(output)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if (B - A) % 2 == 0:
    print(int((B - A) / 2))
else:
    if N - A > B - 1: # 1 で対戦
        print(B - 1)
    else:
        print(N - A)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if a > b:
  a,b=b,a

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

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
min_=min(a,b)
max_=max(a,b)
if a==b:
    print(0)

else:
    k=max_-min_-1
    if k%2!=0:#間の卓が奇数
        print(k)
    else:
        ans=min(max_-1,n-min_)
        print(ans)

Submission status: Wrong Answer

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

if abs(A-B) != 1:
    print(math.ceil((B - A)/2))
else:
    if N%2==1:
        if B <= N/2:
            print(B-1)
        else:
            print(N-A)
    else:
        if N/2 > B :
            print(B-1)
        else:
            print(N-A)

Submission status: Wrong Answer

Solution code:
import sys
from pprint import pprint

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

    print(ans)

if __name__ == '__main__':
    n, a, b = map(int, sys.stdin.readline().strip().split(" "))
    solve(n, a, b)

Submission status: Wrong Answer

Solution code:
N, A, B = (int(i) for i in input().split())

if abs(A - B) % 2 == 0:
    ans = abs(int((A + B) / 2) - A)
else:
    # どちらも1に近づくとき
    ans_a = max(A - 1, B - 1)
    # どちらもNに近づくとき
    ans_b = max(N - A, N - B)
    
    ans = min(ans_a, ans_b)
    
print(ans)

Submission status: Wrong Answer

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

to_top_A = A - 1
to_end_A = N - A
to_top_B = B - 1
to_end_B = N - B

dif = max([A-B, B-A])

if dif%2 == 1:  dif = 10**18 + 2
rnd = min([max([to_top_A, to_top_B]), max([to_end_A, to_end_B]), int(dif/2)])

print(rnd)

Submission status: Wrong Answer

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

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

print(int(ans))

Submission status: Wrong Answer

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

diff = abs(A - B)

if diff % 2 == 0:
    x1 = diff/2
    small = min(A, B)
    big = max(A, B)
    x2 = N - small
    x3 = big - 1
    x4 = min(x1, x2)
    x = min(x1, x4)
else:
    small = min(A, B)
    big = max(A, B)
    x1 = N - small
    x2 = big - 1
    x3 = min(x1, x2)
    
    diff_small = small - 1
    diff_big = N - big
    x4 = diff + 1 + min(diff_small, diff_big)

    x = min(x3, x4)


print(int(x))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,A,B = map(int,input().split())
S = B-A
C = 0

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

print(int(C))

Submission status: Wrong Answer

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

if a%2==0 and b%2==0:
  c=abs(a-b)//2
else:
  if a>b:
    c=min(abs(1-a),abs(n-b))
  else:
    c=min(abs(n-a),abs(1-b))

print(c)

Submission status: Wrong Answer

Solution code:

import math
N,a, b =list(map(int,input().split(" ")))
case1 = 10 ** 20 # 卓1で戦う場合
case2 = 10 ** 20 # 卓Nで戦う場合
case3 = 10 ** 20 # 卓中間地点で戦う場合
if (b - a ) % 2 == 0:
    case3 = (b-a)//2

else:
    step = (N - b)
    case2 = step+  math.ceil( (b-a) /2)
    step = (a-1)
    case1 = step + math.ceil((b - a) / 2)


print(min([case1,case2,case3]))

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

n,a,b=map(int,input().split())
res = []
if (b-a)%2==0:
    print(abs(b-a)//2)
    exit()
else:
    if min(a-1,n-b)==a-1:
        res.append(b-1)
        if n%2==0:
            res.append((b-a-1)//2+a)
    else:
        res.append(n-a)
        res.append((b-a-1)//2+n-b+1)
print(min(res))

Submission status: Wrong Answer

Solution code:
input_line = input().split()
num_N = int(input_line[0])
num_A = int(input_line[1])
num_B = int(input_line[2])

diff = abs(num_A-num_B)
if(diff%2==0):
    print(int(diff/2))
else:
    diff_top = (num_A - 1) + (num_B - 1)
    diff_end = (num_N - num_A) + (num_N - num_B)
    if(diff_top < diff_end):
        print(max(num_A -1 , num_B - 1 ))
    else:
        print(max(num_N - num_A, num_N - num_B))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def main():

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

    if abs(a-b) % 2 == 0:
        print(abs(a-b)//2)
        return
    left=0
    temp = max(a,b)
    left = temp - 1
    right = 0
    temp = min(a,b)
    right = n - temp
    ans = min(left,right)

    tempR=b-a
    mid1=(tempR-1)//2
    tempL=a+n-b
    mid2=(n-tempL)//2
    ans = min(ans,mid1,mid2)

    print(ans)
    return
if __name__=='__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if (b - a)%2 == 0:
  ans = int((b - a)/2)
else:
  ans1 = 10**18
  
  ans2 = b-1
  ans3 = N-a
  ans4 = a-1 + (b-a-1)/2 +1
  ans5 = N-b + (b-a-1)/2 +1
  ans = int(min(ans1,ans2,ans3,ans4,ans5))

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if (A + B) % 2 == 0:
    print(((A+B)>>1) - min(A,B))
    exit(0)

NA = N - A
NB = N - B

nn = min(max(A, B), max(NA, NB)) - 1
print(nn)

Submission status: Wrong Answer

Solution code:
n = list(map(int, input().split()))
difference = n[2] - n[1]

if difference % 2 == 0 :
    print(difference // 2)

else :
    a = n[1] - 1
    b = n[0] - n[2]
    if a <= b :
        print(n[2] - 1)
    else :
        print(n[0] - n[1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if (b-a)%2 == 0:
    print(int((b-a)/2))
elif n-a >= b-1:
    r = n-a-1
    print(r)
else:
    r = b-1
    print(r)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if A == 1:
  print(B//2)
  exit()

if B == N:
  print((N-A+1)//2)
  exit()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''

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

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,b=list(map(int,input().split()))
p=min(a,b)
q=max(a,b)
sum=q-p
if(sum%2==0):
    print(int(sum//2))
else:
    k=n-q
    r=p-1
    if(k<r):
        print(int(n-p))
    else:
        print(int(q-1))

Submission status: Wrong Answer

Solution code:
import numpy as np

val = input().split(' ')
N = int(val[0])
A = int(val[1])
B = int(val[2].strip())

if B - A % 2 == 0:
    print((B-A)/2)
else:
    max = np.power(10, 18)
    if A - 1 > max - B:
        diff = max - B
    else:
        diff = A - 1
    print(diff + 1 + 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
  #ans=min(ans,n-a)
  print(ans)
else:
  print(min(b-1,n-a))

Submission status: Wrong Answer

Solution code:
i = input().split()
n = int(i[0])
a = int(i[1])
b = int(i[2])

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

Submission status: Wrong Answer

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

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

print(int(ans))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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


main()

Submission status: Wrong Answer

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

loc = (A + B) / 2
if int((loc - A)) == 0:
    print(A)
else:
    print(int(loc - A))