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 .

Solution (Python):
import sys

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

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

Solution (Python):
import sys
input = sys.stdin.readline

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

ANS=10*N

if (B-A)%2==0:
    ANS=min(ANS,(B-A)//2)

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

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

print(ANS)

Solution (Python):
from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


def main():
    n,a,b = mi()
    if not (b-a)%2:
        print((b-a)//2)
    else:
        print(min(a-1,n-b)+(b-a)//2+1)
    


    
main()

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

left = A-1
right = N-B


a,b = 1, B-left-1
l = left + 1 + abs(b-a) // 2


a,b = A+right+1, N
r = right + 1 + abs(b-a) // 2
print(min(l,r))

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

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

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

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

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

ans = n

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

left = a-1
right = n - b
if (b - a) % 2 == 1:
    left += 1
    right += 1
ans = min(ans, left + (b-a) // 2)
ans = min(ans, right + (b-a) // 2)

print(ans)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

def F(N,A,B):
    if (B - A) % 2 == 0:
        return (B - A) // 2
    
    cand = []
    x = (B - 1) + (A - 1) + 1
    cand.append(x//2)
    x = (N - B) + (N - A) + 1
    cand.append(x//2)
    return min(cand)

answer = F(N,A,B)
print(answer)

Solution (Python):
n,a,b=map(int,input().split())
if (a+b)%2==0:print((b-a)//2);exit()
aa,bb=1,b-(a-1)
x=0--(bb-aa)//2+a-1
aa,bb=aa+(n-bb),n
y=0--(bb-aa)//2+n-b
print(min(x,y))

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

Solution (Python):
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7



N, A, B = list(map(int, sys.stdin.buffer.readline().split()))

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