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:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline
from collections import defaultdict
from heapq import heappop, heappush

from decimal import *

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

##### 累乗 #####
# pow(x, y, z) -> x**y % z

##### 割り算の切り上げ #####
# tmp = -(-4 // 3)

##### dict の for文 #####
# for k, v in d.items():
#     print(k, v)

##### 進数の変換 #####
# bin_str = bin(i)[2:]
# oct_str = oct(i)[2:]
# hex_str = hex(i)[2:]

##### とても大きな数 と 小数の計算誤差 #####
# 「Decimal」は計算誤差を 0にできる。必要に応じて粒度を設定せよ。
# getcontext().prec = 100
#
# tmp = Decimal(i)
# A,B = map(Decimal, input().split())
# ans = A * B

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	N,A,B = inputMap()

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



#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# 2分検索のリバース
def bisect_left_reverse(a, x):
    if a[0] <= x:
        return 0
    if x < a[-1]:
        return len(a)
    # 二分探索
    ok = len(a) - 1
    ng = 0
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if a[mid] <= x:
            ok = mid
        else:
            ng = mid
    return ok

def bisect_right_reverse(a, x):
    if a[0] < x:
        return 0
    if x <= a[-1]:
        return len(a)
    # 二分探索
    ok = len(a) - 1
    ng = 0
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if a[mid] < x:
            ok = mid
        else:
            ng = mid
    return ok

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# 2分検索
# 存在しない場合: None 存在する場合: その値
def binary_search(list, item):
    low = 0
    high = len(list) - 1

    while low <= high:
        mid = (low + high) //2
        guess = list[mid]
        if guess == item:
            return mid
        if guess > item:
            high = mid -1
        else:
            low = mid + 1
    return None

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# N 個のボールを K グループに分ける場合のパターン数
def sunuke(N, K, mod=10**9+7):
	if N < K or K-1 < 0:
		return 0
	else:
		return combination(N-1, K-1, mod)

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# nCr mod m
# rがn/2に近いと非常に重くなる
def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

# mを法とするaの乗法的逆元
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# nHr mod m
# 問題によって、combination()を切り替えること
def H(n, r, mod=10**9+7):
	# comb = Combination(n+r-1, mod)
	# return comb(n+r-1, r)
    return combination(n+r-1, r, mod)


class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# dfs のサンプル
def dfs(graph,parent,counter,edge):
    stk = []
    stk.append(edge)
    while len(stk) > 0:
        p = stk.pop()
        for e in graph[p]:
            if parent[p] == e:
                continue
            else:
                parent[e] = p
                counter[e] += counter[p]
                stk.append(e)

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

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


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


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

#####GCD#####
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

N,A,B = IL()

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

Submission status: Wrong Answer

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

#####GCD#####
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

N,A,B = IL()

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

Submission status: Wrong Answer

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

#####GCD#####
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

N,A,B = IL()

print((B-A)//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(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)-1)
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:
    print((B-A)//2)
else:
    if A-1<=N-B:
        print(B-1)
    else:
        print(N-A)

Submission status: Wrong Answer

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

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

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

print(ans)

Submission status: Wrong Answer

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

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

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

print(ans)

Submission status: Wrong Answer

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

ans = float("inf")
if (b-a)%2:
    ans = min((b-a+1)//2+a-1, ans)
    ans = min((a+n-b+1)//2+n-b, ans)
else:
    ans = (b-a)//2
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# A - Table Tennis Training
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:
    ans=(B-A)//2
else:
    ans=min(A,N-B)+(B-A)//2
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

result = 0

if (A-B)%2 == 0:
    #差が偶数
    result = (B - A) / 2
else:
    #差が奇数
    result = min(A-1,N-B)+1+(B-A-1)/2

print(int(result))

Submission status: Wrong Answer

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

result = 0

if (A-B)%2 == 0:
    #差が偶数
    result = int((B - A) / 2)
else:
    #差が奇数
    if (N-A) < (B-1):
        result = N-A
    else:
        result = B-1

print(result)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if (b - a) % 2 == 0:
    d = min(d, int((b - a) / 2))

print(d)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if (b - a) % 2 == 0:
    d = min(d, int((b - a) / 2))

print(d)

Submission status: Wrong Answer

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

dif = abs(A-B)
if(dif%2 == 0):
  ans = dif//2
else:
  #A1_diff = A-1
  B1_diff = B-1
  AN_diff = N-A
  #BN_diff = N-B
  ans = min(B1_diff, AN_diff)
print(ans)

Submission status: Wrong Answer

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

dif = abs(A-B)
if(dif%2 == 0):
  ans = dif//2
else:
  A_diff = A-1
  B_diff = N-B
  ans = max(A_diff,B_diff)
print(ans)

Submission status: Wrong Answer

Solution code:
#n=int(input())
n,a,b=map(int,input().split())
#al=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
dif=b-a-1
if dif%2==0:
    print(min(b-1,n-a))
else:
    print(dif//2+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())
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())

ab = B - A

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

Submission status: Wrong Answer

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

ab = B - A

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n, a, b = map(int, input().split())
if (b - a) % 2 == 0:
    print((b - a) // 2)
else:
    m = min(a, n - b)
    print(m + (b - a) // 2)

Submission status: Wrong Answer

Solution code:

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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

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(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:
    print(abs(b-a)//2)
else:
    s = n//2
    if a > s and b > s:
        print(n - min(a,b))
    elif a<= s and b <= s:
        print(max(a,b) - 1)
    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:
    print((b-a)//2)
else:
    s = n//2
    if a > s and b > s:
        print(n - min(a,b))
    elif a<= s and b <= s:
        print(max(a,b) - 1)
    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:
    print((b-a)//2)
else:
    if a == 1 or b == 5:
        print(b-a)
    elif a == 5 or b == 1:
        print(a-b)
    else:
        print(2)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

from math import ceil

def solve():
    n, a, b = MI()
    # a -= 1
    # b -= 1

    left = max(a-1, b-1)
    right = max(n-a, n-b)

    center = INF
    sa = abs(b - a)
    if a % 2 == b % 2:
        center = sa // 2
    else:
        t = min(a-1, n-b)
        center = t + ceil((sa-1) / 2) + 1
    # print(left, right, center)
    print(min([left, right, center]))


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

from math import ceil

def solve():
    n, a, b = MI()
    # a -= 1
    # b -= 1

    left = max(a-1, b-1)
    right = max(n-a, n-b)

    center = INF
    sa = abs(b - a) - 1
    if sa % 2 != 0:
        center = ceil(sa / 2)
    else:
        t = min(a-1, n-b)
        center = t + ceil(sa / 2) + 1
    # print(left, right, center)
    print(min([left, right, center]))


if __name__ == '__main__':
    solve()