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

Submission status: Wrong Answer

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

if abs(a-b) == 1 and ((a == 1 or a == n) or (b == 1 or b == n)):
    print((abs(a-b)+1)//2+2)
else:
    if abs(a-b) % 2 == 0:
        print(abs(a-b)//2)
    else:
        print((abs(a-b)+1)//2+1)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, A: int, B: int):
    from math import ceil
    if (B-A)%2 == 0:
        print(ceil((B-A)/2))
        exit()
    else:
        if A == 0:
            print((B+1)//2)
        elif B == N:
            print((N-A+1)//2)
        else:
            print(min(
                (B+2-1)//2,
                (N-A+2-1)//2,
            ))

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

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, A, B)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, A: int, B: int):
    from math import ceil
    if (B-A)%2 == 0:
        print(ceil((B-A)/2))
        exit()
    else:
        print(min(
            (B+2-1)//2,
            (N-A+2-1)//2,
        ))

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

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, A, B)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, A: int, B: int):
    from math import ceil
    if (B-A)%2 == 0:
        print(ceil((B-A)/2))
        exit()
    else:
        print(min(
            (B-(-A-1)-1)//2,
            (B-(-A)-1)//2,
            ((N+(N-B)+1)-A-1)//2,
            ((N+(N-B))-A-1)//2
        ))

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

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, A, B)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, A: int, B: int):
    from math import ceil
    if (B-A)%2 == 0:
        print(ceil((B-A)/2))
        exit()
    else:
        print(min(
            B-(-A-1)-1//2,
            B-(-A)-1//2,
            ((N+(N-B)+1)-A-1)//2,
            ((N+(N-B))-A-1)//2
        ))

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

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, A, B)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, A: int, B: int):
    from math import ceil
    if (B-A)%2 == 0:
        print(ceil((B-A)/2))
        exit()
    else:
        x = B-A+1
        print(x//2+B-A)

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

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, A, B)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, A: int, B: int):
    from math import ceil
    if (B-A)%2 == 0:
        print(ceil((B-A)/2))
        exit()

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

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, A, B)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, A: int, B: int):
    from math import ceil
    if (B-A)%2 == 0:
        print(ceil((B-A)/2))
        exit()

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

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, A, B)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

    print(roundTime)



tableTennis()

Submission status: Wrong Answer

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

    print(int(roundTime))



tableTennis()

Submission status: Wrong Answer

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



tableTennis()

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

Submission status: Wrong Answer

Solution code:
# Author: cr4zjh0bp
# Created: Sat Feb 29 04:25:06 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

n, a, b = na()

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

Submission status: Wrong Answer

Solution code:
# Author: cr4zjh0bp
# Created: Sat Feb 29 04:25:06 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

n, a, b = na()

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

Submission status: Wrong Answer

Solution code:
x,y,z = map(int, input().split())
if (z+y)%2==1:
	print(min(max(y,z)-1, max(x-y,x-z)))
else:
	print((abs(y-z)+1)//2)

Submission status: Wrong Answer

Solution code:
x,y,z = map(int, input().split())
print(abs(y-z)//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(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:
	min([1+N-B+(B-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:
	min([N-B+(B-A)//2, A-1+(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-A, B-1]) )

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

x = a//2 + 1 if a%2 == 0 else (a+1)//2
y = b//2 + 1 if b%2 == 0 else (b+1)//2

if x == y:
    print(2)
else:
    d = y-x+1
    print(min(x-1, n-y)+d if d%2 == 0 and d != 2 else d//2)

Submission status: Wrong Answer

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

x = a//2 + 1 if a%2 == 0 else (a+1)//2
y = b//2 + 1 if b%2 == 0 else (b+1)//2

print(2 if x == y else (y-x+1)//2)

Submission status: Wrong Answer

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

x = a//2 + 1 if a%2 == 0 else (a+1)//2
y = b//2 + 1 if b%2 == 0 else (b+1)//2

print(2 if x == y else y-x)

Submission status: Wrong Answer

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

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

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

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

else:
    print(min(a,n-b))

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
d = abs(a-b)
r = d % 2
import math
res = math.ceil(d / 2) + r
print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

diff = B - A

if diff % 2 == 0:
    ans = diff / 2
else:
    # 左端で会う
    d1 = A - 1  # Aが左に到達するまでにd戦する
    ans1 = d1 + (diff + 1) // 2

    # 右端で会う
    d2 = N - B  # Bが右端まで到達するのにd戦必要
    ans2 = d2 + (diff + 1) // 2

    ans = min(ans1, ans2)

print(ans)

Submission status: Wrong Answer

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

diff = B - A

if diff % 2 == 0:
    ans = diff / 2
else:
    # d1 = A - 1
    # ans1 = d1 + (diff - 1) / 2 + 1

    # d2 = N - B
    # ans2 = d2 + (diff - 1) / 2 + 1

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

print(int(ans))

Submission status: Wrong Answer

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

diff = B - A

if diff % 2 == 0:
    ans = diff / 2
else:
    # 左端で会う
    d1 = A - 1  # Aが左に到達するまでにd戦する
    ans1 = d1 + (diff - 1) / 2 + 1

    # 右端で会う
    d2 = N - B  # Bが右端まで到達するのにd戦必要
    ans2 = d2 + (diff - 1) / 2 + 1

    ans = min(ans1, ans2, diff/2)
    # print(ans1, ans2)

print(int(ans))

Submission status: Wrong Answer

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

diff = B - A

if diff % 2 == 0:
    ans = diff / 2
else:
    # 左端で会う
    d1 = A - 1  # Aが左に到達するまでにd戦する
    ans1 = d1 + (diff - 1) / 2 + 1

    # 右端で会う
    d2 = N - B  # Bが右端まで到達するのにd戦必要
    ans2 = d2 + (diff - 1) / 2 + 1

    ans = min(ans1, ans2)
    # print(ans1, ans2)

print(ans)

Submission status: Wrong Answer

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

diff = B - A

if diff % 2 == 0:
    ans = diff / 2
else:
    # 左端で会う
    d1 = A - 1  # Aが左に到達するまでにd戦する
    ans1 = d1 + (diff - 1) / 2 + 1

    # 右端で会う
    d2 = N - B  # Bが右端まで到達するのにd戦必要
    ans2 = d2 + (diff - 1) / 2 + 1

    ans = min(ans1, ans2)
    # print(ans1, ans2)

print(round(ans))

Submission status: Wrong Answer

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

diff = B - A

if diff % 2 == 0:
    ans = diff / 2
else:
    # 左端で会う
    d1 = A - 1  # Aが左に到達するまでにd戦する
    ans1 = d1 + (diff - 1) / 2 + 1

    # 右端で会う
    d2 = N - B  # Bが右端まで到達するのにd戦必要
    ans2 = d2 + (diff - 1) / 2 + 1

    ans = min(ans1, ans2)
    # print(ans1, ans2)

print(int(ans))

Submission status: Wrong Answer

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

diff = B - A

# ans = (diff + 2 - 1) // 2

if diff % 2 == 0:
    ans = diff / 2
# else:  # 端で対面
#     a = N - A  # Aが右端に到達
#     b = B - 1  # Bが左端に到達
#     ans = max(a, b)
else: # 折り返し
    # 左端で会う
    d1 = A - 1  # Aが左に到達するまでにd戦する
    ans1 = d1 + (diff + 1) / 2

    # 右端で会う
    d2 = 2 * N - B  # Bが右端まで到達するのにd戦必要
    ans2 = d2 + (diff + 1) / 2

    ans = min(ans1, ans2)

print(int(ans))

Submission status: Wrong Answer

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

diff = B - A

# ans = (diff + 2 - 1) // 2

if diff % 2 == 0:
    ans = diff / 2
# else:  # 端で対面
#     a = N - A  # Aが右端に到達
#     b = B - 1  # Bが左端に到達
#     ans = max(a, b)
else: # 折り返し
    # 左端で会う
    d1 = A - 1  # Aが左に到達するまでにd戦する
    ans1 = d1 + (diff + 1) / 2

    # 右端で会う
    d2 = N - B  # Bが右端まで到達するのにd戦必要
    ans2 = d2 + (diff + 1) / 2
    ans = min(ans1, ans2)
    # print(ans1, ans2)

print(int(ans))

Submission status: Wrong Answer

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

diff = B - A

# ans = (diff + 2 - 1) // 2

if diff % 2 == 0:
    ans = int(diff/2)
else:
    a1 = max(A-1, B-1)
    a2 = max(N-A, N-B)
    ans = min(a1, a2)

print(ans)

Submission status: Wrong Answer

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

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

print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N=[int(e) for e in input().split()]

a=N[1]
b=N[2]

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

Submission status: Wrong Answer

Solution code:
N=[int(e) for e in input().split()]
if(N[1]>N[2]):
    a=N[1]
    b=N[2]
else:
    a=N[2]
    b=N[1]
if (a-b)%2==0 :
    print(int((a-b)/2))
else:
    print(min(a-1,N[0]-b))

Submission status: Wrong Answer

Solution code:
def min_match(a, b):
  if a > b or a < b:
    return 1
  return min(min_match(a - 1, b + 1), min(min_match(a + 1, b + 1), min(min_match(a - 1, b - 1),
             min_match(a + 1, b - 1))))

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
N, A, B = map(int, input().split())
now_A = A
now_B = B
diff = abs(now_A - now_B)
print(now_A, now_B)
if diff == 0:
    print(0)
    exit()
if diff % 2 == 0:
    print(diff//2)
    exit()
else:
    print(min(max(now_A - 1, now_B - 1), max(N - now_A, N - now_B)))
    exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N,A,B =[int(i) for i in input().split()]
k = (A+B)/2
if k.is_integer():
    print(int(abs(A-k)))
    exit()
else:
    la = A-1
    lb = B-1
    ra = N-A
    rb = N-B
    l = max(la,lb)
    r = max(ra,rb)
    print(min(l,r))
    exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if a-b & 1:
  mi = min(a - 1, n - b)
  print(mi + 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 a-b & 1:
  mi = min(a, b)
  ma = max(a, b)
  if mi - 0 < n - ma:
    # 負けるほうが早い
    print(n - mi)
  else:
    # 勝つほうが早い
    print(ma - 1)
else:
  print(int(abs(a - b) / 2))

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

dev = abs( b - ((a + b) // 2) )
adjust = min(min(a,b)-1,n-max(a,b)) + 1

if (a+b) % 2 == 0:
  print(dev)
else:
  print(adjust)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if a<b:
    a,b = b,a

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

Submission status: Wrong Answer

Solution code:
import numpy as np
N,A,B = map(int,input().split())
x=abs(A-B)
if x%2==0:
    print(x//2)
else:
    y,z=max(N-A,N-B),max(A-1,B-1)
    if y>z:
        print(z)
    else:
        print(y)

Submission status: Wrong Answer

Solution code:
import numpy as np
N,A,B = map(int,input().split())
x=abs(A-B)
if x%2==0:
    print(x//2)
else:
    print(x//2+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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)
  exit()
a = A-1
b = N-B
c = min(a,b)
print((A-c+B-c)//2+c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main(n: int, a: int, b: int):
    if abs(a - b) % 2 == 0:
        print(abs(a - b) // 2)
    else:
        print(abs(a - b) * 2)


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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(ans)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,A,B = list(map(int,input().split()))
a = A - 1
b = N - B
c = B - A
if c%2==0:
  res = c/2
elif a<b:
  res = B - 1
else:
  res = N - A
print(res)

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-a)/2 + 1)