func_code_string: #include <bits/stdc++.h>   using namespace std;   int main() {     long long n, k;     cin >> n >> k;     vector<long long> a;     vector<long long> b;     long long sum;     if (k + 1 < n) {       sum = k + 1;       b.push_back(sum);     } else {       for (long long i = 0; i < n; i++) {         cout << n <<    ;       }       return 0;     }     for (long long i = 0; i < n; i++) {       long long te;       cin >> te;       te--;       a.push_back(te);     }     for (long long i = 1; i < n; i++) {       long long re = 0;       if (a[i] > -1) {         if (a[i] + k > i) {           if (a[i] + k < n) {             re = a[i] + k - i;           } else {             re = n - i - 1;           }         }         if (a[i] + k < i) {           sum = 1;         } else {           sum = 0;         }         if (sum) {           if (i - k > a[i] + k) {             sum += k;           } else {             sum += i - 1 - (a[i] + k);           }         }         sum += b[a[i]];       } else {         sum = 1;         if (i - k > -1) {           sum += k;         } else {           sum += i;         }       }       if (i + k < n) {         sum += k - re;       } else {         sum += n - 1 - i - re;       }       b.push_back(sum);     }     for (long long i = 0; i < n; i++) {       cout << b[i] <<    ;     }     return 0;   }   