func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long MOD = 1e9 + 7;   int n;   vector<int> dig;   long long cnt[15];   long long C[25][25];   struct cond {     int sum;     int a[20];     string s;     cond() {       for (int i = 0; i < 20; i++) {         a[i] = 0;       }       s =   ;       sum = 0;     }   };   void calculateC() {     for (int i = 0; i <= 20; i++)       for (int j = 0; j <= 20; j++) C[i][j] = 0;     for (int i = 0; i < 20; i++) C[i][0] = 1;     for (int i = 1; i <= 20; i++)       for (int j = 1; j <= 20; j++)         C[i][j] =             ((C[i][j] % MOD) + ((C[i - 1][j] + C[i - 1][j - 1]) % MOD)) % MOD;   }   long long C2(int n, int k) {     if (n < 0 || k < 0 || k > n) return 0;     long long ans = 1;     for (int i = n; i > n - k; i--) ans = (ans * i) % MOD;     return ans % MOD;   }   long long Power2(int n) {     long long k = 1ll;     for (int i = 1; i <= n; i++) k = (k * 2ll) % MOD;     return k;   }   long long Power8(int n) {     long long k = 1ll;     for (int i = 1; i <= n; i++) k = (k * 8ll) % MOD;     return k;   }   bool good(int n) {     if (n == 4 || n == 7) return true;     return false;   }   void findcnt(int pos, int sum) {     if (pos == (int)dig.size()) return;     int p = (int)dig.size() - pos;     long long Q = (long long)dig[pos];     if (p == 1) {       cnt[0]--;       for (int i = 0; i <= Q; i++)         if (good(i))           cnt[sum + 1]++;         else           cnt[sum]++;       return;     }     for (int i = 0; i <= p - 1; i++) {       for (int j = 0; j < Q; j++) {         if (!good(j))           cnt[i + sum] += Power2(i) * C[p - 1][i] * Power8(p - 1 - i);         else           cnt[i + sum + 1] += Power2(i) * C[p - 1][i] * Power8(p - 1 - i);       }     }     if (good(dig[pos]))       findcnt(pos + 1, sum + 1);     else       findcnt(pos + 1, sum);   }   long long ans = 0;   vector<cond> allposib;   void BT(int pos, int sum, string s) {     if (pos == 6) {       cond A;       for (int i = 0; i < (int)s.length(); i++) A.a[(int)s[i] - (int) 0 ]++;       A.sum = sum;       A.s = s;       if (sum <= 10) allposib.push_back(A);     } else       for (int i = 0; i <= 10; i++)         BT(pos + 1, sum + i, s + (char)(i + (int) 0 ));   }   int fac(int n) {     int ans = 1;     for (int i = 1; i <= n; i++) ans *= i;     return ans;   }   int main() {     calculateC();     for (int i = 0; i <= 10; i++) cnt[i] = 0;     cin >> n;     while (n) {       dig.push_back(n % 10);       n /= 10;     }     reverse((dig).begin(), (dig).end());     findcnt(0, 0);     BT(0, 0,   );     long long ans = 0;     for (int i = 0; i < (int)allposib.size(); i++) {       int from = allposib[i].sum + 1;       long long tmp = 1, posfor7 = 0;       for (int j = 0; j <= 10; j++) {         tmp = (tmp * (C2(cnt[j], allposib[i].a[j]))) % MOD;       }       for (int j = from; j <= 10; j++) posfor7 += cnt[j];       posfor7 %= MOD;       tmp = (tmp * posfor7) % MOD;       ans = (ans + tmp) % MOD;     }     cout << ans % MOD << endl;     return 0;   }   