func_code_string: #include <bits/stdc++.h>   using namespace std;   const long double EPS = 1E-9;   const int INF = (int)1E9;   const long long INF64 = (long long)1E18;   const long double PI = 2 * acos(.0);   long long dp[10][10][2];   vector<int> number;   int pivot = 1;   long long solve(int pos, bool is_bounded, int lucky_digits) {     long long &memo = dp[pos][lucky_digits][is_bounded];     if (lucky_digits > pivot) return 0;     if (pos == (int)(number).size()) return 1;     if (memo != -1) return memo;     memo = 0;     int upto = 9;     if (is_bounded) upto = number[pos];     for (int i = 0; i <= upto; i++) {       bool next_bound = is_bounded && (upto == i);       int next_lucky = lucky_digits + ((i == 4 || i == 7) ? 1 : 0);       int next_pos = pos + 1;       memo += solve(next_pos, next_bound, next_lucky);     }     return memo;   }   const long long MOD = 1000000007ll;   long long bigPow(long long a, long long b) {     long long resp = 1;     while (b) {       if (b & 1) resp = (resp * a) % MOD;       a = (a * a) % MOD;       b >>= 1;     }     return resp % MOD;   }   long long inv(long long x) { return bigPow(x, MOD - 2); }   long long binCoefRec(int nn, int kk) {     if (nn == kk) return 1ll;     if (kk == 0) return 1ll;     long long bin = (binCoefRec(nn - 1, kk - 1) * nn) % MOD;     long long resp = (bin * inv(kk)) % MOD;     return resp;   }   set<string> occur_set[10];   bool cent[10];   void find_occur(string seed, int times, int last) {     if (times > 9) return;     occur_set[times].insert(seed);     for (int i = last; i < (int)(10); i++) {       seed[i]++;       seed[0]--;       find_occur(seed, times + i, i);       seed[i]--;       seed[0]++;     }   }   int main() {     ios_base::sync_with_stdio(0);     int m;     cin >> m;     while (m) {       number.push_back(m % 10);       m /= 10;     }     reverse(number.begin(), number.end());     long long lucky_id[10];     long long calc = 0, calc_bef = 0;     long long ans = 0;     find_occur( 6000000000 , 0, 1);     for (pivot = 0; pivot < 10; pivot++) {       for (int i = 0; i < (int)(10); i++)         for (int j = 0; j < (int)(10); j++)           for (int k = 0; k < (int)(2); k++) dp[i][j][k] = -1;       calc = solve(0, true, 0) - 1;       lucky_id[pivot] = calc - calc_bef;       calc_bef = calc;       if (pivot == 0 || lucky_id[pivot] == 0) continue;       for (int x = 0; x < pivot; x++) {         set<string>::iterator p = occur_set[x].begin();         while (p != occur_set[x].end()) {           long long temp = 1;           bool cant = 1;           for (int i = 0; i < (int)((*p).size()); i++) {             if (i > pivot) continue;             if ((*p)[i] <  0  || lucky_id[i] < ((*p)[i] -  0 )) {               cant = 0;               break;             }             temp =                 (((temp) % MOD) * binCoefRec(lucky_id[i], (*p)[i] -  0 )) % MOD;           }           if (cant == 0)             temp = 0;           else             temp = (temp * lucky_id[pivot]) % MOD;           ans = (ans + temp * 720) % MOD;           p++;         }       }     }     cout << ans << endl;     return 0;   }   