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:
#A - Table Tennis Training
N,A,B = list(map(int, input().split()))

Lab = B-A
La = A-1
Lb = N-B

if Lab%2==0:
    #case Lab is even
    ans = Lab/2
else:
    #case Lab is odd
    ans = min(La,Lb) + 1 + (Lab-1)/2
    
ans = int(ans)
ans

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

elif (b - a) % 2 == 1 and b == n and a > 1:
          print(int((b - a - 1) / 2 + 1))
elif (b - a) % 2 == 1 and 2 <= b < n and a == 1:
          print(int((b - 1 ) / 2 + 1))
elif (b - a) % 2 == 1 and b == n and a == 1:
          print(int((n - 1 - 1) /2 + 1))
else:
     print(int((b - a) / 2))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

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

elif A==1 and B==N:
  print(B/2)

elif (A-1)<=(N-B):
  print(int(A-1+(B-A-1)/2))

else:
  print(int(N-B+(B-A-1)/2))

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

elif (b - a) % 2 == 1 and b == n and a > 1:
          print(int((b - a - 1) / 2 + 1))
elif (b - a) % 2 == 1 and 2 <= b < n and a == 1:
          print(int((b - 1 ) / 2 + 1))
elif (b - a) % 2 == 1 and b == n and a == 1:
          print(int((n -1) /2 + 1))
else:
     print(int((b - a) / 2))

Submission status: Wrong Answer

Solution code:
def main():
    tmp = input()
    [n, a, b] = [int(i) for i in (tmp.split())]
    dst = b - a
    top_a = a - 1
    b_lst = n - b
    long = top_a if top_a<b_lst else b_lst

    if dst % 2 == 0:
        short = int(dst / 2)
    else:
        short = int((dst - 1) / 2) + (long + 1)

    print(short)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    tmp = input()
    [n, a, b] = [int(i) for i in (tmp.split())]
    dst = b - a
    top_a = a - 1
    b_lst = n - b
    long = top_a if top_a<b_lst else b_lst

    if dst % 2 == 0:
        short = dst / 2
    else:
        short = (dst - 1) / 2 + (long + 1)

    print(int(short))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

ans = 10**20

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

print(ans)

Submission status: Wrong Answer

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

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

    upfold = a - 1
    downfold = n - b

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

elif (b - a) % 2 == 1 and b == n and a > 1:
          print(int((b - a + 1) / 2 + 1))
elif (b - a) % 2 == 1 and 2 <= b < n and a == 1:
          print(int((b - 1 ) / 2 + 1))
elif (b - a) % 2 == 1 and b == n and a == 1:
          print(int((n -1) /2 + 1))
else:
     print(int((b - a) / 2))

Submission status: Wrong Answer

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

print(answer)

Submission status: Wrong Answer

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

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

    upfold = a - 1
    downfold = n - b

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

Submission status: Wrong Answer

Solution code:
n,a,b=[int(i) for i in input().split()]
if abs(a-b)%2==0:
    print(min([max(a,b)-1,n-min(a,b),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())
cnt=0
c=100000000000000000
if (b-a)%2 == 0:
  cnt=round(b-(b+a)/2)
  print(cnt)
  exit()
if (b-a)%2 == 1:
    cnt=round(min(a-1,n-b)+1+((b-a-1)/2))
    print(cnt)
    exit()

Submission status: Wrong Answer

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

    upfold = a
    downfold = n - b + 1

    pat1 = int(upfold + (b - a - 1)/2)
    pat2 = int(downfold + (b - a - 1)/2)

    print(int(min([pat1, pat2])))

Submission status: Wrong Answer

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

Lab = B-A
La = A-1
Lb = N-B

if Lab%2==0:
    #case Lab is even
    ans = int(Lab/2)
else:
    #case Lab is odd
    ans = min(La,Lb) + 1 + int((Lab-1)/2)

print(ans)

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 (B-A)%2==0:
        p1=(B-A)/2
        #p2=min(B-1,N-A)
        #print(min(p1,p2))
        print(int(p1))
    else:
        #p1=(min(int(B-1),int(N-A)))
        """
        if B-1>N-A:
            bufA=N-B+1
            bufB=N-A+1
            A=bufA
            B=bufB
        """
#        if B-1<N-A:
        #if (B-(A-1+1)-1)%2==0:
            #ans=int(A+int((B-(A-1+1)-1)/2))
        #ans=int(min(A-1,N-B)+1+(B-A-1)/2)
        ans=min(A-1,N-B)+1+(B-A-1)/2
    
        print(int(ans))

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

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, A, B = (int(i) for i in input().split())

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

n,a,b = map(int, input().split())
l = min(a, b)
r = max(a, b)
k = r - l
if k % 2 == 1:
    count = min(l - 1, n - r) + 1 + ((k - 1) / 2)
    print(int(count))
else:
    print(int(k / 2))

Submission status: Wrong Answer

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

if (B - A) % 2 == 0:
    print((B - A) // 2)
elif 2*B < N:
    print(B-1)
elif 2*A > N:
    print(N - A)
else:
    if N-A <= B-1:
        m = N - B + 1 + ((B-A-1)//2)
    else:
        m = A - 1 + 1 +((B -A - 1)//2)

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 (B-A)%2==0:
        p1=(B-A)/2
        #p2=min(B-1,N-A)
        #print(min(p1,p2))
        print(p1)
    else:
        #p1=(min(int(B-1),int(N-A)))
        """
        if B-1>N-A:
            bufA=N-B+1
            bufB=N-A+1
            A=bufA
            B=bufB
        """
#        if B-1<N-A:
        #if (B-(A-1+1)-1)%2==0:
            #ans=int(A+int((B-(A-1+1)-1)/2))
        #ans=int(min(A-1,N-B)+1+(B-A-1)/2)
        ans=min(A-1,N-B)+1+(B-A-1)/2
    
        print(int(ans))

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

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

Submission status: Wrong Answer

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

if int((B-A)%2)==0:
    #case Lab is even
    ans = int(B-A/2)
else:
    #case Lab is odd
    ans = min(A-1,N-B) + 1 + int((B-A-1)/2)

print(ans)

Submission status: Wrong Answer

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

if (B-A) % 2 == 0:
    ans = int((B-A)/2)
else:
    # ansB1 = A-1
    # ansB2 = int((B - A-1) / 2)
    # ansB = A-1 +1+ ansB2

    ansC2 = int((B - A-1) // 2)
    ans = min(N-B,A-1) +1+ ansC2

print(int(ans))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
da = a - 1
db = n - b
dab = b - a
if dab%2==0:
  #偶数の場合
  print( int(dab / 2) )
else:
  #奇数の場合、どちらかが端までいき調整
  if da < db:
    #まずda回数分負け、追加で1回負、奇数が偶数になる
    print( int( (dab+1)/2 + da ))
  else:
    print( int( (dab+1)/2 + db ))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

x = b-a
if ((x % 2) == 0):
    print(math.floor(x/2))
    exit()
else:
    print(min(a-1, n-b) + 1 + (b-a-1)//2)
    exit()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque

inf=10**9+7

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

    if (int(B)-int(A))%2==0:
        p1=(int(B/2)-int(A/2))
        #p2=min(B-1,N-A)
        #print(min(p1,p2))
        print(p1)
    else:
        #p1=(min(int(B-1),int(N-A)))
        """
        if B-1>N-A:
            bufA=N-B+1
            bufB=N-A+1
            A=bufA
            B=bufB
        """
#        if B-1<N-A:
        #if (B-(A-1+1)-1)%2==0:
            #ans=int(A+int((B-(A-1+1)-1)/2))
        ans=int(min(A-1,N-B)+1+(B-(A-1+1)-1)/2)
    
        print(ans)

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

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:
a,s,d=map(int,input().split())
print(-((s-d)//2))

Submission status: Wrong Answer

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

if B % 2 == A % 2:
    ans = int((B-A)/2)
else:
    # ansB1 = A-1
    # ansB2 = int((B - A-1) / 2)
    # ansB = A-1 +1+ ansB2

    ansC2 = int((B - A-1) / 2)
    ans = min(N-B,A-1) +1+ ansC2

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

Submission status: Wrong Answer

Solution code:
a,s,d=map(int,input().split())
print(-(s-d)//2)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque

inf=10**9+7

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

    if (int(B)-int(A))%2==0:
        p1=(int(B/2)-int(A/2))
        #p2=min(B-1,N-A)
        #print(min(p1,p2))
        print(p1)
    else:
        #p1=(min(int(B-1),int(N-A)))
        """
        if B-1>N-A:
            bufA=N-B+1
            bufB=N-A+1
            A=bufA
            B=bufB
        """
#        if B-1<N-A:
        #if (B-(A-1+1)-1)%2==0:
            #ans=int(A+int((B-(A-1+1)-1)/2))
        ans=min(A-1,N-B)+1+(B-(A-1+1)-1)/2
    
        print(ans)

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

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, A, B = map(int, input().split(' ')) 

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math as m
 
[N, A, B] = [int(x) for x in input().split()]
 
dif = B-A
print(m.floor(dif/2) if dif%2== 0 else min(A-1, N-B)+ 1 + m.floor((dif-1)/2))

Submission status: Wrong Answer

Solution code:
a,s,d=map(int,input().split())
print(-(-s-d)//2)

Submission status: Wrong Answer

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

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if B % 2 == A % 2:
    ans = int((B-A)/2)
else:
    ansB1 = A-1
    ansB2 = int((B - A-1) / 2)
    ansB = ansB1 +1+ ansB2

    ansC1 = N-B
    ansC2 = int((B - A-1) / 2)
    ansC = ansC1 +1+ ansC2
    ans = min(ansB,ansC)
print(int(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math as m
 
[N, A, B] = [int(x) for x in input().split()]
 
dif = B-A
print(m.floor(dif/2) if dif%2== 0 else min(A-1, N-B)+ (dif-1)//2 +1)

Submission status: Wrong Answer

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

n,a,b = map(int, input().split())
l = min(a, b)
r = max(a, b)
k = r - l
if k % 2 == 1:
    if n - r > l - 1:
        count = l - 1 + 1 + ((k - 1) / 2)
    else:
        count = n - r + 1 + ((k - 1) / 2)
    print(int(count))
else:
    print(int(k / 2))

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque

inf=10**9+7

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

    if (int(B)-int(A))%2==0:
        p1=(int(B/2)-int(A/2))
        #p2=min(B-1,N-A)
        #print(min(p1,p2))
        print(p1)
    else:
        #p1=(min(int(B-1),int(N-A)))
        if B-1>N-A:
            bufA=N-B+1
            bufB=N-A+1
            A=bufA
            B=bufB

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

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

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, A, B = map(int, input().split())
        
Y = int(B-A)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque

inf=10**9+7

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

    if (int(B)-int(A))%2==0:
        p1=(int(B/2)-int(A/2))
        #p2=min(B-1,N-A)
        #print(min(p1,p2))
        print(p1)
    else:
        #p1=(min(int(B-1),int(N-A)))
        if B-1>N-A:
            bufA=N-B+1
            bufB=N-A+1
            A=bufA
            B=bufB

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

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

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

print(answer)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math as m
 
[N, A, B] = [int(x) for x in input().split()]
 
dif = B-A
print(m.floor(dif/2) if dif%2== 0 else min(A-1, N-B)+dif//2 +1)

Submission status: Wrong Answer

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

print(answer)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

diff = B-A
if diff%2 == 0:
    print(int(diff/2))
elif((N-B) > (A-1)):
        path = A-1 + 1 + (B-1 - A)/2
        print(int(path))
else:
        path = N-B + 1 + (N-A - (N-B+1))/2
        print(int(path))

Submission status: Wrong Answer

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

if (B-A) % 2 == 0:
    ans = int((B-A)/2)
else:
    ansB1 = A-1
    ansB2 = int((B - A-1) / 2)
    ansB = ansB1 +1+ ansB2

    ansC1 = N-B
    ansC2 = int((B - A-1) / 2)
    ansC = ansC1 +1+ ansC2
    ans = min(ansB,ansC)
print(int(ans))

Submission status: Wrong Answer

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


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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3

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 = (int(i) for i in input().split())

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

Submission status: Wrong Answer

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

med = N / 2 + 0.5
Sub = B - A

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Lab = B-A
La = A-1
Lb = N-B

if Lab%2==0:
    #case Lab is even
    ans = int(Lab/2)
else:
    #case Lab is odd
    ans1 = La + 1 + int((Lab-1)/2)
    ans2 = Lb + 1 + int((Lab-1)/2)
    ans = min(La,Lb) + 1 + int((Lab-1)/2)

print(ans)

Submission status: Wrong Answer

Solution code:
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if (B-A) % 2 == 0:
    ans = int((B-A)/2)
else:
    ansB1 = A-1
    ansB2 = int(((B - A-1) / 2))
    ansB = ansB1 +1+ ansB2

    ansC1 = N-B
    ansC2 = int(((B - A-1)) // 2)
    ansC = ansC1 +1+ ansC2
    ans = min(ansB,ansC)
print(int(ans))