Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

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

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

d = prime_factorize(N)

ans = 2**64

A = d

for i in range(1 << len(A)):
    a = []
    b = []
    ao = 1
    bo = 1
    for j in range(len(A)):
        if ((i >> j) & 1) == 1:
            a.append(A[j])
        else:
            b.append(A[j])
            
    for j in range(len(a)):
        ao *= a[j]
    for j in range(len(b)):
        bo *= b[j]
        
    ans = min(ans, ao+bo-2)
    
print(ans)




Fixed submission:
N = int(input())

a = 1
ans = 2**64
while a*a<=N:
    b = N/a
    if b!=int(b):
        a += 1
        continue
    b = int(b)
    ans = min(ans, a+b-2)

    a += 1

print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())

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

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

d = prime_factorize(N)

import math
ans = math.inf

A = d

for i in range(1 << len(A)):
    a = []
    b = []
    ao = 1
    bo = 1
    for j in range(len(A)):
        if ((i >> j) & 1) == 1:
            a.append(A[j])
        else:
            b.append(A[j])
            
    for j in range(len(a)):
        ao *= a[j]
    for j in range(len(b)):
        bo *= b[j]
        
    ans = min(ans, ao+bo-2)
    
print(ans)




Fixed submission:
N = int(input())

a = 1
ans = 2**64
while a*a<=N:
    b = N/a
    if b!=int(b):
        a += 1
        continue
    b = int(b)
    ans = min(ans, a+b-2)

    a += 1

print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())

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

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

d = prime_factorize(N)

import math
ans = math.inf

A = d

for i in range(1 << len(A)):
    a = []
    b = []
    ao = 1
    bo = 1
    for j in range(len(A)):
        if ((i >> j) & 1) == 1:
            a.append(A[j])
        else:
            b.append(A[j])
            
    for j in range(len(a)):
        ao *= a[j]
    for j in range(len(b)):
        bo *= b[j]
        
    ans = min(ans, ao+bo-2)
    
print(ans)




Fixed submission:
N = int(input())

a = 1
ans = 2**64
while a*a<=N:
    b = N/a
    if b!=int(b):
        a += 1
        continue
    b = int(b)
    ans = min(ans, a+b-2)

    a += 1

print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())

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

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

d = prime_factorize(N)

import math
ans = math.inf

A = d

for i in range(1 << len(A)):
    a = []
    b = []
    ao = 1
    bo = 1
    for j in range(len(A)):
        if ((i >> j) & 1) == 1:
            a.append(A[j])
        else:
            b.append(A[j])
            
    for j in range(len(a)):
        ao *= a[j]
    for j in range(len(b)):
        bo *= b[j]
        
    ans = min(ans, ao+bo-2)
    print(ans)



Fixed submission:
N = int(input())

a = 1
ans = 2**64
while a*a<=N:
    b = N/a
    if b!=int(b):
        a += 1
        continue
    b = int(b)
    ans = min(ans, a+b-2)

    a += 1

print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())

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

d = make_divisors(N)
d.sort()

a = 0
b = 0
ans = 0
if len(d)%2==0:
    a = d[len(d)//2-1]
    b = d[len(d)//2]
    ans = a+b
else:
    a = d[len(d)//2]
    b = d[len(d)//2+1]
    c = d[len(d)//2+2]
    ans = min(a+b,b+c)

ans -= 2
print(ans)



Fixed submission:
N = int(input())

a = 1
ans = 2**64
while a*a<=N:
    b = N/a
    if b!=int(b):
        a += 1
        continue
    b = int(b)
    ans = min(ans, a+b-2)

    a += 1

print(ans)