Problem p02647 (python)

Fixed submission:
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, A: "List[int]"):

    for k in range(K):
        B = [0] * N

        for i in range(N):
            l = max(0, i - A[i])
            r = i + A[i]

            B[l] += 1
            if r + 1 < N:
                B[r + 1] -= 1

        for i in range(1, N):
            B[i] += B[i - 1]

        A = B.copy()
        if sum(A) == N*N:
            break
    print(*A)

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, A)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
import numpy as np

def solve(N: int, K: int, A: "List[int]"):
    M = np.zeros((N,N))
    a, b = np.indices((N,N))
    rc_mat = np.abs(a-b)

    A = np.array(A)
    for k in range(K):
        B = np.sum(rc_mat - A <= 0, axis=1)
        A = B
    print(*A)

    # for k in range(K):
    #     B = [0] * N
    #     for i in range(N):
    #         d = A[i]
    #         if d == 0:
    #             B[i] += 1
    #             continue

    #         for j in range(max(0, i-d), min(i+d+1, N)):
    #             B[j] += 1

    #     print(*A, '||', *[a-1 for a in B])
    #     # A = [a-1 for a in B]
    #     A = B.copy()

        
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, A)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
import numpy as np

def solve(N: int, K: int, A: "List[int]"):
    M = np.zeros((N,N))
    a, b = np.indices((N,N))
    rc_mat = np.abs(a-b)

    A = np.array(A)
    for k in range(K):
        B = np.sum(rc_mat - A <= 0, axis=1)
        A = B
    print(*A)

    # for k in range(K):
    #     B = [0] * N
    #     for i in range(N):
    #         d = A[i]
    #         if d == 0:
    #             B[i] += 1
    #             continue

    #         for j in range(max(0, i-d), min(i+d+1, N)):
    #             B[j] += 1

    #     print(*A, '||', *[a-1 for a in B])
    #     # A = [a-1 for a in B]
    #     A = B.copy()

        
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, A)

if __name__ == '__main__':
    main()