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:
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

n, a, b = [int(item) for item in input().split()]
ans = 10**20

diff = abs(a - b)
if diff % 2 == 0:
    ans = diff // 2
    print(ans)
else:
    if a > b:
        a, b = b, a
    left = a
    left += (b - left) // 2
    right = 2 * n - b + 1
    right += (2 * n - right - a) // 2
    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:
    if a<n//2:
        cnt = 0
        while a>1:
            cnt+=1
            a-=1
            b-=1
        while b>1:
            cnt+=1
            b-=1
        print(cnt)
    else:
        cnt=0
        while a<n:
            cnt+=1
            a+=1
            b+=1
        while b<n:
            cnt+=1
            b+=1
        print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!python3

def resolve():
    N, A, B = map(int, input().rstrip().split())

    diff = B - A

    a = []
    if diff % 2 == 0:
        a.append(diff//2)

    a.append(B-1)
    a.append(N-A)

    print(min(*a))

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

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

if (B-A)%2==0:
    kaisu=int(math.log2(B-A))
    print(kaisu)
else:
    if (N-B)>=(A-1):
        #Bが左端にいく
        print(B-1)
    else:
        print(N-A)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if C == 1:
    kabe = int(min(N-B,A-1))
    print(kabe + 1)
elif C % 2 == 0:
    print(int(C / 2))
else:
    NB = N-B
    A1 = A-1
    if NB < A1:
        print(int(NB+1+(NB-1)/2))
    else:
        print(int(A1+1+(A1-1)/2))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n,a,b = map(int,input().split()) 

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

Submission status: Wrong Answer

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

if abs(a-b) % 2 == 0:
    print(abs(a-b)//2)
else:
    ans1 = math.ceil(abs(1 - (b - abs(1 - a))) / 2) + abs(1 - a)
    ans2 = math.ceil(abs(n - (a + abs(n - b))) / 2) + abs(n - b)
    print(min(ans1, ans2))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

d = n[1] - n[2]

if(d == 2)or(d == -2):
    ans = 1
else:
    ad = n[0] - n[1]
    bd = n[2] - 1
    #if(d == 1) or (d == -1):
    ans = max(ad,bd) -1

print(ans)

Submission status: Wrong Answer

Solution code:
import sys

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

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

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

main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if abs(a-b) % 2 == 0:
    print(abs(a-b)//2)
else:
    ans1 = math.ceil(abs(1 - (b - abs(1 - a))) / 2) + abs(1 - a)
    ans2 = math.ceil(abs(n - (a + abs(n - b))) / 2) + abs(n - b)
    print(ans1, ans2)
    print(min(ans1, ans2))

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque

def resolve():
    input = sys.stdin.readline
    N,A,B=map(int,input().rstrip().split())

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


from io import StringIO
import unittest

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,x,y = map(int,input().split(' '))
b = min(x,y);
a = max(x,y);
if((a-b)==0):
    print(0)
elif((a-b)==1):
    print(min(b,n-b))
elif((a-b)%2==0):
    print((a-b)//2)
else:
    print(min(a-1,n-b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

if C == 1:
    kabe = int(min(N-B,A-1))
    print(kabe + 1)
elif C % 2 == 0:
    print(int(C / 2))
else:
    NB = N-B
    A1 = A-1
    if NB < A1:
        print(NB+1+(NB-1)/2)
    else:
        print(A1+1+(A1-1)/2)

Submission status: Wrong Answer

Solution code:
inp = list(map(int,input().split()))

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


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

Submission status: Wrong Answer

Solution code:
mylist = [int(x) for x in input().split()]
N=mylist[0]
A=mylist[1]
B=mylist[2]

if abs(A-B)==1:
    print(min(A,B))
else:
    print(abs(A-B)//2)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
if A % 2 == B % 2: # 両方とも偶数/奇数の場合
    print(int(abs(A-B)/2))
else: # 両方が違う場合
    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 == 0):
    print(int((max(a,b) - min(a,b))/2))
else:
    print(min(n-max(a,b),min(a,b)-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:
    print(abs(a-b)//2 + 1)

Submission status: Wrong Answer

Solution code:
def even(d):
    return d // 2

def odd(A, B, N):
    return min(abs(0-B), abs(A-(N-1)))


def main():
    N, A, B = map(int, input().split())
    diff = abs(A-B)

    if diff % 2 == 0:
        print(even(diff))
    else:
        print(odd(min(A,B), max(A,B), N))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
aa=a
bb=b
sa=b-a
from math import ceil
if sa%2==0:
	print(sa//2)
else:
	ans1=a-1
	bb-=(a-1)
	ans1+=ceil((bb-1)/2)
	bb=b
	ans2=n-b
	aa+=n-b
	ans2+=ceil((n-aa)/2)
	print(min(ans1,ans2))

Submission status: Wrong Answer

Solution code:


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

if((b-a)%2==0):
	print((b-a)//2)
else:
	ans=10**20

	ta=a
	tb=b
	tp=0
	tp+=ta-1
	tb-=tp-1
	tp+=1
	ans=min(ans,(tb-ta)//2+tp)

	ta=a
	tb=b
	tp=n-tb
	ta+=tp+1
	tp+=1
	ans=min(ans,(tb-ta)//2+tp)

	print(ans)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

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 (a-b)%2==0:
    print(int((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())
    ans = 0
    diff = abs(a - b)
    if diff % 2 == 0:
        ans = diff // 2
    else:
        ab = [a, b]
        ab.sort()
        temp0 = n - ab[0]
        temp1 = ab[1] - 1
        ans = min(temp0, temp1)
    print(ans)


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

Submission status: Wrong Answer

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


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


diff_t=abs(A-B)
if diff_t%2==0:
    print(diff_t/2)
else:
    go_top=max(abs(1-A),abs(1-B))
    go_bottom=max(abs(N-A),abs(N-B))
    print(min(go_top,go_bottom))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
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)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
''' بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ '''
#codeforces
gi = lambda : list(map(int,input().split()))
n, a, b = gi()
if a > b:
	a, b = b, a
if (abs(a - b) % 2):
	x = a
	b -= a
	x += (b - 1) // 2
	y = n - b + 1
	a += y
	y += (n - a) // 2
	print(min(x, y))
else:
	print(abs(a - b) // 2)

Submission status: Wrong Answer

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

diff = b - a

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
li = list(map(int,input().split()))
a=max(li[1],li[2])
b=min(li[1],li[2])

if (a-b)%2==0:
    print(int((a-b)/2))
else:
    x=min(li[0]-a,b-1)
    y=int((a-b-1)/2)+1
    print(x+y)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np

val = input().split(' ')
N = int(val[0])
A = int(val[1])
B = int(val[2].strip())

if B - A % 2 == 0:
    print((B-A)/2)
else:
    max = np.power(10, 18)
    if A - 1 > max - B:
        diff = max - B
    else:
        diff = A - 1
    print(diff + 1 + (B - A) / 2)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (n, a, b) = [int(e) for e in lines[0].split(" ")]

    return (n, a, b)

def solve(n, a, b):
 

    d = b - a 
    if d % 2 == 0:
        c = d // 2
        result = min([b-1, n-a, c])
    else:
        result = min([b-1, n-a])

    return result

def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n, a, b = map(int, input().split())

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if A%2 == B%2:
    print((B-A)//2)
else:
    if N - B > A-1:
        c += N - B
        c += 1
        c += (B-A-1)//2
        print(c)
    else:
        c += A-1
        c += 1
        c += (B-A-1)//2
        print(c)

Submission status: Wrong Answer

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

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

print(c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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


main()

Submission status: Wrong Answer

Solution code:
import math

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

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

Submission status: Wrong Answer

Solution code:
import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush,heapify
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n,a,b = MAP()

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

o = []

L,R = sorted([A,B])

o.append(R-1)
o.append(N-L)
if A%2 == B%2:
    o.append(abs(A-B)//2)

if R%2 == 1:
    o.append(L-1+(R-1)//2)
    
if L%2 == N%2:
    o.append(N-R+(N-L)//2)

print(min(o))

Submission status: Wrong Answer

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

ans=0

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

else:
    if (A-1)>=(N-B):
        ans = ans + N-B+1
        ans = ans + (B-A-1)/2
    else:
        ans = ans + A-1+1
        ans = ans + (B-A-1)/2
print(int(ans))

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N, A, B = [int(x) for x in input().split()]
a = max(A, B) - 1
b = N - min(A, B)
c = 10 ** 19
if abs(A - B) % 2 == 0:
    c = abs(A - B) // 2
print(min(a, b, c))

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

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

if A < B:
    tmp = A
    A = B
    B = tmp

diff = A-B
if diff%2 == 0:
    print(diff)
else:
    if (N-A) > B:
        print(N-B-1)
    else:
        print(A-1)

Submission status: Wrong Answer

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

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

if __name__ == '__main__':
    inputs = read()
    print("%d" % solve(*inputs))

Submission status: Wrong Answer

Solution code:

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

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

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

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

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8

N, A, B = (int(n) for n in input().split())
offset = B - A
if offset % 2 == 0:
  print(offset // 2)
else:
  left = B - 1
  right= N - A
  if left < right:
    print(left)
  else:
    print(right)

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:
  x1 = N-max(A,B)
  ans1 = x1 + N-(min(A,B)+x1+1)

  x2 = N-min(A,B)-1
  ans2 = x2 + max(A,B)-x2-1
  print(min(ans1,ans2))

Submission status: Wrong Answer

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


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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math
from math import ceil
from math import factorial
from collections import Counter
from operator import itemgetter
import bisect
ii = lambda: int(input())
iia = lambda: list(map(int,input().split()))
isa = lambda: list(input().split())
def gcd(a,b):
	if(b==0):
		return a
	return gcd(b,a%b)

n,a,b = iia()
ans = 0
if(abs(a-b)%2==0):
	ans = 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 (abs(a - b) % 2) == 0:
    print(abs(a - b) // 2)
else:
    a, b = min(a, b), max(a, b)
    ans1 = a - 1
    ans1 += (b - (a - 1)) // 2
    ans2 = n - b
    ans2 += (n - (a + (n - b))) // 2
    print(min(ans1, ans2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n, a, b = map(int, input().split())

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

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

Submission status: Wrong Answer

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

v=b-(a+1)

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

Submission status: Wrong Answer

Solution code:
from sys import stdout
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n,a,b = inm()
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:

from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


# show_flg = False
show_flg = True


def main():
    N, A, B = MI()
    diff = abs(A - B)

    if diff % 2 == 0:
        print(diff // 2)
    else:
        minp = min(A, B)
        maxp = max(A, B)
        print(minp, maxp, N - maxp)
        if N - maxp < minp:
            print(N - min(A, B))
        else:
            print(max(A, B) - 1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# coding: utf-8


def solve(*args: str) -> str:
    n, a, b = map(int, args[0].split())

    ret = min(max(a-1, b-1), max(n-a, n-b))

    if not (b-a) % 2:
        ret = min(ret, (b-a)//2)

    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

Submission status: Wrong Answer

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

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:
    if n-a > b-1:
        print(b-1)
    else:
        print(n-a)

Submission status: Wrong Answer

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

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