Buggy python submission (verdict: Runtime Error):
n,a,b = map(int,input().split())
i = 1
p = 0
if (b-a)%2==0:
    print((b-a)//2)
else:
    print(min(b-1,n-a,round((a-1+b-(a-1))/2),round((n-b+a+(n-b))/2)))

Fixed submission:
n,a,b = map(int,input().split())
i = 1
p = 0
if (b-a)%2==0:
    print((b-a)//2)
else:
    if a-1 < n-b:
        print(min((1+b+(a-2))//2,b-1))
    else:
        print(min((n-a+(n-b+1))//2,n-a))

Buggy python submission (verdict: Time Limit Exceeded):
n,a,b = map(int,input().split())
i = 1
p = 0
if (b-a)%2==0:
    print((b-a)//2)
else:
    if a <= (n//2):
        for i in range(1,n):
            b -= 1
            if p == 1:
                a += 1
            elif a <= 1:
                a = 1
                p += 1
            else:
                a -= 1
            if a == b:
                print(i)
                break
    else:
        for i in range(1,n):
            a += 1
            if p == 1:
                b -= 1
            elif b >= n:
                b = n
                p += 1
            else:
                b += 1
            if a == b:
                print(i)
                break

Fixed submission:
n,a,b = map(int,input().split())
i = 1
p = 0
if (b-a)%2==0:
    print((b-a)//2)
else:
    if a-1 < n-b:
        print(min((1+b+(a-2))//2,b-1))
    else:
        print(min((n-a+(n-b+1))//2,n-a))

Buggy python submission (verdict: Time Limit Exceeded):
import math
n,a,b = map(int,input().split())
i = 1
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

Fixed submission:
n,a,b = map(int,input().split())
i = 1
p = 0
if (b-a)%2==0:
    print((b-a)//2)
else:
    if a-1 < n-b:
        print(min((1+b+(a-2))//2,b-1))
    else:
        print(min((n-a+(n-b+1))//2,n-a))

Buggy python submission (verdict: Time Limit Exceeded):
import math
n,a,b = map(int,input().split())

if (b-a)%2==0:
    print((b-a)//2)
else:
    if n >= 10**5:
        if a < math.floor(n/2):
            i = 0
            while True:
                b -= i
                if a <= 1:
                    a = 1
                else:
                    a -= i
                if a == b:
                    a += 10000
                    b += 10000
                    for j in range(1,10001):
                        a -= j
                        b -= j
                        if a <= 1:
                            a = 1
                        if a == b:
                            print(i+j)
                            break
                    break
                i += 10000
        else:
            i = 0
            while True:
                a += i
                if b >= n:
                    b = n
                else:
                    b += i
                if a == b:
                    a -= 10000
                    b -= 10000
                    for j in range(1,10001):
                        a += j
                        b += j
                        if b >= n:
                            b = n
                        if a == b:
                            print(i+j)
                            break
                    break
                i += 10000
    else:
        if a < math.floor(n/2):
            i = 0
            while True:
                b -= i
                if a <= 1:
                    a = 1
                else:
                    a -= i
                if a == b:
                    print(i)
                    break
                i += 1
        else:
            i = 0
            while True:
                a += i
                if b >= n:
                    b = n
                else:
                    b += i
                if a == b:
                    print(i)
                    break
                i += 1
    
#min  median max

Fixed submission:
n,a,b = map(int,input().split())
i = 1
p = 0
if (b-a)%2==0:
    print((b-a)//2)
else:
    if a-1 < n-b:
        print(min((1+b+(a-2))//2,b-1))
    else:
        print(min((n-a+(n-b+1))//2,n-a))

Buggy python submission (verdict: Time Limit Exceeded):
import math
n,a,b = map(int,input().split())

if (b-a)%2==0:
    print((b-a)//2)
else:
    if n >= 10**5:
        if a < math.floor(n/2):
            i = 0
            while True:
                a -= i
                b -= i
                if a <= 1:
                    a = 1
                if a == b:
                    a += 1000
                    b += 1000
                    for j in range(1,1001):
                        a -= j
                        b -= j
                        if a <= 1:
                            a = 1
                        if a == b:
                            print(i+j)
                            break
                    break
                i += 1000
        else:
            i = 0
            while True:
                a += i
                b += i
                if b >= n:
                    b = n
                if a == b:
                    a -= 1000
                    b -= 1000
                    for j in range(1,1001):
                        a += j
                        b += j
                        if b >= n:
                            b = n
                        if a == b:
                            print(i+j)
                            break
                    break
                i += 1000
    else:
        if a < math.floor(n/2):
            i = 0
            while True:
                a -= i
                b -= i
                if a <= 1:
                    a = 1
                if a == b:
                    print(i)
                    break
                i += 1
        else:
            i = 0
            while True:
                a += i
                b += i
                if b >= n:
                    b = n
                if a == b:
                    print(i)
                    break
                i += 1


Fixed submission:
n,a,b = map(int,input().split())
i = 1
p = 0
if (b-a)%2==0:
    print((b-a)//2)
else:
    if a-1 < n-b:
        print(min((1+b+(a-2))//2,b-1))
    else:
        print(min((n-a+(n-b+1))//2,n-a))

Buggy python submission (verdict: Time Limit Exceeded):
import math
n,a,b = map(int,input().split())

if (b-a)%2==0:
    print((b-a)//2)
else:
    if a < math.floor(n/2):
        i = 0
        while True:
            b -= i
            if a <= 1:
                a = 1
            else:
                a -= i
            if a == b:
                print(i)
                break
            i += 1
    else:
        i = 0
        while True:
            a += i
            if b >= n:
                b = n
            else:
              b += i
            if a == b:
                print(i)
                break
            i += 1

Fixed submission:
n,a,b = map(int,input().split())
i = 1
p = 0
if (b-a)%2==0:
    print((b-a)//2)
else:
    if a-1 < n-b:
        print(min((1+b+(a-2))//2,b-1))
    else:
        print(min((n-a+(n-b+1))//2,n-a))

Buggy python submission (verdict: Time Limit Exceeded):
import math
n,a,b = map(int,input().split())

if (b-a)%2==0:
    print((b-a)//2)
else:
    if a < math.floor(n/2):
        i = 0
        while True:
            a -= i
            b -= i
            if a <= 1:
                a = 1
            if a == b:
                print(i)
                break
            i += 1
    else:
        i = 0
        while True:
            a += i
            b += i
            if b >= n:
                b = n
            if a == b:
                print(i)
                break
            i += 1
    
#min  median max

Fixed submission:
n,a,b = map(int,input().split())
i = 1
p = 0
if (b-a)%2==0:
    print((b-a)//2)
else:
    if a-1 < n-b:
        print(min((1+b+(a-2))//2,b-1))
    else:
        print(min((n-a+(n-b+1))//2,n-a))