malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   const int INF_INT = 0x3f3f3f3f;   const long long INF_LL = 0x7f7f7f7f;   const int MOD = 1e9 + 7;   const double eps = 1e-10;   const double pi = acos(-1);   using namespace std;   const int N = 200200;   int n, m, q;   int u[N], v[N];   struct Query {     int l, r, s, t, id;     Query(int l, int r, int s, int t, int id) : l(l), r(r), s(s), t(t), id(id) {}     Query() {}     bool operator<(const Query& rhs) const { return l > rhs.l; }   };   vector<Query> qs;   int dp[1010][1010];   int ans[N];   int main(int argc, char const* argv[]) {     scanf( %d%d%d , &n, &m, &q);     for (int i = 1; i <= m; i++) scanf( %d%d , &u[i], &v[i]);     for (int i = 1; i <= q; i++) {       int l, r, s, t;       scanf( %d%d , &l, &r);       scanf( %d%d , &s, &t);       qs.emplace_back(l, r, s, t, i);     }     sort(qs.begin(), qs.end());     memset((dp), (INF_INT), sizeof(dp));     for (int i = 1; i <= n; i++) dp[i][i] = 0;     int cnt = 0;     for (int i = m; i >= 1; i--) {       dp[u[i]][v[i]] = dp[v[i]][u[i]] = i;       for (int j = 1; j <= n; j++) {         if (j != u[i]) dp[v[i]][j] = min(dp[v[i]][j], dp[u[i]][j]);         if (j != v[i]) dp[u[i]][j] = min(dp[u[i]][j], dp[v[i]][j]);       }       while (cnt < qs.size() && qs[cnt].l >= i) {         ans[qs[cnt].id] = dp[qs[cnt].s][qs[cnt].t] <= qs[cnt].r;         cnt++;       }     }     for (int i = 1; i <= q; i++) puts(ans[i] ?  Yes  :  No );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool deb = false;   int n;   vector<int> p, b;   void init() {     if (!deb) return;     p.resize(n);     for (auto& x : p) cin >> x;     b.resize(n);     for (int i = 0; i < n; ++i) b[p[i]] = i;   }   int get(int i, int j) {     if (deb) return p[i] ^ b[j];     cout <<  ?   << i <<     << j << endl;     int x;     cin >> x;     if (x == -1) exit(0);     return x;   }   void ans(int cnt, vector<int> p) {     cout <<  ! n ;     cout << cnt << endl;     for (int x : p) cout << x <<    ;     cout << endl;   }   int main() {     cin >> n;     init();     vector<int> a(n);     for (int i = 0; i < n; ++i) a[i] = get(0, i);     vector<int> x(n);     for (int i = 0; i < n; ++i) x[i] = get(i, 0);     int cnt = 0;     vector<int> pans;     for (int i = 0; i < n; ++i) {       vector<int> b(n);       for (int j = 0; j < n; ++j) b[j] = i ^ a[j];       vector<int> arr(n);       for (int i : b)         if (i < n) ++arr[i];       if (count(arr.begin(), arr.end(), 1) != n) continue;       vector<int> p(n);       for (int j = 0; j < n; ++j) p[b[j]] = j;       bool f = true;       for (int j = 0; j < n; ++j)         if ((p[j] ^ b[0]) != x[j]) f = false;       if (f) ++cnt, pans = p;     }     ans(cnt, pans);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     int n, k;     while (cin >> n >> k) {       int r = n, l = 1;       cout << l;       l++;       for (int i = 1; i < k; i++)         if (i % 2) {           cout <<     << r;           r--;         } else {           cout <<     << l;           l++;         }       if (k % 2)         for (int i = k; i < n; i++, l++) cout <<     << l;       else         for (int i = k; i < n; i++, r--) cout <<     << r;       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   long long m[1000005], n[1000005], w[1000005];   int main() {     long long a, b, c;     char ch[10];     while ((scanf( %lld%lld%lld , &a, &b, &c)) != EOF) {       long long t;       scanf( %lld , &t);       long long p = 0, q = 0, r, sum1 = 0, sum2 = 0, f;       for (int i = 0; i < t; i++) {         scanf( %lld , &f);         scanf( %s , ch);         if (ch[0] ==  U )           m[p++] = f;         else           n[q++] = f;       }       sort(m, m + p);       sort(n, n + q);       long long i, j;       long long l = 0;       for (i = 0; i < a && i < p; i++) {         sum2 += m[i];         sum1++;       }       while (m[i]) {         w[l++] = m[i++];       }       for (i = 0; i < b && i < q; i++) {         sum2 += n[i];         sum1++;       }       while (n[i]) w[l++] = n[i++];       sort(w, w + l);       for (int i = 0; i < c && i < l; i++) {         sum2 += w[i];         sum1++;       }       printf( %lld %lld n , sum1, sum2);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   char s[25][25];   int c[25][25];   int chs[1 << 21];   int dp[1 << 21];   vector<int> hv;   int main() {     scanf( %d%d , &n, &m);     for (int i = 0; i < n; ++i) {       scanf( %s , s[i]);     }     for (int i = 0; i < n; ++i) {       for (int j = 0; j < m; ++j) {         scanf( %d , c[i] + j);       }     }     memset(chs, 0x3f, sizeof(chs));     for (int i = 0; i < n; ++i) {       hv.push_back(1 << i);       for (int j = 0; j < m; ++j) {         chs[1 << i] = min(chs[1 << i], c[i][j]);       }     }     for (int i = 0; i < m; ++i) {       for (int j = 0; j < 26; ++j) {         int num = 0, maxx = 0, sum = 0;         for (int k = 0; k < n; ++k) {           if (s[k][i] == j +  a ) {             num |= 1 << k;             maxx = max(maxx, c[k][i]);             sum += c[k][i];           }         }         if (!num) {           continue;         }         if (chs[num] == 0x3f3f3f3f) {           hv.push_back(num);         }         chs[num] = min(chs[num], sum - maxx);       }     }     memset(dp, 0x3f, sizeof(dp));     dp[0] = 0;     for (int i = 0; i < (1 << n) - 1; ++i) {       for (int j : hv) {         dp[i | j] = min(dp[i | j], dp[i] + chs[j]);       }     }     printf( %d n , dp[(1 << n) - 1]);     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize(2)   using namespace std;   const long long mod = 998244353;   const long long maxn = 3e5 + 10;   long long p[2] = {1000000007, 998244353};   long long seed[2] = {500000004, 500000004};   int main() {     int x, a[6];     scanf( %d , &x);     for (int i = 0; i < 6; i++)       if (x & (1 << i))         a[i] = 1;       else         a[i] = 0;     swap(a[0], a[4]);     swap(a[2], a[3]);     int y = 0;     for (int i = 0; i < 6; i++)       if (a[i]) y += 1 << i;     printf( %d n , y);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int n;   long long int u;   string s;   int q;   int count(long long int number) {     if (!number) return 0;     int result = 0;     while (number % 2 == 0) {       result++;       number >>= 1;     }     return result;   }   long long int solve(long long int start, string s) {     int tmp = count(n + 1) - 1;     for (int i = 0; i < s.size(); ++i) {       int zeros = count(start);       long long int total = ((long long int)1 << (zeros + 1)) - 1;       if (s[i] ==  U ) {         if (zeros < tmp) {           long long int tmp_one = start + (total - 1) / 2 + 1;           long long int tmp_two = start - (total - 1) / 2 - 1;           if (count(tmp_one) == zeros + 1) {             start = tmp_one;           } else             start = tmp_two;         }       } else {         if (s[i] ==  L ) {           if (zeros) {             long long int left = (total - 1) / 2;             start = start - left + ((left - 1) / 2);           }         } else {           if (s[i] ==  R ) {             if (zeros) {               long long int right = (total - 1) / 2;               start = start + (right - 1) / 2 + 1;             }           }         }       }     }     return start;   }   int main() {     cin >> n >> q;     for (int i = 0; i < q; ++i) {       cin >> u >> s;       cout << solve(u, s) << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int boss = 2e5;   map<int, int> used;   queue<int> q;   int n, k, c[2], a[boss + 10];   int main() {     int i, answer = 0;     cin >> n >> k;     for (i = 1; i <= n; i++) {       scanf( %d , &a[i]);       if (used[a[i]] || c[a[i] % 2] == n / 2)         q.push(i);       else         used[a[i]] = 1, c[a[i] % 2]++;     }     for (i = 1; i <= k && !q.empty(); i++) {       if (used[i]) continue;       if (c[i % 2] < n / 2) {         c[i % 2]++;         answer++;         a[q.front()] = i;         q.pop();       }     }     if (!q.empty())       return printf( -1 ), 0;     else {       cout << answer << endl;       for (i = 1; i <= n; i++) printf( %d  , a[i]);     }   }
#include <bits/stdc++.h>   using namespace std;   const int mx = 2e5 + 10;   int main() {     int n, arr[mx], temp, z = 0;     queue<int> visit;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d , &arr[i]);       if (arr[i] == 0) visit.push(i);     }     temp = visit.front();     visit.pop();     for (int i = 0; i < n; i++) {       if (arr[i] != 0) {         if (visit.size() > 0) {           if (abs(visit.front() - i) < abs(i - temp)) {             temp = visit.front();             visit.pop();           }         }         printf( %d , abs(i - temp));       } else {         if (i != n - 1) {           if (arr[i + 1] == 0) {             temp = visit.front();             visit.pop();           }         }         printf( 0 );       }       if (i != n - 1) printf(   );     }   }
#include <bits/stdc++.h>   using namespace std;   template <typename T> inline int len(const T &a) { return a.size(); }      int main() {    ios_base::sync_with_stdio(false);    cin.tie(nullptr);    int tc;    cin >> tc;    while (tc--) {     int n, m;     cin >> n >> m;     vector<int> k(n);     vector<int> c(m);     for (auto &i : k) {      cin >> i;      --i;     }     for (auto &i : c) {      cin >> i;     }          sort(k.rbegin(), k.rend());     int ptr = 0;     long long ans = 0;     for (int i = 0; i < n; ++i) {      if (ptr > k[i] || c[k[i]] == c[ptr]) {       ans += c[k[i]];      } else {       ans += c[ptr++];      }     }          cout << ans <<   n ;    }    return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 610001;   const long long inf = (long long)5e16;   struct node {     long long val, id;   };   node a[N], b[N];   bool cmp(node x, node y) {     if (x.val == y.val) return x.id < y.id;     return x.val < y.val;   }   long long n, m, ans[N], pos[N];   signed main() {     scanf( %lld%lld , &m, &n);     for (long long i = 1; i <= n; i++) {       scanf( %lld , &a[i].val);       a[i].id = i;     }     for (long long i = n + 1; i <= n + n; i++) {       scanf( %lld , &b[i].val);       b[i].id = i - n;       b[i + n].val = b[i].val + m;       b[i + n].id = i - n;       b[i - n].val = b[i].val - m;       b[i - n].id = i - n;     }     sort(a + 1, a + n + 1, cmp);     sort(b + 1, b + 3 * n + 1, cmp);     for (long long i = 1, j = 1; i <= n; i++) {       while (a[i].val >= b[j].val && j <= 3 * n) j++;       ans[0] += a[i].val;       ans[j - i + 1] -= (a[i].val + a[i].val);     }     for (long long i = 1, j = 1; j <= 3 * n; j++) {       ans[max(j - n + 1, 0LL)] -= b[j].val;       while (b[j].val > a[i].val && i <= n) i++;       ans[j - i + 2] += b[j].val + b[j].val;       ans[j + 1] -= b[j].val;     }     long long sum = ans[0], id = 0, mi = inf;     for (long long i = 1; i <= 2 * n + 1; i++) {       sum += ans[i];       ans[i] += ans[i - 1];       if (mi > sum) {         mi = sum;         id = i;       }     }     cout << mi << endl;     for (long long i = 1; i <= n; i++) pos[a[i].id] = b[i + id - 1].id;     for (long long i = 1; i <= n; i++) printf( %d  , pos[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int k, n, a;   int d[1001];   bool vis[1001], flag;   int main() {     scanf( %d%d , &n, &k);     int cut = 0;     for (int i = 2; i <= k; i++) {       if (k % i) continue;       int crt = 1;       while (k % i == 0) {         crt *= i;         k /= i;       }       d[cut++] = crt;     }     for (int i = 0; i < n; i++) {       scanf( %d , &a);       for (int j = 0; j < cut; j++) {         if (a % d[j] == 0) {           vis[j] = true;         }       }     }     flag = true;     for (int j = 0; j < cut; j++) {       flag &= vis[j];     }     if (flag)       printf( Yes n );     else       printf( No n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int dx[] = {0, 1, -1, 0, 0};   const int dy[] = {0, 0, 0, 1, -1};   struct MinCostMaxFlow {     int head[20010], total;     int next[1000010], aim[1000010], flow[1000010], cost[1000010];     int f[20010], from[20010], p[20010];     bool v[20010];     MinCostMaxFlow() : total(1) {}     void Add(int x, int y, int f, int c) {       next[++total] = head[x];       aim[total] = y;       flow[total] = f;       cost[total] = c;       head[x] = total;     }     void Insert(int x, int y, int f, int c) {       Add(x, y, f, c);       Add(y, x, 0, -c);     }     bool SPFA() {       static queue<int> q;       while (!q.empty()) q.pop();       memset(f, 0x3f, sizeof(f));       memset(v, false, sizeof(v));       f[0] = 0;       q.push(0);       while (!q.empty()) {         int x = q.front();         q.pop();         v[x] = false;         for (int i = head[x]; i; i = next[i])           if (flow[i] && f[aim[i]] > f[x] + cost[i]) {             f[aim[i]] = f[x] + cost[i];             if (!v[aim[i]]) v[aim[i]] = true, q.push(aim[i]);             from[aim[i]] = x;             p[aim[i]] = i;           }       }       return f[(20010 - 1)] != 0x3f3f3f3f;     }     int EdmondsKarp() {       int re = 0;       while (SPFA()) {         int max_flow = 0x3f3f3f3f;         for (int i = (20010 - 1); i != 0; i = from[i])           max_flow = ((max_flow) < (flow[p[i]]) ? (max_flow) : (flow[p[i]]));         for (int i = (20010 - 1); i != 0; i = from[i]) {           flow[p[i]] -= max_flow;           flow[p[i] ^ 1] += max_flow;         }         re += f[(20010 - 1)] * max_flow;       }       return re;     }   } solver;   int m, n;   int src[110][110];   int main() {     cin >> m >> n;     for (int i = 1; i <= m; ++i)       for (int j = 1; j <= n; ++j) scanf( %d , &src[i][j]);     for (int i = 1; i <= m; ++i)       for (int j = 1; j <= n; ++j) {         if (i + j & 1) {           solver.Insert(0, ((i - 1) * n + j), 1, 0);           for (int k = 1; k <= 4; ++k) {             int fx = i + dx[k], fy = j + dy[k];             if (!fx || !fy || fx > m || fy > n) continue;             solver.Insert(((i - 1) * n + j), ((fx - 1) * n + fy), 1,                           src[i][j] != src[fx][fy]);           }         } else           solver.Insert(((i - 1) * n + j), (20010 - 1), 1, 0);       }     cout << solver.EdmondsKarp() << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 2e5 + 51;   struct BIT {     int x[MAXN];     inline void add(int pos, int val);     inline int query(int pos);   };   BIT bit;   int n, tp, res, totd, r;   int x[MAXN], d[MAXN], st[MAXN], f[MAXN], g[MAXN];   long long int dsc[MAXN];   inline int read() {     register int num = 0, neg = 1;     register char ch = getchar();     while (!isdigit(ch) && ch !=  - ) {       ch = getchar();     }     if (ch ==  - ) {       neg = -1;       ch = getchar();     }     while (isdigit(ch)) {       num = (num << 3) + (num << 1) + (ch -  0 );       ch = getchar();     }     return num * neg;   }   inline void BIT::add(int pos, int val) {     for (; pos; pos -= pos & -pos) {       x[pos] = max(x[pos], val);     }   }   inline int BIT::query(int pos) {     int res = 0;     for (; pos <= totd; pos += pos & -pos) {       res = max(res, x[pos]);     }     return res;   }   int main() {     n = read();     for (register int i = 0; i <= n + 1; i++) {       x[i] = read();     }     for (register int i = 1; i <= n; i++) {       d[i] = read();     }     for (register int i = 1; i <= n; i++) {       while (tp && x[i] > (long long int)2 * d[st[tp]] + x[f[st[tp]]]) {         tp--;       }       f[i] = st[tp];       while (tp && (long long int)2 * d[i] + x[f[i]] >=                        (long long int)2 * d[st[tp]] + x[f[st[tp]]]) {         tp--;       }       st[++tp] = i;     }     st[tp = 0] = n + 1, res = x[n + 1];     for (register int i = n; i; i--) {       while (tp && x[i] < x[g[st[tp]]] - (long long int)2 * d[st[tp]]) {         tp--;       }       g[i] = st[tp];       while (tp && x[g[i]] - (long long int)2 * d[i] <=                        x[g[st[tp]]] - (long long int)2 * d[st[tp]]) {         tp--;       }       st[++tp] = i;     }     for (register int i = 1; i <= n; i++) {       if (x[g[i]] - x[f[i]] <= 2 * d[i]) {         return puts( 0 ), 0;       }     }     for (register int i = 1; i <= n; i++) {       res = min(res, x[g[i]] - x[f[i]]);       x[i] - x[f[i]] < (long long int)2 * d[i]           ? dsc[++totd] = (long long int)2 * d[i] + x[f[i]]           : 1;       f[i] == 0 && x[g[i]] - x[i] < (long long int)2 * d[i] ? res = min(res, x[i])                                                             : 1;       g[i] == n + 1 && x[i] - x[f[i]] < (long long int)2 * d[i]           ? res = min(res, x[n + 1] - x[i])           : 1;     }     sort(dsc + 1, dsc + totd + 1),         totd = unique(dsc + 1, dsc + totd + 1) - dsc - 1;     for (register int i = 1; i <= n; i++) {       if (x[g[i]] - x[i] < (long long int)2 * d[i]) {         r = lower_bound(dsc + 1, dsc + totd + 1,                         x[g[i]] - (long long int)2 * d[i]) -             dsc;         if (r = bit.query(r)) {           res = min(res, x[i] - r);         }       }       if (x[i] - x[f[i]] < (long long int)2 * d[i]) {         r = lower_bound(dsc + 1, dsc + totd + 1,                         x[f[i]] + (long long int)2 * d[i]) -             dsc;         bit.add(r, x[i]);       }     }     printf( %.1lf n , res * 0.5);   }
#include <bits/stdc++.h>   using namespace std;   int T, N, M;   int A[300][300];   int dx[4] = {0, 1, 0, -1};   int dy[4] = {1, 0, -1, 0};   int main() {     scanf( %d , &T);     for (; T--;) {       scanf( %d%d , &N, &M);       bool ok = true;       for (int i = 0; i < N; i++)         for (int j = 0; j < M; j++) {           scanf( %d , &A[i][j]);           int cnt = 0;           for (int r = 0; r < 4; r++) {             int x = i + dx[r], y = j + dy[r];             if (0 <= x && x < N && 0 <= y && y < M) cnt++;           }           if (A[i][j] > cnt)             ok = false;           else             A[i][j] = cnt;         }       if (ok) {         puts( YES );         for (int i = 0; i < N; i++) {           for (int j = 0; j < M; j++)             printf( %d%c , A[i][j], j + 1 == M ?   n  :    );         }       } else         puts( NO );     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int r, g, b, w;       cin >> r >> g >> b >> w;       int count = 0;       if (r % 2) count++;       if (g % 2) count++;       if (b % 2) count++;       int m = min(r, min(g, b));       bool flag;       if (count == 0)         flag = true;       else if (count == 1) {         if (w % 2 == 0)           flag = true;         else           flag = false;       } else if (count == 2) {         if (w % 2 == 0)           flag = false;         else if (m > 0)           flag = true;         else           flag = false;       } else {         flag = true;       }       if (flag)         cout <<  Yes n ;       else         cout <<  No n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 55;   int n, k, dp[N][N];   long long a[N], sum[N], dq;   int main() {     scanf( %d%d , &n, &k);     for (int i = 1; i <= n; i++) scanf( %lld , &a[i]);     for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + a[i];     for (int i = 60; i >= 0; i--) {       dq |= (long long)1 << i;       dp[0][0] = 1;       for (int j = 1; j <= n; j++)         for (int l = 1; l <= k; l++) {           dp[j][l] = 0;           for (int o = j - 1; o >= 0; o--)             if (((sum[j] - sum[o]) & dq) == dq) dp[j][l] |= dp[o][l - 1];         }       if (!dp[n][k]) dq ^= (long long)1 << i;     }     printf( %lld , dq);   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int n;     cin >> n;     vector<vector<int>> a(5, vector<int>(n));     for (int i = 0; i < n; i++) {       string s;       cin >> s;       vector<int> aa(5);       for (int j = 0; j < s.size(); j++) {         aa[s[j] -  a ]++;       }       for (int j = 0; j < 5; j++) {         a[j][i] = 2 * aa[j] - s.size();       }     }     int ans = 0;     for (int i = 0; i < 5; i++) {       sort(a[i].begin(), a[i].end(), greater<int>());       long long sum = 0;       int j = 0;       for (; j < n; j++) {         sum += a[i][j];         if (sum <= 0) {           break;         }       }       ans = max(j, ans);     }     cout << ans <<   n ;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int t;     cin >> t;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1e9 + 7;   long long n, n2 = 1, a[5010], dat[20010], ans = 0;   vector<long long> v, vv[5010];   map<long long, long long> mp;   void build(long long k, long long lb, long long ub) {     if (lb == ub) return;     build(k * 2 + 1, lb, (lb + ub) / 2);     build(k * 2 + 2, (lb + ub) / 2 + 1, ub);     dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);   }   long long query(long long k, long long lb, long long ub, long long tlb,                   long long tub) {     if (ub < tlb || tub < lb) return 2e9;     if (tlb <= lb && ub <= tub) return dat[k];     return min(query(k * 2 + 1, lb, (lb + ub) / 2, tlb, tub),                query(k * 2 + 2, (lb + ub) / 2 + 1, ub, tlb, tub));   }   long long dfs(long long lb, long long ub, long long lst) {     if (lb > ub) return 0;     long long ret = ub - lb + 1, mn = query(0, 0, n2 - 1, lb, ub), res = mn - lst;     long long num = mp[mn],               pos = lower_bound(vv[num].begin(), vv[num].end(), lb) -                     vv[num].begin(),               pos2 = lower_bound(vv[num].begin(), vv[num].end(), ub + 1) -                      vv[num].begin() - 1;     for (long long i = pos; i < pos2; i++)       res += dfs(vv[num][i] + 1, vv[num][i + 1] - 1, mn);     res += dfs(lb, vv[num][pos] - 1, mn) + dfs(vv[num][pos2] + 1, ub, mn);     ret = min(ret, res);     return ret;   }   int main() {     cin >> n;     for (int i = 0; i < n; i++) {       scanf( %I64d , &a[i]);       v.push_back(a[i]);     }     sort(v.begin(), v.end());     v.erase(unique(v.begin(), v.end()), v.end());     for (int i = 0; i < v.size(); i++) mp[v[i]] = i;     for (int i = 0; i < n; i++) vv[mp[a[i]]].push_back(i);     while (n2 < n) n2 *= 2;     for (int i = 0; i < 20005; i++) dat[i] = 1e18;     for (int i = 0; i < n; i++) dat[i + n2 - 1] = a[i];     build(0, 0, n2 - 1);     cout << dfs(0, n - 1, 0) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;      typedef long long ll;   typedef pair<int, int> pii;   #define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)   #define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)   #define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)   template<class T, class U> void umin(T& x, const U& y){ x = min(x, (T)y);}   template<class T, class U> void umax(T& x, const U& y){ x = max(x, (T)y);}   template<class T, class U> void init(vector<T> &v, U x, size_t n) { v=vector<T>(n, (T)x); }   template<class T, class U, typename... W> void init(vector<T> &v, U x, size_t n, W... m) { v=vector<T>(n);  for(auto& a : v) init(a, x, m...); }      const int m = 2e5;   const ll MOD = 1e9+7;   int dp[10][m+1];   int main(int argc, char** argv) {       ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);       if (argc == 2 && atoi(argv[1]) == 123456789) freopen( d:  code  cpp  contests  stdin ,  r , stdin);       int T = 1;       cin >> T;          FOR(x, 10) dp[x][0] = 1;       FOR1(i, m){           FOR(x, 9){               dp[x][i] = dp[x+1][i-1];           }           dp[9][i] = (dp[1][i-1] + dp[0][i-1]) % MOD;       }          FOR1(t, T){           int n, m;           cin >> n >> m;           ll sol = 0;           while(n){               int d = n%10;               sol += dp[d][m];               n /= 10;           }           sol %= MOD;           cout << sol << endl;       }       if (argc == 2 && atoi(argv[1]) == 123456789) cout << clock()*1.0/CLOCKS_PER_SEC <<   sec n ;       return 0;   }