Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N, K = list(map(int, input().split(' ')))
    A = list(map(int, input().split(' ')))
    if K >= 42:
        print(' '.join([str(N) for _ in range(N)]))
        return
    for _ in range(K):
        cumsum = [0 for _ in range(N)]
        for i, a in enumerate(A):
            left = max(0, i - a)
            cumsum[left] += 1
            right = i + 1 + a
            if right <= N - 1:
                cumsum[right] -= 1
        for i in range(1, N):
            cumsum[i] += cumsum[i - 1]
        A = cumsum
    print(' '.join(map(str, A)))
 
 
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N, K = list(map(int, input().split(' ')))
    A = list(map(int, input().split(' ')))
    if K >= 42:
        print(' '.join([str(N) for _ in range(N)]))
        return
    for _ in range(K):
        cumsum = [0 for _ in range(N)]
        for i, a in enumerate(A):
            left = max(0, i - a)
            cumsum[left] += 1
            right = i + 1 + a
            if right <= N - 1:
                cumsum[right] -= 1
        for i in range(1, N):
            cumsum[i] += cumsum[i - 1]
        A = cumsum
    print(' '.join(map(str, A)))
 
 
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N, K = list(map(int, input().split(' ')))
    A = list(map(int, input().split(' ')))
    if K >= N:
        print(' '.join([str(N) for _ in range(N)]))
        return
    for _ in range(K):
        imos = [0 for _ in range(N)]
        for i, a in enumerate(A):
            left = max(0, i - a)
            imos[left] += 1
            right = i + 1 + a
            if right <= N - 1:
                imos[right] -= 1
        for i in range(1, N):
            imos[i] += imos[i - 1]
        A = imos
    print(' '.join(map(str, A)))


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N, K = list(map(int, input().split(' ')))
    A = list(map(int, input().split(' ')))
    if K >= 42:
        print(' '.join([str(N) for _ in range(N)]))
        return
    for _ in range(K):
        cumsum = [0 for _ in range(N)]
        for i, a in enumerate(A):
            left = max(0, i - a)
            cumsum[left] += 1
            right = i + 1 + a
            if right <= N - 1:
                cumsum[right] -= 1
        for i in range(1, N):
            cumsum[i] += cumsum[i - 1]
        A = cumsum
    print(' '.join(map(str, A)))
 
 
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N, K = list(map(int, input().split(' ')))
    A = list(map(int, input().split(' ')))
    if K >= N:
        print(' '.join([str(N) for _ in range(N)]))
        return
    for _ in range(K):
        imos = [0 for _ in range(N)]
        for i, a in enumerate(A):
            left = max(0, i - a)
            imos[left] += 1
            right = i + 1 + a
            if right <= N - 1:
                imos[right] -= 1
        for i in range(1, N):
            imos[i] += imos[i - 1]
        A = imos
    print(' '.join(map(str, A)))


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N, K = list(map(int, input().split(' ')))
    A = list(map(int, input().split(' ')))
    if K >= 42:
        print(' '.join([str(N) for _ in range(N)]))
        return
    for _ in range(K):
        cumsum = [0 for _ in range(N)]
        for i, a in enumerate(A):
            left = max(0, i - a)
            cumsum[left] += 1
            right = i + 1 + a
            if right <= N - 1:
                cumsum[right] -= 1
        for i in range(1, N):
            cumsum[i] += cumsum[i - 1]
        A = cumsum
    print(' '.join(map(str, A)))
 
 
if __name__ == '__main__':
    main()