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 decimal import Decimal, ROUND_HALF_UP

def move_center(N, A, B):
  range = B - A - 1
  if range % 2 == 0:
    return -1
  return Decimal(str(range/2)).quantize(Decimal('0'), rounding=ROUND_HALF_UP)

def move_left(N, A, B):
  return B - 1

def move_right(N, A, B):
  return N - A

def move_left_back(N, A, B):
  range = B - A - 1
  if range == 0 or range % 2 != 0:
    return -1
  left = A-1
  round = left + 1
  range = range - 1
  round = round + Decimal(str(range/2)).quantize(Decimal('0'), rounding=ROUND_HALF_UP)
  return round

def move_right_back(N, A, B):
  range = B - A - 1
  if range == 0 or range % 2 != 0:
    return -1
  right = N-B
  round = right + 1
  range = range - 1
  round = round + Decimal(str(range/2)).quantize(Decimal('0'), rounding=ROUND_HALF_UP)
  return round

def answer(N, A, B):
  rounds = [move_center(N, A, B), move_left(N, A, B), move_right(N, A, B), move_left_back(N, A, B), move_right_back(N, A, B)]
  rounds = filter(lambda n:n!=-1, rounds)
  round = min(rounds)
  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()) #intでインプット
dif=abs(A-B)
if dif%2==0:
    print(int(dif/2))
elif dif%2==1:
    dis_1=(N-A)+(N-B)
    dis_2=(A-1)+(B-1)
    if dis_1%2==0:
        half_1=int(dis_1/2)
    elif dis_1%2==1:
        half_1=int((dis_1+1)/2)
    if dis_2%2==0:
        half_2=int(dis_2/2)
    elif dis_2%2==1:
        half_2=int((dis_2+1)/2)
    print(min(half_1, half_2))

Submission status: Wrong Answer

Solution code:
def how_match_play(N, A, B):
    return_value = 0
    if (B - A) % 2 == 0:
        return_value = (B - A) / 2
    else:
        diff_1A = A - 1
        diff_BN = N - B
        if diff_1A < diff_BN:
            return_value = B - 1
        else:
            return_value = N - A
            
    return return_value

n, a, b = input().split()
N = int(n)
A = int(a)
B = int(b)

print('N: {}'.format(N))
print('A: {}'.format(A))
print('B: {}'.format(B))

print(how_match_play(N, A, B))

Submission status: Wrong Answer

Solution code:
import sys, os

if len(sys.argv) < 4:
  print("error")
  exit()

N = int(sys.argv[1])
A = int(sys.argv[2])
B = int(sys.argv[3])

count = 0
odd_flag = False

if (B-A) %2 == 1:
  # print("even")
  # print((B-A %2))
  odd_flag = True

if not odd_flag:
  print( (B-A)//2 )

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

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
i = 1
p = 0
if (b-a)%2==0:
    print((b-a)//2)
else:
    if a-1 <= n-b:
        print(min((1+b-(a-2))//2,b-1))
    else:
        for i in range(1,n):
            a += 1
            if p == 1:
                b -= 1
            elif b >= n:
                b = n
                p += 1
            else:
                b += 1
            if a == b:
                print(i)
                break

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

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/agc041/tasks/agc041_a


def main():
    (n, a, b) = map(int, input().split(" "))
    ans = abs(a - b)
    if ans % 2 == 0:
        ans //= 2
    else:
        ato1 = a - 1
        bton = n - b
        if ato1 < bton:
            if ato1 * 2 < b - 1:
                b -= ato1
            ans = b - 1
        else:
            if bton + 2 < n - a:
                a += bton
            ans = n - a
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

C = int(B - A)
min = 0


while C > 2:
    min = min + 1
    C = C - 2
    print(C)

if C == 2:
    print(min + 1)
    exit
elif C == 1:
    print(min + 2)
    exit

Submission status: Wrong Answer

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

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

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

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

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

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
k=b-a-1
if k%2!=0:#間の卓が奇数
    ans=(k+1)//2
    print(ans)    
else:#偶数
    if a%2==0:
        ans=min(b-1,n-a)
        print(ans)
    else:
        
        k=k-(a-1)
        ans=a-1+(k+1)//2

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N,A,B = map(int,input().split())
temp = 0
if (B-A)%2 == 0:
    print(int((B-A)/2))
else:
    if A-1 < N-B:
        temp = A + (B-A-1)/2
    else:
        a = N - A + 1
        b = N - B + 1
        temp = a + (b-a-1)/2
    print(int(min([B-1,N-A,temp])))

Submission status: Wrong Answer

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

# print(N)
# print(A)
# print(B)

ans = 0

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(answer)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from sys import stdin
lines = stdin.readlines()
 
N, A, B = map(int, lines[0].split())
 
a = B - A
b = N - B
 
if a % 2 == 0:
  print(int(a / 2))  
else:
  if b > A:
    print(A)
  elif a > b:
    print(b + a)
  elif a > A:
    print(A + a)
  else:
    print(b)

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

Submission status: Wrong Answer

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

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

    else:
        shifta = abs(N - A)
        shiftb = abs(B - 1)

        if shifta > shiftb:
            print(shiftb)

        else:
            print(shifta)

main()

Submission status: Wrong Answer

Solution code:
a,b,c = input().split(" ")
a=int(a)
b=int(b)
c=int(c)
 
minum = c-b-1
count = 0
 
 
if (minum%2==0):
    if (a-b>b-1):
        while (b!=c) :
            if (b!=1):
                b-=1
            if (c!=1):
                c-=1
            count+=1
        print(count)
    else:
        while (b!=c) :
            if (b!=a):
                b+=1
            if (c!=a):
                c+=1
            count+=1
        print(count)
elif (minum%2!=0):
    print(minum)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
i = 1
p = 0
if (b-a)%2==0:
    print((b-a)//2)
else:
    if a <= (n//2):
        print(min((1+b-(a-2))//2,b-1))
    else:
        for i in range(1,n):
            a += 1
            if p == 1:
                b -= 1
            elif b >= n:
                b = n
                p += 1
            else:
                b += 1
            if a == b:
                print(i)
                break

Submission status: Wrong Answer

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

print(answer)

Submission status: Wrong Answer

Solution code:
import math

inpt = input().split(" ")
inpt = [int(i) for i in inpt]
N = inpt[0]
A = inpt[1]
B = inpt[2]


difab = abs(A - B)
r1 = math.ceil(difab)

dai = max(A,B)
shou = min(A,B)

r2 = N - dai + shou
r2 = math.ceil(r2)

ab_dis = min(r1,r2)

if ab_dis % 2 == 0:
  result = ab_dis / 2
  print(math.ceil(result))


else:
  r_cand = N*2
  if max(r1,r2) % 2 == 0:
    r_cand = max(r1,r2)
  if N - dai <= shou:
    if shou <= N - shou:
      result = min(math.ceil((shou + N - dai) / 2), r_cand)
      print(result)
    else:
      result = min(math.ceil((N - shou + N - dai) / 2), r_cand)
      print(result)
  else:
    if dai <= N - dai:
      result = min(math.ceil((dai + shou) / 2), r_cand)
      print(result)
    else:
      result = min(math.ceil((N - dai + shou) / 2), r_cand)
      print(result)

Submission status: Wrong Answer

Solution code:
n, A, B = input().split( )
n = int(n)
A = int(A)
B = int(B)
ans = 0
if A == B:
    ans = 0
elif (B-A) % 2 == 0:
    ans = (B-A) / 2
else:
    if A > B:
        ans = A - 1
    else:
        ans = B - 1
print(int(ans))

Submission status: Wrong Answer

Solution code:
number = input()
n,a,b = [int(ele)for ele in number.split(' ')]
res =[]
if (b-a) % 2 == 0:
    res.append(len(range(a,b))//2)

res.append(len(range(a,n)))
res.append(b-1)

print(min(res))

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 - a - 1)/2)
    pat2 = int(downfold + (b - a - 1)/2)
    print(pat1, pat2)
    print(int(min([pat1, pat2])))

Submission status: Wrong Answer

Solution code:
import math as m

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

dif = abs(B-A)
half = N/2
a2half = half - A
b2half = B - half - 1
if a2half == b2half:
  print(m.ceil(a2half))
else:
  n = N - B
  n2 = A - 1
  print(m.floor(n/2 if n>n2 else n2/2) + dif)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

    upfold = a
    downfold = n - b + 1

    pat1 = int(upfold + (b - a - 1)/2)
    pat2 = int(downfold + (b - a - 1)/2)
    print(pat1, pat2)
    print(int(min([pat1, pat2])))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
n,a,b = map(int,input().split())
ans =0
if (a-b)%2 ==0:
    print(int(abs((a-b))/2))
else:
    if n-max(a,b)<min(a,b)-1 and n!=max(a,b) and 1!=min(a,b):
        ans+=n - max(a,b)
        ans+=int((n-(min(a,b)+n - max(a,b)))/2)
        print(ans)
    elif n-max(a,b)>min(a,b)-1 and n!=max(a,b) and 1!=min(a,b):
        ans+=min(a,b)-1
        ans+=math.ceil((max(a,b)-(min(a,b)-1))/2)
        print(ans)
    elif n == max(a,b) and 1!=min(a,b):
        ans+=1
        ans+=int((n-min(a,b)-1)/2)
        print(ans)
    elif n != max(a,b) and 1==min(a,b):
        ans+=1
        ans+=int((max(a,b)-1)/2)
        print(ans)
    elif n == max(a,b) and 1==min(a,b):
        ans+=1
        ans+=int((n-min(a,b)-1)/2)
        print(ans)

Submission status: Wrong Answer

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

w_a = a % 2

if w_a == (b % 2):
  ans = b - a
  ans /= 2
  print(int(ans))
  exit()

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

Submission status: Wrong Answer

Solution code:

# 入力 =stdin.readline().rstrip()
# 分割 = stdin.readline().rstrip().split()

'''
条件に合うものを絞り込む
data = [1, 2, 3]
s = [x for x in data if x % 3 == 0]
'''

'''
文字配列を数値に
l_si = ['-10', '0', '100']

l_si_i = [int(s) for s in l_si]
'''

'''
a = [2, 4, 6, 8]
b = [3, 6, 9]

print(list(set(a) | set(b)))  # 和集合
print(list(set(a) & set(b)))  # 積集合
'''

'''
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
count = 0
while len([x for x in A if x % 2 == 0]) == N:
    A = list(map(lambda y: y / 2, A))
    count += 1
print(count)
'''

'''
.append(要素)
.extend(要素)
.insert(場所,要素)
del 配列名[場所]
-1で末尾で末尾から一つ前
'''
'''
間に空白追加
' '.join(lis)
'''
'''
copy.copy(配列名)6

'''
'''
sort()50
sorted(reverse=true)
'''
'''
2分探索
bisect.bisect_left(リスト, 要素)
'''


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 num % 2 == 0:
    res = num/2
    print(int(res))
elif num % 2 == 1:

    res1 = a - 1
    b1 = b - (a - 1)
    a1 = 1
    num1 = b1 - a1
    if num1 % 2 != 0:
        res1 += 1
        b1 -= 1

    res1 += (b1 - a1)/2

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

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

Submission status: Wrong Answer

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

d = b-a
d_nearest_side = int(min(a-1, n-b))
if d % 2 == 0:
    print(int(d/2))
else:
    move_side = 1 + int((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(int((b-a)/2))
else:
    if a and b <=int(n/2):
        print(b-1)
    elif a and b >=int(n/2):
        print(n-a)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

# 入力 =stdin.readline().rstrip()
# 分割 = stdin.readline().rstrip().split()

'''
条件に合うものを絞り込む
data = [1, 2, 3]
s = [x for x in data if x % 3 == 0]
'''

'''
文字配列を数値に
l_si = ['-10', '0', '100']

l_si_i = [int(s) for s in l_si]
'''

'''
a = [2, 4, 6, 8]
b = [3, 6, 9]

print(list(set(a) | set(b)))  # 和集合
print(list(set(a) & set(b)))  # 積集合
'''

'''
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
count = 0
while len([x for x in A if x % 2 == 0]) == N:
    A = list(map(lambda y: y / 2, A))
    count += 1
print(count)
'''

'''
.append(要素)
.extend(要素)
.insert(場所,要素)
del 配列名[場所]
-1で末尾で末尾から一つ前
'''
'''
間に空白追加
' '.join(lis)
'''
'''
copy.copy(配列名)6

'''
'''
sort()50
sorted(reverse=true)
'''
'''
2分探索
bisect.bisect_left(リスト, 要素)
'''


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 num % 2 == 0:
    print(int(num / 2))
elif num % 2 == 1:

    res1 = a - 1
    b1 = b - (a - 1)
    a1 = 1
    num1 = b1 - a1
    if num1 % 2 != 0:
        res1 += 1
        b1 -= 1

    res1 += (b1 - a1)/2

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

Submission status: Wrong Answer

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

v=b-(a+1)

if v%2==0:
    if a==1 or b==n:
        ans=int((v+1)/2)+1
    else:
        dif=min(n-b,a-1)
        #ans1=dif+int((v+2*dif)/2)+1
        ans1=dif+1+v//2
        if (n-b)<(a-1):
            ans2=n-a
        else:
            ans2=b-1
        #ans=min(ans1,ans2)
        ans=ans1
else:
    ans=(v+1)//2
print(ans)

Submission status: Wrong Answer

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

if (sa-1)%2==1:
  print(int(sa/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:
  ans = int((b - a)/2)
else:
  ans4 = int(int(a) + int((b-a-1)//2))
  ans5 = int(int(N-b+1) + int((b-a-1)//2))
  ans = int(min(ans4,ans5))
  
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math
N,A,B = map(int,input().split())
if B==A:
    print(0)
if B-A+1 == 0:
    if N==B or A==1:
        print(1)
    if B-1 >= N-A:
        print(N-A)
    else:
        print(B-1)

if abs(B-A+1)%2 ==1 :
    print(math.ceil(abs(B-A)/2))

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





    """if B-1 > N - A:
        print(N-A)
    elif N-A > B-1:
        print(B-1)"""

Submission status: Wrong Answer

Solution code:

# 入力 =stdin.readline().rstrip()
# 分割 = stdin.readline().rstrip().split()

'''
条件に合うものを絞り込む
data = [1, 2, 3]
s = [x for x in data if x % 3 == 0]
'''

'''
文字配列を数値に
l_si = ['-10', '0', '100']

l_si_i = [int(s) for s in l_si]
'''

'''
a = [2, 4, 6, 8]
b = [3, 6, 9]

print(list(set(a) | set(b)))  # 和集合
print(list(set(a) & set(b)))  # 積集合
'''

'''
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
count = 0
while len([x for x in A if x % 2 == 0]) == N:
    A = list(map(lambda y: y / 2, A))
    count += 1
print(count)
'''

'''
.append(要素)
.extend(要素)
.insert(場所,要素)
del 配列名[場所]
-1で末尾で末尾から一つ前
'''
'''
間に空白追加
' '.join(lis)
'''
'''
copy.copy(配列名)6

'''
'''
sort()50
sorted(reverse=true)
'''
'''
2分探索
bisect.bisect_left(リスト, 要素)
'''


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 num % 2 == 0:
    print(num / 2)
elif num % 2 == 1:

    res1 = a - 1
    b1 = b - (a - 1)
    a1 = 1
    num1 = b1 - a1
    if num1 % 2 != 0:
        res1 += 1
        b1 -= 1

    res1 += (b1 - a1)/2

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

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


elif mod != 0 :
  
  if n - a < b - 1 :
    if diff == 1:
      	print(n-a)
    else :
    	print( min( n - a , b - a - 1 ) )   
  else : 
    if diff == 1 :
        print(b-1)
    else:
    	print( min( b - 1 , n-a-n-b) )

Submission status: Wrong Answer

Solution code:
i = list(map(int, input().split()))
a=[]
if abs(i[2]-i[1])%2 == 0:
    ans=(i[2]-i[1])//2
else:
    a.append(i[1])
    a.append(i[2])
    x=min(a)
    y=max(a)
    if x-1<i[0]-y:
        ans=x-1
    else:
        ans=i[0]-x
print(ans)

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

Submission status: Wrong Answer

Solution code:
import math as m

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

dif = abs(B-A)
half = N/2
a2half = half - A
b2half = B - half - 1
if a2half == b2half:
  print(m.ceil(a2half))
else:
  n = N-B
  if A>= n:
    print(m.floor(n/2) +A-n+dif)
  else:
    print(m.floor(n/2)+dif)

Submission status: Wrong Answer

Solution code:

# 入力 =stdin.readline().rstrip()
# 分割 = stdin.readline().rstrip().split()

'''
条件に合うものを絞り込む
data = [1, 2, 3]
s = [x for x in data if x % 3 == 0]
'''

'''
文字配列を数値に
l_si = ['-10', '0', '100']

l_si_i = [int(s) for s in l_si]
'''

'''
a = [2, 4, 6, 8]
b = [3, 6, 9]

print(list(set(a) | set(b)))  # 和集合
print(list(set(a) & set(b)))  # 積集合
'''

'''
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
count = 0
while len([x for x in A if x % 2 == 0]) == N:
    A = list(map(lambda y: y / 2, A))
    count += 1
print(count)
'''

'''
.append(要素)
.extend(要素)
.insert(場所,要素)
del 配列名[場所]
-1で末尾で末尾から一つ前
'''
'''
間に空白追加
' '.join(lis)
'''
'''
copy.copy(配列名)6

'''
'''
sort()50
sorted(reverse=true)
'''
'''
2分探索
bisect.bisect_left(リスト, 要素)
'''


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 num % 2 == 0:
    print(num / 2)
elif num % 2 == 1:

    res1 = a - 1
    b1 = b - (a - 1)
    a1 = 1
    num1 = b1 - a1
    if num1 % 2 != 0:
        res1 += 1
        b1 -= 1
    print(b1)
    print(a1)
    print(b1-a1)
    res1 += (b1 - a1)/2

    res2 = n - b
    a2 = n-b+a
    b2 = n
    num2 = b2 - a2
    if num2 % 2 != 0:
        res2 += 1
        a2 += 1
    res2 += (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())

# print(N)
# print(A)
# print(B)

ans = 0

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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


def main():
    N, A, B = map(int, input().split())
    diff = B - A
    if diff % 2 == 0:
        print(int(diff / 2))
    else:
        if A + B - 1 > N:
            print(int(N - (A + B - 1) / 2))
        else:
            print(int((A + B - 1) / 2))


if __name__ == "__main__":
    main()

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 == 0:
            return (B - A + 1)/2
        elif right_s == 0:
            return (B - A + 1)/2
        elif left_s < right_s:
            tmp_s = (B - A + left_s)/2
            if tmp_s < 1:
                tmp_s = 1
            return left_s + int(tmp_s)
        else:
            tmp_s = (B - A + right_s)/2
            if tmp_s < 1:
                tmp_s = 1
            return right_s + int(tmp_s)
    
if __name__ == '__main__':
    print(int(main()))

Submission status: Wrong Answer

Solution code:
import math
n,a,b = map(int,input().split())
ans =0
if (a-b)%2 ==0:
    print(int(abs((a-b))/2))
else:
    if n-max(a,b)<min(a,b)-1 and n!=max(a,b) and 1!=min(a,b):
        ans+=n - max(a,b)
        ans+=int((n-(min(a,b)+n - max(a,b)))/2)
        print(ans)
    elif n-max(a,b)>min(a,b)-1 and n!=max(a,b) and 1!=min(a,b):
        ans+=min(a,b)-1
        ans+=math.ceil((max(a,b)-(min(a,b)-1))/2)
        print(ans)
    elif n == max(a,b) and 1!=min(a,b):
        ans+=1
        ans+=int((n-min(a,b)-1)/2)
        print(ans)
    elif n != max(a,b) and 1==min(a,b):
        ans+=1
        ans+=int((max(a,b)-1)/2)
        print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
a1 = float("inf")
a2 = float("inf")
a3 = float("inf")
if (B - A) % 2 == 0:
    a1 = int((B - A) / 2)

if (N - A) < (B - 1):
    a2 = N - A
    a3 = int((2 * (N + 1) - A - B) / 2)
else:
    a2 = B - 1
    a3 = int((A + B) / 2)

print(min(a1, a2, a3))

Submission status: Wrong Answer

Solution code:
n, a, b = map(int,input().split())
if (b - a) // 2 % 1 and b < n and a > 1:
    x = min( n - a, b -1 )
    print(int(x))
elif (b - a) // 2 % 1 and b == n and a > 1:
          print(int(n - a))
elif (b - a) // 2 % 1 and b < n and a == 1:
          print(int(b - 1))
elif (b - a) // 2 % 1 and b == n and a == 1:
          print(int(b - 1))
else:
    print(int((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:
    d = b - 1
    e = n - a
    c = min(d, e)
    print(c)

Submission status: Wrong Answer

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

if (B-A) % 2 == 0:
    ansA = int((B-A)/2)
else:
    ansA = 10**19

if N-B > A-1:
    ans1 = A-1
    ans2 = int(((B-1) - (A-1))//2)
    if (B - A) % 2 == 0:
        ansB = ans1 + ans2
    else:
        ansB = ans1 + 1 + ans2

elif N-B < A-1:
    ans1 = N-B
    ans2 = int(((N-A) - (N-B))//2)
    if (B - A) % 2 == 0:
        ansB = ans1 + ans2
    else:
        ansB = ans1 + 1 + ans2
else:
    ans1 = N - B
    ans2 = int(((N - A) - (N - B)) // 2)
    if (B-A) % 2 == 0:
        ansB = ans1 + ans2
    else:
        ansB = ans1 +1+ans2

ans = min(ansA,ansB)
print(ans)

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 = 1 + (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()]
c = b - a
if c % 2 == 0:
    print(c // 2)
    exit()

d = n - a
e = b - 1
f = (n - b) + 1 + ((n - (n - b) + 1 + a)) // 2
g = (a - 1) + 1 + (b - ((a - 1) + 1)) // 2
print(min([d, e, f, g]))