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:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,a,b = LI()

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

Submission status: Wrong Answer

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,a,b = LI()

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math
N,A,B = map(int,input().split())
if A%2 == B%2 :
    print(math.ceil(abs(B-A)/2))
 
else:
    k = min(A-1,N-B)
    m = (B-A-1)//2
    print(k+1+m)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if (A - B) % 2 == 0:
    print((A - B) // 2)
else:
    # the shortest of the distances to each farther edge.
    distance = 0
    if N - A > B - 1:
        distance = B - 1
    else:
        distance = N - A
    print(distance)

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:
# -*- coding: utf-8 -*-

[N, A, B] = [int(i) for i in input().split()]

A_even = A % 2
B_even = B % 2

if (A_even == 0 and B_even == 1) or (A_even == 1 and B_even == 0):
    # diffが奇数なら以下の3ステップで同じ卓に来る
    # 1. 1もしくはNの近いほうの端に寄る
    total = min(A-1, N-B) + 1 + (B-A-1)/2

    print(int(total))
else:
    # diffが偶数ならdiff/2回で同じ卓に来る
    print(int((B-A) / 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(a,b,n-a-1,n-b-1)+1+(abs(a-b)-1)//2)

Submission status: Wrong Answer

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

[N, A, B] = [int(i) for i in input().split()]

A_even = A % 2
B_even = B % 2

if (A_even == 0 and B_even == 1) or (A_even == 0 and B_even == 1):
    # diffが奇数なら以下の3ステップで同じ卓に来る
    # 1. 1もしくはNの近いほうの端に寄る
    total = min(A-1, N-B) + 1 + (B-A-1)/2

    print(int(total))
else:
    # diffが偶数ならdiff/2回で同じ卓に来る
    print(int((B-A) / 2))

Submission status: Wrong Answer

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

[N, A, B] = [int(i) for i in input().split()]

A_even = A % 2
B_even = B % 2

if (A_even == 0 and B_even == 0) or (A_even == 1 and B_even == 1):
    # diffが偶数ならdiff/2回で同じ卓に来る
    print(int((B-A) / 2))
else:
    # diffが奇数なら以下の3ステップで同じ卓に来る
    # 1. 1もしくはNの近いほうの端に寄る
    total = min(A-1, N-B) + 1 + (B-A-1)/2

    print(int(total))

Submission status: Wrong Answer

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

[N, A, B] = [int(i) for i in input().split()]

diff = abs(A - B)

A_even = A % 2
B_even = B % 2

if (A_even == 0 and B_even == 0) or (A_even == 1 and B_even == 1):
    # diffが偶数ならdiff/2回で同じ卓に来る
    print(int((B-A) / 2))
else:
    # diffが奇数なら以下の3ステップで同じ卓に来る
    # 1. 1もしくはNの近いほうの端に寄る
    total = min(A-1, N-B) + 1 + (B-A-1)/2

    print(int(total))

Submission status: Wrong Answer

Solution code:

def main():
    n, a, b = map(int, input().split())
    diff = b - a
    if diff%2 == 0:
        print(diff//2)
        return

    print(min(n-a, b-1))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import fractions

def main():
    n, a, b = map(int, input().split())
    diff = abs(a - b)
    if diff&1 == 0:
        print(diff//2)
    else:
        if b>a:
            temp = b
            b = a
            a = temp
        print(min(n-b, a-1))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import fractions

def main():
    n, a, b = map(int, input().split())
    diff = abs(a - b)
    if diff&1 == 0:
        print(diff//2)
    else:
        if b>a:
            temp = b
            b = a
            a = temp
            print(min(n-b, a-1))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import fractions

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
a=A
b=B
if (B-A)%2==0:
    ans=int((B-A)/2)
    print("{:20d}".format(ans))
else:
    ans=B-1
    ans=min(ans,N-A)
    ans2=A-1
    A=1
    B=B-(a-1)
    ans2+=1
    B-=1
    ans2+=int((B-A)/2)
    ans=min(ans,ans2)
    A=a
    B=b
    ans2=N-B
    B=N
    A=A+(N-b)
    ans2+=1
    A+=1
    ans2+=int((B-A)/2)
    ans=min(ans,ans2)
    print(int(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,b = (int(i) for i in input().split())
if (b-a)%2 == 0:
  print((b-a)//2)
else:
  print(min(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))
else:
    if  B - 1 <= N - A:
    # 1を目指す
        T1 = A # Aが1になるまでの回数 + 待ち時間（１）
        T2 = int ( (B - A - 1) / 2)
        print (T1 + T2)
    else:
    # Nを目指す
        T1 = N - B + 1
        T2 = int ( (B - A - 1) / 2)
        print  (T1 + T2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


    else:
        sa=A-1
        print((A-1)+(B-(A-1))//2)

Submission status: Wrong Answer

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

if A == B:
    print (0)
elif (A - B) % 2 == 0:
    print (int((B - A) / 2))
else:
    if  B - 1 < N - A:
    # 1を目指す
        T1 = A # Aが1になるまでの回数 + 待ち時間（１）
        T2 = int(((B - T1) - 1) / 2)
        print (T1 + T2)
    else:
    # Nを目指す
        T1 = N - B + 1
        T2 = int((N - (A + T1)) / 2)
        print  (T1 + T2)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
[N, A, B] = list(map(int, input().split()))
a = A % 2
b = B % 2
if (a == b):
  ans = int(np.abs(A - B) / 2)
else:
  path_to_1 = A - 1
  path_to_N = N - B
  if path_to_1 <= path_to_N:
    #Aが卓1に行くまでの回数 = path_to_1
    #Bの位置 = B - (path_to_1)
    #AとBが同じ位置に行くまでの回数
    path_A_to_B = math.ceil(np.abs(B - path_to_1 - 1) / 2)
    ans = int(path_to_1 + path_A_to_B)
  else:
    #Bが卓Nに行くまでの回数 = path_to_N
    #Bが卓Nに居る時のAの位置 = A + path_to_N
    #AとBが同じ位置に行くまでの回数
    path_B_to_A = math.ceil(np.abs(A + path_to_N - N) / 2)
    ans = int(path_to_N + path_B_to_A)
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,a,b = inpl()
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().rstrip().split()]
sa=0
if(abs(B-A)%2==0):
    if(A<=N and N<=B):
        sa=abs(A-N)
        print(sa+((B-sa)-N))
    else:
        print(abs(B-A)//2)
else:
    if(A<=N and N<=B):
        sa=abs(A-N)
        print(sa+((B-sa)-N))


    else:
        sa=A-1
        print((A-1)+(B-(A-1))//2)

Submission status: Wrong Answer

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

def main():
    if A == B:
        result(0)
    elif (A - B) % 2 == 0:
        result(abs((A - B) / 2))
    else:
        if  B <= N - A:
            result(B - 1)
        else:
            result(N - A)

def result(t):
    print(int(t))
    return 0

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N,A,B=[int(x) for x in input().rstrip().split()]
sa=0
if(abs(B-A)%2==0):
    if(A<=N and N<=B):
        sa=abs(A-N)
        print(sa+((B-sa)-N))
    else:
        print(abs(B-A)//2)
else:
    if(A<=N and N<=B):
        sa=abs(A-N)
        print(sa+((B-sa)-N))


    else:
        sa=A-1
        print((A-1)+(B-(A-2))//2)

Submission status: Wrong Answer

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

def main():
    if A == B:
        result(0)
    elif (A - B) % 2 == 0:
        result(abs((A - B) / 2))
    else:
        if N - A > B:
            result(B - 1)
        else:
            result(N - A)

def result(t):
    print(int(t))
    return 0

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

result = []

#２で割れる
if (a+b)%2 == 0:
    ans = b - (a+b)//2
    result.append(int(ans))

#左に寄せる
ans = b - 1
result.append(int(ans))

#右に寄せる
ans = n - a
result.append(int(ans))

#左に寄せて真ん中
ans = b - (b - a)//2
result.append(int(ans))

#右に寄せて真ん中
ans = n - b + 1 + n - (a + (2*n) - b + 1)//2
result.append(int(ans))

print(min(result))

Submission status: Wrong Answer

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

result = []

#２で割れる
if (a+b)%2 == 0:
    ans = b - (a+b)//2
    result.append(int(ans))


#左に寄せて真ん中
ans = b - (b - a)//2
result.append(int(ans))

#右に寄せて真ん中
ans = n - b + 1 + n - (a + (2*n) - b + 1)//2
result.append(int(ans))

print(min(result))

Submission status: Wrong Answer

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

result = []

#２で割れる
if (a+b)%2 == 0:
    ans = b - (a+b)//2
    result.append(int(ans))

#右に寄せる
ans = n - a
result.append(int(ans))

#左に寄せて真ん中
ans = b - (b - a)//2
result.append(int(ans))

#右に寄せて真ん中
ans = n - b + 1 + n - (a + (2*n) - b + 1)//2
result.append(int(ans))

print(min(result))

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

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

def main():
    if A == B:
        result(0)
    elif (A - B) % 2 == 0:
        result(abs((A - B) / 2))
    else:
        if N - A > B:
            result(B - 1)
        else:
            result(A)

def result(t):
    print(int(t))
    return 0

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

Solution code:
N,A,B=[int(x) for x in input().rstrip().split()]
sa=0
if(abs(B-A)%2==0):
    if(A<=N and N<=B):
        sa=abs(A-N)
        print(sa+((B-sa)-N))
    else:
        print(abs(B-A)//2)
else:
    if(A<=N and N<=B):
        sa=abs(A-N)
        print(sa+((B-sa)-N))

Submission status: Wrong Answer

Solution code:
N,A,B=[int(x) for x in input().rstrip().split()]
sa=0
if(abs(B-A)%2==0):
    if(A<=N and N<=B):
        sa=abs(A-N)
        print(sa+((B-sa)-N))
    else:
        print(abs(B-A)//2)
else:
    if(A<=N and N<=B):
        sa=abs(A-N)
        print(sa+((B-sa)-N))


    else:
        print(B-1)

Submission status: Wrong Answer

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

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

    onLeft = A 
    fromLeft = onLeft + (B - onLeft -1)/2
    
    print(int(min(fromRight, fromLeft)))
    #print([onRight, fromRight, onLeft, fromLeft])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math

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

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

Submission status: Wrong Answer

Solution code:
import math

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

diff = abs(A - B)
if diff % 2: #差が奇数の場合
    distance = min(A, N - B)
    ans = diff // 2 + distance # 片方を端まで寄せる
else:
    ans = diff // 2

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

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

Submission status: Wrong Answer

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

dim = B - A

if dim % 2 == 0:
  print(int(dim//2))
elif dim % 2 == 1:
  dimAN = N - A
  dimBN = N - B
  dimB1 = B - 1
  dimA1 = A - 1
  
  if dimAN > dimB1:#Aが1にいって折り返す
    print(dimA1+1 + int((dim-1)//2))
  elif dimAN < dimB1:#BがNにいって折り返す
    print(dimBN+1 + int((dim-1)//2))
  else:
    print(dimA1+1 + int((dim-1)/2))

Submission status: Wrong Answer

Solution code:
def A():
    temp = [int(n) for n in input().split()]
    N = temp[0]
    A = temp[1]
    B = temp[2]
    if abs(B-A)%2==0:
        print(abs(B-A)//2)
        return
    distance_to_one = min(A, B)
    distance_to_N = max(A, B)
    print(min(distance_to_one+abs(B-A-1)//2, 
                distance_to_N+abs(B-A-1)//2))

A()

Submission status: Wrong Answer

Solution code:
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b): #最小公倍数
    return a/gcd(a,b)*b

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def prime_fact(a): #素因数分解
    sqrt = math.sqrt(a)
    res = []
    i = 2
    if is_prime(a):
        res.append(a)
    else:
        while a!=1:
            while a%i==0:
                res.append(i)
                a //= i
            i += 1
    return res

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

if __name__=='__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

if (a + b) % 2 == 0:
  print((b - a) // 2)
else:
  cnt_a = b - 1
  cnt_b = n - a
  cnt_c = a + (b - a - 1) // 2
  cnt_d = n - b + 1 + (b - a + 1) // 2
  cnt = [cnt_a, cnt_b, cnt_c, cnt_d]
  cnt = filter(lambda x: x > 0, cnt)
  print(min(cnt))

Submission status: Wrong Answer

Solution code:
import math

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

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

Submission status: Wrong Answer

Solution code:
import math

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

num_play = (b - a) / 2

if num_play.is_integer():
  print(int(num_play))
else:
  result = min(a - 1, n - b) + 1 + (b - a - 1) // 2
  print(result)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

def solve(n, a, b):
    m = b-a
    if m%2:
        return min(
            max(a-1, b-1),
            max(n-a, n-b)
        )
    else:
        return m//2

print(solve(N, A, B))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

d=B-A

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

Submission status: Wrong Answer

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

d=B-A

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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