Problem:


Score : 300 points

Problem Statement

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

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

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

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

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

Constraints

2 \leq N \leq 10^{18}

1 \leq A < B \leq N

All input values are integers.

Input

Input is given from Standard Input in the following format:

N A B

Output

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

Sample Input 1

5 2 4

Sample Output 1

1

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

Sample Input 2

5 2 3

Sample Output 2

2

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



Sample input:
5 2 4


Sample output:
1

Submission status: Wrong Answer

Solution code:
from sys import stdin
import math
import re
import queue

input = stdin.readline

MOD = 1000000007

def solve():
    N,A,B = map(int, input().split())
    if(abs(A - B)%2 == 0):
        print(abs(A-B)//2)
        return
    
    
    print(min(max(A,B)-1,5 - min(A,B)))
    
if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

ans = min(ans, B - 1, N - A)
print(ans)

Submission status: Wrong Answer

Solution code:
def main():

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

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

Submission status: Wrong Answer

Solution code:
def main():

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

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

Submission status: Wrong Answer

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

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

ans = min(ans, A, N - B)
print(ans)

Submission status: Wrong Answer

Solution code:
def main():

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

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

Submission status: Wrong Answer

Solution code:
def main():

    N, A, B = map(int, input().split())
    if (B-A) % 2 == 0:
        return  (B-A) // 2
    else:
        return min([B-1, N-A])

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

Submission status: Wrong Answer

Solution code:
def main():
    N, A, B = list(map(int, input().split(' ')))
    assert 1 <= A < B <= N
    if (B - A) % 2 == 0:
        print((B - A) // 2)
    else:
        if B - 1 <= N - A:
            print(A + max([0, B - A - 1]) // 2)
        else:
            print(N - B + max([0, B - A - 1]) // 2)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N, A, B = list(map(int, input().split(' ')))
    if (B - A) % 2 == 0:
        print((B - A) // 2)
    else:
        A, B = min([A, B]), max([A, B])
        print(A + max([0, B - A - 1]) // 2)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# N = int(input())
N, A, B = [int(_) for _ in 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())
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 = list(map(int,input().split()))
if abs(A-B) % 2 == 0:
  print(abs(A-B)//2)
else:
  print(max(A-1,B-1))

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,a,b=map(int, input().split())
    if abs(a-b)%2==0:
        print(abs(a-b)//2)
    else:
        ue=max(a-1,b-1)
        sita=max(n-a,n-b)
        print(min(ue,sita))
resolve()

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

mid = b - a

if mid % 2 == 0:
    print(mid // 2)
else:
    print(min(a+mid//2, b+mid//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:
    a=max(A-1,B-1)
    b=max(N-A,N-B)
    print(min(a,b))

Submission status: Wrong Answer

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

left = B-1
right = N-A
mid = (B - A)//2

if (B - A)%2==0:
    print(min([left, right, mid]))
else:
    print(min(left, right))

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    '''
    if N - B >= A - 1:
        ans = B - 1
    else:
        ans = N - A
'''
print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,A,B = map(int, input().split(" "))
distance = abs(B - A)
res=0
if distance % 2 == 0:
  res = distance/2
else:
  a,b = min(A,B), max(A,B)
  ans = distance//2 + min(a-1, N-b)+1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
from io import StringIO
import unittest


def resolve():
    N, A, B = [int(i) for i in input().split()]
    if abs(A - B) % 2 == 0:
        print(int(abs(A - B) / 2))
    # A->1 or B->N
    elif A - 1 < N - B:
        # A->1
        if B - (A - 1) == 2:
            print(A - 1 + 1)
        elif (B - (A - 1) - 1) % 2 == 0:
            print(int(A - 1 + ((B - (A - 1) - 1) / 2)))
        else:
            print(int(A - 2 + ((B - (A - 2) - 1) / 2)))
    else:
        if A + (N - B) == N - 1:
            print(N - B + 1)
        elif (N - A + (N - B)) % 2 == 0:
            print(int(N - B + ((N - A + (N - B)) / 2)))
        else:
            print(int(N - B + 1 + ((N - A + (N - B + 1)) / 2)))
    return


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """5 2 4"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """5 2 3"""
        output = """2"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun May 10 17:22:34 2020

@author: shinba
"""
import sys 
n,a,b = map(int,input().split())

if (b-a) % 2 == 0:
    print((b-a)//2)
    sys.exit()
    
print(min(n-a,b-1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

# In[10]:


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


# In[15]:


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


# In[ ]:

Submission status: Wrong Answer

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

# In[10]:


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


# In[14]:


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


# In[ ]:

Submission status: Wrong Answer

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

# In[10]:


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


# In[11]:


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


# In[ ]:

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

main()

Submission status: Wrong Answer

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

main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
def resolve():
    N,A,B=pin()
    tt=abs(A-B)
    if tt%2==0:
        print(tt//2)
        return
    else:
        s= max(A,B)-1
        t=N-min(A,B)
        print(min(s,t,(tt-1)//2+1))
#%%submit!
resolve()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
def resolve():
    N,A,B=pin()
    tt=abs(A-B)
    if tt%2==0:
        print(tt//2)
        return
    else:
        s= max(A,B)-1
        t=N-min(A,B)
        print(min(s,t))
#%%submit!
resolve()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
def resolve():
    N,A,B=pin()
    tt=abs(A-B)
    if tt%2==0:
        print(tt//2)
        return
    else:
        s= max(A,B)-1
        t=max(N-A,N-B)
        print(min(s,t))
#%%submit!
resolve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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