Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
li = list(map(int,input().split()))
ans = [0]*(n+1)
tmp = [0]*(n+1)
tmp_sum = []
#print(ans)
#[0, 0, 0, 0, 0]

for kkk in range(k):
    #print(li,'li')
    for i,l in enumerate(li):
        if l != 0:
            start = max(0,i-l)
            end = min(n,i+l+1)
            #print(start,'start',end,'end')
            tmp[start] += 1
            #print(end,len(tmp),'aaa')
            tmp[end] -= 1
    #print(tmp,'tmp')
    last = 0
    for t in tmp:
        last = t+last
        tmp_sum.append(last)
    for i,l in enumerate(li):
        if l == 0:
            tmp_sum[i] += 1
    ans = tmp_sum[:n]
    li = tmp_sum[:n]
    tmp = [0]*(n+1)
    tmp_sum = []
    #if len(set(ans)) == 1:
    #    break
print(*ans)

Fixed submission:
n,k = map(int,input().split())
li = list(map(int,input().split()))
ans = [0]*(n+1)
tmp = [0]*(n+1)
tmp_sum = []
#print(ans)
#[0, 0, 0, 0, 0]
k = min(k,100)

for kkk in range(k):
    #print(li,'li')
    for i,l in enumerate(li):
        if l != 0:
            start = max(0,i-l)
            end = min(n,i+l+1)
            #print(start,'start',end,'end')
            tmp[start] += 1
            #print(end,len(tmp),'aaa')
            tmp[end] -= 1
    #print(tmp,'tmp')
    last = 0
    for t in tmp:
        last = t+last
        tmp_sum.append(last)
    for i,l in enumerate(li):
        if l == 0:
            tmp_sum[i] += 1
    ans = tmp_sum[:n]
    li = tmp_sum[:n]
    tmp = [0]*(n+1)
    tmp_sum = []
    #if len(set(ans)) == 1:
    #    break
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
li = list(map(int,input().split()))
ans = [0]*n
tmp = [0]*n
#print(ans)
#[0, 0, 0, 0, 0]
for kkk in range(k):
    for i,l in enumerate(li):
        for xx in range(n):
            sa = abs(xx - i)
            #print(sa,l,'sa',i)
            if sa<=l:
                tmp[xx]+=1
    ans = tmp
    li = tmp
    tmp = [0]*n
    if len(set(ans)) == 1:
        break
print(*ans)

Fixed submission:
n,k = map(int,input().split())
li = list(map(int,input().split()))
ans = [0]*(n+1)
tmp = [0]*(n+1)
tmp_sum = []
#print(ans)
#[0, 0, 0, 0, 0]
k = min(k,100)

for kkk in range(k):
    #print(li,'li')
    for i,l in enumerate(li):
        if l != 0:
            start = max(0,i-l)
            end = min(n,i+l+1)
            #print(start,'start',end,'end')
            tmp[start] += 1
            #print(end,len(tmp),'aaa')
            tmp[end] -= 1
    #print(tmp,'tmp')
    last = 0
    for t in tmp:
        last = t+last
        tmp_sum.append(last)
    for i,l in enumerate(li):
        if l == 0:
            tmp_sum[i] += 1
    ans = tmp_sum[:n]
    li = tmp_sum[:n]
    tmp = [0]*(n+1)
    tmp_sum = []
    #if len(set(ans)) == 1:
    #    break
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
li = list(map(int,input().split()))
ans = [0]*n
tmp = [0]*n
#print(ans)
#[0, 0, 0, 0, 0]
for kkk in range(k):
    for i,l in enumerate(li):
        for xx in range(n):
            sa = abs(xx - i)
            #print(sa,l,'sa',i)
            if sa<=l:
                tmp[xx]+=1
    ans = tmp
    li = tmp
    tmp = [0]*n
print(*ans)

Fixed submission:
n,k = map(int,input().split())
li = list(map(int,input().split()))
ans = [0]*(n+1)
tmp = [0]*(n+1)
tmp_sum = []
#print(ans)
#[0, 0, 0, 0, 0]
k = min(k,100)

for kkk in range(k):
    #print(li,'li')
    for i,l in enumerate(li):
        if l != 0:
            start = max(0,i-l)
            end = min(n,i+l+1)
            #print(start,'start',end,'end')
            tmp[start] += 1
            #print(end,len(tmp),'aaa')
            tmp[end] -= 1
    #print(tmp,'tmp')
    last = 0
    for t in tmp:
        last = t+last
        tmp_sum.append(last)
    for i,l in enumerate(li):
        if l == 0:
            tmp_sum[i] += 1
    ans = tmp_sum[:n]
    li = tmp_sum[:n]
    tmp = [0]*(n+1)
    tmp_sum = []
    #if len(set(ans)) == 1:
    #    break
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
li = list(map(int,input().split()))
ans = [0]*n
#print(ans)
#[0, 0, 0, 0, 0]
for kkk in range(k):
    if kkk == 0:
        for i,l in enumerate(li):
            if l == 0:
                ans[i]+=1
            else:
                mi = max(0,i - l)
                ma = min(n-1,i + l)
                for x in range(mi,ma+1):
                    ans[x]+=1
    else:
        tmp = [0]*n
        for i,l in enumerate(ans):
            if l == 0:
                tmp[i]+=1
            else:
                mi = max(0,i - l)
                ma = min(n-1,i + l)
                for x in range(mi,ma+1):
                    tmp[x]+=1
        ans = tmp
    #print(*ans)
print(*ans)

Fixed submission:
n,k = map(int,input().split())
li = list(map(int,input().split()))
ans = [0]*(n+1)
tmp = [0]*(n+1)
tmp_sum = []
#print(ans)
#[0, 0, 0, 0, 0]
k = min(k,100)

for kkk in range(k):
    #print(li,'li')
    for i,l in enumerate(li):
        if l != 0:
            start = max(0,i-l)
            end = min(n,i+l+1)
            #print(start,'start',end,'end')
            tmp[start] += 1
            #print(end,len(tmp),'aaa')
            tmp[end] -= 1
    #print(tmp,'tmp')
    last = 0
    for t in tmp:
        last = t+last
        tmp_sum.append(last)
    for i,l in enumerate(li):
        if l == 0:
            tmp_sum[i] += 1
    ans = tmp_sum[:n]
    li = tmp_sum[:n]
    tmp = [0]*(n+1)
    tmp_sum = []
    #if len(set(ans)) == 1:
    #    break
print(*ans)