Buggy python submission (verdict: Time Limit Exceeded):
from copy import copy
import sys
input = sys.stdin.readline

def main():
    n,k = map(int,input().split())
    a = list(map(int,input().split()))

    for i in range(k):
        imos = [0] * (n+1)
        for i in range(n):
            imos[max(0, i-a[i])] += 1
            imos[min(n, i+a[i]+1)] -= 1
        for i in range(n):
            imos[i+1] += imos[i]
        for i in range(n):
            a = copy(imos)
        if all((a[i]==n for i in range(n))):
            break

    for i in a[:-1]:
        print(i, end = ' ')

if __name__ == '__main__':
    main()


Fixed submission:
from copy import copy
import sys
input = sys.stdin.readline

def main():
    n,k = map(int,input().split())
    a = list(map(int,input().split()))

    for i in range(k):
        imos = [0] * (n+1)
        for i in range(n):
            imos[max(0, i-a[i])] += 1
            imos[min(n, i+a[i]+1)] -= 1
        for i in range(n):
            imos[i+1] += imos[i]
        a = copy(imos[:-1])
        if all((a[i]==n for i in range(n))):
            break

    for i in a:
        print(i, end = ' ')

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

def main():
    n,k = map(int,input().split())
    a = list(map(int,input().split()))

    class Bit:
        def __init__(self, n):
            self.size = n
            self.tree = [0]*(n+1)
            self.depth = n.bit_length()

        def __iter__(self):
            psum = 0
            for i in range(self.size):
                csum = self.sum(i+1)
                yield csum - psum
                psum = csum
            raise StopIteration()

        def __str__(self):  # O(nlogn)
            return str(list(self))

        def sum(self, i):
            # [0, i) の要素の総和を返す
            if not (0 <= i <= self.size): raise ValueError("error!")
            s = 0
            while i>0:
                s += self.tree[i]
                i -= i & -i
            return s

        def add(self, i, x):
            if not (0 <= i < self.size): raise ValueError("error!")
            i += 1
            while i <= self.size:
                self.tree[i] += x
                i += i & -i

        def lower_bound(self, x):
            """ 累積和がx以上になる最小のindexと、その直前までの累積和 """
            sum_ = 0
            pos = 0
            for i in range(self.depth, -1, -1):
                k = pos + (1 << i)
                if k <= self.size and sum_ + self.tree[k] < x:
                    sum_ += self.tree[k]
                    pos += 1 << i
            return pos + 1, sum_

        def __getitem__(self, key):
            if not (0 <= key < self.size): raise IndexError("error!")
            return self.sum(key+1) - self.sum(key)

        def __setitem__(self, key, value):
            # 足し算と引き算にはaddを使うべき
            if not (0 <= key < self.size): raise IndexError("error!")
            self.add(key, value - self[key])

    class BitImos:
        """
        ・範囲すべての要素に加算
        ・ひとつの値を取得
        の2種類のクエリをO(logn)で処理
        bit = BitImos(len(li))
        """
        def __init__(self, n):
            self.bit = Bit(n+1)

        def add(self, s, t, x):
            # [s, t)にxを加算
            self.bit.add(s, x)
            self.bit.add(t, -x)

        def get(self, i):
            return self[i]

        def __getitem__(self, key):
            # 位置iの値を取得
            return self.bit.sum(key+1)

    for i in range(k):
        bit = BitImos(n)
        for i in range(n):
            bit.add(max(0, i-a[i]), min(n, i+a[i]+1), 1)
        for i in range(n):
            a[i] = min(n, bit.get(i))
        if all((a[i]==n for i in range(n))):
            break

    for i in a:
        print(i, end = ' ')

if __name__ == '__main__':
    main()


Fixed submission:
from copy import copy
import sys
input = sys.stdin.readline

def main():
    n,k = map(int,input().split())
    a = list(map(int,input().split()))

    for i in range(k):
        imos = [0] * (n+1)
        for i in range(n):
            imos[max(0, i-a[i])] += 1
            imos[min(n, i+a[i]+1)] -= 1
        for i in range(n):
            imos[i+1] += imos[i]
        a = copy(imos[:-1])
        if all((a[i]==n for i in range(n))):
            break

    for i in a:
        print(i, end = ' ')

if __name__ == '__main__':
    main()