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

def solve():
    N = int(input())
    D = sympy.divisors(N)
    ans = N - 1
    for d in D:
        print(d)
        ans = min(ans, N // d - 1 + d - 1)
    print(ans)

if __name__ == "__main__":
    solve()


Fixed submission:
def make_divisors(n):
    '''
    nの約数の配列を返す
    '''
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


def solve():
    N = int(input())
    D = make_divisors(N)
    ans = N - 1
    for d in D:
        ans = min(ans, N // d - 1 + d - 1)
    print(ans)

if __name__ == "__main__":
    solve()

Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce

def factorization(n):
    '''
    素因数分解の結果を返す
    例： n = 100 の時、[2, 2, 5, 5] 
    '''
    arr = []
    tmp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if tmp % i == 0:
            while tmp % i == 0:
                arr.append(i)
                tmp //= i
    if tmp != 1:
        arr.append(tmp)
    if arr == []:
        arr.append(n)
    return arr


def combination(l):
    res = []
    for i in range(1, 2**len(l)):
        tmp = []
        for j in range(len(l)):
            if (i >> j) &1 == 1:
                tmp.append(l[j])
        res.append(tmp)
    return res


def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]


def solve():
    N = int(input())
    F = factorization(N)
    ans = N - 1
    for c in get_unique_list(combination(F)):
        t = reduce(lambda x, y: x * y, c)
        ans = min(ans, N // t - 1 + t - 1)
    print(ans)

if __name__ == "__main__":
    solve()


Fixed submission:
def make_divisors(n):
    '''
    nの約数の配列を返す
    '''
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


def solve():
    N = int(input())
    D = make_divisors(N)
    ans = N - 1
    for d in D:
        ans = min(ans, N // d - 1 + d - 1)
    print(ans)

if __name__ == "__main__":
    solve()

Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce

def factorization(n):
    '''
    素因数分解の結果を返す
    例： n = 100 の時、[2, 2, 5, 5] 
    '''
    arr = []
    tmp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if tmp % i == 0:
            while tmp % i == 0:
                arr.append(i)
                tmp //= i
    if tmp != 1:
        arr.append(tmp)
    if arr == []:
        arr.append(n)
    return arr


def combination(l):
    res = []
    for i in range(1, 2**len(l)):
        tmp = []
        for j in range(len(l)):
            if (i >> j) &1 == 1:
                tmp.append(l[j])
        res.append(tmp)
    return res


def solve():
    N = int(input())
    F = factorization(N)
    ans = N - 1
    for c in combination(F):
        t = reduce(lambda x, y: x * y, c)
        ans = min(ans, N // t - 1 + t - 1)
    print(ans)

if __name__ == "__main__":
    solve()


Fixed submission:
def make_divisors(n):
    '''
    nの約数の配列を返す
    '''
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


def solve():
    N = int(input())
    D = make_divisors(N)
    ans = N - 1
    for d in D:
        ans = min(ans, N // d - 1 + d - 1)
    print(ans)

if __name__ == "__main__":
    solve()