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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N, A, B = map(int,input().split())

M1 = float("inf")
if (B-A)%2==0:
	M1 = (B-A)//2
M2 = B-1
M3 = N-A

print(min(M1,M2,M3))

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import random
n,a,b = map(int,input().split()) 
"""
n = random.randint(2, 10 ** 18)
c = random.randint(1, n)
a = random.randint(1, c)
b = random.randint(a, n)
print(n, a, b)
"""
if (b - a) % 2 == 0:
    ans = int((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 (B-A)&1:
    print(min(B-1,N-A))
else:
    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
    print(int(ans))
else:
    ans = min(a - 1, n - b) + 1 + ((b - a - 1)/2)
    print(int(ans))

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

Solution code:
N, A, B = [int(n) for n in input().split()]
if (B-A)%2==0:
    print((B-A)//2)
else:
    if (A-1) < (N-B):
        print(A+(B-A)//2)
    else:
        print((N-B)+(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
    print(ans)
else:
    ans = min(a - 1, n - b) + 1 + (b - a - 1)/2
    print(ans)

Submission status: Wrong Answer

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

result = []

#２で割れる
if (b - a)%2 == 0:
    ans = (b - a) /2
    result.append(int(ans))


#左に寄せて真ん中
ans = a - 1 + 1 + (b - a - 1)/2
result.append(int(ans))

#右に寄せて真ん中
ans = n - b + 1 + (b - a - 1)/2
result.append(int(ans))

print(min(result))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

result = []

#２で割れる
if (a+b)%2 == 0:
    ans = b - (a+b)/2
    result.append(int(ans))


#左に寄せて真ん中
ans = b - (b - a)/2
result.append(int(ans))

#右に寄せて真ん中
ans = n - b + 1 + n - (a + (2*n) - b + 1)/2
result.append(int(ans))

print(min(result))

Submission status: Wrong Answer

Solution code:
N, A, B = [int(n) for n in input().split()]
if (B-A)%2==0:
    print((B-A)//2)
else:
    print((B-A-1)//2)

Submission status: Wrong Answer

Solution code:
N, A, B = [int(n) for n in input().split()]
if (B-A)%2==0:
    print((B-A)/2)
else:
    print((B-A-1)/2)

Submission status: Wrong Answer

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

result = []

#２で割れる
if (a+b)%2 == 0:
    ans = b - (a+b)/2
    result.append(int(ans))

#左に寄せる
ans = b - 1
result.append(int(ans))

#右に寄せる
ans = n - a
result.append(int(ans))

#左に寄せて真ん中
ans = b - (b - a)/2
result.append(int(ans))

#右に寄せて真ん中
ans = n - b + 1 + n - (a + (2*n) - b + 1)/2
result.append(int(ans))

print(min(result))

Submission status: Wrong Answer

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

result = []

#２で割れる
if (a+b)%2 == 0:
    ans = b - (a+b)/2
    result.append(int(ans))

#左に寄せる
ans = b - 1
result.append(int(ans))

#右に寄せる
ans = n - a
result.append(int(ans))

#左に寄せて真ん中
ans = b - (b - a)/2
result.append(int(ans))

#右に寄せて真ん中
ans = n - b + 1 + n - (a + (2*n) - b + 1)/2
result.append(int(ans))

print(min(result))

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a = list(map(int,input().split()))
print(a[0]*((a[1]-1)*(a[2]-1))+1+(a[2]-a[1]-1)/2)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

round_1 = max(A-1,B-1)
round_N = max(N-A,N-B)

ans = 10**18

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

ans = min(round_1,round_N,ans)

print(ans)

Submission status: Wrong Answer

Solution code:
import sys

n, a, b = map(int, sys.stdin.readline().split())

def main():
    d = b - a
    if d % 2 == 0:
        return d // 2
    else:
        return min(n - b, abs(1 - a) + 1 + (d - 1) // 2)

if __name__ == '__main__':
    ans = main()
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,b=[int(j) for j in 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())
 
diff = B - A
 
if diff % 2 == 0:
    x = diff/2

else:
    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:
N, A, B = map(int, input().split())

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

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

Submission status: Wrong Answer

Solution code:
lst = list(map(lambda x: int(x), input().split(" ")))
N = lst[0]
A = lst[1]
B = lst[2]

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

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

Submission status: Wrong Answer

Solution code:
N , A ,B = map(int,input().split())
C = B - A
ans = C / 2
print(int(round(ans)))

Submission status: Wrong Answer

Solution code:
def wczytaj_liste(): 
    wczytana_lista = input()
    lista_znakow = wczytana_lista.split()
    ostateczna_lista = []
    for element in lista_znakow:
        ostateczna_lista.append(int(element))
    return ostateczna_lista

def table_tenis(): 
    N, A, B = wczytaj_liste()
    if (B-A)%2 == 0: 
        print ((B-A)//2)
    else: 
        if A - 1 <= N - B: 
            print(A+((B-A)//2))
        else: 
            print((N -B+1)+((A-(N -B+1))//2))
            
table_tenis()

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n,a,b=MI()
    ans=10**18+5
    if (b-a)%2==0:ans=(b-a)//2
    ans=min(ans,b-1,n-a)
    print(ans)
main()

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b): #最小公倍数
    return a/gcd(a,b)*b

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def prime_fact(a): #素因数分解
    sqrt = math.sqrt(a)
    res = []
    i = 2
    if is_prime(a):
        res.append(a)
    else:
        while a!=1:
            while a%i==0:
                res.append(i)
                a //= i
            i += 1
    return res

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

if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b): #最小公倍数
    return a/gcd(a,b)*b

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def prime_fact(a): #素因数分解
    sqrt = math.sqrt(a)
    res = []
    i = 2
    if is_prime(a):
        res.append(a)
    else:
        while a!=1:
            while a%i==0:
                res.append(i)
                a //= i
            i += 1
    return res

def main():
    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)
    return

if __name__=='__main__':
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N, A, B = (int(i) for i in input().split())
 
def f(A, B):
  return int((B - A) / 2)

if (B - A) % 2 == 0:
    ans = f(A, B)
else:
    # Aが1に向かうとき
    ans_a = A + f(1, B - A)
    # BがNに向かうとき
    ans_b = (N - B + 1) + f(A + N - B +1, N)
    # 
    
    ans = min(ans_a, ans_b)
    
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

solve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

solve()

Submission status: Wrong Answer

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

if (b - a) % 2 == 0:
    if b > 10 ** 15:
        print(int(abs(a - b)/2))
    print(int(abs(a - b)//2))
elif (b - a) % 2 == 1:
    print(int(min([a, n - b + 1]) + (b - a - 1)//2))

Submission status: Wrong Answer

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

if (b - a) % 2 == 0:
    if b > 10 ** 15:
        print('a')
    print(int(abs(a - b)//2))
elif (b - a) % 2 == 1:
    print(int(min([a, n - b + 1]) + (b - a - 1)//2))

Submission status: Wrong Answer

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

if (b - a) % 2 == 0:
    if b > 10 ** 10:
        print('a')
    print(int(abs(a - b)//2))
elif (b - a) % 2 == 1:
    print(int(min([a, n - b + 1]) + (b - a - 1)//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:
    if (a-1)<=(n-b):
        b-=a
        print(int((b-1)/2)+a)
    else:
        a+=n-b+1
        print(int((n-a)/2)+n-b+1)

Submission status: Wrong Answer

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

if (b - a) % 2 == 0:
    print(int(abs(a - b)/2), 'faeag')
elif (b - a) % 2 == 1:
    print(int(min([a, n - b + 1]) + (b - a - 1)//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) % 2 == 1:
    print(int(min([a, n - b + 1]) + (b - a - 1)//2))

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 = (abs(a - b))
    fst = a if a<b else b
    snd = a if a>b else b
    dst_top = snd - 1
    dst_lst = n - fst
    long = dst_top if dst_top<dst_lst else dst_lst

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

    print(min([short, long]))

if __name__ == "__main__":
    main()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

res = float("inf")
if (B - A - 1) % 2 != 0:
    res = min(res, (B - A - 1) // 2 + 1)
res = min(res, B - 1, N - A)

print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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-1)//2
  else:
    E = N-B+1 + (S-1)//2
  C = min(D,E)
 
print(int(C))

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
n, a, b = [int(x) for x in input().strip().split()]
if (a + b) % 2 == 0:
    print(int((b - a) / 2))
else:
    if a - 1 <= n - b:
        ans = a - 1
        b -= ans
        if b % 2 == 0:
            ans += 1
            b -= 1
        ans += int((b - 1) / 2)
    else:
        ans = n - b
        a += ans
        if (n - a) % 2 == 1:
            ans += 1
            a += 1
        ans += int((n - a) / 2)
    print(ans)

Submission status: Wrong Answer

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

C = B-A

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

C = B-A

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

Submission status: Wrong Answer

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

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

elif (A-1)<=(N-B):
  print(int(A+(B-A-1)/2))

else:
  print(int(N-B+1+(B-A-1)/2))

Submission status: Wrong Answer

Solution code:
def main():
    N, A, B = map(int, input().split())
    sub = B - A
 
    left_s = A - 1
    right_s = N - B
    
    if sub % 2 == 0:
        return sub // 2
    elif sub == 1:
        if left_s < right_s:
            return B - 1
        else:
            return N - A
    else:
        if left_s < right_s:
            if left_s == 0:
                left_s = 1
            return (B - 1) - left_s
        else:
            if right_s == 0:
                right_s = 1
            return (N - A) - right_s
 
if __name__ == '__main__':
    print(int(main()))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

C = B-A

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

Submission status: Wrong Answer

Solution code:
def upper_cnt(a, b):
    upper_cnt = n-b + 1
    a += upper_cnt + 1
    upper_cnt += ((b-a) // 2)    
    return upper_cnt

def lower_cnt(a, b):
    lower_cnt = a-1 + 1
    b -= lower_cnt - 1
    lower_cnt += ((b-a) // 2)
    return lower_cnt

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

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

else:
    up = upper_cnt(a, b)
    low = lower_cnt(a, b)

    print(min(a, b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


elif (b - a) % 2 == 1 and b == n and a == 1:
          print(int((n - 1 - 1) /2 + 1))
elif (b - a) % 2 == 1 and b == n and a > 1:
          print(int((b - a - 1) / 2 + 1))
elif (b - a) % 2 == 1 and 2 <= b  and a == 1:
          print(int((b - 1 - 1 ) / 2 + 1))
else:
     print(int((b - a) / 2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from decimal import *
N,A,B = map(int,input().split())

C = B-A

if C % 2 == 0:
#     print("1")
    dec = Decimal(B-A)/2
    print(int(dec))
#     print(int((B-A)/2))
elif C == 1:
#     print("2")
    print(int(max(N-B,A-1)))
else:
#     print("3")
    if N-B > A-1:
        dec = Decimal(B+A)/2
        print(int(dec))
    else:
        dec = N - Decimal(A+B-1)/2
        print(int(dec))

Submission status: Wrong Answer

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

if (A%2==0 and B%2==0) or (A%2==1 and B%2==1):
  print((B-A)/2)

elif (A-1)<=(N-B):
  print(int(A+(B-A-1)/2))

else:
  print(int(N-B+1+(B-A-1)/2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    left_s = A - 1
    right_s = N - B
        
    # 偶数なら
    if sub % 2 == 0:
        return sub / 2
    # 奇数なら
    else:
        return (min(left_s, right_s) + 1 + ((sub - 1)/2))
    
if __name__ == '__main__':
    print(int(main()))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    left_s = A - 1
    right_s = N - B
        
    # 偶数なら
    if sub % 2 == 0:
        return sub / 2
    # 奇数なら
    else:
        return (min(left_s, right_s) + 1 + ((sub - 1)/2))
    
if __name__ == '__main__':
    print(main())

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

if (A%2==0 and B%2==0) or (A%2==1 and B%2==1):
  print((B-A)/2)

elif (A-1)<=(N-B):
  print(int(A+(B-A-1)/2))

else:
  print(int(N-B+(B-A-1)/2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

Solution code:

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

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

else:
    upper_cnt = n-b + 1
    a += upper_cnt + 1
    upper_cnt += ((b-a) // 2)    

    lower_cnt = a-1 + 1
    b -= lower_cnt - 1
    lower_cnt += ((b-a) // 2)

    print(min(upper_cnt, lower_cnt))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if (A%2==0 and B%2==0) or (A%2==1 and B%2==1):
  print((B-A)/2)

elif (A-1)<=(N-B):
  print(int(A-1+(B-A-1)/2))

else:
  print(int(N-B+(B-A-1)/2))

Submission status: Wrong Answer

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

if (A%2==0 and A%2==0) or (A%2==1 and A%2==1):
  print((B-A)/2)

elif (A-1)<=(N-B):
  print(int(A-1+(B-A-1)/2))

else:
  print(int(N-B+(B-A-1)/2))

Submission status: Wrong Answer

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

elif (b - a) % 2 == 1 and b == n and a > 1:
          print(int((b - a - 1) / 2 + 1))
elif (b - a) % 2 == 1 and 2 <= b < n and a == 1:
          print(int((b - 1 - 1 ) / 2 + 1))
elif (b - a) % 2 == 1 and b == n and a == 1:
          print(int((n - 1 - 1) /2 + 1))
else:
     print(int((b - a) / 2))

Submission status: Wrong Answer

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

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

if Lab%2==0:
    #case Lab is even
    ans = Lab/2
else:
    #case Lab is odd
    ans = min(La,Lb) + 1 + (Lab-1)/2
    
ans = int(ans)
print(ans)

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) % 2 == 1:

    print(int(min([a, n - b + 1]) + (b - a - 1)/2))

Submission status: Wrong Answer

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

    left_s = A - 1
    right_s = N - B
        
    # 偶数なら
    if sub % 2 == 0:
        return sub / 2
    # 奇数なら
    else:
        return min(left_s, right_s) + 1 + ((sub - 1)/2)
    
if __name__ == '__main__':
    print(int(main()))