Problem:


Score : 300 points

Problem Statement

2N players are running a competitive table tennis training on N tables numbered from 1 to N.

The training consists of rounds.
In each round, the players form N pairs, one pair per table.
In each pair, competitors play a match against each other.
As a result, one of them wins and the other one loses.

The winner of the match on table X plays on table X-1 in the next round,
except for the winner of the match on table 1 who stays at table 1.

Similarly, the loser of the match on table X plays on table X+1 in the next round,
except for the loser of the match on table N who stays at table N.

Two friends are playing their first round matches on distinct tables A and B.
Let's assume that the friends are strong enough to win or lose any match at will.
What is the smallest number of rounds after which the friends can get to play a match against each other?

Constraints

2 \leq N \leq 10^{18}

1 \leq A < B \leq N

All input values are integers.

Input

Input is given from Standard Input in the following format:

N A B

Output

Print the smallest number of rounds after which the friends can get to play a match against each other.

Sample Input 1

5 2 4

Sample Output 1

1

If the first friend loses their match and the second friend wins their match, they will both move to table 3 and play each other in the next round.

Sample Input 2

5 2 3

Sample Output 2

2

If both friends win two matches in a row, they will both move to table 1.



Sample input:
5 2 4


Sample output:
1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, a, b = [int(i) for i in input().split()]
a_distance = a-1
b_distance = n-b
ab_distance = b - a

if ab_distance % 2 == 0:
  result = ab_distance/2
else:
  if a_distance < b_distance:
    result = a_distance + (ab_distance-1)/2 + 1
  else:
    result = b_distance + (ab_distance-1)/2 + 1
result = int(result)
print(result)

Submission status: Wrong Answer

Solution code:
n, a, b = [int(i) for i in input().split()]
a_distance = a-1
b_distance = n-b
ab_distance = b - a

if ab_distance % 2 == 0:
  result = ab_distance/2
else:
  if a_distance < b_distance:
    result = a_distance + (ab_distance-1)/2 + 1
  else:
    result = b_distance + (ab_distance-1)/2 + 1
print(int(result))

Submission status: Wrong Answer

Solution code:
n, a, b = [int(i) for i in input().split()]
a_distance = a-1
b_distance = n-b
ab_distance = b - a

if ab_distance % 2 == 0:
  result = ab_distance/2
elif ab_distance % 2 == 1:
  if a_distance < b_distance:
    result = a_distance + (ab_distance-1)/2 + 1
  else:
    result = b_distance + (ab_distance-1)/2 + 1
print(int(result))

Submission status: Wrong Answer

Solution code:
n, a, b = [int(i) for i in input().split()]
a_distance = a-1
b_distance = n-b
ab_distance = b - a

if ab_distance % 2 == 0:
  result = ab_distance/2
  print("A")
elif ab_distance % 2 == 1:
  if a_distance < b_distance:
    result = a_distance + (ab_distance-1)/2 + 1
    print("B")
  else:
    result = b_distance + (ab_distance-1)/2 + 1
    print("C")
print(int(result))

Submission status: Wrong Answer

Solution code:
n, a, b = [int(i) for i in input().split()]
a_distance = a-1
b_distance = n-b
ab_distance = b - a

if ab_distance % 2 == 0:
  result = ab_distance/2
elif ab_distance % 2 == 1:
  if a_distance < b_distance:
    result = a_distance + (ab_distance+1)/2
  else:
    result = b_distance + (ab_distance+1)/2
print(int(result))

Submission status: Wrong Answer

Solution code:
n, a, b = [int(i) for i in input().split()]
a_distance = a-1
b_distance = n-b
ab_distance = b - a

if ab_distance % 2 == 0:
  result = ab_distance/2
elif ab_distance % 2 == 1:
  if a_distance < b_distance:
    result = a_distance + (ab_distance+1)/2
  elif b_distance <= a_distance:
    result = b_distance + (ab_distance+1)/2
print(int(result))

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math

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

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

Submission status: Wrong Answer

Solution code:
import math

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
import math

N,a,b=map(int,input().split())
d=b-a
d=math.floor(d)+1
print(d)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
d = A - B if A > B else B - A
d2 = d // 2
d3 = d % 2
if d3 == 0:
  ans = d2
else:
  bigger = B
  smaller = A
  if A > B:
    bigger = A
    smaller = B
  distance = N - smaller if N - smaller < bigger else bigger - 1
  ans = distance

print(ans)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
d = A - B if A > B else B - A
d2 = d // 2
d3 = d % 2
if d3 == 0:
  ans = d2
else:
  bigger = B
  smaller = A
  if A > B:
    bigger = A
    smaller = B
  distance = N - smaller if N - smaller < bigger else bigger
  ans = distance

print(ans)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
d = A - B if A > B else B - A
d2 = d // 2
d3 = d % 2
if d3 == 0:
  ans = d2
else:
  ans = A - 1 if A > B else B - 1

print(ans)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
d = A - B if A > B else B - A
d2 = d // 2
d3 = d % 2
if d3 == 0:
  ans = d2
else:
  ans = d2 + 2

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n ,a, b =  map(int, input().split())
dif = abs(a-b)
ans = 0
if dif == 1:
  ans = abs(1-max(a,b))
elif dif >=2:
  ans = dif//2
print(ans)

Submission status: Wrong Answer

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

ans = 0
if (B-(A-1))%2 != 0:
    ans = (B-(A-1))//2
else:
    a = N - A
    b = B - 1
    if a < b:
        ans = a
    else:
        ans = b

print(ans)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
ans = min(A - 1, N - B) + 1 + (B - A - 1)/2


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

print(ans)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
ans = min(A - 1, N - B) + 1 + (B - A - 1)/2


if abs(A-B) % 2 == 0 and abs(A-B)//2 < ans:
    ans = abs(A-B)//2

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''
#import copy
n, a, b = map(int, input().split())

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

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
if (B-A)%2==0:
  print ((B-A)//2)
else:
  import math
  print (math.ceil(min(A+B-2,2*N-A-B)/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(B-1,N-A))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

d = B - A

if (d % 2 == 0):
    ans = d // 2
else:
    left = B - 1
    right = N - A
    mini_1 = min(left, right)
    
    kado = min(A - 1, N - B)
    mini_2 = max(0, (d - kado - 1)) // 2 + kado + 1
    
    ans = min(mini_1, mini_2)

print(ans)

Submission status: Wrong Answer

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

d = B - A

if (d % 2 == 0):
    ans = d // 2
else:
    left = B - 1
    right = N - A
    ans = min(left, right)

print(ans)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
ans = min(max(A,B)-1, N - min(A,B))


if abs(A-B) % 2 == 0 and abs(A-B)//2 < ans:
    ans = abs(A-B)//2

print(ans)

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)-1, N - min(A,B)))

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

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 - 1, B - 1,), max(N - A, N - B)))

Submission status: Wrong Answer

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

if abs(A - B) % 2 == 1:
    print(abs(A - B))
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())
X = abs(A - B)

if X & 1 == 0:
	print(X >> 1)
else:
	max = max(max(N - A, A - 1), max(N - B, B - 1))
	print(max - 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:
    ans = 0
    if N-A < B-1:
        ans += N - B + 1
        A += ((N - B) + 1)
        if A == N:
            print(ans)
        else:
            print((N - A) // 2)
    else:
        ans += A - 1 + 1
        B -= (A - 1 + 1)
        if B == 1:
            print(ans)
        else:
            print((B - 1) // 2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

else:
    answer_1 = ((N - A) + (N - B) * 2 + 1) // 2
    answer_2 = ((A - 1) * 2 + (B - 1) + 1) // 2

    print(min(answer_1, answer_2))

Submission status: Wrong Answer

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

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

else:
    a = A - 1
    b = N - B
    if a > b:
        answer = ((N - A) + (N - B) * 2 + 1) // 2
    else:
        answer = ((A - 1) * 2 + (B - 1) + 1) // 2

    print(answer)

Submission status: Wrong Answer

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

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

else:
    a = A - 1
    b = N - B
    if a > b:
        print(N - A)
    else:
        print(B - 1)

Submission status: Wrong Answer

Solution code:
n, a, b = (int(x) for x in input().split())
if (b - a) % 2 == 0:
  ans = (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(int((B-A)/2))
elif (B-1)>=(N-A):
  print(N-A)
else:
  print(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))
elif B-1>=N-A:
  print(N-A)
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)
elif B-1>=N-A:
  print(N-A)
else:
  print(B-1)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
ans = [max(a-1, b-1), max(n-a, n-b)]
if abs(a-b) % 2 == 0:
    ans.append(abs(a-b)//2)
print(min(ans))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys


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


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, A, B)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from decimal import *
def resolve():

    tn,ta, tb = map(int, input().split())
    n=Decimal(tn)
    a=Decimal(ta)
    b=Decimal(tb)
    if (b-a)%2 == 1:
        ans=min(a-1,n-b)+1+(b-a-1)/2
    else:
        ans=(b-a)/2

    print(int(ans))

Submission status: Wrong Answer

Solution code:
from decimal import *
def resolve():

    n,a, b = map(int, input().split())
    if (b-a)%2 == 1:
        ans=Decimal(min(a-1,n-b)+1+(b-a-1)/2)
    else:
        ans=Decimal(((b-a)/2))

    print(int(ans))

resolve()

Submission status: Wrong Answer

Solution code:
from decimal import *
def resolve():

    n,a, b = map(int, input().split())
    if (b-a)%2 == 1:
        ans=Decimal(min(a-1,n-b)+1+(b-a-1)/2)
    else:
        ans=Decimal(((b-a)/2))

    print(ans)

resolve()

Submission status: Wrong Answer

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

    print(int(ans))
resolve3()

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:
    k=min(a,b)
    h=max(a,b)
    if n-k>h-1:
        print(h-1)
    else:
        print(n-k)

Submission status: Wrong Answer

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

    print(int(ans))


resolve()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python

n, a, b = (int(val) for val in input().split())

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

Submission status: Wrong Answer

Solution code:
def resolve():
    n,a, b = map(int, input().split())
    if (b-a)%2 == 1:
    # if (a%2 == 1 and b%2 == 0) or (a%2 == 0 and b%2 == 1):
        if a-1 <= n-b:
            # aが壁+1分移動する
            # その時の距離は-1縮まってる
            # 足して/2
            ans=(a-1+1) + (b-a-1)//2
        else:
            # bが壁+1分移動する
            # その時の距離は-1縮まってる
            # 足して/2
            ans=(n-b+1) + (b-a-1)//2
    else:
        ans=((b-a)/2)

    print(int(ans))

resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    n,a, b = map(int, input().split())
    # if (b-a)%2 == 1:
    if (a%2 == 1 and b%2 == 0) or (a%2 == 0 and b%2 == 1):
        if a-1 <= n-b:
            # aが壁+1分移動する
            # その時の距離は-1縮まってる
            # 足して/2
            ans=(a-1+1) + (b-a-1)/2
        else:
            # bが壁+1分移動する
            # その時の距離は-1縮まってる
            # 足して/2
            ans=(n-b+1) + (b-a-1)/2
    else:
        ans=((b-a)/2)

    print(int(ans))

resolve()

Submission status: Wrong Answer

Solution code:
import sys
import re

l = sys.stdin.readline()
l = l.split(' ')
l = [int(str) for str in l]

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

pre = 10**19
if(abs(a-b)%2==0):
	pre = int(abs(a -b)/2)
smax = ( a + b - 2 + 1) / 2
emax = ( n - a + n - b + 1) / 2
tmin = min( smax, emax)
v = int(tmin)
print(min(v,pre))

sys.stdout.flush()

Submission status: Wrong Answer

Solution code:
def resolve():
    n,a, b = map(int, input().split())
    if (b-a)%2 == 1:
        if a-1 <= n-b:
            # aが壁+1に行く
            # その時の距離は-1縮まってる
            # 足して/2
            ans=(a-1+1) + (b-a-1)/2
        else:
            # bが壁+1に行く
            # その時の距離は-1縮まってる
            # 足して/2
            ans=(n-b+1) + (b-a-1)/2
    else:
        ans=((b-a)/2)

    print(int(ans))

resolve()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3
import sys
import re

l = sys.stdin.readline()
l = l.split(' ')
l = [int(str) for str in l]

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

pre = 10**19
if(abs(a-b)%2==0):
	pre = int(abs(a -b)/2)
smax = max( a - 1, b - 1)
emax = max( n - a, n - b)
tmin = min( smax, emax)
v = int(tmin)
print(min(v,pre))

sys.stdout.flush()

Submission status: Wrong Answer

Solution code:
import sys
import re

l = sys.stdin.readline()
l = l.split(' ')
l = [int(str) for str in l]

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

pre = 9999999999
if(abs(a-b)%2==0):
	pre = int(abs(a -b)/2)
smax = max( a - 1, b - 1)
emax = max( n - a, n - b)
tmin = min( smax, emax)
v = int(tmin)
print(min(v,pre))

sys.stdout.flush()

Submission status: Wrong Answer

Solution code:
import sys
import re

l = sys.stdin.readline()
l = l.split(' ')
l = [int(str) for str in l]

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

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

sys.stdout.flush()

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
# 卓1で遭遇
hoge = max(a, b) - 1
# 卓nで遭遇
huga = n - min(a, b)
# a, b間で遭遇
if (max(a, b) - min(a, b)) % 2 == 0:
  piyo = min(a, b) + (max(a, b) - min(a, b)) // 2
  ans = abs(min(hoge, huga, piyo) - max(a, b))
else:
  ans = abs(min(hoge, huga))
print(ans)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
# 卓1で遭遇
hoge = max(a, b) - 1
# 卓nで遭遇
huga = n - min(a, b)
# a, b間で遭遇
if (max(a, b) - min(a, b)) % 2 == 0:
  piyo = min(a, b) + (max(a, b) - min(a, b)) // 2
  ans = abs(min(hoge, huga, piyo) - a)
else:
  ans = abs(min(hoge, huga))
print(ans)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
# 卓1で遭遇
hoge = max(a, b) - 1
# 卓nで遭遇
huga = n - min(a, b)
# a, b間で遭遇
if (max(a, b) - min(a, b)) % 2 == 0:
  piyo = min(a, b) + (max(a, b) - min(a, b)) // 2
  ans = abs(min(hoge, huga, piyo) - a)
else:
  ans = abs(min(hoge, huga))
print(ans)
print(hoge)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
# 卓1で遭遇
hoge = max(a, b) - 1
# 卓nで遭遇
huga = n - min(a, b)
# a, b間で遭遇
if (max(a, b) - min(a, b)) % 2 == 0:
  piyo = min(a, b) + (max(a, b) - min(a, b)) // 2
  ans = min(hoge, huga, piyo) - a
else:
  ans = min(hoge, huga) - a

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
# 卓1で遭遇
hoge = max(a, b) - 1
# 卓nで遭遇
huga = n - min(a, b)
# a, b間で遭遇
if (max(a, b) - min(a, b)) % 2 == 0:
  piyo = min(a, b) + (max(a, b) - min(a, b)) // 2
  ans = min(hoge, huga, piyo)
else:
  ans = min(hoge, huga)
print(ans)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
# 卓1で遭遇
hoge = min(a, b) - 1
# 卓2で遭遇
huga = n - max(a, b)
# a, b間で遭遇
if (max(a, b) - min(a, b)) % 2 == 0:
  piyo = min(a, b) + (max(a, b) - min(a, b)) // 2
  ans = min(hoge, huga, piyo)
else:
  ans = min(hoge, huga)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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:
import sys
input = sys.stdin.readline

def main():
    N, A, B = map(int, input().split())
    tmp = B - A
    if tmp&1:
        print(min(B - 1, N - A))
    else:
        print(tmp // 2)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

resolve()

Submission status: Wrong Answer

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

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

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

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

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
diff = abs(a-b)
print(diff//2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(int(ans))

Submission status: Wrong Answer

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

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

print(int(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

if (B-A)%2==0:
    ans = int((B-A)/2)
elif (B-A)%2==1:
    ans = min(B-1, N-A)

print(ans)

Submission status: Wrong Answer

Solution code:
from sys import maxsize

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

res = min(n-min(a,b), max(a,b)-1)
val = abs(a-b) // 2
if (a-b) % 2 == 0 and val < res:
    res = val

print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import ceil


def main():
    n, a, b = map(int, input().split())
    print(ceil((b - a) / 2) if a % 2 == b % 2 else min(max(a, b) - 1, n - min(a, b)))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

print(min(a + (b-a-1)//2, n - b + 1 + (n - (a + (n - b + 1)))//2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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