malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int col[5001], mid, n, dis[5001][5001], ans;   bool v[5001];   long long mod = 1e9 + 7;   bool dfs(int x) {     v[x] = 1;     for (int i = 1; i <= n; ++i)       if (i != x && dis[x][i] > mid)         if (!v[i]) {           col[i] = col[x] ^ 1;           if (dfs(i)) return 1;         } else if (col[x] == col[i])           return 1;     return 0;   }   bool check() {     memset(v, 0, sizeof(v));     for (int i = 1; i <= n; ++i)       if (!v[i])         if (dfs(i)) return 0;     return 1;   }   void dfss(int x) {     v[x] = 1;     for (int i = 1; i <= n; ++i)       if (!v[i] && dis[x][i] > ans) dfss(i);   }   long long mult(long long x, long long y) {     long long res = x * 1ll;     y--;     while (y) {       if (y & 1) res = res * x % mod;       x = x * x % mod;       y >>= 1;     }     return res;   }   int cnt, x[5001], y[5001];   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i) scanf( %d%d , &x[i], &y[i]);     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= n; ++j)         dis[i][j] = abs(x[i] - x[j]) + abs(y[i] - y[j]);     int l = 0, r = 10000;     while (l <= r) {       mid = l + r >> 1;       if (check()) {         ans = mid;         r = mid - 1;       } else         l = mid + 1;     }     memset(v, 0, sizeof(v));     printf( %d n , ans);     for (int i = 1; i <= n; ++i)       if (!v[i]) {         ++cnt;         dfss(i);       }     printf( %I64d , mult(2ll, (long long)cnt));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 200 * 1000 + 13;   const long long INF64 = 1e18;   int n, m;   long long a[N];   vector<pair<int, long long>> g[N];   long long dist[N];   void Dijkstra() {     set<pair<long long, int>> q;     for (int i = 0; i < int(n); i++) {       dist[i] = a[i];       q.insert({dist[i], i});     }     while (!q.empty()) {       int v = q.begin()->second;       q.erase(q.begin());       for (auto it : g[v]) {         int u = it.first;         long long w = it.second;         if (dist[u] > dist[v] + w) {           q.erase({dist[u], u});           dist[u] = dist[v] + w;           q.insert({dist[u], u});         }       }     }   }   int main() {     scanf( %d%d , &n, &m);     for (int _ = 0; _ < int(m); _++) {       int f, t;       long long w;       scanf( %d%d%lld , &f, &t, &w);       --f, --t;       w *= 2;       g[f].push_back({t, w});       g[t].push_back({f, w});     }     for (int i = 0; i < int(n); i++) {       scanf( %lld , &a[i]);     }     Dijkstra();     for (int i = 0; i < int(n); i++) printf( %lld  , dist[i]);     puts(  );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int _ = 2e2 + 20;   int n;   struct matrix {     double a[_][_];     matrix operator*(matrix b) {       matrix c;       for (int i = 0; i <= n * 2; ++i)         for (int j = 0; j <= n * 2; ++j) {           c.a[i][j] = 0;           for (int k = 0; k <= n * 2; ++k)             c.a[i][j] = max(c.a[i][j], a[i][k] + b.a[k][j]);           c.a[i][j] /= 2;         }       return c;     }   } A;   double a[_];   int main() {     cin >> n;     for (int i = 0; i <= n; ++i) cin >> a[i];     for (int i = 0; i <= n * 2; ++i) {       for (int j = 0; j <= n * 2; ++j) {         if (i + j >= n && (i + n - j & 1) == 0 && i - j <= n && j - i <= n)           A.a[i][j] = a[(i + n - j) / 2];         else           A.a[i][j] = -1e18;       }     }     double ans = 0;     for (int i = 1; i <= 50; ++i) A = A * A;     for (int i = 0; i <= n * 2; ++i) ans = max(ans, A.a[0][i]);     printf( %.10f n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3000010;   const int inf = 1e9 + 1;   int n, k, a[N], b[N];   bool check(long long x) {     long long s = 0;     for (int i = 1; i <= n; i++) {       long long tmp = b[i] - a[i] * x;       if (tmp < 0) {         s -= tmp;       }       if (s > k) return false;     }     return (s <= k);   }   int main() {     scanf( %d%d , &n, &k);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     for (int i = 1; i <= n; i++) scanf( %d , &b[i]);     long long l = 0, r = 2e9;     while (l + 1 < r) {       long long m = (l + r) / 2;       if (check(m))         l = m;       else         r = m - 1;     }     if (check(r))       cout << r;     else       cout << l;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     cin >> s;     stack<char> stk;     int cnt = 0;     for (int i = s.size() - 1; i >= 0; i--) {       if (stk.empty())         stk.push(s[i]);       else {         if (stk.top() == s[i]) {           cnt++;           stk.pop();         } else           stk.push(s[i]);       }     }     cout << (cnt & 1 ?  Yes  :  No ) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     long long a[n];     for (long long i = 0; i <= n - 1; i++) cin >> a[i];     for (long long i = 0; i <= n - 1; i++)       if ((a[i] % 2)) a[i] += 1;     for (long long i = 0; i <= n - 1; i++)       if (!(a[i] % 2)) a[i] -= 1;     for (long long i = 0; i <= n - 1; i++) cout << a[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void File_input() {     freopen( in.txt ,  r , stdin);     freopen( out.txt ,  w , stdout);   }   void FastInputOutput() {     ios_base ::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);   }   vector<char> geno[ z  + 1];   int t, n;   string str;   bool vis[ z  + 1], in[ z  + 1];   int indeg[ z  + 1];   void DFS(char a) {     cout << a;     for (auto i : geno[a]) {       if (!vis[i]) {         vis[i] = 1;         DFS(i);       }     }   }   int main() {     cin >> t;     while (t--) {       cin >> str;       n = (long long)str.size();       for (int i = 0; i < n; i++) in[str[i]] = 1;       for (int i = 1; i < n; i++) {         geno[str[i - 1]].push_back(str[i]);         indeg[str[i]]++;       }     }     for (char a =  a ; a <=  z ; a++) {       if (!vis[a] && in[a] && !indeg[a]) {         DFS(a);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double distance(double x1, double y1, double x2, double y2) {     return sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));   }   int main() {     double ax, ay, bx, by, tx, ty;     scanf( %lf%lf%lf%lf%lf%lf , &ax, &ay, &bx, &by, &tx, &ty);     int n;     scanf( %d , &n);     double cdist[n], D = 0;     pair<double, double> p[n];     for (int i = 0; i < n; ++i) {       scanf( %lf%lf , &p[i].first, &p[i].second);       cdist[i] = distance(tx, ty, p[i].first, p[i].second);       D += 2 * cdist[i];     }     set<pair<double, int> > A, B;     double distA[n], distB[n];     for (int i = 0; i < n; ++i) {       double x = -cdist[i] + distance(ax, ay, p[i].first, p[i].second);       distA[i] = x;       A.insert({x, i});       x = -cdist[i] + distance(bx, by, p[i].first, p[i].second);       distB[i] = x;       B.insert({x, i});     }     double temp1 = D + A.begin()->first;     double temp2 = D + B.begin()->first;     double temp3 = D + A.begin()->first;     int idx = A.begin()->second;     B.erase({distB[idx], idx});     if (not B.empty()) temp3 += B.begin()->first;     B.insert({distB[idx], idx});     double temp4 = D + B.begin()->first;     idx = B.begin()->second;     A.erase({distA[idx], idx});     if (not A.empty()) temp4 += A.begin()->first;     double ans = min(min(temp1, temp2), min(temp3, temp4));     printf( %lf n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct Activity {     int gym, contest;     bool gym_used, contest_used;   };   int main() {     int n;     cin >> n;     vector<int> v(n);     for (int &e : v) cin >> e;     vector<Activity> res(n);     switch (v[0]) {       case 0:         res[0].gym = res[0].contest = 0;         res[0].gym_used = res[0].contest_used = false;         break;       case 1:         res[0].gym = 0;         res[0].contest = 1;         res[0].gym_used = false;         res[0].contest_used = true;         break;       case 2:         res[0].gym = 1;         res[0].contest = 0;         res[0].gym_used = true;         res[0].contest_used = false;         break;       case 3:         res[0].gym = res[0].contest = 1;         res[0].gym_used = res[0].contest_used = true;         break;     }     for (int i = 1; i < v.size(); i++) {       if (v[i] == 1) {         res[i] = res[i - 1];         res[i].contest_used = res[i].gym_used = false;       }       if (v[i] == 1 || v[i] == 3) {         if (res[i - 1].contest_used) {           if (res[i - 1].gym >= res[i - 1].contest) {             res[i].contest_used = true;             res[i].contest = res[i - 1].gym + 1;           } else {             res[i].contest_used = false;             res[i].contest = res[i - 1].contest;           }         } else {           res[i].contest_used = true;           res[i].contest = max(res[i - 1].gym, res[i - 1].contest) + 1;         }       }       if (v[i] == 0 || v[i] == 1) {         res[i].gym = res[i - 1].gym;         res[i].gym_used = false;       }       if (v[i] == 0 || v[i] == 2) {         res[i].contest = res[i - 1].contest;         res[i].contest_used = false;       }       if (v[i] == 2 || v[i] == 3) {         if (res[i - 1].gym_used) {           if (res[i - 1].contest >= res[i - 1].gym) {             res[i].gym_used = true;             res[i].gym = res[i - 1].contest + 1;           } else {             res[i].gym_used = false;             res[i].gym = res[i - 1].gym;           }         } else {           res[i].gym_used = true;           res[i].gym = max(res[i - 1].gym, res[i - 1].contest) + 1;         }       }     }     cout << n - max(res[n - 1].gym, res[n - 1].contest) << endl;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int a;     cin >> a;     int b[a];     for (int i = 0; i < a; i++) {       cin >> b[i];     }     int ind = 0;     for (int i = 0; i < a - 1; i++) {       if (b[i] > b[i + 1]) {         b[0] = b[0] - b[i] + b[i + 1];         if (b[0] < 0) {           cout <<  NO ;           return;         }       }     }     cout <<  YES ;   }   int main() {     int t;     cin >> t;     while (t--) {       solve();       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e6 + 60;   const int IN = 0;   const int AND = 1;   const int OR = 2;   const int XOR = 3;   const int NOT = 4;   struct Node {     int val, p1, p2;     int op;   } node[maxn];   int n, p1, p2;   string op;   bool change[maxn];   int eval(int cur) {     if (node[cur].op == IN) {       return node[cur].val;     }     if (node[cur].op == AND) {       return node[cur].val = (eval(node[cur].p1) & eval(node[cur].p2));     }     if (node[cur].op == OR) {       return node[cur].val = (eval(node[cur].p1) | eval(node[cur].p2));     }     if (node[cur].op == XOR) {       return node[cur].val = (eval(node[cur].p1) ^ eval(node[cur].p2));     }     if (node[cur].op == NOT) {       return node[cur].val = (!eval(node[cur].p1));     }   }   void process(int cur, int now) {     int l = node[cur].p1;     int r = node[cur].p2;     int vl = node[l].val;     int vr = node[r].val;     if (node[cur].op == IN) {       return;     } else if (node[cur].op == AND) {       if (vl == 0 && vr == 0) {         process(l, change[l] = 0);         process(r, change[r] = 0);       } else if (vl == 0 && vr == 1) {         process(l, change[l] = (now & 1));         process(r, change[r] = 0);       } else if (vl == 1 && vr == 0) {         process(l, change[l] = 0);         process(r, change[r] = (now & 1));       } else if (vl == 1 && vr == 1) {         process(l, change[l] = (now & 1));         process(r, change[r] = (now & 1));       }     } else if (node[cur].op == OR) {       if (vl == 0 && vr == 0) {         process(l, change[l] = (now & 1));         process(r, change[r] = (now & 1));       } else if (vl == 0 && vr == 1) {         process(l, change[l] = 0);         process(r, change[r] = (now & 1));       } else if (vl == 1 && vr == 0) {         process(l, change[l] = (now & 1));         process(r, change[r] = 0);       } else if (vl == 1 && vr == 1) {         process(l, change[l] = 0);         process(r, change[r] = 0);       }     } else if (node[cur].op == XOR) {       process(l, change[l] = (now & 1));       process(r, change[r] = (now & 1));     } else if (node[cur].op == NOT) {       process(l, change[l] = (now & 1));     }   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       cin >> op;       if (op ==  IN ) {         scanf( %d , &p1);         node[i] = {p1, 0, 0, IN};       } else if (op ==  NOT ) {         scanf( %d , &p1);         node[i] = {0, p1, 0, NOT};       } else if (op ==  AND ) {         scanf( %d%d , &p1, &p2);         node[i] = {0, p1, p2, AND};       } else if (op ==  OR ) {         scanf( %d%d , &p1, &p2);         node[i] = {0, p1, p2, OR};       } else if (op ==  XOR ) {         scanf( %d%d , &p1, &p2);         node[i] = {0, p1, p2, XOR};       }     }     eval(1);     process(1, 1);     for (int i = 1; i <= n; i++) {       if (node[i].op == IN) printf( %d , change[i] ^ node[1].val);     }   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = (long long)1e13 + 7LL;   int reqHigh[100100], grow[100100];   int n, nDay, allow, cut;   struct Tree {     int id;     long long finHigh, timeDie;     Tree() { id = finHigh = timeDie = 0; }     Tree(int id, long long x) {       this->id = id;       finHigh = x - 1LL * grow[id] * nDay;       timeDie = min((x + 1) / grow[id] + ((x + 1) % grow[id] > 0), nDay + 1LL);     }     void cutTree(void) {       finHigh += cut;       long long tmp = finHigh + 1LL * grow[id] * nDay + 1;       timeDie = min(tmp / grow[id] + (tmp % grow[id] > 0), nDay + 1LL);     }     bool needCut(void) const { return (finHigh < reqHigh[id]); }     bool operator>(const Tree &t) const {       if (timeDie != t.timeDie) return (timeDie < t.timeDie);       return (reqHigh[id] - finHigh > reqHigh[t.id] - t.finHigh);     }     bool operator<(const Tree &t) const { return (t > *this); }   };   void init(void) {     scanf( %d%d%d%d , &n, &nDay, &allow, &cut);     for (int i = (1), _b = (n); i <= _b; i = i + 1)       scanf( %d%d , &reqHigh[i], &grow[i]);   }   bool ok(long long x) {     priority_queue<Tree> q;     for (int i = (1), _b = (n); i <= _b; i = i + 1) q.push(Tree(i, x));     for (int i = (1), _b = (nDay); i <= _b; i = i + 1) {       Tree tmp = q.top();       q.pop();       if (tmp.timeDie <= i) return (false);       q.push(tmp);       int used = 0;       while (used < allow) {         Tree tmp = q.top();         q.pop();         if (!tmp.needCut()) return (true);         tmp.cutTree();         q.push(tmp);         used++;       }     }     Tree tmp = q.top();     q.pop();     return (!tmp.needCut());   }   long long process(void) {     long long L = 1;     long long R = INF;     while (true) {       if (L == R) return (R);       if (R - L == 1) return (ok(L) ? L : R);       long long M = (L + R) >> 1;       if (ok(M))         R = M;       else         L = M + 1;     }   }   int main(void) {     init();     cout << process() << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 105;   int n, m, grid[N][N];   int val[N][N];   bool vis[105][105];   int a[105];   int b[105];   int dp[105][105];   int tot;   int main() {     scanf( %d%d , &n, &m);     for (int i = 0; i < n; i++) scanf( %d , a + i), tot ^= a[i];     int tmp = 0;     for (int i = 0; i < m; i++) scanf( %d , b + i), tmp ^= b[i];     if (tot != tmp) return puts( NO );     for (int x = 0; x < 31; x++) {       for (int i = 0; i < n; i++) {         if (a[i] >> x & 1) {           bool f = false;           for (int j = 0; j < m; j++)             if (b[j] >> x & 1) {               grid[i][j] ^= (1 << x);               b[j] ^= (1 << x);               a[i] ^= (1 << x);               break;             }         }       }       int cnt = 0;       for (int j = 0; j < m; j++) cnt += (b[j] >> x & 1);       if (cnt & 1) return puts( NO );       for (int j = 0; j < m; j++)         if (b[j] >> x & 1) grid[0][j] ^= (1 << x), b[j] ^= (1 << x);     }     for (int x = 0; x < 31; x++) {       for (int j = 0; j < m; j++) {         if (b[j] >> x & 1) {           bool f = false;           for (int i = 0; i < n; i++)             if (a[i] >> x & 1) {               grid[i][j] ^= (1 << x);               b[j] ^= (1 << x);               a[i] ^= (1 << x);               break;             }         }       }       int cnt = 0;       for (int i = 0; i < n; i++) cnt += (a[i] >> x & 1);       if (cnt & 1) return puts( NO );       for (int i = 0; i < n; i++)         if (a[i] >> x & 1) grid[i][0] ^= (1 << x), a[i] ^= (1 << x);     }     puts( YES );     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) cout << grid[i][j] <<    ;       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main(int argc, char* argv[]) {     char str[105];     cin.getline(str, 104);     for (unsigned i = 1; i < strlen(str) + 1; i++) {       if ((str[i] == str[i - 1]) && (str[i - 1] ==  / )) {         for (unsigned j = i; j < strlen(str); j++) {           str[j] = str[j + 1];         }         i--;       }     }     if ((str[strlen(str) - 1] ==  / ) && (strlen(str) >= 2)) {       str[strlen(str) - 1] = 0;     }     cout << str << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = (int)1e9 + 7, mod = (int)1e9 + 9, pw = 31, N = (int)1e5 + 123,             M = (int)1e6 + 123;   const double eps = 1e-11;   const unsigned long long inf = 5e18 + 1;   unsigned long long n, a, b, x, m, ans;   bool check = 0;   unsigned long long binpow(unsigned long long a, unsigned long long b) {     unsigned long long rec = 0;     while (b) {       if (b % 2) {         rec = rec + a;         b--;       } else {         a = a + a;         b /= 2;       }       if (rec > n || a > n) {         check = 1;         return 0;       }     }     return rec;   }   long long gcd(long long x, long long y) { return (y ? gcd(y, x % y) : x); }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cin >> n >> a >> b;     ans = min(n, min(a, b) - 1);     m = binpow(a, b / gcd(a, b));     if (check) {       cout << ans / gcd(ans, n) <<  /  << n / gcd(ans, n);       return 0;     }     ans += ((n / m) - 1) * min(a, b);     ans += min((n / m) * m + min(a, b) - 1, n) - (n / m) * m + 1;     cout << ans / gcd(ans, n) <<  /  << n / gcd(ans, n);     return 0;   }
#include <bits/stdc++.h>   const int N = 7e3 + 5;   int n, k[2], a[2][N], cnt[2][N];   bool vis[2][N], win[2][N];   void dfs(int v, int now) {     if (vis[v][now]) return;     vis[v][now] = 1;     int u = v ^ 1;     for (int i = 1; i <= k[u]; ++i) {       int pre = (now - a[u][i] + n - 1) % n + 1;       if (pre == 1) continue;       if (!win[v][now]) {         win[u][pre] = 1;         dfs(u, pre);       } else if (++cnt[u][pre] == k[u]) {         win[u][pre] = 0;         dfs(u, pre);       }     }   }   int main() {     scanf( %d , &n);     for (int o = 0; o <= 1; ++o) {       scanf( %d , &k[o]);       for (int i = 1; i <= k[o]; ++i) scanf( %d , &a[o][i]);     }     dfs(0, 1), dfs(1, 1);     for (int o = 0; o <= 1; ++o) {       for (int i = 2; i <= n; ++i) {         if (!vis[o][i])           printf( %s%c ,  Loop ,    n [i == n]);         else           printf( %s%c , win[o][i] ?  Win  :  Lose ,    n [i == n]);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int Z = (int)2e5 + 111;   const int inf = (int)1e9 + 111;   const long long llinf = (long long)1e18 + 5;   const int MOD = (int)1e9 + 7;   vector<long long> pref[4 * Z];   vector<int> t[4 * Z];   int a[Z];   void build(int v, int vl, int vr) {     if (vl == vr) {       t[v].push_back(a[vl]);       pref[v].push_back(a[vl]);       return;     }     int vm = (vl + vr) / 2;     build(2 * v, vl, vm);     build(2 * v + 1, vm + 1, vr);     merge((t[2 * v]).begin(), (t[2 * v]).end(), (t[2 * v + 1]).begin(),           (t[2 * v + 1]).end(), back_inserter(t[v]));     pref[v].resize((int)t[v].size());     pref[v][0] = t[v][0];     for (int i = 1; i < (int)t[v].size(); ++i) {       pref[v][i] = pref[v][i - 1] + t[v][i];     }   }   pair<long long, long long> query(int v, int vl, int vr, int l, int r, int val1,                                    int val2) {     if (vl > r || vr < l) return make_pair(0, 0);     if (l <= vl && r >= vr) {       long long cnt = upper_bound((t[v]).begin(), (t[v]).end(), val2) -                       lower_bound((t[v]).begin(), (t[v]).end(), val1);       int posL = lower_bound((t[v]).begin(), (t[v]).end(), val1) - t[v].begin();       int posR = upper_bound((t[v]).begin(), (t[v]).end(), val2) - t[v].begin();       posR--;       long long sum;       if (posR == -1)         sum = 0;       else         sum = pref[v][posR] - (posL == 0 ? 0 : pref[v][posL - 1]);       return make_pair(sum, cnt);     }     int vm = (vl + vr) / 2;     pair<long long, long long> ql = query(2 * v, vl, vm, l, r, val1, val2);     pair<long long, long long> qr =         query(2 * v + 1, vm + 1, vr, l, r, val1, val2);     return make_pair(ql.first + qr.first, ql.second + qr.second);   }   int main() {     srand(time(0));     ios_base::sync_with_stdio(false);     int n;     cin >> n;     for (int i = 1; i <= n; ++i) {       cin >> a[i];     }     build(1, 1, n);     long double ans = 0;     for (int i = 1; i <= n; ++i) {       pair<long long, long long> l;       if (a[i] - 2 >= 1)         l = query(1, 1, n, i + 1, n, 1, a[i] - 2);       else         l = make_pair(0, 0);       pair<long long, long long> r = query(1, 1, n, i + 1, n, a[i] + 2, inf);       ans += l.first + r.first - (l.second + r.second) * a[i];     }     cout << fixed << setprecision(0) << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long maxN = 1e7 + 5;   const long long inf = 1e10;   const long long mod = 1e9 + 7;   long long n;   long long a[maxN];   double f[maxN];   int main() {     ios_base::sync_with_stdio(0);     cin >> n;     for (long long i = 1; i <= n; i++) {       cin >> a[i];     }     long long cnt = 0;     for (long long i = 1; i <= n; i++) {       for (long long j = i + 1; j <= n; j++)         if (a[i] > a[j]) cnt++;     }     f[0] = 0.0;     f[1] = 1.0;     for (long long i = 2; i <= cnt + 2; i++) {       f[i] = f[i - 2] + 4.0;     }     printf( %.10f , f[cnt]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int M = 200000;   int a[M];   vector<int> all[M];   int main() {     int n, m;     scanf( %d %d , &n, &m);     long long init = 0;     for (int i = 1; i <= m; i++) scanf( %d , &a[i]);     for (int i = 2; i <= m; i++) init += abs(a[i] - a[i - 1]);     for (int i = 1; i <= m; i++) {       if (i != 1 && a[i] != a[i - 1]) all[a[i]].push_back(a[i - 1]);       if (i != m && a[i] != a[i + 1]) all[a[i]].push_back(a[i + 1]);     }     long long ans = init;     for (int i = 1; i <= n; i++) {       int t = all[i].size();       if (t == 0) continue;       long long cur = init;       sort(all[i].begin(), all[i].end());       int be = all[i][t >> 1];       for (int j = 0; j < t; j++)         cur += -abs(i - all[i][j]) + abs(be - all[i][j]);       ans = min(ans, cur);     }     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int n;     cin >> n;     vector<int> ans;     int power = 1;     while (n > 0) {       if (n % 10 > 0) {         ans.push_back((n % 10) * power);       }       n /= 10;       power *= 10;     }     cout << ans.size() << endl;     for (auto number : ans) cout << number <<    ;     cout << endl;   }   int main() {     int t;     cin >> t;     while (t--) solve();   }