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

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N, A, B = [int(x) for x in input().split()]
a = max(A, B) - 1
b = N - min(A, B)
c = 10 * 19
if abs(A - B) % 2 == 0:
    c = abs(A - B) // 2
print(min(a, b, c))

Submission status: Wrong Answer

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

ab = [a, b]

if abs(a-b) % 2 == 0:
    # 距離が偶数
    print(abs(a-b) // 2)
    exit()

print(min([max(ab)-1, n - min(ab)]))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
inputLine = input().split(' ')
N = int(inputLine[0])
A = int(inputLine[1])
B = int(inputLine[2])

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n,a,b = (int(x) for x in input().split())
c = b - a

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

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

Submission status: Wrong Answer

Solution code:
import math

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

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

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:
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N, A, B = map(int, input().split())

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


main()

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:
        delta_one = max(a - 1, b - 1)
        delta_n = max(n - a, n - b)
        ans = min(delta_one, delta_n)

    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 (b-a)%2==0:
    print(int( (b-a)/2 ))
else:
    r = int( a + (b-a-1)/2 )
    l = int( n-b+1 + ( n - (a+n-b+1) )/2 )
    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(int((B-A)/2))
else:
    a1=int(min(N-1-A,B-1))
    a2=int((A-1)+1+(B-A-1)/2)
    a3=int((N-1-B)+1+(B-A-1)/2)
    print(min(a1,a2,a3))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if a>b:
    a,b=b,a
if (b-a)%2==0:
    ans=(b-a)//2
else:
    ans=min(a-1,N-b)+math.ceil((b-a)/2)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

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

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))))

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:
x=[]
n,a,b=map(int,input().split())
if (b-a)%2==0:
    print((b-a)//2)
else:
    c=(a+b)//2
    d=((n-a)+(n-b))//2
    print(min(c,d))

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

n, a, b = map(int, sys.stdin.readline().split())

def main(a, b):
    d = b - a
    if d % 2 == 0:
        return d // 2

    if n - b >= abs(1 - a):
        res = a
        b -= res
        a = 1
    else:
        res = n - b + 1
        a += res
        b = n

    return res

if __name__ == '__main__':
    ans = main(a, b)
    print(ans)

Submission status: Wrong Answer

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

if abs(a-b) % 2 ==0:
  print(abs(a-b)//2)
  exit(0)
print(min(math.ceil((a+b-2)/2),math.ceil((2*n-a-b)/2)))

Submission status: Wrong Answer

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

sa = abs(a-b)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
aa=a
bb=b
sa=b-a
from math import ceil
if sa%2==0:
	print(sa//2)
else:
	ans1=a-1
	bb-=(a-1)
	ans1+=ceil(bb/2)
	bb=b
	ans2=n-b
	aa+=n-b
	ans2+=ceil((n-aa)/2)
	print(min(ans1,ans2))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N, A, B = [int(x) for x in input().split()]
a = max(A, B) - 1
b = N - min(A, B)
c = 10 * 19
if abs(a-b) % 2 == 0:
    c = abs(A - B) // 2
print(min(a, b, c))

Submission status: Wrong Answer

Solution code:
def main():
    v = input().split(' ')
    n = int(v[0])
    a = int(v[1])
    b = int(v[2])

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 1.0e+100

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A, B):
    if (B - A) % 2 == 0:
        C = (B - A) // 2
    else:
        C = INF

    return min(B-1, N-A, C)


def main():
    N, A, B = read_int_n()
    print(slv(N, A, B))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
inputLine = input().split(' ')
N = int(inputLine[0])
A = int(inputLine[1])
B = int(inputLine[2])

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

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 < 5 - A:
        print(B-1)
    else:
        print(5-A)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
x = [int(i) for i in input().split()]
n = x[0]
a = x[1]
b = x[2]
if (b - a) % 2 == 0:
    ans = b - (a + b) // 2
else:
    if b - 1 <= n - a:
        ans = b - 1
    else:
        ans = 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:
    cnt = 0
    while a>1:
        cnt+=1
        a-=1
        b-=1
    while b>1:
        cnt+=1
        b-=1
    print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
li = list(map(int,input().split()))
a=max(li[1],li[2])
b=min(li[1],li[2])

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

Submission status: Wrong Answer

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

else:
    k=max(a,b)-min(a,b)-1
    if k%2!=0:#間の卓が奇数
        print(k)
    else:
        print(max(a,b)-1)

Submission status: Wrong Answer

Solution code:
def main():
    tmp = input()
    tmp = [int(i) for i in (tmp.split())]
    n = tmp[0]
    a = tmp[1]
    b = tmp[2]
    
    if abs(a - b)%2 == 0:
        print(abs(a - b))
    else:
        lose = a if a>b else b
        print(lose - 1)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

average = (A + B) / 2.0
if average.is_integer():
    print(int(average) - A)
else:
    print(min([N - A, B - 1]))

Submission status: Wrong Answer

Solution code:

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

m = abs(B-A)
if m%2==0:
    ans = m//2
else:
    ans1 = N-B+1
    A1 = A+N-B+1
    ans1 += (N-A1)//2
    
    ans2 = A-1+1
    B2 = B-A-2
    ans2 += (B2-1)//2
    ans = min(ans1,ans2)
    
    
print(ans)

Submission status: Wrong Answer

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

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

tmp1 = A
b = B - A
tmp1 += (B - 1) // 2

tmp2 = N - B
a = A + tmp2
tmp2 += (N - a) // 2

print (min(tmp1, tmp2) + 1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

diff = abs(A - B)

if diff % 2 == 0:
    print(diff // 2)
    pass
else:
    left = min(A, B)
    right = max(A, B)

    # distance
    if (left - 1) < (N - right):
        print(right - 1)
    else:
        print(left - 1)

Submission status: Wrong Answer

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

def solve(N, A, B):
    if (A + B) % 2 == 0:
        return (B - A) // 2
    left = max(A-1, B-1)
    right = max(N-A, N-B)
    return min(left, right)

if __name__ == '__main__':
    inputs = read()
    print("%d" % solve(*inputs))

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-b
else:
  ans=a
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    R = max(A, B)
    L = min(A, B)
    sub = R - L

    left_s = L - 1
    right_s = N - R
    
    # 偶数なら
    if sub % 2 == 0:
        return sub / 2
    # 奇数なら
    else:
        if left_s < right_s:
            return R - 1
        else:
            return N - L
    
if __name__ == '__main__':
    print(int(main()))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!python3

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

    diff = B - A

    if diff % 2 == 0:
        print(diff//2)
        return

    if B - 1 < N - A:
        print(B - 1)
    else:
        print(N - A)

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
ui = input()
uis = ui.split(" ")
N = int(uis[0])
A = int(uis[1])
B = int(uis[2])
if abs(A-B) % 2 == 0:
    print(abs(A-B) // 2)
elif A == B:
    print(0)
else:
    if A > B:
        temp1 = A-1
        temp2 = N-B
    else:
        temp1 = B-1
        temp2 = N-A
    if temp1 > temp2:
        print (temp2)
    else:
        print (temp1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
from random import choice,randint
inp=sys.stdin.readline
out=sys.stdout.write
flsh=sys.stdout.flush
 
sys.setrecursionlimit(10**9)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
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 MI(): return map(int, inp().strip().split())
def LI(): return list(map(int, inp().strip().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines().strip()]
def LI_(): return [int(x)-1 for x in inp().strip().split()]
def LF(): return [float(x) for x in inp().strip().split()]
def LS(): return inp().strip().split()
def I(): return int(inp().strip())
def F(): return float(inp().strip())
def S(): return inp().strip()
def pf(s): return out(s+'\n')
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=MI()
    if (b-a)%2==0:
        pf(str((b-a)//2))
    else:
        ans = min(n-a,b-1)
        pf(str(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(B - 1)

Submission status: Wrong Answer

Solution code:
#import sys
MOD = 10 ** 9 + 7
#input = sys.stdin.readline
import math

import itertools

#import bisect

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default


#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]
def main():
    n,a,b=map(int,input().split())
    count=0
    if (b-a)%2==0:
        count=(b-a)//2
    else:
        if a-1<=n-b:
            count=(b-a-1)//2+a-1
            if b-a==1:
                count=a
        else:
            count=(b-a-1)//2+n-b
            if b-a==1:
                count=n-b+1
#    print(a-1,n-b,b-a-1)
    print(count)









if __name__ == "__main__":
    main()

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

Submission status: Wrong Answer

Solution code:
N, A, B = map(int,input().split())
d = abs(A-B)
if d % 2 == 0:
    print(d//2)
else:
    if A == 1 or B == N:
        print(1+d//2)
        exit()
    MIN_A = A-1
    MIN_B = B-1
    MIN = max(MIN_A,MIN_B)
    MAX_A = N-A
    MAX_B = N-B
    MAX = max(MAX_A,MAX_B)
    print(min(MIN,MAX))

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

Submission status: Wrong Answer

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

diff = b - a

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

Submission status: Wrong Answer

Solution code:
tmp = input().split()
N = int(tmp[0])
A = int(tmp[1])
B = int(tmp[2])

ans = 0

tmp = B - A
if tmp % 2 == 0:
    print(abs(tmp // 2))
    
else:
    MIN = min(A, B)
    MAX = max(A, B)


    if MIN - 1 < N - MAX:
        print(MAX - 1)
    else:
        print(N - MIN)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

#print(n, a, b)

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

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
if A % 2 == B % 2: # 両方とも偶数/奇数の場合
    print(abs(int((A-B)/2)))
else: # 両方が違う場合
    print(min(max(A-1, B-1), max(N-A, N-B)))

Submission status: Wrong Answer

Solution code:
s=raw_input().split()
[N, A, B] = s
N = int(N)
A = int(A)
B = int(B)

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 = list(map(int, input().split()))
x = (B-A)
if x%2 == 0:
    print(x//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(abs(a-b)+1)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF=float('inf')
MOD=10**9+7
input=sys.stdin.readline

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

if a==b:
    print(0)
    exit()

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
def fastio():
    from io import StringIO
    from atexit import register
    global input
    sys.stdin = StringIO(sys.stdin.read())
    input = lambda : sys.stdin.readline().rstrip('\r\n')
    sys.stdout = StringIO()
    register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

def debug(*var, sep = ' ', end = '\n'):
    print(*var, file=sys.stderr, end = end, sep = sep)

INF = 10**20
MOD = 10**9 + 7
I = lambda:list(map(int,input().split()))
# from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br

n, a, b = I()
b, a = max(a, b), min(a, b)
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:
p=input().rstrip().split(' ')
N=int(p[0])
A=int(p[1])
B=int(p[2])
AA=max(A,B)
BB=min(A,B)
XF = -1
if((AA-BB)%2==0):
    XF = ((AA-BB)//2)
X=AA-1;
Y=BB-1;
Z=max(X,Y)
XX=N-AA;
YY=N-BB;
ZZ=max(XX,YY)
if XF!=-1:
    print(min(XF,Z,ZZ))
else:
    print(min(Z,ZZ))

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

Submission status: Wrong Answer

Solution code:
from sys import stdin
N,A,B = [int(x) for x in stdin.readline().rstrip().split()]
if (B - A) % 2 == 0:
    print(min((B-A)//2,N-A,B-1))
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:
  ans1 = 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-b)%2==0):
    print(int((abs(a-b)/2)))
else:
    if(a-1<n-b):
        print(a+int(abs(a-b)/2))
    else:
        print(n-b+1+int(abs(a-b)/2))

Submission status: Wrong Answer

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


def main():
    distance = b - a

    if distance % 2 == 0:
        return distance // 2
    else:
        if a < n-b+1:
            return a
        if a > n-b+1:
            return n-b+1
        if a == n-b+1:
            return a

print(main())

Submission status: Wrong Answer

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

print(n, a, b)

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

l = list(map(int, input().split()))

ans = 0
if not abs(l[1] - l[2]) % 2:
    ans = abs(l[1] - l[2]) // 2
else:
    if l[1] < l[2]:
        if (l[2] - 1) < (l[0] - l[1]):
            ans = l[2] - 1
        else:
            ans = l[0] - l[1]
    else:
        if (l[1] - 1) < (l[0] - l[2]):
            ans = l[1] - 1
        else:
            ans = l[0] - l[2]

print(ans)

Submission status: Wrong Answer

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

l = B-A

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

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
c=b-a
if a==b:
    print(0)
if c%2==0:
    print(c//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:
def main():
    n, a, b = map(int, input().split())

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N, A, B = [int(i) for i in input().split()]
if (B-A) % 2 == 0:
    print((B-A) // 2)
    quit()

l = B-1
r = N-A

print(min(l, r))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
m = 1
l = b - a
x = min(n - a, n - b, a - m, b - m)

if l % 2 == 0:
    print(int(l / 2))
else:
    print(int(l + x))

Submission status: Wrong Answer

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

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

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
    x = min(x1, x2)

print(int(x))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if C%2==0:
  print(C//2)
else:
  dist_a=A-1
  dist_b=N-B
  base=min(dist_a,dist_b)
  print(base+(B-A+1)//2)