Language: C++

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n,k;
	int ans=0;
	cin >>n>>k;
	ll bef;
	V a(n+1,0LL),cnt(n+1,0LL);
	rep(i,n){
		cin>>bef;
		cnt[i]+=bef;
		cnt[i+1]-=bef;
	}
	rep(i,min(k,1+log2(n))){
		rep(I, n + 1)
		{

		a[I]=0LL;
		}
		rep(j,n){
			if(j!=0){
				
				cnt[j]+=cnt[j-1];
			}
				clog<<j-cnt[j]<<" "<<1+j+cnt[j]<<endl;
				a[max(0LL,j-cnt[j])]++;
				a[min((ll)n,1+j+cnt[j])]--;
				
			
		}
		 cnt=a;
		//clog << endl;
		//rep(I, n+1)
		//{

		//	cout << cnt[I] << " ";
		//	
		//}
	//	clog << endl;
	}
	rep(j, n)
	{
		if(j!=0){
			cnt[j] += cnt[j - 1];
		}
		cout<<cnt[j];
		if(j!=n-1){cout<<" ";}
	}
	cout<<endl;


}
/*
1
1 0 0 1 0
1 0] [0 1 0]
1 2 2 1 2
---------

0 2
1 2
2 3
2 5
4 5

1 1
1 1 1 1
1 1 1 1 1
0 0 1 1 1
0 0 1 1 1
---------
3 3 4 4 3



0 0 0 0 0 0
----------
1 1 1 1 1 1 ....1
---------------
2 3 3 3 3 3 3....3 2
------------
1 1 1
1 1 1 1 1
1 1 1 1 1 1
1 1 1 1 1 1 1
0 1 1 1 1 1 1 1
0 0 1 1 1 1 1 1 1
0 0 0 1 1 1 1 1 1 1
....................  
  ........      1 1 1
---

4 5 6 6 6 6 6 ...6 5 4
7 8 9 10 11 12 13 13 13 .... 12 11 10 9 8 7
14 15 16 17 18 19 20 21 22 23 24 25 26 27 27 27 ... 26 ~ 15 14

[0 1 2 4 7] i_n= i_(n-1)+1
[0 1 3 6 13 27...n] a_n=a_(n-1)*2 +1

0 0 0....0 0 0 1 0 0 0...0
0 0 0 ...0 0 1 1 1 0 0 ...0
0 0 0 ...0 1 2 3 2 1 0 ... 0
0 0 0 ...1 2 3 3 3 2 1 ... 0
0 0 0 .2 2 2 1 1
*/

Compiler output:
a.cc: In function 'int main()':
a.cc:39:18: error: no matching function for call to 'min(int&, __gnu_cxx::__enable_if<true, double>::__type)'
   39 |         rep(i,min(k,1+log2(n))){
      |               ~~~^~~~~~~~~~~~~
a.cc:4:45: note: in definition of macro 'rep'
    4 | #define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
      |                                             ^
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:39:18: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__enable_if<true, double>::__type' {aka 'double'})
   39 |         rep(i,min(k,1+log2(n))){
      |               ~~~^~~~~~~~~~~~~
a.cc:4:45: note: in definition of macro 'rep'
    4 | #define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
      |                                             ^
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:39:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   39 |         rep(i,min(k,1+log2(n))){
      |               ~~~^~~~~~~~~~~~~
a.cc:4:45: note: in definition of macro 'rep'
    4 | #define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
      |                                             ^