Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a=input().split()
a=[int(i) for i in a]
a.sort()
if a=[5, 5, 7]:
	print("YES")
else:
 	print("NO")
 
  

Fixed submission:
a=input().split()
a=[int(i) for i in a]
a.sort()
if a[0]==5 and a[1]==5 and a[2]==7:
	print("YES")
else:
 	print("NO")

Buggy python submission (verdict: Runtime Error):
a=[int(i) for i in input().split()]
a.sort()
if a=[5, 5, 7]:
	print("YES")
else:
 	print("NO")
 
  

Fixed submission:
a=input().split()
a=[int(i) for i in a]
a.sort()
if a[0]==5 and a[1]==5 and a[2]==7:
	print("YES")
else:
 	print("NO")

Buggy python submission (verdict: Runtime Error):
a=[int(i) for i in input().split()]
a.sort()
if a=[5, 5, 7]:
 print("YES")
else print("NO");
 
  

Fixed submission:
a=input().split()
a=[int(i) for i in a]
a.sort()
if a[0]==5 and a[1]==5 and a[2]==7:
	print("YES")
else:
 	print("NO")

Buggy python submission (verdict: Runtime Error):
a=[int(i) for i in input().split()]
a.sort()
if a=[5, 5, 7]:
 print("YES")
else print("NO"):
 
  

Fixed submission:
a=input().split()
a=[int(i) for i in a]
a.sort()
if a[0]==5 and a[1]==5 and a[2]==7:
	print("YES")
else:
 	print("NO")
Buggy python submission (verdict: Time Limit Exceeded):

n = int(input())
li = list(map(int,input().split()))
mod = 10**9+7

sum = 0
for i in range(0,n-1):
    for j in range(i+1,n):
        sum += li[i]*li[j] % mod
        sum %= mod
print(sum)

Fixed submission:
n = int(input())
li = list(map(int,input().split()))
mod = 10**9+7

sum = 0
for i in range(0,n):
    sum += li[i]
    sum %= mod

ans = 0
for i in range(0,n):
    sum -= li[i]
    if sum < 0:
        sum += mod
    ans += li[i] * sum
    ans %= mod
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())

s = 0
while True:
    x = n % 10
    s += x
    n = int(n/10)
    if(n==0):
        break
if s%9==0:
    print("Yes")
else:
    print("No")

Fixed submission:
n = input()

s = 0
for i in range(0,len(n)):
    s += int(n[i:i+1])

if s%9==0:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n = int(input())

for i in rang(0,2):
    if( n % 10 == 7):
        print("YES")
        break
    n /= 10
else:
    print("NO")

Fixed submission:
n = int(input())

for i in range(0,3):
    if( n % 10 == 7):
        print("Yes")
        break
    n = int(n / 10)
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np

stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n = ni()
    A = nl()
    mod = 10 ** 9 + 7
    ans = 0
    for i in range(n):
        ans += (np.sum(A[i + 1:]) * A[i]) % mod
        ans %= mod
    print(int(ans))


if __name__ == '__main__':
    main()


Fixed submission:
import sys

stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n = ni()
    A = nl()
    mod = 10 ** 9 + 7
    s = sum(A)
    q = sum([a ** 2 for a in A])
    ans = (((s * s) - q)) // 2
    print(int(ans % mod))


if __name__ == '__main__':
    main()

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


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n = ni()
    A = nl()
    mod = 10 ** 9 + 7
    ans = 0
    for i in range(n):
        for j in range(i + 1, n):
            ans += A[i] * A[j] % mod
            ans %= mod
    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
import sys

stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n = ni()
    A = nl()
    mod = 10 ** 9 + 7
    s = sum(A)
    q = sum([a ** 2 for a in A])
    ans = (((s * s) - q)) // 2
    print(int(ans % mod))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from math import gcd


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n = ni()
    A = nl()
    c = A[0]
    b = []

    m = A[0]

    for i in range(n - 1):
        m *= A[i + 1]

    for i in range(n - 1):
        c = gcd(c, A[i + 1])

    for i in range(n):
        b.append(gcd(A[i], m // A[i]))

    if c == 1 and all([bb == 1 for bb in b]):
        print('pairwise coprime')
    elif c == 1:
        print('setwise coprime')
    else:
        print('not coprime')


if __name__ == '__main__':
    main()


Fixed submission:
import sys
from math import gcd


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n = ni()
    A = nl()
    c = A[0]
    b = []

    cnt = [0] * (10 ** 6 + 1)

    for a in A:
        c = gcd(c, a)
        cnt[a] += 1

    max_num = 0
    for i in range(2, 10 ** 6 + 1):
        max_num = max(max_num, sum(cnt[i::i]))

    if c == 1 and max_num <= 1:
        print('pairwise coprime')
    elif c == 1:
        print('setwise coprime')
    else:
        print('not coprime')


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
from collections import Counter

stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    h, w, m = nm()
    H = []
    W = []
    for i in range(m):
        hh, ww = nm()
        H.append(hh)
        W.append(ww)
    h_m = Counter(H).most_common()[0]
    w_m = Counter(W).most_common()[0]
    ans_1 = h_m[1]
    ans_2 = w_m[1]
    WW = []
    HH = []

    for i in range(m):
        if H[i] == h_m[0]:
            continue
        WW.append(W[i])

    for i in range(m):
        if W[i] == w_m[0]:
            continue
        HH.append(H[i])

    ans_1 += Counter(WW).most_common()[0][1]
    ans_2 += Counter(HH).most_common()[0][1]

    print(max(ans_1, ans_2))


if __name__ == '__main__':
    main()


Fixed submission:
import sys
from collections import Counter

stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    h, w, m = nm()
    H = []
    W = []
    for i in range(m):
        hh, ww = nm()
        H.append(hh)
        W.append(ww)
    h_m = Counter(H).most_common()[0]
    w_m = Counter(W).most_common()[0]
    ans_1 = h_m[1]
    ans_2 = w_m[1]
    WW = []
    HH = []

    for i in range(m):
        if H[i] == h_m[0]:
            continue
        WW.append(W[i])

    for i in range(m):
        if W[i] == w_m[0]:
            continue
        HH.append(H[i])
    if WW:
        ans_1 += Counter(WW).most_common()[0][1]
    if HH:
        ans_2 += Counter(HH).most_common()[0][1]

    print(max(ans_1, ans_2))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    S = ns()
    A = []
    ans = 0
    for s in S:
        if s == 'R':
            ans += 1
        else:
            A.append(ans)
            ans = 0
    print(max(A))


if __name__ == '__main__':
    main()


Fixed submission:
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    S = ns()
    if S == 'RRR':
        print(3)
    elif S == 'RRS' or S == 'SRR':
        print(2)
    elif S == 'SSR' or S == 'SRS' or S == 'RSS' or S == 'RSR':
        print(1)
    else:
        print(0)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
ans = 1000
for ii in range(2 ** n):
    tmp = 1000
    kab = 0
    action = 'buy'
    for i in range(n):
        if (ii >> i) & 1:
            if action == 'buy':
                if tmp < A[i]:
                    break
                kab += tmp // A[i]
                tmp = tmp % A[i]
                action = 'sell'

            elif action == 'sell':
                if kab == 0:
                    break
                tmp += kab * A[i]
                kab = 0
                action = 'buy'
    else:
        ans = max(ans, tmp)

print(ans)


Fixed submission:
n = int(input())
A = list(map(int, input().split()))
ans = 1000
for i in range(n - 1):
    if A[i] < A[i + 1]:
        ans += ans // A[i] * (A[i + 1] - A[i])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
ans = 1000
for ii in range(2 ** n):
    for jj in range(2 ** n):
        tmp = 1000
        kab = 0
        for i in range(n):
            if (ii >> i) & 1:  # buy
                if tmp < A[i]:
                    break
                kab += tmp // A[i]
                tmp = tmp % A[i]

            if (jj >> i) & 1:  # sell
                if kab == 0:
                    break
                tmp += kab * A[i]
                kab = 0
        else:
            ans = max(ans, tmp)

print(ans)


Fixed submission:
n = int(input())
A = list(map(int, input().split()))
ans = 1000
for i in range(n - 1):
    if A[i] < A[i + 1]:
        ans += ans // A[i] * (A[i + 1] - A[i])
print(ans)
Buggy python submission (verdict: Runtime Error):
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if k >= sum(a) + sum(b):
    print(n + m)
    exit()
ans = -1
total_time = 0
a_cnt = 0
b_cnt = 0
while total_time <= k:
    read_time = min(a[a_cnt], b[b_cnt])
    if read_time == a[a_cnt]:
        if a_cnt < len(a) - 1:
            a_cnt += 1
        else:
            b_cnt += 1
    else:
        if b_cnt < len(b) - 1:
            b_cnt += 1
        else:
            a_cnt += 1
    total_time += read_time
    ans += 1

print(ans)


Fixed submission:
import numpy as np
from bisect import bisect_right

n, m, k = map(int, input().split())
a = [0] + list(map(int, input().split()))
b = [0] + list(map(int, input().split()))
a = np.cumsum(a)
b = np.cumsum(b)

ans = 0
for a_num, time in enumerate(a):
    if time > k:
        continue
    b_num = bisect_right(b, k - time)
    num = a_num + b_num - 1
    if num > ans:
        ans = num
print(ans)

Buggy python submission (verdict: Runtime Error):
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if k >= sum(a) + sum(b):
    print(n + m)
    exit()
ans = -1
total_time = 0
a_cnt = 0
b_cnt = 0
while total_time <= k:
    read_time = min(a[a_cnt], b[b_cnt])
    if read_time == a[a_cnt]:
        if a_cnt < len(a):
            a_cnt += 1
        else:
            b_cnt += 1
    else:
        if b_cnt < len(b):
            b_cnt += 1
        else:
            a_cnt += 1
    total_time += read_time
    ans += 1

print(ans)


Fixed submission:
import numpy as np
from bisect import bisect_right

n, m, k = map(int, input().split())
a = [0] + list(map(int, input().split()))
b = [0] + list(map(int, input().split()))
a = np.cumsum(a)
b = np.cumsum(b)

ans = 0
for a_num, time in enumerate(a):
    if time > k:
        continue
    b_num = bisect_right(b, k - time)
    num = a_num + b_num - 1
    if num > ans:
        ans = num
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np

n = int(input())
a = list(map(int, input().split()))
a = np.array(a, dtype=np.float64)
ans = np.prod(a)
print(int(ans))


Fixed submission:
n = int(input())
A = list(map(int, input().split()))
if 0 in A:
    print(0)
    exit()
ans = 1
for a in A:
    ans *= a
    if ans > 10 ** 18:
        print(-1)
        exit()
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans = 1
for i in a:
    ans *= i

if ans > 1e18:
    print(-1)
else:
    print(ans)


Fixed submission:
n = int(input())
A = list(map(int, input().split()))
if 0 in A:
    print(0)
    exit()
ans = 1
for a in A:
    ans *= a
    if ans > 10 ** 18:
        print(-1)
        exit()
print(ans)

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

n = int(input())
a = list(map(int, input().split()))
ans = reduce(mul, a)

if ans > 1e18:
    print(-1)
else:
    print(ans)


Fixed submission:
n = int(input())
A = list(map(int, input().split()))
if 0 in A:
    print(0)
    exit()
ans = 1
for a in A:
    ans *= a
    if ans > 10 ** 18:
        print(-1)
        exit()
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans = 1
for i in a:
    ans *= i

if ans > 1e18:
    print(-1)
else:
    print(ans)


Fixed submission:
n = int(input())
A = list(map(int, input().split()))
if 0 in A:
    print(0)
    exit()
ans = 1
for a in A:
    ans *= a
    if ans > 10 ** 18:
        print(-1)
        exit()
print(ans)
Buggy python submission (verdict: Runtime Error):
import itertools
import numpy as np
n, m, x = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(n)]
l = sorted(l)
l = np.array(l)
ans = np.sum(l, 0)[0]
ans_s = np.sum(l, 0)
if np.any(ans_s[1:] < x):
    print(-1)
    exit()
count = 0
for i in range(1, n + 1):
    for j in itertools.combinations(l, i):
        tot = np.sum(j, 0)
        if np.all(tot[1:] >= x) and tot[0] < ans:
            ans = tot[0]
            print(int(ans))
            exit()


Fixed submission:
s = input()
t = input()
if s == t[:-1]:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
x = int(input())
for i in range(x // 2 + 1):
    if pow(x - pow(i, 5), 1 / 5).is_integer():
        print(i, int(-pow(x - pow(i, 5), 1 / 5)))
        exit()


Fixed submission:
import numpy as np


def main():
    x = int(input())
    A = np.arange(-120, 120)
    a = A ** 5
    for i, a_1 in enumerate(a):
        for j, a_2 in enumerate(a):
            if a_1 - a_2 == x:
                print(A[i], A[j])
                return


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
x = int(input())
for i in range(x // 2):
    if pow(x - pow(i, 5), 1 / 5).is_integer():
        print(i, int(-pow(x - pow(i, 5), 1 / 5)))
        exit()

Fixed submission:
import numpy as np


def main():
    x = int(input())
    A = np.arange(-120, 120)
    a = A ** 5
    for i, a_1 in enumerate(a):
        for j, a_2 in enumerate(a):
            if a_1 - a_2 == x:
                print(A[i], A[j])
                return


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import itertools

n, m, q = map(int, input().split())
abcd = [tuple(map(int, input().split())) for _ in range(Q)]
ans = 0
for com in itertools.combinations_with_replacement(range(1, M + 1), N):
    score = sum([d for a, b, c, d in abcd if com[b-1] - com[a-1] == c])
    if ans < score:
        ans = score
print(ans)


Fixed submission:
import itertools

n, m, q = map(int, input().split())
abcd = [tuple(map(int, input().split())) for _ in range(q)]
ans = 0
for com in itertools.combinations_with_replacement(range(1, m + 1), n):
    score = sum([d for a, b, c, d in abcd if com[b-1] - com[a-1] == c])
    if ans < score:
        ans = score
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a = int(input())
l = list(map(int, input().split()))
l_2 = list(set(l))
l_2.sort()
if l_2[0] == 1:
    for i in range(len(l_2) - 1):
        print(l.count(l_2[i]))
        word = '0\n' * (l_2[i + 1] - l_2[i])
        if l_2[i + 1] - l_2[i] - 1 > 0:
            print(word[:-3])
    print(l.count(l_2[-1]))
    word = '0\n' * (a - max(l_2))
    print(word[:3 * (a - max(l_2) - 1) + 1])

Fixed submission:
import collections
a = int(input())
l = list(map(int, input().split()))
l_2 = collections.Counter(l)
for i in range(a):
    print(l_2[i + 1])

Buggy python submission (verdict: Time Limit Exceeded):
a = int(input())
l = list(map(int, input().split()))
tot = 0
for i in range(a):
    if tot <= a - 1:
        print(l.count(i + 1))
        tot += l.count(i + 1)
    else:
        n = a - (i + 1)
        print('0\n' * n)
        exit()


Fixed submission:
import collections
a = int(input())
l = list(map(int, input().split()))
l_2 = collections.Counter(l)
for i in range(a):
    print(l_2[i + 1])

Buggy python submission (verdict: Time Limit Exceeded):
a = int(input())
l = list(map(int, input().split()))
for i in range(a):
    print(l.count(i + 1))


Fixed submission:
import collections
a = int(input())
l = list(map(int, input().split()))
l_2 = collections.Counter(l)
for i in range(a):
    print(l_2[i + 1])
Buggy python submission (verdict: Runtime Error):
import numpy as np
import math
import itertools
n = int(input())
l = list(map(int, input().split()))
ans = 0
pos = [0] * n
for i in range(n):
    pos[i] = list(map(lambda x: abs(x - i), list(range(n))))
pos = np.array(pos)
tot = np.zeros(math.factorial(n))
for i in range(n):
    pos[i, :] = pos[i, :] * l[i]
for i, x in enumerate(itertools.permutations(range(n))):
    tot[i] = np.sum(pos[list(range(n)), x])
print(int(np.max(tot)))


Fixed submission:
import numpy as np
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
A = np.array(read().split(), np.int64)
I = np.argsort(A)[::-1].tolist()
A = A[I].tolist()

dp = np.zeros(1, np.int64)

for n, (i, x) in enumerate(zip(I, A)):
    newdp = np.zeros(len(dp) + 1, np.int64)
    left_ind = np.arange(len(dp))
    right_ind = N - 1 - n + left_ind
    left_cost = x * np.abs(left_ind - i)
    right_cost = x * np.abs(right_ind - i)
    np.maximum(newdp[:-1], dp + right_cost, out=newdp[:-1])
    np.maximum(newdp[1:], dp + left_cost, out=newdp[1:])
    dp = newdp

print(dp.max())
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(input())
tot = 0
R = [i for i, x in enumerate(s) if x == 'R']
G = [i for i, x in enumerate(s) if x == 'G']
B = [i for i, x in enumerate(s) if x == 'B']
tot += len(R) * len(G) * len(B)
for i in range(len(R)):
    for j in range(len(G)):
        for k in range(len(B)):
            if 2 * R[i] == G[j] + B[k] or 2 * G[j] == R[i] + B[k] or 2 * B[k] == G[j] + R[i]:
                tot -= 1
print(tot)


Fixed submission:
n = int(input())
s = list(input())
tot = 0
tot += s.count('R') * s.count('G') * s.count('B')
for i in range(n):
    for j in range(i + 1, n):
        k = 2 * j - i
        if k < n and s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            tot -= 1
print(tot)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(input())
tot = 0
for i in range(n):
    for j in range(i + 1, n):
        if s[i] != s[j]:
            li = ['R', 'G', 'B']
            li.remove(s[i])
            li.remove(s[j])
            tot += s[j + 1:].count(li[0])
            if n > 2 * j - i and s[2 * j - i] == li[0]:
                tot -= 1

print(tot)


Fixed submission:
n = int(input())
s = list(input())
tot = 0
tot += s.count('R') * s.count('G') * s.count('B')
for i in range(n):
    for j in range(i + 1, n):
        k = 2 * j - i
        if k < n and s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            tot -= 1
print(tot)
Buggy python submission (verdict: Runtime Error):
import math


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


def main():
    n, m = map(int, input().split())
    print(combinations_count(n, 2) + combinations_count(m, 2))


if __name__ == "__main__":
    main()


Fixed submission:
import math


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


def main():
    n, m = map(int, input().split())
    if n < 2:
        even = 0
    else:
        even = combinations_count(n, 2)
    if m < 2:
        odd = 0
    else:
        odd = combinations_count(m, 2)
    print(even + odd)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
l = list(map(int, input().split()))
l = list(map(lambda x: (((x + 1) * x) / 2) / x, l))
l_2 = []
for i in range(len(l) - (k - 1)):
    l_2 += [sum(l[i:i + k])]
print(max(l_2))


Fixed submission:
from itertools import accumulate
n, k = map(int, input().split())
l = list(map(int, input().split()))
l = list(map(lambda x: (((x + 1) * x) / 2) / x, l))
s = list(accumulate(l))
l_2 = [s[k - 1]]
for i in range(len(l) - (k - 1) - 1):
    l_2 += [s[i + k] - s[i]]
print(max(l_2))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
P = list(map(int, input().split()))
cnt = 0
for i, p in enumerate(P):
    if p == min(P[:i + 1]):
        cnt += 1
print(cnt)


Fixed submission:
n = int(input())
P = list(map(int, input().split()))
cnt = 0
m = P[0]
for p in P:
    if m >= p:
        cnt += 1
        m = p
print(cnt)
Buggy python submission (verdict: Runtime Error):
def make_divisors(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


n = int(input())
low, up = make_divisors(n)
if len(low) != 1:
    ans = low[0] + up[0]
    for i in range(1, len(low)):
        tmp = low[i] + up[i]
        if tmp < ans:
            ans = tmp
    print(tmp - 2)
else:
    print(n - 1)

Fixed submission:
def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            upper_divisors.append(n//i)
        i += 1
    return lower_divisors, upper_divisors


n = int(input())
low, up = make_divisors(n)
if len(low) != 1:
    # ans = low[0] + up[0]
    # for i in range(1, len(low)):
    #     tmp = low[i] + up[i]
    #     if tmp < ans:
    #         ans = tmp
    print(low[-1] + up[-1] - 2)
else:
    print(n - 1)

Buggy python submission (verdict: Runtime Error):
def make_divisors(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


n = int(input())
low, up = make_divisors(n)
if up:
    ans = low[0] + up[0]
    for i in range(1, len(low)):
        tmp = low[i] + up[i]
        if tmp < ans:
            ans = tmp
    print(tmp - 2)
else:
    print(n - 1)


Fixed submission:
def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            upper_divisors.append(n//i)
        i += 1
    return lower_divisors, upper_divisors


n = int(input())
low, up = make_divisors(n)
if len(low) != 1:
    # ans = low[0] + up[0]
    # for i in range(1, len(low)):
    #     tmp = low[i] + up[i]
    #     if tmp < ans:
    #         ans = tmp
    print(low[-1] + up[-1] - 2)
else:
    print(n - 1)