Problem:


Score : 500 points

Problem Statement

We have N bulbs arranged on a number line, numbered 1 to N from left to right.
Bulb i is at coordinate i.

Each bulb has a non-negative integer parameter called intensity.
When there is a bulb of intensity d at coordinate x, the bulb illuminates the segment from coordinate x-d-0.5 to x+d+0.5.
Initially, the intensity of Bulb i is A_i. We will now do the following operation K times in a row:

For each integer i between 1 and N (inclusive), let B_i be the number of bulbs illuminating coordinate i. Then, change the intensity of each bulb i to B_i.

Find the intensity of each bulb after the K operations.

Constraints

1 \leq N \leq 2 \times 10^5

1 \leq K \leq 2 \times 10^5

0 \leq A_i \leq N

Input

Input is given from Standard Input in the following format:

N K
A_1 A_2 \ldots A_N

Output

Print the intensity A{'}_i of each bulb i after the K operations to Standard Output in the following format:

A{'}_1 A{'}_2 \ldots A{'}_N

Sample Input 1

5 1
1 0 0 1 0

Sample Output 1

1 2 2 1 2 

Initially, only Bulb 1 illuminates coordinate 1, so the intensity of Bulb 1 becomes 1 after the operation.
Similarly, the bulbs initially illuminating coordinate 2 are Bulb 1 and 2, so the intensity of Bulb 2 becomes 2.

Sample Input 2

5 2
1 0 0 1 0

Sample Output 2

3 3 4 4 3 



Sample input:
5 1
1 0 0 1 0


Sample output:
1 2 2 1 2

Submission status: Runtime Error

Solution code:
import sys
from math import factorial
from collections import Counter
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
import numpy as np
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

n, k = MAP()
a = LIST()

def update(a):
    b = np.zeros((n, n), dtype = np.int64)
    for i in range(n):
        b[i, max(0, i-a[i]):min(n, i+a[i]+1)] = 1
    return np.sum(b, axis=0)
end = [n]*n

for i in range(k):
    if a == end:
        break
    a = list(update(a))
for i in range(n):
    print(str(int(a[i]))+" ",end = "" )

Submission status: Runtime Error

Solution code:
import copy
import math
N, K = map(int, input().split())
A = list(map(int, input().split()))

if math.ceil(math.log2(N // 10)) * 3 + 6 < K:
    A= [N]*N
else:
    for _ in range(K):
        B = [0] * N
        for i in range(N):
            if A[i] >= 0:
                if (A[i] >= max(N - i, i)):
                    B = list(map(lambda x: x+1, B))
                else:
                    B[i] += 1
                    for j in range(A[i]):
                        if (i - j - 1 >= 0):
                            B[i-j-1] += 1
                        if (i + j + 1 < N):
                            B[i+j+1] += 1
        A = copy.copy(B)

for _ in A:
    print(_, end=' ')

Submission status: Runtime Error

Solution code:
n, k = map(int,input().split())
A = list(map(int,input().split()))
B = [0 for d in range(n)]
for i in range(k):
    for j in range(n):
        if int(A[j]) >= 1:
            min = (j+1) - int(A[j])
            max = (j+1) + int(A[j]) 
            for e in range(n):
                if min <= e or e <= max:
                    int(B[e]) = int(B[e]) + 1
        min = 0
        max = 0

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
A = list(map(int,input().split()))
a = [0]*N
for i in range(K) :
    for j in range(N) :
        for d in range(j-A[j],j+A[j]):
            a[d] += A[j]
    A = a
print(A)

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split()
A = map(int, input().split())

A = list(A)
for h in range(1, K+1):    
    B = [1] * N
    for i in range(N):
        if i - A[i] < 0:
            x = 0
        else:
            x = i - A[i]     
        if i + A[i] >= N:       
            y = N - 1
        else:
            y = i + A[i]    

        for j in range(x, y):
            B[j] = B[j] + 1 
        A = B    
print(A)

Submission status: Runtime Error

Solution code:
import numpy as np

if __name__ == '__main__':
    N, K = map(int, input().strip().split(" "))
    A = np.array(input().strip().split(" ")).astype(int)

    if N <= K:
        print(" ".join([str(N)] * N))
    else:
        B = np.identity(N).astype(bool)
        for i in range(K):
            for j in range(N):
                for k in range(max(0, j - A[j]), min(j + A[j] + 1, N), 1):
                    B[j][k] = True
            A = np.sum(B, axis=0)
        print(" ".join(A.astype(str)))

Submission status: Runtime Error

Solution code:
n, k = map(int,input().split())
A = list(map(int,input().split()))
B = [0 for d in range(n)]
for i in range(k):
    for j in range(n):
        if int(A(j)) >= 1:
            min = (j+1) - int(A(j))
            max = (j+1) + int(A(j)) 
            for e in range(n):
                if min <= e or e <= max:
                    int(B(e)) = int(B(e)) + 1
        min = 0
        max = 0

Submission status: Runtime Error

Solution code:
import math
import numpy as np

N,K = map(int,input().split())
A = np.array(list(map(int,input().split())))

eikyo = np.zeros((N,N))

def make_eikyo(o_A):
    for i,a in enumerate(o_A):
        satan = max(0,math.ceil(i-a-0.5))
        utan = min(N,math.floor(i+a+0.5))
        eikyo[i][:] = 0
        eikyo[i][satan:utan+1] = 1
    n_A = eikyo.sum(axis=0)
    # print(eikyo)
    return n_A



for _ in range(K):
    A = make_eikyo(A)
    if np.all(A>=N):
        break
for i,a in enumerate(A):
    if i+1 == A.size:
        print(int(a))
    else:
        print(int(a), end=' ')

Submission status: Runtime Error

Solution code:
import copy
def resolve():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    
    if K + min(A) >= N:
        print(" ".join(map(str, [N]*N))
        return

    for i in range(K):
        A_next = [0] * len(A)
        for i, a in enumerate(A):
            A_next[i] += 1
            for d in range(1, a+1):
                idx = i - d
                if idx >= 0 and idx < len(A_next):
                    A_next[idx] += 1

                idx = i + d
                if idx >= 0 and idx < len(A_next):
                    A_next[idx] += 1
        A = copy.deepcopy(A_next)

        if min(A) == N:
            break 

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

if __name__ == "__main__":
    resolve()

Submission status: Runtime Error

Solution code:
N,K=map(int,input().split())
a=list(map(int,input().split()))
if K>=N-1:
    ans=[N]*N
print(' '.join(map(str,ans)))
else:
    pass

Submission status: Runtime Error

Solution code:
import sys
from collections import deque
import copy
import math
def main():
    N, K = map(int, input().split())
    a = [float(i) for i in input().split()]
    A = [0] * (N + 1)
    if K >= N:
        for i in range(1, N+1):
            if i > 1:
                print(' ', end='')
            print(N, end='')
        print()
        sys.exit()
    for i in range(1, N+1):
        if a[i - 1] > N:
            a[i - 1] = N
        A[i] = a[i - 1]
    for _ in range(K):
        count = [0] * (N + 1)
        for i in range(1, N+1):
            if A[i] == N:
                left_d = 1
                right_d = N
                count[1:] += 1
            else:
                left_d = math.ceil(i - A[i] - 0.5)
                right_d =  math.floor(i + A[i] + 0.5)
                if left_d < 1:
                    left_d = 1
                if right_d > N:
                    right_d = N
                for j in range(left_d, right_d+1):
                    count[j] += 1
        A = copy.copy(count)
        flag = True
        for i in range(1, N+1):
            if A[i] != N:
                flag = False
                break
        if flag:
            break
    for i in range(1, N+1):
        if i > 1:
            print(' ', end='')
        print(A[i], end='')
    print()


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import numpy as np

n, k = map(int,input().split())

a = list(map(int,input().split()))

light = np.zeros((n, n), dtype=int)

for _ in range(k):
    for i, arr in enumerate(light):
        x_1, x_2 = i - a[i], i + a[i] + 1

        if x_1 < 0:
            x_1 = 0

        arr[x_1:x_2] = 1
    a = light.sum(axis=0)

print(*list(a))

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
import numpy as np

n, k = map(int, input().split())
A = [int(a) for a in input().split()]

Defl = np.zeros((n, 3*n+2), dtype = int)


def nextLights(A, Defl):
    Lights =Defl
    i = 1
    for a in A:
        line = np.ones(a*2+1, dtype = int)
        Lights[i-1, n+i-a:n+i+a+1] = line
        i+=1
    Lights = Lights[:, n+1:2*n+1]
    Next_A = np.sum(Lights, axis=0)
    return Next_A

if k >= n+1:
    print((str(n)+" ")*n)
else:
    for i in range(k):
        nextLights(A, Defl)
        A = A
    print(" ".join(str(a) for a in A))

Submission status: Runtime Error

Solution code:
import numpy as np
n, k = map(int, input().split())
an = list(map(int, input().split()))

an = np.array(an)
an1 = np.zeros((n, n), int)
for _ in range(k):
    for i in range(n):
        right = i - an[i]
        left = i + an[i] + 1
        if right < 0:
            right = 0
        if left > n:
            left = n
        an1[i][right : left] = 1

    an = np.sum(an1, axis=0)
    if np.sum(an) == n**2:
        break

print(' '.join(map(str, an)))

Submission status: Runtime Error

Solution code:
n, k = map(int,input().split())
A = list(map(int,input().split()))
B = [0 for d in range(n)]
for i in range(k):
    for j in range(n):
        if A(j) >= 1:
            min = (j+1) - A(j)
            max = (j+1) + A(j) 
            for e in range(n):
                if min <= e or e <= max:
                    B(e) = B(e) + 1
        min = 0
        max = 0

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
A = list(map(int,input().split()))

for i in range(K):
    cnt=[0]*N
    if min(A)=N:
        A=[N]*N
        print(" ".join(str(x) for x in A))
        exit()
    for j in range(N):
        p=A[j]
        if p>N:
            continue
        for k in range(max(0,j-p),min(j+p+1,N)):
                cnt[k]+=1
    A=cnt

print(" ".join(str(x) for x in A))

Submission status: Runtime Error

Solution code:
import numpy as np
N, K = map(int, input().split())
A = np.array(list(map(int, input().split())))

D = np.diag([1]*N)

is_all_on = [0] * N

for k in range(K):
    for i in range(N):
        if not is_all_on[i]:
            L = max(0, i-A[i])
            R = min(i+A[i]+1, N)

            D[i][L:R] = 1

            is_all_on[i] = D[i].all()
    A = D.sum(axis=0)
    
print(*D.sum(axis=0))

Submission status: Runtime Error

Solution code:
import math
import numpy as np

N,K = map(int,input().split())
A = np.array(list(map(int,input().split())))

eikyo = np.zeros((N,N))

def make_eikyo(A):
    for i,a in enumerate(A):
        satan = max(0,math.ceil(i-a-0.5))
        utan = min(N,math.floor(i+a+0.5))
        eikyo[i][:] = 0
        eikyo[i][satan:utan+1] = 1
    n_A = eikyo.sum(axis=0)
    # print(eikyo)
    return n_A



for _ in range(K):
    A = make_eikyo(A)
    if np.all(A>=N):
        break
for i,a in enumerate(A):
    if i+1 == A.size:
        print(int(a))
    else:
        print(int(a), end=' ')

Submission status: Runtime Error

Solution code:
n, k = map(int,input().split())
A = list(map(int,input().split()))
B = [0 for i in range(n)]
for i in range(k):
    for j in range(n):
        if A(j) >= 1:
            min = (j+1) - A(j)
            max = (j+1) + A(j) 
            for e in range(n):
                if min <= e or e <= max:
                    B(e) = B(e) + 1
        min = 0
        max = 0

Submission status: Runtime Error

Solution code:
NK = list(map(int, input().split()))
A = list(map(int, input().split()))

lamp = []
for i in range(len(A)):
    lamp.append(A[i])


def sum1(n):
    return n + 1

def operation(lampList):
    tmpList = [0] * len(lampList)

    for i in range(len(lampList)):
        l = lampList[i] + 1
        if (l > NK[0] - i and l > i):
            tmpList = map(sum1, tmpList)
        else:
            tmpList[i] += 1
            for j in range(1, l):
                if (i - j >= 0):
                    tmpList[i - j] += 1
                if (i + j < NK[0]):
                    tmpList[i + j] += 1
    return tmpList

for i in range(NK[1]):
    lamp = operation(lamp)

L=[str(a if a < NK[0] else NK[0]) for a in lamp]
L=" ".join(L)
print(L)

Submission status: Runtime Error

Solution code:
from numpy import zeros
 
N,K=(int(x) for x in input().split())
#print(N)
#print(K)
 
A=input().split()
#print(type(A))
for count in range(K):
  Anew=zeros(N)
  for i in range(N):
    for k in range(N):
      if abs(i-k)<=int(A[k]):
        Anew[i]+=1
 #       print(i,k,Anew[i])
 
  if count==K-1:
    for i in Anew:
      print(int(i),end=" ")
  A=Anew

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
num=0
ans=[0]*n
if
def abs_1(num1):
    return(abs(num1))
for i in range(k):
    ans=[0]*n
    for j in range(n):
        for l in range(n):
            if abs_1(j-l)<=a[l]:
                ans[j]+=1
    a=ans
    if sum(a)==n**2:
        break
print(*a)

Submission status: Runtime Error

Solution code:
import sys
from math import factorial
from collections import Counter
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
import numpy as np
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

n, k = MAP()
a = LIST()
a = np.array(a, dtype= np.int64)
def update(a):
    b = np.zeros((n, n), dtype = np.int64)
    for i in range(n):
        b[i, max(0, i-a[i]):min(n, i+a[i]+1)] = 1
    return np.sum(b, axis=0)
end = np.full(n, n, dtype = np.int64)


for i in range(k):
    if np.all(a == end):
        break
    a = update(a)
for i in range(n):
    print(str(int(a[i]))+" ",end = "" )

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')
AtoZ = "abcdefghijklmnopqrstuvwxyz"

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

#####GCD#####
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############
N,K = IL()
A = IL()


while True:
  if K == 0:
    break
  if min(A) == N:
    break
  SEGLEN = 17
  seg = [0 for i in range(2**(SEGLEN+1))]
  for i in range(N):
    l = max(0,i-A[i])
    r = min(N-1,i+A[i])
    l += 2**SEGLEN
    r += 2**SEGLEN+1
    while l < r:

      if l%2 == 1:
        seg[l] += 1
      if r%2 == 1:
        seg[r-1] += 1
      l = -(-l//2)
      r = r//2
  A = []
  for i in range(N):
    i += 2**SEGLEN
    ans = 0
    while i:
      ans += seg[i]
      i //= 2
    A.append(ans)
  K -= 1
  
print(*A)

Submission status: Runtime Error

Solution code:
from math import floor, ceil
import numpy as np

n, k = map(int, input().split())
lights = list(map(int, input().split()))
new_lights = [0] * n


for _ in range(k):
    arr = np.empty((0,n), int)

    for i, num in enumerate(lights):
        r = ceil((i+1) - num - 0.5)
        l = floor((i+1) + num + 0.5)

        if r != 0: 
            r -= 1

        l -= 1
        if l >= n:
            l = n-1

        add_lights = [0] * n
        add_lights[r:l+1] = [1]*(l-r+1)

        arr = np.append(arr, np.array([add_lights]), axis=0)
        
    lights = np.sum(arr, axis=0)

for x in lights.tolist():
    print(x, end=" ")

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
ans=list(map(int,input().split()))

ans1=[0]*n

for b in range(0,n):
  temp=ans[b]
    
  d=b-temp
  if d <= 0:
    d=0
  e=b+temp
  if e >= n:
    e=n
  for c in range(d,e+1):
    ans1[c]=ans1[c]+1
    

    
for a in range(0,k-1):
  ans2=ans1
  ans3=[0]*n
  for b in range(0,n):
  	temp=ans1[b]
    
  	d=b-temp
  	if d <= 0:
    	 d=0
  	e=b+temp
  	if e >= n-1:
    	 e=n-1
  	for c in range(d,e+1):
    	 ans3[c]=ans3[c]+1
  ans1=ans3
  

print(ans1)

Submission status: Runtime Error

Solution code:
import threading
N,K= map(int,input().split())
A = list(map(int,input().split()))
T = [0]*N
class loop(threading.Thread):
    def __init__(self):
        threading.Thread.__init__(self)
    def main(self):
        for i in range(N):
            for j in range(i-A[i],i+A[i]+1):
                if j>=0 and j<=N-1:
                    T[j] += 1
for t in range(K):
    thread = loop()
    thread.start()
    thread_list.append(thread)
    A = T
    T =[0]*N
for thread in thread_list:
    thread.join()

A=' '.join(map(str,A))
print(A)

Submission status: Runtime Error

Solution code:
A, V = list(map(int,input().split()))
B, W = list(map(int,input().split()))
T = int(input())
if V<=W or (V-W)*T <= (B-A):
  print('NO')
else :
  print('YES')

Submission status: Runtime Error

Solution code:
N , K = map(int , input().split())
A = list(map(int , input().split()))
    
if K >= (N-1):
    S = [N]*(N)
    print(*S)
else:
    for h in range(K):
        ans = [N]*0
        for i in range (N):
            lo = (i + 1)-A[i]
            hi = (i + 1)+A[i]
            if lo<0:
                lo = 0
            if hi>N-1:
                hi = N-1
            for j in range (hi-lo):
                ans [j+lo] += 1
            A = ans
        if sum(A) == N**2:
            A = [N]*(N)
            break
    print(*A)

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
As = list(map(int, input().split()))

for i in range(K):
  nextA = [0] * N
  for j in range(N):
    lamps = [0] * N
    under , over = 0, N
    if j-As[j] > 0:
        under = j-As[j]
    if j+As[j] <= N:
        over = j+As[j]+1
    for k in range(under, over):
        lamps[k] = 1
    nextA = [x+y for x, y in zip(nextA, lamps)]
  As = nextA

ans = ''
for A in As:
    ans += str(A) + ' '
print(ans.strip())

Submission status: Runtime Error

Solution code:
import numpy as np

n, k = map(int,input().split())

a = list(map(int,input().split()))

light = np.zeros((n, n))

for _ in range(k):
    for i, arr in enumerate(light):
        x_1, x_2 = i - a[i], i + a[i] + 1

        if x_1 < 0:
            x_1 = 0

        arr[x_1:x_2] = 1
    a = light.sum(axis=0).astype(int)

print(*list(a))

Submission status: Runtime Error

Solution code:
from math import floor, ceil
import numpy as np

n, k = map(int, input().split())
lights = list(map(int, input().split()))
new_lights = [0] * n


for _ in range(k):
    arr = np.empty((0,n), int)

    for i, num in enumerate(lights):
        r = ceil((i+1) - num - 0.5)
        l = floor((i+1) + num + 0.5)

        if r != 0: 
            r -= 1

        l -= 1
        if l >= n:
            l = n-1

        add_lights = [0] * n
        add_lights[r:l+1] = [1]*(l-r+1)

        arr = np.append(arr, np.array([add_lights]), axis=0)
        
    lights = np.sum(arr, axis=0)

print(" ".join([str(x) for x in lights.tolist()]))

Submission status: Runtime Error

Solution code:
def main():
    number, operations = [int(x) for x in input().split()]
    dists = [int(x) for x in input().split()]

    # number = 635
    # dists = [1] * number
    # operations = number
    satulation = any(
        operations >= 40,
        number <= 3000 and operations >= 25,
        number <= 1000 and operations >= 21,
        number <= 625 and operations >= 20
    )
    if satulation:
        print(*([number] * number))
        return

    for xx in range(operations):
        dists_new = [0] * number
        for i, d in enumerate(dists):
            start = max(0, i - d)
            end = min(i + d, number - 1)
            for j in range(start, end + 1):
                dists_new[j] += 1
        dists = dists_new
        if min(dists) == number:
            # すべての光が両端まで届く，変化しなくなる。
            print('Over', xx)
            break

    print(*dists)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import sys
input=sys.stdin.readline
def main():
    n,k=map(int,input().split())
    a=list(map(int,input().split()))
    zeros=[0 for i in range(n)]
    if max(a)==0:
        print(*a)
        exit()
    if min(a)==n:
        print(*a)
        exit()
    for i in range(k):
        x=zeros.copy()
        for j in range(n):
            if a[j]==0:
                l=j
                r=j+1
            else:
                l=max(0,j-a[j])
                r=min(j+a[j]+1,n-1)
           # print(l,r)
            x[l]+=1
            if r!=n-1:
                x[r]+=-1
            #print(x)
        ruiseki=[0]*n
        ruiseki[0]=x[0]
        a[0]=ruiseki[0]
        mina=a[0]
        for i in range(1,n):
            ruiseki[i]=ruiseki[i-1]+x[i]
            a[i]=ruiseki[i]
            if a[i]<mina:
                mina=a[i]
        if mina==n:
            print(*a)
            exit()
        #print(*ruiseki)
    print(*a)
if __name__=="__main__":
    main()

Submission status: Runtime Error

Solution code:
import numpy as np

n, k = map(int, input().split())
a = input().split()
i_list = list(range(len(a)))
i_array = np.array(i_list)
a = [int(a[i]) for i in i_list]
c = [0]*n

for m in range(k):
    a = np.array(a)
    for i in range(n):
        dum = np.array([i]*n)
        b = a - abs(i_array - dum)
        c[i] = sum(1 for x in b if x >=0)
    a = []
    a += c
a = [str(aa) for aa in a]
print(' '.join(a))

Submission status: Runtime Error

Solution code:

N,K=map(int,input().split())
A= list(map(int,input().split()))
new_A = A
len_A=N
count_list = [0]*N
K_list=range(K)
A_list=range(len_A)
for i in K_list:
    for j in A_list:
        if(new_A[j]!=0):
            low_posi=j-new_A[j]
            if(low_posi<0):
                low_posi=0
            high_posi = j+new_A[j]
            if(high_posi>N):
                high_posi=N-1
            for k in range(low_posi,high_posi+1):
                count_list[k] += 1
        else:
            count_list[j]+=1
    new_A=count_list
    count_list = [0]*N
for s in new_A:
    print(str(s)+" ", end ="")

Submission status: Runtime Error

Solution code:
import math
import numpy as np

N,K = map(int,input().split())
A = np.array(list(map(int,input().split())))

eikyo = np.zeros((N,N))

def make_eikyo(A):
    for i,a in enumerate(A):
        satan = max(0,math.ceil(i-a-0.5))
        utan = min(N,math.floor(i+a+0.5))
        eikyo[i][:] = 0
        if satan==utan:
            eikyo[i][i] = 1
        else:
            eikyo[i][satan:utan+1] = 1
    n_A = eikyo.sum(axis=0)
    # print(eikyo)
    return n_A



for _ in range(K):
    A = make_eikyo(A)
    if np.all(A>=N):
        break
for i,a in enumerate(A):
    if i+1 == A.size:
        print(int(a))
    else:
        print(int(a), end=' ')

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
As = list(map(int, input().split()))

for i in range(K):
  nextA = [0] * N
  for j in range(N):
    lamps = [0] * N
    under , over = 0, N
    if j-As[j] > 0:
        under = j-As[j]
    if j+As[j] <= N:
        over = j+As[j]+1
    for k in range(under, over):
        lamps[k] = 1
    nextA = [x+y for x, y in zip(nextA, lamps)]
  As = nextA

ans = ''
for A in As:
    ans += str(A) + ' '
print(ans.strip())

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
import numpy as np

n, k = map(int, input().split())
A = [int(a) for a in input().split()]

Defl = np.zeros((n, 3*n+2), dtype = int)


def nextLights(A, Defl):
    Lights =Defl
    i = 1
    for a in A:
        line = np.ones(a*2+1, dtype = int)
        Lights[i-1, n+i-a:n+i+a+1] = line
        i+=1
    Lights = Lights[:, n+1:2*n+1]
    Next_A = np.sum(Lights, axis=0)
    return Next_A

if k >= n+1:
    print((str(n)+" ")*n)
else:
    for i in range(k):
        Next_A = nextLights(A, Defl)
        A = Next_A
    print(" ".join(str(a) for a in A))

Submission status: Runtime Error

Solution code:
import numpy as np
n, k = map(int, input().split())
an = list(map(int, input().split()))

an = np.array(an)
an1 = np.zeros((n, n), int)
for _ in range(k):
    for i in range(n):
        right = i - an[i]
        left = i + an[i] + 1
        if right < 0:
            right = 0
        if left > n:
            left = n
        an1[i][right : left] = 1

    an = np.sum(an1, axis=0)
    if np.sum(an) == n**2:
      break

print(' '.join(map(str, an)))

Submission status: Runtime Error

Solution code:
a = input().split()
N = int(a[0])
K = int(a[1])
A = input().split()
B = []
C = []
time = 0
for i in range(N):
    B.append(0)
if time ==0:
    for i in range(N):
        X = i + 1 - int(A[i])
        Y = i + 1 + int(A[i])
        if X -1 >= 0:
            if Y <= N:
                for z in range(X-1,Y):
                    C.append(z)
            else:
                for z in range(X-1,N):
                    C.append(z)
        elif X-1 < 0:
            if Y <= N:
                for z in range(0,Y):
                    C.append(z)
            else:
                for Z in range(0,N):
                    C.append(z)
        for k in range(len(C)):
            B[C[k]] += 1
        C = []
    time += 1
else:
    for v in range(K-1):
        for i in range(N):
            X = i + 1 - int(B[i])
            Y = i + 1 + int(B[i])
            if X -1 >= 0:
                if Y <= N:
                    for z in range(X-1,Y):
                        C.append(z)
                else:
                    for z in range(X-1,N):
                        C.append(z)
            elif X-1 < 0:
                if Y <= N:
                    for z in range(0,Y):
                        C.append(z)
                else:
                    for Z in range(0,N):
                        C.append(z)
            for k in range(len(C)):
                B[C[k]] += 1
            C = []
print(B)
print(" ".join(map(str, B)))

Submission status: Runtime Error

Solution code:
import math
import numpy as np

N,K = map(int,input().split())
A = np.array(list(map(int,input().split())))

eikyo = np.zeros((N,N))

def make_eikyo(A):
    for i,a in enumerate(A):
        satan = max(0,math.ceil(i-a))
        utan = min(N,math.floor(i+a))
        eikyo[i][:] = 0
        if satan==utan:
            eikyo[i][i] = 1
        else:
            eikyo[i][satan:utan+1] = 1
    n_A = eikyo.sum(axis=0)
    # print(eikyo)
    return n_A



for _ in range(K):
    A = make_eikyo(A)
    if np.all(A>=N):
        break
for i,a in enumerate(A):
    if i+1 == A.size:
        print(int(a))
    else:
        print(int(a), end=' ')

Submission status: Runtime Error

Solution code:
N,K=map(int,input().split())
A=list(map(int,input().split()))

for n in range(K):
  B=[0]*N
  for i in range(N):
    key=i-A[i]
    Key=i+A[i]+1
    if key<0:
      key=0
    if Key>N+1:
      Key=N
    for x in range(key,Key):
      B[x]+=1
      if B[x]>N:
        B[x]==N
  A=list(B)
  if B[0]==N and len(B)==1:
    break
B=[str(b) for b in B]
print(' '.join(B))

Submission status: Runtime Error

Solution code:
import numpy as np

def conv(A,N):
    #A(座標iの電灯の強さリスト)からB(座標iを照らしている電灯数)への変換
    B=np.array([0 for n in range(N)])
    for n in range(1,N+1):
        il_min=max(int(n-A[n-1]-0.5)+1,0)
        il_max=min(int(n+A[n-1]+0.5),N)
        fore=np.zeros(il_min-1,dtype=int)
        back=np.zeros(N-il_max,dtype=int)
        cent=np.ones(il_max-il_min+1,dtype=int)
        C=np.hstack((fore,cent,back))
        B+=C
    return B

def main():
    #input
    N,K=map(int,input().strip().split())
    A=np.array(list(map(int,input().strip().split())),dtype=int)

    for k in range(K):
        B=conv(A,N)
        if np.allclose(A, B):
            break
        else:
            A=B
    return " ".join(list(map(str,A)))

if __name__=="__main__":
    print(main())