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

    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    
    for cnt in range(min(k, 41)):
        ans = []
        bit = [0]*(n+1)
        for i, j in enumerate(a):
            x, y = max(i-j, 0)+1, min(i+j+1, n)+1
            while x < n+1:
                bit[x] += 1
                x += x & (-x)
            while y < n+1:
                bit[y] -= 1
                y += y & (-y)
        for i in range(n):
            ret, x = 0, i+1
            while x > 0:
                ret += bit[x]
                x -= x & (-x)
            ans.append(ret)
        a = ans

    print(*ans)


main()


Fixed submission:
def main():
    from sys import stdin
    input = stdin.readline

    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    
    for cnt in range(min(k, 41)):
        ans = []
        bit = [0]*(n+1)
        for i, j in enumerate(a):
            x, y = max(i-j, 0)+1, min(i+j+1, n)+1
            while x < n+1:
                bit[x] += 1
                x += x & (-x)
            while y < n+1:
                bit[y] -= 1
                y += y & (-y)
        for i in range(n):
            ret, x = 0, i+1
            while x > 0:
                ret += bit[x]
                x -= x & (-x)
            ans.append(ret)
        a = ans

    print(*ans)


main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    from sys import stdin
    input = stdin.readline
    # 区間更新・一点取得の加法BIT

    class BIT():
        def __init__(self, n):
            self.n = n
            self.maxbit = 2**(len(bin(n))-3)
            self.bit = [0]*(n+1)

        # 初期化する
        def make_bit(self, a):
            n, bit = self.n, self.bit
            for i, j in enumerate(a):
                x, y = i+1, i+2
                while x < n+1:
                    bit[x] += j
                    x += x & (-x)
                while y < n+1:
                    bit[y] -= j
                    y += y & (-y)

        # 区間[i:j]に値vを足す
        def add(self, i, j, v):
            x, y, n, bit = i+1, j+1, self.n, self.bit
            while x < n+1:
                bit[x] += v
                x += x & (-x)
            while y < n+1:
                bit[y] -= v
                y += y & (-y)

        # 位置iの値を出力する
        def output(self, i):
            ret, x, bit = 0, i+1, self.bit
            while x > 0:
                ret += bit[x]
                x -= x & (-x)
            return ret

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

    for cnt in range(min(k, 42)):
        ans = []
        bit = BIT(n)
        for i in range(n-1, -1, -1):
            bit.add(max(i-a[i], 0), min(i+a[i]+1, n), 1)
        for i in range(n):
            ans.append(bit.output(i))
        a = ans

    print(*ans)


main()

Fixed submission:
def main():
    from sys import stdin
    input = stdin.readline

    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    
    for cnt in range(min(k, 41)):
        ans = []
        bit = [0]*(n+1)
        for i, j in enumerate(a):
            x, y = max(i-j, 0)+1, min(i+j+1, n)+1
            while x < n+1:
                bit[x] += 1
                x += x & (-x)
            while y < n+1:
                bit[y] -= 1
                y += y & (-y)
        for i in range(n):
            ret, x = 0, i+1
            while x > 0:
                ret += bit[x]
                x -= x & (-x)
            ans.append(ret)
        a = ans

    print(*ans)


main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    # 区間更新・一点取得の加法BIT
    class BIT():
        def __init__(self, n):
            self.n = n
            self.maxbit = 2**(len(bin(n))-3)
            self.bit = [0]*(n+1)

        # 初期化する
        def make_bit(self, a):
            n, bit = self.n, self.bit
            for i, j in enumerate(a):
                x, y = i+1, i+2
                while x < n+1:
                    bit[x] += j
                    x += x & (-x)
                while y < n+1:
                    bit[y] -= j
                    y += y & (-y)

        # 区間[i:j]に値vを足す
        def add(self, i, j, v):
            x, y, n, bit = i+1, j+1, self.n, self.bit
            while x < n+1:
                bit[x] += v
                x += x & (-x)
            while y < n+1:
                bit[y] -= v
                y += y & (-y)

        # 位置iの値を出力する
        def output(self, i):
            ret, x, bit = 0, i+1, self.bit
            while x > 0:
                ret += bit[x]
                x -= x & (-x)
            return ret

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

    for cnt in range(min(k, 50)):
        ans = []
        bit = BIT(n)
        for i in range(n-1, -1, -1):
            bit.add(max(i-a[i], 0), min(i+a[i]+1, n), 1)
        for i in range(n):
            ans.append(bit.output(i))
        a = ans

    print(*ans)


main()


Fixed submission:
def main():
    from sys import stdin
    input = stdin.readline

    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    
    for cnt in range(min(k, 41)):
        ans = []
        bit = [0]*(n+1)
        for i, j in enumerate(a):
            x, y = max(i-j, 0)+1, min(i+j+1, n)+1
            while x < n+1:
                bit[x] += 1
                x += x & (-x)
            while y < n+1:
                bit[y] -= 1
                y += y & (-y)
        for i in range(n):
            ret, x = 0, i+1
            while x > 0:
                ret += bit[x]
                x -= x & (-x)
            ans.append(ret)
        a = ans

    print(*ans)


main()