jiahuimbzuai/CoQuIR huggingface dataset:
//  [c]
#include <stdio.h>
int main(void)
{
    int N;
    scanf("%d", &N);

    int numbers[N];
    for(int i=0; i<N; i++){
        scanf("%d", &numbers[i]);
    }

    // 入力した値の最小公倍数を求めるプログラムを作成
    int count = 1;
    int amari[N];
    int sum_amari;
    int saisyou_koubaisuu;
    while(1){
        sum_amari = 0;
        for(int i=0; i<N; i++){
            //amari[i] = count%numbers[i];
            //sum_amari += amari[i];
            sum_amari += count%numbers[i]
        }
        if(sum_amari == 0){
            saisyou_koubaisuu = count;
            break;
        }
        count++;
    }
    // printf("saisyou_koubaisuu = %d\n", saisyou_koubaisuu);

    int f;
    int ans = -1;
    for(int i=0; i<saisyou_koubaisuu; i++){
        f = 0;
        for(int j=0; j<N; j++){
            f += i%numbers[j];
        }
        if(ans < f){
            ans = f;
        }
        // printf("%d %d\n", i, f);
    }

    printf("%d\n", ans);

    return 0;
}
//  [javascript]
function main(input) {
  const a1 = parseInt(input.split(" ")[0], 10);
  const a2 = parseInt(input.split(" ")[1], 10);
  const a3 = parseInt(input.split(" ")[2], 10);
  var arr=[a1,a2,a3]
  var max=Math.max.apply(null,arr );
  var min=Math.min.apply(null, arr);
  console.log(max-min);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
"use strict"

function main(input) {
    let nums = input.split(' ')
    nums = nums.map(x => +x)
    nums.sort()//.reverse()
    let num = 0;
    for (let i=0; i<nums.length;i++) {
        let red = (i >= 1) ? nums[i - 1] : 0
        num += Math.abs(nums[i] - red)
    }
    num -= nums[0]
    console.log(num)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
var input=require("fs").readFileSync(0,"utf8");
var a=input.match(/\d+/g).map(Number);
var x=Math.abs(a[0]-a[1]),
	y=Math.abs(a[1]-a[2]),
	z=Math.abs(a[2]-a[0]);
var ans=x+y+z-Math.max(x,y,z);
console.log(ans);
//  [javascript]
const main = (arg) => {
  const lines = arg.trim().split('\n');
  const A = lines[0].split(' ').map((x) => Number.parseInt(x));
  A.sort((a, b) => b - a);
  console.log(A[2] - A[0]);
};
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
const main = (arg) => {
  const lines = arg.trim().split('\n');
  console.log(lines[0]);
  const A = lines[0].split(' ').map((x) => Number.parseInt(x));
  A.sort((a, b) => b - a);
  console.log(A[2] - A[0]);
};
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = [];
var reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});
reader.on('line', (line) => {
    lines.push(line);
});
reader.on('close', () => {
    const arr = lines[0].split(' ');
    const max = Math.max(...arr);
    const min = Math.min(...arr);
    
    let result = Math.abs(max - min);
    console.log(result);
});
//  [go]
package main

import (
    . "fmt"
    "sort"
)

func main() {
    var a1, a2, a3 int
    Scanf("%d %d %d", &a1, &a2, &a3)

    var arr []int = []int{a1, a2, a3}

    sort.Sort(sort.IntSlice(arr))

    sum := 0
    for i := 1; i < 3; i++ {
        sum += arr[i] - arr[i - 1]
    }

    Println(sum)
}
//  [go]
package main

import (
  "fmt"
  "sort"
)

func main() {
  a := make([]int, 3)
  for i := 0; i < 3; i++ {
    fmt.Scan(&a[i])
  }
  sort.Ints(a)
  fmt.Println(a[2] - a[0])
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	arr := strings.Split(sc.Text(), " ")
	nums := make([]int, 3)
	for i := range arr {
		nums[i], _ = strconv.Atoi(arr[i])
	}
	sort.Ints(nums)
	fmt.Println(nums[len(nums)-1] - nums[0])
}
//  [go]
package main

import (
	"fmt"
	"sort"
)

func abs(a int) int {
	if a > 0 {
		return a
	}
	return a
}

func main() {
	var a [3]int
	fmt.Scan(&a[0], &a[1], &a[2])
	b := a[:]
	sort.Ints(b)

	fmt.Println(abs(b[0]-b[1]) + abs(b[1]-b[2]))
}
//  [go]
package main

import (
	"fmt"
)

func abs(a int) int {
	if a > 0 {
		return a
	}
	return a
}

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	fmt.Println(abs(a-b) + abs(b-c))
}
//  [go]
package main

import (
	"fmt"
)

func abs(a int) int {
	if a > 0 {
		return a
	}
	return b
}

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	fmt.Println(abs(a-b) + abs(b-c))
}
//  [ruby]
a=gets.split.map(&:to_i).sort;p a[1] - a[0] + a[2] - a[1]
//  [ruby]
a = []
a[0], a[1], a[2] = gets.split.map(&:to_i)
a = a.sort

puts (a[1] - a[0]) + (a[2] - a[1])
//  [ruby]
a = gets.split.map(&:to_i)
a.sort!
sum = 0
sum += (a[1] - a[0]).abs
sum += (a[2] - a[1]).abs
puts sum
//  [ruby]
s=gets.chomp.chars
t=gets.chomp.chars
ans=0
for i in 0...s.size
  s << s[0]
  s.shift
  ans=1 if s==t
end
puts ans==0? "No":"Yes"
//  [ruby]
a, b, c = gets.chomp.split.map(&:to_i)

array = [a - b, b - c, c - a]

puts array.min.abs
//  [ruby]
# 3 個のタスクがあり、あなたは全てのタスクを完了させなければなりません。
# はじめ、任意の 1 個のタスクをコスト 0 で完了できます。
# また、i 番目のタスクを完了した直後にコスト |Aj−Ai| で j 番目のタスクを完了できます。
# ここで |x| は x の絶対値を表します。
# 全てのタスクを完了するのに要する合計コストの最小値を求めてください。

a = gets.chomp.split
a.length.times do |i|
    a[i] = a[i].to_i
end

costs = []
ai_permu_array = a.permutation(a.length).to_a

a.length.times do |i|
    ai_permu_array.each do |ai_permu|
        cost = 0
        next_cost = 0
        ai_permu.length.times do |k|
            if k == i
                cost += next_cost
                next_cost = ai_permu[k]
            else
                cost += (ai_permu[k] - next_cost).abs
                next_cost = ai_permu[k]
            end
        end
        costs << cost
    end
end

puts costs.min
//  [rust]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let  s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: [i32; 3]
    }
    let mut b = vec![
        (a[0] - a[1]).abs(),
        (a[1] - a[2]).abs(),
        (a[2] - a[0]).abs(),
    ];
    b.sort();
    println!("{}", b[0] + b[1]);
}
//  [rust]
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let mut v:Vec<i32> = procon_read();
	v.sort();
	println!("{}", (v[1] - v[0]) + (v[2] - v[1]));
}
//  [rust]
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

use std::ascii::AsciiExt;
use std::cmp;
use std::collections::VecDeque;
use std::io::Write;
use std::iter::Iterator;

fn main() {
    input! {
        n:usize,
        m:usize,
        bredge:[(usize, usize);m],
    }

    let mut bredge_mut = bredge; 
    bredge_mut.sort_by_key(|a| a.1);

    let mut ans = 1;
    let mut t = bredge_mut[0].1;
    for i in 0..m {
        if  t <= bredge_mut[i].0 {
            ans += 1;
            t = bredge_mut[i].1;
        }
    }

    println!("{}", ans);

}
//  [rust]
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let a: u16 = read(&mut stdin_lock, &mut buf, b' ');
    let b: u16 = read(&mut stdin_lock, &mut buf, b' ');
    let c: u16 = read(&mut stdin_lock, &mut buf, b'\n');
    let mut vs: Vec<u16> = vec![a, b, c];
    vs.sort_unstable();
    let ans = vs[2] - vs[0];
    println!("{}", ans);
}
//  [swift]
let i=readLine()!.characters.split(" ").map{Int(String($0))!}.sort();print(i[2]-i[0])
//  [swift]
import Foundation
var strA=readLine()!.componentsSeparatedByString(" ")
var A=[Int]()
for i in strA{
  A.append(Int(i)!)
}
let max=A.maxElement()
let min=A.minElement()
print(max!-min!)
//  [swift]
import Foundation

let arguments = ProcessInfo.processInfo.arguments
let inputs = arguments.compactMap(Int.init)

let output = inputs.sorted(>).reduce(0) { $0-$1 }
print(output)
//  [swift]
import Foundation
let S=readLine()!
let T=readLine()!
var a=0
for_i:for i 0..<S.characters.count{
  a=0
  if S[0]==T[i] {
    for_j:for j 1..<S.characters.count{
      if S[j]==T[(i+j)%5]{
        a=a+1
      }else {
        break for_j
      }
    }
  }
  if a==S.characters.count{
    print("Yes")
    break for_i
  }
}
if a!=S.characters.count{
  print("No")
}
//  [typescript]
declare var require: (x: string) => any;

function Main(input: string[]) {
  const ab = input[0].split(' ').map(x => +x);
  console.log(Math.max(...ab) - Math.min(...ab));
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8').split('\n'));
//  [typescript]
//declare var require: (x: string) => any;

function Main(input: string[]) {
  const ab = input[0].split(' ').map(x => +x);
  console.log(Math.max(...ab) - Math.min(...ab));
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8').split('\n'));
//  [typescript]
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const a = stdin
  .split('\n')[0]
  .split(' ')
  .map(Number)

a.sort((a, b) => b - a)

let cost = 0

cost = Math.abs(a[0] - a[1])

cost += Math.abs(a[1] - a[2])

console.log(cost)
//  [typescript]
"use strict"
let fs = require('fs');
let input = fs.readFileSync("/dev/stdin", "utf8").split(/\s/);
const inp = input.map(x => +x);
console.log(Math.max.apply(null, inp) - Math.min.apply(null, inp));
//  [typescript]
declare var require: (x: string) => any;

function Main(input: string[]) {
    const ab = input[0].split(' ').map(x => +x);
    console.log((Math.max(...ab) - Math.min(...ab)))
}

Main(require('fs').readFlieSync('dev/stdin', 'utf8').split("\n"));
//  [typescript]
declare var require: (x: string) => any;

function Main(input: string[]) {
  const ab: number[] = input[0].split(' ').map(x => +x);
  console.log(Math.max(ab) - Math.min(ab));
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8').split('\n'));
//  [python]
def solve(N,K,A):
    for i in range(K):
        arr = [0] * (N + 1)

        for ind,j in enumerate(A):
            arr[max(ind-j,0)] += 1
            arr[min(ind+j+1, N)] -= 1

        A[0] = arr[0]
        for k in range(N-1):
            A[k+1] = A[k] + arr[k+1]

        if arr[0] ==N and arr[-1] == -N:
            return A
    return A


if __name__ == "__main__":
    n,k = map(int, input().split())
    a = list(map(int, input().split()))
    ans = solve(n,k,a)
    print(*ans)
//  [python]
def solve():
    N,K = map(int, input().split())
    A = list(map(int, input().split()))

    for i in range(K):

        arr = [0] * (N + 1)

        for ind,j in enumerate(A):
            arr[max(ind-j,0)] += 1
            arr[min(ind+j+1, N)] -= 1

        A[0] = arr[0]
        for k in range(N-1):
            A[k+1] = A[k] + arr[k+1]

        if arr[0] ==N and arr[-1] == -N:
            return A
    return A


if __name__ == "__main__":
    ans = solve()
    print(*ans)
//  [python]
N, K = map(int, input().split())
A = list(map(int, input().split()))

for i in range(K):
  new = [0] * (N+1)
  for j in range(N):
    new[max(0, j-A[j])] += 1
    if j+A[j]+1 <= N-1:
      new[j+A[j]+1] -= 1
  A[0] = new[0]
  for j in range(1, N):
    new[j] += new[j-1]
    A[j] = new[j] 
  for ai in A:
    if ai != N:
      break
  else:
    break
    
print(' '.join([str(ai) for ai in A]))
//  [python]
import sys
import numpy as np
from numba import njit

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


@njit('i8[:](i8,i8,i8[:])', cache=True)
def func(n, k, A):
    for _ in range(k):
        B = np.zeros(n + 1, np.int64)
        for i, a in enumerate(A):
            B[max(0, i - a)] += 1
            B[min(i + a + 1, n)] -= 1
        A = B.cumsum()[:-1]
    return A


def main():
    N, K = map(int, readline().split())
    A = np.array(readline().split(), np.int64)
    ans = func(N, K, A)
    print(*ans)


if __name__ == '__main__':
    main()
//  [python]
import sys
import numpy as np

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N, K = map(int, readline().split())
    np.set_printoptions(precision=0)
    A = np.array(readline().split(), np.int64)
    for _ in range(K):
        B = np.zeros(N + 1)
        for i, a in enumerate(A):
            B[max(0, int(i - a))] += 1
            B[min(int(i + a + 1), N)] -= 1
        A = B.cumsum()[:-1]
    print(*A)


if __name__ == '__main__':
    main()
//  [python]
import sys
import numpy as np

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N, K = map(int, readline().split())
    np.set_printoptions(precision=0)
    A = np.array(readline().split(), np.int64)
    for _ in range(K):
        B = np.zeros(N + 1)
        for i, a in enumerate(A):
            B[max(0, int(i - a))] += 1
            B[min(int(i + a + 1), N)] -= 1
        B = B.cumsum()
        A = np.copy(B[:N])
    print(' '.join(map(str, list(map(int, A)))))


if __name__ == '__main__':
    main()
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {
	
	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner();
		PrintWriter out = new PrintWriter(System.out);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] vals = new int[N];
		for (int i = 0; i < N; i++) {
			vals[i] = sc.nextInt();
		}
		while (K > 0) {
			int[] tmp = make(vals);
			if (Arrays.equals(tmp, vals)) break;
			vals = tmp;
			K--;
		}
		for (int i = 0; i < N; i++) {
			out.print(vals[i] + " ");
		}
		out.println();

		out.flush();
	}

	static int[] make(int[] vals) {
		Point[] all = new Point[vals.length * 2];
		int idx = 0;
		for (int i = 0; i < vals.length; i++) {
			all[idx++] = new Point(i - vals[i], true);
			all[idx++] = new Point(i + vals[i], false);
		}
		Arrays.sort(all);
		int[] ret = new int[vals.length];
		idx = 0;
		int got = 0;
		for (int i = 0; i < ret.length; i++) {
			while (idx < all.length && (all[idx].val < i || all[idx].val == i && all[idx].open)) {
				if (all[idx].open) got++;
				else got--;
				idx++;
			}
			ret[i] = got;
		}
		return ret;
	}

	static class Point implements Comparable<Point> {
		int val;
		boolean open;

		public Point(int val, boolean open) {
			this.val = val;
			this.open = open;
		}

		@Override
		public int compareTo(Point o) {
			int cmp = Integer.compare(val, o.val);
			if (cmp != 0) return cmp;
			return Boolean.compare(o.open, open);
		}
	}
	
	static class MyScanner {
		private BufferedReader br;
		private StringTokenizer tokenizer;
		
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}
//  [java]
import java.util.*;
import java.io.*;
public class Main{
   public static void main(String[] main) throws Exception{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      StringTokenizer st = new StringTokenizer(br.readLine());
      PrintWriter out = new PrintWriter(System.out);
      int n = Integer.parseInt(st.nextToken());
      int k = Integer.parseInt(st.nextToken());
      st = new StringTokenizer(br.readLine());
      int[] a = new int[n];
      for(int i = 0; i < n; i++)
    	  a[i] = Integer.parseInt(st.nextToken());
      StringJoiner sj = new StringJoiner(" ");
      if(k > Math.log(n)/Math.log(2)+5) {
    	  for(int i = 0; i < n; i++)
    		  sj.add(Integer.toString(n));
      }
      else {
    	  for(int i = 0; i < k; i++) {
    		  int[] b = new int[n];
    		  for(int j = 0; j < n; j++) {
    			  b[Math.max(0,j - a[j])]++;
    			  if(j + a[j] < n-1)
    				  b[j + a[j]+1]--;
    		  }
    		  for(int j = 1; j < n; j++) {
    			  b[j] += b[j-1];
    		  }
    		  a = b;
    	  }
    	  for(int i = 0; i < n; i++)
    		  sj.add(Integer.toString(a[i]));
      }
      out.println(sj);
      out.close();
   }
}
//  [java]
import java.util.*;
import java.io.*;
public class Main{
   public static void main(String[] main) throws Exception{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      StringTokenizer st = new StringTokenizer(br.readLine());
      PrintWriter out = new PrintWriter(System.out);
      int n = Integer.parseInt(st.nextToken());
      int k = Integer.parseInt(st.nextToken());
      st = new StringTokenizer(br.readLine());
      int[] a = new int[n];
      for(int i = 0; i < n; i++)
    	  a[i] = Integer.parseInt(st.nextToken());
      StringJoiner sj = new StringJoiner(" ");
      if(k > Math.log(n)/Math.log(2)+1) {
    	  for(int i = 0; i < n; i++)
    		  sj.add(Integer.toString(n));
      }
      else {
    	  for(int i = 0; i < k; i++) {
    		  int[] b = new int[n];
    		  for(int j = 0; j < n; j++) {
    			  b[Math.max(0,j - a[j])]++;
    			  if(j + a[j] < n-1)
    				  b[j + a[j]+1]--;
    		  }
    		  for(int j = 1; j < n; j++) {
    			  b[j] += b[j-1];
    		  }
    		  a = b;
    	  }
    	  for(int i = 0; i < n; i++)
    		  sj.add(Integer.toString(a[i]));
      }
      out.println(sj);
      out.close();
   }
}
//  [cpp]
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

//const int cm = 1 << 17;
//char cn[cm], * ci = cn + cm, ct;
//inline char getcha() {
//	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
//	return *ci++;
//}
//inline int getint() {
//	int A = 0;
//	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
//	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
//	return A;
//}
const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}


const int dm = 1400000;
char dn[dm], * di = dn;
const int MAX = 20000;
class unko {
public:
	char C[MAX * 7 + 10], *K[MAX + 10];
	constexpr unko() : C(), K() {
		auto di = C + 3;
		C[0] = '0';
		C[0] = ' ';
		C[0] = '\n';
		K[0] = C;
		K[1] = di;
		rep1(i, MAX) {
			int X = i;
			int keta = 0;
			char c[10] = {};
			while (X) {
				*(c + keta) = '0' + X % 10;
				X /= 10;
				keta++;
			}
			for (int j = keta - 1; j >= 0; j--)* di++ = (*(c + j));
			*di++ = ' ';
			*di++ = '\n';
			K[i + 1] = di;
		}
	}
};
constexpr unko f;
inline void putint(int X) {
	if (X > 20000) {
		int ue = X / 10;
		for (auto i = f.K[ue]; *i != ' '; i++) *di++ = *i;
		*di++ = '0' + X % 10;
		*di++ = ' ';
	}
	else for (auto i = f.K[X]; *i != '\n'; i++)* di++ = *i;
}

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint(), K = getint();

	int A[200001];
	rep(i, N) A[i] = getint();
	ll owa = ll(N) * N;

	rep(p, K) {
		int B[200001] = {};
		rep(i, N) {
			B[max(0, i - A[i])]++;
			B[min(N, i + A[i] + 1)]--;
		}
		ll kei = B[0];
		A[0] = B[0];
		rep1(i, N - 1) {
			kei += (A[i] = A[i - 1] + B[i]);
		}
		if (kei == owa) break;
	}

	rep(i, N) putint(A[i]);
	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}
//  [cpp]
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}


const int dm = 1400000;
char dn[dm], * di = dn;
const int MAX = 20000;
class unko {
public:
	char C[MAX * 7 + 10], *K[MAX + 10];
	constexpr unko() : C(), K() {
		auto di = C + 3;
		C[0] = '0';
		C[0] = ' ';
		C[0] = '\n';
		K[0] = C;
		K[1] = di;
		rep1(i, MAX) {
			int X = i;
			int keta = 0;
			char c[10] = {};
			while (X) {
				*(c + keta) = '0' + X % 10;
				X /= 10;
				keta++;
			}
			for (int j = keta - 1; j >= 0; j--)* di++ = (*(c + j));
			*di++ = ' ';
			*di++ = '\n';
			K[i + 1] = di;
		}
	}
};
constexpr unko f;
inline void putint(int X) {
	if (X > 20000) {
		int ue = X / 10;
		for (auto i = f.K[ue]; *i != ' '; i++) *di++ = *i;
		*di++ = '0' + X % 10;
		*di++ = ' ';
	}
	else for (auto i = f.K[X]; *i != '\n'; i++)* di++ = *i;
}

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint(), K = getint();

	int A[200001];
	rep(i, N) A[i] = getint();
	ll owa = ll(N) * N;

	rep(p, K) {
		int B[200001] = {};
		rep(i, N) {
			B[max(0, i - A[i])]++;
			B[min(N, i + A[i] + 1)]--;
		}
		ll kei = B[0];
		A[0] = B[0];
		rep1(i, N - 1) {
			kei += (A[i] = A[i - 1] + B[i]);
		}
		if (kei == owa) break;
	}

	rep(i, N) putint(A[i]);
	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}
//  [cpp]
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n, k;  cin >> n >> k;
    vector<int> a(n), v(n+1, 0);

    for (int i = 0; i < n; i++)
        cin >> a[i];
    
    for (int i = 0; i < k; i++) {
        for (int j = 0; j < n+1; j++)
            v[j] = 0;
        for (int j = 0; j < n; j++) {
            int l = max(0, j-a[j]), r = min(n, j+a[j]+1);
            v[l]++;
            v[r]--;
        }
        for (int j = 0; j < n; j++)
            v[j+1] += v[j];

        for (int j = 0; j < n; j++)
            a[j] = v[j];
    }

    for (int j = 0; j < n; j++)
        cout << a[j] << " ";
    cout << endl;
    return 0;
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N, K;
int A[50][200010];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> K;

    for(int i = 1; i <= N; i++){
        cin >> A[0][i];
    }

    K = min(K, 40);
    for(int i = 1; i <= K; i++){
        for(int j = 1; j <= N; j++){
            A[i][max(1, j - A[i - 1][j])]++;
            A[i][min(j + A[i - 1][j] + 1, N + 1)]--;
        }

        for(int j = 1; j <= N; j++){
            A[i][j + 1] += A[i][j];
        }
    }

    for(int i = 1; i <= N; i++){
        cout << A[K][i];
        if(i != N) cout << " ";
        else cout << endl;
    }
    return 0;
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N, K;
int A[30][200010];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> K;

    for(int i = 1; i <= N; i++){
        cin >> A[0][i];
    }

    K = min(K, 29);
    for(int i = 1; i <= K; i++){
        for(int j = 1; j <= N; j++){
            A[i][max(1, j - A[i - 1][j])]++;
            A[i][min(j + A[i - 1][j] + 1, N + 1)]--;
        }

        for(int j = 1; j <= N; j++){
            A[i][j + 1] += A[i][j];
        }
    }

    for(int i = 1; i <= N; i++){
        cout << A[K][i];
        if(i != N) cout << " ";
        else cout << endl;
    }
    return 0;
}
//  [c]
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define NMAX 200001

int a[NMAX], up[NMAX], bt[NMAX];
int imos[NMAX];

void reset(int n) {
    for(int i = 0; i < n; i++) imos[i] = 0;
}

int get_int() {
    int res = 0;
    char c = getchar();
    while(c != EOF && c != ' ' && c != '\n') {
        res *= 10;
        res += c - '0';
        c = getchar();
    }
    return res;
}

void put_int(int n) {
    char c[30];
    int sz = 0;
    c[sz++] = (n % 10) + '0';
    n /= 10;
    while(n > 0) {
        c[sz++] = (n % 10) + '0';
        n /= 10;
    }
    for(int i = sz-1; i >= 0; i--) {
        putchar(c[i]);
    }
    putchar('\n');
}

int max(int a, int b) { 
    if(a > b) return a;
    else return b;
}

int min(int a, int b) { 
    if(a < b) return a;
    else return b;
}

int main(){

    int n, k;
    n = get_int();
    k = get_int();
    for(int i = 0; i < n; i++) a[i] = get_int();

    for(int itr = 0; itr < k; itr++) {
        reset(n+1);
        for(int i = 0; i < n; i++) {
            bt[i] = max(0, i - a[i]);
            up[i] = min(n, i + a[i] + 1);
        }
        for(int i = 0; i < n; i++){
            imos[bt[i]]++;
            imos[up[i]]--;
        }
        int acc = 0;
        for(int i = 0; i < n; i++){
            acc += imos[i];
            a[i] = acc;
        }
        int sum = 0;
        for(int i = 0; i < n; i++) sum += a[i];
        if(sum == n * n) break;
    }

    for(int i = 0; i < n; i++) put_int(a[i]);
    return 0;
}
//  [c]
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")

#include <stdio.h>
#include <stdlib.h>

#define NMAX 200001

int a[NMAX];
int imos[NMAX];

void reset(int n) {
    for(int i = 0; i < n; i++) imos[i] = 0;
}

int max(int a, int b) {
    if(a > b) return a;
    else return b;
}

int min(int a, int b) {
    if(a > b) return b;
    else return a;
}

int get_int() {
    int res = 0;
    char c = getchar();
    while(c != EOF && c != ' ' && c != '\n') {
        res *= 10;
        res += c - '0';
        c = getchar();
    }
    return res;
}

void put_int(int n) {
    char c[30];
    int sz = 0;
    c[sz++] = (n % 10) + '0';
    n /= 10;
    while(n > 0) {
        c[sz++] = (n % 10) + '0';
        n /= 10;
    }
    for(int i = sz-1; i >= 0; i--) {
        putchar(c[i]);
    }
    putchar('\n');
}

int main(){

    int n, k;
    n = get_int();
    k = get_int();
    for(int i = 0; i < n; i++) a[i] = get_int();

    for(int itr = 0; itr < k; itr++) {
        reset(n+1);
        for(int i = 0; i < n; i++){
            imos[max(0, i - a[i])]++;
            imos[min(n, i + a[i] + 1)]--;
        }
        int acc = 0;
        for(int i = 0; i < n; i++){
            acc += imos[i];
            a[i] = acc;
        }
        int sum = 0;
        for(int i = 0; i < n; i++) sum += a[i];
        if(sum == n * n) break;
    }

    for(int i = 0; i < n; i++) put_int(a[i]);
    return 0;
}
//  [c]
#include <iostream>

using namespace std;

int main(){
	int N, Q;

	cin >> N >> Q;

	int field[N+1];
	int ans[N];

	for(int i = 0; i < N+1; i++){
		field[i] = 0;
	}

	int l, r;
	for(int i = 0; i < Q; i++){
		cin >> l >> r;
		field[l-1]++;
		field[r]--;
	}

	for(int i = 0; i < N; i++){
		if(i == 0){
			ans[i] = field[i];
		} else {
			ans[i] = field[i] + ans[i-1];
		}
		cout << ans[i] % 2;
	}
	cout << "\n";
}
//  [c]
#include <stdio.h>

#define max(a, b) ((int)(a) > (int)(b) ? (a) : (b))
#define min(a, b) ((int)(a) > (int)(b) ? (b) : (a))

int main(void)
{
    int N, K;
    scanf("%d %d", &N, &K);

    int A[N + 1], lamp[N + 1];
    for(int i = 0; i < N; i++)
    {
        scanf("%d", &A[i]);
    }
    A[N] = 0;

    for(int i = 0; i < min(K, 40); i++)
    {
        for(int j = 0; j < N + 1; j++) { lamp[j] = 0; }
        for(int j = 0; j < N; j++)
        {
            lamp[max(0, j - A[j])] += 1;
            lamp[min(N, j + A[j] + 1)] -= 1;
        }

        for(int j = 1; j < N + 1; j++) { lamp[j] += lamp[j - 1]; }
        for(int j = 0; j < N + 1; j++) { A[j] = lamp[j]; }
    }

    for(int i = 0; i < N; i++)
    {
        printf("%d ", A[i]);
    }
    printf("\n");
}
//  [c]
#include <stdio.h>

#define max(a, b) ((int)(a) > (int)(b) ? (a) : (b))
#define min(a, b) ((int)(a) > (int)(b) ? (b) : (a))

int main(void)
{
    int N, K;
    scanf("%d %d", &N, &K);

    int A[N + 1], lamp[N + 1];
    for(int i = 0; i < N; i++)
    {
        scanf("%d", &A[i]);
    }

    for(int i = 0; i < min(K, 40); i++)
    {
        for(int j = 0; j < N + 1; j++) { lamp[j] = 0; }
        for(int j = 0; j < N; j++)
        {
            lamp[max(0, j - A[j])] += 1;
            lamp[min(N, j + A[j] + 1)] -= 1;
        }

        for(int j = 1; j < N + 1; j++) { lamp[j] += lamp[j - 1]; }
        for(int j = 0; j < N + 1; j++) { A[j] = lamp[j]; }
    }

    for(int i = 0; i < N; i++)
    {
        printf("%d ", A[i]);
    }
    printf("\n");
}
//  [javascript]
console.log(function(args){
  const [[N,K],A] = args.trim().split('\n').map( r=>r.split(' ').map(v=>v|0) );
  for ( let i = 0; i < K; i++ ) {
    const m = Array(N+1).fill(0);
    for ( let j = 0; j < N; j++ ) {
      m[Math.max( 0, j - A[j] )]++;
      m[Math.min( N, j + A[j] + 1)]--;
    }
    let s = 0, nx = 0;
    for ( let j = 0; j < N; j++ ) {
      A[j] = s += m[j];
      if ( A[j] === N ) nx++;
    }
    if ( nx === N ) break;
  }
  return A.join(' ');
}(require('fs').readFileSync('/dev/stdin', 'utf8')));
//  [javascript]
"use strict";

const main = arg => {
    const input = arg.trim().split("\n");
    const [N, K] = input[0].split(" ").map(el => parseInt(el));
    let As = input[1].split(" ").map(el => parseInt(el))

    for(let ki=0; ki<K; ki++){
        let imos = new Array(N+1).fill(0)
        for(let i = 0; i<N;i++){
            let l = Math.max(0, i - As[i])
            let r = Math.min(i+As[i]+1, N)
            imos[l]++
            imos[r]--
        }
        for(let i = 0; i<N; i++){
            imos[i+1] += imos[i]
        }
        let isDone = true
        for(let i = 0; i<N; i++){
            if(imos[i] !== N){
                isDone = false
                break
            }
        }
        imos.pop()
        As = imos
        if(isDone) break
    }
    console.log(As.join(" "))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
const input = require("fs").readFileSync("/dev/stdin", "utf8")
let cin = input.split(/ |\n/), cid = 0
const next = () => cin[cid++]
const nexts = (n) => cin.slice(cid, cid+=n).map(j=>parseInt(j))

function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

const [N, K] = nexts(2)
let A = nexts(N)

for (let j = 0; j < K; j++) {
    let Ans = Array(N+1).fill(0)
    for (let i = 0; i < N; i++) {
        Ans[Math.max(0, i-A[i])]++
        Ans[Math.min(N, A[i]+i+1)]--
    }
    if (Ans[0] === N && Ans[N] === -N) return console.log(Array(N).fill(N).join(' '))
    for (let i = 1; i < N; i++) {
        Ans[i] += Ans[i-1]
    }
    A = Ans;
}
console.log(A.slice(0, N).join(' '))
//  [javascript]
"use strict";

const main = arg => {
    const inputList = arg.trim().split("\n");
    const N = parseInt(inputList[0].split(" ")[0]);
    const K = parseInt(inputList[0].split(" ")[1]);
    let ALightList = inputList[1].split(" ").map(ele => parseInt(ele));

    for (let i = 0; i < K; i++) {
        const changeSumList = Array(ALightList.length).fill(0);
        for (let j = 0; j < ALightList.length; j++) {
            const minus = (j - ALightList[j]) < 0 ? 0 : j - ALightList[j];
            const plus = j + ALightList[j] > N ? N : j + ALightList[j];
            for (let k = minus; k <= plus; k++) {
                if (changeSumList[k] < N) {
                    changeSumList[k]++;
                }
            }
        }
        if (ALightList.every((ele, idx) => ele == changeSumList[idx])) {
            break;
        }

        ALightList = changeSumList;
    }
    console.log(ALightList.join(" "))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
"use strict";

const main = arg => {
    const input = arg.trim().split("\n");
    const [N, K] = input[0].split(" ").map(el => parseInt(el));
    let As = input[1].split(" ").map(el => parseInt(el))

    for(let ki=0; ki<K; ki++){
        let imos = new Array(N+1).fill(0)
        for(let i = 0; i<N;i++){
            let l = Math.max(0, i - As[i])
            let r = Math.min(i+As[i]+1, N)
            imos[l]++
            imos[r]--
        }
        for(let i = 0; i<N; i++){
            imos[i+1] += imos[i]
        }
        let isDone = true
        for(i = 0; i<N; i++){
            if(imos[i] !== N){
                isDone = false
                break
            }
        }
        imos.pop()
        As = imos
        if(isDone) break
    }
    console.log(As.join(" "))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	k := getNextInt(scanner)
	aa := make([]int, n)
	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner)
	}
	var sum int64
	for i := 0; i < k; i++ {
		aa, sum = update(n, aa)
		if sum == int64(n)*int64(n) {
			break
		}
	}
	for i := 0; i < n; i++ {
		fmt.Fprintln(writer, aa[i])
	}
}

func update(n int, aa []int) ([]int, int64) {
	bb := make([]int, n+1)
	for i := 0; i < n; i++ {
		l := i - aa[i]
		if l < 0 {
			l = 0
		}
		r := i + aa[i] + 1
		if r >= n {
			r = n
		}
		bb[l]++
		bb[r]--
	}
	sum := int64(bb[0])
	for i := 1; i < n; i++ {
		bb[i] += bb[i-1]
		sum += int64(bb[i])
	}
	return bb, sum
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func f(N int, a []int) ([]int, bool) {
	b := make([]int, N+1)
	x := N
	flg := false
	for i := 0; i < N; i++ {
		if a[i] != x {
			flg = true
		}
		f := max(0, i-a[i])
		t := min(N, i+a[i]+1)
		b[f]++
		b[t]--
	}
	for i := 1; i <= N; i++ {
		b[i] += b[i-1]
	}
	return b, flg
}

func main() {
	sc.Split(bufio.ScanWords)
	N, K := getInt(), getInt()
	a := make([]int, N+1)
	for i := 0; i < N; i++ {
		a[i] = getInt()
	}
	flg := true
	for i := 0; i < K; i++ {
		a, flg = f(N, a)
		if flg == false {
			// out(i)
			break
		}
	}
	ans := a
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()
	for i := 0; i < N; i++ {
		fmt.Fprint(w, ans[i], " ")
	}
	fmt.Fprintln(w)
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var (
	scanner = bufio.NewScanner(os.Stdin)
	w       = bufio.NewWriter(os.Stdout)
)

func readInt() (read int) {
	scanner.Scan()
	read, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func arrayEqual(A []int, B []int, N int) bool {
	for i := 0; i < N; i++ {
		if A[i] != B[i] {
			return false
		}
	}
	return true
}

func main() {
	buf := make([]byte, 1024*1024)
	scanner.Buffer(buf, bufio.MaxScanTokenSize)
	scanner.Split(bufio.ScanWords)
	defer w.Flush()

	n := readInt()
	k := readInt()

	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = readInt()
	}

	for i := 0; i < k; i++ {
		b := make([]int, n+1)
		for j := 0; j < n; j++ {
			l := max(j-a[j], 0)
			r := min(j+a[j]+1, n)
			b[l]++
			b[r]--
		}
		for j := 0; j < n; j++ {
			b[j+1] += b[j]
		}
		if arrayEqual(a, b, n) {
			break
		}
		a = b[:len(b)-1]
	}

	for i := 0; i < n; i++ {
		fmt.Fprintf(w, "%d ", a[i])
	}
}
//  [go]
package main
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)

func Solve() {
  var N, K int
  var A []int
  NextInt(&N, &K)
  NextIntVec(&A)
  B := make([][]int, 2)
  for i := range B { B[i] = make([]int, N + 1) }
  for i, a := range A { B[0][i] = a }
  for k := 0; k < K; k++ {
    i := k % 2
    for j := range B[1 - i] { B[1 - i][j] = 0 }
    for j, b := range B[i][:N] {
      B[1 - i][MaxInt(j - b, 0)]++
      B[1 - i][MinInt(j + b + 1, N)]--
    }
    for j := range B[1 - i][:N] {
      B[1 - i][j + 1] += b
    }
    if SumInt(B[i]...) == N * N { break }
  }
  WriteIntVec(B[K % 2][:N])
}

func main() {
  Solve()
  Output()
}

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntVec(A *[]int) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatVec(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(S ...interface{}) {
  fmt.Fprintln(writer, S...)
}
func WriteIntVec(A []int) {
  B := make([]interface{}, len(A))
  for i, a := range A { B[i] = a }
  Write(B...)
}
func Output() {
  _ = writer.Flush()
}
func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}
func AbsInt(x int) int {
  if x < 0 { x = -x }
  return x
}
//  [go]
package main
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)

func Solve() {
  var N, K int
  var A []int
  NextInt(&N, &K)
  NextIntVec(&A)
  B := make([][]int, 2)
  for i := range B { B[i] = make([]int, N + 1) }
  for i, a := range A { B[0][i] = a }
  for k := 0; k < K; k++ {
    i := k % 2
    for j := range B[1 - i] { B[1 - i][j] = 0 }
    for j, b := range B[i][:N] {
      B[1 - i][MaxInt(j - b, 0)]++
      B[1 - i][MinInt(j + b + 1, N)]--
    }
    for j, b := range B[1 - i][:N] {
      B[1 - i][j + 1] += b
    }
    if SumInt(B[1 - i]...) == N * N { break }
  }
  WriteIntVec(B[K % 2][:N])
}

func main() {
  Solve()
  Output()
}

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntVec(A *[]int) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatVec(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(S ...interface{}) {
  fmt.Fprintln(writer, S...)
}
func WriteIntVec(A []int) {
  B := make([]interface{}, len(A))
  for i, a := range A { B[i] = a }
  Write(B...)
}
func Output() {
  _ = writer.Flush()
}
func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}
func AbsInt(x int) int {
  if x < 0 { x = -x }
  return x
}
//  [ruby]
class Array
  def cumsum!(s = 0); map!{|t| s += t } end
end

n, k = gets.to_s.split.map{|t| t.to_i }
a    = gets.to_s.split.map{|t| t.to_i }

if k >= 41
  puts [n] * n * ' '
  exit
end

ans = []
[k, 41].min.times do |i|
  ans = [0] * n
  a.each_with_index do |t, i|
    
    j = i - t
    if 0 <= j
      ans[j] += 1
    else
      ans[0] += 1
    end
    
    j = i + t + 1
    ans[j] += -1 if j < n
  end
  ans.cumsum!
  a = ans.dup
end

puts ans * ' '
//  [ruby]
class Array
  def cumsum!(s = 0); map!{|t| s += t } end
end

n, k = gets.to_s.split.map{|t| t.to_i }
a    = gets.to_s.split.map{|t| t.to_i }

if k >= 41
  puts "#{n} " * (n - 1) + "#{n}"
  exit
end

ans = []
[k, 41].min.times do |i|
  ans = [0] * n
  a.each_with_index do |t, i|
    
    j = i - t
    if 0 <= j
      ans[j] += 1
    else
      ans[0] += 1
    end
    
    j = i + t + 1
    ans[j] += -1 if j < n
  end
  ans.cumsum!
  a = ans.dup
end

puts ans * ' '
//  [ruby]
class Array
  def cumsum!(s = 0); map!{|t| s += t } end
end

n, k = gets.to_s.split.map{|t| t.to_i }
a    = gets.to_s.split.map{|t| t.to_i }

if k >= 41
  puts [n] * n * ' '
  exit
end

ans = []
[k, 40].min.times do |i|
  
  ans = [0] * n
  a.each_with_index do |t, i|
    
    j = [i - t, 0].max
    ans[j] += 1
    
    j = i + t + 1
    ans[j] += -1 if j < n
  end
  
  ans.cumsum!
  
  a = ans.dup
end

puts ans * ' '
//  [ruby]
n,k=gets.split.map(&:to_i)
a=gets.split.map(&:to_i)
#n,k=200000,200000
#a=[0]*200000
[k,41].min.times do
  b=[]
  l=[0]*n
  c=0
  0.upto(n-1) do |i|
    c+=1
    if i+a[i]<n-1
      l[i+a[i]]+=1
    else
      l[n-1]+=1
    end
    b[i]=c
    c-=l[i]
  end
  l=[0]*n
  c=0
  (n-1).downto(0) do |i|
    if i-a[i]>0
      l[i-a[i]]+=1
    else
      l[0]+=1
    end
    b[i]+=c
    c-=l[i]
    c+=1
  end
  a=b.dup
end
puts a.join(" ")
//  [ruby]
n,k=gets.split.map(&:to_i)
a=gets.split.map(&:to_i)
#n,k=200000,200000
#a=[0]*200000
t=41
while k>0&&t>0
  b=[]
  l=[0]*n
  c=0
  0.upto(n-1) do |i|
    c+=1
    if i+a[i]<n-1
      l[i+a[i]]+=1
    else
      l[n-1]+=1
    end
    b[i]=c
    c-=l[i]
  end
  l=[0]*n
  c=0
  (n-1).downto(0) do |i|
    if i-a[i]>0
      l[i-a[i]]+=1
    else
      l[0]+=1
    end
    b[i]+=c
    c-=l[i]
    c+=1
  end
  a=b.dup
  k-=1
  t-=1
end
puts a.join(" ")