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())
a -= 1
b -= 1
n -= 1
import math

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
bbn=1000000007
	
#+++++
		
def main():
	n, a, b= map(int, input().split())
	k=b-a
	if k %2 ==0:
		return 2//k
		
	to=max(a-1,b-1)
	tn=max(n-a,n-b)
	return min(to,tn)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

else:

    if abs(A-1) >= abs(A-N) and abs(B-1) >= abs(B-N):
        a = min(abs(A-1), abs(A-N))
        b = min(abs(B-1), abs(B-N))
        print(max(a, b))

    elif abs(A-1) <= abs(A-N) and abs(B-1) <= abs(B-N):
        a = min(abs(A-1), abs(A-N))
        b = min(abs(B-1), abs(B-N))
        print(max(a, b))

    else:
        a = max(abs(A-1), abs(A-N))
        b = max(abs(B-1), abs(B-N))
        print(min(a, b))

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

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

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

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

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

Submission status: Wrong Answer

Solution code:
from sys import stdin


def fetch_one_line():
    return stdin.readline().rstrip()


def fetch_int_input():
    return [int(s) for s in fetch_one_line().split()]


def fetch_inputs(times):
    return [fetch_one_line() for _ in range(times)]


def fetch_int_inputs(times):
    return [[int(s) for s in fetch_one_line()] for _ in range(times)]


def fetch_ints_inputs(times):
    return [fetch_int_input() for _ in range(times)]


N, A, B = fetch_int_input()

dist = abs(A - B)
if dist % 2 == 0:
    print(int(dist / 2))
else:
    all_win_long = max(A - 1, B - 1)
    all_win_short = min(A - 1, B - 1)
    all_short_edge = all_win_short + 1
    all_win_dist = all_win_long - all_short_edge
    win_dist = int(abs(all_win_dist) / 2) + all_short_edge

    all_lose_long = max(N - A, N - B)
    all_lose_short = min(N - A, N - B)
    all_short_edge = all_lose_short + 1
    all_lose_dist = all_lose_long - all_short_edge
    lose_dist = int(abs(all_lose_dist) / 2) + all_short_edge


    print(int(min(all_win_long, all_lose_long, win_dist, lose_dist)))

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
n,a,b=map(int,input().split())
if (b-a)%2==0:
    print(min(n-a,b-1,(b-a)//2))
else:
    print(min(n-a,b-1))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

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
    p4 = ((B - A) - 1) // 2 + (B-A)
    print(min(p1,p2,p3,p4))

Submission status: Wrong Answer

Solution code:
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, a, b = list(map(int, readline().split()))
    if (b - a) % 2 == 0:
        print((b - a) // 2)
    else:
        if a - 1 < n - b:
            c = a - 1
            b -= c
            a -= c
            if (b - a) % 2 == 0:
                print((b - a) // 2 + c)
            else:
                print(b - 1 + c)
        else:
            c = n - b
            a -= c
            b -= c
            if (b - a) % 2 == 0:
                print((b - a) // 2 + c)
            else:
                print(n - a + c)


if __name__ == '__main__':
    solve()

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+1) / 2))
    b = abs(B - ((N+1) / 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:
# -*- coding: utf-8 -*-
n, a, b = map(int, input().split())

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

print(result)

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:
        na = n - a
        nb = n - b
        a1 = a - 1
        b1 = b - 1
        v1 = min(max(na, nb), max(a1, b1))
        v2 = min(min(na, nb) + 1 + int(abs(a - b) / 2), min(a1,  b1) + 1 + int(abs(a - b) / 2))
        print(int(min(v1, v2)))
        

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n, a, b = list(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())

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

Submission status: Wrong Answer

Solution code:
import numpy as np

N, A, B = list(map(int,input().split()))
if np.mod(B-A, 2) != 0:
    diff_min = min(A-1, N-B)
    if diff_min == (A-1):
        ans = B-1
    else:
        ans = N-A
else:
    ans = (B-A)-1
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
#n,m,v,p=map(int,input().split())
#l=list(map(int,input().split()))
n,a,b=map(int,input().split())
c=b-a
if c//2==c/2:
    print(min(c//2,n-a,b-1))
else:
    print(min(n-a,b-1,(b-a-1)//2+a,(b-a-1)//2+n-b+1))

Submission status: Wrong Answer

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

X = B-A

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

print(min_round)

Submission status: Wrong Answer

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

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

NA = N - A + 1
NB = N - B + 1

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

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=10**19
    if tempR-1>0:
        mid1=(tempR-1)//2 + a -1
    tempL=a+n-b
    mid2=10**19
    if n-tempL > 0:
        mid2=(n-tempL)//2 + n-a+1
    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())

if abs(A-B)-1 % 2 == 0:
    A_side = A
    A_right = N-A+1
    B_left = B
    B_right = N-B+1
    
    if A < N/2 and B < N/2:
        print(max(A-1, B-1))
    elif A > N/2 and B > N/2:
        print(max(A_right-1, B_right-1))
    elif A < N/2 and B > N/2:
        print(min(A_right-1, B-1))
    elif B < N/2 and A > N/2:
        print(min(A-1, B_right-1))
    elif A == N/2:
        print(A-1)
    elif B == N/2:
        print(B-1)
        
else:
    if A == B:
        print(0)
    else:
        print(abs(A-B)/2)

Submission status: Wrong Answer

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

startA = a == (a == 1)
endB = (b == n)
aida = b-a-1


if any([startA, endB]):
    # 端に点があれば、間の卓数＋１
    print(aida+1)
else:
    if aida % 2 != 0:
        #　間の卓数が奇数なら、間の個数/2 +1
        print(aida//2+1)
    else:
        if (a-1) > (n - b):
            print(n-b)
        else:
            print(b-1)

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

print(c)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

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

# a を 1に置くパターン
step = (a-1)
case1 = step + ( (b - step) - 1)


# b を N に置くパターン
step = (N - b)
case2 = step+  ( N - (a + step) )



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

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)
else:
    m = min(a, n - b - 1)
    ans.append(min(max(a, b), max(n - a - 1, n - b - 1)))
    ans.append(m + 1 + (abs(a - b) + 2 * m + 1) // 2)

a = min(ans)

print(a)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
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)+(l-1)/2+1))

Submission status: Wrong Answer

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

if (a - b) % 2 == 0:
    if a - b > 0:
        print((a-b)//2)
    else :
        print((b-a)//2)
else:
    min_x = 0
    top_a = a - 1
    top_b = b - 1
    if top_a < top_b:
        min_x = (top_b - (top_a - 1) )//2 + 1
    else:
        min_x = (top_a - (top_b - 1) )//2 + 1
    
    bot_a = n - a
    bot_b = n - b
    if bot_a < bot_b:
        min_x1 = (bot_b - (bot_a - 1) )//2 + 1
    else:
        min_x1 = (bot_a - (bot_b - 1) )//2 + 1
    if min_x > min_x1:
        min_x = min_x1
    print(min_x)

Submission status: Wrong Answer

Solution code:
# A - Table Tennis Training
N,A,B = map(int, input().split())

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

diff = abs(a-b) - 1
mod = diff % 2

if diff == 0 or mod == 0:

  print(min(a,n - b))

else :
  
  print( abs(a-b)  // 2 )

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(int(d + t + 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:
    first = max(A-1, B-1)
    last = max(N-A, N-B)

    print(min(first, last))

Submission status: Wrong Answer

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

d = n[1] - n[2]

m = []
m.append(n[1])
m.append(n[2])
m.sort()

if(d % 2 == 0):
    ans = int(d/2)
else:
    ad = n[0] - m[0]
    bd = m[1] - 1
    #if(d == 1) or (d == -1):
    ans = int(min(ad,bd))

if(ans < 0):
    ans *= -1
print(ans)

Submission status: Wrong Answer

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

Awin = A
Alose = A
Bwin = B
Blose = B
count = 0

while True:
  count += 1

  if Awin == 1:
    Awin = 1
  else:
    Awin -= 1
  
  if Bwin == 1:
    Bwin = 1
  else:
    Bwin -= 1
  
  if Alose == 1:
    Awin = 1
  elif Alose == N:
    Alose = N
  else:
    Alose += 1
  
  if Blose == 1:
    Blose = 1
  elif Alose == N:
    Alose = N
  else:
    Blose += 1

  
  if Awin == Bwin or Awin == Blose or Alose == Bwin or Bwin == Blose:
    print(count)
    break;

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if difference % 2 == 0 :
    print(int(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())

dif = abs(a-b)

#print(dif)

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

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=10**19
    if tempR-1>0:
        mid1=(tempR-1)//2 + a
    tempL=a+n-b
    mid2=10**19
    if n-tempL > 0:
        mid2=(n-tempL)//2 + n-a+1
    ans = min(ans,mid1,mid2)


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

Submission status: Wrong Answer

Solution code:
s = input().split()
k = int(s[0])
a = int(s[1])
b = int(s[2])
n = int(max(a,b))
m = int(min(a,b))
res = n-m
resp = n + m
if res % 2 == 0:
  print(int(n/2-m/2))
elif k-n > m-1:
  print(k-n)
elif m-1 > k-n:
  print(k-m)
elif m-1 == k-n:
  print(n-resp//2)

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

    x = min(x3, x4)


print(int(x))

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

Submission status: Wrong Answer

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

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


main()

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:
        dst = (abs(a - b))
    else:
        dst = 2 * n
    fst = a if a<b else b
    lst = a if a>b else b
    dst_fst = lst - 1
    dst_lst = n - fst

    print(min([dst, dst_fst, dst_lst]))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

if (n_a_b[2] - n_a_b[1]) % 2 == 0:
    print(int(abs(n_a_b[2] - n_a_b[1]) / 2))
elif (n_a_b[2] - n_a_b[1]) % 2 == 1:
    c = n_a_b[0] - n_a_b[2]
    d = n_a_b[1] - 1
    if d > c:
        print(n_a_b[0] - n_a_b[1])
    else:
        print(n_a_b[2] - 1)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
#print('{}{}{}' .format(n, a, b))

x = max(a, b)
y = min(a, b)
if (x - y) % 2 == 0: #AとBが勝ちのみor負けのみで賄える場合
    t = (x - y) // 2
    print(t)
else:
    if (x + y) <= n: #AとBが偶奇別れていて、1 or N卓でトントンしないといけない場合
        t = abs(1 - x)
        print(t)
    else:
        t = abs(n - y)
        print(t)

Submission status: Wrong Answer

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

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

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)
else:
    edge = min([N-A, B-1])
    a_change = A+(B - A + 1)//2
    b_change = N-B+(B-A+1)//2
    print(min([edge, a_change, b_change]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

n = inp[0]
a = inp[1]
b = inp[2]


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

Submission status: Wrong Answer

Solution code:
# 1行目の入力を空白で分割された数字として扱う
N, A, B = map(int, input().split())

# 答えの準備
res = 0

if A == B:
    print(0)
    exit(0)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

N, A, B=map(int, input().split())
C=0
if (B-A)%2==0:
    C=(B-A)/2
else:
    if A-1 > N-B:
        C=N-A
    elif A-1 < N-B:
        C=B-1
    else:
        C=B-1

print(int(C))

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

end_lenght1=min(min(n-a,n-b),max(a-1,b-1))
end_lenght2=min(max(n-a,n-b),max(a-1,b-1))

if not abs(a-b)%2:
    print(abs(a-b)//2)
else:
    print(min(end_lenght2,end_lenght1+abs(a-b)-1))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if C == 1:
    kabe = int(min(N-B,A-1))
    print(kabe + 1)
elif C % 2 == 0:
    print(int(C / 2))
else:
    NB = N-B
    A1 = A-1
    if NB < A1:
        NA = N-A
        zan = int((NA-NB-1)/2)
        print(int(NB+1+zan))
    else:
        zan = int(((B-1)-A1-1)/2)
        print(int(A1+1+zan))

Submission status: Wrong Answer

Solution code:
n,a,b = list(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())
#N, A, B
#Nは全部の卓数
#AはAさんの卓
#BはBさんの卓
count = 0

if A < B:
    if (B - A) % 2 == 0:
        while True:
            B -= 1
            A += 1
            count += 1
            if A == B:
                break
    if not (B - A) % 2 == 0:
        if N-B > A-1:
            count = B-1
        else:
            count = N-A

if A > B:
    if (A - B) % 2 == 0:
        while True:
            A -= 1
            B += 1
            count += 1
            if A == B:
                break
    if not (A - B) % 2 == 0:
        if N-A > B-1:
            count = A-1
        else:
            count = N-B

print(count)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

startA = a == (a == 1)
endB = (b == n)
aida = b-a-1


if any([startA, endB]):
    # 端に点があれば、間の卓数＋１
    print(aida+1)
else:
    if aida % 2 != 0:
        #　間の卓数が奇数なら、間の個数/2 +1
        print(aida//2+1)
    else:
        if (a-1) > (n - b):
            print(n-1)
        else:
            print(b-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
mylist = [int(x) for x in input().split()]
N=mylist[0]
A=mylist[1]
B=mylist[2]

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3

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

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

Submission status: Wrong Answer

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

if N == 2:
    print(1)
    exit()

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

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

# Aが近い
if (A-1) <= (N-B):
    flag = True
# Bが近い
else:
    flag = False

if flag:
    move = A-1
    answer = move + 1 + ((B-A-1)//2)
else:
    move = N-B
    answer = move + 1 + ((B-A-1)//2)

print(answer)

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)

    if right == N:
        print(N - left)
    elif left == N:
        print(N - right)
    else:
        # distance
        # 左のほうが近い
        if (left - 1) < (N - right):
            print(right - 1)
        else:
            # 右のほうが近い
            print(N - left)

Submission status: Wrong Answer

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

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

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=10**19
    if tempR-1>0:
        mid1=(tempR-1)//2 + a-1
    tempL=a+n-b
    mid2=10**19
    if n-tempL > 0:
        mid2=(n-tempL)//2 + n-a
    ans = min(ans,mid1,mid2)
    

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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