Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))
    _max = max
    _min = min
    for _ in range(k):
        C = [0] * n
        for i in range(n):
            a = A[i]
            l = _max(0, i - a)
            r = _min(n, i + a + 1)
            C[l] += 1
            if r < n:
                C[r] -= 1
        r = 0
        for i in range(n):
            r += C[i]
            A[i] = r
        if A == [n] * n:
            break
    print(" ".join(map(str, A)))
main()


Fixed submission:
def main():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))
    _max = max
    _min = min
    for _ in range(k):
        C = [0] * n
        i = 0
        for a in A:
            l = _max(0, i - a)
            r = _min(n, i + a + 1)
            C[l] += 1
            if r < n:
                C[r] -= 1
            i += 1
        r = 0
        for i in range(n):
            r += C[i]
            A[i] = r
        if A == [n] * n:
            break
    print(" ".join(map(str, A)))
main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))
    _max = max
    _min = min
    for _ in range(k):
        C = [0] * n
        for i in range(n):
            a = A[i]
            l = _max(0, i - a)
            r = _min(n, i + a + 1)
            C[l] += 1
            if r < n:
                C[r] -= 1
        r = 0
        for i in range(n):
            r += C[i]
            A[i] = r
    print(" ".join(map(str, A)))
main()

Fixed submission:
def main():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))
    _max = max
    _min = min
    for _ in range(k):
        C = [0] * n
        i = 0
        for a in A:
            l = _max(0, i - a)
            r = _min(n, i + a + 1)
            C[l] += 1
            if r < n:
                C[r] -= 1
            i += 1
        r = 0
        for i in range(n):
            r += C[i]
            A[i] = r
        if A == [n] * n:
            break
    print(" ".join(map(str, A)))
main()

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
A = list(map(int, input().split()))
for _ in range(k):
    C = [0] * n
    for i in range(n):
        a = A[i]
        l = max(0, i - a)
        r = min(n, i + a + 1)
        C[l] += 1
        if r < n:
            C[r] -= 1
    r = 0
    for i in range(n):
        r += C[i]
        A[i] = r
print(" ".join(map(str, A)))

Fixed submission:
def main():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))
    _max = max
    _min = min
    for _ in range(k):
        C = [0] * n
        i = 0
        for a in A:
            l = _max(0, i - a)
            r = _min(n, i + a + 1)
            C[l] += 1
            if r < n:
                C[r] -= 1
            i += 1
        r = 0
        for i in range(n):
            r += C[i]
            A[i] = r
        if A == [n] * n:
            break
    print(" ".join(map(str, A)))
main()

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
import numpy as np
import copy
A = np.array(list(map(int, input().split())))
for _ in range(k):
    C = np.zeros([n,], dtype=np.int32)
    for i in range(n):
        a = A[i]
        l = max(0, i - a)
        r = min(n, i + a + 1)
        C[l:r] += 1
    A = C + 0
print(" ".join(map(str, list(A))))

Fixed submission:
def main():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))
    _max = max
    _min = min
    for _ in range(k):
        C = [0] * n
        i = 0
        for a in A:
            l = _max(0, i - a)
            r = _min(n, i + a + 1)
            C[l] += 1
            if r < n:
                C[r] -= 1
            i += 1
        r = 0
        for i in range(n):
            r += C[i]
            A[i] = r
        if A == [n] * n:
            break
    print(" ".join(map(str, A)))
main()