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:
ui = input()
uis = ui.split(" ")
N = int(uis[0])
A = int(uis[1])
B = int(uis[2])
if abs(A-B) % 2 == 0:
    print(abs(A-B) // 2)
else:
    if A > B:
        temp1 = A-1
        temp2 = N-B
    else:
        temp1 = B-1
        temp2 = N-A
    if temp1 > temp2:
        print (temp2)
    else:
        print (temp1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,a,b=LI()

  if abs(a-b)%2==0:
    return abs(a-b)//2

  # return min(n-abs(a-b)//2,max(a,b)-1)
  return min(n-a,b-1)

# main()
print(main())

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N,a,b=map(int,input().split())
if (b-a)%2==0:
    print((b-a)//2)
else:
    M=(a+b)//2
    if M-1<N-M+1:
        print(b-1)
    else:
        print(N-M+1-a)

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

    print(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)
  exit()
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:
    if n-a!=0 and b-1!=0:
        print(min(n-a,b-1))
    elif n-a==0:
        print(b-1)
    else:
        print(n-a)

Submission status: Wrong Answer

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

sa = abs(A-B)

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

    ans2 = n-b
    c = a + ans2
    ans2 += (n - c) // 2
    print(min(ans1, ans2))

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 = max(A - 1, B - 1)
    all_lose = max(N - A, N - B)
    print(int(min(all_win, all_lose)))

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

Submission status: Wrong Answer

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

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

else:
    p = min(max(a,b)-1,num-min(a,b))
    print(p)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
if abs(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:
def main():
    n,a,b = map(int,input().split())
    a,b = sorted([a,b])
    if (a-b)%2==1:
        x = min([b-1,n-a])
        print(x)
    else:
        print(abs(a-b)//2)
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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(n-x,y-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)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:


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

if((b-a)%2==0):
	print((b-a)//2)
else:
	ans=10**20

	ans=min(ans,max(abs(a-1),abs(b-1)))
	ans=min(ans,max(abs(a-n),abs(b-n)))

	print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

f = abs(a-b)
if f&1:
	print(min(max(a,b)-1, n - min(a,b)))
else:
	print(f//2)

Submission status: Wrong Answer

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

if (B - A) % 2 == 0:
    print ((B - A) // 2)
    exit()

tmp1 = A
b = B - A
tmp1 += (B - 1) // 2

tmp2 = N - B
a = A + tmp2
tmp2 += (N - a) // 2

print (min(tmp1, tmp2))

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

Submission status: Wrong Answer

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

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:
            ans += B - 1
        else:
            ans += N - A
    print(ans)
 
if __name__ == '__main__':
    main()

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:
    max_x = 0
    if max_x < a - 1 :
        max_x = a - 1
    if max_x < b - 1:
         max_x = b - 1
    min_x = max_x
    if max_x < n - a:
        max_x = n - a
    if max_x < n - b:
        max_x = n - b
    if min_x > max_x:
        min_x > max_x
    print(min_x)

Submission status: Wrong Answer

Solution code:
i = input().split()
n = int(i[0])
a = int(i[1])
b = int(i[2])

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
diff = b - a - 1
if diff & 1:
    print((diff + 1) // 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:
    if (N-B) > A:
        print(N-B)
    else:
        print(A)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
# import numpy as np
# import scipy
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
 
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return [list(map(int, input().split())) for _ in range(n)]

def main():

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math

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

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

num_play = (b - a) / 2

if num_play.is_integer():
  print(int(num_play))
else:
  print(b - 1)

Submission status: Wrong Answer

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


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




if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N,A,B=map(int,input().split())

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

print(ans)

Submission status: Wrong Answer

Solution code:
def main():

    n,a,b=map(int,input().split())
    if abs(a-b) % 2 == 0:
        print(abs(a-b)//2)
        return
    left=0
    temp = max(a,b)
    left = temp - 1
    right = 0
    temp = min(a,b)
    right = n - temp
    ans = min(left,right)
    print(ans)
    return
if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
def test(N, A, B, E):
    assert solve(N, A, B) == E, "solve(%d, %d, %d) == %d" % (N, A, B, E)

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

test(5, 2, 4, 1)



N, A, B = map(int, input().split())
print(solve(N, A, B))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
bg = max(a,b)
sm = min(a,b)

if (bg - sm) % 2 == 0:
    ans = (bg - sm) //2
else:
    x = bg - 1
    y = n - sm
    ans = min(x,y)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if (B - A) % 2 == 0:
    ans = (B - A) // 2

else:
    a = A - 1
    b = N - B

    if a > b:
        ans = N - A

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

else:
    if min(a,b) < n-max(a,b):
        print(min(a,b))
    else:
        print(n-max(a,b))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

sa = abs(a-b)

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8


def solve(*args: str) -> str:
    n, a, b = map(int, args[0].split())

    ret = 0

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

    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

Submission status: Wrong Answer

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

average = (A + B) / 2.0
if average.is_integer():
    print(int(average) - A)
else:
    print(min([N - A, N - B]))

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

def solve(N, A, B):
    if A > B:
        tmp = B
        B = A
        A = tmp
    if (A + B) % 2 == 0:
        return (B - A) // 2
    left = max(A-1, B-1)
    right = max(N-A, N-B)
    return min(left, right)

if __name__ == '__main__':
    inputs = read()
    print("%d" % solve(*inputs))

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

Submission status: Wrong Answer

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

n1 = B - 1
nx = (B-A)/2
nn = N - A

if nx % 1 != 0 :
    print(int(min(n1, nn)))
else:
    print(int(min(n1, nx, nn)))

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from sys import stdin
N,A,B = [int(x) for x in stdin.readline().rstrip().split()]
if (B - A) % 2 == 0:
    print((B-A)//2)
else:
    print(min(N-A,B-1))

Submission status: Wrong Answer

Solution code:
import math
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,b)-1,max(N-a,N-b)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if (b - a)%2 == 0:
  ans1 = int((b - a)/2)
else:
  ans1 = 10**18
  
ans2 = b-1
ans3 = N-a

ans4 = a-1 + (b-a-1)/2
ans5 = N-b + (b-a-1)/2

ans = int(min(ans1,ans2,ans3,ans4,ans5))
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(abs(B-A-1)//2+A,abs(A+N-B+1)//2+(N-B+1)))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 1.0e+100

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A, B):
    if A > B:
        A, B = B, A

    if (B - A) % 2 == 0:
        C = (B - A) // 2
    else:
        C = INF

    return min(B-1, N-A, C)


def main():
    N, A, B = read_int_n()
    print(slv(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(abs((b-a)//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:
    print(min(max(n-a, n-b), max(a-1, b-1)))

Submission status: Wrong Answer

Solution code:
s=raw_input().split()
[N, A, B] = s
N = int(N)
A = int(A)
B = int(B)

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N, A, B = map(int, input().split())
x = max(abs(1 - A), abs(1 - B))
y = max(abs(N - A), abs(N - B))
t = -(-(A + B) // 2)
z = max(abs(A - t), abs(B - t))
print(min(x, y, z))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def main():
    n,a,b = map(int,input().split())
    a,b = sorted([a,b])
    if (a-b)%2==1:
        x = min([b-1,n-a])
        print(x)
    else:
        print((a-b)//2)
    
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:
  x=min(abs(n-a),abs(b-1))
  print(x)

Submission status: Wrong Answer

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

ab = b-a
if ab > 1:
  print(ab//2)
else:
  if b-1 > n-a:
    print(n-a)
  else:
    print(b-1)

Submission status: Wrong Answer

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

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

else:
    upper = max(abs(a-1), abs(b-1))
    lower = max(abs(n-a), abs(n-b))

    print(min(upper, lower))

Submission status: Wrong Answer

Solution code:
import math

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

d = abs(a - b)
print(math.ceil(d/2))

Submission status: Wrong Answer

Solution code:
import sys


def solve(N: int, A: int, B: int):
    if (B-A)%2 == 0:
        print((B-A)//2)
    else: #端でしか会えない
        print(min(B-1,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:
# coding: utf-8
N,A,B=map(int,input().split())

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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




print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    NAB = [int(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 = int(ans)
    else:
        if A - 1 <= N - B:
            ans += 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())
if (b-a)%2==0:
    print((b-a)//2)
else:
    print(max(a,n-b))

Submission status: Wrong Answer

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

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


main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math
n ,a, b= map(int, input().split())
dis = max(a,b) - min(a,b)
if dis % 2 == 0:
    print(math.ceil(dis / 2))
else:
    left = min(a,b)
    right = max(a,b)
    if left - 1 > n - right:
        print(n - left)
    else:
        print(right - 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())
c=abs(a-b)
if c%2==0:
  print(c//2)
else:
  print(min(n-a,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:
    to_top = max(a-1, b-1)
    to_end = max(n-a, n-b)
    print(min(to_end, to_top))

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:


N,a, b =list(map(int,input().split(" ")))
case1 = 10 ** 20 # 卓1で戦う場合
case2 = 10 ** 20 # 卓Nで戦う場合
case3 = 10 ** 20 # 卓中間地点で戦う場合
if (b - a ) % 2 == 0:
    case3 = (b-a)//2
case1 = max(a-1 ,b-1)
case2 = max(N - a , N -b)

print(min([case1,case2,case3]))

Submission status: Wrong Answer

Solution code:
N,A,B = map(int,input().split())
if (A-B)%2==0:
  print((B-A)//2)
  exit()
else:
  p = A - 1
  q = N - B
  if p < q:
    print(B-1)
  elif p >= q:
    print(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:
    a1=A-1
    aN=N-A
    b1=B-1
    bN=N-B
    print(min(max(a1,b1),max(aN,bN)))

Submission status: Wrong Answer

Solution code:
from math import ceil
N,A,B = [int(i) for i in input().split()]

l = abs(A-B)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

else:
    da = abs(n - a)
    db = abs(n - b)

    print(int(min([max([a, b]) - 1, max([da, db]) - 1])))

Submission status: Wrong Answer

Solution code:
import math
N,a,b=(int(x) for x in input().split())
if abs(a-b)%2==0:
    print((a-b)//2)
else:
    print(min(max(a,b)-1,max(N-a,N-b)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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