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 (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) // 2)
else:
  print(min((2 * N - A - B + 1) // 2, (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:
    ans = 0
    if n-b < a:
        ans += n-b
        ans += int((b-a-1)/2)
        print(ans)
    else:
        ans += a
        ans += int((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(int((b-a)/2))
else:
    ans = 0
    if n-b < a:
        ans += n-b
        ans += int((b-a)/2)
        print(ans)
    else:
        ans += a
        ans += int((b-a)/2)
        print(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-b < a:
        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(int((b-a)/2))
else:
    if n-b <= a:
        print(n-a-1)
    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)
  exit()
  
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 A % 2 == B % 2:
    print((B - A) // 2)
else:
    x = min(A - 1, N - B) + (B - A - 1) // 2
    y = min(B - 1, N - A)
    print(min(x, y))

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8


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

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

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline

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

if (b-a)%2 ==0:
    print(int((b-a)/2))

else:
    min_sabun = min(a-1,n-b)
    kyori = int((b-a-1)/2)
    print(min_sabun+kyori+1)

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline

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

sum_ab = a + b
if sum_ab % 2 == 0:
    print(int(sum_ab/2) - a)

else:
    min_sabun = min(a-1,n-b)
    kyori = int((b-a-1)/2)
    print(min_sabun+kyori+1)

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline

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

sum_ab = a + b
if sum_ab % 2 == 0:
    print(int(sum_ab/2) - a)

else:
    min_sabun = min(a-1,n-b)
    kyori = (b-a-1)/2
    print(int(min_sabun+kyori+1))

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline

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

sum_ab = a + b
if sum_ab % 2 == 0:
    print(int(sum_ab/2) - a)

else:
    min_sabun = min(n-a,b-1)
    print(min_sabun)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n, a, b = LI()
    a, b = min(a,b), max(a,b)
    ans = 0
    if (b-a)%2 == 0:
        ans = (b-a)//2
    else:
        ans = min(b-1, n-a)
    print(ans)
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())

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

Submission status: Wrong Answer

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

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

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

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

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

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
# row = [int(x) for x in input().rstrip().split(" ")]
# n = int(input().rstrip())
# s = input().rstrip()

def resolve():
    import sys
    input = sys.stdin.readline

    n, a, b = [int(x) for x in input().rstrip().split(" ")]

    if a > n - b:
        tmp = a
        a = n - b
        b = n - tmp

    a = a - 1
    b = b - 1



    if (b - a) % 2 == 0:
        print(abs(a - b) // 2)
    else:
        count = a + 1 + ((b - a - 1) // 2)
        print(count)



if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
# row = [int(x) for x in input().rstrip().split(" ")]
# n = int(input().rstrip())
# s = input().rstrip()

def resolve():
    import sys
    input = sys.stdin.readline

    n, a, b = [int(x) for x in input().rstrip().split(" ")]

    a = a - 1
    b = b - 1

    if (b - a) % 2 == 0:
        print(abs(a - b) // 2)
    else:
        # 近いほうの端で一回だけとどまる
        # 0の方へ
        if a > n - b:
            tmp = a
            a = n - b
            b = n - tmp

        count = a + 1 + ((b - a - 1) // 2)
        print(count)



if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
# row = [int(x) for x in input().rstrip().split(" ")]
# n = int(input().rstrip())
# s = input().rstrip()

def resolve():
    import sys
    input = sys.stdin.readline

    n, a, b = [int(x) for x in input().rstrip().split(" ")]

    a = min([a, b]) - 1
    b = max([a, b]) - 1

    if (b - a) % 2 == 0:
        print(abs(a - b) // 2)
    else:
        # 近いほうの端
        print(min([b, n - a]))


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

print(int(ans))

Submission status: Wrong Answer

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

print(int(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if (A+B)%2 == 0:
    print(B-int((A+B)/2))
else:
    cnt = 0
    if (A-1) <= (N-B):
        cnt += A-1
        B -= (A-1)
        A = 1
        for _ in range(N):
            cnt += 1
            B -= 1
            if A == B:
                print(cnt)
                sys.exit(0)
            if (A+B)%2 == 0:
                cnt += B-int((A+B)/2)
                print(cnt)
                sys.exit(0)
    else:
        cnt += N-B
        A += N-B
        B = N
        for _ in range(N):
            cnt += 1
            A += 1
            if A == B:
                print(cnt)
                sys.exit(0)
            if (A+B)%2 == 0:
                cnt += B-int((A+B)/2)
                print(cnt)
                sys.exit(0)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

ans = 0

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

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

p = b-a-1

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

Submission status: Wrong Answer

Solution code:
import math

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

sa = B - A + 1;

if sa % 2 == 1 :
	ans = min(N - A, B - 1);
	#chmin(ans, (B - A) / 2);
	ans = min(ans, (B - A) // 2)

	print(ans)
else :
	ans = 10**30;

	# A を 1 に移動させて1勝
	ca = A
	cb = B

	ca = 1;
	cb -= A;

	cand = (cb - ca) // 2 + A;
	ans = min(ans, cand);

	# B を N に移動させて1敗
	cb = N;
	ca += N - B + 1;
	cand = (cb - ca) / 2 + (N - B + 1);

	ans = min(ans, cand);


	print(ans)

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
X=N-A
Y=N-B
ans=min(X,Y)
sum=0
if (B-A)%2==0:
    sum=(B-A)//2
    ans=min(sum,ans)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1 << 25)
readline = sys.stdin.buffer.readline
read = sys.stdin.readline  # 文字列読み込む時はこっち
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(readline())


def ints(): return list(map(int, readline().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, readline().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, readline().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, readline().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce
from math import gcd


def lcm(a, b):
    # 最小公倍数
    g = gcd(a, b)
    return a // g * b


# 差が偶数だったら/2
# 奇数だったら端に行くまで対戦を続けないと行けない
N, A, B = ints()
if (B - A) % 2 == 0:
    exit((B - A) // 2)
else:
    exit(min(B - 1, N - A))

Submission status: Wrong Answer

Solution code:
'''
Created on 2020/09/03

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N,A,B=map(int,pin().split())
  if (B-A)%2==0:
    print((B-A)//2)
    return 
  if A<N-B:
    print(A+(B-A-1)//2)
  else:
    print(N-B+(B-A-1)//2)
  return 
main()

Submission status: Wrong Answer

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

p = b-a-1

if p%2==0:
    print(b-1)
else:
    print((p+1)//2)

Submission status: Wrong Answer

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

# 2で割って余り1ならすれ違わない
if (b - a) % 2 == 0:
    print((b - a) // 2)
    sys.exit()

# 左で落ち合う

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

Submission status: Wrong Answer

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

ans = INF = 1 << 60

# 2で割って余り1ならすれ違わない
if (b - a) % 2 == 0:
    ans = (b - a) // 2

# 左で落ち合う
ans = min(ans, b - 1)

# 右で落ち合う
ans = min(ans, n - a)

print(ans)

Submission status: Wrong Answer

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

ans = INF = 1 << 60
ans = min(ans, max(a - 1, b - 1))
ans = min(ans, max(n - a, n - b))

if (b - a) % 2 == 0:
    ans = min(ans, (b - a) // 2)

print(ans)

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


N,A,B = MI()

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

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

Submission status: Wrong Answer

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

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

x = (b-a) % 2
if x == 1:
    ans = 0
    if (a-1) < (n-b):
        d = a-1
        y = b - a
        ans += a
        ans += y // 2
    else:
        d = n-b
        y = a + b
        ans += (n-b) + 1
        ans += (n-y) // 2
    ans = min([ans, b-1, n-a])
    print(ans)
else:
    print((b-a+1)//2)

Submission status: Wrong Answer

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

x = (b-a) % 2
if x == 1:
    ans = 0
    if (a-1) < (n-b):
        d = a-1
        b -= a
        ans += a
        ans += b // 2
    else:
        d = n-b
        a += b
        ans += (n-b) + 1
        ans += (n-a) // 2
    ans = min([ans, b-1, n-a])
    print(ans)
else:
    print((b-a+1)//2)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ans = (b-a + 1) // 2
ans += (b-a) % 2
print(ans)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
x = A - 1
y = B - A - 1
z = N -B 

if y % 2 == 1:
  ans = (y + 1) / 2
else:
  if x >= z:
    if (N - A - z - 1) % 2 == 1:
      ans = z + (N - A - z) / 2
    else:
      ans = z + (N - A - z) / 2 + 1
  else:
    if (B - x - 2) % 2 == 1:
      ans = x + ( B - x - 2)/2
    else:
      ans = x + ( B - x - 2)/2 + 1
      
print(int(ans))

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
x = A - 1
y = B - A - 1
z = N -B 

if y % 2 == 1:
  ans = (y + 1) / 2
else:
  if x >= z:
    ans = y + z + 1
  else:
    ans = y + x + 1
print(int(ans))

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
x = A - 1
y = B - A - 1
z = N -B -1

if y % 2 == 1:
  ans = (y + 1) / 2
else:
  if x >= z:
    ans = y + z + 1
  else:
    ans = y + x + 1
print(int(ans))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
n,a,b = readInts()
ab = abs(b-a)
if ab%2 == 0:
    print(ab//2)
else:
    print(min(abs(a-1)+ab, abs(n-b)+ab))

Submission status: Wrong Answer

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

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)
ans.append(min(n-a, b-1))
print(min(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(min(n-b+(b-a-1)//2, a+(b-a-1)//2))

Submission status: Wrong Answer

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

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

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

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

print(int(count))

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

print(int(count))

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

print(int(count))

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

print(int(count))

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

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

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

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

Submission status: Wrong Answer

Solution code:
N, A, B = input().split(' ')
N = int(N)
A = int(A)
B = int(B)
Count = -(-(B-A)//2)
print(Count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if abs(A - B) % 2 == 0:
    ans = abs(A - B) // 2
else:
    x = max(A, B) - 1
    y = 5 - min(A, B)
    if x <= y:
        ans = x
    else:
        ans = y
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

    A_btm = N - A
    B_btm = N - B
    btm = B_btm + (A - B_btm) // 2 if A_btm > B_btm else A_btm + (N - B - A_btm) // 2
    print(min(top, btm) + 1)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

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,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,a,b = readInts()
sa = b-a
if sa%2 == 0:
    print(sa//2)
else:
    print(min(b-1, n-a))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

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

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

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

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

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