func_code_string: #include <bits/stdc++.h>   using namespace std;   long long mul(long long a, long long b, long long M) { return a * b % M; }   long long add(long long a, long long b, long long M) { return (a + b) % M; }   vector<vector<long long> > eye(int n) {     vector<vector<long long> > I(n, vector<long long>(n));     for (int i = 0; i < n; ++i) I[i][i] = 1;     return I;   }   vector<vector<long long> > mul(vector<vector<long long> > &A,                                  vector<vector<long long> > &B, long long M) {     int l = A.size(), m = B.size(), n = B[0].size();     vector<vector<long long> > C(l, vector<long long>(n));     for (int i = 0; i < l; ++i)       for (int k = 0; k < m; ++k)         for (int j = 0; j < n; ++j)           C[i][j] = add(C[i][j], mul(A[i][k], B[k][j], M), M);     return C;   }   vector<vector<long long> > pow(vector<vector<long long> > A, long long b,                                  long long M) {     vector<vector<long long> > X = eye(A.size());     for (; b > 0; b >>= 1) {       if (b & 1) X = mul(X, A, M);       A = mul(A, A, M);     }     return X;   }   const long long mod = 1e9 + 7;   int main() {     ios_base::sync_with_stdio(0), cin.tie(0);     long long n, m;     cin >> n >> m;     vector<vector<long long> > M(m, vector<long long>(m));     for (int i = 0; i < m - 1; ++i) M[i][i + 1] = 1;     M[m - 1][0] = M[m - 1][m - 1] = 1;     M = pow(M, n, mod);     long long ans = 0;     for (auto i : M[0]) ans = (ans + i) % mod;     cout << ans <<   n ;     return 0;   }   