Buggy python submission (verdict: Time Limit Exceeded):
N,K,*A = map(int, open(0).read().split())

for _ in range(K):
    X = [1] * N
    for i, d in enumerate(A):
        for j in range(max(0, i-d), i):
            X[j] += 1
        for j in range(i+1, min(N, i+d+1)):
            X[j] += 1
    if X == A:
        break
    A = X

print(" ".join(map(str, A)))


Fixed submission:
N,K,*A = map(int, open(0).read().split())
                                         
for _ in range(K):                       
    b = [0] * N                          
    for i, d in enumerate(A):            
        b[max(0, i-d)] += 1              
        if i+d+1 < N:                    
            b[i+d+1] -= 1                
    for i in range(1, N):                
        b[i] += b[i-1]                   
    if A == b:                           
        break                            
    A = b                                
                                         
print(" ".join(map(str, A)))

Buggy python submission (verdict: Runtime Error):
import numpy as np                       
                                         
N,K,*A = map(int, open(0).read().split())
A = np.array(A)                          
                                         
for _ in range(K):                       
    X = np.ones(N, int)                  
    for i, d in enumerate(A):            
        X[max(0, i-d):max(0, i)] += 1    
        X[i+1:i+d+1] += 1                
    if np.array_equal(X, A):             
        break                            
    A = X                                
                                         
print(" ".join(map(str, A)))             

Fixed submission:
N,K,*A = map(int, open(0).read().split())
                                         
for _ in range(K):                       
    b = [0] * N                          
    for i, d in enumerate(A):            
        b[max(0, i-d)] += 1              
        if i+d+1 < N:                    
            b[i+d+1] -= 1                
    for i in range(1, N):                
        b[i] += b[i-1]                   
    if A == b:                           
        break                            
    A = b                                
                                         
print(" ".join(map(str, A)))

Buggy python submission (verdict: Runtime Error):
N,K,*A = map(int, open(0).read().split())
n = len(A)

def left(i, d):
    if not (0 <= i < n):
        return 0
    v = A[i] - d + 0.5
    if v <= 0:
        return 0 + left(i - 1, d + 1)
    else:
        return 1 + left(i - 1, d + 1)

def right(i, d):
    if not (0 <= i < n):
        return 0
    v = A[i] - d + 0.5
    if v <= 0:
        return 0 + right(i + 1, d + 1)
    else:
        return 1 + right(i + 1, d + 1)

for _ in range(K):
    X = [0 for _ in range(n)]
    for i in range(n):
        l = left(i-1, 1)
        r = right(i+1, 1)
        v = 1 if i < N else 0
        c = v + l + r
        X[i] = c
    if A == X:
        print(" ".join(map(str, A)))
        exit(0)
    A = X

print(" ".join(map(str, A)))

Fixed submission:
N,K,*A = map(int, open(0).read().split())
                                         
for _ in range(K):                       
    b = [0] * N                          
    for i, d in enumerate(A):            
        b[max(0, i-d)] += 1              
        if i+d+1 < N:                    
            b[i+d+1] -= 1                
    for i in range(1, N):                
        b[i] += b[i-1]                   
    if A == b:                           
        break                            
    A = b                                
                                         
print(" ".join(map(str, A)))

Buggy python submission (verdict: Runtime Error):
N,K,*A = map(int, open(0).read().split())
n = len(A)

def left(i, d):
    if not (0 <= i < n):
        return 0
    v = A[i] - d + 0.5
    if v <= 0:
        return 0 + left(i - 1, d + 1)
    else:
        return 1 + left(i - 1, d + 1)

def right(i, d):
    if not (0 <= i < n):
        return 0
    v = A[i] - d + 0.5
    if v <= 0:
        return 0 + right(i + 1, d + 1)
    else:
        return 1 + right(i + 1, d + 1)

for _ in range(K):
    X = [0 for _ in range(n)]
    for i in range(n):
        l = left(i-1, 1)
        r = right(i+1, 1)
        v = 1 if i < N else 0
        c = v + l + r
        X[i] = c
    if A == X:
        print(" ".join(map(str, A)))
        exit(0)
    A = X

print(" ".join(map(str, A)))

Fixed submission:
N,K,*A = map(int, open(0).read().split())
                                         
for _ in range(K):                       
    b = [0] * N                          
    for i, d in enumerate(A):            
        b[max(0, i-d)] += 1              
        if i+d+1 < N:                    
            b[i+d+1] -= 1                
    for i in range(1, N):                
        b[i] += b[i-1]                   
    if A == b:                           
        break                            
    A = b                                
                                         
print(" ".join(map(str, A)))

Buggy python submission (verdict: Runtime Error):
N,K,*A = map(int, open(0).read().split())
n = min(N, len(A))

def left(i, d):
    if not (0 <= i < n):
        return 0
    v = A[i] - d + 0.5
    if v <= 0:
        return 0 + left(i - 1, d + 1)
    else:
        return 1 + left(i - 1, d + 1)

def right(i, d):
    if not (0 <= i < n):
        return 0
    v = A[i] - d + 0.5
    if v <= 0:
        return 0 + right(i + 1, d + 1)
    else:
        return 1 + right(i + 1, d + 1)

for _ in range(K):
    X = [0 for _ in range(n)]
    for i in range(n):
        l = left(i-1, 1)
        r = right(i+1, 1)
        c = 1 + l + r
        X[i] = c
    if A == X:
        print(" ".join(map(str, A)))
        exit(0)
    A = X

print(" ".join(map(str, A)))

Fixed submission:
N,K,*A = map(int, open(0).read().split())
                                         
for _ in range(K):                       
    b = [0] * N                          
    for i, d in enumerate(A):            
        b[max(0, i-d)] += 1              
        if i+d+1 < N:                    
            b[i+d+1] -= 1                
    for i in range(1, N):                
        b[i] += b[i-1]                   
    if A == b:                           
        break                            
    A = b                                
                                         
print(" ".join(map(str, A)))

Buggy python submission (verdict: Runtime Error):
N,K,*A = map(int, open(0).read().split())

def left(i, d):
    if not (0 <= i < N):
        return 0
    v = A[i] - d + 0.5
    if v <= 0:
        return 0 + left(i - 1, d + 1)
    else:
        return 1 + left(i - 1, d + 1)

def right(i, d):
    if not (0 <= i < N):
        return 0
    v = A[i] - d + 0.5
    if v <= 0:
        return 0 + right(i + 1, d + 1)
    else:
        return 1 + right(i + 1, d + 1)

for _ in range(K):
    X = [0 for _ in range(N)]
    for i in range(N):
        l = left(i-1, 1)
        r = right(i+1, 1)
        c = 1 + l + r
        X[i] = c
    if A == X:
        print(" ".join(map(str, A)))
        exit(0)
    A = X

print(" ".join(map(str, A)))

Fixed submission:
N,K,*A = map(int, open(0).read().split())
                                         
for _ in range(K):                       
    b = [0] * N                          
    for i, d in enumerate(A):            
        b[max(0, i-d)] += 1              
        if i+d+1 < N:                    
            b[i+d+1] -= 1                
    for i in range(1, N):                
        b[i] += b[i-1]                   
    if A == b:                           
        break                            
    A = b                                
                                         
print(" ".join(map(str, A)))

Buggy python submission (verdict: Runtime Error):
N,K,*A = map(int, open(0).read().split())

def left(i, d):
    if not (0 <= i < N):
        return 0
    v = A[i] - d + 0.5
    if v <= 0:
        return 0
    else:
        return 1 + left(i - 1, d + 1)

def right(i, d):
    if not (0 <= i < N):
        return 0
    v = A[i] - d + 0.5
    if v <= 0:
        return 0
    else:
        return 1 + right(i + 1, d + 1)

for _ in range(K):
    X = [0 for _ in range(N)]
    for i, d in enumerate(A):
        l = left(i-1, 1)
        r = right(i+1, 1)
        c = 1 + l + r
        X[i] = c
    A = X
    if all([N == a for a in A]):
        print(" ".join(map(str, A)))
        exit(0)

print(" ".join(map(str, A)))

Fixed submission:
N,K,*A = map(int, open(0).read().split())
                                         
for _ in range(K):                       
    b = [0] * N                          
    for i, d in enumerate(A):            
        b[max(0, i-d)] += 1              
        if i+d+1 < N:                    
            b[i+d+1] -= 1                
    for i in range(1, N):                
        b[i] += b[i-1]                   
    if A == b:                           
        break                            
    A = b                                
                                         
print(" ".join(map(str, A)))

Buggy python submission (verdict: Runtime Error):
N,K,*A = map(int, open(0).read().split())

def left(i, d):
    if i < 0:
        return 0
    if i >= N:
        return 0
    v = A[i] - d + 0.5
    if v <= 0:
        return 0
    else:
        return 1 + left(i - 1, d + 1)

def right(i, d):
    if i < 0:
        return 0
    if i >= N:
        return 0
    v = A[i] - d + 0.5
    if v <= 0:
        return 0
    else:
        return 1 + right(i + 1, d + 1)

for _ in range(K):
    X = [0 for _ in range(N)]
    for i, d in enumerate(A):
        l = left(i-1, 1)
        r = right(i+1, 1)
        c = 1 + l + r
        X[i] = c
    A = X

print(" ".join(map(str, A)))

Fixed submission:
N,K,*A = map(int, open(0).read().split())
                                         
for _ in range(K):                       
    b = [0] * N                          
    for i, d in enumerate(A):            
        b[max(0, i-d)] += 1              
        if i+d+1 < N:                    
            b[i+d+1] -= 1                
    for i in range(1, N):                
        b[i] += b[i-1]                   
    if A == b:                           
        break                            
    A = b                                
                                         
print(" ".join(map(str, A)))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np                       
                                         
N,K,*A = map(int, open(0).read().split())
                                         
for _ in range(K):                       
    X = np.ones(N, int)                  
    for i, d in enumerate(A):            
        X[max(0,i-d):max(0,i)] += 1      
        X[i+1:i+d+1] += 1                
    A = X                                
                                         
print(" ".join(map(str, A)))             

Fixed submission:
N,K,*A = map(int, open(0).read().split())
                                         
for _ in range(K):                       
    b = [0] * N                          
    for i, d in enumerate(A):            
        b[max(0, i-d)] += 1              
        if i+d+1 < N:                    
            b[i+d+1] -= 1                
    for i in range(1, N):                
        b[i] += b[i-1]                   
    if A == b:                           
        break                            
    A = b                                
                                         
print(" ".join(map(str, A)))

Buggy python submission (verdict: Runtime Error):
N,K,*A = map(int, open(0).read().split())  
                                           
def left(i, d):                            
    if i < 0:                              
        return 0                           
    if i >= N:                             
        return 0                           
    v = A[i] - d + 0.5                     
    if v <= 0:                             
        return 0                           
    else:                                  
        return 1 + left(i - 1, d + 1)      
                                           
def right(i, d):                           
    if i < 0:                              
        return 0                           
    if i >= N:                             
        return 0                           
    v = A[i] - d + 0.5                     
    if v <= 0:                             
        return 0                           
    else:                                  
        return 1 + right(i + 1, d + 1)     
                                           
for _ in range(K):                         
    X = [0 for _ in range(N)]              
    for i, d in enumerate(A):              
        l = left(i-1, 1)                   
        r = right(i+1, 1)                  
        c = 1 + l + r                      
        X[i] = c                           
    A = X                                  
                                           
print(A)                                   

Fixed submission:
N,K,*A = map(int, open(0).read().split())
                                         
for _ in range(K):                       
    b = [0] * N                          
    for i, d in enumerate(A):            
        b[max(0, i-d)] += 1              
        if i+d+1 < N:                    
            b[i+d+1] -= 1                
    for i in range(1, N):                
        b[i] += b[i-1]                   
    if A == b:                           
        break                            
    A = b                                
                                         
print(" ".join(map(str, A)))