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:
from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
l_si_i = [int(s) for s in stdin.readline().rstrip().split()]
n = l_si_i[0]
a = l_si_i[1]
b = l_si_i[2]

num = b - a
if a == 1 or b == n:
    if num % 2 == 0:
        print(int(num / 2))
    else:
        print(int((num-1)/2)+1)
if a != 0 and b != n:
    if num % 2 == 0:
        print(int(num / 2))
    elif num % 2 == 1:
        res1 = a - 1
        b1 = b - (a - 1)
        a1 = 1
        num = b1 - a1
        if num % 2 != 0:
            res1 += 1
            b1 -= 1
        res1 += int((b1 - a1) / 2)

        res2 = n - b
        a2 = n - b + a
        b2 = n
        num = b2 - a2
        if num % 2 != 0:
            res2 += 1
            a2 += 1
        res2 += int((b2 - a2) / 2)
        res = 0
        if res1 <= res2:
            res = res1
        else:
            res = res2
        print(res)

Submission status: Wrong Answer

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


if A < B:
    kari = B-A
    sa1 = B-1
    sa2 = N-A
    sa3 = min(sa1,sa2)#端っこにいってから折り返さない場合
    
    sa4 = N-B
    sa5 = A-1
    sa6 = min(sa4,sa5)
    
else:
    kari = A -B
    sa1 = A-1
    sa2 = N-B
    
    sa3 = min(sa1,sa2)
    
    sa4 = N-A
    sa5 = B-1
    sa6 = min(sa4,sa5)



    
out = kari // 2        
out2 = kari % 2     
#2の倍数の場合は差をとれば終了する。



if out2 == 0:
    ans = out
else:
    ans = int(sa6+(out+1)/2)

#端っこにいってから折り返す可能性がある。

print(ans)

Submission status: Wrong Answer

Solution code:
N,A,B = list(map(int,input().split()))
count = 0
while A!=B:
    if A < B:
        if B == 1:
            pass
        else:
            B -= 1
    if A > B:
        if B == N:
            pass
        else:
            B += 1
    if (A == B and ((not A == 1) or (not A == 1))):
        if A < N/2:
            A -= 1
        else:
            A += 1
    else:
        if A < B:
            if A == 1:
                pass
            else:
                A += 1
        if A > B:
            if A == N:
                pass
            else:
                A -= 1
    count += 1
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

e = (b+a) // 2
even = (b-e) + (e-a)
upper = max(a-1, b-1)
lower = max(n-a, n-b)

print(min([even, lower, upper]))

Submission status: Wrong Answer

Solution code:
n = input().split()
a = int(n[1])
b = int(n[2])
n = int(n[0])
r1 = 100000000000000000000
if((b-a)%2==0):
  r1 = (b-a)//2
r2 = b - 1
r3 = n - a
if(r1 < r2):
  r1 = r2
if(r1 < r3):
  r1 = r3
print(r1)

Submission status: Wrong Answer

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

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

else:
    upfold = a
    downfold = n - b + 1

    pat1 = int(upfold + ((b - upfold) - 1)/2)
    pat2 = int(downfold + (n - a - downfold)/2)

    print(min([pat1, pat2]))

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

Submission status: Wrong Answer

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

if (b-a)%2==0:
  x=(b-a)/2
elif n-a>=b-1:
  x=b-1
elif b-1>n-a:
  x=n-1

print(int(x))

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
s = float('inf')
m = float('inf')
e = float('inf')
if (B - A) % 2 == 0:
  m = (B - A) // 2
s = max(B - 1, N - B)
e = max( A - 1, N - A)
print(min(s, m, e))

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

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]
    dst = a - b
    dst_top = a - 1
    dst_lst = n - b
    long = dst_top if dst_top<dst_lst else dst_lst

    if dst % 2 == 0:
        short = dst / 2
        long = (dst - (long + 1)) / 2 + (long + 1)
    else:
        short = 2 * n
        long = (dst - (long + 2)) / 2 + (long + 1)

    print(min([short, long]))

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

Submission status: Wrong Answer

Solution code:
def solve(n, a, b):
    cand = [n-a, b-1]
    diff = b - a
    if diff % 2 == 0:
        cand.append(int(diff / 2))
    return min(*cand)

if __name__ == '__main__':
    n, a, b = map(int, input().split())
    print(solve(n, a, b))

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

Submission status: Wrong Answer

Solution code:
input_data = input()
input_data = input_data.split()

n = int(input_data[0])
a = int(input_data[1])
b = int(input_data[2])

if a > b:
    a = int(input_data[2])
    b = int(input_data[1])

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    while True:
        left_s = A - 1
        right_s = N - B
        sub = B - A
        
        if A == B:
            return ans
        ans+=1
        # 偶数なら
        if sub % 2 == 0:
            return sub / 2
        # 奇数なら
        else:
            if left_s < right_s:
                if A != 1:
                    A -= 1
                B -= 1
            else:
                if B != N:
                    B += 1
                A += 1

if __name__ == '__main__':
    print(int(main()))

Submission status: Wrong Answer

Solution code:
N, A, B = [int(i) for i in input().split()]
#  N, A, B = [5, 2, 4]
#  N, A, B = [5, 2, 3]
#  N, A, B = [10, 2, 3]
#  N, A, B = [10, 7, 8]
#  N, A, B = [5, 2, 5]
#  N, A, B = [10, 2, 8]
#  N, A, B = [2, 1, 2]
#  N, A, B = [2, 1, 1]
a = A - 1
b = N - B
diff = abs(A - B)
if diff == 0:
    print(0)
else:
    #  print(a, b, diff)
    if diff % 2 == 0:
        print(diff // 2)
    else:
        if a < b:
            print(B - 1)
        else:
            print(N - A)

Submission status: Wrong Answer

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

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

if diff == 0 or mod != 0:

  if n - a < b - 1 :
    print( n - a )   
  else : 
    print( b - 1 )
    


elif mod == 0 :
  
  print( diff // 2 )

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans1 = 10000000000000000000

# a,b 勝ち続け or 負け続けで会える場合
if abs(a-b)%2==0:
    ans1 = (b-a)//2

# 1 or n テーブルで会える場合
ans2 = min(b-1, n-a)


# 17, 2, 7 とか, 一旦どちらかが端に行ってから途中で会う場合
c = 0
if a-1 <= n-b:
    c = a - 1
    a, b = 1, b-c
    ans3 = c + (b-2)//2 + 1
else:
    c = n - b
    a, b = a + c, n
    ans3 = c + (b-2)//2 +1
            
print(min(ans1, ans2, ans3))

Submission status: Wrong Answer

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

distance = B - A
moves = 0
if distance % 2 ==1:
    distance_B2W = N - B
    distance_A2W = A - 1
    if min(distance_A2W,distance_B2W) != 0:
        moves = moves + min(distance_A2W,distance_B2W)
    else:
        moves = moves + 1
    if distance != 1:
        moves = moves + (distance - 1) // 2
    else:
        moves = moves + 1
    print(moves)
else:
    print(distance // 2)

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
N, A, B = [int(i) for i in input().split()]
a = A - 1
b = N - B
diff = abs(A - B)
if diff == 0:
    print(0)
else:
    if diff % 2 == 0:
        print(diff // 2)
    else:
        if a < b:
            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:
    print(min(b-1, n-a))

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]
    dst = a - b
    dst_top = a - 1
    dst_lst = n - b
    long = dst_top if dst_top<dst_lst else dst_lst

    if a - b%2 == 0:
        short = dst
        long = (dst - (long + 1)) / 2 + (long + 1)
    else:
        short = 2 * n
        long = (dst - (long + 2)) / 2 + (long + 1)

    print(min([short, long]))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys

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

    if A > B:
        tmp = A
        A = B
        B = tmp

    c = abs(A-B)
    if (c - 1) % 2 == 1:
        point = int((A + B) // 2)
        print(abs(A - point))
        sys.exit()

    else:
        ansa = abs(1 - B)
        ansb = abs(N - A)

        if ansa >= ansb:
            print(ansb)
        else:
            print(ansa)

main()

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 A <=B:
        a = N - A
        b = B - 1
    else:
        a = N - B
        b = A - 1
    print(min(a, b))

Submission status: Wrong Answer

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

Half = (A + B)//2

if Half == (A + B)/2:
    if Half >= A:
        print(Half - A)
    elif Half < A:
        print(A - Half)
else:
    if N/2 >= A and N/2 >= B:
        print(B - 1)
    elif N/2 <= A and N/2 <= B:
        print(N - A)
    elif B > N/2 > A:
        if (N - A) < (B - 1):
            print(N - A)
        else:
            print(B - 1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
players = [int(x) for x in input().split(" ")]
end = [1, players[0]]
endState = True if players[1] in end or players[2] in end else False
sub = abs((players[1] - players[2]))
if sub % 2 == 0: print(sub//2)
elif endState and sub == 1: print(1)
elif sub == 1: print(min(players[0]-players[1], players[0] - players[2]))
elif endState: print(sub)
elif sub % 2 != 0: print(max(players[0]-players[1], players[0]-players[2]))

Submission status: Wrong Answer

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

if (B - A) % 2 == 1:
    # どっちの角による
    if B - A >= 3:
        if A - 1 < N - B:
            print((B - 3) // 2 + 2)
        else:
            print((N - A - 2) // 2 + 2)
    else:
        print(min(N - A, B - 1))
else:
    print((B - A) // 2)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
k=b-a-1
ans1=(k-1)//2+1
ans2=min(b-1,n-a)
print(min(ans1,ans2))

Submission status: Wrong Answer

Solution code:
from decimal import Decimal, ROUND_HALF_UP
def answer(N, A, B):
  round = 0
  range = B-A-1
  if range == 0 or range % 2 == 0:
    left = A-1
    right = N-B
    if left < right:
      round = B-1
    elif left > right:
      round = N-A
    else:
      round = B-1
  else:
    round = Decimal(str(range/2)).quantize(Decimal('0'), rounding=ROUND_HALF_UP)
  return round

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

Submission status: Wrong Answer

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

C = B-A

if C % 2 == 0:
#     print("1")
    print(int((B-A)/2))
elif C == 1:
#     print("2")
    kabe = int(min(N-B,A-1))
    print(kabe + 1)    
else:
#     print("3")
    if N-B > A-1:
        print(int((B+A-1)/2))
    else:
        print(int(N-(A+B-1)/2))

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
if A % 2 == B % 2: # 両方とも偶数/奇数の場合
    print(int(abs(A-B)/2))
else: # 両方が違う場合
    # 大きい値がNにいってから戻るパターン
    nReturnedCount = (N - max(A, B) + 1)
    nCount = nReturnedCount + int((N - (min(A, B) + nReturnedCount)) / 2)
    # 小さい値が1にいってから戻るパターン
    minReturnedCount = min(A, B)
    minCount = minReturnedCount + int(((max(A, B) - minReturnedCount) - 1) / 2)
    print(min(nCount, minCount))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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


if A < B:
    kari = B-A
    sa1 = B-1
    sa2 = N-A
    sa3 = min(sa1,sa2)#端っこにいってから折り返さない場合
    
    sa4 = N-B
    sa5 = A-1
    sa6 = min(sa4,sa5)
    
else:
    kari = A -B
    sa1 = A-1
    sa2 = N-B
    
    sa3 = min(sa1,sa2)
    
    sa4 = N-A
    sa5 = B-1
    sa6 = min(sa4,sa5)



    
out = kari // 2        
out2 = kari % 2     
#2の倍数の場合は差をとれば終了する。



if out2 == 0:
    ans = out
else:
    ans = int(sa6+(kari+1)/2)

#端っこにいってから折り返す可能性がある。

print(ans)

Submission status: Wrong Answer

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

aaa = A-B
new_A = A
new_B = B
times = 0
if abs(aaa%2) == 0 and not aaa==0:
  if aaa > 0:
    while True:
      new_A -= 1
      new_B += 1
      times += 1
      if new_A == new_B:
        break
  if aaa < 0:
    while True:
      new_A += 1
      new_B -= 1
      times += 1
      if new_A == new_B:
        break
      
if abs(aaa%2) == 1:
  bbb = min(abs(N-A),abs(1-A))
  ccc = min(abs(N-B),abs(1-B))
  times = max(bbb,ccc)
print(times)

Submission status: Wrong Answer

Solution code:
a = list(map(int, input().split()))
N,A,B = a[0],a[1],a[2]

dim = B - A

if dim % 2 == 0:
  print(int(dim/2))
if dim % 2 == 1:
  dimAN = N - A
  dimBN = N - B
  dimB1 = B - 1
  dimA1 = A - 1
  
  if dimAN > dimB1:#Aが1にいって折り返す
    print(dimA1 + int((dim-1)/2)+1)
  elif dimAN < dimB1:
    print(dimBN + int((dim-1)/2)+1)
  elif dimAN == dimB1:
    print(dimBN + int((dim-1)/2)+1)

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

Submission status: Wrong Answer

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

ans = b-a
if ans % 2 == 0:
  ans = ans/2
else:
  if n-a > b-1:
    ans = b-1
  else:
    ans = n-a

print(ans)

Submission status: Wrong Answer

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

sa = abs(a-b)
n = n*2
if sa %2 == 0:
    print(int(sa/2))
else:
    if n-b < a-1:
        print(n-a)
    elif n-b > a-1:
        print(b-1)
    else:
        print(b-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

N -= 1
A -= 1
B -= 1

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

Submission status: Wrong Answer

Solution code:
import math
N,A,B = map(int,input().split())
if abs(A-B) != 1:
    if abs(A-B)%2 ==0 :
        print(math.ceil(abs(B-A)/2))

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


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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if A%2 == B%2:
    o['a'] = abs(A-B)//2

N -= 1
L,R = sorted([A,B])
L -= 1
R -= 1

a = N - R
LL = L + a
if LL % 2 == N % 2:
    o['b'] = a + (N - LL)//2

b = L
RR = R - b
if RR % 2 == 0:
    o['c'] = b + RR // 2

o['d'] = N - L
o['e'] = R

print(min(o.values()))

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()
    # n,a,b=randint(1,30),randint(1,10),randint(5,25)
    # print(n,a,b)
    if (b-a)%2==0:
        pf(str((b-a)//2))
    elif a==1 or b==n:
        pf(str((b-a+1)//2))
    else:
        ans = min(n-a,b-1)
        pf(str(ans))

if __name__ == "__main__":
    main()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split(" ")) 
#N,A,B=map(float,input().split(" ")) 
if (B-A)%2==0:
    print(int(int(B-A)//2))
else:
    a1=int(min(int(N-1-A),int(B-1)))
    a2=int(int(A-1)+1+int(B-A-1)//2)
    a3=int(int(N-1-B)+1+int(B-A-1)//2)
    print(min(a1,a2,a3))

Submission status: Wrong Answer

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

a_length=a
b_length=n-b

if not (b-a)%2:
    print(b-a//2)
elif b_length>=a_length:
    print(a+(b-a-1)//2)
elif b_length<a_length:
    print(n-b+(b-a)//2+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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 == N:
    Alose = N
  else:
    Alose += 1
  
  if 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())
o = {}

if A%2 == B%2:
    o['a'] = abs(A-B)//2

N -= 1
L,R = sorted([A,B])
L -= 1
R -= 1

a = N - R
LL = L + a
if LL % 2 == N % 2:
    o['b'] = a + (N - LL)//2

b = L
RR = R - b
if RR % 2 == 0:
    o['c'] = b + RR // 2

o['d'] = N - L
o['e'] = R

print(o)
print(min(o.values()))

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

Submission status: Wrong Answer

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

ans = b-a
if ans % 2 == 0:
  ans /= 2
else:
  if n-a > b-1:
    ans = b-1
  else:
    ans = n-a

print(ans)

Submission status: Wrong Answer

Solution code:
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,(c-1)//2+a,(c-1)//2+n-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]
    dst = (abs(a - b))
    fst = a if a<b else b
    snd = a if a>b else b
    dst_top = snd - 1
    dst_lst = n - fst
    long = dst_top if dst_top<dst_lst else dst_lst

    if abs(a - b)%2 == 0:
        short = dst
        long = (dst - (long + 1)) / 2 + (long + 1)
    else:
        short = 2 * n
        long = (dst - (long + 2)) / 2 + (long + 1)

    print(min([short, long]))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

output = 0
if d % 2 == 0:
  output = int(d / 2)
else:
  # 「aと1の距離」の方が「bとn」の距離より近い場合
  if a-1 < n-b:
    if (b-(a-1)-1) % 2 == 0:
      output = (a-1) + int((b-(a-1)-1) / 2)
    else:
      output = (a-1) + int((b-(a-1)-1) / 2) + 1
  else:
    if (n-(n-b)-a) % 2 == 0:
      output = (n-b) + int((n-(n-b+a)) / 2)
    else:
      output = (n-b) + int((n-(n-b+a)) / 2) + 1
      
print(output)

Submission status: Wrong Answer

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

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

print(count)

Submission status: Wrong Answer

Solution code:
import numpy as np

N, A, B = map(int, input().split())
ab_max = np.amax(np.array([A, B]))
ab_min = np.amin(np.array([A, B]))

if (A - B) % 2 == 0:
    print(int((ab_max - ab_min) / 2))
else:
    print(int(np.amin([(ab_max - 1), (N - ab_min)])))

Submission status: Wrong Answer

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

diff = abs(A - B)

if diff % 2 == 0:
    x = diff/2
elif N == 2:
    x = 1
elif diff == 1:
    small = min(A, B)
    big = max(A, B)
    x_1 = N - small
    x_2 = big - 1
    x = min(x_1, x_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:
N, A, B = map(int, input().split())
if (B-A) % 2 == 0:
    print((B-A) // 2)
else:
    print(min(N-A, B-1, (B - A- 1) // 2 + N - B + 1, (B - A - 1) // 2 + A + 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 a == 1:
        print(b-1)
    elif b == n:
        print(n-a)
    else:
        print(min(max(a, b) - 1, n - min(a, b)))

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split(" ")) 
#N,A,B=map(float,input().split(" ")) 
if (B-A)%2==0:
    print(int(int(B-A)//2))
else:
    a1=int(min(int(N-1-A),int(B-1)))
    a2=int(int(A-1)+1+int(B-A-1)//2)
    a3=int(int(N-1-B)+1+int(B-A-1)//2)
    print(a1,a2,a3)
    print(min(a1,a2,a3))

Submission status: Wrong Answer

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

if (B - A) % 2 == 0:
  print((B - A) // 2)
else:
  NA = N - A
  B1 = B - 1
  if NA < B1:
    distance = N - B
    adjust = distance + 1
    moveA = A + adjust
    print(((N - moveA) // 2) + adjust)
  else:
    distance = A - 1
    adjust = distance + 1
    moveB = B + adjust
    print(((moveB - 1) // 2) + adjust)

Submission status: Wrong Answer

Solution code:
#coding:utf-8
n, a, b = map(int, input().split())
#a,bのテーブル距離
dist = b-a

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

print(ans)

Submission status: Wrong Answer

Solution code:
import sys

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

    if A > B:
        A = tmp
        A = B
        B = tmp


    c = abs(A-B)
    if (c - 1) % 2 == 1:
        point = int((A + B) // 2)
        print(abs(A - point))
        sys.exit()

    else:
        ansa = abs(1 - B)
        ansb = abs(N - A)

        if ansa >= ansb:
            print(ansb)
        else:
            print(ansa)

main()

Submission status: Wrong Answer

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

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(n-a)
elif n < a+b:
    print(max(n-b,n-a))
else:
    print(min(b-1,n-a))

Submission status: Wrong Answer

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

if (B - A) % 2 == 0:
    # print('a')
    print((B - A) // 2)
else:
    if N - A > B - 1:  # 1 で対戦
        # print('b;')
        print(B - 1)
    else:
        # print('c;')
        print(N - A)

Submission status: Wrong Answer

Solution code:
a = list(map(int, input().split()))
N,A,B = a[0],a[1],a[2]

dim = B - A

if dim % 2 == 0:
  print(int(dim/2))
if dim % 2 == 1:
  dimAN = N - A
  dimBN = N - B
  dimB1 = B - 1
  dimA1 = A - 1
  
  if dimAN > dimB1:#Aが1にいって折り返す
    print(dimA1 + int((dim-1)/2)+1)
  elif dimAN < dimB1:
    print(dimBN + int((dim-1)/2)+1)
  elif dimAN == dimB1:
    print(dimB1 + int((dim-1)/2)+1)