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, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = True

n, a, b = MAP()
if (a - b) % 2 == 0:
    print(abs(a - b) // 2)
    exit()
if n - max(a, b) < min(a, b): #最下位で対戦
    print(n - min(a, b))
else:
    print(max(a, b) - 1)

Submission status: Wrong Answer

Solution code:
def solve(N, A, B):
    if A % 2 == B % 2:
        return (B - A) // 2
    return int(min(A-1, N-B) + 1 + (B - A -1)/2)

if __name__ == "__main__":
    n, a, b = map(int, input().split())
    print(int(solve(n, a, b)))

Submission status: Wrong Answer

Solution code:
def solve(N, A, B):
    return int(min(A - 1, N - B) + 1 + (B - A - 1)//2)

if __name__ == "__main__":
    n, a, b = map(int, input().split())
    print(int(solve(n, a, b)))

Submission status: Wrong Answer

Solution code:
def solve(N, A, B):
    if A % 2 == B % 2:
        return (B - A) / 2
    return min(A - 1, N - B) + 1 + (B - A - 1)//2

if __name__ == "__main__":
    n, a, b = map(int, input().split())
    print(int(solve(n, a, b)))

Submission status: Wrong Answer

Solution code:
def solve(N, A, B):
    if A % 2 == B % 2:
        return (B - A) / 2
    return min(A - 1, N - B) + 1 + (B - A - 1)//2

if __name__ == "__main__":
    n, a, b = map(int, input().split())
    print(solve(n, a, b))

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


resolve()

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(int((b-a)/2))
    exit()

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

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

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

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

if(a < ( n - b )):
    print(n-a)
else:
    print(b-1)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

if A % 2 == B % 2:
    print((B - A) // 2)
elif B - A == 1:
    print(min(B - 1, N - A))
else:
    a = ((B - (A - 1) - 1) - 1) // 2 + (A - 1)
    b = (N - (A + (N - B) + 1)) // 2 + (N - B)
    #print(a)
    #print(b)
    print(min(a, b))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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


if (A % 2 == 0 and B % 2 == 0) or (A % 2 != 0 and B % 2 != 0):
    print(int((B-A)/2))
    sys.exit()
else:
    tmp1 = (max((A-1,B-1)) + 1)
    tmp2 = (max((N-A,N-B)) - 1)
    print(min(tmp1, tmp2))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

#a,bの差が偶数でないと中間地点では合わない
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:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,a,b=map(int,input().split())
    if (b-a)%2==0:print((b-a)//2)
    else:print(min((b-a+1)//2,(2*n-b+1-a)//2))

if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,a,b=map(int,input().split())
    if (b-a)%2:print(min(b-1,n-a))
    else:print((b-a)//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(min(b, n-a, n-b+(n-a)//2,a+(b-a)//2))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

import sys
input = sys.stdin.readline

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

ans1=max(a,b)-1
ans2=n-min(a,b)
print(min(ans1,ans2))

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

# A, B の奇偶が一致するときは近づけば良い
if (A - B) % 2 == 0:
    print((B - A)//2)
else:
    print(min(N - A, B - 1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""


n,a,b = m()

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
if (A-B)%2:
    if A > B:
        A, B = B, A
    a = (B-A-1)//2+A if B > A+1 else 10**20
    b = (N-A+(N-B+1))//2+N-B+1 if N > A+(N-B+1) else 10**20
    print(min(max(A, B)-1, N-min(A,B), a, b))
else:
    print(abs(A-B)//2)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
if (A-B)%2:
    if A > B:
        A, B = B, A
    a = (B-A-2)//2+A if B > A+1 else 10**9
    b = (N-A+(N-B+1))//2+N-B+1 if N > A+(N-B+1) else 10**9
    print(min(max(A, B)-1, N-min(A,B), a, b))
else:
    print(abs(A-B)//2)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
if (A-B)%2:
    if A > B:
        A, B = B, A
    a = (B-A-1)//2+A if B > A+1 else 10**9
    b = (N-A+(N-B+1))//2+N-B+1 if N > A+(N-B+1) else 10**9
    print(min(max(A, B)-1, N-min(A,B), a, b))
else:
    print(abs(A-B)//2)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
if (A-B)%2:
    if A > B:
        A, B = B, A
    a = (B-A-1)//2+A if B > 2*A else 10**9
    b = (N-A+(N-B+1))//2+N-B+1 if B > A+(N-B+1) else 10**9
    print(min(max(A, B)-1, N-min(A,B), a, b))
else:
    print(abs(A-B)//2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, a, b = map(int, input().split())
c=a+b
minab = min(a-1, N-a, b-1, N-b)
# if difference odd, easier to meet at end
if c%2!=0 and minab == a-1:
	print(b-1)
elif c%2!=0 and minab == b-1:
	print(a-1)
elif c%2!=0 and minab == N-a:
	print(N-b)
elif c%2!=0 and minab == N-b:
	print(N-a)
# if difference even, meet half way
else:
	print(abs(a-b)/2)

Submission status: Wrong Answer

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

dis = abs(a-b)

if dis % 2 == 0:
  print(dis // 2)

else:
  high = n - min(a, b)
  low = max(a, b) - 1
  print(min(high, low))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
#041_A
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:
    ans=abs(A-(A+B)//2)
else:
    ans=min((B-1),(N-A))
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

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

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:
    x,y = min(a,b), max(a,b)
    ret1 = (x-1+y)//2
    ret2 = (2*n-x-y)//2
    print(min(ret1, ret2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if (B - A) % 2 == 0:
    # 間で合う
    c1 = (B - A) // 2
    # AもBも1まで行く
    c2 = max((A - 1), (B - 1))
    # AもBもNまで行く
    c3 = max((N - A), (N - B))
    c = min(c1, c2, c3)
else:
    # AもBも1まで行く
    c2 = max((A - 1), (B - 1))
    # AもBもNまで行く
    c3 = max((N - A), (N - B))
    c = min(c2, c3)
print(c)

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

Submission status: Wrong Answer

Solution code:
import sys

tokens = sys.stdin.readline().split(' ')

N = int(tokens[0])
A = int(tokens[1])
B = int(tokens[2])


# if the distance between the two is even they can meet in the middle
# else they have to go to one end

dist = B-A

if dist % 2 == 0:
    print(int(dist/2))
else:
    # search the closer end

    steps = 0
    while dist % 2 != 0:
        if A == B:
            print('this should not happen!')
        elif (A-1) < (N-B):
            A -= 1
            B -= 1
        else:
            A += 1
            B += 1

        A = max(A, 1)
        B = min(B, N)

        dist = B-A
        steps += 1

    print(int(dist/2) + steps)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

N = int(N)
A = int(A)
B = int(B)

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

Submission status: Wrong Answer

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

d = b - a
if d % 2 == 0:
    print(d//2)
else:
    do = min(a-1,n-b)
    if do == a-1:
        side = 'L'
    else:
        side = 'R'
    if b - do == 2 or a + do == 2:
        print(do+1)
    else:
        do += 1
        if side == 'L':
            print(do+(b-1)//2)
        if side == 'R':
            print(do+(n-a+do)//2)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np

in_string = input()
in_arr = in_string.split()
N = np.int64(in_arr[0])
A = np.int64(in_arr[1])
B = np.int64(in_arr[2])

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

Submission status: Wrong Answer

Solution code:
import numpy as np

in_string = input()
in_arr = in_string.split()
N = np.int64(in_arr[0])
A = np.int64(in_arr[1])
B = np.int64(in_arr[2])

if ((A-B) % np.int64(2)) == np.int64(0):
    print(np.int64((B-A)/np.int64(2)))
else:
    if (N-B) > A-np.int64(1):
        print(A + (B-A-1)/2)
    else:
        print(N-B+1+(N-(A+N-B+1)/2))

Submission status: Wrong Answer

Solution code:
import numpy as np

in_string = input()
in_arr = in_string.split()
N = np.int64(in_arr[0])
A = np.int64(in_arr[1])
B = np.int64(in_arr[2])

if ((A-B) % np.int64(2)) == np.int64(0):
    print(np.int64((B-A)/np.int64(2)))
else:
    if (N-B) > A-np.int64(1):
        print(np.int64((A+(B-A-np.int64(1))/np.int64(2))))
    else:
        print(np.int64((N-B+np.int64(1))+(N-(A+N-B+np.int64(1)))/np.int64(2)))

Submission status: Wrong Answer

Solution code:
import numpy as np

in_string = input()
in_arr = in_string.split()
N = np.int64(in_arr[0])
A = np.int64(in_arr[1])
B = np.int64(in_arr[2])

if ((A-B) % np.int64(2)) == 0:
    print(np.int64((B-A)/2))
else:
    if (N-B) > A-1:
        print(np.int64((A+(B-A-1)/2)))
    else:
        print(np.int64((N-B+1)+(N-(A+N-B+1))/2))

Submission status: Wrong Answer

Solution code:
import numpy as np

in_string = input()
in_arr = in_string.split()
N = np.int64(in_arr[0])
A = np.int64(in_arr[1])
B = np.int64(in_arr[2])

if ((A-B) % np.int64(2)) == 0:
    print(np.int64((B-A)/2))
else:
    if (N-B) > A-1:
        print(np.int64((A+(B-A-1)/2)))
    else:
        print(np.int64((N-A+1+(N-(N-A+1)))/2))

Submission status: Wrong Answer

Solution code:
import numpy as np

in_string = input()
in_arr = in_string.split()
N = np.int64(in_arr[0])
A = np.int64(in_arr[1])
B = np.int64(in_arr[2])

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

Submission status: Wrong Answer

Solution code:
import numpy as np

in_string = input()
in_arr = in_string.split()
N = np.int64(in_arr[0])
A = np.int64(in_arr[1])
B = np.int64(in_arr[2])

if ((A-B) % np.int64(2)) == 0:
    print(int((B-A)/2))
else:
    if (N-B) > A-1:
        print(int(B-1))
    else:
        print(int(N-A))

Submission status: Wrong Answer

Solution code:
# Function for calc
def match(n, a, b):
    if (b - a)% 2 == 0:
        print((b-a)/2)
    else:
        if (n - b) > a:
            print((a)+((b-(a+1))/2))
        else:
            x=(n-b+1)
            print(x+((n-(a+x))/2))
# Run match
in_string = raw_input()
#print(in_string)
[N, A, B] = [int(v) for v in in_string.split()]
#N = int(in_string[0])
#A = int(in_string[1])
#B = int(in_string[2])
#print(N)
#print(A)
#print(B)
match(N, A, B)

Submission status: Wrong Answer

Solution code:
# Function for calc
def match(n, a, b):
    if (b - a)% 2 == 0:
        print((b-a)/2)
    else:
        if (n - b) > a:
            print((a)+((b-(a+1))/2))
        else:
            x=(n-b+1)
            print(x+((n-(a+x))/2))
# Run match
in_string = raw_input("Enter the input:")
#print(in_string)
[N, A, B] = [int(v) for v in in_string.split()]
#N = int(in_string[0])
#A = int(in_string[1])
#B = int(in_string[2])
#print(N)
#print(A)
#print(B)
match(N, A, B)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N, A, B = map(int, input().split())

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
strargs = input()

n, a, b = map(lambda x: int(x), strargs.split())

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

else:
  newA = (a + (n - b + 1))
  print((n - newA)//2)

Submission status: Wrong Answer

Solution code:
def min_steps_v2(n, a, b):
    if (b - a) % 2 == 0:
        return int((b - a) / 2)
 
    # odd case
    a_diff = a - 1
    b_diff = n - b
 
    if a_diff > b_diff:
      steps_to_even = n - b + 1
      remain_steps = min_steps_v2(n, a + (n - b) + 1, n)
    else:
      steps_to_even = a
      remain_steps = min_steps_v2(n, 1, b - a)
 
    return steps_to_even + remain_steps

numbers = input().split(' ')
 
n = int(numbers[0])
a = int(numbers[1])
b = int(numbers[2])
 
print(min_steps_v2(n, a, b))

Submission status: Wrong Answer

Solution code:
def min_steps_v2(n, a, b):
    if (b - a) % 2 == 0:
        return int((b - a) / 2)
 
    # odd case
    a_diff = a - 1
    b_diff = n - b
 
    if a_diff > b_diff:
      steps_to_even = n - b + 1
      remain_steps = min_steps_v2(n, a + (n - b) + 1, n)
    else:
      steps_to_even = a
      remain_steps = min_steps_v2(n, 1, b - a)
 
    return steps_to_even + remain_steps

Submission status: Wrong Answer

Solution code:
import math

i = input()
N, A, B = i.split()

N = int(N)
A = int(A)
B = int(B)

if abs(A-B)%2 == 0:
  print(int(abs(A-B)/2))
else:
  e = int(min(A-1, N-B))
  d = int(math.ceil((B-A)/ 2))
  print(e + d)

Submission status: Wrong Answer

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

N = int(N)
A = int(A)
B = int(B)

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

Submission status: Wrong Answer

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

n = min(max(A, B)-1, N-min(A, B))
print(n)

Submission status: Wrong Answer

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

N = int(N)
A = int(A)
B = int(B)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

N = int(N)
A = int(A)
B = int(B)

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

Submission status: Wrong Answer

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

N = int(N)
A = int(A)
B = int(B)

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

Submission status: Wrong Answer

Solution code:
INP = list(map(int, input().split()))
print(int((INP[1]-INP[0]+1)/2))