func_code_string: #include <bits/stdc++.h>   using namespace std;   using namespace chrono;   const long long int MOD = 1000000007;   const long long int MAXN = 100005;   long long int k, dp[MAXN];   long long int recurse(long long int n) {     if (n == 0) return 1;     if (dp[n] != -1) return dp[n];     long long int ans = 0;     if (n >= k) {       ans = (ans + recurse(n - k)) % MOD;     }     if (n > 0) {       ans = (ans + recurse(n - 1)) % MOD;     }     return (dp[n] = ans);   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long int t;     cin >> t >> k;     long long int a, b;     memset(dp, -1, sizeof(dp));     dp[0] = 0;     for (long long int i = 1; i < 100001; ++i) {       dp[i] = recurse(i);     }     for (long long int i = 1; i < 100001; ++i) {       dp[i] = (dp[i] + dp[i - 1]) % MOD;     }     while (t--) {       cin >> a >> b;       cout << ((MOD + dp[b] - dp[a - 1])) % MOD << endl;     }     return 0;   }   