Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from scipy.special import comb
n, p = map(int, input().split())
a = list(map(int, input().split()))
ev, od = 0, 0
for i in a:
    if i%2 == 0:
        ev += 1
    else:
        od += 1
ans = 0
if p == 0:
    for i in range(0, od+1, 2):
        for j in range(ev+1):
            ans += comb(od, i, exact = True)*comb(ev, j, exact = True)
else:
    for i in range(1, od+1, 2):
        for j in range(ev+1):
            ans += comb(od, i, exact = True)*comb(ev, j, exact = True) 
print(ans)

Fixed submission:
n, p = map(int, input().split())
a = list(map(int, input().split()))

def comb(n, r):
    ans = 1
    if n < 2*r:
        r = n - r
    for i in range(r):
        ans *= (n - i)
        ans //= (i + 1)
    return ans

ev, od = 0, 0
for i in a:
    if i%2 == 0:
        ev += 1
    else:
        od += 1
ans = 0
if p == 0:
    for i in range(0, od+1, 2):
        for j in range(ev+1):
            ans += comb(od, i)*comb(ev, j)
else:
    for i in range(1, od+1, 2):
        for j in range(ev+1):
            ans += comb(od, i)*comb(ev, j) 
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

color = [0]*9
cnt = 0
for i in range(n):
    if a[i] < 400:
        color[0] += 1
    elif a[i] < 800:
        color[1] += 1
    elif a[i] < 1200:
        color[2] += 1
    elif a[i] < 1600:
        color[3] += 1
    elif a[i] < 2000:
        color[4] += 1
    elif a[i] < 2400:
        color[5] += 1
    elif a[i] < 2800:
        color[6] += 1
    elif a[i] < 3200:
        color[7] += 1
    else:
        color[8] += 1

for i in range(8):
    if color[i] != 0:
        cnt += 1
        mi = cnt
if cnt != 8:
    cnt += color[8]
    if cnt > 8:
        cnt = 8

print(str(mi) + " " + str(cnt))


Fixed submission:
n = int(input())
a = list(map(int, input().split()))

color = [False]*8
flex = 0
cnt = 0
for i in range(n):
    if a[i] < 400:
        color[0] = True
    elif a[i] < 800:
        color[1] = True
    elif a[i] < 1200:
        color[2] = True
    elif a[i] < 1600:
        color[3] = True
    elif a[i] < 2000:
        color[4] = True
    elif a[i] < 2400:
        color[5] = True
    elif a[i] < 2800:
        color[6] = True
    elif a[i] < 3200:
        color[7] = True
    else:
        flex += 1

for i in range(8):
    if color[i]:
        cnt += 1
mi = cnt
if mi == 0:
    mi = 1
cnt += flex

print(str(mi) + " " + str(cnt))
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))

i = 1
ans = 1
plus = False
minus = False
while True:
    while A[i] - A[i-1] == 0:
        i += 1
    if A[i] - A[i - 1] > 0:
        plus = True
    else:
        minus = True
    if plus:
        while A[i] - A[i - 1] >= 0:
            i += 1
            if i == n:
                break
    else:
        while A[i] - A[i -1] <= 0:
            i += 1
            if i == n:
                break
    if i == n:
        break
    if plus:
        minus = True
        plus = False
    else:
        plus = True
        minus = False
    ans += 1
    if i != n -1:
        i += 1

print(ans)

Fixed submission:
n = int(input())
A = list(map(int, input().split()))

i = 1
ans = 1
flg = 0
for i, j in zip(A[:-1],A[1:]):
    if i < j:
        if flg == 0:
            flg = 1
        elif flg == 2:
            ans += 1
            flg = 0
    if i > j:
        if flg == 0:
            flg = 2
        elif flg == 1:
            ans += 1
            flg = 0
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = []
B = []
for i in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

ans = 0
for i in range(n)[-1::-1]:
    val = B[i] - A[i]%B[i]
    if val == B[i]:
        continue
    ans += val
    j = 0
    while j != i:
        A[j] += val
        j += 1
print(ans)

Fixed submission:
n = int(input())
A = []
B = []
for i in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

ans = 0
for i in range(n)[-1::-1]:
    val = B[i] - (A[i] + ans)%B[i]
    if val == B[i]:
        continue
    ans += val
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = []
B = []
for i in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

ans = 0
for i in range(n)[-1::-1]:
    val = B[i] - A[i]%B[i]
    if val == B[i]:
        continue
    ans += val
    for j in range(i):
        A[j] += val

print(ans)

Fixed submission:
n = int(input())
A = []
B = []
for i in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

ans = 0
for i in range(n)[-1::-1]:
    val = B[i] - (A[i] + ans)%B[i]
    if val == B[i]:
        continue
    ans += val
    
print(ans)
Buggy python submission (verdict: Runtime Error):
# input
N = int(input())
noguchi = [1000 * n for n in range(1, 11)]

# check
print(min([ngc - N for ngc in noguchi if (ngc - N) > 0]))


Fixed submission:
# input
N = int(input())
noguchi = [1000 * n for n in range(1, 11)]

# check
print(min([ngc - N for ngc in noguchi if (ngc - N) >= 0]))

Buggy python submission (verdict: Runtime Error):
# input
N = int(input())
noguchi = [1000 * n for n in range(1, 11)]

# check
print(min([ngc - N for ngc in noguchi if (ngc - N) < 0]))


Fixed submission:
# input
N = int(input())
noguchi = [1000 * n for n in range(1, 11)]

# check
print(min([ngc - N for ngc in noguchi if (ngc - N) >= 0]))
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import product

# input
X, Y = map(int, input().split())

# check
if Y in set([sum(p) for p in set(product([2, 4], repeat=X))]):
    print("Yes")
else:
    print("No")

Fixed submission:
# input
X, Y = map(int, input().split())

# check
if Y < 2 * X or Y > 4 * X or abs(Y - 2 * X) % 2 != 0:
    print("No")
else:
    print("Yes")

Buggy python submission (verdict: Runtime Error):
# input
X, Y = map(int, input().split())

# check
if Y in set([sum(p) for p in set(product([2, 4], repeat=X))]):
    print("Yes")
else:
    print("No")

Fixed submission:
# input
X, Y = map(int, input().split())

# check
if Y < 2 * X or Y > 4 * X or abs(Y - 2 * X) % 2 != 0:
    print("No")
else:
    print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

limit = 10 ** 18
res = A[0]

if 0 in A:
    start_idx = max(
        [
            idx
            for idx, a in enumerate(A)
            if a == 0
        ]
    ) + 1

    if start_idx == N:
        print(0)
        exit(0)
else:
    start_idx = 1

for i in range(start_idx, N):
    res *= A[i]

if res > limit:
    print(-1)
else:
    print(res)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))

limit = 10 ** 18
res = A[0]

if 0 in A:
    print(0)
    exit(0)
else:
    for i in range(1, N):
        res *= A[i]
        if res > limit:
            print(-1)
            exit(0)

print(res)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

limit = 10 ** 18
res = A[0]

for i in range(1, N):
    res *= A[i]
    
if res > limit:
    print(-1)
else:
    print(res)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))

limit = 10 ** 18
res = A[0]

if 0 in A:
    print(0)
    exit(0)
else:
    for i in range(1, N):
        res *= A[i]
        if res > limit:
            print(-1)
            exit(0)

print(res)
Buggy python submission (verdict: Runtime Error):
from math import floor

A, B = map(int, input().split())

print(floor(A * B))

Fixed submission:
from math import floor
from fractions import Fraction

A, B = input().split()

print(floor(int(A) * Fraction(B)))
Buggy python submission (verdict: Time Limit Exceeded):
def get_prime_fact(n):
    primes = []
    append = primes.append
    while n % 2 == 0:
        append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        append(n)
    return primes


def get_knu(a):
    if a == 1:
        return 1
    n = 2
    while True:
        if a == (n * (n + 1)) // 2:
            return n
        n += 1


D = int(input())
p = get_prime_fact(D)

if len(p) != len(set(p)):
    res = 0
    for n in set(p):
        count = p.count(n)
        res += get_knu(count)

    print(res)
else:
    print(len(p))

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


def get_knu(a):
    before = 1
    n = 2
    while True:
        knum = (n * (n + 1)) // 2
        if a == knum:
            return n
        elif knum > a > before:
            return n - 1
        else:
            n += 1
            before = knum


D = int(input())
p = get_prime_fact(D)

if len(p) != len(set(p)):
    res = 0
    for n in set(p):
        count = p.count(n)
        if count == 1:
            res += 1
        else:
            add = get_knu(count)
            res += add

    print(res)
else:
    print(len(p))
Buggy python submission (verdict: Runtime Error):
# input
S = input()
T = input()

if T.startswith(S):
    print("Yes")
else;
    print("No")

Fixed submission:
# input
S = input()
T = input()

if T.startswith(S):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
# input
A, B, C, K = map(int, input().split())

# check
result_score = 0
for score, i in [(1, A), (0, B), (-1, C)]:
        if K <= 0:
                break
        while K > 0 and i > 0:
                result_score += score
                i -= 1
                K -= 1

print(result_score)

Fixed submission:
# input
A, B, C, K = map(int, input().split())

# check
result_score = 0
for score, i in [(1, A), (0, B), (-1, C)]:
        if K <= 0:
               continue

        if K >= i:
            result_score += score * i
            K -= i
        else:
            result_score += score * K
            K = 0

print(result_score)

Buggy python submission (verdict: Time Limit Exceeded):
# B - Easy Linear Programming

# input
A, B, C, K = map(int, input().split())

# check
result_score = 0
while K > 0:
        for score, i in [(1, A), (0, B), (-1, C)]:
                if K <= 0:
                        break
                while K > 0 and i > 0:
                        result_score += score
                        i -= 1
                        K -= 1

print(result_score)

Fixed submission:
# input
A, B, C, K = map(int, input().split())

# check
result_score = 0
for score, i in [(1, A), (0, B), (-1, C)]:
        if K <= 0:
               continue

        if K >= i:
            result_score += score * i
            K -= i
        else:
            result_score += score * K
            K = 0

print(result_score)

Buggy python submission (verdict: Time Limit Exceeded):
# input
A, B, C, K = map(int, input().split())

# check
result_score = 0
while K > 0:
        for score, i in [(1, A), (0, B), (-1, C)]:
                while K > 0 and i > 0:
                        result_score += score
                        i -= 1
                        K -= 1

print(result_score)

Fixed submission:
# input
A, B, C, K = map(int, input().split())

# check
result_score = 0
for score, i in [(1, A), (0, B), (-1, C)]:
        if K <= 0:
               continue

        if K >= i:
            result_score += score * i
            K -= i
        else:
            result_score += score * K
            K = 0

print(result_score)
Buggy python submission (verdict: Time Limit Exceeded):
# input
N, M = map(int, input().split())
H = list(map(int, input().split()))

road = {}
for i, h in zip(range(1, N + 1, 1), H):
    road[i] = {
        "high": h,
        "connect": [],
        "good": True
    }

for i in range(M):
    Ai, Bi = map(int, input().split())

    road[Ai]["connect"] = list(set(road[Ai]["connect"] + [Bi]))
    if road[Ai]["high"] <= road[Bi]["high"]:
        road[Ai]["good"] = False

    road[Bi]["connect"] = list(set(road[Bi]["connect"] + [Ai]))
    if road[Bi]["high"] <= road[Ai]["high"]:
        road[Bi]["good"] = False

print(len([1 for i in range(1, N + 1, 1) if road[i]["good"] is True]))


Fixed submission:
# input
N, M = map(int, input().split())
H = list(map(int, input().split()))

cnt = N
road = {}
for i, h in zip(range(1, N + 1, 1), H):
    road[i] = {
        "high": h,
        "good": True
    }

for i in range(M):
    Ai, Bi = map(int, input().split())

    if road[Ai]["good"] is True and road[Ai]["high"] <= road[Bi]["high"]:
        road[Ai]["good"] = False
        cnt -= 1

    if road[Bi]["good"] is True and road[Bi]["high"] <= road[Ai]["high"]:
        road[Bi]["good"] = False
        cnt -= 1

print(cnt)
Buggy python submission (verdict: Runtime Error):
# input
A, B, C = map(int, input().split())

# change box
tmp = A
A = B
B = tmp

tmp = A
A = C
C = tmp
    

# output
print("{} {} {]".format(A, B, C))

Fixed submission:
# input
A, B, C = map(int, input().split())

# change box
tmp = A
A = B
B = tmp

tmp = A
A = C
C = tmp


# output
print("{} {} {}".format(A, B, C))

Buggy python submission (verdict: Runtime Error):
# input
A, B, C = map(int, input().split())

# output
print("{} {} {]".format(C, A, B))

Fixed submission:
# input
A, B, C = map(int, input().split())

# change box
tmp = A
A = B
B = tmp

tmp = A
A = C
C = tmp


# output
print("{} {} {}".format(A, B, C))
Buggy python submission (verdict: Runtime Error):
# input
S = input()

# check
N = len(S)

print(f"{S}\t{S[:int((N - 1) / 2)]}\t{S[int((N + 2) / 2):]}")

if S[:int((N - 1) / 2)] == S[int((N + 2) / 2):]:
    print("Yes")
else:
    print("No")

Fixed submission:
# input
S = input()

# check
N = len(S)

if S[:int((N - 1) / 2)] == S[int((N + 2) / 2):]:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
# input
A, B = map(int, input().split())

# check
ans = -1
for n in range(100 / 0.1, -1, -1):
    if int(n * 0.08) == A and int(n * 0.1) == B:
        ans = n

print(ans)

Fixed submission:
# input
A, B = map(int, input().split())

# check
ans = -1
for n in range(1000, -1, -1):
    if int(n * 0.08) == A and int(n * 0.1) == B:
        ans = n

print(ans)

Buggy python submission (verdict: Runtime Error):
# input
A, B = map(int, input().split())

# check
# kimeuchi = max([int(A / 0.08), int(B / 0.1)])
# if int(kimeuchi * 0.08) == A and int(kimeuchi * 0.1) == B:
#
#     print(kimeuchi)
# else:
#     print(-1)

ans = -1
for n in range(100 * 0.1, -1 , -1):
    if int(n * 0.08) == A and int(n * 0.1) == B:
        ans = n

print(ans)

Fixed submission:
# input
A, B = map(int, input().split())

# check
ans = -1
for n in range(1000, -1, -1):
    if int(n * 0.08) == A and int(n * 0.1) == B:
        ans = n

print(ans)
Buggy python submission (verdict: Runtime Error):
# input
N, M = map(int, input().split())

c = []

c_append = c.append

for i in range(M):
    sm, cm = map(int, input().split())
    c_append((sm, cm))

if (1, 0) in c:
    print(-1)
else:
    ans = -1

    # check
    for i in range(1000):
        str_i = str(i)

        if N < len(str_i):
            break

        if False not in [int(str_i[sm - 1]) == cm for sm, cm in c]:
            ans = i
            break

    print(ans)

Fixed submission:
# input
N, M = map(int, input().split())

c = []

c_append = c.append

for i in range(M):
    sm, cm = map(int, input().split())
    c_append((sm, cm))

ans = -1

# check
for i in range(1000):
    str_i = str(i)

    if N < len(str_i):
        break

    if N == len(str_i) and False not in [int(str_i[sm - 1]) == cm for sm, cm in c]:
        ans = i
        break

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial

# input
n, a, b = map(int, input().split())

ans = 0
for i in range(1, n + 1, 1):
    if i == a or i == b:
        continue

    ans += factorial(n) // (factorial(n - i) * factorial(i))

print(ans % (10 ** 9 + 7))

Fixed submission:
# input
n, a, b = map(int, input().split())
mod = 10 ** 9 + 7
al = (pow(2, n, mod) - 1)


# 参考：https://qiita.com/MyOden/items/b669bfbf6dbf83242bdf =>フェルマーの小定理を基に演算関数を用意
def fur(n, r):
    p, q = 1, 1
    for i in range(r):
        p = p * (n - i) % mod
        q = q * (i + 1) % mod
    return p * pow(q, mod - 2, mod) % mod


nca = fur(n, a)
ncb = fur(n, b)
ans = (al - nca - ncb) % mod

print(ans)
Buggy python submission (verdict: Runtime Error):
# input
N, M = map(int, input().split())

# check
AC_questions = {}
for i in range(M):
    P, S = map(str, input().split())

    if P not in AC_questions:
        AC_questions[P] = {
            "wa_cnt": 0,
            "ac": False
        }

    if AC_questions[P]["wa_cnt"] is True:
        continue
    elif S == "AC":
        AC_questions[P]["ac"] = True
    # S == "WA"
    else:
        AC_questions[P]["wa_cnt"] += 1
        
AC_cnt = sum([1 for a in AC_questions if a['ac'] is True])
WA_cnt = sum([a["wa_cnt"] for a in AC_questions if a["ac"] is True])

print(AC_cnt, WA_cnt)

Fixed submission:
# input
N, M = map(int, input().split())

# check
AC_questions = {}
for i in range(M):
    P, S = map(str, input().split())

    if P not in AC_questions:
        AC_questions[P] = {
            "wa_cnt": 0,
            "ac": False
        }

    if AC_questions[P]["ac"] is True:
        continue
    elif S == "AC":
        AC_questions[P]["ac"] = True
    # S == "WA"
    else:
        AC_questions[P]["wa_cnt"] += 1

AC_cnt = sum([1 for key in AC_questions.keys() if AC_questions[key]['ac'] is True])
WA_cnt = sum([AC_questions[key]["wa_cnt"] for key in AC_questions.keys() if AC_questions[key]["ac"] is True])

print(AC_cnt, WA_cnt)
Buggy python submission (verdict: Time Limit Exceeded):
# input
A, B, K = map(int, input().split())

# check
for i in range(K):
    if A >= 1:
         A -= 1
    elif B >= 1:
         B -= 1
    else:
        continue

print(A, B)

Fixed submission:
# input
A, B, K = map(int, input().split())

# check
if A + B > K >= A:
    K -= A
    A = 0
    B -= K
elif A + B <= K:
    A, B = 0, 0
else:
    A -= K

print(A, B)
Buggy python submission (verdict: Runtime Error):
from sympy import nextprime

# input
X = int(input())

print(nextprime(X))

Fixed submission:
# check
def is_prime(n):
    if n < 2:
        return False
    elif n == 2:
        return True
    else:
        for p in range(2, n):
            if n % p == 0:
                return False
        else:
            return True


# input
X = int(input())

while is_prime(X) is False:
    X += 1

print(X)
Buggy python submission (verdict: Runtime Error):
from math import gcd

# input
A, B = map(int, input().split())

snack = (A * B) // gcd(A, B)

print(snack)

Fixed submission:
def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if x % y == 0:
        return y
    else:
        while x % y != 0:
            z = x % y
            x = y
            y = z
        return z


def lcm(m, n):
    return (m * n) // gcd(m, n)


# input
A, B = map(int, input().split())

# lcm
snack = lcm(A, B) 

print(snack)

Buggy python submission (verdict: Time Limit Exceeded):

# input
A, B = map(int, input().split())

snack = max([A, B])
while snack % A != 0 or snack % B != 0:
    snack += 1

print(snack)

Fixed submission:
def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if x % y == 0:
        return y
    else:
        while x % y != 0:
            z = x % y
            x = y
            y = z
        return z


def lcm(m, n):
    return (m * n) // gcd(m, n)


# input
A, B = map(int, input().split())

# lcm
snack = lcm(A, B) 

print(snack)

Buggy python submission (verdict: Runtime Error):
# input
A, B = int(input())

snack = max([A, B])
while snack % A != 0 and snack % B != 0:
    snack += 1

print(snack)

Fixed submission:
def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if x % y == 0:
        return y
    else:
        while x % y != 0:
            z = x % y
            x = y
            y = z
        return z


def lcm(m, n):
    return (m * n) // gcd(m, n)


# input
A, B = map(int, input().split())

# lcm
snack = lcm(A, B) 

print(snack)
Buggy python submission (verdict: Runtime Error):
# input
N = int(input())
S = input()

# check
if N < 2 or N % 2 != 0:
    print("No")

if N == 2:
    right = S[0]
    left = S[1]
else:
    c = N // 2
    right = S[0:c]
    left = S[c:]

print(f"{right} {left}")

if right == left:
    print("Yes")
else:
    print("No")

Fixed submission:
# input
N = int(input())
S = input()

# check
if N < 2 or N % 2 != 0:
    print("No")
else:
    if N == 2:
        right = S[0]
        left = S[1]
    else:
        c = N // 2
        right = S[0:c]
        left = S[c:]

    if right == left:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
from itertools import combinations, combinations_with_replacement
from math import sqrt

# input
N = int(input())
xy = []
xy_append = xy.append
for n in range(N):
    x, y = map(int, input().split())
    xy_append((x, y))

nC2 = list(combinations(xy, 2))
dist = []
d_append = dist.append
for a, b in nC2:
    d_append(sqrt((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2))

dist_sum = 0
dist_case = combinations_with_replacement(dist, 2)
for m, n in dist_case:
    dist_sum += m + n

print(dist_sum / len(dist_case))


Fixed submission:
from itertools import combinations
from math import sqrt

# input
N = int(input())
xy = []
xy_append = xy.append
for n in range(N):
    x, y = map(int, input().split())
    xy_append((x, y))

nC2 = list(combinations(xy, 2))
dist = []
d_append = dist.append
for a, b in nC2:
    d_append(sqrt((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2))

if len(dist) == 1:
    print(dist[0])
else:
    dist_sum = 0
    dist_case = list(combinations(dist, N - 1))
    for d in dist_case:
        dist_sum += sum(d)

    print(dist_sum / len(dist_case))
Buggy python submission (verdict: Time Limit Exceeded):
# input
N = int(input())

# check
all_case = [
    sum((i - 1, N // i - 1))
    for i in range(1, N + 1, 1)
    if N % i == 0
]

print(min(all_case))

Fixed submission:
def get_div(n):
    div = []
    append = div.append
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            append(i)
            if i != n // i:
                append(n // i)
    div.sort()
    return div


# input
N = int(input())

# div = divisors(N)
div = get_div(N)
mov = []
append = mov.append
for x in div:
    y = N // x
    append(sum([x - 1, y - 1]))

print(min(mov))

# check
cnt = 0

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

# check
all_case = [
    sum((i - 1, j - 1))
    for i in range(1, N + 1, 1)
    for j in range(1, N + 1, 1)
    if i * j == N
]

print(min(all_case))

Fixed submission:
def get_div(n):
    div = []
    append = div.append
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            append(i)
            if i != n // i:
                append(n // i)
    div.sort()
    return div


# input
N = int(input())

# div = divisors(N)
div = get_div(N)
mov = []
append = mov.append
for x in div:
    y = N // x
    append(sum([x - 1, y - 1]))

print(min(mov))

# check
cnt = 0