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

    
def main():
    Input = [input() for i in range(1)]
    N = int(Input[0])
    x = math.sqrt(N)
    if x.is_integer():
        print(int(x+N/x-2))
    else:
        while x >= 1:
            x = math.floor(x)-1
            y = N/x
            if y.is_integer():
                print(int(x+y-2))
                break

        
        
if __name__ == "__main__":
    main()
    


Fixed submission:
import math

def main():
    Input = [input() for i in range(1)]
    N = int(Input[0])
    x = math.sqrt(N)
    if x.is_integer():
        print(int(x+N/x-2))
    else:
        while x >= 1:
            x = math.ceil(x)-1
            y = N/x
            if y.is_integer():
                print(int(x+y-2))
                break

        
        
if __name__ == "__main__":
    main()

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

def factorization(n): #素因数分解
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])

    return arr

def main1():
    Input = [input() for i in range(1)]
    N = int(Input[0])
    fact = factorization(N)
    ff = []
    for fn in fact:
        for i in range(fn[1]):
            ff.append(fn[0])
    ans = 10000000000000
    fN = len(ff)
    for wake in range(2**(fN-1)):
        wake2 = format(wake, '0'+str(fN-1)+'b')
        A = ff[-1]
        for i in range(fN-1):
            if wake2[i] == '1':
                 A = A*ff[i]   
        B = N / A
        if A + B - 2 < ans:
            ans = int(A+B-2)
    print(ans)
    
def main1():
    Input = [input() for i in range(1)]
    N = int(Input[0])
    x = math.sqrt(N)
    if x.is_integer():
        print(int(x+N/x-2))
    else:
        while x >= 1:
            x = math.floor(x)-1
            y = N/x
            if y.is_integer():
                print(int(x+y-2))
                break

        
        
if __name__ == "__main__":
    main1()
    


Fixed submission:
import math

def main():
    Input = [input() for i in range(1)]
    N = int(Input[0])
    x = math.sqrt(N)
    if x.is_integer():
        print(int(x+N/x-2))
    else:
        while x >= 1:
            x = math.ceil(x)-1
            y = N/x
            if y.is_integer():
                print(int(x+y-2))
                break

        
        
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def factorization(n): #素因数分解
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def main():
    Input = [input() for i in range(1)]
    N = int(Input[0])
    fact = factorization(N)
    ff = []
    for fn in fact:
        for i in range(fn[1]):
            ff.append(fn[0])
    ans = 10000000000000
    fN = len(ff)
    for wake in range(2**(fN-1)):
        wake2 = format(wake, '0'+str(fN-1)+'b')
        A = ff[-1]
        for i in range(fN-1):
            if wake2[i] == '1':
                 A = A*ff[i]   
        B = N / A
        if A + B - 2 < ans:
            ans = int(A+B-2)
    print(ans)
    
if __name__ == "__main__":
    main()
    


Fixed submission:
import math

def main():
    Input = [input() for i in range(1)]
    N = int(Input[0])
    x = math.sqrt(N)
    if x.is_integer():
        print(int(x+N/x-2))
    else:
        while x >= 1:
            x = math.ceil(x)-1
            y = N/x
            if y.is_integer():
                print(int(x+y-2))
                break

        
        
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def factorization(n): #素因数分解
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def main():
    Input = [input() for i in range(1)]
    N = int(Input[0])
    fact = factorization(N)
    ff = []
    for fn in fact:
        for i in range(fn[1]):
            ff.append(fn[0])
    ans = 10000000000000
    fN = len(ff)
    for wake in range(2**fN):
        wake2 = format(wake, '0'+str(fN)+'b')
        A = 1
        for i in range(fN):
            if wake2[i] == '1':
                 A = A*ff[i]   
        B = N / A
        if A + B - 2 < ans:
            ans = int(A+B-2)
    print(ans)
    
if __name__ == "__main__":
    main()
    


Fixed submission:
import math

def main():
    Input = [input() for i in range(1)]
    N = int(Input[0])
    x = math.sqrt(N)
    if x.is_integer():
        print(int(x+N/x-2))
    else:
        while x >= 1:
            x = math.ceil(x)-1
            y = N/x
            if y.is_integer():
                print(int(x+y-2))
                break

        
        
if __name__ == "__main__":
    main()