func_code_string: #include <bits/stdc++.h>   using namespace std;   long long MOD = 1000000007;   long long fac[1100000], inv[1100000], p[1100000];   long long pow_mod(long long a, long long b, long long m) {     long long ans = 1LL;     a %= m;     while (b) {       if (b & 1) ans = ans * a % m;       a = a * a % m;       b >>= 1;     }     return ans;   }   int main() {     fac[0] = 1LL;     inv[0] = pow_mod(fac[0], MOD - 2, MOD);     for (long long i = 1; i <= 1010000; ++i) {       fac[i] = i * fac[i - 1] % MOD;       inv[i] = pow_mod(fac[i], MOD - 2, MOD);     }     long long n, k;     cin >> n >> k;     for (long long i = 1; i <= k + 2; ++i) {       p[i] = p[i - 1] + pow_mod(i, k, MOD);       p[i] %= MOD;     }     if (n <= k + 2) {       cout << p[n] << endl;       return 0;     }     long long x = 1LL;     for (int i = 1; i <= k + 2; ++i) {       x *= (n - i);       x %= MOD;     }     long long ans = 0LL, flag;     for (int i = 1; i <= k + 2; ++i) {       if ((k + 2 - i) & 1)         flag = -1;       else         flag = 1;       ans += x * flag * pow_mod(n - i, MOD - 2, MOD) % MOD * inv[i - 1] % MOD *              inv[k + 2 - i] % MOD * p[i];       (ans += MOD) %= MOD;     }     cout << ans << endl;     return 0;   }   