Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()

for i in range(q):
    l, r = map(int, input().split())
    s_i = s[l-1:r]
    print(s_i.count("AC"))


Fixed submission:
import numpy as np
n, q = map(int, input().split())
s = input()
w = np.zeros(n, dtype=int)

a = 0
for i in range(n):
    if s[i] == "A":
        if a == 0:
            a += 1
    elif s[i] == "C":
        if a:
            w[i-1] = 1
            a -= 1
    else:
        if a:
            a -= 1

ans = np.append(np.zeros(1, dtype=int), np.cumsum(w))
for _ in range(q):
    l, r = map(int, input().split())
    print(ans[r-1] - ans[l-1])

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

for i in range(q):
    l, r = map(int, input().split())
    s_i = s[l-1:r]
    ans_i = "".join(s_i.split("AC"))
    print(
        (len(s_i) - len(ans_i)) // 2
    )

Fixed submission:
import numpy as np
n, q = map(int, input().split())
s = input()
w = np.zeros(n, dtype=int)

a = 0
for i in range(n):
    if s[i] == "A":
        if a == 0:
            a += 1
    elif s[i] == "C":
        if a:
            w[i-1] = 1
            a -= 1
    else:
        if a:
            a -= 1

ans = np.append(np.zeros(1, dtype=int), np.cumsum(w))
for _ in range(q):
    l, r = map(int, input().split())
    print(ans[r-1] - ans[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = len(s)


def divide(x):
    a = "".join(x.split("01"))
    b = "".join(a.split("10"))
    return b


def judge(x):
    return len(x.split("01")) == 1 and len(x.split("10")) == 1


while not judge(s):
    s = divide(s)

print(n - len(s))


Fixed submission:
s = input()
n = len(s)
num_0 = s.count("0")
num_1 = n - num_0

print(n - abs(num_0 - num_1))
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
l = [x[i]-x[i-1] for i in range(1,m)]
l.sort(reverse=True)
ans = x[m-1] - x[0]
if len(x) == 1:
    print(ans)
else:
    for i in range(n-1):
        ans -= l[i]
    print(ans)

Fixed submission:
n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
l = [x[i]-x[i-1] for i in range(1,m)]
l.sort(reverse=True)
ans = x[m-1] - x[0]
if n >= m:
    print(0)
else:
    for i in range(n-1):
        ans -= l[i]
    print(ans)

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
l = [x[i]-x[i-1] for i in range(1,m)]
ans = x[m-1] - x[0] 
if len(x) == 1:
    print(ans)
else:
    for i in range(n-1):
        ans -= max(l)
        l.remove(max(l))
    print(ans)

Fixed submission:
n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
l = [x[i]-x[i-1] for i in range(1,m)]
l.sort(reverse=True)
ans = x[m-1] - x[0]
if n >= m:
    print(0)
else:
    for i in range(n-1):
        ans -= l[i]
    print(ans)

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
l = [x[i]-x[i-1] for i in range(1,m)]
ans = x[m-1] - x[0] 
if len[x] == 1:
    print(ans)
else:
    for i in range(n-1):
        ans -= max(l)
        l.remove(max(l))
    print(ans)

Fixed submission:
n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
l = [x[i]-x[i-1] for i in range(1,m)]
l.sort(reverse=True)
ans = x[m-1] - x[0]
if n >= m:
    print(0)
else:
    for i in range(n-1):
        ans -= l[i]
    print(ans)
Buggy python submission (verdict: Runtime Error):
from functools import lru_cache
n = int(input())
inf = 10**10
h = list(map(int, input().split()))


@lru_cache(maxsize=None)
def dp(i):
    if i == 0:
        return 0
    if i == 1:
        return dp(i-1) + abs(h[i] - h[i-1])
    if i >= 2:
        return min(dp(i-2) + abs(h[i] - h[i-2]), dp(i-1) + abs(h[i] - h[i-1]))


print(dp(n-1))


Fixed submission:
N = int(input())
h = list(map(int, input().split()))
import numpy as np
dp = np.zeros(N+1, dtype=int)
dp[2] = abs(h[0]-h[1])
for i in range(2, N):
    dp[i+1] = min(
        dp[i] + abs(h[i-1]-h[i]),
        dp[i-1] + abs(h[i-2]-h[i])
    )
print(dp[N])

Buggy python submission (verdict: Runtime Error):
from functools import lru_cache
n = int(input())
inf = 10**10
h = list(map(int, input().split())) + [inf] * 10


@lru_cache(maxsize=None)
def dp(i):
    if i == 0:
        return 0
    if i >= 2:
        return min(dp(i-2) + abs(h[i] - h[i-2]), dp(i-1) + abs(h[i] - h[i-1]))
    if i == 1:
        return dp(i-1) + abs(h[i] - h[i-1])


print(dp(n-1))


Fixed submission:
N = int(input())
h = list(map(int, input().split()))
import numpy as np
dp = np.zeros(N+1, dtype=int)
dp[2] = abs(h[0]-h[1])
for i in range(2, N):
    dp[i+1] = min(
        dp[i] + abs(h[i-1]-h[i]),
        dp[i-1] + abs(h[i-2]-h[i])
    )
print(dp[N])

Buggy python submission (verdict: Runtime Error):
from functools import lru_cache
n = int(input())
inf = 10**10
h = list(map(int, input().split())) + [inf] * 10


@lru_cache
def dp(i):
    if i == 0:
        return 0
    if i >= 2:
        return min(dp(i-2) + abs(h[i] - h[i-2]), dp(i-1) + abs(h[i] - h[i-1]))
    if i == 1:
        return dp(i-1) + abs(h[i] - h[i-1])


print(dp(n-1))


Fixed submission:
N = int(input())
h = list(map(int, input().split()))
import numpy as np
dp = np.zeros(N+1, dtype=int)
dp[2] = abs(h[0]-h[1])
for i in range(2, N):
    dp[i+1] = min(
        dp[i] + abs(h[i-1]-h[i]),
        dp[i-1] + abs(h[i-2]-h[i])
    )
print(dp[N])
Buggy python submission (verdict: Time Limit Exceeded):
from functools import lru_cache
import sys
sys.setrecursionlimit(10**7)
n, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(n)]


# i番目の荷物を見たときの価値の最大値
@lru_cache(maxsize=None)
def f(i, r):
    w, v = wv[i]
    if i == 0:
        if w <= r:
            return v
        else:
            return 0
    if w <= r:
        return max(f(i-1, r), f(i-1, r-w) + v)
    else:
        return f(i-1, r)


print(f(n-1, W))





Fixed submission:
N, W = map(int, input().split())
item = [list(map(int, input().split())) for i in range(N)]

dp = [[0]*(W+1) for i in range(N+1)]
for i in range(N):
    for w in range(1, W+1):
        if w - item[i][0] >= 0:
            dp[i+1][w] = max(
                dp[i][w],
                dp[i][w-item[i][0]] + item[i][1]
            )
        else:
            dp[i+1][w] = dp[i][w]
print((dp[N][W]))

Buggy python submission (verdict: Time Limit Exceeded):
n, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(n)]

dp = [[0]*(W+1) for _ in range(n+1)]

for i in range(n):
    for w in range(W+1):
        if w >= wv[i][0]:
            dp[i+1][w] = max(
                dp[i][w - wv[i][0]] + wv[i][1],
                dp[i][w]
            )
        else:
            dp[i+1][w] = dp[i][w]

print(dp[n][W])

Fixed submission:
N, W = map(int, input().split())
item = [list(map(int, input().split())) for i in range(N)]

dp = [[0]*(W+1) for i in range(N+1)]
for i in range(N):
    for w in range(1, W+1):
        if w - item[i][0] >= 0:
            dp[i+1][w] = max(
                dp[i][w],
                dp[i][w-item[i][0]] + item[i][1]
            )
        else:
            dp[i+1][w] = dp[i][w]
print((dp[N][W]))
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
h = [int(input()) for _ in range(n)]
h.sort()
ans = h[-1]
for i in range(n-k+1):
    trees = h[i:i+k]
    ans = min(
        ans,
        trees[-1] - trees[0]
    )
print(ans)


Fixed submission:
import numpy as np
n, k = map(int, input().split())
h = [int(input()) for _ in range(n)]
h.sort()
h_max = np.array(h[k-1:])
h_min = np.array(h[:-k+1])
print(min(h_max - h_min))

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
h = [int(input()) for _ in range(n)]
h.sort()
ans = h[-1]
for i in range(n-k+1):
    trees = h[i:i+k]
    ans = min(
        ans,
        max(trees) - min(trees)
    )
print(ans)


Fixed submission:
import numpy as np
n, k = map(int, input().split())
h = [int(input()) for _ in range(n)]
h.sort()
h_max = np.array(h[k-1:])
h_min = np.array(h[:-k+1])
print(min(h_max - h_min))
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())

for i in reversed(range(1, m//n + 1)):
    if m % i == 0:
        print(i)
        break


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

for i in reversed(range(1, m//n + 1)):
    if m % i == 0:
        print(i)
        break
Buggy python submission (verdict: Runtime Error):
S = input()
n = len(S)
k = int(input())
cnt = 0
itl = sorted(list(set(S)))
ans = set([])
for w in itl:
    for i, s in enumerate(S):
        if s != w:
            continue
        else:
            for j in range(i+1, n+1):
                ans.add(S[i:j])
                cnt += 1
                if cnt == k:
                    break

    ans.clear()

ans = list(ans)
ans.sort()
index = k - 1 - (cnt - len(ans))
print(ans[index])


Fixed submission:
S = input()
n = len(S)
k = int(input())
cnt = 0
itl = sorted(list(set(S)))
ans = set([])
for w in itl:
    for i, s in enumerate(S):
        if s != w:
            continue
        else:
            for j in range(i+1, i+k+1):
                ans.add(S[i:j])
    cnt += len(ans)
    if cnt >= k:
        break
    else:
        ans.clear()

ans = list(ans)
ans.sort()
index = k - 1 - (cnt - len(ans))
print(ans[index])

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
n = len(S)
k = int(input())
cnt = 0
itl = sorted(list(set(S)))
ans = set([])
for w in itl:
    for i, s in enumerate(S):
        if s != w:
            continue
        else:
            for j in range(i+1, n+1):
                ans.add(S[i:j])
    cnt += len(ans)
    if cnt >= k:
        break
    else:
        ans.clear()

ans = list(ans)
ans.sort()
index = k - 1 - (cnt - len(ans))
print(ans[index])


Fixed submission:
S = input()
n = len(S)
k = int(input())
cnt = 0
itl = sorted(list(set(S)))
ans = set([])
for w in itl:
    for i, s in enumerate(S):
        if s != w:
            continue
        else:
            for j in range(i+1, i+k+1):
                ans.add(S[i:j])
    cnt += len(ans)
    if cnt >= k:
        break
    else:
        ans.clear()

ans = list(ans)
ans.sort()
index = k - 1 - (cnt - len(ans))
print(ans[index])
Buggy python submission (verdict: Runtime Error):
from collections import Counter
march = "MARCH"
n = int(input())
initial = Counter([input()[0] for _ in range(n)])
ans = []
for i, num in initial.items():
    if i in march:
        ans.append(num)

x = len(ans)
if x < 3:
    print(0)
elif x >= 3:
    y = 0
    for i in range(1, x-1):
        for j in range(i+1, x):
            for k in range(j+1, x+1):
                y += ans[i] * ans[j] * ans[k]
    print(y)




Fixed submission:
from collections import Counter
march = "MARCH"
n = int(input())
initial = Counter([input()[0] for _ in range(n)])
ans = []
for i, num in initial.items():
    if i in march:
        ans.append(num)

x = len(ans)
if x < 3:
    print(0)
elif x >= 3:
    y = 0
    for i in range(0, x-2):
        for j in range(i+1, x-1):
            for k in range(j+1, x):
                y += ans[i] * ans[j] * ans[k]
    print(y)
Buggy python submission (verdict: Runtime Error):
import sys
n, y = map(int, input().split())
sys.setrecursionlimit(2000)


def calc(a, b, c):
    return 10000 * a + 5000 * b + 1000 * c


def dfs(pos, a, b, c):
    if pos == n:
        if calc(a, b, c) == y:
            return [a, b, c]
        else:
            return [-1, -1, -1]
    ret1 = [
        dfs(pos+1, a+1, b, c),
        dfs(pos+1, a, b+1, c),
        dfs(pos+1, a, b, c+1)
        ]
    ret1.sort(key=lambda x: x[0])
    return ret1[-1]


print(*dfs(0, 0, 0, 0))

Fixed submission:
import sys
n, price = map(int, input().split())
ans = [-1, -1, -1]
for x in range(n+1):
    for y in range(n+1):
        z = n - x - y
        if z < 0:
            continue
        if 10000 * x + 5000 * y + 1000 * z == price:
            ans = [x, y, z]
            print(*ans)
            sys.exit()
print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, h = map(int, input().split())
a = []
b = []
for _ in range(n):
    a_i, b_i = map(int, input().split())
    a.append(a_i)
    b.append(b_i)
b.sort()
ap = h - sum(b)
ans = ap // max(a)
h -= ans * max(a)

if h > sum(b):
    h -= max(a)
    ans += 1

while h > 0:
    attack = b.pop()
    if attack > max(a):
        h -= attack
        ans += 1
    else:
        b.append(attack)
        h -= max(a)
        ans += 1
print(ans)

Fixed submission:
n, h = map(int, input().split())
a = []
b = []
for _ in range(n):
    a_i, b_i = map(int, input().split())
    a.append(a_i)
    b.append(b_i)

r = max(a)
key_b = 10**10

attack = []
for i in range(n):
    if a[i] == r:
        if b[i] < key_b:
            if key_b != 10**10:
                attack.append(key_b)
            key_b = b[i]
        else:
            attack.append(b[i])
    elif r < b[i]:
        attack.append(b[i])

ans = 0
attack.sort(reverse=True)
for bi in attack:
    if bi > key_b:
        h -= bi
        ans += 1
    elif h <= key_b:
        h -= key_b
        ans += 1
    else:
        h -= bi
        ans += 1

    if h <= 0:
        break

if 0 < h <= key_b:
    ans += 1
elif key_b < h:
    h -= key_b
    ans += 1

    if h % r == 0:
        ans += h // r
    else:
        ans += 1 + h // r

print(ans)
Buggy python submission (verdict: Runtime Error):
n, c = map(int, input().split())
stc = [list(map(int, input().split())) for _ in range(n)]
T = max(stc, key=lambda x:x[1])[1]
record = [[0]*(T+2) for _ in range(c+1)]
for s, t, c in stc:
    record[c][s] += 1
    record[c][t] -= 1

for r in record:
    for i in range(T+3):
        r[i+1] += r[i]

for s, t, c in stc:
    record[c][s-1] += 1

ans = 0
for i in range(T+3):
    y = 0
    for r in record:
        y += r[i]
    ans = max(ans, y)
print(ans)

Fixed submission:
n, c = map(int, input().split())
stc = [list(map(int, input().split())) for _ in range(n)]
T = 10**5+1
record = [[0]*(T+3) for _ in range(c+1)]
channel = [[] for _ in range(c+1)]
stc.sort()

for s, t, c in stc:
    if not channel[c]:
        channel[c].append([s - 1, t])
        continue
    if channel[c][-1][1] == s:
        channel[c][-1][1] = t
    else:
        channel[c].append([s-1, t])

for i, v in enumerate(channel):
    for s, t in v:
        record[i][s] += 1
        record[i][t] -= 1

for i in record:
    for j in range(T+2):
        i[j+1] += i[j]

ans = 0
for i in range(T+2):
    y = 0
    for r in record:
        y += r[i]
    ans = max(ans, y)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

a_num = np.zeros(n)
b_num = np.zeros(n)

left = 0
right = 0
while left <= n-1 and right <= n-1:
    if a[left] < b[right]:
        a_num[left:] += 1
        right += 1
    else:
        left += 1

left = 0
right = 0
while left <= n-1 and right <= n-1:
    if b[left] < c[right]:
        b_num[left:] += 1
        right += 1
    else:
        left += 1

ans = 0
for i in a_num:
    i = int(i)
    ans += sum(b_num[:i])
print(int(ans))

Fixed submission:
from bisect import bisect_left, bisect_right
n = int(input())
a = sorted(list(map(int, input().split())))
b = list(map(int, input().split()))
c = sorted(list(map(int, input().split())))

ans = 0
for i in b:
    x = bisect_left(a, i)
    y = n - bisect_right(c, i)
    ans += x * y
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
x = Counter(a)
cnt = sorted(x.items(), key=lambda x: x[0], reverse=True)
ans = 0
for i in range(len(cnt)):
    x = cnt[i][1]
    print(x)
    if i != 0:
        if cnt[i][0] == cnt[i-1][0] - 1:
            x += cnt[i-1][1]
    if i == len(cnt) - 1:
        if cnt[i][0] == cnt[i+1][0] + 1:
            x += cnt[i+1][1]
    ans = max(ans, x)
print(ans)

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
x = Counter(a)
cnt = sorted(x.items(), key=lambda x: x[0], reverse=True)
ans = 0
for i in range(len(cnt)):
    x = cnt[i][1]
    if i != 0:
        if cnt[i][0] == cnt[i-1][0] - 1:
            x += cnt[i-1][1]
    if i != len(cnt) - 1:
        if cnt[i][0] == cnt[i+1][0] + 1:
            x += cnt[i+1][1]
    ans = max(ans, x)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def dijkstra(s, n, cost):
    d = [float("inf")] * (n+1)
    used = [False] * (n+1)
    d[s] = 0

    while True:
        v = -1
        for i in range(1, n+1):
            if (not used[i]) and (v == -1):
                v = i
            elif (not used[i]) and d[i] < d[v]:
                v = i
        if v == -1:
            break
        used[v] = True
        for j in range(1, n+1):
            d[j] = min(d[j], d[v] + cost[v][j])
    return d


n = int(input())
inf = float("inf")
cost = [[inf]*(n+1) for _ in range(n+1)]
for _ in range(n-1):
    a, b, c = map(int, input().split())
    cost[a][b] = c
    cost[b][a] = c
q, k = map(int, input().split())
ans = dijkstra(k, n, cost)
for _ in range(q):
    x, y = map(int, input().split())
    print(ans[x] + ans[y])

Fixed submission:
n = int(input())
inf = float("inf")
tree = [[] for _ in range(n+1)]
for _ in range(n-1):
    a, b, c = map(int, input().split())
    tree[a].append([b, c])
    tree[b].append([a, c])
q, k = map(int, input().split())

depth = [inf] * (n+1)
visited = [False] * (n+1)
depth[k] = 0
stack = [k]
while stack:
    now = stack.pop()
    visited[now] = True
    for i, v in tree[now]:
        if visited[i]:
            pass
        else:
            stack.append(i)
            depth[i] = min(depth[i], depth[now] + v)
for _ in range(q):
    x, y = map(int, input().split())
    ans = depth[x] + depth[y]
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n, ma, mb = map(int, input().split())
r = 10 * n + 6
inf = 10**5
dp = np.full((n+1, r, r), inf)
dp[0][0][0] = 0
for i in range(n):
    a, b, c = map(int, input().split())
    for j in range(r):
        for k in range(r):
            if j + a < r and k + b < r:
                dp[i+1][j+a][k+b] = min(
                    dp[i][j][k] + c, dp[i][j+a][k+b]
                )
            dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k])

ans = inf
x, y = 0, 0
while True:
    x += ma
    y += mb
    if x < r and y < r:
        ans = min(ans, dp[n][x][y])
    else:
        break
if ans == inf:
    print(-1)
else:
    print(int(ans))

Fixed submission:
import numpy as np
n, ma, mb = map(int, input().split())
r = 10 * n + 6
inf = 10**5
dp = np.full((n+1, r, r), inf)
dp[0][0][0] = 0
for i in range(n):
    a, b, c = map(int, input().split())
    dp[i+1][a:, b:] = np.minimum(
        dp[i][:r-a, :r-b] + c, dp[i][a:, b:]
    )
    dp[i+1] = np.minimum(dp[i+1], dp[i])

ans = inf
x, y = 0, 0
while True:
    x += ma
    y += mb
    if x < r and y < r:
        ans = min(ans, dp[n][x][y])
    else:
        break
if ans == inf:
    print(-1)
else:
    print(int(ans))
Buggy python submission (verdict: Runtime Error):
n, t = map(int, input().split())
a = list(map(int, input().split()))

ans = []
for i in range(n):
    b = max(a[i+1:]) - a[i]
    ans.append(b)

r = max(ans)
print(ans.count(r))

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

ans = []
min_a = a[0]
for i in range(1, n):
    min_a = min(min_a, a[i-1])
    ans.append(a[i] - min_a)
r = max(ans)
print(ans.count(r))

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

ans = [max(a[i+1:]) - a[i] for i in range(n-1)]
r = max(ans)
print(ans.count(r))


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

ans = []
min_a = a[0]
for i in range(1, n):
    min_a = min(min_a, a[i-1])
    ans.append(a[i] - min_a)
r = max(ans)
print(ans.count(r))
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
d = set(map(int, input().split()))
inf = 10 * n + 1
num = []
for i in range(10):
    if i in d:
        pass
    else:
        num.append(i)

for i in num:
    if i >= int(str(n)[0]):
        ans = i
        break


def dfs(pos, x):
    if pos == len(str(n)):
        if x >= n:
            return x
        else:
            return inf

    ret = [
        dfs(pos + 1, 10 * x + num_i) for num_i in num
    ]

    return min(ret)


print(dfs(1, ans))

Fixed submission:
n, k = map(int, input().split())
d = set(map(int, input().split()))
inf = 10 * n + 1
stop = len(str(n))
num = []
for i in range(10):
    if i in d:
        pass
    else:
        num.append(i)


def dfs(pos, x):
    if pos == stop:
        if x >= n:
            return x
        else:
            return inf

    ret = [
        dfs(pos + 1, 10 * x + num_i) for num_i in num
    ]

    return min(ret)


if dfs(0, 0) != inf:
    print(dfs(0, 0))
else:
    stop += 1
    print(dfs(0, 0))
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
from sys import setrecursionlimit
import numpy as np
import math

setrecursionlimit(10 ** 7)

n,k = map(int,stdin.readline().rstrip().split())
a = list(map(int,stdin.readline().rstrip().split()))

a.sort()
a = np.array(a,dtype=np.int64)

low = 0
hi = 10**9
point = 0

while hi-low > 0.000000001:
    ave = (hi+low)/2
    if np.ceil(a//ave).sum() <= k:
        hi = ave
    else:
        low = ave

print(math.ceil(ave))

Fixed submission:
from sys import stdin
from sys import setrecursionlimit
import numpy as np
import math

setrecursionlimit(10 ** 7)

n,k = map(int,stdin.readline().rstrip().split())
a = list(map(int,stdin.readline().rstrip().split()))

a.sort()
a = np.array(a,dtype=np.int64)

low = 0
hi = 10**9
point = 0

while point <= 100:
    ave = (hi+low)/2
    if np.ceil(a//ave).sum() <= k:
        hi = ave
    else:
        low = ave
    point += 1

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

now = 1

for i in range(k):
    now *= a[i]

for i in range(k,n):
    ima = now * a[i]
    ima //= a[i-k]
    if ima > now:
        print("Yes")
    else:
        print("No")
    now = ima

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

for i in range(k,n):
    if a[i]/a[i-k] > 1:
        print("Yes")
    else:
        print("No")

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

now = 1

for i in range(k):
    now *= a[i]

for i in range(k,n):
    ima = now * a[i]
    ima //= a[i-k]
    if ima > now:
        print("Yes")
    else:
        print("No")
    now = ima

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

for i in range(k,n):
    if a[i]/a[i-k] > 1:
        print("Yes")
    else:
        print("No")