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

diff = abs(A - B)

if diff % 2 == 0:
    x = diff/2
else:
    small = min(A, B)
    big = max(A, B)
    x1 = N - small
    x2 = big - 1
    x = min(x1, x2)

print(int(x))

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

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

if __name__ == '__main__':
  run()

Submission status: Wrong Answer

Solution code:
N, A, B = map(int,input().split())
d = abs(A-B)
if d % 2 == 0:
    print(d//2)
else:
    MIN_A = A-1
    MIN_B = B-1
    MIN = max(MIN_A,MIN_B)
    MAX_A = N-A
    MAX_B = N-B
    MAX = max(MAX_A,MAX_B)
    print(min(MIN,MAX))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

else:
    print(min(N - A, B - 1))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
''' بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ '''
#codeforces
gi = lambda : list(map(int,input().split()))
n, a, b = gi()
if a > b:
	a, b = b, a
if (abs(a - b) % 2):
	print(min(b - 1, n - a))
else:
	print(abs(a - b) // 2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N,a,b = map(int,input().split())
sub = b-a
if(sub%2==0):
    print(sub/2)
else:
    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:
  C=max([A-1,B-1])
  D=max([N-A,N-B])
  print(min([C,D]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N, A, B = [int(x) for x in input().split()]
a = max(A, B)
b = (N - 1) - min(A, B)
c = 10 * 19
if abs(a-b) % 2 == 0:
    c = abs(a-b) // 2
print(min(a, b, c))

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

Submission status: Wrong Answer

Solution code:
import sys

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))  # applies to numbers only
rs = lambda: stdin.readline().rstrip()  # ignores trailing space

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

print(answer)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

def ceil(x,y):
  return (x-1)//y+1
n,a,b=map(int,input().split())
if abs(b-a)%2==0:
    print(abs(b-a)//2)
else:
    if a>b: a,b=b,a
    print(max(b-1,n-a-1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush,heapify
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n,a,b = MAP()

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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
    c1 = max(a1,b1)
    c2 = max(aN,bN)
    print(min(c1,c2))

Submission status: Wrong Answer

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

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

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

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)

# main()
print(main())

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,A,B = map(int,input().split())
# N,A,B=10,7,8

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

Submission status: Wrong Answer

Solution code:
import sys, math
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict

sys.setrecursionlimit(10**7)
N, A, B = map(int, input().split())


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

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

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

n, a, b = map(int, readline().split())
ans = n + 1
if abs(a - b) % 2 == 0:
    ans = min(ans, abs(a - b) // 2)
ans = min(max(a, b) -1, ans)
ans = min(n - min(a, b), ans)



print(ans)

Submission status: Wrong Answer

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

if a==b:
    print(0)
    exit()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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(tmp // 2)
    
else:
    MIN = min(A, B)
    MAX = max(A, B)

    if MIN - 1 < 5 - MAX:
        print(MAX - 1)
    else:
        print(5 - MIN)

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:
    print(min(n-a,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 = 2**62-1

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 (abs(a - b) % 2) == 0:
    print(abs(a - b) // 2)
else:
    a = min(a, b)
    b = max(a, b)
    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:
    D = max(A - 1, B - 1)
    E = max(N - A, N - B)
    print(min(D,E))

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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)
    ans = min(left - 1, n - right)
    print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    N, A, B = [int(i) for i in input().split()]
    diff = B - A
    if diff % 2 == 0:
        ans = diff // 2
    else:
        ans = min(B - 1, N - A)
    print(ans)


if __name__ == '__main__':
    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)

else:
    print (min(max(A-1,B-1) , max(N-A,N-B)))

Submission status: Wrong Answer

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

a, b = min(a,b), max(a,b)

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n, a, b = list(map(int, input().split()))
print((abs(a - b) + 1) // 2)

Submission status: Wrong Answer

Solution code:
import math
n ,a,b = map(int, input().split())
if (abs(a-b) % 2) == 1:
    oneToA = a-1
    oneToB = b-1
    endToA = n-a
    endToB = n-b
    print(min(max(oneToA, oneToB), max(oneToA, oneToB)))
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(max(a, b)-1)

Submission status: Wrong Answer

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

if A > B:
  A, B = B, A
  
D = B - A

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def ints():
  return [int(x) for x in input().split()]
def readi():
  return int(input())

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

N, A, B = map(int, readline().split())

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if (A - B) % 2 == 0:
    print(int(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 = [int(x) for x in input().split()]
d1 = max(A-1, B-1)
d2 = abs(A-B)//2 if (A-B)%2 == 0 else 10**20
d3 = max(N-A, N-B)
print(min(d1, d2, d3))

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

Submission status: Wrong Answer

Solution code:
import sys
import math
import time

start = time.time()
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n, a, b = na()

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 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:
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, A: int, B: int):
    if (B-A) % 2 == 0:
        print(min((B-A)//2, min(max(A, B)-1, N-min(A, B))))
    else:
        print(min(max(A, B)-1, N-min(A, B)))
    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:
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N, A, B = read_ints()
sa = abs(A - B)
if sa % 2 == 0:
    print(sa // 2)
    exit()

to_haji = min(A - 1, N - B)
print(to_haji + sa)

Submission status: Wrong Answer

Solution code:
n = input()    
m = n.split()
p = [int(i) for i in m]
a = p[2] -p[1]
import math
A = math.ceil(a/2)
print(A)

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def p_a():
    n, a, b = map(int, input().split())
    if (b - a) & 1 == 0:
        print((b - a) // 2)
        exit()
    print(min(b - 1, n - a))
    
p_a()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

o = []

o.append(max(A-1,B-1))
o.append(max(N-A,N-B))
if A%2 == B%2:
    o.append(abs(A-B)//2)

print(min(o))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
print((a+b)//2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
#import numpy as np


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

Submission status: Wrong Answer

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

N, A, B = map(int, readline().split())

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

Submission status: Wrong Answer

Solution code:
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))


main()

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 = 2**62-1

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:
        return (B - A) // 2

    return min(B-1, N-A)


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())
ans = 10**20
if abs(a-b)%2==0:
    ans = abs(a-b)//2
ans = min(max(n-a,n-b),ans)
ans = min(max(a,b)-1,ans)
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math
from math import ceil
from math import factorial
from collections import Counter
from operator import itemgetter
import bisect
ii = lambda: int(input())
iia = lambda: list(map(int,input().split()))
isa = lambda: list(input().split())
def gcd(a,b):
	if(b==0):
		return a
	return gcd(b,a%b)

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

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))
z = abs(A - (A + B) // 2)
if (A + B) % 2:
  print(min(x, y))
else: print(min(x, y, z))

Submission status: Wrong Answer

Solution code:
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, a, b = list(map(int, readline().split()))
    if a == b:
        print(0)
    elif (a - b) % 2 == 0:
        print(abs(a - b) // 2)
    else:
        print(min(max(a, b) - 1, n - min(a, b)))


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
n,a,b = map(int,input().split())
ans = ((b-a)/2)
if int(ans) == ans:
    print(round(ans))
else:
    print(math.ceil(ans))

Submission status: Wrong Answer

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

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

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:
    x = max(a, b) - 1
    y = max(n - a, n - b)
    print(min(x, y))

Submission status: Wrong Answer

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


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

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


if __name__ == '__main__':
  main()

Submission status: Wrong Answer

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

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