Buggy python submission (verdict: Runtime Error):
i = input()
N, A, B = i.split(' ')

N = int(N)
A = int(A)
B = int(B)

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

Fixed submission:
i = raw_input()
N, A, B = i.split()

N = int(N)
A = int(A)
B = int(B)

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

Buggy python submission (verdict: Runtime Error):
# Function for calc
def match(n, a, b):
    if (b - a)% 2 == 0:
        print((b-a)/2)
    else:
        if (n - b) > a:
            print((a)+((b-(a+1))/2))
        else:
            x=(n-b+1)
            print(x+((n-(a+x))/2))
# Run match
in_string = input()
N = int(in_string[0])
A = int(in_string[1])
B = int(in_string[2])

match(N, A, B)

Fixed submission:
# Function for calc
def match(n, a, b):
    if (b - a)% 2 == 0:
        print((b-a)/2)
    else:
        if (n - b) >= a:
            print((a)+((b-(a+1))/2))
        else:
            x=(n-b+1)
            print(x+((n-(a+x))/2))
# Run match
in_string = raw_input()
[N, A, B] = [int(v) for v in in_string.split()]
match(N, A, B)

Buggy python submission (verdict: Runtime Error):
from sys import argv

# Function for calc
def match(n, a, b):
    if (b - a)% 2 == 0:
        print((b-a)/2)
    else:
        if (n - b) > a:
            print((a)+((b-(a+1))/2))
        else:
            x=(n-b+1)
            print(x+((n-(a+x))/2))
# Run match
match(int(argv[1]), int(argv[2]), int(argv[3]))

Fixed submission:
# Function for calc
def match(n, a, b):
    if (b - a)% 2 == 0:
        print((b-a)/2)
    else:
        if (n - b) >= a:
            print((a)+((b-(a+1))/2))
        else:
            x=(n-b+1)
            print(x+((n-(a+x))/2))
# Run match
in_string = raw_input()
[N, A, B] = [int(v) for v in in_string.split()]
match(N, A, B)

Buggy python submission (verdict: Runtime Error):
from sys import argv

# Function for calc
def match(n, a, b):
    if (b - a)% 2 == 0:
        print((b-a)/2)
    else:
        if (n - b) > a:
            print((a)+((b-(a+1))/2))
        else:
            x=(n-b+1)
            print(x+((n-(a+x))/2))
# Run match
match(int(argv[1]), int(argv[2]), int(argv[3]))

Fixed submission:
# Function for calc
def match(n, a, b):
    if (b - a)% 2 == 0:
        print((b-a)/2)
    else:
        if (n - b) >= a:
            print((a)+((b-(a+1))/2))
        else:
            x=(n-b+1)
            print(x+((n-(a+x))/2))
# Run match
in_string = raw_input()
[N, A, B] = [int(v) for v in in_string.split()]
match(N, A, B)

Buggy python submission (verdict: Runtime Error):
from sys import argv

# Function for calc
def match(n, a, b):
    if (b - a)% 2 == 0:
        print((b-a)/2)
    else:
        mid = (n / 2)
        if (n - a) > b:
            print(b)
        else:
            print(n-a-1)

# Run match
match(int(argv[1]), int(argv[2]), int(argv[3]))


Fixed submission:
# Function for calc
def match(n, a, b):
    if (b - a)% 2 == 0:
        print((b-a)/2)
    else:
        if (n - b) >= a:
            print((a)+((b-(a+1))/2))
        else:
            x=(n-b+1)
            print(x+((n-(a+x))/2))
# Run match
in_string = raw_input()
[N, A, B] = [int(v) for v in in_string.split()]
match(N, A, B)

Buggy python 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)))


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

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


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 python 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])

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 python 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])

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 python submission (verdict: Runtime Error):
def min_steps_v2(n, a, b):
    n = np.int64(n)
    a = np.int64(a)
    b = np.int64(b)

    if (b - a) % 2 == 0:
        return np.int64(int(b - a) // 2)
 
    # odd case
    a_diff = a - 1
    b_diff = n - b
 
    if a_diff > b_diff:
      steps_to_even = n - b + 1
      remain_steps = min_steps_v2(n, a + (n - b) + 1, n)
    else:
      steps_to_even = a
      remain_steps = min_steps_v2(n, 1, b - a)
 
    return steps_to_even + remain_steps

numbers = input().split(' ')
 
n = int(numbers[0])
a = int(numbers[1])
b = int(numbers[2])
 
print(min_steps_v2(n, a, b))


Fixed submission:
import numpy as np

def min_steps_v2(n, a, b):
    n = np.int64(n)
    a = np.int64(a)
    b = np.int64(b)

    if (b - a) % 2 == 0:
        return np.int64(int(b - a) // 2)
 
    # odd case
    a_diff = a - 1
    b_diff = n - b
 
    if a_diff > b_diff:
      steps_to_even = n - b + 1
      remain_steps = min_steps_v2(n, a + (n - b) + 1, n)
    else:
      steps_to_even = a
      remain_steps = min_steps_v2(n, 1, b - a)
 
    return steps_to_even + remain_steps

numbers = input().split(' ')
 
n = int(numbers[0])
a = int(numbers[1])
b = int(numbers[2])
 
print(min_steps_v2(n, a, b))

Buggy python submission (verdict: Runtime Error):
def min_steps_v2(n, a, b):
    if (b - a) % 2 == 0:
        return int((b - a) / 2)
 
    # odd case
    a_diff = a - 1
    b_diff = n - b
 
    if a_diff > b_diff:
      steps_to_even = n - b + 1
      remain_steps = min_steps_v2(n, A + (N - B) + 1, N)
    else:
      steps_to_even = a
      remain_steps = min_steps_v2(n, 1, b - a)
 
    return int(steps_to_even + remain_steps)
 
numbers = input().split(' ')
 
n = int(numbers[0])
a = int(numbers[1])
b = int(numbers[2])
 
print(min_steps_v2(n, a, b))


Fixed submission:
import numpy as np

def min_steps_v2(n, a, b):
    n = np.int64(n)
    a = np.int64(a)
    b = np.int64(b)

    if (b - a) % 2 == 0:
        return np.int64(int(b - a) // 2)
 
    # odd case
    a_diff = a - 1
    b_diff = n - b
 
    if a_diff > b_diff:
      steps_to_even = n - b + 1
      remain_steps = min_steps_v2(n, a + (n - b) + 1, n)
    else:
      steps_to_even = a
      remain_steps = min_steps_v2(n, 1, b - a)
 
    return steps_to_even + remain_steps

numbers = input().split(' ')
 
n = int(numbers[0])
a = int(numbers[1])
b = int(numbers[2])
 
print(min_steps_v2(n, a, b))

Buggy python submission (verdict: Runtime Error):
numbers = raw_input().split(' ')

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

def even_diff(A, B):
  return (B - A) / 2


def odd_diff(N, A, B):
  a_diff = A - 1
  b_diff = N - B
  
  if a_diff > b_diff:
    return N - A
  else:
    return B - 1

if (a - b) % 2 == 0:
  result = even_diff(a, b)
else:
  result = odd_diff(n, a, b)    
  
print(result)

Fixed submission:
import numpy as np

def min_steps_v2(n, a, b):
    n = np.int64(n)
    a = np.int64(a)
    b = np.int64(b)

    if (b - a) % 2 == 0:
        return np.int64(int(b - a) // 2)
 
    # odd case
    a_diff = a - 1
    b_diff = n - b
 
    if a_diff > b_diff:
      steps_to_even = n - b + 1
      remain_steps = min_steps_v2(n, a + (n - b) + 1, n)
    else:
      steps_to_even = a
      remain_steps = min_steps_v2(n, 1, b - a)
 
    return steps_to_even + remain_steps

numbers = input().split(' ')
 
n = int(numbers[0])
a = int(numbers[1])
b = int(numbers[2])
 
print(min_steps_v2(n, a, b))

Buggy python submission (verdict: Runtime Error):
strargs = input()

n, a, b = map(lambda x: int(x), strargs)

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

else:
  print(b - 1)

Fixed submission:
strargs = input()

n, a, b = map(lambda x: int(x), strargs.split())

if (b - a) % 2 == 0:
  print((b - a)//2)
  
elif a - 1 < n - b:
  newB = b - a
  mid = (newB - 1)//2 + 1
  print(a + mid - 1)

else:
  newA = (a + (n - b + 1))
  mid = newA + (n - newA)//2
  print((n - b + 1) + (n - newA)//2)

Buggy python submission (verdict: Runtime Error):
strargs = [10, 3, ]

n, a, b = map(lambda x: int(x), strargs)

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

else:
  print(b - 1)

Fixed submission:
strargs = input()

n, a, b = map(lambda x: int(x), strargs.split())

if (b - a) % 2 == 0:
  print((b - a)//2)
  
elif a - 1 < n - b:
  newB = b - a
  mid = (newB - 1)//2 + 1
  print(a + mid - 1)

else:
  newA = (a + (n - b + 1))
  mid = newA + (n - newA)//2
  print((n - b + 1) + (n - newA)//2)