malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long n, m;     cin >> n >> m;     vector<vector<vector<long long>>> g(n);     vector<vector<long long>> store(m);     for (long long i = 0; i < m; i++) {       long long a, b, c;       cin >> a >> b >> c;       --a;       b--;       g[a].push_back({b, c});       g[b].push_back({a, c});       store[i] = {a, b, c};     }     long long s;     cin >> s;     s--;     vector<long long> d(n, LONG_LONG_MAX);     vector<long long> parent(n), dd(n, LONG_LONG_MAX);     for (long long i = 0; i < n; i++) {       parent[i] = i;     }     d[s] = dd[s] = 0;     set<pair<long long, long long>> q;     q.insert({d[s], s});     while (!q.empty()) {       long long v = q.begin()->second;       q.erase(q.begin());       for (long long i = 0; i < g[v].size(); i++) {         long long to = g[v][i][0], len = g[v][i][1];         if (d[v] + len < d[to]) {           if (q.find({d[to], to}) != q.end()) {             q.erase({d[to], to});           }           parent[to] = v;           d[to] = d[v] + len;           dd[to] = len;           q.insert(make_pair(d[to], to));         } else if (d[v] + len == d[to]) {           if (dd[to] > len) {             dd[to] = len;             parent[to] = v;           }         }       }     }     long long ans = 0;     for (long long i = 0; i < n; i++) {       ans += dd[i];     }     cout << ans << endl;     for (long long i = 0; i < m; i++) {       long long a = store[i][0];       long long b = store[i][1];       if (parent[a] == b || parent[b] == a) {         cout << i + 1 <<    ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   int main() {     cin >> n;     int cur = 1;     while (n) {       if (n == 3) {         printf( %d %d %d  , cur, cur, cur * n);         return 0;       }       int cnt = n / 2 + n % 2;       n -= cnt;       while (cnt--) printf( %d  , cur);       cur *= 2;     }   }
#include <bits/stdc++.h>   const int Max_N(1000005);   int N, D;   int first[Max_N], ecnt(1), Next[Max_N * 2], To[Max_N * 2];   int degree[Max_N];   std::tuple<int, int> dfs(const int v, const int p = 0) {     if (To[first[v]] == p && Next[first[v]] == 0) return std::make_tuple(0, 0);     int res(0), max(0), min(D + 1);     for (int e(first[v]); e; e = Next[e])       if (To[e] != p) {         int len(1);         auto tmp(dfs(To[e], v));         res += std::get<0>(tmp), len += std::get<1>(tmp);         if (len >= 0) {           if (len == D)             ++res;           else if (len * 2 > D)             min = std::min(min, len), ++res;           else             max = std::max(max, len);         }       }     if (max == 0 && min == D + 1) return std::make_tuple(res, -1);     return std::make_tuple(res - (max + min <= D), max + min <= D ? min : max);   }   int main(int argc, char **argv) {     scanf( %d %d , &N, &D);     int r;     for (int i(1), v, w; i != N; ++i) {       scanf( %d %d , &v, &w);       Next[ecnt] = first[v], To[ecnt] = w, first[v] = ecnt++;       Next[ecnt] = first[w], To[ecnt] = v, first[w] = ecnt++;       ++degree[v], ++degree[w];       if (degree[v] > 1) r = v;       if (degree[w] > 1) r = w;     }     auto res(dfs(r));     printf( %d , std::get<0>(res) + (std::get<1>(res) != -1));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mxn = 5e5 + 123;   const long long inf = 1e9;   const long long mod = 998244353;   bool om[mxn];   vector<long long> v;   long long n, mn = 1e18;   ;   int main() {     int n, m;     cin >> n >> m;     for (int i = 1; i <= n; i++)       if (n % i == 0) v.push_back(i);     for (int i = 0; i < v.size(); i++) {       if (n / v[i] < m) mn = min(mn, (v[i] * m) + (n / v[i]));     }     cout << mn;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long tmx(long long a, long long b, long long c) {     return (a > b && a > c) ? a : ((b > c) ? b : c);   }   inline long long tmn(long long a, long long b, long long c) {     return (a < b && a < c) ? a : ((b < c) ? b : c);   }   const int MXL = 0x3f3f3f3f;   string s[] = { Anka ,    Chapay ,  Cleo ,        Troll ,                  Dracul ,  Snowy ,   Hexadecimal };   inline int find(string x) {     for (int i = 0; i < 7; ++i)       if (s[i] == x) return i;   }   int n;   long long A, B, C;   int f[7][7] = {};   long long BE = (long long)MXL * MXL, AM = 0;   int c[7];   void dfs(int w) {     if (w == 7) {       int t[3] = {};       for (int i = 0; i < 7; ++i) ++t[c[i]];       if (!t[0] || !t[1] || !t[2]) return;       long long MX = tmx(A / t[0], B / t[1], C / t[2]);       long long MN = tmn(A / t[0], B / t[1], C / t[2]);       long long BE_N = MX - MN;       if (BE_N > BE) return;       long long AM_N = 0;       for (int i = 0; i < 7; ++i)         for (int j = 0; j < 7; ++j)           if (c[i] == c[j]) AM_N += f[i][j];       if (BE_N < BE || AM_N > AM) {         BE = BE_N;         AM = AM_N;       }       return;     }     for (int i = 0; i < 3; ++i) {       c[w] = i;       dfs(w + 1);     }   }   string L, R;   int LN, RN;   string like;   inline void EXEC() {     cin >> n;     for (int i = 0; i < n; ++i) {       cin >> L >> like >> R;       LN = find(L);       RN = find(R);       ++f[LN][RN];     }     cin >> A >> B >> C;     dfs(0);     cout << BE <<     << AM << endl;   }   int main() {     EXEC();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1000000007;   long long f = 0, g = 1;   int n;   int main() {     cin >> n;     for (int i = 2; i <= n; i++) {       long long k = f;       f = 3 * g % mod;       g = (k + 2 * g) % mod;     }     printf( %lld , f);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const long long LINF = 0x3f3f3f3f3f3f3f3fll;   void bad() {     cout <<  NO  <<   n ;     exit(0);   }   const int MAX = 4e5 + 10;   vector<int> g[MAX];   int main() {     if (!false) ios_base::sync_with_stdio(0);     cin.tie(0);     int n, d, k;     cin >> n >> d >> k;     if (d >= n or (n > 2 and k == 1)) bad();     int nxt = 0;     vector<int> pos_dist(n, -1);     stack<int> can;     for (nxt = 0; nxt <= d; nxt++) {       if (nxt < d) {         g[nxt].push_back(nxt + 1);         g[nxt + 1].push_back(nxt);       }       pos_dist[nxt] = min(nxt, d - nxt);       can.push(nxt);     }     while (nxt < n) {       if (false) cout <<  g  <<   n ;       for (int i = 0; i < n; i++) {         if (false) cout << i <<  :  ;         for (auto j : g[i])           if (false) cout << j <<    ;         if (false) cout <<   n ;       }       if (false) cout <<   n ;       if (can.empty()) bad();       int v = can.top();       if (g[v].size() == k or pos_dist[v] == 0) {         can.pop();         continue;       }       g[v].push_back(nxt);       g[nxt].push_back(v);       pos_dist[nxt] = pos_dist[v] - 1;       can.push(nxt);       nxt++;     }     set<pair<int, int>> stans;     cout <<  YES  <<   n ;     for (int i = 0; i < n; i++) {       for (auto j : g[i]) stans.insert({min(i, j) + 1, max(i, j) + 1});     }     for (auto [x, y] : stans) cout << x <<     << y <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 1e8;   struct node {     int x, y, z, s;   } pre[12][18][18][18];   int n, a, b, dp[12][18][18][18], h[12];   vector<int> ans;   void f(int i, int x, int y, int z, int v, int xx, int yy, int zz, int s) {     x = max(0, x);     y = max(0, y);     z = max(0, z);     if (dp[i][x][y][z] > v) {       dp[i][x][y][z] = v;       pre[i][x][y][z] = (node){xx, yy, zz, s};     }   }   void find(int i, int x, int y, int z) {     node tmp = pre[i][x][y][z];     int s = tmp.s;     for (int j = 0; j < s; j++) {       ans.push_back(i);     }     if (i == 2) {       return;     }     find(i - 1, tmp.x, tmp.y, tmp.z);   }   int main() {     scanf( %d%d%d , &n, &a, &b);     for (int i = 1; i <= n; i++) {       scanf( %d , &h[i]);       h[i]++;     }     for (int i = 0; i <= n; i++) {       for (int x = 0; x <= 16; x++) {         for (int y = 0; y <= 16; y++) {           for (int z = 0; z <= 16; z++) {             dp[i][x][y][z] = inf;           }         }       }     }     f(1, h[1], h[2], h[3], 0, 0, 0, 0, 0);     for (int i = 1; i < n - 1; i++) {       int z = h[i + 2];       for (int x = 0; x <= h[i]; x++) {         for (int y = 0; y <= h[i + 1]; y++) {           int v = dp[i][x][y][z];           if (v >= inf) {             continue;           }           for (int j = (x + b - 1) / b;; j++) {             f(i + 1, y - j * a, z - j * b, h[i + 3], v + j, x, y, z, j);             if (j * a > y && j * b > z) {               break;             }           }         }       }     }     find(n - 1, 0, 0, 0);     cout << ans.size() << endl;     for (int i = 0; i < ans.size(); i++) {       printf( %d  , ans[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, arr[2005], counts[2005];   char c =  a ;   int main() {     cin >> n;     for (int i = 0; i < n; i++) {       cin >> arr[i];     }     for (int i = n - 1; i >= 0; i--) {       counts[i] = arr[i];       if (arr[i] != 0) {         for (int j = i - 1; j >= 0; j--) {           arr[j] -= (i - j + 1) * arr[i];         }       }     }     for (int i = 1; i <= n; i++) {       for (int j = 0; j < counts[i - 1]; j++) {         for (int k = 0; k < i; k++) {           cout << c;         }         c = ((c ==  a ) ?  b  :  a );       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n, c = 0;       cin >> n;       int r = n;       int cnt = 0;       while (r > 0) {         int temp = r % 10;         if (temp > 0) cnt++;         r = r / 10;         c++;       }       cout << cnt << endl;       int it, ans;       for (int i = 0; i < c; i++) {         it = n % 10;         ans = it * pow(10, i);         if (ans > 0) cout << ans <<    ;         n = n / 10;       }       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   char A[102];   int M[102][205][3][52];   int dp(int i, int x, int d, int n) {     if (n < 0) return 0;     if (!A[i] && n == 0) return abs(x - 102);     if (!A[i]) return 0;     int &r = M[i][x][d == 1][n];     if (r == -1) {       if (A[i] ==  F ) {         r = max(dp(i + 1, x + d, d, n),                 max(max(dp(i, x, d, n - 2), dp(i + 1, x + d, d, n - 2)),                     dp(i + 1, x, d * -1, n - 1)));       } else {         r = max(dp(i + 1, x, d * -1, n),                 max(max(dp(i, x, d * -1, n - 2), dp(i + 1, x, d * -1, n - 2)),                     dp(i + 1, x + d, d, n - 1)));       }     }     return r;   }   int main() {     int n;     scanf( %s %d , A, &n);     memset(M, -1, sizeof(M));     printf( %d n , dp(0, 102, 1, n));   }
#include <bits/stdc++.h>   using namespace std;   long long n, s, k;   string u;   long long r[60], dp[2501][60];   signed main() {     cin >> n >> s >> k;     for (long long i = 0; i < n; ++i) cin >> r[i];     cin >> u;     for (long long i = 0; i < n; ++i)       for (long long j = 0; j < n; ++j) dp[i][j] = -1e18;     --s;     dp[0][s] = r[s];     for (long long i = 0; i < s; ++i) dp[s - i][i] = r[i];     for (long long i = s + 1; i < n; ++i) dp[i - s][i] = r[i];     for (long long i = 1; i <= 2500; ++i)       for (long long j = 0; j < n; ++j)         for (long long t = 1; t <= i; ++t) {           if (j - t >= 0 && u[j - t] != u[j] && r[j - t] < r[j])             dp[i][j] = max(dp[i][j], dp[i - t][j - t] + r[j]);           if (j + t < n && u[j + t] != u[j] && r[j + t] < r[j])             dp[i][j] = max(dp[i][j], dp[i - t][j + t] + r[j]);         }     for (long long i = 0; i < 2501; ++i)       for (long long j = 0; j < n; ++j)         if (dp[i][j] >= k) return cout << i, 0;     cout << -1;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e5 + 5;   const int MOD = 1e9 + 7.5;   char s[MAXN];   int f[MAXN], n;   int main() {     scanf( %s , s + 1);     n = strlen(s + 1);     int preb = 0;     for (int i = 1; i <= n; ++i) {       f[i] = f[i - 1];       if (s[i] ==  a ) {         f[i] = (f[i] + f[preb] + 1) % MOD;       } else if (s[i] ==  b ) {         preb = i;       }     }     cout << f[n] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N, C, cnt;   int A[33], P[33];   double dp[33][33][222], sol;   inline int f(int l, int r, int i) {     if (i < l || i > r) return i;     int ret = i - l + 1;     int len = r - l + 1;     ret = len - ret + 1;     ret = l + ret - 1;     return ret;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout << setprecision(15) << fixed;     cin >> N >> C;     for (int I = 1; I <= N; I++) cin >> A[I];     for (int I = 1; I <= N; I++)       for (int K = I + 1; K <= N; K++) dp[I][K][0] = 1;     for (int c = 1; c <= C; c++) {       for (int I = 1; I <= N; I++) {         for (int K = 1; K <= N; K++) {           for (int l = 1; l <= N; l++) {             for (int r = l; r <= N; r++) {               int pi = f(l, r, I);               int pk = f(l, r, K);               dp[I][K][c] += dp[pi][pk][c - 1];             }           }           dp[I][K][c] /= (N * (N - 1) / 2) + N;         }       }     }     for (int I = 1; I <= N; I++)       for (int K = 1; K <= N; K++)         if (A[I] > A[K]) {           sol += dp[I][K][C];         }     cout << sol << endl;   }
#include <bits/stdc++.h>   const int inf = INT_MAX;   const int MAX = 1e6 + 8;   const long long MOD = 998244353;   const int TOT_PRIMES = 1e6 + 9;   const int MAX_A = 71;   const int LN = 20;   using namespace std;   vector<int> adj[MAX];   int vis[MAX];   long long c = 0;   void dfs(int u) {     vis[u] = 1;     c = c + 1;     for (auto v : adj[u]) {       if (!vis[v]) {         dfs(v);       }     }   }   int main() {     int n;     cin >> n;     for (int i = 1; i <= n; i++) {       int x;       cin >> x;       adj[i].push_back(x);       adj[x].push_back(i);     }     vector<long long> res;     for (int i = 1; i <= n; i++) {       if (!vis[i]) {         dfs(i);         res.push_back(c);         c = 0;       }     }     sort(res.begin(), res.end());     long long ans = 0;     int m = res.size();     if (m == 1) {       cout << res[0] * res[0];       return 0;     }     ans = res[m - 1] + res[m - 2];     ans = ans * ans;     for (int i = 0; i < m - 2; i++) {       ans = ans + (res[i] * res[i]);     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O2 )   using namespace std;   long long mod = 1000000007;   void solve() {     long long n;     cin >> n;     long long a[n];     long long k0 = 0;     long long k1 = 0;     for (long long i = 0; i < n; i++) {       cin >> a[i];       if (a[i] == 0) k0++;       if (a[i] == 1) k1++;     }     long long ans = k1 * (pow(2, k0));     cout << ans << endl;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long t;     cin >> t;     while (t--) solve();   }
#include <bits/stdc++.h>   const long long inf = std::numeric_limits<long long>::max();   const int infint = std::numeric_limits<int>::max();   const long long mod = 1e9 + 7;   using namespace std;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   vector<int> g[500100];   long long a[500100];   long long par[500100][21];   void dfs(int v, int p) {     for (auto i : g[v]) {       if (i == p) continue;       dfs(i, v);       par[i][0] = v;     }   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     long long mn = inf;     for (int i = 0; i < n; i++) {       cin >> a[i];       mn = min(a[i], mn);     }     for (int i = 0; i < n - 1; i++) {       int x, y;       cin >> x >> y;       x--, y--;       g[x].push_back(y);       g[y].push_back(x);     }     for (int i = 0; i < n; i++) {       if (a[i] == mn) {         par[i][0] = i;         dfs(i, -1);         break;       }     }     long long w = 0;     for (int i = 1; i < 21; i++)       for (int j = 0; j < n; j++) par[j][i] = par[par[j][i - 1]][i - 1];     for (int i = 0; i < n; i++) {       if (a[i] == mn) continue;       long long now = inf;       for (int j = 0; j < 21; j++) {         now = min(now, a[par[i][j]] * (j + 1) + a[i]);       }       w += now;     }     cout << w;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename _T>   void read(_T &x) {     _T f = 1;     x = 0;     char s = getchar();     while (s >  9  || s <  0 ) {       if (s ==  - ) f = -1;       s = getchar();     }     while ( 0  <= s && s <=  9 ) {       x = (x << 3) + (x << 1) + (s ^ 48);       s = getchar();     }     x *= f;   }   struct ming {     long long typ, t, x, id, pos;   } a[100010];   long long n, ans[100010], num[100010];   vector<long long> vec;   long long cmp1(const ming &a, const ming &b) { return a.t < b.t; }   long long cmp2(const ming &a, const ming &b) { return a.id < b.id; }   void merge(long long l, long long r) {     if (l == r) return;     long long mid = l + r >> 1, j = l;     merge(l, mid);     merge(mid + 1, r);     sort(a + l, a + mid + 1, cmp1);     sort(a + mid + 1, a + r + 1, cmp1);     for (long long i = mid + 1; i <= r; i++) {       while (j <= mid && a[j].t <= a[i].t) num[a[j].pos] += a[j].typ, j++;       if (!a[i].typ) ans[a[i].id] += num[a[i].pos];     }     for (long long i = l; i < j; i++) num[a[i].pos] -= a[i].typ;   }   signed main() {     read(n);     for (long long i = 1; i <= n; i++) {       read(a[i].typ);       read(a[i].t);       read(a[i].x);       if (a[i].typ == 2) a[i].typ = -1;       if (a[i].typ == 3) a[i].typ = 0;       a[i].id = i;       vec.push_back(a[i].x);     }     sort(vec.begin(), vec.end());     vec.erase(unique(vec.begin(), vec.end()), vec.end());     for (long long i = 1; i <= n; i++)       a[i].pos = lower_bound(vec.begin(), vec.end(), a[i].x) - vec.begin() + 1;     merge(1, n);     sort(a + 1, a + n + 1, cmp2);     for (long long i = 1; i <= n; i++)       if (!a[i].typ) printf( %lld n , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n;     int x1, y1, x2, y2;     cin >> n;     long long ans = 0;     for (int i = 1; i <= n; i++) {       cin >> x1 >> y1 >> x2 >> y2;       ans += (long long)(x2 - x1 + 1) * (y2 - y1 + 1);     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1e13, Mo = 998244353;   const int N = 1000000;   const double eps = 1e-6;   namespace slow_IO {   long long read() {     long long x = 0;     int zf = 1;     char ch = getchar();     while (ch !=  -  && (ch <  0  || ch >  9 )) ch = getchar();     if (ch ==  - ) zf = -1, ch = getchar();     while (ch >=  0  && ch <=  9 ) x = x * 10 + ch -  0 , ch = getchar();     return x * zf;   }   void write(long long y) {     if (y < 0) putchar( - ), y = -y;     if (y > 9) write(y / 10);     putchar(y % 10 +  0 );   }   }  // namespace slow_IO   using namespace slow_IO;   vector<int> E1[N + 5], E2[N + 5];   int Flag1[N + 5], Flag2[N + 5];   int Ans[N + 5];   int ans = 0;   int main() {     int n = read(), m = read();     for (int i = (1); i <= (m); i++) {       int x = read(), y = read();       E1[x].push_back(y);       E2[y].push_back(x);     }     for (int i = (1); i <= (n); i++)       if (!Flag1[i]) {         Flag1[i] = Flag2[i] = 1;         for (int j = (0); j < (E1[i].size()); j++) Flag1[E1[i][j]] = 1;       }     for (int i = (n); i >= (1); i--)       if (Flag2[i]) {         for (int j = (0); j < (E2[i].size()); j++)           if (Flag2[E2[i][j]]) Flag2[i] = 0;       }     for (int i = (1); i <= (n); i++)       if (Flag2[i]) Ans[++ans] = i;     printf( %d n , ans);     for (int i = (1); i <= (ans); i++)       printf( %d%c , Ans[i], i == ans ?   n  :    );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 109;   int n;   int a[N];   map<int, int> m;   set<int> s[2];   int main() {     int n;     cin >> n;     for (int i = 0; i < n; ++i) {       cin >> a[i];       m[a[i]]++;     }     int pos = 0;     for (auto p : m)       if (p.second == 1) {         s[pos].insert(p.first);         pos = 1 - pos;       }     if (s[0].size() == s[1].size()) {       string res(n,  A );       for (int i = 0; i < n; ++i)         if (s[1].count(a[i])) res[i] =  B ;       cout <<  YES  << endl;       for (auto c : res) cout << c;       cout << endl;       return 0;     } else {       assert(int(s[0].size()) - 1 == int(s[1].size()));       string res(n,  A );       for (int i = 0; i < n; ++i)         if (s[1].count(a[i])) res[i] =  B ;       int id = -1;       for (auto p : m)         if (p.second >= 3) {           id = p.first;           break;         }       if (id == -1) {         cout <<  NO  << endl;         return 0;       }       bool flag = false;       for (int i = 0; i < n; ++i) {         if (a[i] == id)           if (!flag) {             flag = true;             res[i] =  B ;           }       }       cout <<  YES  << endl;       for (auto c : res) cout << c;       cout << endl;       return 0;     }     return 0;   }
#include <bits/stdc++.h>   bool comp(const int& a, const int& b) { return a < b ? false : true; }   using namespace std;   int main() {     long long int k, a, b, m, n;     cin >> k >> m >> n;     a = max(m, n);     b = min(m, n);     long long int ans = 0;     if (a > 0 && b > 0) {       ans = a / k - (b - 1) / k;     } else if (a < 0 && b < 0) {       ans = abs(b) / k - (abs(a) - 1) / k;     } else {       ans = abs(a) / k;       ans += (abs(b)) / k;       ans += 1;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2000 + 11;   const int MOD = 1e9 + 7;   int dp[N][2][2][N];   int m, d;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> m >> d;     string s1, s2;     cin >> s1 >> s2;     s1 =  .  + s1;     s2 =  .  + s2;     dp[0][0][0][0] = 1;     int n = s1.size() - 1;     for (int i = 1; i <= n; i++)       for (int d1 = 0; d1 <= 1; d1++)         for (int d2 = 0; d2 <= 1; d2++)           for (int mm = 0; mm < m; mm++) {             for (int x = 0; x <= 9; x++) {               if (d1 == 0 && x < s1[i] -  0 ) continue;               if (d2 == 0 && x > s2[i] -  0 ) continue;               if (i % 2 == 1 && x == d) continue;               if (i % 2 == 0 && x != d) continue;               int dd1 = d1, dd2 = d2, mmm = (mm * 10 + x) % m;               if (x > s1[i] -  0 ) dd1 = 1;               if (x < s2[i] -  0 ) dd2 = 1;               dp[i][dd1][dd2][mmm] =                   (dp[i][dd1][dd2][mmm] + dp[i - 1][d1][d2][mm]) % MOD;             }           }     int ans = 0;     for (int d1 = 0; d1 <= 1; d1++)       for (int d2 = 0; d2 <= 1; d2++) ans = (ans + dp[n][d1][d2][0]) % MOD;     cout << ans;   }