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

disA = max(a,b) -1
disB = n - min(a,b)
if abs(a-b) % 2 == 0:
  disC = abs(a-b) // 2
else:
  disC = n

print(min(disA, disB, disC))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input().split()
k = int(s[0])
a = int(s[1])
b = int(s[2])
n = int(max(a,b))
m = int(min(a,b))
res = n-m
if res % 2 == 0:
  print(int(n/2-m/2))
elif k-n > m-1:
  print(k-n)
elif m-1 > k-n:
  print(k-m)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
n, a, b = map(int, input().split())
diff = abs(a - b)
if diff % 2 == 0:
    print(diff // 2)
else:
    cnt_win = n - max(a, b)
    win = math.ceil((n - (min(a, b) + cnt_win)) / 2)
    cnt_lose = min(a, b) - 1
    lose = math.ceil((max(a, b) - 1 - cnt_lose) / 2)
    win += cnt_win
    lose += cnt_lose
    print(min(win, lose))

Submission status: Wrong Answer

Solution code:
def main():
    tmp = input()
    tmp = [int(i) for i in (tmp.split())]
    n = tmp[0]
    a = tmp[1]
    b = tmp[2]
    
    if abs(a - b)%2 == 0:
        dst = (abs(a - b))
    else:
        dst = 2 * n
    fst = a if a<b else b
    lst = a if a>b else b
    dst_fst = n - lst
    dst_lst = fst - 1

    print(min([dst, dst_fst, dst_lst]))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

print(c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if (a - b) % 2 == 0:
    if a - b > 0:
        print((a-b)//2)
    else :
        print((b-a)//2)
else:
    min_x = 0
    top_a = a - 1
    top_b = b - 1
    if top_a < top_b:
        min_x = (top_b - (top_a - 1) )//2
    else:
        min_x = (top_a - (top_b - 1) )//2
    
    bot_a = n - a
    bot_b = n - b
    if bot_a < bot_b:
        min_x1 = (bot_b - (bot_a - 1) )//2
    else:
        min_x1 = (bot_a - (bot_b - 1) )//2
    if min_x > min_x1:
        min_x = min_x1
    print(min_x)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
NUM=input()
N,A,B=int(NUM.split(" ")[0]),int(NUM.split(" ")[1]),int(NUM.split(" ")[2])
count=0
ans=B-A

if(ans%2!=0):
  count+=1
  ans+=1
while ans>1:
  ans/=2
  count+=1
print(count)

Submission status: Wrong Answer

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

N, A, B=map(int, input().split())
C=0
if (B-A)%2==0:
    C=(B-A)/2
else:
    if A-1 > N-B:
        C=N-A
    elif A-1 < N-B:
        C=B-1
    else:
        C=B-1

print(C)

Submission status: Wrong Answer

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

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:
    first_move = (b - a) // 2
    p = (a + b) // 2
    second_move = min(p, n - p)
    ans = first_move + second_move
ans = min(ans, b - 1, n - a)
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-A,B-1))

Submission status: Wrong Answer

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

if abs(A-B)%2 ==0 :
    print(math.ceil(abs(A-B)/2))
elif abs(A-B)%2==1:
    if B-1 >= N-A:
        print(N-A)
    else:
        print(B-1)


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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
from sys import stdin


def fetch_one_line():
    return stdin.readline().rstrip()


def fetch_int_input():
    return [int(s) for s in fetch_one_line().split()]


def fetch_inputs(times):
    return [fetch_one_line() for _ in range(times)]


def fetch_int_inputs(times):
    return [[int(s) for s in fetch_one_line()] for _ in range(times)]


def fetch_ints_inputs(times):
    return [fetch_int_input() for _ in range(times)]


N, A, B = fetch_int_input()

dist = abs(A - B)
if dist % 2 == 0:
    print(int(dist / 2))
else:
    all_win_long = max(A - 1, B - 1)
    all_win_short = min(A - 1, B - 1)
    all_short_edge = all_win_short + 1
    all_win_dist = all_win_long - all_short_edge
    win_dist = int(abs(all_win_dist) / 2) + all_short_edge

    all_lose_long = max(N - A, N - B)
    all_lose_short = min(N - A, N - B)
    all_short_edge = all_lose_short + 1
    all_lose_dist = all_lose_long - all_short_edge
    lose_dist = int(abs(N - all_lose_dist) / 2) + all_short_edge


    print(int(min(all_win_long, all_lose_long, win_dist, lose_dist)))

Submission status: Wrong Answer

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


def solve(N: int, A: int, B: int):
    if (B-A)%2 == 0:
        between = (B-A)//2
        print(between)

    else: #端でしか会えない
        answer = 0
        if A-1<=N-B:
            answer += A
            A = 1
            B -= A
            answer += (B-A)//2
        else:
            answer += N-B+1
            A += N-B+1
            B = N
            answer += (B-A)//2

        print(answer)

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

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

Submission status: Wrong Answer

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

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

    print(n+int((B-A+1)/2))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
#n,m,v,p=map(int,input().split())
#l=list(map(int,input().split()))
n,a,b=map(int,input().split())
c=b-a
if c//2==c/2:
    print(min(c//2,n-a,b-1))
else:
    print(min(n-a,b-1,(b-a-1)//2+a,(b-a-1)+n-b+1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

S = (B - A)

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0

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

Submission status: Wrong Answer

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

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

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))
if dim % 2 == 1:
  dimAN = N - A
  dimBN = N - B
  dim1A = A - 1
  dim1B = B - 1
  
  dim_max = max(dimAN,dimBN,dim1A,dim1B)
  
  if dim_max == dimAN:
    print(dim1B)
  elif dim_max == dimBN:
    print(dim1A)
  elif dim_max == dim1A:
    print(dimBN)
  elif dim_max == dim1B:
    print(dimAN)

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

Submission status: Wrong Answer

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

for i in range(abs(A-B)):
    if (abs(A-B)==1):
        print(min(A,B)) 
        break
    elif abs(A-B)==2:
        print(abs(A-B)-1)
        break
    else:
        if A == min(A,B):
            A+=1
            B-=1
        else:
            B+=1
            A-=1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
a1 = float("inf")
a2 = float("inf")
if (B - A) % 2 == 0:
    a1 = int((B - A) / 2)

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

print(min(a1, a2))

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:
    a, b = b, a
  if n - b > a - 1:
    print((2 * a + b - 3) // 2)
  else:
    print((2 * n - b - a + 1) // 2)

Submission status: Wrong Answer

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

flag = 0
if (B - A) % 2 == 0:
    print(int((B-A)/2))
else:
    if A-1 < N-B:
        if A != 1:
            A -= 1
        B -= 1
        flag = 0
    else:
        if B != N:
            B += 1
        A += 1
        flag = 1
    count = 1
    while 1:
        if (B-A)%2 == 0:
            count += int((B-A)/2)
            break
        else:
            count += 1
            if flag == 0:
                if A != 1:
                    A -= 1
                B -= 1
            else:
                if B != N:
                    B += 1
                A += 1
    print(count)

Submission status: Wrong Answer

Solution code:
import numpy as np
def main():
    NAB = [np.int64(i) for i in input().split(" ")]
    N = NAB[0]
    A = NAB[1]
    B = NAB[2]
    ans = 0

    if abs(A - B) % 2 == 0:
        ans += abs(A - B) // 2
        ans = np.int64(ans)
    else:
        if A - 1 <= N - B:
            if (B - 1) >= (A - 1) + 1:
                ans += (((B - 1) - (A - 1)) // 2) + A
            else:
                ans += B - 1
        else:
            if (B - 1) >= (A - 1) + 1:
                ans += (((N - A) - (N - B)) // 2) + N - B - 1
            else:
                ans += N - A
    print(ans)
 
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


# N, A, B = 10 ** 18, 1, 10 ** 18
# N, A, B = 5, 2, 5


def main(n, a, b):
    # print(n, a, b)
    distance = b - a

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

print(main(N, A, B))

Submission status: Wrong Answer

Solution code:
def main():
    tmp = input()
    tmp = [int(i) for i in (tmp.split())]
    n = tmp[0]
    a = tmp[1]
    b = tmp[2]
    
    if abs(a - b)%2 == 0:
        print(abs(a - b))
    else:
        fst = a if a<b else b
        lst = a if a>b else b
        dst_fst = fst - 1
        dst_lst = n - lst
        if dst_fst > dst_lst:
            print(dst_fst)
        else:
            print(dst_lst)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if (A + B) % 2 == 0:
    print(((A+B)>>1) - min(A,B))
    exit(0)

NA = N - A + 1
NB = N - B + 1

nn = min(max(A, B), max(NA, NB)) - 1
print(nn)

Submission status: Wrong Answer

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

if (b-a)%2==0:
    ans=(b-a)//2
else:
    ans=min(a-1,N-b)+math.ceil((b-a)/2)
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:
    l = max(n-a, n-b)
    r = max(a-1, b-1)
    print(min(l, r))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

t = float('inf')
if abs(A - B) % 2 == 0:
    t = min(abs(A - B) // 2, t)
t = min(B - 1, t)
t = min(N - A, t)
t = min((B - A - 1) // 2, t)
t = min((N - A + (N - B + 1)) // 2, t)
print(t)

Submission status: Wrong Answer

Solution code:
from decimal import Decimal
N, A, B = input().split()
n=Decimal(N)
a=Decimal(A)
b=Decimal(B)
if (b-a) % 2==0:
    print((b-a)//2)
else:
    print(b-1)

Submission status: Wrong Answer

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

S = (B - A)

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

Submission status: Wrong Answer

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

ans = 0

tmp = B - A
if tmp % 2 == 0:
    print(abs(tmp // 2))
    
else:
    if B - A == 1:
        print(math.ceil(tmp/2)+1)
    else:
        print(math.ceil(tmp / 2))

# 25 35 44

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

Submission status: Wrong Answer

Solution code:
n, a, b = [int(x) for x in input().split(' ')]

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

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
m = 1
l = b - a
x = min(n - b, a - m)

if l % 2 == 0:
    print(int(l / 2))
else:
    print(int(x + l - (l - 1) / 2))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
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 = list(map(int,input().split()))
diff = B - A
N2B = N - B
N2A = N - A
sumN = N2A + N2B
sumAB = A + B
if sumN < sumAB:
    print(N2A)
else:
    print(B - 1)

Submission status: Wrong Answer

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

#print(n, a, b)

if (b-a)%2 == 0:
    if b-a > b-1 or b-a > n-a:
        pass
    else:
        print(int((b-a)/2))
        exit(0)
if n-a >= b-1:
    r = n-a-1
    print(r)
else:
    r = b-1
    print(r)

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

Submission status: Wrong Answer

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

ans=0
if (nab[2]-nab[1])%2==0:
    ans=int((nab[2]-nab[1])/2)
else:
    if nab[1]-1<nab[0]-nab[2]:
        ans=nab[2]-1
    else:
        ans=nab[0]-nab[1]
print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
min_=min(a,b)
max_=max(a,b)
if a==b:
    print(0)

else:
    k=max_-min_-1
    if k%2!=0:#間の卓が奇数
        if k==1:
            print(k)
        else:
            print(k-1)
    else:
        ans=min(max_-1,n-min_)
        print(ans)

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:
# 2019/12/28

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

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
if abs(a - b) % 2:
    te = [a - 1, b - 1]
    te.sort()
    rem = te[1] - te[0] + 1
    cand1 = te[0] + rem // 2

    te = [n - a, n - b]
    te.sort()
    rem = te[1] - te[0] + 1
    cand2 = te[0] + rem // 2
    print(min(cand2, cand2))
else:
    print(abs(a-b)//2)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
#print('{}{}{}' .format(n, a, b))

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

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque

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

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


from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """5 2 4"""
        output = """1"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """5 2 3"""
        output = """2"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
import math

stdin = sys.stdin

na = lambda: list(map(int, ns().split()))
ns = lambda: stdin.readline()

N, a, b = na()

mod = int(abs(b-a) % 2)
if mod == 0:
    print(int(abs(a-b)/2))
elif mod == 1:
    if a+b <= (N-a)+(N-b):
        print(max(a-1, b-1))
    elif a+b > (N-a)+(N-b):
        print(max(N-a, N-b))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#coding:utf-8
n, a, b = map(int, input().split())
#a,bのテーブル距離
dist = b-a

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

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    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, (B-A-1)//2 + 1))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


if A < B:
    kari = B-A
    sa1 = B-1
    sa2 = N-A
    sa3 = min(sa1,sa2)
else:
    kari = A -B
    sa1 = A-1
    sa2 = N-B
    sa3 = min(sa1,sa2)


    
out = kari // 2        
out2 = kari % 2     
#2の倍数の場合は差をとれば終了する。
if out2 == 0:
    ans = out
else:
    ans = sa3



print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, A, B = [int(i) for i in input().split()]
m = 10**19
if (B-A) % 2 == 0:
    print((B-A) // 2)
    quit()


l = A - 1
r = N - B

c = min(l, r)

res = c+1
d = B-c-1
res += d // 2

print(res)

Submission status: Wrong Answer

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

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

print(int(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
import math
import bisect
import re

def solve(n, a, b):
    if abs(a - b) % 2 == 0:
        return abs(a - b) // 2
    val1 = max(a - 1, b - 1)
    val2 = max(n - a, n - b)
    return min(val1, val2)

def main():
    n, a, b = map(int, input().split())
    ans = solve(n, a, b)
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


# N, A, B = 10 ** 18, 1, 10 ** 18
# N, A, B = 5, 2, 4


def main(n, a, b):
    # print(n, a, b)
    distance = b - a

    if distance % 2 == 0:
        return distance // 2
    else:
        if a == 1:
            return b
        if b == n:
            return n - a
        else:
            if a + b / 2 <= n / 2:
                return b
            else:
                return a

print(main(N, A, B))

Submission status: Wrong Answer

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