Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
P = list(map(int, input().split()))
for i in range(N):
    P[i] -= 1
C = list(map(int, input().split()))

ans = -(10 ** 18)

for si in range(N):
    x = si
    loop = []
    total = 0
    while 1:
        x = P[x]
        loop.append(C[x])
        total += C[x]
        if x == si:
            break
    T = len(loop)  # 周期の大きさ
    tmp = 0
    for i in range(T):
        tmp += loop[i]
        if K < i + 1:
            break
        now = tmp
        if total > 0:  # loopの和が正ならloopを回した方がお得
            loop_times = (K - (i + 1)) // T  # 何周できるか
            now += total * loop_times
        ans = max(ans, now)

print(ans)



Fixed submission:
N, K = map(int, input().split())
P = list(map(int, input().split()))
for i in range(N):
    P[i] -= 1
C = list(map(int, input().split()))

ans = -(10 ** 18)

for si in range(N):
    x = si
    loop = []
    total = 0
    while 1:
        x = P[x]
        loop.append(C[x])
        total += C[x]
        if x == si:
            break
    T = len(loop)  # 周期の大きさ
    tmp = 0
    for i in range(T):
        tmp += loop[i]
        if K < i + 1:
            break
        now = tmp
        if total > 0:  # loopの和が正ならloopを回した方がお得
            loop_times = (K - (i + 1)) // T  # 何周できるか
            now += total * loop_times
        ans = max(ans, now)

print(ans)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))

ok = 10 ** 9  # 解が存在する値
ng = -1  # 解が存在しない値


def solve(x):
    """
    一番長いのをx以下にできるか
    → 全部をx以下にするのに切る回数 <= K
    """
    res = 0
    for i in range(N):
        res += (A[i] - 1) // x

    return res <= K


while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    if solve(mid):
        ok = mid
    else:
        ng = mid

print(ok)

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

ok = 10 ** 9  # 解が存在する値
ng = 0  # 解が存在しない値


def solve(x):
    """
    一番長いのをx以下にできるか
    → 全部をx以下にするのに切る回数 <= K
    """
    res = 0
    for i in range(N):
        res += (A[i] - 1) // x

    return res <= K


while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    if solve(mid):
        ok = mid
    else:
        ng = mid

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

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    N = int(input())
    MAX = int(N ** 0.5)

    def f(x, y, z, n):
        return x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x == n

    res = [0] * 10008

    for n in range(1, N + 1):
        ans = 0
        li = []
        for x in range(1, MAX + 1):
            for y in range(1, MAX + 1):
                delta = (y + x) ** 2 - 4 * (x ** 2 + y ** 2 + x * y - n)
                if delta >= 0:
                    z = (-(y + x) + (delta) ** 0.5) / 2
                    if z > 0 and z % 1 == 0 and f(x, y, z, n):
                        ans += 1
                        li.append((x, y, z))

        # print(n, ans, li)
        print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    N = int(input())
    MAX = int(N ** 0.5)

    res = [0] * 10008

    ans = 0
    li = []
    for x in range(1, MAX + 1):
        for y in range(1, MAX + 1):
            for z in range(1, MAX + 1):
                tmp = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
                if tmp <= 10000:
                    res[tmp] += 1

    for i in range(1, N + 1):
        print(res[i])


if __name__ == "__main__":
    main()

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

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    N = int(input())
    MAX = int(N ** 0.5)

    def f(x, y, z, n):
        return x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x == n

    res = [0] * 10008

    for n in range(1, N + 1):
        ans = 0
        li = []
        for x in range(1, MAX + 1):
            for y in range(1, MAX + 1):
                delta = (y + x) ** 2 - 4 * (x ** 2 + y ** 2 + x * y - n)
                if delta >= 0:
                    z = (-(y + x) + (delta) ** 0.5) / 2
                    if z > 0 and z % 1 == 0 and f(x, y, z, n):
                        ans += 1
                        li.append((x, y, z))

        # print(n, ans, li)
        print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    N = int(input())
    MAX = int(N ** 0.5)

    res = [0] * 10008

    ans = 0
    li = []
    for x in range(1, MAX + 1):
        for y in range(1, MAX + 1):
            for z in range(1, MAX + 1):
                tmp = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
                if tmp <= 10000:
                    res[tmp] += 1

    for i in range(1, N + 1):
        print(res[i])


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

# d = dict()


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

    # divisors.sort()
    # return res + len(divisors)
    return len(divisors)


ans = 0
for i in range(1, N + 1):
    ans += i * make_divisors(i)

print(ans)


Fixed submission:
N = int(input())


def num_divisors_table(n):
    table = [0] * (n + 1)

    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1

    return table


# li = np.array(num_divisors_table(N))
# k = np.arange(N + 1)

li = num_divisors_table(N)

# print(sum(li * k))
ans = 0
for i in range(N + 1):
    ans += i * li[i]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from scipy.sparse.csgraph import csgraph_from_dense, dijkstra
import numpy as np

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    N, M = map(int, input().split())
    F = [[0 for i in range(N)] for j in range(N)]

    for i in range(M):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        F[a][b] = 1
        F[b][a] = 1

    G = csgraph_from_dense(F, null_value=0)
    d, predecessors = dijkstra(G, return_predecessors=True)
    # print(d, "\n", predecessors)

    # print(type(G))
    if np.any(d[0] == np.inf):
        print("No")
        sys.exit()
    else:
        print("Yes")
        for i in range(1, N):
            print(predecessors[0][i] + 1)


if __name__ == "__main__":
    main()


Fixed submission:
import sys
import heapq


input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    N, M = map(int, input().split())
    adj = [[] for _ in range(N)]

    for i in range(M):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        adj[a].append(b)
        adj[b].append(a)

    # print(adj)

    INF = 10 ** 18
    WHITE = 0
    GRAY = 1
    BLACK = 2

    def dijkstra(s):
        color = [WHITE] * N
        d = [INF] * N
        p = [-1] * N
        d[s] = 0
        PQ = []
        heapq.heappush(PQ, (0, s))  # (距離, 頂点の番号)
        color[s] = GRAY

        while PQ:
            distance, u = heapq.heappop(PQ)
            color[u] = BLACK

            if d[u] < distance:
                continue
            # print(u)

            for j in range(len(adj[u])):
                v = adj[u][j]
                if color[v] == BLACK:
                    continue
                if d[v] > d[u] + 1:
                    d[v] = d[u] + 1
                    p[v] = u
                    heapq.heappush(PQ, (d[v], v))
                    color[v] = GRAY

        return d, p

    d, p = dijkstra(0)
    # print(d, p)
    if INF in d[1:]:
        print("No")
        sys.exit()
    else:
        print("Yes")
        for i in range(1, N):
            print(p[i] + 1)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

# from collections import defaultdict


def gcd(*numbers):
    return reduce(math.gcd, numbers)


def reducef(x, y):
    return gcdd[(x, y)]


def gcd2(*numbers):
    return reduce(reducef, numbers)


K = int(input())
ans = 0
# gcdd=defaultdict()
gcdd = {}
for a in range(1, K + 1):
    for b in range(1, K + 1):
        if (a, b) not in gcdd:
            gcdd[(a, b)] = gcd(a, b)

for a in range(1, K + 1):
    for b in range(1, K + 1):
        for c in range(1, K + 1):
            ans += gcd2(a, b, c)
print(ans)


Fixed submission:
from functools import reduce

# from collections import defaultdict


def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x


def gcddd(*numbers):
    return reduce(gcd, numbers)


def reducef(x, y):
    return gcdd[(x, y)]


def gcd2(*numbers):
    return reduce(reducef, numbers)


K = int(input())
ans = 0
# gcdd=defaultdict()
gcdd = {}
for a in range(1, K + 1):
    for b in range(1, K + 1):
        if (a, b) not in gcdd:
            gcdd[(a, b)] = gcddd(a, b)

for a in range(1, K + 1):
    for b in range(1, K + 1):
        for c in range(1, K + 1):
            ans += gcd2(a, b, c)
print(ans)
Buggy python submission (verdict: Runtime Error):
K = int(input())

dp = [-1] * (10 ** 5 + 10)
dp[1] = 1
runrun = []
for i in range(1, len(dp) - 1):
    if len(str(i)) == 1:
        dp[i + 1] = i
        runrun += [i]
        continue
    s = str(i)
    last = int(s[-1])
    upper = s[:-1]
    upper = int(upper)
    if dp[upper + 1] != -1 and (
        dp[upper + 1] == last - 1 or dp[upper + 1] == last or dp[upper + 1] == last + 1
    ):
        dp[i + 1] = last
        runrun += [i]

# print(runrun[:30])
print(runrun[K - 1])


Fixed submission:
K = int(input())

lunlun = [i for i in range(1, 10)]

p = 0


def genelate_lunlun(p):
    last = p % 10
    if last > 0:
        yield p * 10 + last - 1
    yield p * 10 + last
    if last + 1 < 10:
        yield p * 10 + last + 1


while len(lunlun) <= K:
    for new in genelate_lunlun(lunlun[p]):
        lunlun.append(new)
    p += 1

# print(lunlun)
print(lunlun[K - 1])
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

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

# nC2 = [0] * (N + 1)
# nC2[0] = 0
# nC2[1] = 0
# for i in range(2, N + 1):
#     nC2[i] = i * (i - 1) // 2

# print(nC2)


def comb(x):
    if x == 0:
        return 0
    if x == 1:
        return 0
    return x * (x - 1) // 2


d = Counter(A)
# print(d)
k = d.keys()

# print(k)

for a in A:
    res = 0
    for kk in k:
        if a == kk:
            res += comb(d[kk] - 1)
            # res += nC2[d[kk] - 1]
        else:
            res += comb(d[kk])
            # res += nC2[d[kk]]
    # print(a, d[a], res)
    print(res)


Fixed submission:
from collections import Counter

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


def comb(x):
    if x == 0:
        return 0
    if x == 1:
        return 0
    return x * (x - 1) // 2


d = Counter(A)
# print(d)
k = d.keys()

# print(k)
total = 0

for kk in k:
    total += comb(d[kk])

# print(total)

for a in A:
    res = total
    res -= comb(d[a])
    res += comb(d[a] - 1)
    print(res)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

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

# nC2 = [0] * (N + 1)
# nC2[0] = 0
# nC2[1] = 0
# for i in range(2, N + 1):
#     nC2[i] = i * (i - 1) // 2

# print(nC2)


def comb(x):
    if x == 0:
        return 0
    if x == 1:
        return 0
    return x * (x - 1) // 2


d = Counter(A)
# print(d)
k = d.keys()

# print(k)

for a in A:
    res = 0
    for kk in k:
        if a == kk:
            res += comb(d[kk] - 1)
            # res += nC2[d[kk] - 1]
        else:
            res += comb(d[kk])
            # res += nC2[d[kk]]
    # print(a, d[a], res)
    print(res)


Fixed submission:
from collections import Counter

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


def comb(x):
    if x == 0:
        return 0
    if x == 1:
        return 0
    return x * (x - 1) // 2


d = Counter(A)
# print(d)
k = d.keys()

# print(k)
total = 0

for kk in k:
    total += comb(d[kk])

# print(total)

for a in A:
    res = total
    res -= comb(d[a])
    res += comb(d[a] - 1)
    print(res)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

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

nC2 = [0] * (N + 1)
nC2[0] = 0
nC2[1] = 0
for i in range(2, N + 1):
    nC2[i] = i * (i - 1) // 2

# print(nC2)

d = Counter(A)
# print(d)
k = d.keys()

# print(k)

for a in A:
    res = 0
    for kk in k:
        if a == kk:
            res += nC2[d[kk] - 1]
        else:
            res += nC2[d[kk]]
    # print(a, d[a], res)
    print(res)


Fixed submission:
from collections import Counter

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


def comb(x):
    if x == 0:
        return 0
    if x == 1:
        return 0
    return x * (x - 1) // 2


d = Counter(A)
# print(d)
k = d.keys()

# print(k)
total = 0

for kk in k:
    total += comb(d[kk])

# print(total)

for a in A:
    res = total
    res -= comb(d[a])
    res += comb(d[a] - 1)
    print(res)
Buggy python submission (verdict: Runtime Error):
import sys

N, M = map(int, input().split())

d = {}

for i in range(M):
    s, c = map(int, input().split())
    if s not in d:
        d[s] = c
    elif d[s] != c:
        print(-1)
        sys.exit()

# print(d)
if d[1] == 0:
    print(-1)
    sys.exit()
ans = ""
for i in range(1, N + 1):
    if i in d:
        ans += str(d[i])
    else:
        ans += "0"
print(ans)


Fixed submission:
import sys

N, M = map(int, input().split())

d = {}

for i in range(M):
    s, c = map(int, input().split())
    if s not in d:
        d[s] = c
    elif d[s] != c:
        print(-1)
        sys.exit()

# print(d)
# if d[1] == 0:
#     print(-1)
#     sys.exit()
ans = [0 for _ in range(N)]

for i in range(N):
    if i + 1 in d:
        ans[i] = d[i + 1]
if 1 not in d and N != 1:
    ans[0] = 1
if ans[0] == 0 and len(ans) != 1:
    print(-1)
else:
    print(*ans, sep="")
Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial


m = 1000000007


r1, c1, r2, c2 = map(int, input().split())


def F(r, c):
    r += 1
    c += 1
    path = (factorial(r + c) % m) * pow(factorial(r) * factorial(c), m - 2, m) % m
    return path - 1


r1 -= 1
c1 -= 1

ans = F(r2, c2)
ans -= F(r1, c2)
ans -= F(r2, c1)
ans += F(r1, c1)

print(ans)



Fixed submission:
m = 1000000007


r1, c1, r2, c2 = map(int, input().split())

nf = 10 ** 6 * 2 + 100
fact = [0] * (nf + 1)
fact[0] = 1
for i in range(nf):
    fact[i + 1] = fact[i] * (i + 1) % m


def F(r, c):
    path = (fact[r + c + 2] % m) * pow(fact[r + 1] * fact[c + 1], m - 2, m) % m
    return path - 1


r1 -= 1
c1 -= 1

ans = F(r2, c2)
ans -= F(r1, c2)
ans -= F(r2, c1)
ans += F(r1, c1)
ans = ans % m

print(ans)

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


m = 1000000007


r1, c1, r2, c2 = map(int, input().split())


def F(r, c):
    path = (factorial(r + c) % m) * pow(factorial(r) * factorial(c), m - 2, m) % m
    return path


ans = 0
for i in range(r1, r2 + 1):
    for j in range(c1, c2 + 1):
        ans = (ans + F(i, j)) % m
print(ans)


Fixed submission:
m = 1000000007


r1, c1, r2, c2 = map(int, input().split())

nf = 10 ** 6 * 2 + 100
fact = [0] * (nf + 1)
fact[0] = 1
for i in range(nf):
    fact[i + 1] = fact[i] * (i + 1) % m


def F(r, c):
    path = (fact[r + c + 2] % m) * pow(fact[r + 1] * fact[c + 1], m - 2, m) % m
    return path - 1


r1 -= 1
c1 -= 1

ans = F(r2, c2)
ans -= F(r1, c2)
ans -= F(r2, c1)
ans += F(r1, c1)
ans = ans % m

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    H, N = map(int, input().split())
    dp = [10 ** 18] * (H + 1)

    dp[0] = 0

    for i in range(N):
        a, b = map(int, input().split())
        for j in range(H):
            nj = min(j + a, H)  # nj: 次のjのindex, 配列外参照しないようにminをとる
            dp[nj] = min(dp[nj], dp[j] + b)

    print(dp[H])


main()


Fixed submission:
H, N = map(int, input().split())
dp = [10 ** 18] * (H + 1)

dp[0] = 0

for i in range(N):
    a, b = map(int, input().split())
    for j in range(H):
        nj = min(j + a, H)  # nj: 次のjのindex, 配列外参照しないようにminをとる
        dp[nj] = min(dp[nj], dp[j] + b)

print(dp[H])

Buggy python submission (verdict: Time Limit Exceeded):
H, N = map(int, input().split())
dp = [10 ** 18] * (H + 1)

dp[0] = 0

for i in range(N):
    a, b = map(int, input().split())
    for j in range(H):
        nj = min(j + a, H)  # nj: 次のjのindex, 配列外参照しないようにminをとる
        dp[nj] = min(dp[nj], dp[j] + b)

print(dp[H])



Fixed submission:
H, N = map(int, input().split())
dp = [10 ** 18] * (H + 1)

dp[0] = 0

for i in range(N):
    a, b = map(int, input().split())
    for j in range(H):
        nj = min(j + a, H)  # nj: 次のjのindex, 配列外参照しないようにminをとる
        dp[nj] = min(dp[nj], dp[j] + b)

print(dp[H])
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()

i = 0
ans = 0

while i < len(s):
    if s[i] == "A" and s[i + 1] == "B" and s[i + 2] == "C":
        ans += 1
        i += 3
    else:
        i += 1
print(ans)



Fixed submission:
n = int(input())
s = input()

i = 0
ans = 0

while i < len(s) - 2:
    if s[i] == "A" and s[i + 1] == "B" and s[i + 2] == "C":
        ans += 1
        i += 3
    else:
        i += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
from math import factorial

N = int(input())

def func(x):
    n = x
    if n % 2 == 0:
        num = str(2 ** (n // 2) * factorial(n // 2))
        ans = len(num) - len(num.rstrip("0"))
        return ans
    else:
        return 0

print(func(N))

Fixed submission:
N = int(input())


def func(x):
    n = x
    if n < 5:
        return 0
    if n % 2 == 0:
        cnt = 0
        i = 1
        n = n // 2
        while 5 ** i <= x:
            n = n // 5
            cnt += n
            i += 1

        return cnt

    else:
        return 0


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

num = set()
for a in range(20):
    for b in range(20):
        for c in range(20):
            for d in range(20):
                for e in range(20):
                    for f in range(20):
                        num.add(
                            100 * a + 101 * b + 102 * c + 103 * d + 104 * e + 105 * f
                        )

# print(1 if x in num else 0)
if x < 100 or x > 2000:
    print(1)
elif x in num:
    print(1)
else:
    print(0)


Fixed submission:
x = int(input())
dp = [0] * 100010
dp[100] = 1
dp[101] = 1
dp[102] = 1
dp[103] = 1
dp[104] = 1
dp[105] = 1

for i in range(106, 100010):
    if (
        dp[i - 100]
        or dp[i - 101]
        or dp[i - 102]
        or dp[i - 103]
        or dp[i - 104]
        or dp[i - 105]
    ):
        dp[i] = 1

print(1 if dp[x] else 0)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

ans = 0
for i in range(1000):
    t = "{:0=3}".format(i)
    p = 0
    for j in range(N):
        if S[j] == t[p]:
            p += 1
        if p == 3:
            break
    if p == 3:
        ans += 1

print(ans)


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

ans = 0
for i in range(1000):
    t = "{:0=3}".format(i)
    p = 0
    for j in range(N):
        if S[j] == t[p]:
            p += 1
        if p == 3:
            break
    if p == 3:
        ans += 1

print(ans)

Buggy python submission (verdict: Runtime Error):
import numpy as np

n = int(input())
s = input()

dp = np.zeros((30009, 4, 1009), dtype=np.bool)

dp[0][0][0] = True

for i in range(n):  # i: どの桁にいるか
    for j in range(4):  # j: 何文字残すか
        for k in range(1000):  # k: 残すと決まった数字
            if dp[i][j][k] == False:
                continue
            dp[i + 1][j][k] = True
            if j <= 2:
                dp[i + 1][j + 1][k * 10 + int(s[i])] = True
cnt = 0
for i in range(1000):
    if dp[n][3][i]:
        cnt += 1
print(cnt)


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

ans = 0
for i in range(1000):
    t = "{:0=3}".format(i)
    p = 0
    for j in range(N):
        if S[j] == t[p]:
            p += 1
        if p == 3:
            break
    if p == 3:
        ans += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n = int(input())
s = input()

dp = np.zeros((30009, 4, 1009), dtype=np.bool)

dp[0][0][0] = True

for i in range(n):  # i: どの桁にいるか
    for j in range(4):  # j: 何文字残すか
        for k in range(1000):  # k: 残すと決まった数字
            if dp[i][j][k] == False:
                continue
            dp[i + 1][j][k] = True
            if j <= 2:
                dp[i + 1][j + 1][k * 10 + int(s[i])] = True
cnt = 0
for i in range(1000):
    if dp[n][3][i]:
        cnt += 1
print(cnt)


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

ans = 0
for i in range(1000):
    t = "{:0=3}".format(i)
    p = 0
    for j in range(N):
        if S[j] == t[p]:
            p += 1
        if p == 3:
            break
    if p == 3:
        ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())


def devide2(x):
    ar = []
    for i in range(1, int(x)):
        if x % i == 0:
            ar.append([i, x // i])
    return ar


kumi = devide2(n)

ans = 10 ** 12 + 1000
for i in range(len(kumi)):
    ans = min(ans, sum(kumi[i]))

print(ans - 2)


Fixed submission:
n = int(input())


def devide2(x):
    ar = []
    ar.append([1, x])
    for i in range(2, int(-(-x ** 0.5 // 1)) + 1):
        if x % i == 0:
            ar.append([i, x // i])
    return ar


kumi = devide2(n)
# print(kumi)

ans = 10 ** 12 + 1000
for i in range(len(kumi)):
    ans = min(ans, sum(kumi[i]))

print(ans - 2)
Buggy python submission (verdict: Runtime Error):
from itertools import combinations
import sys
sys.setrecursionlimit(10**6)

n = int(input())
d = list(map(int, input().split()))

comb = list(combinations(d, 2))
ans = 0

for i in range(len(d)):
    ans += comb[i][0] * comb[i][1]

print(ans)

Fixed submission:
from itertools import combinations

n = int(input())
d = list(map(int, input().split()))

comb = list(combinations(d, 2))

ans = 0

for i in range(len(comb)):
    ans += comb[i][0] * comb[i][1]
    # print(ans, comb[i])

print(ans)

Buggy python submission (verdict: Runtime Error):
from itertools import combinations

n = int(input())
d = list(map(int, input().split()))

comb = list(combinations(d, 2))
ans = 0

for i in range(len(d)):
    ans += comb[i][0] * comb[i][1]

print(ans)

Fixed submission:
from itertools import combinations

n = int(input())
d = list(map(int, input().split()))

comb = list(combinations(d, 2))

ans = 0

for i in range(len(comb)):
    ans += comb[i][0] * comb[i][1]
    # print(ans, comb[i])

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

# print(a)
# li = []
for i in range(1, n + 1):
    # li.append(a.index(i) + 1)

    print(a.index(i) + 1, end=" ")
    

Fixed submission:
import numpy as np

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

npa = np.array(a)
print(*(np.argsort(npa) + 1))

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

# print(a)
li = []
for i in range(1, n + 1):
    li.append(a.index(i) + 1)

    # print(a.index(i) + 1, end=" ")

print(*li)


Fixed submission:
import numpy as np

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

npa = np.array(a)
print(*(np.argsort(npa) + 1))