Buggy python submission (verdict: Time Limit Exceeded):
import sys
import os
import itertools

n = int(input())

def is_prime(n):
    for p in range(2, n):
        if n % p == 0:
            return 0
    return 1

a = is_prime(n)
if a == 1:
    print(n-1)
    sys.exit()


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

    return divisors

ans = make_divisors(n)
m = max(ans)
print( (m-1) + ans[m]-1)

Fixed submission:
import sys
import os
import itertools

n = int(input())

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

    return divisors

ans = make_divisors(n)
m = max(ans)
print( (m-1) + ans[m]-1)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import os
import itertools

n = int(input())

def is_prime(n):
    for p in range(2, n):
        if n % p == 0:
            return 0
    return 1

a = is_prime(n)
if a == 1:
    print(n-1)
    sys.exit()

l = []
# for i in range(2, n):
#     for j in range(2, n):
#         if i*j == n:
#             l.append((i-1)+(j-1))
#         else:
#             continue

# print(min(l))

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

    # divisors.sort()
    return divisors

ans = make_divisors(n)
print( (max(ans)-1) + ans[max(ans)]-1)

Fixed submission:
import sys
import os
import itertools

n = int(input())

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

    return divisors

ans = make_divisors(n)
m = max(ans)
print( (m-1) + ans[m]-1)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import os
import itertools

n = int(input())

def is_prime(n):
    for p in range(2, n):
        if n % p == 0:
            return 0
    return 1

a = is_prime(n)
if a == 1:
    print(n-1)
    sys.exit()

l = []
for i in range(2, n):
    for j in range(2, n):
        if i*j == n:
            l.append((i-1)+(j-1))
        else:
            continue

print(min(l))

Fixed submission:
import sys
import os
import itertools

n = int(input())

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

    return divisors

ans = make_divisors(n)
m = max(ans)
print( (m-1) + ans[m]-1)

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

n = int(input())

def is_prime(n):
    for p in range(2, n):
        if n % p == 0:
            return p, n//p
        else:
            return 0, 0

a, b = is_prime(n)
if a:
    print((a-1)+(b-1))
else:
    print(n-1)

Fixed submission:
import sys
import os
import itertools

n = int(input())

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

    return divisors

ans = make_divisors(n)
m = max(ans)
print( (m-1) + ans[m]-1)