Language: C++

#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

template <typename T>
using vec = vector<T>;

template <typename T>
using vec2 = vector<vector<T>>;

template <typename T>
using vec3 = vector<vector<vector<T>>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 61;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

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

    Int n, k;
    cin >> n >> k;
    vec<Int> a(n);
    for (Int i = 0; i < n; i++) {
        cin >> a[i];
    }

    if (n <= k) {
        for (Int i = 0; i < n - 1; i++) {
            cout << n << ' ';
        }
        cout << n << endl;

        return 0;
    }

    for (Int i = 0; i < k; i++) {
        bool iscon = false;
        vec<Int> aa(n);
        for (Int j = 0; j < n; j++) {
            Int L, R;
            L = clamp(j - a[j], 0LL, n);
            R = clamp(j + a[j] + 1, 0LL, n);
            for (Int k = L; k < R; k++) {
                aa[k]++;
            }
        }

        a = aa;
        // for (Int i = 0; i < n - 1; i++) {
        //     cout << setw(3) << a[i];
        // }
        // cout << setw(3) << a[n - 1] << endl;

        for (Int j = 0; j < n; j++) {
            if (a[j] < n) {
                iscon = true;
                break;
            }
        }

        if (!iscon) {
            a.assign(n, n);
            break;
        }
    }

    for (Int i = 0; i < n - 1; i++) {
        cout << a[i] << ' ';
    }
    cout << a[n - 1] << endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:67:22: error: no matching function for call to 'clamp(Int, long long int, Int&)'
   67 |             L = clamp(j - a[j], 0LL, n);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:17:
/usr/include/c++/14/bits/stl_algo.h:3624:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::clamp(const _Tp&, const _Tp&, const _Tp&)'
 3624 |     clamp(const _Tp& __val, const _Tp& __lo, const _Tp& __hi)
      |     ^~~~~
/usr/include/c++/14/bits/stl_algo.h:3624:5: note:   template argument deduction/substitution failed:
a.cc:67:22: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
   67 |             L = clamp(j - a[j], 0LL, n);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:3644:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::clamp(const _Tp&, const _Tp&, const _Tp&, _Compare)'
 3644 |     clamp(const _Tp& __val, const _Tp& __lo, const _Tp& __hi, _Compare __comp)
      |     ^~~~~
/usr/include/c++/14/bits/stl_algo.h:3644:5: note:   candidate expects 4 arguments, 3 provided
a.cc:68:22: error: no matching function for call to 'clamp(Int, long long int, Int&)'
   68 |             R = clamp(j + a[j] + 1, 0LL, n);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:3624:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::clamp(const _Tp&, const _Tp&, const _Tp&)'
 3624 |     clamp(const _Tp& __val, const _Tp& __lo, const _Tp& __hi)
      |     ^~~~~
/usr/include/c++/14/bits/stl_algo.h:3624:5: note:   template argument deduction/substitution failed:
a.cc:68:22: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
   68 |             R = clamp(j + a[j] + 1, 0LL, n);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:3644:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::clamp(const _Tp&, const _Tp&, const _Tp&, _Compare)'
 3644 |     clamp(const _Tp& __val, const _Tp& __lo, const _Tp& __hi, _Compare __comp)
      |     ^~~~~
/usr/include/c++/14/bits/stl_algo.h:3644:5: note:   candidate expects 4 arguments, 3 provided