Language: C++

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>

#define ld long double
#define db double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define RAND mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define debx cout << " X " << endl;
#define deby cout << " Y " << endl;
#define debz cout << " Z " << endl;
#define deb(x) cout << '>' << #x << ':' << x << endl;

const long double PI = 3.14159265358979323846264338;
const long long INF = 1000000000000000000;
const long long INF1 = 1000000000;
const long long MOD = 1000000007;
// const long long MOD = 998244353;

using namespace __gnu_pbds; 
using namespace std;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update> ; 
/*  
    find_by_order() - Returns an iterator to the k-th largest element (counting from zero) 
    order_of_key()  - The number of items in a set that are strictly smaller than our item 
    Rest same as set
*/
 
int mpow(int a, int b){
    a %= MOD;
    if(!b)
        return 1;
    int temp = mpow(a, b/2);
    temp = (temp*temp) % MOD;
    if(b%2)
        return (a * temp) % MOD;
    return temp;
}
int _pow(int a, int b){
    if(!b)
        return 1;
    int temp = _pow(a, b/2);
    temp = (temp * temp);
    if(b%2)
        return (a * temp);
    return temp;
}
int mod_in(int n){
    return mpow(n, MOD-2);
}
int cl(int a, int b){
    if(a%b)
        return 1 + a/b;
    return a/b;
}

class SegTree{
    private:
        int *st = new int[10000000];
        int *lazy = new int[10000000];
        int n = 0;
    public:
        SegTree(int x){
            n = x;
            for(int i=0 ; i<4*x ; i++)
                st[i] = lazy[i] = 0;    
        }
        
        void update(int lo, int hi, int val){
            up(1, 1, n, lo, hi, val);
        }

        int query(int lo, int hi){
            return q(1, 1, n, lo, hi);
        }

        void up(int node, int l, int r, int lo, int hi, int val){
            if(lazy[node]){
                st[node] += lazy[node] * (r-l+1);
                if(r!=l){
                    lazy[2*node] += lazy[node];
                    lazy[2*node+1] += lazy[node];
                }
                lazy[node] = 0;
            }
            if(l>r || l>hi || lo>r)
                return;
            if(l>=lo && r<=hi){
                st[node] += (r-l+1) * val;
                if(r!=l){
                    lazy[2*node] += val;
                    lazy[2*node+1] += val;
                }
                return;
            }
            int mid = (l+r) / 2;
            up(2*node, l, mid, lo, hi, val);    
            up(2*node+1, mid+1, r, lo, hi, val);
            st[node] = st[2*node] + st[2*node+1];
            return;
        }
 
        int q(int node, int l, int r, int lo, int hi){
            if(lazy[node]){
                st[node] += lazy[node] * (r-l+1);
                if(r!=l){
                    lazy[2*node] += lazy[node];
                    lazy[2*node+1] += lazy[node];
                }
                lazy[node] = 0;
            }
            if(l>r || l>hi || lo>r)
                return 0;
            if(l>=lo && r<=hi){
                return st[node] ;
            }
            int mid = (l+r) / 2;
            int q1 = q(2*node, l, mid, lo, hi);    
            int q2 = q(2*node+1, mid+1, r, lo, hi);
            return q1 + q2;
        }
  
        void clear(){
            delete st;
            delete lazy;
        }
};

int32_t main(){
    fastio;
    int n, k;
    cin >> n >> k;
    int a[n+5];
    for(int i=1 ; i<=n ; i++){
        cin >> a[i];
    }
    SegTree st = SegTree(n);
    int Z = min(k, (int) log(n) + 13);
    for(int j=0 ; j<Z ; j++){
        for(int i=1 ; i<=n ; i++){
            int l = max(1ll, i - a[i]);
            int r = min(n, i + a[i]);
            st.update(l, r, 1);
        }
        for(int i=1 ; i<=n ; i++){
            a[i] = st.query(i,i) ;
            st.update(i, i, -a[i]);
        }
    }
    for(int i=1 ; i<=n ; i++)
        cout << a[i] << " ";
}


Compiler output:
a.cc: In function 'int32_t main()':
a.cc:147:24: error: no matching function for call to 'max(long long int, int)'
  147 |             int l = max(1ll, i - a[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:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:147:24: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
  147 |             int l = max(1ll, i - a[i]);
      |                     ~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:147:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  147 |             int l = max(1ll, i - a[i]);
      |                     ~~~^~~~~~~~~~~~~~~