Scanf.scanf "%d %d" (fun n k ->
    let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in

    let next_step arr =
        let b = Array.make (n + 1) 0 in
        Array.iteri (fun i v ->
            let mi = max 0 (i - v) in
            let mx = min n (v + i + 1) in
            b.(mi) <- b.(mi) + 1;
            b.(mx) <- b.(mx) - 1;
        ) arr;
        let c = Array.make n b.(0) in
        for i = 1 to n - 1 do
            c.(i) <- c.(i - 1) + b.(i)
        done;
        c
    in
    let rec loop i arr =
        if i = k then arr else
            let arr2 = next_step arr in
            if arr2 = arr then arr else loop (i + 1) arr2
    in
    loop 0 a |> Array.iter (Printf.printf "%d ");
    print_newline ()
)