Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math
# from fractions import gcd

MOD = 10 ** 9 + 7
# MOD = 998244353
# sys.setrecursionlimit(10**8)

INF = 2**31-1


class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


class RangeUpdate:
    def __init__(self, n):
        self.p = Bit(n + 1)
        self.q = Bit(n + 1)

    def add(self, s, t, x):
        t += 1
        self.p.add(s, -x * s)
        self.p.add(t, x * t)
        self.q.add(s, x)
        self.q.add(t, -x)

    def sum(self, s, t):
        t += 1
        return self.p.sum(t) + self.q.sum(t) * t - self.p.sum(s) - self.q.sum(s) * s


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

for j in range(N):
    T.add(j+1, j+1, A[j])
prev_T = T

for i in range(min(k, 3*int(math.log(N))+1)):
    T = RangeUpdate(N)
    for j in range(N):
        num = prev_T.sum(j+1, j+1)
        T.add(max(j - num + 1, 1), min(j + num + 1, N), 1)

    prev_T = T

ans = [0]*N
for i in range(N):
    ans[i] = prev_T.sum(i+1, i+1)

print(*ans)


Fixed submission:
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math
# from fractions import gcd

MOD = 10 ** 9 + 7
# MOD = 998244353
# sys.setrecursionlimit(10**8)

N, k = map(int, input().split())
prev_arr = list(map(int, input().split()))

# N = k = 200000
# prev_arr = [0]*N

count = 0
for i in range(min(k, 3*int(math.log(N))+5)):
    que = []
    arr = [0]*N
    for j in range(N):
        heapq.heappush(que, j+prev_arr[j])
        while que[0] < j:
            heapq.heappop(que)
        arr[j] += len(que)
    # print(arr)

    que = []
    for j in reversed(range(N)):
        heapq.heappush(que, -(j-prev_arr[j]))
        while -que[0] > j:
            heapq.heappop(que)
        arr[j] += len(que) - 1

    prev_arr = arr
    count += 1

# print(count)
print(*prev_arr)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math
# from fractions import gcd

MOD = 10 ** 9 + 7
# MOD = 998244353
# sys.setrecursionlimit(10**8)

INF = 2**31-1


class SegTree:
    def __init__(self, N):
        self.LV = (N - 1).bit_length()
        self.N0 = 2 ** self.LV
        self.data = [0] * (2 * self.N0)
        self.lazy = [0] * (2 * self.N0)

    def gindex(self, l, r):
        L = (l + self.N0) >> 1
        R = (r + self.N0) >> 1
        lc = 0 if l & 1 else (L & -L).bit_length()
        rc = 0 if r & 1 else (R & -R).bit_length()
        for i in range(self.LV):
            if rc <= i:
                yield R
            if L < R and lc <= i:
                yield L
            L >>= 1; R >>= 1

    def propagates(self, *ids):
        for i in reversed(ids):
            v = self.lazy[i-1]
            if not v:
                continue
            self.lazy[2*i-1] += v
            self.lazy[2*i] += v
            self.data[2*i-1] += v
            self.data[2*i] += v
            self.lazy[i-1] = 0

    def update(self, l, r, x):
        *ids, = self.gindex(l, r)
        self.propagates(*ids)

        L = self.N0 + l
        R = self.N0 + r
        while L < R:
            if R & 1:
                R -= 1
                self.lazy[R-1] += x
                self.data[R-1] += x
            if L & 1:
                self.lazy[L-1] += x
                self.data[L-1] += x
                L += 1
            L >>= 1
            R >>= 1
        for i in ids:
            self.data[i-1] = min(self.data[2*i-1], self.data[2*i])

    def query(self, l, r):
        self.propagates(*self.gindex(l, r))
        L = self.N0 + l
        R = self.N0 + r

        s = INF
        while L < R:
            if R & 1:
                R -= 1
                s = min(s, self.data[R-1])
            if L & 1:
                s = min(s, self.data[L-1])
                L += 1
            L >>= 1
            R >>= 1
        return s


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

for j in range(N):
    T.update(j, j+1, A[j])
prev_T = T

for i in range(min(k, 3*int(math.log(N))+1)):
    T = SegTree(N)
    for j in range(N):
        num = prev_T.query(j, j+1)
        T.update(max(j - num, 0), min(j + num + 1, N), 1)

    prev_T = T

ans = [0]*N
for i in range(N):
    ans[i] = prev_T.query(i, i+1)

print(*ans)


Fixed submission:
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math
# from fractions import gcd

MOD = 10 ** 9 + 7
# MOD = 998244353
# sys.setrecursionlimit(10**8)

N, k = map(int, input().split())
prev_arr = list(map(int, input().split()))

# N = k = 200000
# prev_arr = [0]*N

count = 0
for i in range(min(k, 3*int(math.log(N))+5)):
    que = []
    arr = [0]*N
    for j in range(N):
        heapq.heappush(que, j+prev_arr[j])
        while que[0] < j:
            heapq.heappop(que)
        arr[j] += len(que)
    # print(arr)

    que = []
    for j in reversed(range(N)):
        heapq.heappush(que, -(j-prev_arr[j]))
        while -que[0] > j:
            heapq.heappop(que)
        arr[j] += len(que) - 1

    prev_arr = arr
    count += 1

# print(count)
print(*prev_arr)