Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = [int(i) for i in input().split()]

for _ in range(K):
    S = [0] * (N + 1)
    for i, a in enumerate(A):
        l = min(N-1, max(0, i-a))
        r = min(N-1, i+a)
        S[l] += 1
        S[r+1] -= 1
    t = 0
    for i in range(N):
        t += S[i]
        A[i] = t
    if sum(A) == N**2:
        break
print(*A)

Fixed submission:
from itertools import accumulate
N, K = map(int, input().split())
A = [int(i) for i in input().split()]

for _ in range(K):
    S = [0] * (N + 1)
    for i, a in enumerate(A):
        l = min(N-1, max(0, i-a))
        r = min(N-1, i+a)
        S[l] += 1
        S[r+1] -= 1
    A = list(accumulate(S))[:-1]
    if all([a == N for a in A]):
        break
print(*A)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate
N, K = map(int, input().split())
A = [int(i) for i in input().split()]

for _ in range(K):
    S = [0] * (N + 1)
    for i, a in enumerate(A):
        l = min(N-1, max(0, i-a))
        r = min(N-1, i+a)
        S[l] += 1
        S[r+1] -= 1
    A = list(accumulate(S))[:-1]
    if all([a == N for a in A]):
        break
print(*A)

Fixed submission:
from itertools import accumulate
N, K = map(int, input().split())
A = [int(i) for i in input().split()]

for _ in range(K):
    S = [0] * (N + 1)
    for i, a in enumerate(A):
        l = min(N-1, max(0, i-a))
        r = min(N-1, i+a)
        S[l] += 1
        S[r+1] -= 1
    A = list(accumulate(S))[:-1]
    if all([a == N for a in A]):
        break
print(*A)

Buggy python submission (verdict: Time Limit Exceeded):
from math import floor, ceil
from numpy import array
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
L = array([0 for i in range(N+2)])

for _ in range(K):
    for i, a in enumerate(A):
        l = max(0, ceil(i+1-a-0.5))
        r = min(N+2, floor(i+1+a+0.5)+1)
        L[l:r] += 1
    for i in range(N):
        A[i] = L[i+1]
    L = array([0 for i in range(2*N+2)])
    if all([a == N for a in A]):
        break
print(*A)

Fixed submission:
from itertools import accumulate
N, K = map(int, input().split())
A = [int(i) for i in input().split()]

for _ in range(K):
    S = [0] * (N + 1)
    for i, a in enumerate(A):
        l = min(N-1, max(0, i-a))
        r = min(N-1, i+a)
        S[l] += 1
        S[r+1] -= 1
    A = list(accumulate(S))[:-1]
    if all([a == N for a in A]):
        break
print(*A)

Buggy python submission (verdict: Time Limit Exceeded):
from math import floor, ceil
from numpy import array
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
L = array([0 for i in range(N+2)])

for _ in range(K):
    for i, a in enumerate(A):
        l = max(0, ceil(i+1-a-0.5))
        r = min(N+2, floor(i+1+a+0.5)+1)
        L[l:r] += 1
        #for j in range(l, r):
        #   L[j] += 1
    for i in range(N):
        A[i] = L[i+1]
    L = array([0 for i in range(2*N+2)])
    if all([A == N for a in A]):
        break
print(*A)

Fixed submission:
from itertools import accumulate
N, K = map(int, input().split())
A = [int(i) for i in input().split()]

for _ in range(K):
    S = [0] * (N + 1)
    for i, a in enumerate(A):
        l = min(N-1, max(0, i-a))
        r = min(N-1, i+a)
        S[l] += 1
        S[r+1] -= 1
    A = list(accumulate(S))[:-1]
    if all([a == N for a in A]):
        break
print(*A)

Buggy python submission (verdict: Time Limit Exceeded):
from math import floor, ceil
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
L = [0 for i in range(N+2)]

for _ in range(K):
    for i, a in enumerate(A):
        l = max(0, ceil(i+1-a-0.5))
        r = min(N+2, floor(i+1+a+0.5)+1)
        for j in range(l, r):
            L[j] += 1
    for i in range(N):
        A[i] = L[i+1]
    L = [0 for i in range(2*N+2)]
    if all([A == N for a in A]):
        break
print(*A)


Fixed submission:
from itertools import accumulate
N, K = map(int, input().split())
A = [int(i) for i in input().split()]

for _ in range(K):
    S = [0] * (N + 1)
    for i, a in enumerate(A):
        l = min(N-1, max(0, i-a))
        r = min(N-1, i+a)
        S[l] += 1
        S[r+1] -= 1
    A = list(accumulate(S))[:-1]
    if all([a == N for a in A]):
        break
print(*A)