Language: C++

#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = int_fast64_t;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
struct RangedFenwickTree {
  int N;
  vll bit1, bit2;
  RangedFenwickTree(int n) : N(n), bit1(n+2, 0), bit2(n+2, 0) {}
  void add(vll& bit, int i, int a) {
    assert(i > 0);
    while(i <= N) {
      bit[i] += a;
      i += (i & -i);
    }
  }
  void range_add(int l, int r, int a) {
    add(bit1, l, a);
    add(bit2, l, -a*(l-1));
    add(bit1, r+1, -a);
    add(bit2, r+1, a*r);
  }
  ll query(vll& bit, int i) {
    ll res = 0;
    while(i > 0) {
      res += bit[i];
      i -= (i & -i);
    }
    return res;
  }
  ll sum(int i) {
    return query(bit1, i) * i + query(bit2, i);
  }
};

void answer() {
  ll n, k; cin >> n >> k;
  vector<ll> a(n, 0), p(n, 0);
  rep(i, n) cin >> a[i];
  rep(j,k) {
    swap(p, a);
    RangedFenwickTree ft2(n);
    rep(i,n) {
      ft2.range_add(max(1LL, i+1-p[i]), min(n, i+1+p[i]), 1);
    }
    rep(i,n) {
      a[i] = ft2.sum(i+1) - ft2.sum(i);
    }
    bool diff = false;
    rep(i,n) {
      if(a[i] != p[i]) diff = true;
    }
    if(!diff) break;
  }
  rep(i,n) {
    if(i) cout << " ";
    cout << a[i];
  }
  cout << "\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Compiler output:
a.cc: In function 'void answer()':
a.cc:58:24: error: no matching function for call to 'max(long long int, __gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type)'
   58 |       ft2.range_add(max(1LL, i+1-p[i]), min(n, i+1+p[i]), 1);
      |                     ~~~^~~~~~~~~~~~~~~
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:58:24: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type' {aka 'long int'})
   58 |       ft2.range_add(max(1LL, i+1-p[i]), min(n, i+1+p[i]), 1);
      |                     ~~~^~~~~~~~~~~~~~~
/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:58:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   58 |       ft2.range_add(max(1LL, i+1-p[i]), min(n, i+1+p[i]), 1);
      |                     ~~~^~~~~~~~~~~~~~~