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

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

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/agc041/tasks/agc041_a


def main():
    (n, a, b) = map(int, input().split(" "))
    ans = abs(a - b)
    if ans % 2 == 0:
        ans //= 2
    else:
        ato1 = a - 1
        bton = n - b
        if ato1 < bton:
            ans = b - 1
        else:
            ans = n - a
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

med = N / 2 + 0.5

Max = max([A, B])
Min = min([A, B])

SubMM = Max - Min

if (SubMM) % 2 == 0:
    round_count = round_count + int(SubMM / 2)
else:
    medAB = (Max + Min) / 2
    if medAB > med:
        Add = N - Max
        Min = Min + Add
        round_count = round_count + Add
        
        Add2 = N - Min
        round_count = round_count + Add2
    else:
        Sub = Min - 1
        Max = Max - Sub
        round_count = round_count + Sub
        
        Sub2 = Max - 1
        round_count = round_count + Sub2

print(round_count)

Submission status: Wrong Answer

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

Half = (A + B)//2

if Half == (A + B)/2:
    if Half >= A:
        print(Half - A)
    elif Half < A:
        print(A - Half)
else:
    if (N + 1)/2 > A and (N + 1)/2 > B:
        print((B - A + 1)//2)
    elif (N + 1)/2 < A and (N + 1)/2 < B:
        print((A + B)//2)
    elif B > (N + 1)/2 > A:
        if (N - A) < (B - 1):
            print((B - A + 1)//2)
        elif (N - A) > (B - 1):
            print((A + B)//2)
        else:
            print(N//2)

Submission status: Wrong Answer

Solution code:
L=input().split()
n=int(L[0])
a=int(L[1])
b=int(L[2])
     
if (b-a)%2==0:
  x=(b-a)/2
elif n-a>=b-1:
  x=a+(b-a)/2
elif b-1>=n-a:
  x=n-1-a
     
print(int(x))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if diff % 2 == 0:
    print(diff // 2)

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

    if gap_n == gap_1:
        print(gap_n)
    elif gap_n < gap_1:
        n = N-A if N-A > N-B else N-B
        print(n)
    else:
        n = A if A-1 < B-1 else B
        print(N - n)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math

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

# print(N)
# print(A)
# print(B)

ans = 0

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,A,B = map(int,input().split())
print((A+B)//2)

Submission status: Wrong Answer

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

def hoge(a,b):
    oo = []
    if a % 2 == b % 2:
        oo.append(abs(a-b)//2)
    if a == 0 or b == 0:
        c = max(a,b)
        oo.append(c)
        oo.append(N-1-c)
    if a == N-1 or b == N-1:
        c = min(a,b)
        oo.append(c)
        oo.append(N-1-c)
    return min(oo,default=-1)

N -= 1
L,R = sorted([A,B])
L -= 1
R -= 1

a = hoge(L,R)
if a > 0:
    o['a'] = a
else:
    o['b1'] = L + hoge(0,R-L-1) + 1
    o['b2'] = L + hoge(0,R-L+1) + 1
    o['c1'] = R + hoge(N-1,R+L-1) + 1
    o['c2'] = R + hoge(N-1,R+L+1) + 1


print(min(o.values()))

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)
  
def f2(N, A, B):
    if (B - A) % 2 == 0:
        ans = f(A, B)
    else:
        # Aが1に向かうとき
        ans_a = A + f(1, B - A + 1)
        # BがNに向かうとき
        ans_b = (N - B + 1) + f(A + N - B +1, N)
        ans = min(ans_a, ans_b)
    
    return ans
  
print(f2(N,A,B))

Submission status: Wrong Answer

Solution code:
from decimal import Decimal
N, A, B = input().split()
n=Decimal(N)
a=Decimal(A)
b=Decimal(B)
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 = input().split()
n = int(n)
a = int(a)
b = int(b)
diff = b-a
if diff %2 == 0:
    print(diff/2)
elif a-1 < n-b:
    print(int(a + (diff-1)/2))
else:
    print(int(((diff-1)/2)+(n-b)))

Submission status: Wrong Answer

Solution code:
x, y, z = input().split()
n = int(x)
a = int(y)
b = int(z)
num_round = 0
num1 = 0

constraints = (2 <= n) and (n <= 10^18) and (1 <= a) and (a <= b) and (b <= n)
if (constraints):
  if (abs(a - b) == 0):
    print(num_round)
  elif (abs(a - b) % 2 == 0):
    average = int((a + b) / 2)
    num_round = abs(a - average)
    print(num_round)
  else:
    num1 = n - b
    if (num1 < a):
      print(n - a)
    else:
      print(b - 1)
else:
  print("invalid, input number does not match with constraints.")

Submission status: Wrong Answer

Solution code:
import math as m

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

dif = abs(B-A)
half = N/2
if dif %2==1:
  print(m.ceil(dif/2))
else:
  n = N-B
  if A>= n:
    print(m.ceil(n/2 +A-n+dif))
  else:
    print(m.ceil(n/2+dif))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

# print(N)
# print(A)
# print(B)

ans = 0

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

Submission status: Wrong Answer

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

med = N / 2 + 0.5
maxAB = 10 ** 18

Max = max([A, B])
Min = min([A, B])

if (Max - Min) % 2 == 0:
    for i in range(maxAB):
        Max = Max - 1
        Min = Min + 1

        round_count = round_count + 1

        if Max == Min:
            break
else:
    medAB = (Max + Min) / 2
    if medAB > med:
        Add = N - Max
        Min = Min + Add
        round_count = round_count + Add
        
        Add2 = N - Min
        round_count = round_count + Add2
    else:
        Sub = Min - 1
        Max = Max - Sub
        round_count = round_count + Sub
        
        Sub2 = Max - 1
        round_count = round_count + Sub2

print(round_count)

Submission status: Wrong Answer

Solution code:
# 整数の入力 
a, b, c = map(int, input().split())
# AとBの間の卓数
bet_table = c - b - 1
# 間の卓数が偶数か奇数で場合分け
if  bet_table % 2 != 0:
    print(bet_table // 2 + bet_table % 2)
elif bet_table % 2 == 0:
    print(c - 1)

Submission status: Wrong Answer

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

def hoge(a,b):
    oo = [-1]
    if a % 2 == b % 2:
        oo.append(abs(a-b)//2)
    if a == 0 or b == 0:
        c = max(a,b)
        oo.append(c)
        oo.append(N-1-c)
    if a == N-1 or b == N-1:
        c = min(a,b)
        oo.append(c)
        oo.append(N-1-c)
    return min(oo)

N -= 1
L,R = sorted([A,B])
L -= 1
R -= 1

a = hoge(L,R)
if a > 0:
    o['a'] = a
else:
    o['b1'] = L + hoge(0,R-L-1) + 1
    o['b2'] = L + hoge(0,R-L+1) + 1
    o['c1'] = R + hoge(N-1,R+L-1) + 1
    o['c2'] = R + hoge(N-1,R+L+1) + 1

print(min(o.values()))

Submission status: Wrong Answer

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

if diff % 2 == 0:
    print(diff // 2)

else:
    gap_n = (N - A) + (N - B)
    gap_1 = (A - 1) + (B - 1)
    # print('n,1:', gap_n, gap_1)
    if gap_n == gap_1:
        print(gap_n)
    elif N == gap_n or N == gap_1:
        print(N)
    elif gap_n < gap_1:
        # print('N-A, N-B:', N-A, N-B)
        n = N-A if N-A > N-B else N-B
        print(n)
    else:
        n = A if A-1 < B-1 else B
        print(n)

Submission status: Wrong Answer

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

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

    else:
        shifta = abs(N - A)
        shiftb = abs(B - 1)

        if shifta > shiftb:
            print(shiftb)

        else:
            print(shifta)

main()

Submission status: Wrong Answer

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

Half = (A + B)//2

if Half == (A + B)/2:
    if Half >= A:
        print(Half - A)
    elif Half < A:
        print(A - Half)
else:
    if (N + 1)/2 > A and (N + 1)/2 > B:
        print(B - 1)
    elif (N + 1)/2 < A and (N + 1)/2 < B:
        print(N - A)
    elif B > (N + 1)/2 > A:
        if (N - A) < (B - 1):
            print((B - A + 1)//2)
        elif (N - A) > (B - 1):
            print((A + B)//2)
        else:
            print(N//2)

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

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:
    #A+ans=B+N-B-(ans-1-N+B)=2N-ans+1-B
    #ans=(2N-A-B+1)/2

    #B-ans=A-(A-1)+(ans-1-(A-1))=ans-A+1
    #ans=(A+B-1)/2
    print(min(int((2*N-A-B+1)/2),int((A+B-1)/2)))
"""    
    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:
i = list(map(int, input().split()))
a=[]
if abs(i[2]-i[1])%2 == 0:
    ans=(i[2]-i[1])//2
else:
    a.append(i[1])
    a.append(i[2])
    x=min(a)
    y=max(a)
    if x-1<i[0]-y:
        ans=(x-1)+1
    else:
        ans=(y-1)+1
print(ans)

Submission status: Wrong Answer

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

diff = abs(a-b) 
mod = diff % 2

if mod == 0:
  
  print( diff // 2 )


elif mod != 0 :
  
  if n - a < b - 1 :
    if diff == 1:
      	print(n-a)
    else :
    	print( min( n - a , b - a - 1 ) )   
  else : 
    if diff == 1 :
        print(b-1)
    else:
    	print( min( b - 1 , b - a - 1) )

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

len = b-a
if ((len % 2) == 0):
    print(int(len/2))
    exit()
else:
    x=0
    for i in range(100000000):
        x += 1
    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())
A_B = abs(A-B)
if A_B % 2 == 1:
    ans = B - 1
else:
    ans = int(A_B / 2)
print(ans)

Submission status: Wrong Answer

Solution code:
import math as m

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

dif = abs(B-A)
half = N/2
a2half = half - A
b2half = B - half - 1
if a2half == b2half:
  print(m.ceil(a2half))
else:
  n = N-B
  if A>= n:
    print(m.ceil(n/2 +A-n+dif))
  else:
    print(m.ceil(n/2+dif))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

def hoge(a,b):
    oo = [-1]
    if a % 2 == b % 2:
        oo.append(abs(a-b)//2)
    if a == 0 or b == 0:
        c = max(a,b)
        oo.append(c)
        oo.append(N-c)
    if a == N-1 or b == N-1:
        c = min(a,b)
        oo.append(c)
        oo.append(N-c)
    return min(oo)

N -= 1
L,R = sorted([A,B])
L -= 1
R -= 1

a = hoge(L,R)
if a > 0:
    o['a'] = a
else:
    o['b1'] = L + hoge(0,R-L-1) + 1
    o['b2'] = L + hoge(0,R-L+1) + 1
    o['c1'] = R + hoge(N,R+L-1) + 1
    o['c2'] = R + hoge(N,R+L+1) + 1

print(min(o.values()))

Submission status: Wrong Answer

Solution code:
from sys import stdin
N,A,B = [int(x) for x in stdin.readline().rstrip().split()]
if (B - A) % 2 == 0:
    print((B-A)//2)
else:
    ans1 = 0
    a1 = A
    b1 = B
    ans1 += (a1-1)
    a1 = 1
    b1 -= (a1-1)
    if b1 % 2 == 0:
        b1 -= 1
        ans1 += 1
    ans1 += ((b1 -1)//2)
    
    ans2 = 0
    a2 = A
    b2 = B
    ans2 += (N-B)
    a2 += (N-B)
    b2 += (N-B)
    if (a2 % 2) != (b2 % 2):
        a2 += 1
        ans2 += 1
    ans2 += ((b2 - a2)//2)
    print(min(ans1,ans2,B-1,N-A))

Submission status: Wrong Answer

Solution code:
from sys import stdin
lines = stdin.readlines()
 
N, A, B = map(int, lines[0].split())
 
a = B - A
b = N - B
 
if a % 2 == 0:
  print(int(a / 2))  
else:
  if b >= A:
    print(A - 1)
  else:
    print(b)

Submission status: Wrong Answer

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

if sa%2!=0:
  print(min(a, n-b))
else:
  print(int(sa/2))

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
if (B-A)%2==0:
  print(int(abs((B-A)/2)))
elif (B-A)%2!=0:
  if A<B and (A-1)<=(N-B):
    print(abs(B-1))
    exit()
  elif A<B and (A-1)>=(N-B):
    print(abs(N-A))
    exit()
  elif B<A and (B-1)<=(N-A):
    print(abs(A-1))
    exit()
  elif B<A and (B-1) >= (N-A):
    print(abs(N-B))
    exit()

Submission status: Wrong Answer

Solution code:
import math
n,a,b = map(int,input().split())
ans =0
if (a-b)%2 ==0:
    print(int(abs((a-b))/2))
else:
    if n-min(a,b)<max(a,b)-1:
        ans+=n - max(a,b)
        ans+=int((n-(min(a,b)+n - max(a,b)+1))/2)
        print(ans)
    else:
        ans+=min(a,b)-1
        ans+=math.ceil((max(a,b)-(min(a,b)-1+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:
    e = min(b - 1, n - a)
    f = min(a, n - b) + d//2 + 1
    print(min(e, f))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math
N,A,B = map(int,input().split())
if B==A:
    print(0)
if B-A+1 == 0:
    if B-1 >= N-A:
        print(N-A)
    else:
        print(B-1)

if abs(B-A+1)%2 ==1 :
    print(math.ceil(abs(B-A)/2))

else: 
    print(math.ceil((B-A-1)/2+1))
    """print(math.ceil((B-A)/2))
    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 B-1 < N - A:
        print(B-1)"""





    """if B-1 > N - A:
        print(N-A)
    elif N-A > B-1:
        print(B-1)"""

Submission status: Wrong Answer

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

def hoge(a,b):
    oo = [-1]
    if a % 2 == b % 2:
        oo.append(abs(a-b)//2)
    if a == 0 or b == 0:
        c = max(a,b)
        oo.append(c)
        oo.append(N-c)
    if a == N or b == N:
        c = min(a,b)
        oo.append(c)
        oo.append(N-c)
    return min(oo)

N -= 1
L,R = sorted([A,B])
L -= 1
R -= 1

a = hoge(L,R)
if a > 0:
    o['a'] = a
else:
    o['b1'] = L + hoge(0,R-L-1) + 1
    o['b2'] = L + hoge(0,R-L+1) + 1
    o['c1'] = R + hoge(N,R+L-1) + 1
    o['c2'] = R + hoge(N,R+L+1) + 1

print(min(o.values()))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:

# 入力 =stdin.readline().rstrip()
# 分割 = stdin.readline().rstrip().split()

'''
条件に合うものを絞り込む
data = [1, 2, 3]
s = [x for x in data if x % 3 == 0]
'''

'''
文字配列を数値に
l_si = ['-10', '0', '100']

l_si_i = [int(s) for s in l_si]
'''

'''
a = [2, 4, 6, 8]
b = [3, 6, 9]

print(list(set(a) | set(b)))  # 和集合
print(list(set(a) & set(b)))  # 積集合
'''

'''
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
count = 0
while len([x for x in A if x % 2 == 0]) == N:
    A = list(map(lambda y: y / 2, A))
    count += 1
print(count)
'''

'''
.append(要素)
.extend(要素)
.insert(場所,要素)
del 配列名[場所]
-1で末尾で末尾から一つ前
'''
'''
間に空白追加
' '.join(lis)
'''
'''
copy.copy(配列名)6

'''
'''
sort()50
sorted(reverse=true)
'''
'''
2分探索
bisect.bisect_left(リスト, 要素)
'''


from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
l_si_i = [int(s) for s in stdin.readline().rstrip().split()]
n = l_si_i[0]
a = l_si_i[1]
b = l_si_i[2]

num = b - a


if num % 2 == 0:
    print(int(num / 2))
elif num % 2 == 1:

    res1 = int(a - 1)
    b1 = b - (a - 1)
    a1 = 1
    num1 = b1 - a1
    if num1 % 2 != 0:
        res1 += 1
        b1 -= 1
    res1 += int((b1 - a1)/2)

    res2 = int(n - b)
    a2 = n-b+a
    b2 = n
    num2 = b2 - a2
    if num2 % 2 != 0:
        res2 += 1
        a2 += 1
    res2 += int((b2 - a2) / 2)
    res = 0
    if res1 <= res2:
        res = res1
    else:
        res = res2
    print(res)

Submission status: Wrong Answer

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

minum = b-c-1
res = 0


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

Submission status: Wrong Answer

Solution code:
N,A,B = map(int,input().split()) #intでインプット
dif=abs(A-B)
if dif%2==0:
    print(int(dif/2))
elif dif%2==1:
    dis_1=(N-A)+(N-B)
    dis_2=(A-1)+(B-1) 
    if dis_1%2==0:
        half_1=dis_1/2
    elif dis_1%2==1:
        half_1=int((dis_1+1)/2)
    if dis_2%2==0:
        half_2=dis_2/2
    elif dis_2%2==1:
        half_2=int((dis_2+1)/2)
    print(min(half_1, half_2))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

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:
        if left_s < right_s:
            tmp_s = (B - A + left_s)/2
            if tmp_s < 1:
                tmp_s = 1
            return left_s + tmp_s
        else:
            tmp_s = (B - A + right_s)/2
            if tmp_s < 1:
                tmp_s = 1
            return right_s + tmp_s
    
if __name__ == '__main__':
    print(int(main()))

Submission status: Wrong Answer

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

if (B - A) % 2 == 0:
    print(int((B-A)/2))
else:
    diff = N - B if A - 1 > N - B else A - 1
    flip = diff + 1
    distance = int((B - A - 1) / 2)
    x_1 = flip + distance
    x_2 = x_1 if N - A - 1 > x_1 else N - A - 1
    x_3 = x_2 if B - 2 > x_2 else B - 2
    print(x_3)

Submission status: Wrong Answer

Solution code:
from fractions import Fraction
li = list(map(int,input().split()))


if (li[2]-li[1])%2==0:
    print(int((li[2]-li[1])/2))
else:
    x=min(li[0]-li[2],li[1]-1)
    y=Fraction(li[2]-li[1]-1,2)+1
    print(x+y)

Submission status: Wrong Answer

Solution code:
from sys import stdin
lines = stdin.readlines()
 
N, A, B = map(int, lines[0].split())

a = B - A
b = N - B

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

Submission status: Wrong Answer

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

Half = (A + B)//2

if Half == (A + B)/2:
    if Half >= A:
        print(Half - A)
    elif Half < A:
        print(A - Half)
else:
    if N/2 > A and N/2 >= B:
        print(B - 1)
    elif N/2 <= A and N/2 < B:
        print(N - A)
    elif B > N/2 > A:
        if (N - A) < (B - 1):
            print((B - A + 1)//2)
        elif (N - A) > (B - 1):
            print((A + B)//2)
        else:
            print(N//2)

Submission status: Wrong Answer

Solution code:
def main():
    v = input().split(' ')
    n = int(v[0])
    a = int(v[1])
    b = int(v[2])

    dis = abs(a - b)
    if dis % 2 == 0:
        print(int(dis / 2))
    else:
        na = n - a
        nb = n - b
        ndis = min(na, nb)
        a1 = a - 1
        b1 = b - 1
        idis = min(a1, b1)
        v1 = min(max(na, nb), max(a1, b1))
        v2 = min(ndis + 1 + int((max(na, nb) - ndis) / 2), idis + 1 + int((max(a1, b1) - idis) / 2))
        print(int(min(v1, v2)))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:

# 入力 =stdin.readline().rstrip()
# 分割 = stdin.readline().rstrip().split()

'''
条件に合うものを絞り込む
data = [1, 2, 3]
s = [x for x in data if x % 3 == 0]
'''

'''
文字配列を数値に
l_si = ['-10', '0', '100']

l_si_i = [int(s) for s in l_si]
'''

'''
a = [2, 4, 6, 8]
b = [3, 6, 9]

print(list(set(a) | set(b)))  # 和集合
print(list(set(a) & set(b)))  # 積集合
'''

'''
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
count = 0
while len([x for x in A if x % 2 == 0]) == N:
    A = list(map(lambda y: y / 2, A))
    count += 1
print(count)
'''

'''
.append(要素)
.extend(要素)
.insert(場所,要素)
del 配列名[場所]
-1で末尾で末尾から一つ前
'''
'''
間に空白追加
' '.join(lis)
'''
'''
copy.copy(配列名)6

'''
'''
sort()50
sorted(reverse=true)
'''
'''
2分探索
bisect.bisect_left(リスト, 要素)
'''


from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
l_si_i = [int(s) for s in stdin.readline().rstrip().split()]
n = l_si_i[0]
a = l_si_i[1]
b = l_si_i[2]

num = b - a


if num % 2 == 0:
    print(int(num / 2))
elif num % 2 == 1:

    res1 = a - 1
    b1 = b - (a - 1)
    a1 = 1
    num1 = b1 - a1
    if num1 % 2 != 0:
        res1 += 1
        b1 -= 1
    res1 += int((b1 - a1)/2)

    res2 = n - b
    a2 = n-b+a
    b2 = n
    num2 = b2 - a2
    if num2 % 2 != 0:
        res2 += 1
        a2 += 1
    res2 += int((b2 - a2) / 2)
    res = 0
    if res1 <= res2:
        res = res1
    else:
        res = res2
    print(res)

Submission status: Wrong Answer

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

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 = int(Lab/2)
else:
    #case Lab is odd
        ans1 = La + 1 + int((Lab-1)/2)
        ans2 = Lb + 1 + int((Lab-1)/2)
        ans = min(ans1,ans2)
        
print(ans)

Submission status: Wrong Answer

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

diff = B-A
if diff%2 == 0:
    print(int(diff/2))
elif((N-B) > (A-1)):
    if diff == 1:
        print(B-1)
    else:
        path = A + (B-A-1)/2
        print(int(path))
else:
    if diff == 1:
        print(N-A)
    else:
        path = N-B + 1 + (B-A-1)/2
        print(int(path))

Submission status: Wrong Answer

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

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

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 a==1 and b==n:
        print(n-1)
    else:
        if n-b < a-1:
            print(n-a)
        elif n-b > a-1:
            print(b-1)
        else:
            print(n-a)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math

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

# print(N)
# print(A)
# print(B)

ans = 0

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

Submission status: Wrong Answer

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

if (b-a)%2==0:
    print(int((b-a)/2))
else:
    if b-a==1:
        if a-1 < n-b:
            print(a)
        else:
            print(n-a)
    else:
        if a==1 or b==n:
            print(int((b-a-1)/2+1))
        elif a-1 < n-b:
            #print(b-1-1)
            print(int(a+(b-a-1)/2))
        else:
            print(int(n-b+1+(n-(a+n-b+1))/2))

Submission status: Wrong Answer

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

if diff % 2 == 0:
    print(diff // 2)

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

    if gap_n < gap_1:
        n = N-A if N-A > N-B else N-B
        print(n)
    else:
        n = A if A-1 < B-1 else B
        print(n)

Submission status: Wrong Answer

Solution code:
X,A,B = map(int,input().split())
if A+B %2 == 0:
    A_min = A- 1
    B_min = X - B
    AB_div = A - B
    if A_min - B_min < 0:
    	if B_min < AB_div:
    		print(AB_div)
    	else:
    		print(A_div)
    else:
    	if B_min < AB_div:
    		print(AB_div)
    	else:
    		print(B_min)
else:
	A_min = A-1
	B_min = X - B
	if A_min < B_min:
		print(B)
	else:
		print(X-A)

Submission status: Wrong Answer

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

if a==1 and b==n:
  print((b//2)+1)
else:
  if (b-a) % 2 == 0:
    print(rs)
  else:
    if a==1 and b==n:
      print(b//2)
    elif (a-1) > (n-b):
      print(rs+(n-b+1))
    else:
      print(rs+a)

Submission status: Wrong Answer

Solution code:
X,A,B = map(int,input().split())
if A+B %2 == 0:
    A_min = A- 1
    B_min = X - B
    AB_div = A - B
    if A_min - B_min > 0:
    	if B_min < AB_div:
    		print(AB_div)
    	else:
    		print(B_div)
    else:
    	if A_min < AB_div:
    		print(AB_div)
    	else:
    		print(A_min)
else:
	A_min = A-1
	B_min = X - B
	if A_min < B_min:
		print(B_min)
	else:
		print(A_min)

Submission status: Wrong Answer

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


def main():
    N, A, B = map(int, input().split())
    diff = B - A
    if diff % 2 == 0:
        print(int(diff / 2))
    else:
        diff = B + A - 1
        print(int(diff / 2))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math
N,A,B = map(int,input().split())
if B-A+1 == 0:
    if B-1 >= N-A:
        print(N-A)
    else:
        print(B-1)

if abs(B-A+1)%2 ==1 :
    print(math.ceil(abs(B-A)/2))

else: 
    print(math.ceil((B-A-1)/2+1))
    """print(math.ceil((B-A)/2))
    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 B-1 < N - A:
        print(B-1)"""





    """if B-1 > N - A:
        print(N-A)
    elif N-A > B-1:
        print(B-1)"""