func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = -1;   const int INF = 1.01e9;   const int MOD = 1e9 + 7;   long long rev(long long a, long long m) {     if (a == 0) return 0;     return ((1 - rev(m % a, a) * m) / a + m) % m;   }   int main() {     int n, k;     scanf( %d%d , &n, &k);     vector<long long> fact(n + 1);     fact[0] = 1;     for (int i = 1; i <= n; i++) {       fact[i] = (fact[i - 1] * i) % MOD;     }     vector<long long> rfact(n + 1);     rfact[n] = rev(fact[n], MOD);     assert(fact[n] * rfact[n] % MOD == 1);     for (int i = n - 1; i >= 0; i--) {       rfact[i] = (rfact[i + 1] * (i + 1)) % MOD;     }     auto getC = [&](int nn, int kk) {       assert(0 <= kk && kk <= nn);       return fact[nn] * rfact[kk] % MOD * rfact[nn - kk] % MOD;     };     vector<long long> f(n + 1);     vector<long long> g(n + 1);     vector<long long> prefG(n + 1);     f[1] = 1;     g[1] = 1;     prefG[1] = 1;     for (int i = 2; i <= n; i++) {       long long tmp = prefG[i - 1];       if (i - k - 1 >= 1) {         tmp = (tmp - prefG[i - k - 1] + MOD) % MOD;       }       tmp = (tmp * fact[i - 2]) % MOD;       f[i] = tmp;       g[i] = f[i] * rfact[i - 1] % MOD;       prefG[i] = (prefG[i - 1] + g[i]) % MOD;     }     long long answer = 0;     for (int i = 1; i <= n; i++) {       answer = (answer + getC(n - 1, i - 1) * f[i] % MOD * fact[n - i]) % MOD;     }     cout << (fact[n] - answer + MOD) % MOD << endl;     return 0;   }   