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


for i in range(k):
    b = [0] * (n+1)
    for j in range(n):
        l = max(0, j-a[j])
        r = min(n, j+a[j]+1)
        b[l] += 1
        b[r] -= 1
    for j in range(n):
        b[j+1] += b[j]
    b.pop()
    if a == b:
        break
    a = b
print(' '.join(map(str, a)))

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


for i in range(k):
    b = [0] * (n+1)
    for j in range(n):
        l = max(0, j-a[j])
        r = min(n, j+a[j]+1)
        b[l] += 1
        b[r] -= 1
    for j in range(n):
        b[j+1] += b[j]
    b.pop()
    if a == b:
        break
    a = b
print(' '.join(map(str, a)))

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


for i in range(k):
    b = [0] * (n+1)
    for j in range(n):
        l = max(0, j-a[j])
        r = min(n, j+a[j]+1)
        b[l] += 1
        b[r] -= 1
    for j in range(n):
        b[j+1] += b[j]
    b.pop()
    if a == b:
        print(' '.join(map(str, a)))
        exit()
    a = b
print(' '.join(map(str, a)))

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


for i in range(k):
    b = [0] * (n+1)
    for j in range(n):
        l = max(0, j-a[j])
        r = min(n, j+a[j]+1)
        b[l] += 1
        b[r] -= 1
    for j in range(n):
        b[j+1] += b[j]
    b.pop()
    if a == b:
        break
    a = b
print(' '.join(map(str, a)))

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

for i in range(k):
    b = [0] * (n+1)
    c = list(b)
    for j in range(n):
        l = max(0, j-a[j])
        r = min(n, j+a[j]+1)
        b[l] += 1
        b[r] -= 1
    for j in range(1, n):
        b[j] += b[j-1]
    a = b
    if b == c:
        for j in range(n):
            print(a[j], end=' ')
        exit()
for i in range(n):
    print(a[i], end=' ')


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


for i in range(k):
    b = [0] * (n+1)
    for j in range(n):
        l = max(0, j-a[j])
        r = min(n, j+a[j]+1)
        b[l] += 1
        b[r] -= 1
    for j in range(n):
        b[j+1] += b[j]
    b.pop()
    if a == b:
        break
    a = b
print(' '.join(map(str, a)))

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

for i in range(k):
    b = [0] * (n+1)
    c = list(b)
    for j in range(n):
        l = max(0, j-a[j])
        r = min(n, j+a[j]+1)
        b[l] += 1
        b[r] -= 1
    for j in range(1, n):
        b[j] += b[j-1]
    a = b
    if b == c:
        for j in range(n):
            print(a[j], end=' ')
        exit()
for i in range(n):
    print(a[i], end=' ')


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


for i in range(k):
    b = [0] * (n+1)
    for j in range(n):
        l = max(0, j-a[j])
        r = min(n, j+a[j]+1)
        b[l] += 1
        b[r] -= 1
    for j in range(n):
        b[j+1] += b[j]
    b.pop()
    if a == b:
        break
    a = b
print(' '.join(map(str, a)))

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

r = [[0 for _ in range(n)] for _ in range(k)]

for i in range(k):
    for j in range(n):
        if j-a[j] < 0 and j+a[j]+1 <= (n-1):
            r[i][0] += 1
            r[i][j+a[j]+1] -= 1           
        elif j-a[j] < 0 and j+a[j]+1 > (n-1):
            r[i][0] += 1
        elif j-a[j] >=0 and j+a[j]+1 <= (n-1):
            r[i][j-a[j]] += 1
            r[i][j+a[j]+1] -= 1
        elif j-a[j] >= 0 and j+a[j]+1 > (n-1):
            r[i][j-a[j]] += 1
        else:
            r[i][j-a[j]] += 1
            r[i][j+a[j]+1] -= 1
    for j in range(1, n):
        r[i][j] += r[i][j-1]
    a = r[i]
    if r[i] == r[i-1]:
        print(' '.join(map(str, r[i])))
        exit()
print(' '.join(map(str, r[k-1])))


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


for i in range(k):
    b = [0] * (n+1)
    for j in range(n):
        l = max(0, j-a[j])
        r = min(n, j+a[j]+1)
        b[l] += 1
        b[r] -= 1
    for j in range(n):
        b[j+1] += b[j]
    b.pop()
    if a == b:
        break
    a = b
print(' '.join(map(str, a)))