Problem p02823 (python)

Fixed submission:
in_string = raw_input()
in_arr = in_string.split()
N = int(in_arr[0])
A = int(in_arr[1])
B = int(in_arr[2])

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

Buggy submission (verdict: Runtime Error):
in_string = input()
in_arr = in_string.split()
N = int(in_arr[0])
A = int(in_arr[1])
B = int(in_arr[2])

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

Buggy submission (verdict: Runtime Error):
in_string = input()
in_arr = in_string.split()
N = in_arr[0]
A = in_arr[1]
B = in_arr[2]

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

Buggy submission (verdict: Runtime Error):
import numpy as np

in_string = input()
in_arr = in_string.split()
N = np.int64(in_arr[0])
A = np.int64(in_arr[1])
B = np.int64(in_arr[2])

if ((A-B) % np.int64(2)) == np.int64(0):
    print(np.int64((B-A)/np.int64(2)))
else:
    if (N-B) > A-np.int64(1):
        print(int(A+((B-A)-1)/2)
    else:
        print(int(N-B+1+(N-(A+N-B+1))/2))

Buggy submission (verdict: Runtime Error):
import math

finished = False
solutions = []

def rec(A, B, n):
    global solutions
    global N

    if (A == B):
        solutions.append(n)

    if (math.floor(N/2) > n):
        if A == 1:
                rec(A+1, B+1, n+1)
                rec(A+1, B-1, n+1)
                rec(A, B+1, n+1)
                rec(A, B-1, n+1)
        elif A == N:
                rec(A, B+1, n+1)
                rec(A, B-1, n+1)
                rec(A-1, B+1, n+1)
                rec(A-1, B-1, n+1)
        elif B == 1:
                rec(A+1, B+1, n+1)
                rec(A+1, B, n+1)
                rec(A-1, B+1, n+1)
                rec(A-1, B, n+1)
        elif B == N:
                rec(A+1, B, n+1)
                rec(A+1, B-1, n+1)
                rec(A-1, B, n+1)
                rec(A-1, B-1, n+1)
        else:
                rec(A+1, B+1, n+1)
                rec(A+1, B-1, n+1)
                rec(A-1, B+1, n+1)
                rec(A-1, B-1, n+1)

in_string = input()
in_arr = in_string.split()
global N
global A
global B
N = int(in_arr[0])
A = int(in_arr[1])
B = int(in_arr[2])

rec(A, B, 0)
solutions.sort()
print(solutions[0])

Buggy submission (verdict: Runtime Error):
finished = False
solutions = []

def rec(A, B, n):
    global finished
    global solutions

    if (A == B):
        finished = True
        solutions.append(n)

    if not finished:
        if A == 1:
                rec(A+1, B+1, n+1)
                rec(A+1, B-1, n+1)
                rec(A, B+1, n+1)
                rec(A, B-1, n+1)
        elif A == N:
                rec(A, B+1, n+1)
                rec(A, B-1, n+1)
                rec(A-1, B+1, n+1)
                rec(A-1, B-1, n+1)
        elif B == 1:
                rec(A+1, B+1, n+1)
                rec(A+1, B, n+1)
                rec(A-1, B+1, n+1)
                rec(A-1, B, n+1)
        elif B == N:
                rec(A+1, B, n+1)
                rec(A+1, B-1, n+1)
                rec(A-1, B, n+1)
                rec(A-1, B-1, n+1)
        else:
                rec(A+1, B+1, n+1)
                rec(A+1, B-1, n+1)
                rec(A-1, B+1, n+1)
                rec(A-1, B-1, n+1)

while True:
    in_string = input("Input in the Format: N A B, where N stands for the Number of Tables, A for the Position of Player A and B Position of Player B:\n")
    if len(in_string) == 5:
        in_arr = in_string.split()
        global N
        global A
        global B
        N = int(in_arr[0])
        A = int(in_arr[1])
        B = int(in_arr[2])

        if 2 <= N <= pow(10,18) and 1 <= A < B <= N:
            break
        else:
            print("Input Invalid, try again")
    else:
        print("Input Invalid, try again")

rec(A, B, 0)
solutions.sort()
print(solutions[0])