malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 7;   struct node {     int l, r, id;   } p[2][2][maxn];   bool cmp1(node A, node B) { return A.l < B.l; }   bool cmp2(node A, node B) { return A.r < B.r; }   int n;   int sz[2][maxn];   int rid1[maxn], rid2[maxn];   int main() {     srand(time(NULL));     memset(sz, 0, sizeof(sz));     scanf( %d , &n);     for (int i = 0; i < n; i++) {       for (int j = 0; j < 2; j++) {         scanf( %d%d , &p[j][0][i].l, &p[j][0][i].r);         p[j][0][i].id = i;         p[j][1][i] = p[j][0][i];       }     }     for (int i = 0; i < 10000000; i++) {       int l = rand() % n;       int r = rand() % n;       int L11 = p[0][0][l].l, L12 = p[0][0][l].r;       int L21 = p[1][0][l].l, L22 = p[1][0][l].r;       int R11 = p[0][0][r].l, R12 = p[0][0][r].r;       int R21 = p[1][0][r].l, R22 = p[1][0][r].r;       int flag1 = 0, flag2 = 0;       if (max(L11, R11) <= min(L12, R12)) {         flag1 = 1;       } else {         flag1 = 0;       }       if (max(L21, R21) <= min(L22, R22)) {         flag2 = 1;       } else {         flag2 = 0;       }       if (flag1 != flag2) {         cout <<  NO  << endl;         return 0;       }     }     for (int i = 0; i < 2; i++) {       sort(p[i][0], p[i][0] + n, cmp1);       sort(p[i][1], p[i][1] + n, cmp2);     }     for (int j = 0; j < 2; j++) {       for (int i = 0; i < n; i++) {         int l = 0, r = n - 1, ans = n;         while (l <= r) {           int mid = (l + r) / 2;           if (p[j][0][mid].l > p[j][0][i].r) {             r = mid - 1;             ans = mid;           } else {             l = mid + 1;           }         }         sz[j][p[j][0][i].id] += n - ans;         l = 0, r = n - 1, ans = -1;         while (l <= r) {           int mid = (l + r) / 2;           if (p[j][1][mid].r < p[j][0][i].l) {             l = mid + 1;             ans = mid;           } else {             r = mid - 1;           }         }         sz[j][p[j][0][i].id] += ans + 1;       }     }     for (int i = 0; i < n; i++) {       if (sz[0][i] != sz[1][i]) {         cout <<  NO  << endl;         return 0;       }     }     cout <<  YES  << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100000;   const long long INF = 1000000000000000;   int a[N];   int main() {     int t;     cin >> t;     for (int q = 0; q < t; q++) {       int n, k;       cin >> n >> k;       for (int j = 0; j < n; j++) {         cin >> a[j];       }       long long answer = -INF;       for (long long j = 1; j < n; j++) {         long long i = j - 1;         while (i >= 0 and (i + 1) * (j + 1) - k * a[j] > answer) {           long long result = (i + 1) * (j + 1) - k * (a[i] | a[j]);           answer = max(answer, result);           i--;         }       }       cout << answer << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long pw[20][120], p[120], V, B, fA, fB, fC, ans;   int num[120], n, T, i, j;   void dfs_B(int l, long long x) {     if ((double)x * x > V) return;     if (l == n + 1) {       B = max(B, x);       return;     }     for (int i = 0; i <= num[l]; ++i) dfs_B(l + 1, x * pw[l][i]);   }   void dfs_A(int l, long long A) {     if ((double)A * A * A > V) return;     if (l == n + 1) {       long long x = (int)sqrt(V / A);       if (2 * A * x + V / A >= ans) return;       V /= A;       B = 0;       dfs_B(1, 1);       if (A * B + A * (V / B) + V < ans) {         ans = A * B + A * (V / B) + V;         fA = A;         fB = B;         fC = V / B;       }       V *= A;       return;     }     for (int i = num[l]; i >= 0; --i) {       num[l] -= i;       dfs_A(l + 1, A * pw[l][i]);       num[l] += i;     }   }   int main() {     for (scanf( %d , &T); T--;) {       scanf( %d , &n);       V = 1;       for (i = 1; i <= n; ++i) {         scanf( %I64d%d , &p[i], &num[i]);         pw[i][0] = 1;         for (j = 1; j <= num[i]; ++j) pw[i][j] = pw[i][j - 1] * p[i];         V *= pw[i][num[i]];       }       ans = 1ll << 62;       dfs_A(1, 1);       printf( %I64d %I64d %I64d %I64d n , ans * 2, fA, fB, fC);     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       long long n, g, b;       cin >> n >> g >> b;       long long sure_fire = (n + 1) / 2;       long long sum = 0;       if (g >= b) {         sum = n;       } else {         long long a1 = (sure_fire + g - 1) / g;         sum = (a1 - 1) * (g + b);         long long a2 = n - sure_fire - (a1 - 1) * b;         if (a2 < 0) a2 = 0;         sure_fire -= (a1 - 1) * g;         sum += sure_fire + a2;       }       cout << sum << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline bool smax(long long &a, long long b) {     if (a < b) {       a = b;       return true;     } else       return false;   }   const long long MAXN = 1e5 + 100;   long long dp[MAXN][4], par[MAXN][4], choose[MAXN][4], id[MAXN];   pair<long long, long long> p[MAXN], s;   set<long long> sz;   map<long long, long long> cost, toid;   bool byP(long long x, long long y) {     return greater<pair<long long, long long> >()(p[x], p[y]);   }   pair<long long, long long> ans[MAXN];   long long ansN;   void get(long long i, long long j) {     if (i) get(i - 1, par[i][j]);     if (choose[i][j] != -1)       ans[ansN++] = pair<long long, long long>(i - 1, choose[i][j]);   }   int main() {     ios::sync_with_stdio(false);     cout.tie(0);     cin.tie(0);     memset(dp, -63, sizeof dp);     memset(choose, -1, sizeof choose);     long long m;     cin >> m;     for (long long i = 0; i < m; i++) {       cin >> s.second >> s.first;       sz.insert(s.first);       cost[s.first] = s.second;       toid[s.first] = i;     }     long long n;     cin >> n;     for (long long i = 0; i < n; i++) cin >> p[i].second >> p[i].first, id[i] = i;     p[n++] = pair<long long, long long>(-1, -1);     id[n - 1] = n - 1;     sort(id, id + n, byP);     sort(p, p + n, greater<pair<long long, long long> >());     long long tmp = 0;     if (sz.count(p[0].first)) tmp += 1;     if (sz.count(p[0].first + 1)) tmp += 2;     dp[0][tmp] = 0;     cerr << bitset<2>(tmp) << endl;     cost[-1] = 0;     for (long long i = 0; i < n - 1; i++)       for (long long j = 0; j < 4; j++)         if (dp[i][j] >= 0) {           long long cur = p[i].first;           vector<long long> t;           t.push_back(-1);           if (j & 1) t.push_back(cur);           if (j >> 1 & 1) t.push_back(cur + 1);           for (long long k = 0; k < t.size(); k++)             if (p[i].second >= cost[t[k]]) {               long long newmask = 0, next = p[i + 1].first;               if (sz.count(next) && t[k] != next) newmask += 1;               if (sz.count(next + 1) && t[k] != next + 1) newmask += 2;               if (next == cur) newmask &= j;               if (next == cur - 1 && j % 2 == 0) newmask -= newmask / 2 * 2;               if (smax(dp[i + 1][newmask], dp[i][j] + cost[t[k]])) {                 par[i + 1][newmask] = j;                 choose[i + 1][newmask] = t[k];               }             }         }     get(n - 1, 0);     cout << dp[n - 1][0] <<   n  << ansN <<   n ;     for (long long i = 0; i < ansN; i++)       cout << id[ans[i].first] + 1 <<     << toid[ans[i].second] + 1 <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3010, Mo = 1000000007;   int tt, n, D;   int f[N][N], rev[N * 2], head[N], to[N], nxt[N];   inline int gi() {     int x = 0, o = 1;     char ch = getchar();     while (ch !=  -  && (ch <  0  || ch >  9 )) ch = getchar();     if (ch ==  - ) o = -1, ch = getchar();     while (ch >=  0  && ch <=  9 ) x = x * 10 + ch -  0 , ch = getchar();     return x * o;   }   inline void dfs(int x) {     for (int i = 1; i <= n; i++) f[x][i] = 1;     for (int i = head[x]; i; i = nxt[i]) {       int y = to[i];       dfs(y);       for (int j = 1; j <= n; j++) f[x][j] = 1LL * f[x][j] * f[y][j] % Mo;     }     for (int i = 2; i <= n; i++) f[x][i] = (f[x][i - 1] + f[x][i]) % Mo;   }   inline int Pow(int x, int y) {     int ret = 1;     while (y) {       if (y & 1) ret = 1LL * ret * x % Mo;       x = 1LL * x * x % Mo, y >>= 1;     }     return ret;   }   int main() {     cin >> n >> D;     for (int i = 2, x; i <= n; i++)       to[++tt] = i, nxt[tt] = head[x = gi()], head[x] = tt;     dfs(1);     if (D <= n) return cout << f[1][D], 0;     int ans = 0;     for (int i = -n; i <= n; i++) rev[i + n] = Pow(i, Mo - 2);     for (int i = 0; i <= n; i++) {       int sum = f[1][i];       for (int j = 0; j <= n; j++)         if (i != j) sum = 1LL * sum * (D - j) % Mo * rev[i - j + n] % Mo;       (ans += sum) %= Mo;     }     cout << (ans + Mo) % Mo;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long int> g[300005];   long long int n, m, flag = 1;   map<pair<long long int, long long int>, long long int> ans;   long long int visit[300005];   long long int color[300005];   void dfs1(long long int src, long long int col) {     visit[src] = 1;     color[src] = col;     for (long long int i = 0; i < g[src].size(); i++) {       if (visit[g[src][i]] == 0) {         long long int x;         if (col == 0)           x = 1;         else           x = 0;         dfs1(g[src][i], x);       }     }   }   void dfs2(long long int src) {     visit[src] = 1;     for (long long int i = 0; i < g[src].size(); i++) {       if (color[g[src][i]] == color[src]) {         flag = 0;         break;       }       if (color[src] == 0) {         ans[{src, g[src][i]}] = 1;       } else {         ans[{src, g[src][i]}] = 0;       }       if (visit[g[src][i]] == 0) {         dfs2(g[src][i]);       }     }   }   int32_t main() {     cin >> n >> m;     pair<long long int, long long int> arr[m];     for (long long int i = 0; i < m; i++) {       long long int a, b;       cin >> a >> b;       a--;       b--;       arr[i].first = a;       arr[i].second = b;       g[a].push_back(b);       g[b].push_back(a);     }     dfs1(0, 0);     for (long long int i = 0; i < n; i++) visit[i] = false;     dfs2(0);     if (flag == 0)       cout <<  NO  << endl;     else {       cout <<  YES  << endl;       for (long long int i = 0; i < m; i++) {         cout << ans[{arr[i].first, arr[i].second}];       }       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   long long MOD = 998244353;   double eps = 1e-12;   void solve() {     long long n, x;     cin >> n >> x;     int a;     map<int, int> mr;     map<int, int> mc;     for (int i = 0; i < n; i++) {       for (int j = 0; j < x; j++) {         cin >> a;         if (a) {           mr[i + 1]++;           mc[j + 1]++;         }       }     }     int k1 = n - mr.size(), k2 = x - mc.size();     int l = min(k1, k2);     if (l & 1)       cout <<  Ashish  << endl;     else       cout <<  Vivek  << endl;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int n, m;     cin >> n >> m;     long long s = 0, x = 1;     long long a[n];     for (int i = 0; i < n; i++) {       cin >> a[i];       s = s + a[i];     }     s = s + m;     sort(a, a + n);     int y = max((s / n + min(x, s % n)), a[n - 1]);     cout << y;     cout <<     << a[n - 1] + m << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 3e5 + 1;   int N, Q, nums[MAXN], ans[MAXN], BIT[MAXN + 5];   vector<pair<int, int> > queries[MAXN];   void upd(int i) {     i++;     while (i > 0) {       BIT[i]++;       i -= i & -i;     }   }   int get(int i) {     i++;     int ret = 0;     while (i < N + 5) {       ret += BIT[i];       i += i & -i;     }     return ret;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> N >> Q;     for (int i = 1; i <= N; i++) {       cin >> nums[i];       nums[i] = i - nums[i];     }     for (int i = 0; i < Q; i++) {       int x, y;       cin >> x >> y;       if (x + y >= N) {         ans[i] = 0;         continue;       }       queries[N - y].push_back(make_pair(1 + x, i));     }     for (int i = 1; i <= N; i++) {       if (nums[i] >= 0 && get(1) >= nums[i]) {         int lo = 1;         int hi = i;         if (nums[i] == 0) lo = i;         while (lo < hi - 1) {           int m = (lo + hi) / 2;           if (get(m) >= nums[i]) {             lo = m;           } else {             hi = m;           }         }         upd(lo);       }       for (auto it : queries[i]) {         ans[it.second] = get(it.first);       }     }     for (int i = 0; i < Q; i++) {       cout << ans[i] <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   double start_moment = 0;   double get_runtime() { return 1.0 * clock() / CLOCKS_PER_SEC; }   void reset_timer() { start_moment = get_runtime(); }   double timer_time() { return get_runtime() - start_moment; }   void runtime() { cout << fixed << setprecision(5) << get_runtime() << endl; }   template <class T>   void read(vector<T> &a, int n) {     T x;     a.clear();     for (int i = 0; i < n; i++) {       cin >> x;       a.push_back(x);     }   }   template <class T>   void write(vector<T> &a) {     for (T x : a) cout << x <<    ;     cout <<   n ;   }   const int N = 2003;   const int INF = 1000000000;   int T, len;   string second, t;   int cnt1[26], cnt2[26];   int have_s[26][N];   int have_t[26][N];   int get(int *have, int x) {     if (x < 0) return 0;     return have[x];   }   int get(int *have, int l, int r) { return get(have, r) - get(have, l - 1); }   int dp[N][N];   int go(int x, int y) {     if (dp[x][y] != INF) return dp[x][y];     if (second[x - 1] == t[y - 1]) dp[x][y] = min(dp[x][y], go(x - 1, y - 1));     dp[x][y] = min(dp[x][y], go(x - 1, y) + 1);     if (get(have_s[t[y - 1] -  a ], x, len) > get(have_t[t[y - 1] -  a ], y, len))       dp[x][y] = min(dp[x][y], go(x, y - 1));     return dp[x][y];   }   int main() {     ios_base::sync_with_stdio(0);     cin >> T;     while (T--) {       memset(cnt1, 0, sizeof(cnt1));       memset(cnt2, 0, sizeof(cnt2));       cin >> len;       cin >> second >> t;       for (char c : second) cnt1[c -  a ]++;       for (char c : t) cnt2[c -  a ]++;       bool bad = 0;       for (int i = 0; i < 26; i++)         if (cnt1[i] != cnt2[i]) bad = 1;       if (bad) {         cout << -1 <<   n ;         continue;         ;       }       for (int i = 0; i <= len; i++)         for (int j = 0; j <= len; j++) dp[i][j] = INF;       memset(have_s, 0, sizeof(have_s));       memset(have_t, 0, sizeof(have_t));       for (char c =  a ; c <=  z ; c++) {         for (int i = 0; i < len; i++) {           have_s[c -  a ][i] = (c == second[i]);           have_t[c -  a ][i] = (c == t[i]);         }         for (int i = 1; i < len; i++) {           have_s[c -  a ][i] += have_s[c -  a ][i - 1];           have_t[c -  a ][i] += have_t[c -  a ][i - 1];         }       }       for (int i = 0; i <= len; i++) dp[0][i] = 0;       cout << go(len, len) <<   n ;     }   }
#include <bits/stdc++.h>   #pragma warning(disable : 4996)   using namespace std;   const int mod = 1e9 + 7;   const int maxn = 1e5 + 5;   int m, q;   int val[maxn], sum1[maxn], sum2[maxn], las[maxn], pre[maxn], fl[maxn],       res[maxn];   struct no {     int le, ri, id;   } qu[maxn];   bool cmp(no n1, no n2) { return n1.ri < n2.ri; }   void solve() {     int i;     scanf( %d , &m);     for (i = 1; i <= m; i++) {       scanf( %d , &val[i]);       pre[i] = las[val[i]];       las[val[i]] = i;       if (i - pre[i] == pre[i] - pre[pre[i]]) {         fl[i] = fl[pre[i]];       } else {         fl[i] = pre[pre[i]];       }     }     scanf( %d , &q);     for (i = 1; i <= q; i++) {       scanf( %d%d , &qu[i].le, &qu[i].ri);       qu[i].id = i;     }     sort(qu + 1, qu + q + 1, cmp);     int j, k = 1;     for (i = 1; i <= m; i++) {       if (i == 10) {         i++;         i--;       }       for (j = i; j; j -= (j & (-j))) {         sum1[j]++;       }       for (j = pre[i]; j; j -= (j & (-j))) {         sum1[j]--;       }       for (j = fl[i]; j; j -= (j & (-j))) {         sum2[j]++;       }       for (j = fl[pre[i]]; j; j -= (j & (-j))) {         sum2[j]--;       }       while (qu[k].ri == i && k <= q) {         int su1 = 0, su2 = 0;         for (j = qu[k].le; j <= i; j += (j & (-j))) {           su1 += sum1[j];           su2 += sum2[j];         }         res[qu[k].id] = su1 + (su1 == su2);         k++;       }     }     for (i = 1; i <= q; i++) {       printf( %d n , res[i]);     }   }   int main() {     solve();     return 0;   }
#include <bits/stdc++.h>   #define MOD 998244353   using namespace std;      #define rep(i, a, b) for(int i = a; i < (b); ++i)   #define rrep(i, a, b) for(int i = (a-1); i >= (b); --i)   #define trav(a, x) for(auto& a : x)   #define all(x) begin(x), end(x)   #define sz(x) (int)(x).size()   typedef long long ll;   typedef pair<int, int> pii;   typedef vector<int> vi;      void solve() {    int n;    cin >> n;    vector<vector<int>> a(2*n, vector<int>(n));    vector<vector<set<int>>> S(n, vector<set<int>>(n));    rep(i,0,2*n) {     rep(j,0,n) {      cin >> a[i][j];      --a[i][j];      S[j][a[i][j]].insert(i);     }    }    ll ans = 1;    vector<bool> used(2*n, false);    vector<int> side(2*n);    int I = 0;    while (true) {     bool any = false;     int r;     int i = I;     while (!any) {      rep(j,0,n) {       if (sz(S[i][j]) == 1) {        any = true;        r = *S[i][j].begin();        break;       }      }      if (any)       break;      i = (i+1)%n;      if (i == I)       break;     }     I = i;     if (!any) {      rep(i,0,2*n)       if (!used[i]) {        r = i;        any = true;       }      if (!any)       break;      ans = (ans*2) % MOD;     }     used[r] = true;     side[r] = 0;     set<int> toRemove;     rep(l,0,n) {      for (int k : S[l][a[r][l]]) {       toRemove.insert(k);      }     }     for (int k : toRemove) {      used[k] = true;      side[k] = k == r;      rep(l,0,n)       S[l][a[k][l]].erase(k);     }    }    cout << ans << endl;    rep(i,0,2*n) {     if (side[i] == 1) {      cout << i+1 <<    ;     }    }    cout << endl;   }      int main() {    cin.sync_with_stdio(0); cin.tie(0);    cin.exceptions(cin.failbit);    int t;    cin >> t;    while (t--)     solve();   }
#include <bits/stdc++.h>   using namespace std;   long long int gcd(long long int a, long long int b) {     if (b == 0) return a;     return gcd(b, a % b);   }   int main() {     vector<long long int> v1;     vector<long long int> v2;     long long int n, mo = 0, x, y, f;     scanf( %lld , &n);     for (long long int i = 0; i < n; i++) {       scanf( %lld , &f);       v1.push_back(f);     }     for (long long int i = 0; i < n; ++i) {       v2.push_back(v1[i]);       if (i + 1 == n) break;       x = v1[i], y = v1[i + 1];       if (x < y) swap(x, y);       if (gcd(x, y) != 1) {         mo++;         v2.push_back(1);       }     }     printf( %lld n , mo);     for (long long int i = 0; i < v2.size(); ++i) printf( %lld  , v2[i]);     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int d, n, m;   const int M = 2e5;   pair<int, int> gas[M + 7];   bool possible = true;   int pendingD, running;   int currentGas;   long long res = 0;   struct cmp {     bool operator()(int c1, int c2) {       if (gas[c1].second != gas[c2].second)         return gas[c1].second > gas[c2].second;       else         return gas[c1].first < gas[c2].first;     }   };   priority_queue<int, vector<int>, cmp> heap;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> d >> n >> m;     int r1, r2;     for (int i = 1; i <= m; i++) {       cin >> r1 >> r2;       gas[i] = {r1, r2};     }     sort(gas + 1, gas + m + 1);     gas[0] = {0, 0};     gas[m + 1] = {d, 0};     for (int i = 1; i <= m + 1; i++)       if (gas[i].first - gas[i - 1].first > n) {         possible = false;         break;       }     if (!possible) {       cout << -1;       exit(0);     }     pendingD = 0;     running = 1;     currentGas = 0;     while (pendingD <= m) {       for (int i = running; i <= m + 1; i++)         if (gas[i].first - gas[pendingD].first > n) {           running = i;           break;         } else {           heap.push(i);           if (gas[i].second < gas[pendingD].second) {             running = i + 1;             break;           }         }       while (heap.top() <= pendingD) heap.pop();       if (gas[heap.top()].second <= gas[pendingD].second) {         res += 1LL * gas[pendingD].second *                (gas[heap.top()].first - gas[pendingD].first - currentGas);         currentGas = 0;       } else {         res += 1LL * gas[pendingD].second * (n - currentGas);         currentGas = n - (gas[heap.top()].first - gas[pendingD].first);       }       pendingD = heap.top();       heap.pop();       running = max(running, pendingD + 1);     }     cout << res;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, sum = 0;     int num[1000];     int x, y;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> num[i];       sum += num[i];     }     cin >> x >> y;     int cur = 0;     for (int i = 1; i <= n; i++) {       if (cur >= x && cur <= y && (sum - cur) >= x && (sum - cur) <= y) {         cout << i << endl;         return 0;       }       cur += num[i];     }     cout << 0 << endl;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int a, b;     scanf( %d%d , &a, &b);     int c[3] = {0, 0, 0};     for (int i = 1; i <= 6; ++i) {       int d1 = abs(i - a), d2 = abs(i - b);       if (d1 < d2) c[0]++;       if (d1 == d2) c[1]++;       if (d1 > d2) c[2]++;     }     for (int i = 0; i < 3; ++i) {       printf( %d  , c[i]);     }   }   int main() {     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T, typename U>   inline void smin(T &a, const U &b) {     if (a > b) a = b;   }   template <typename T, typename U>   inline void smax(T &a, const U &b) {     if (a < b) a = b;   }   template <class T>   inline void gn(T &first) {     char c, sg = 0;     while (c = getchar(), (c >  9  || c <  0 ) && c !=  - )       ;     for ((c ==  -  ? sg = 1, c = getchar() : 0), first = 0; c >=  0  && c <=  9 ;          c = getchar())       first = (first << 1) + (first << 3) + c -  0 ;     if (sg) first = -first;   }   template <class T1, class T2>   inline void gn(T1 &x1, T2 &x2) {     gn(x1), gn(x2);   }   int power(int a, int b, int m, int ans = 1) {     for (; b; b >>= 1, a = 1LL * a * a % m)       if (b & 1) ans = 1LL * ans * a % m;     return ans;   }   const int mod = 1000000007;   int pt[100100], p2[100100];   int sum[100100], dp[100100], mn[100100], mx[100100];   char s[100100], t[100100];   int calc(char *s, int n) {     int ans = 0, val = 0, pre = 0;     for (int i = 0; i < n; i++) {       int v = (val + 4LL * pt[n - i - 1]) % mod;       if (s[i] ==  7 ) {         ans = (ans + (long long)v * v % mod * (p2[n - i - 1] - 1) +                (long long)v *                    (2LL * sum[n - i - 1] - mn[n - i - 1] - mx[n - i - 1]) +                dp[n - i - 1]) %               mod;         ans = (ans + mod) % mod;         if (pre)           ans = (ans + (long long)(pre + mx[n - i]) * (v + mn[n - i - 1])) % mod;       }       if (s[i] ==  7 )         pre = (val + 4LL * pt[n - i - 1]) % mod;       else if (pre)         pre = (pre + 7LL * pt[n - i - 1]) % mod;       val = (val + (long long)(s[i] -  0 ) * pt[n - i - 1]) % mod;     }     ans = (ans + (long long)val * pre) % mod;     return ans;   }   int main() {     scanf( %s %s , s, t);     int n = strlen(s);     for (int i = pt[0] = p2[0] = 1; i <= n; i++)       pt[i] = 10LL * pt[i - 1] % mod, p2[i] = p2[i - 1] * 2 % mod;     for (int i = 1; i <= n; i++) {       dp[i] =           ((long long)pt[i - 1] * pt[i - 1] % mod * (4 * 4 + 7 * 7) % mod *                (p2[i - 1] - 1) +            11LL * pt[i - 1] % mod * (2LL * sum[i - 1] - mn[i - 1] - mx[i - 1]) +            2LL * dp[i - 1] +            (4LL * pt[i - 1] + mx[i - 1]) % mod *                (7LL * pt[i - 1] % mod + mn[i - 1])) %           mod;       dp[i] = (dp[i] + mod) % mod;       mn[i] = (10LL * mn[i - 1] + 4) % mod;       mx[i] = (10LL * mx[i - 1] + 7) % mod;       sum[i] = (2LL * sum[i - 1] + 11LL * pt[i - 1] % mod * p2[i - 1]) % mod;     }     cout << (calc(t, n) - calc(s, n) + mod) % mod << endl;     return 0;   }