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

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

print(int(ans))

Submission status: Wrong Answer

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

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

else:
    if min(N-A,B-1) < min((B-A-1)/2 + A, (N-(A+N-(B+1))/2 + N-B+1)):
        print(int(min(N-A,B-1)))
    if min(N-A,B-1) > min((B-A-1)/2 + A, (N-(A+N-(B+1))/2 + N-B+1)):
        print(int(min((B-A-1)/2 + A, (N-(A+N-(B+1))/2 + N-B+1))))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if (A + B) % 2 == 0 and not (A == 1 and B == N):
    print(((A+B)>>1) - A)
else:
    NA = N - A + 1

    nn = min(B, NA) - 1
    print(nn)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# A - Table Tennis Training
N,A,B = map(int, input().split())

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

    ans = int((B-A)/2)
else:
    if N-B > A-1:
        ans1 = A-1
        ans2 = int(((B-1) - (A-1))//2)
        ans = ans1+1+ans2
    # elif N-B == A-1:

    else:
        ans1 = N-B
        ans2 = int(((N-A) - (N-B))//2)
        ans = ans1+1+ans2
print(ans)

Submission status: Wrong Answer

Solution code:
a,b,c = input().split(" ")
a=int(a)
b=int(b)
c=int(c)

minum = c-b-1
count = 0


if (minum%2==0):
    if (a-b>b-1):
        while (b!=c) :
            if (b!=1):
                b-=1
            if (c!=1):
                c-=1
            count+=1
        print(count)
    else:
        while (b!=c) :
            if (b!=a):
                b+=1
            if (c!=a):
                c+=1
            count+=1
        print(count)
elif (minum%2!=0):
    while (b!=c) :
        b-=1
        c+=1
        count+=1
    print(count)

Submission status: Wrong Answer

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

def halfdist(x,y):
    return (y-x)/2

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

Submission status: Wrong Answer

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

if (abs(A-B)-1) % 2 == 0:
    A_side = A
    A_right = N-A+1
    B_left = B
    B_right = N-B+1
    M = (N+1)/2
    
    if A <= M and B <= M:
        print(max(A-1, B-1))
    elif A >= M and B >= M:
        print(max(A_right-1, B_right-1))
    elif A <= M and B >= M:
        print(min(A_right-1, B-1))
    elif B <= M and A >= M:
        print(min(A-1, B_right-1))
        
else:
    if A == B:
        print(0)
    else:
        print(int(abs(A-B))/2)

Submission status: Wrong Answer

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

# 最小公倍数
def gcd(a, b):
  if a < b:
      a, b = b, a
  while a % b != 0:
      a, b = b, a % b
  return b
 
# 最大公約数 
def lcm(a, b):
    y = a*b / gcd(a, b)
    return int(y)

# N = INT()
# print(N)
N, A, B = MAP()
# guusuu
if (A - B) % 2 == 0:
  s = B - A
  ans = s // 2
  print(ans)
# kisuu
else:
  # if N - A <= B
  # k = B - A
  # m = min(N - A, B)
  if A - 1 <= N - B:
    # A ni tikazuku
    # 最初の移動
    s = A - 1
    # Bが残り移動する距離
    b = B - (A - 1) - 1

    ans = (s + (b + 1)) // 2
    # print(ans)
  else:
    s = N - B
    ans = N - (A + s) + 1
    ans = ans // 2
    # ans = A + s + 1
    # ans = ans // 2
  print(ans)
  #   ans =(B - A + 1)//2

  # else:
  #   a = N - (A +  N - B )
  #   ans = a // 2
  # print(ans)
    



  # print(ans - k)
  # if A <= N - B:
  #   print(B - A)
  # else:
  #   print(B - A)
  # # k = B - A
  # ans = k+min(N - A, N - B)
  # B - min(N - A, N - B)
  # print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque

inf=10**9+7

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

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


from io import StringIO
import unittest

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

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

Submission status: Wrong Answer

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

if((B-A)%2==0):
  print("(B-A)/2=",int((B-A)/2))
else:
  if(A-1 < N-B):
    ans=A
    c=1
  else:
    ans=N-B+1
    c=N
  if(c==1):
    ans+=(B-ans-c)/2
  elif(c==N):
    ans+=(c-A+ans)/2
  print(int(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
from decimal import Decimal

N, A, B = map(Decimal, input().split())
ab_max = np.amax(np.array([A, B]))
ab_min = np.amin(np.array([A, B]))

if (A - B) % 2 == 0:
    print(int((ab_max - ab_min) / 2))
else:
    print(int(np.amin([(ab_max - 1), (N - ab_min)])))

Submission status: Wrong Answer

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

n = inp[0]
a = inp[1]
b = inp[2]


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

Submission status: Wrong Answer

Solution code:
import numpy as np

N, A, B = list(map(int,input().split()))
if np.mod(B-A, 2) != 0:
    diff_min = min(A-1, N-B)
    if diff_min == (A-1):
        ans = A+int((B-A-1)/2)
    else:
        ans = (N-B)+1+int((N-(A+N-B+1))/2)
else:
    ans = int((B-A)/2)
print(ans)

Submission status: Wrong Answer

Solution code:
#A - Table Tennis Training
N,A,B = list(map(int, input().split()))

Lab = B-A
La = N-A
Lb = B-1

if Lab%2==0:
    #case Lab is even
    ans = int(Lab/2)
else:
    #case Lab is odd
    if La>=Lb:
        L1a = A-1
        ans = L1a + 1 + int((Lab-1)/2)
    else:
        Lbn = N-B
        ans = Lbn + 1 + int((Lab-1)/2)

print(ans)

Submission status: Wrong Answer

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

# 最小公倍数
def gcd(a, b):
  if a < b:
      a, b = b, a
  while a % b != 0:
      a, b = b, a % b
  return b
 
# 最大公約数 
def lcm(a, b):
    y = a*b / gcd(a, b)
    return int(y)

# N = INT()
# print(N)
N, A, B = MAP()
# guusuu
if (A - B) % 2 == 0:
  s = B - A
  ans = s // 2
  print(ans)
# kisuu
else:
  # if N - A <= B
  # k = B - A
  # m = min(N - A, B)
  if A - 1 <= N - B:
    # A ni tikazuku
    # 最初の移動
    s = A - 1
    # Bが残り移動する距離
    b = B - (A - 1) - 1

    ans = s + (b + 1) // 2
    # print(ans)
  else:
    s = N - B
    ans = N - (A + s) + 1
    ans = ans // 2
    # ans = A + s + 1
    # ans = ans // 2
  print(ans)
  #   ans =(B - A + 1)//2

  # else:
  #   a = N - (A +  N - B )
  #   ans = a // 2
  # print(ans)
    



  # print(ans - k)
  # if A <= N - B:
  #   print(B - A)
  # else:
  #   print(B - A)
  # # k = B - A
  # ans = k+min(N - A, N - B)
  # B - min(N - A, N - B)
  # print(ans)

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

Submission status: Wrong Answer

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

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

    pat1 = int(upfold + ((b - upfold) - 1)/2)
    pat2 = int(downfold + (n - a - downfold)/2)

    print(min([pat1, pat2]))

Submission status: Wrong Answer

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

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

if (b-a)%2==1:
    if (a-1) <= (n-b):
        print(int(a+abs(b-a-3)/2))
    if (a-1) > (n-b):
        print(int((n-b+1)+abs(b-a-1)/2))

Submission status: Wrong Answer

Solution code:
input_data = input()
input_data = input_data.split()

n = int(input_data[0])
a = int(input_data[1])
b = int(input_data[2])

if a > b:
    a = int(input_data[2])
    b = int(input_data[1])

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

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

Submission status: Wrong Answer

Solution code:
import math

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

num_play = (b - a) / 2

if num_play.is_integer():
  print(int(num_play))
else:
  cnt_a = b - 1
  cnt_b = n - a
  cnt_c = a + (b - a - 1) // 2
  cnt_d = n - b + 1 + (b - a + 1) // 2
  cnt = [cnt_a, cnt_b, cnt_c, cnt_d]
  cnt = filter(lambda x: x > 0, cnt)
  print(min(cnt))

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

print(answer)

Submission status: Wrong Answer

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

aaa = A-B
new_A = A
new_B = B
times = 0
if abs(aaa%2) == 0 and not aaa==0:
  if aaa > 0:
    while True:
      new_A -= 1
      new_B += 1
      times += 1
      if new_A == new_B:
        break
  if aaa < 0:
    while True:
      new_A += 1
      new_B -= 1
      times += 1
      if new_A == new_B:
        break
      
if abs(aaa%2) == 1:
  d1 = abs(N-A)
  d2 = abs(N-B)
  d3 = abs(1-A)
  d4 = abs(1-B)
  bbb = d1 + d2
  ccc = d3 + d4
  if bbb >= ccc:
    times = max(d1,d2)
  else:
    times = max(d3,d4)
print(times)

Submission status: Wrong Answer

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

if S % 2 ==0:
  C = S / 2
else:
  D = min(N-A,B-1)
  if A-1 <= N-B:
    E = A + S//2
  else:
    E = N-B+1 + S//2
  C = min(D,E)

print(int(C))

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
cnt=0
if (b-a)%2 == 0:
    while a:
        a+=1
        b-=1
        cnt+=1
        if a == b:
            print(cnt)
            exit()
if (b-a)%2 == 1:
    if a-1 > n-b:
      cnt=n-a
      print(cnt)
      exit()
    if a-1 < n-b:
      cnt=b-1
      print(cnt)
      exit()

Submission status: Wrong Answer

Solution code:
def CheckLowestNumber(N: int,A: int,B:int):

    num_A_up = A
    num_B_up = B
    num_A_down = A
    num_B_down = B
    num_time = 0
    while num_A_down != num_B_up and num_A_up != num_B_down:
        num_A_up += 1
        num_A_down -= 1
        num_B_up += 1
        num_B_down -= 1
        if num_A_up > N - 1: num_A_up = N
        if num_B_up > N - 1: num_B_up = N
        if num_B_down < 1: num_B_down = 1
        if num_A_down < 1: num_A_down = 1
        num_time += 1
        if num_A_down - num_B_down == 0 or num_A_up - num_B_up == 0: break

    return num_time

Submission status: Wrong Answer

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

if (N - A) < (B - 1):
    a2 = N - A
    a3 = int((2 * N - A - B + 2) / 2)
else:
    a2 = B - 1
    a3 = int((A + B) / 2)

print(min(a1, a2, a3))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, a, b = (int(i) for i in input().split())

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

Submission status: Wrong Answer

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

diff = abs(B - A)

if diff % 2 == 0:
    x = diff/2
elif N == 2:
    x = 1
elif diff == 1:
    x_1 = N - A
    x_2 = A - 1
    x = min(x_1, x_2)
else:
    # x1 = N - A
    # x2 = B - 1
    # x3 = min(x1, x2)

    # 端に近い方が端で数を合わせ、真ん中で再開するパターン
    diff_small = A - 1
    diff_big = N - B

    x = (diff - 1)/2 + min(diff_small, diff_big) + 1


print(int(x))

Submission status: Wrong Answer

Solution code:
def solve(N, A, B):
    rounds = 0
    for i in xrange(N):
        if A == B:
            return rounds
        average = float(A + B) / 2.0
        if average.is_integer():
            rounds += int(average) - A
            return rounds
        rounds += 1
        if (A - 1) < (N - B):
            A = max(1, A - 1)
            B = max(1, B - 1)
        else:
            A = min(N, A + 1)
            B = min(N, B + 1)

print solve(*map(int, raw_input().split()))

Submission status: Wrong Answer

Solution code:
def main():
    tmp = input()
    tmp = [int(i) for i in (tmp.split())]
    n = tmp[0]
    a = tmp[1]
    b = tmp[2]
    dst = a - b
    dst_top = a - 1
    dst_lst = n - b
    long = dst_top if dst_top<dst_lst else dst_lst

    if dst % 2 == 0:
        short = dst / 2
        wait = b-1 if (b-1)>(n-a) else n-a
        long = (dst - (long + 2)) / 2 + (long + 2)
    else:
        short = 2 * n
        wait = b-1 if (b-1)>(n-a) else n-a
        long = (dst - (long + 1)) / 2 + (long + 1)

    print(min([short, long, wait]))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math
n,a,b = map(int,input().split())
i = 0
p = 0
if (b-a)%2==0:
    print((b-a)//2)
else:
    if a < math.floor(n/2):
        while True:
            b -= 1
            if p == 1:
                a += 1
            elif a <= 1:
                a = 1
                p = 1
            else:
                a -= 1
            if a == b:
                print(i)
                break
            i += 1
    else:
        while True:
            a += 1
            if p == 1:
                b -= 1
            elif b >= n:
                b = n
                p = 1
            else:
                b += 1
            if a == b:
                print(i)
                break
            i += 1

Submission status: Wrong Answer

Solution code:
N,A,B = list(map(int,input().split()))
diff = B - A
N2B = N - B
N2A = N - A
sumN = N2A + N2B
sumAB = A + B

flag = 0
if B == N or A == 1:
    flag = 1

if diff % 2 == 0:
    print(diff // 2)
elif flag == 1:
    tmp = diff // 2
    if sumN < sumAB:
        if N2A < tmp:
            print(N2A)
        else:
            print(tmp + 1)
    else:
        if B-1 < tmp: 
            print(B - 1)
        else:
            print(tmp + 1)
else:
    tmp = diff // 2
    if sumN < sumAB:
        if N2A < tmp + N2B:
            print(N2A)
        else:
            print(tmp + N2B)
    else:
        if B-1 < tmp + A - 1: 
            print(B - 1)
        else:
            print(tmp + N2A - 1)

Submission status: Wrong Answer

Solution code:
N,A,B = list(map(int,input().split()))
count = 0
while A!=B:
    if A < B:
        if B == 1:
            pass
        else:
            B -= 1
    if A > B:
        if B == N:
            pass
        else:
            B += 1
    if (A == B and ((not A == 1) or (not A == N))):
        if A < N/2:
            A -= 1
        else:
            A += 1
    else:
        if A < B:
            if A == 1:
                pass
            else:
                A += 1
        if A > B:
            if A == N:
                pass
            else:
                A -= 1
    count += 1
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if 0 == (b-a) % 2:
    e = (b+a) // 2
    even = ((b-e) + (e-a)) // 2
    upper = max(a-1, b-1)
    lower = max(n-a, n-b)
    print(min([even, lower, upper]))

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

    print(min(upper, lower))

Submission status: Wrong Answer

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

################ DANGER ################
test = ""
#test = \
"""
5 2 4
ans 1
"""

"""
5 2 3
ans 2
"""
########################################
test = list(reversed(test.strip().splitlines()))
if test:
    def input2():
        return test.pop()
else:
    def input2():
        return input()
########################################  
        
    
n, a, b = map(int, input2().split())


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

Submission status: Wrong Answer

Solution code:
N,A,B = input().split()
N = int(N)
A = int(A)
B = int(B)
sa = B-A-1
if sa%2 == 1:#間に奇数個のテーブルがある時
    mi = min(B-A-1,N-A,B-1,2*B-N-2)
    print(mi)
if sa%2 == 0:
    mi = min(N-A,B-1)#遠いほうが端との距離が近い方で集まる
    print(mi)

Submission status: Wrong Answer

Solution code:
N, a, b=list(map(int,input().split()))
ans=0
if((b-a)%2==0):
	ans = int((b-a)/2)
elif(b-1 < N-a):
	if a+1 < b:
		ans = int(a+(b-a-1)/2)
	else:
		ans = b-1 
else:
	if a < b+1:
		ans = int((b-a-1)/2) + N-b+1
	else:
		ans = N-a

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

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

else:
    gap_n = (N - A) + (N - B)
    gap_1 = (A - 1) + (B - 1)

    if gap_n == gap_1:
        n = A if (N - A) < B else (N - B)
        print(N - n)
    else:
        n = gap_n if gap_n < gap_1 else gap_1
        print(math.ceil(n / 2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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


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

Submission status: Wrong Answer

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

k = abs(A - B)
k + k / 2 + k % 1
print(k)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

dif = abs(a-b)

#print(dif)

if(dif%2 == 0):
  print(int(dif/2))
else:
  #winwin
  if((n-b) > (a-1)):
    if(a != 1):
      up = a - 1
    else:
      up = 0
    #print("up",up)
    if((b - up)%2 == 0):
      #print("ue")
      print(int((b-up)/2) + up)
    else:
      print(math.ceil((b-up)/2) + up)
  #loselose
  else:
    if(b != n):
      down = n - b
    else:
      down = 0
    #print("down",down)
    if((b - a) % 2 == 0):
      #print("ue")
      print(int((b - a)/2) + down)
    else:
      print(math.ceil((b - a)/2) + down)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

top=max(a-1,b-1)
bottom=max(n-a,n-b)

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

Submission status: Wrong Answer

Solution code:
import numpy as np

N, A, B = list(map(int,input().split()))
if np.mod(B-A, 2) != 0:
    diff_min = min(A-1, N-B)
    if diff_min == (A-1):
        ans = A+int((B-A-1)/2)
    else:
        ans = (N-B)+1+int((N-(N-B+1))/2)
else:
    ans = int((B-A)/2)
print(ans)

Submission status: Wrong Answer

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

top=max(a-1,b-1)
bottom=max(n-a,n-b)

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

Submission status: Wrong Answer

Solution code:
N, A, B = [int(x) for x in input().split(' ')]
absdist = abs(A - B)
if absdist % 2 == 1:
    edgedist = min(A-1, B-1, N-A, N-B)
    returndist = edgedist * 2 + 1
    if absdist >= returndist:
        print((absdist - returndist) // 2 + returndist)
    else:
        print(min(max(A-1, B-1), max(N-A, N-B)))
else:    
    print(absdist // 2)

Submission status: Wrong Answer

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

T = B - A - 1

if(T < 0):
    Ans = 0
elif(T % 2 == 1):
    Ans = (int)((T + 1) / 2)
else:
    A_prime = A + (T / 2)
    
    if(A_prime < N / 2):
        Ans = B - 1
    else:
        Ans = N - A

print(Ans)

Submission status: Wrong Answer

Solution code:
import math

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

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

else:
    gap_n = (N - A) + (N - B)
    gap_1 = (A - 1) + (B - 1)
    print(gap_n, gap_1)

    if gap_n == gap_1:
        n = A if (N - A) < B else (N - B)
        print(N - n)
    else:
        n = gap_n if gap_n < gap_1 else gap_1
        print(math.ceil(n / 2))

Submission status: Wrong Answer

Solution code:
def even(d):
    return d // 2

def odd(A, B, N):
    if abs(A-1) > abs(B-N):
        dist2edge = abs(B-N)
        A += dist2edge
        B += dist2edge 

        return even(abs((A+1)- B)) + 1 + dist2edge

    else:
        dist2edge = abs(A)
        A -= dist2edge
        B -= dist2edge
    
        return even(abs(A- (B-1))) + 1 + dist2edge


def main():
    N, A, B = map(int, input().split())
    diff = abs(A-B)

    if diff % 2 == 0:
        print(even(diff))
    else:
        print(odd(A, B, N))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

diff = abs(b-a)
result = 0
if diff % 2 == 0:
    result = diff // 2
else:
    if a < (n-b+1):
        n_a = 1
        n_b = b - a + 1
        result = a-1
        result += (b-1)//2 + (b-1)%2
    else:
        n_a = a + n - b
        n_b = n
        result = n-b
        result += (n-a)//2 + (n-a)%2

print(result)

Submission status: Wrong Answer

Solution code:
nc, ac, bc = map(int, input().split())

n = nc - 1
a = ac - 1
b = bc - 1

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

Submission status: Wrong Answer

Solution code:
strings = input().split(' ')
N = int(strings[0])
A = int(strings[1])
B = int(strings[2])

distance = B - A
moves = 0
if distance % 2 ==1:
    distance_B2W = N - B
    distance_A2W = A - 1
    moves = moves + min(distance_A2W,distance_B2W) + 1
    if distance != 1:
        moves = moves + (distance - 1) // 2
    else:
        moves = moves + 1
    print(moves)
else:
    print(distance // 2)

Submission status: Wrong Answer

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

startA = (a == 1)
endB = (b == n)
aida = b-a-1



if any([startA, endB]):
    # 端に点があれば、間の卓数＋１
    print(aida+1)
else:
    if aida % 2 != 0:
        #　間の卓数が奇数なら、間の個数/2 +1
        print(aida//2+1)
    else:
        if (a-1) > (n - b):
            print(n-b)
        else:
            print(b-1)

Submission status: Wrong Answer

Solution code:
def main():
    tmp = input()
    tmp = [int(i) for i in (tmp.split())]
    n = tmp[0]
    a = tmp[1]
    b = tmp[2]
    dst = a - b
    dst_top = a - 1
    dst_lst = n - b
    long = dst_top if dst_top<dst_lst else dst_lst

    if dst % 2 == 0:
        short = dst / 2
        long = (dst - (long + 2)) / 2 + (long + 2)
    else:
        short = 2 * n
        long = (dst - (long + 1)) / 2 + (long + 1)

    print(min([short, long]))

if __name__ == "__main__":
    main()