func_code_string: #include <bits/stdc++.h>   using namespace std;   template <class X, class Y>   void minimize(X &x, const Y &y) {     if (x > y) x = y;   }   template <class X, class Y>   void maximize(X &x, const Y &y) {     if (x < y) x = y;   }   template <class T>   T Abs(const T &x) {     return (x < 0 ? -x : x);   }   const int mod = (int)1e9 + 7;   int cntWay[500500 * 2], sumWay[500500 * 2];   int frac[500500], finv[500500];   int inverse(int x) {     int res = 1;     int mul = x;     int k = mod - 2;     while (k > 0) {       if (k & 1) res = 1LL * res * mul % mod;       mul = 1LL * mul * mul % mod;       k >>= 1;     }     return (res);   }   void precalc(void) {     frac[0] = finv[0] = 1;     for (int i = (1), _b = (500500 - 1); i <= _b; i = i + 1)       frac[i] = 1LL * frac[i - 1] * i % mod;     for (int i = (1), _b = (500500 - 1); i <= _b; i = i + 1)       finv[i] = inverse(frac[i]);   }   int comb(int k, int n) {     if (k > n) return (0);     return (1LL * frac[n] * finv[k] % mod * finv[n - k] % mod);   }   int countWay(int number, int sum, int absLim, int numBig) {     sum -= numBig * absLim;     sum += (number - numBig) * (absLim + 1);     return (comb(number - 1, sum - 1));   }   int countWay(int number, int sum, int absLim) {     int res = 0;     for (int numBig = 0, _n = (number + 1); numBig < _n; numBig = numBig + 1) {       int numSet = comb(numBig, number);       int numWay = countWay(number, sum, absLim, numBig);       if (numBig % 2 == 0)         res = (res + 1LL * numSet * numWay) % mod;       else         res = (res - 1LL * numSet * numWay % mod + mod) % mod;     }     return (res);   }   void process(void) {     int a, b, range, n;     cin >> a >> b >> range >> n;     for (int i = (-range * n), _b = (range * n); i <= _b; i = i + 1)       cntWay[i + 500500] = countWay(n, i, range);     for (int i = (range * n), _a = (-range * n); i >= _a; i = i - 1)       sumWay[i + 500500] = (sumWay[i + 1 + 500500] + cntWay[i + 500500]) % mod;     int res = 0;     for (int i = (-range * n), _b = (range * n); i <= _b; i = i + 1) {       int reqScore = b + i + 1 - a;       if (reqScore > range * n) continue;       maximize(reqScore, -range * n);       int numWayB = cntWay[i + 500500];       int numWayA = sumWay[reqScore + 500500];       res = (res + 1LL * numWayA * numWayB) % mod;     }     printf( %d n , res);   }   int main(void) {     precalc();     process();     return 0;   }   