Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a,b=map(int,inout().split())
if a>=0:
    print("Positive" if a!=0 else "Zero")
if a<0 and b>0:
    print("Zero")
if b<=0:
    if b==0:
        print("Zero")
    else:
        if (a-b+1)%2==0:
            print("Positive")
        else:
            print("Negative")

Fixed submission:
a,b=map(int,input().split())
if a>=0:
    print("Positive" if a!=0 else "Zero")
if a<0 and b>0:
    print("Zero")
if b<=0:
    if b==0:
        print("Zero")
    else:
        if (a-b+1)%2==0:
            print("Positive")
        else:
            print("Negative")

Buggy python submission (verdict: Time Limit Exceeded):
a,b=map(int,input().split())
ne=[]
po=[]
for i in range(a,b+1):
    if i<0:
        ne.append(i)
    if i>0:
        po.append(i)
    if i==0:
        print("Zero")
        exit()
if len(po)==0:
    print("Positive" if len(ne)%2==0 else "Negative")
else:
    print("Positive")

Fixed submission:
a,b=map(int,input().split())
if a>=0:
    print("Positive" if a!=0 else "Zero")
if a<0 and b>0:
    print("Zero")
if b<=0:
    if b==0:
        print("Zero")
    else:
        if (a-b+1)%2==0:
            print("Positive")
        else:
            print("Negative")
Buggy python submission (verdict: Runtime Error):
def survey(A, B, Ai, Bi, AMax, BMax, answer, reqTime, K):
    if(reqTime > K):
        return answer - 1
    else:
        if(Ai == AMax and Bi == BMax):
            return answer
        elif(Ai == AMax):
            return survey(A, B, Ai, Bi + 1, AMax, BMax, answer + 1, reqTime + B[Bi], K)
        elif(Bi == BMax):
            return survey(A, B, Ai + 1, Bi, AMax, BMax, answer + 1, reqTime + A[Ai], K)
        else:
            return max(survey(A, B, Ai + 1, Bi, AMax, BMax, answer + 1, reqTime + A[Ai], K), survey(A, B, Ai, Bi + 1, AMax, BMax, answer + 1, reqTime + B[Bi], K))
        
def main():
    N, M, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    A = A
    B = B

    AMax = len(A)
    BMax = len(B)

    answer = 0
    reqTime = 0

    Ai = 0
    Bi = 0

    answer = survey(A, B, Ai, Bi, AMax, BMax, answer, reqTime, K)
    print(answer)

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    N, M, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    AReqTime = [0]
    BReqTime = [0]

    for i in range(N):
        AReqTime.append(AReqTime[i] + A[i])
    for i in range(M):
        BReqTime.append(BReqTime[i] + B[i])

    j = M
    answer = 0

    for i in range(N + 1):
        if(AReqTime[i] > K):
            break

        while BReqTime[j] > K - AReqTime[i]:
            j = j - 1

        answer = max(i + j, answer)

    print(answer)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    AList = list(map(int, input().split()))

    answer = 0

    for i in range(N):

        for j in range(N):

            if((i != j) and AList[i] % AList[j] == 0):
                break

        else:
            answer = answer + 1

    print(answer)


if __name__ == "__main__":
    main()

Fixed submission:
def main():
    N = int(input())
    AList = list(map(int, input().split()))
    AList.sort()
    AMax = AList[-1] + 1

    dp = [True] * AMax
    answer = 0

    ACheckSet = set()
    ACheckSetCheckSet = set()

    for A in AList:

        if dp[A]:
            answer = answer + 1
            ACheckSet.add(A)

            for x in range(A, AMax, A):
                dp[x] = False

        elif A in ACheckSet:

            if A in ACheckSetCheckSet:
                pass
            else:
                answer = answer - 1
                ACheckSetCheckSet.add(A)

    print(answer)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    inputList = input().split()
    print(int(inputList[0]) * int(inputList[1]))

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    A, B = map(int, input().replace(".", "").split())
    print(A*B//100)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def oneNum(N):
    answer = 0

    while(N > 0):
        if(N >= 9):
            answer = answer + 9
        else:
            answer = answer + N
        
        N = N // 10

    return answer

def twoNum(N):
    answer = 0

    strN = str(N)
    topN = int(strN[0])
    lenN = len(strN)

    answer = answer + oneNum(int(strN[1:])) + (topN - 1) * oneNum(int('9' * (lenN - 1)))

    N = int('9' * (lenN - 1))

    while(N >= 10):
        N = N // 10
        answer = answer + 9 * oneNum(N)

    return answer

def main():
    N = int(input())
    K = int(input())

    answer = 0

    if(K == 1):
        answer = oneNum(N)

    elif(K == 2):
        answer = twoNum(N)

    else:
        strN = str(N)
        topN = int(strN[0])
        lenN = len(strN)

        answer = answer + twoNum(int(strN[1:])) + (topN - 1) * twoNum(int('9' * (lenN - 1)))

        N = int('9' * (lenN - 1))

        while(N >= 100):
            N = N // 10
            answer = answer + 9 * twoNum(N)

    print(answer)


if __name__ == "__main__":
    main()

Fixed submission:
#https://atcoder.jp/contests/abc154/tasks/abc154_e

def oneNum(N):
    answer = 0

    while(N > 0):
        if(N >= 9):
            answer = answer + 9
        else:
            answer = answer + N
        
        N = N // 10

    return answer

def twoNum(N):
    answer = 0

    strN = str(N)
    topN = int(strN[0])
    lenN = len(strN)

    if(lenN != 1):
        answer = answer + oneNum(int(strN[1:])) + (topN - 1) * oneNum(int('9' * (lenN - 1)))
        N = int('9' * (lenN - 1))

    while(N >= 10):
        N = N // 10
        answer = answer + 9 * oneNum(N)

    return answer

def main():
    N = int(input())
    K = int(input())

    answer = 0

    if(K == 1):
        answer = oneNum(N)

    elif(K == 2):
        answer = twoNum(N)

    else:
        strN = str(N)
        topN = int(strN[0])
        lenN = len(strN)

        answer = answer + twoNum(int(strN[1:])) + (topN - 1) * twoNum(int('9' * (lenN - 1)))

        N = int('9' * (lenN - 1))

        while(N >= 100):
            N = N // 10
            answer = answer + 9 * twoNum(N)

    print(answer)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import sys
N = int(input())
D = list(map(int,input().split()))
M = max(D)
countlist=[0] * M
ans=1

for i in D:
    countlist[i]+=1

if countlist[0]!=1 :
    print(0)
    sys.exit()

if D[0]!=0 :
    print(0)
    sys.exit()

for i in range(2,M+1):
    ans *= countlist[i-1]**countlist[i]

print(ans%998244353) 

Fixed submission:
def main():
    N = input()
    D_list = list(map(int, input().split()))

    if D_list[0] != 0:
        ans = 0
    
    else:
        maxD = max(D_list)
        count_ele_Dlist = [0] * (maxD + 1)

        for i in D_list:
            count_ele_Dlist[i] = count_ele_Dlist[i] + 1

        if count_ele_Dlist[0] == 1:
            ans = 1
            for i in range(1, maxD + 1):
                ans = (ans * count_ele_Dlist[i - 1] ** count_ele_Dlist[i]) % 998244353
        else:
            ans = 0
        
    print(ans)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    N = input()
    D_list = list(map(int, input().split()))

    maxD = max(D_list)
    count_nowD = D_list.count(0)
    lenD = len(count_nowD)

    if D_list.count(0) == 0:
        ans = 0
    elif count_nowD == lenD:
        ans = 1
    else:
        counter = 1
        ans = 1

        while counter <= maxD:
            count_beforeD = count_nowD
            count_nowD = D_list.count(counter)

            if(count_nowD == 0):
                ans = 0
                break

            ans = (ans * (count_beforeD ** count_nowD) % 998244353) % 998244353
            counter = counter + 1

    print(ans)

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    N = input()
    D_list = list(map(int, input().split()))

    if D_list[0] != 0:
        ans = 0
    
    else:
        maxD = max(D_list)
        count_ele_Dlist = [0] * (maxD + 1)

        for i in D_list:
            count_ele_Dlist[i] = count_ele_Dlist[i] + 1

        if count_ele_Dlist[0] == 1:
            ans = 1
            for i in range(1, maxD + 1):
                ans = (ans * count_ele_Dlist[i - 1] ** count_ele_Dlist[i]) % 998244353
        else:
            ans = 0
        
    print(ans)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = input()
    L = [int(i) for i in input().split()]
    dL = list(L)

    for i in range(len(L)):
        minL = min(L)
        print(dL.index(minL) + 1, end = " ")
        L.remove(minL)

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    N = input()
    L = [int(i) for i in input().split()]
    
    siL = sorted(range(len(L)), key=lambda k: L[k])
    for i in siL:
        print(i + 1, end=" ")

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = input()
    L = [int(i) for i in input().split()]

    sL = sorted(L)
    ans = []

    for num in sL:
        print(L.index(num) + 1, end=" ")

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    N = input()
    L = [int(i) for i in input().split()]
    
    siL = sorted(range(len(L)), key=lambda k: L[k])
    for i in siL:
        print(i + 1, end=" ")

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = input()
    L = [int(i) for i in input().split()]

    sL = sorted(L)

    ans = []
    
    sL = sorted(L)
    for num in sL:
        print(L.index(num) + 1, end=" ")

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    N = input()
    L = [int(i) for i in input().split()]
    
    siL = sorted(range(len(L)), key=lambda k: L[k])
    for i in siL:
        print(i + 1, end=" ")

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
from math import *
import sys

N = int(input())
all_input_list = [list(map(int, input().split())) for i in range(N)]
x, y, h = [all_input_list[i] for i in range(N) if all_input_list[i][2] > 0][0]
for cx in range(101):
    for cy in range(101):
        H = h + abs(cx - x) + abs(cy - y)
        for input_list in all_input_list:
            result = H - abs(cx - input_list[0]) -  abs(cy - input_list[1])
            if (result < 0) or (input_list[2] != result):
                break
        else:
            print("%s %s %s" % (cx, cy, H))
            sys.exit(0)

Fixed submission:
print("Hello World") if(input() == "1") else print(int(input()) + int(input()))

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

N = int(input())
all_input_list = [list(map(int, input().split())) for i in range(N)]
x, y, h = [all_input_list[i] for i in range(N) if all_input_list[i][2] > 0][0]
for cx in range(101):
    for cy in range(101):
        H = h + abs(cx - x) + abs(cy - y)
        for input_list in all_input_list:
            result = H - abs(cx - input_list[0]) - abs(cy - input_list[1])
            if (result >  0) and (input_list[2] != result):
                break
        else:
            print("%s %s %s" % (cx, cy, H))
            sys.exit(0)


Fixed submission:
print("Hello World") if(input() == "1") else print(int(input()) + int(input()))

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

N = int(input())
all_input_list = [list(map(int, input().split())) for i in range(N)]
x, y, h = [all_input_list[i] for i in range(N) if all_input_list[i][2] > 0][0]
for cx in range(101):
    for cy in range(101):
        H = h + abs(cx - x) + abs(cy - y)
        for input_list in all_input_list:
            if (input_list[2] != (H - abs(cx - input_list[0]) - abs(cy - input_list[1])):
                break
        else:
            print("%s %s %s" % (cx, cy, H))
            sys.exit(0)


Fixed submission:
print("Hello World") if(input() == "1") else print(int(input()) + int(input()))
Buggy python submission (verdict: Time Limit Exceeded):
from math import *

def Prime_Factorization(M):
    factor_count_list = []
    root_M = int(sqrt(M))

    while root_M > 1:
        root_M = int(sqrt(M))

        for i in range(2, root_M + 1):
            e = 0
            while M % i == 0:
                e += 1
                M = M // i
            if e > 0:
                factor_count_list.append(e)
                break
        else:
            break

    if M > root_M:
        factor_count_list.append(1)

    return factor_count_list

def comb(num_object, num_bar):
    return factorial(num_object) // (factorial(num_object - num_bar) * factorial(num_bar))

def all_comb(N, factor_count_list):
    ans = 1
    for factor in factor_count_list:
        ans = (ans * comb(factor + N - 1, factor)) % (10 ** 9 + 7)
    return ans

def main():
    N, M = map(int, input().split())
    factor_count_list = Prime_Factorization(M)

    if (factor_count_list == 1):
        print(N)
    else:
        print(all_comb(N, factor_count_list))

if __name__ == "__main__":
    main()

Fixed submission:
from math import *

def Prime_Factorization(M):
    factor_count_list = []
    root_M = int(sqrt(M))

    while root_M > 1:
        root_M = int(sqrt(M))

        for i in range(2, root_M + 1):
            e = 0
            while M % i == 0:
                e += 1
                M = M // i
            if e > 0:
                factor_count_list.append(e)
                break
        else:
            break

    if M > root_M:
        factor_count_list.append(1)

    return factor_count_list

def comb(num_object, num_bar):
    numerator = 1

    for i in range(num_bar):
        numerator = (numerator * (num_object - i))

    return  numerator // factorial(num_bar)

def all_comb(N, factor_count_list):
    ans = 1
    for factor in factor_count_list:
        ans = (ans * comb(factor + N - 1, factor)) % (10 ** 9 + 7)
    return ans

def main():
    N, M = map(int, input().split())
    factor_count_list = Prime_Factorization(M)

    print(all_comb(N, factor_count_list))

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
if a<0 and c<0:
    print(a*c)
elif b>=0 and d>=0:
    print(b*d)
elif b<0 and c>=0:
    print(b*c)
elif a>=0 and d<0:
    print(a*d)
else:
    if a*c>=b*d:
        print(a*c)
    else:
        print(b*d)

Fixed submission:
a,b,c,d=map(int,input().split())

if b<0 and d<0:
    print(a*c)
elif a>=0 and c>=0:
    print(b*d)
elif b<0 and c>=0:
    print(b*c)
elif a>=0 and d<0:
    print(a*d)
else:
    if a*c>=b*d:
        print(a*c)
    else:
        print(b*d)
Buggy python submission (verdict: Runtime Error):
N=int(input())
c=input()

i=0
listNum=[]

for i in range(N):
    w=c.count("W",0,i)
    s=c.count("R",i+1,N)
    listNum.append(max(w,s))
    i+=1
print(min(listNum))

Fixed submission:
X=int(input())

if X>=30:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
from sys import stdin

str = stdin.readline().rstrip()

if str.islower():
    print('a')
else:
    print('A'from sys import stdin

str = stdin.readline().rstrip()

if str.islower():
    print('a')
else:
    print('A'

Fixed submission:
import sys
from sys import stdin

str = sys.stdin.readline()

if str.islower():
    print('a')
else:
    print('A')
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n):
  ans=ans+1/a[i]
ans=1/ans
 print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=0.0
for i in range(n):
  ans=ans+1.0/a[i]
ans=1.0/ans
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#-*-coding:utf-8-*-

import sys
import numpy as np

def main():
    n = int(input())
    a_numbers=np.arange(1,1001).reshape(1,1000)
    b_numbers=np.arange(1,1001).reshape(1,1000)
    t_a_numbers=a_numbers.T
    dp=np.dot(t_a_numbers,b_numbers)
    numbers=[]
    count=0
    for i in range(1,n):
        tmp=sum(np.count_nonzero(dp==n-i,axis=1))
        count+=tmp
        tmp=0
    print(count)

if __name__ == "__main__":
    main()

Fixed submission:
#-*-coding:utf-8-*-

import sys

def main():
    n = int(input())
    ans=0
    b=0

    for a in range(1,n):
        #A*B+C=n → A <= n-c//b
        #cは1<=c<=nなのでbで可変
        b=(n-1)//a
        ans+=b
    print(ans)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#-*-coding:utf-8-*-

import sys

def main():
    k = int(input())
    mod=10**9+7
    if k % 2==0:
        print(-1)
        exit()

    sevens=7
    for i in range(1,10**6):
        if sevens%k==0:
            print(i)
            exit()
        else:
            sevens=(sevens*10+7)

if __name__ == "__main__":
    main()

Fixed submission:
#-*-coding:utf-8-*-

import sys

def main():
    k = int(input())
    sevens=0
    for i in range(1,k+1):
        sevens=(sevens*10+7)%k
        if sevens==0:
            print(i)
            exit()
    print(-1)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
#-*-coding:utf-8-*-

import math

def calculate_length(A,B,theta):
    radian=math.radians(theta)
    length=(A**2)+(B**2)-(2*A*B*math.cos(radian))
    return  math.sqrt(length)

def main():
    A,B,H,M = map(int,input().split())
    thetaA=H*30+M*0.5
    thetaB=M*6
    if thetaA > thetaB:
        theta=thetaA-thetaB
    elif thetaA < thetaB:
        theta = thetaB-thetaA
    else:
        print("0")
    length=calculate_length(A,B,theta)
    print(length)

if __name__=="__main__":
    main()

Fixed submission:
#-*-coding:utf-8-*-

import math

def calculate_length(A,B,rad):
    length=(A**2)+(B**2)-(2*A*B*math.cos(math.pi*rad/180))
    return  math.sqrt(length)

def main():
    A,B,H,M = map(int,input().split())
    rad = abs((H*60+M)*0.5-M*6)
    length=calculate_length(A,B,rad)
    print(length)

if __name__=="__main__":
    main()

Buggy python submission (verdict: Runtime Error):
#-*-coding:utf-8-*-

import math

def calculate_length(A,B,theta):
    radian=math.radians(theta)
    length=(A**2)+(B**2)-(2*A*B*math.cos(math.radians(theta)))
    return  math.sqrt(length)

def main():
    A,B,H,M = map(int,input().split())
    thetaA=H*30+M*0.5
    thetaB=M*6
    if thetaA> thetaB:
        theta=thetaA-thetaB
    elif thetaA < thetaB:
        theta = thetaB-thetaA
    elif thetaA==thetaB:
        print("0")
    length=calculate_length(A,B,theta)
    print(length)

if __name__=="__main__":
    main()

Fixed submission:
#-*-coding:utf-8-*-

import math

def calculate_length(A,B,rad):
    length=(A**2)+(B**2)-(2*A*B*math.cos(math.pi*rad/180))
    return  math.sqrt(length)

def main():
    A,B,H,M = map(int,input().split())
    rad = abs((H*60+M)*0.5-M*6)
    length=calculate_length(A,B,rad)
    print(length)

if __name__=="__main__":
    main()
Buggy python submission (verdict: Runtime Error):
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    n,a,b = map(int,input().split())
    count=0
    blue_count=0
    blue=""
    red=""
    tmp=""
    ball_list=[]

    while count < n:
        blue = "b"*a
        red = "r"*b
        tmp+=blue+red
        count=len(tmp)
    ball_list.append(tmp)
    print(str(ball_list[0])[:n].count("b"))

if __name__=="__main__":
    main()

Fixed submission:
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    n,a,b = map(int,input().split())
    a_count=0
    d,r=divmod(n,a+b)
    a_count+=a*d
    if r > a:
        a_count+=a
    else:
        a_count+=r
    print(a_count)

if __name__=="__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    numbers=[]
    n = int(input())
    numbers=list(map(int,input().split()))
    count=0

    for idx,data in enumerate(numbers):
        if idx == 0:
            count+=1
        elif min(numbers[0:idx+1])==data:
            count+=1
        else:
            continue
    print(count)

if __name__=="__main__":
    main()

Fixed submission:
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    numbers=[]
    n = int(input())
    numbers=list(map(int,input().split()))
    small=0
    dp=[]

    for idx,data in enumerate(numbers):
        if idx == 0:
            small=data
            dp.append(data)
        elif data < small:
            small=data
            dp.append(data)
        else:
            continue
    print(len(dp))

if __name__=="__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import sys

def check(a,b,k):
    if a + b == k:
        b = 0
        a = 0
    elif a < k:
        b = b - (k-a)
        a = 0
    elif a > k:
        a = a - k
    return a,b

a,b,k=map(int,input().split(" "))
if len(str(a)) > 12 or len(str(b)) > 12 or len(str(k)) > 12:
  a=0
  b=0
  print(str(a),str(b))
  sys.exit()

else:
    if a > 0 and k > 0:
        A,B=check(a,b,k)
        print(str(A), str(B))
    elif a == 0 and b > k:
        b = b-k
        print(str(a), str(b))
    elif a+b < K:
        b = 0
        a = 0
        print(str(a), str(b))
    elif k ==0:
        print(str(a),str(b))

Fixed submission:
a,b,k = map(int,(input().split(" ")))

if k <= a:
    print(str(a-k),str(b))
elif k <= a+b:
    print(str(0),str(b-(k-a)))
else:
    print(str(0),str(0))

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

def check(a,b,k):
    if a + b == k:
        b = 0
        a = 0
    elif a < k:
        b = b - (k-a)
        a = 0
    elif a > k:
        a = a - k
    return a,b

a,b,k=map(int,input().split(" "))
if len(str(a)) > 12 or len(str(b)) > 12 or len(str(k)) > 12:
  a=0
  b=0
  print(str(a),str(b))
  sys.exit()

else:
    if a > 0 or k > 0:
        A,B=check(a,b,k)
    elif a <= 0 and b > 0:
        b = k -b
    print(str(A),str(B))

Fixed submission:
a,b,k = map(int,(input().split(" ")))

if k <= a:
    print(str(a-k),str(b))
elif k <= a+b:
    print(str(0),str(b-(k-a)))
else:
    print(str(0),str(0))
Buggy python submission (verdict: Runtime Error):
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    n,a,b = map(int,input().split())
    if a==b:
        print(0)
    elif a==1:
        print(str(b-1))
    elif b==1:
        print(str(a-1))
    elif a==n:
        print(str(b+1))
    elif b==n:
        print(str(a+1))
    else:
        if abs(a-b)%2==0:
            ans=abs(a-b)//2
        else:
            if n-min(a,b)>=max(a,b)-1:
                ans=max(a,b)-1
            else:
                ans=n-min(a,b)
    print(ans)

if __name__=="__main__":
    main()

Fixed submission:
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

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

if __name__=="__main__":
    main()

Buggy python submission (verdict: Runtime Error):
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

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

    if a==b:
        print(0)
    elif a==1:
        print(str(b))
    elif b==1:
        print(str(a))
    else:
        if abs(a-b)%2==0:
            ans=abs(a-b)//2
        else:
            if n-min(a,b)>max(a,b)-1:
                ans=max(a,b)-1
            else:
                ans=n-min(a,b)
    print(ans)

if __name__=="__main__":
    main()

Fixed submission:
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

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

if __name__=="__main__":
    main()