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

def make_divisors(n):
    divisors = []
    for i in range(int(math.sqrt(n))+1, 0, -1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
        if len(divisors) == 2:
            break
        
    return divisors

def main():
    target = int(input())

    a, b = make_divisors(target)
    a -= 1
    b -= 1
    print(a+b)
        
        
if __name__ == "__main__":
    main()


Fixed submission:
import math


def main():
    n = int(input())
    a = 1
    b = n
    
    ans = n - 1 
    
    for i in range(2, int(math.sqrt(n)) + 1):
        if n % i == 0:
            a = int(i)
            b = int(n / i)
            ans = min(ans, a+b-2)
    print(ans)
        
        
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
def make_divisors(n):
    divisors = []
    for i in range(int(n**0.5)+1, 0, -1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
        if len(divisors) == 2:
            break
        
    return divisors

def main():
    target = int(input())

    a, b = make_divisors(target)
    a -= 1
    b -= 1
    print(a+b)
        
        
if __name__ == "__main__":
    main()


Fixed submission:
import math


def main():
    n = int(input())
    a = 1
    b = n
    
    ans = n - 1 
    
    for i in range(2, int(math.sqrt(n)) + 1):
        if n % i == 0:
            a = int(i)
            b = int(n / i)
            ans = min(ans, a+b-2)
    print(ans)
        
        
if __name__ == "__main__":
    main()

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

def make_divisors(n):
    divisors = []
    for i in range(int(n**0.5)+1, 0, -1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
        if len(divisors) == 2:
            break
        
    return divisors

def main():
    n = int(input())

    a, b = make_divisors(n)
    a -= 1
    b -= 1
    print(a+b)
        
        
if __name__ == "__main__":
    main()


Fixed submission:
import math


def main():
    n = int(input())
    a = 1
    b = n
    
    ans = n - 1 
    
    for i in range(2, int(math.sqrt(n)) + 1):
        if n % i == 0:
            a = int(i)
            b = int(n / i)
            ans = min(ans, a+b-2)
    print(ans)
        
        
if __name__ == "__main__":
    main()

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

def make_divisors(n):
    divisors = []
    for i in range(int(n**0.5)+1, 0, -1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
        if len(divisors) == 2:
            break
        
    return divisors

def main():
    n = int(input())

    a, b = make_divisors(n)
    a -= 1
    b -= 1
    print(a+b)
        
        
if __name__ == "__main__":
    main()


Fixed submission:
import math


def main():
    n = int(input())
    a = 1
    b = n
    
    ans = n - 1 
    
    for i in range(2, int(math.sqrt(n)) + 1):
        if n % i == 0:
            a = int(i)
            b = int(n / i)
            ans = min(ans, a+b-2)
    print(ans)
        
        
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import math

def eratosthenes(n):
    p_list = []
    root_n = math.sqrt(n)
    data = [i + 1 for i in range(1, n)] 
    while True:
        p = data [0]
        if root_n <= p:
            return p_list + data 
        p_list.append(p)
        data = [e for e in data if e % p != 0]

def make_divisors(n):
    divisors = []
    for i in range(int(n**0.5)+1, 1, -1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
        if len(divisors) == 2:
            break
        
    # divisors.sort()
    return divisors

def main():
    n = int(input())

    if n in eratosthenes(n):
        print(n-1)
    else:
        a, b = make_divisors(n)
        a -= 1
        b -= 1
        print(a+b)
        
        
if __name__ == "__main__":
    main()


Fixed submission:
import math


def main():
    n = int(input())
    a = 1
    b = n
    
    ans = n - 1 
    
    for i in range(2, int(math.sqrt(n)) + 1):
        if n % i == 0:
            a = int(i)
            b = int(n / i)
            ans = min(ans, a+b-2)
    print(ans)
        
        
if __name__ == "__main__":
    main()