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

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

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

sa = abs(a-b)

if sa % 2 == 0:#差が偶数の場合
    print(int(sa / 2))
else:#差が奇数の場合
    if abs(b-1) < abs(a-1):
        l = abs(b-1)
    else:
        l = abs(a-1)

    if abs(b-5) < abs(a-5):
        r = abs(b-5)
    else:
        r = abs(a-5)

    if l < r:
        print(r)
    else:
        print(l)

Submission status: Wrong Answer

Solution code:
import math

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

d = b - a + 1
d2 = a + n - b + 1

if d > d2:
    d = d2
if d%2 == 0:
    print(d//2 + 1)
else:
    print(math.ceil(d/2))

Submission status: Wrong Answer

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

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

else:
    print(int(min(N-A,B-1)))

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


# N, A, B = 10 ** 18, 2, 10 ** 18
N, A, B = 100, 5, 12


def main(n, a, b):
    # print(n, a, b)
    distance = b - a

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


print(main(N, A, B))

Submission status: Wrong Answer

Solution code:
input_list = list(map(int, input().split()))
table = input_list[0]
position_A = input_list[1]
position_B = input_list[2]
if (position_B - position_A) % 2 != 0:
  if abs(position_A - (int(table / 2) + 1)) < \
  abs(position_B - (int(table / 2) + 1)):
    ans = table - position_A
  else:
    ans = position_B - 1

else:
  ans = int((position_B - position_A) / 2)
print(ans)

Submission status: Wrong Answer

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

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(a)
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:
num,a,b = map(int,input().split())

if b-a %2 ==0:
    print((b-a)//2)
    
    #間隔が奇数の時
else:
    #aと右端の差
    p=num-a
    #bと左端の差
    q=b-1
    #aと左端の差
    r=a-1
    #bと右端の差
    s=num-b
    
    #もしbとaの差が3未満のとき
    if b-a <3:
        p = min(max(a,b)-1,num-min(a,b))
        print(p)
    
    else:
        z=r+1+(b-(r+1)-1)//2
        y=s+1+(num-(a+(s+1)))//2
        print(min(y,z))

Submission status: Wrong Answer

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

if (A+B)%2 == 0:
    print(round((A+B)/2-A))
elif (A+B)%2 != 0:
    if A == 2:
        print(N-B)
    elif A== 1:
        print(B-A)
    elif B == N-1:
        print(N-A)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
if 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(min(max(a, b) - 1, n - min(a, b)))

Submission status: Wrong Answer

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

diff = B - A

_a, mod = divmod(diff, 2)

is_diff_even = (mod == 0)

if is_diff_even:
    print(diff // 2)
else:
    left = A
    right = B

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

else:
  i=0
  while B-A>=1:
    B=B-1
    A=A+1
    i=i+1
    if A==B:
      print(i)
      break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,A,B = input().split()
N = int(N)
A = int(A)
B = int(B)
sa = B-A-1
if sa%2 == 1:#間に奇数個のテーブルがある時
    mi = (sa+1)/2+1
    print(mi)
if sa%2 == 0:
    mi = min(N-A,B-1)#遠いほうが端との距離が近い方で集まる
    print(mi)

Submission status: Wrong Answer

Solution code:
import math

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

num_play = (b - a) / 2

if num_play.is_integer():
  print(int(num_play))
else:
  cnt_a = b - 1
  cnt_b = n - a
  cnt_c = a + (b - a  -1) // 2
  cnt_d = n - b + 1 + (b - a + 1) // 2
  print(min(cnt_a, cnt_b, cnt_c, cnt_d))

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
aa = a - (a - 1)
bb = b - (a - 1)
aaa = a + (n - b) + 1
bbb = n

if (a + b)%2 == 0:
    print(int(abs(((a+b)/2) - a)))
else:
    result = min(b - 1, n - a, int(abs(((aa+bb)/2) - a)) + a + 2, int(abs(((aaa+bbb)/2) - a) + n - b + 3))
    print(result)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
x = min(a,b)
y = max(a,b)    
if a==b:
    print("0")
elif abs(a-b)%2==0 and x!=1 and y!=n:
    k = abs(a-b)
    print(k//2)
elif abs(a-b)%2==0:
    print(y-x)
else:
    print(min(max(n-x,y-x),max(x-1,y-1)))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    n, a, b = map(int, input().split())
    ans = 0
    diff = b - a
    if diff % 2 == 0:
        ans = diff // 2
    else:
        ab = [a, b]
        len_to_opp = [0] * 2
        len_to_opp[0] = n - ab[0]
        len_to_opp[1] = ab[1] - 1
        ans = min(len_to_opp)

        len_to_self = [0] * 2
        len_to_self[0] = ab[0] - 1
        len_to_self[1] = n - ab[1]
        if len_to_self[0] < len_to_self[1]:
            ab[0] *= -1
        else:
            ab[1] *= -1
        temp_ans = abs(ab[0] - ab[1]) // 2
        ans = min(ans, temp_ans)

    print(ans)


if __name__ == '__main__':
    main()

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:
  print(int((dim+1)/2)+1)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
import sys
from math import factorial
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

n, a, b = MAP()

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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:
    low=A
    high=B
    if (low-1)>=(N-high):
        dis=(N-low)+(N-high)
        if dis%2==0:
            print(int(dis/2))
        elif dis%2==1:
            print(int((dis+1)/2))
    elif (N-high)>(low-1):
        dis=(low-1)+(high-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 = map(int, input().split())
num = abs(a-b)
if num%2 == 0:
    half = num//2
    print(half)
else:
#    half = N
    edge = min(N-min(a,b), max(a,b)-1)
    print(edge)
#print(min(half, edge))

Submission status: Wrong Answer

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

print(answer)

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

print(count)

Submission status: Wrong Answer

Solution code:
import sys
import math

(N, A, B) = [int(e) for e in (input().split(" "))]
if (A+B) % 2 != 1:
    print(math.ceil((B-A)/2))
    exit(0)
hidari = A - 1
migi = N - B
if hidari > migi:
    print(math.floor(A+(B-A)/2))
    exit(0)
else:
    buf = N-B+1
    print(math.floor(buf + (N-(A+buf))/2))
    exit(0)

Submission status: Wrong Answer

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

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

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
    moves = moves + min(distance_A2W,distance_B2W)
    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 = (int(x) for x in input().split())

n1 = B - 1
nx = (B-A)/2
nn = N - A
n1x = (B-A+(A-1)*2+1)/2
nnx = (B-A+(N-B)*2+1)/2

if nx % 1 != 0 :
    print(int(min(n1, nn, n1x, nnx)))
else:
    print(int(min(n1, nn, n1x, nnx, nx)))

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(abs(B-A)-1)

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


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

Submission status: Wrong Answer

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

disA = b - 1
disB = n - a
if (b-a) % 2 == 0:
  disC = (b-a) // 2
else:
  disC = 3*n

print(min(disA, disB, disC))

Submission status: Wrong Answer

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


def main():
    N,A,B = (int(x) for x in input().split())


    def calc(n, a, b, ans):
        if abs(a-b)%2 == 0:
            return ans + (abs(a-b)//2)
        else:
            if min(a,b) - (n - max(a,b)) <= 0:
                a -= 1 if not a==1 else 0
                b -= 1 if not b==1 else 0
            else:
                a += 1 if not a==n else 0
                b += 1 if not b==n else 0
            ans += 1
            return calc(n,a,b,ans)

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

if abs(b-a)%2==0:
    print(abs(b-a)//2)
elif abs(b-a)%2==1:
    lst = [a-1,n-b]
    if lst[0]>lst[1]:
        print(n-a)
    elif lst[0]<lst[1]:
        print(b-1)
    elif lst[0]==lst[1]:
        print(b-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

else:
  i=0
  while B-A>=1:
    B=B-1
    A=A+1
    i=i+1
    if A==B:
      print(i)
      break

Submission status: Wrong Answer

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

if (B - A) % 2 == 0:
  print((B - A) // 2)
else:
  if N - A < B - 1:
    cnt = 0
    for i in range(N - A):
      A += 1
      B = min(B + 1, 5)
      cnt += 1
      if (B - A) % 2 == 0:
        print(cnt + (B-A)//2)
        break
  else:
    cnt = 0
    for i in range(B - 1):
      A = max(1, A - 1)
      B -= 1
      cnt += 1
      if (B - A) % 2 == 0:
        print(cnt + (B-A)//2)
        break

Submission status: Wrong Answer

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

l = b-a
if l %2 == 0:
  print(l//2)
  
else:
  mi = b-1
  ma = n-a
  
  x1 = min(mi,ma)
  t1 = a-1
  b -= (t1+1)
  t1 += (b-1)//2+1
  t2 = n-b
  a += (t2+1)
  t2 += (n-a)//2+1
  print(min(x1,t1,t2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s=input().split()
N=int(s[0])
A=int(s[1])
B=int(s[2])
if B>A:
    d=B-A
else:
    d=A-B
if d%2==0:
    print(int(d/2))
else:
    print(int((A+B-1)/2))

Submission status: Wrong Answer

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

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

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

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

print(rnd)

Submission status: Wrong Answer

Solution code:
w, x, y = input().split(" ")
n = int(w)
a = int(x)
b = int(y)

round = 0
if abs(a - b) % 2 == 0:
    round = abs(a - b) // 2
else:
    half = n//2
    if a >= half and b >= half:
        round = max(abs(n-a), abs(n-b)) - 1
    elif a <= half and b <= half:
        round = max(a, b) - 1
    else:
        round = max(abs(a-half), abs(b-half)) - 1

print(round)

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((min(A, B) + nReturnedCount) / 2)
    # 小さい値が1にいってから戻るパターン
    minReturnedCount = min(A, B)
    minCount = minReturnedCount + int((max(A, B) - minReturnedCount) / 2)
    print(min(nCount, minCount))

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

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if (A+B)%2 == 0:
    print(round((A+B)/2-A))
elif (A+B)%2 != 0:
    if A==2:
        print(N-B)
    elif B==N-1:
        print(N-A)

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

sa = abs(A-B)

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

Submission status: Wrong Answer

Solution code:
from decimal import Decimal
N, A, B = input().split()
n=Decimal(N)
a=Decimal(A)
b=Decimal(B)
if (b-a) % 2==0:
    print((b-a)/2)
elif (b-1) < (n-a):
    print(b-1)
else:
    print(n-a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if (a-b) % 2 == 0:
  print(max(a-b,b-a)//2)
  exit()

top=max(a-1,b-1)
bottom=max(n-a,n-b)
print(min(top,bottom))

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

Submission status: Wrong Answer

Solution code:
N,A,B = list(map(int,input().split()))
diff = B - A
N2B = N - B
N2A = N - A
sumN = N2A + N2B
sumAB = A + B
if diff % 2 == 0:
    print(diff // 2)
else:
    tmp = diff // 2
    if sumN < sumAB:
        if N2A < tmp:
            print(N2A)
        else:
            print(tmp + 1)
    else:
        if B-1 < tmp: 
            print(B - 1)
        else:
            print(tmp + 1)

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

Submission status: Wrong Answer

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

n1 = B - 1
nx = (B-A)/2
nn = N - A
n1x = (B-A+(A-1)*2+1)/2
nnx = (B-A+(N-B)*2+1)/2

if nx % 1 != 0 :
    print(int(min(n1, nn, n1x, nnx)))
else:
    print(int(nx))

Submission status: Wrong Answer

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

for i in range(abs(A-B)):
    if (abs(A-B)==1):
        print(min(A,B)) 
        break
    elif abs(A-B)==2:
        print(abs(A-B)-1)
        break
    else:
        if A == min(A,B):
            A+=1
            B-=1
        else:
            B+=1
            A-=1
        if (abs(A-B)==1):
            print(min(A,B)+1) 
            break

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

k = b-a

a_m = n - a
b_m = n - b
k_m = [a_m, b_m]

if k%2 == 0:
    print(int(k/2))

else:
    if n == a or n == b or a == 1 or b == 1:
        print(max(k_m))
    else:
        print(min(k_m))

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

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((A+B)//2,(N*2-A-B)//2))

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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 B == N:
        return N - A
    if A == 1:
        return B - 1
        
    # 偶数なら
    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 == 1:
    if b == n and a != 1:
        print(min(n - a, b-1))
    elif a == 1 and b != n:
        print(min(b-1, n-a))
    elif a == 1 and b == n:
        print(n-1)
    else:
        print(min(n-a, b-1))
else:
    if b == n and a != 1:
        print(min((b-a)//2, b-a))
    elif a == 1 and b != n:
        print(min((b-a)//2, b-a))
    elif a == 1 and b == n:
        print(b-a)
    else:
        print((b-a) // 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((a + b -1)/2)
    else:
        print((n-a + n-b +1)/2)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
aa = a - (a - 1)
bb = b - (a - 1)
aaa = a + (n - b) + 1
bbb = n

if (a + b)%2 == 0:
    print(int(abs(((a+b)/2) - a)))
else:
    result = min(b - 1, n - a, int(abs(((aa+bb)/2) - a)) + a + 1, int(abs(((aaa+bbb)/2) - a) + n - b + 2))
    print(result)

Submission status: Wrong Answer

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

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

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:
    low=min(A, B)
    high=max(A, B)
    if (low-1)>=(N-high):
        dis=(N-low)+(N-high)
        if dis%2==0:
            print(int(dis/2))
        elif dis%2==1:
            print(int((dis+1)/2))
    elif (N-high)>(low-1):
        dis=(low-1)+(high-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=map(int,input().split())
c=abs(a-b)
if(c%2==0):
    print(int(c/2))
else:
    d=min(a,b)
    e=max(a,b)
    f=min(d-1,n-e)
    print(f+c)

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