malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include<bits/stdc++.h>   #define fo(i,a,b) for(int i=a;i<=b;i++)   #define gc (p1==p2&&(p2=(p1=fr)+fread(fr,1,1<<20,stdin))==p1?EOF:*p1++)   #define fl fwrite(fw,1,p3-fw,stdout),p3=fw   char ch,fr[1<<21],*p1=fr,*p2=fr,fw[1<<21],*p3=fw;   void rd(int&x)   {    while(!isdigit(ch=gc));x=ch-48;    while( isdigit(ch=gc)) x=ch-48+x*10;   }   void pc(char c) {*p3++=c; if(p3-fw==1<<20)fl;}   void pt(int x) {if(x>9)pt(x/10); pc(x%10+48);}   using namespace std;   typedef pair<int,int>P;   const int N=5e5+9;   int T,n,m,X[N],Y[N],x,y,n1,c[N],sz[N],deg[N],t,d[N];   set<int>r,e[N],E[N];   struct Comp{bool operator()(const int&x,const int&y){return deg[x]>deg[y];}};   multiset<int,Comp>_;   multiset<int,Comp>::iterator it;   #define fi first   #define se second   P a[N],w[N];   void dg(int x)   {    int y;    for(set<int>::iterator it=r.begin();it!=r.end();)     if(e[x].find(y=*it)==e[x].end())     {      E[x].insert(y);      E[y].insert(x);      r.erase(it); dg(y);      it=r.lower_bound(y);     }     else it++;   }   int main()   {    for(rd(T);T--;)    {     rd(n),rd(m); _.clear();     fo(i,1,n) e[i].clear(), E[i].clear(), deg[i]=c[i]=sz[i]=0;     fo(i,1,m)     {      rd(x),rd(y); deg[x]++,deg[y]++; X[i]=x,Y[i]=y;      e[x].insert(y);      e[y].insert(x);     }     fo(i,1,n) _.insert(i);     n1=n;   //  n1=_.size();     while(!_.empty())     {      if(deg[x=*_.begin()]<n1-1) break;      _.erase(_.find(x)), n1--;      for(int y:e[x])      {       _.erase(_.find(y));       e[y].erase(x); deg[y]--; _.insert(y);      }     }   //  n1=_.size();     if(!n1) goto DW;     r.clear();     r.insert(_.begin(),_.end());     for(int x:_) if(r.find(x)!=r.end()) r.erase(x),dg(x);     if(!r.empty())     {      puts( cyka blyat! );      printf( %d %d n ,n,m);      fo(i,1,m) printf( %d %d n ,X[i],Y[i]);      return 0;     }     for(int x:_)      if(!c[x])     {      UP:for(int y:E[x]) if(!c[y]) d[++t]=y;      if(t)      {       for(sz[c[x]=x]=t+1;t;t--) c[d[t]]=x;       continue;      }      y=*E[x].begin();      if(sz[c[y]]==2) {c[c[y]]=sz[c[y]]=0; x=y; goto UP;}      else --sz[c[y]], sz[c[y]=c[x]=x]=2;     }     DW:int nw=0;     for(int x:_) if(sz[x]) w[x]=a[x]=P(nw+sz[x],nw+1), nw+=sz[x];     for(int x:_) if((y=c[x])^x) w[y]=a[x]=P(w[y].fi-1,w[y].se==a[y].se?a[y].fi:w[y].se-1);   //  n1=_.size();     fo(i,1,n) if(_.find(i)==_.end()) ++nw,a[i]=P(nw,nw);     fo(i,1,n) pt(a[i].fi),pc(   );     pc(  n );     fo(i,1,n) pt(a[i].se),pc(   );     pc(  n );    }    fl;   }
#include <bits/stdc++.h>   const int Max_N = 100005, Mod = 1000000007;   int Fact[Max_N], Inv_Fact[Max_N];   long long Inv(const int x) {     return x == 1 ? 1 : (Mod - Mod / x) * Inv(Mod % x) % Mod;   }   long long Binomial(const int x1, const int x2) {     return x1 == -1 && x2 == -1                ? 1                : static_cast<long long>(Fact[x1]) * Inv_Fact[x2] % Mod *                      Inv_Fact[x1 - x2] % Mod;   }   int calc(const int x, const int a, const int b, const int c, const int d) {     if (a < 0 || b < 0 || c < 0 || d < 0 ||         (b != c && (x == 0 ? b != c + 1 : b + 1 != c)))       return 0;     return Binomial((x == 0) + a + c - 1, (x == 0) + c - 1) *            Binomial((x == 1) + b + d - 1, (x == 1) + b - 1) % Mod;   }   int calc(const char A[], int a, int b, int c, int d) {     if (b != c && b != c + 1 && b + 1 != c) return 0;     int len = strlen(A);     if (a + b + c + d == 0) return len != 1;     if (len - 1 < a + b + c + d) return 0;     Fact[0] = 1;     for (int i = 1; i <= len; ++i)       Fact[i] = static_cast<long long>(Fact[i - 1]) * i % Mod;     Inv_Fact[len] = Inv(Fact[len]);     for (int i = len; i; --i)       Inv_Fact[i - 1] = static_cast<long long>(Inv_Fact[i]) * i % Mod;     if (len - 1 > a + b + c + d) return calc(1, a, b, c, d);     int res = 0;     for (int i = 0; i != len - 1 && a >= 0 && b >= 0 && c >= 0 && d >= 0; ++i) {       int x = (A[i] -  0 ) << 1 | (A[i + 1] -  0 );       if (x == 0)         --a;       else if (x == 1)         res = (res + calc(0, a - 1, b, c, d)) % Mod, --b;       else if (x == 2)         --c;       else         res = (res + calc(0, a, b, c - 1, d)) % Mod, --d;     }     return res;   }   char A[Max_N], B[Max_N];   int a, b, c, d;   int main(int argc, char **argv) {     scanf( %s , A);     scanf( %s , B);     scanf( %d %d %d %d , &a, &b, &c, &d);     for (int i = strlen(B) - 1; i >= 0; --i)       if (B[i] ==  0 ) {         B[i] =  1 ;         break;       } else         B[i] =  0 ;     if (B[0] ==  0 ) B[0] =  1 , B[strlen(B)] =  0 ;     printf( %d , (calc(B, a, b, c, d) + Mod - calc(A, a, b, c, d)) % Mod);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> adj[300007];   bool vis[300007];   int Time[300007], timeMin[300007], cnt = 0, res = 0;   int dfs(int u, int p) {     vis[u] = true;     Time[u] = timeMin[u] = cnt++;     int ret = 0;     vector<int> childList;     for (auto child : adj[u]) {       if (child == p) {         continue;       }       if (vis[child]) {         timeMin[u] = min(timeMin[u], Time[child]);       } else {         int temp = dfs(child, u);         timeMin[u] = min(timeMin[u], timeMin[child]);         if (timeMin[child] > Time[u]) {           temp++;         }         ret = max(ret, temp);         childList.push_back(temp);       }     }     sort(childList.rbegin(), childList.rend());     if (childList.size() == 1) {       res = max(res, childList[0]);     } else if (childList.size() > 1) {       res = max(res, childList[0] + childList[1]);     }     return ret;   }   int main() {     int n, m;     scanf( %d %d , &n, &m);     for (int i = 0; i < m; i++) {       int u, v;       scanf( %d %d , &u, &v);       u--;       v--;       adj[u].emplace_back(v);       adj[v].emplace_back(u);     }     dfs(0, -1);     printf( %d n , res);   }
#include <bits/stdc++.h>   const int M = 100010;   int n, k;   int l[M], r[M], a[M];   long long dp[M], ans = 1e18;   template <typename T>   inline void read(T &x) {     x = 0;     char ch = getchar();     int f = 1;     for (; ch <  0  || ch >  9 ; ch = getchar())       if (ch ==  - ) f = -1;     for (; ch >=  0  && ch <=  9 ; ch = getchar()) x = x * 10 + ch -  0 ;     x *= f;   }   int main() {     read(n);     read(k);     for (int i = 1; i <= n; i++) read(l[i]), read(r[i]), read(a[i]);     memset(dp, 0x3f, sizeof(dp));     dp[1] = 0;     for (int i = 1; i <= n; i++) {       long long sum = dp[i], res = k;       for (int j = i; j <= n; j++) {         long long reload;         if (a[j] <= res)           reload = 0;         else           reload = (a[j] - res + k - 1) / k;         if (reload > r[j] - l[j]) break;         long long rest = res + reload * k - a[j];         sum += a[j];         if (j == n)           ans = std::min(ans, sum);         else if (l[j] + reload < l[j + 1])           dp[j + 1] = std::min(dp[j + 1], sum + rest);         res = rest;       }     }     if (ans >= 1e16)       printf( -1 n );     else       printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 10000;   const long double pi = acos(-1.0);   int n, sum[2020];   long long bin[2020], f[2020][2020];   char s[2020];   int read() {     int x = 0, f = 1;     char ch = getchar();     while ((ch <  0 ) || (ch >  9 )) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while ((ch >=  0 ) && (ch <=  9 )) {       x = x * 10 + (ch -  0 );       ch = getchar();     }     return x * f;   }   int main() {     scanf( %s , s + 1);     n = strlen(s + 1);     for (register int i = 2; i <= n; i++) sum[i] = sum[i - 1] + (s[i] ==  ? );     bin[0] = 1;     for (register int i = 1; i <= n; i++) bin[i] = (bin[i - 1] * 2) % 998244353;     for (register int len = 2; len <= n; len++) {       for (int i = 1; i + len - 1 <= n; i++) {         int j = i + len - 1;         if (s[i] !=  ( ) f[i][j] = (f[i][j] + f[i + 1][j]) % 998244353;         if (s[j] !=  ) ) f[i][j] = (f[i][j] + f[i][j - 1]) % 998244353;         if ((s[i] !=  ( ) && (s[j] !=  ) ))           f[i][j] = (f[i][j] - f[i + 1][j - 1] + 998244353) % 998244353;         if ((s[i] !=  ) ) && (s[j] !=  ( ))           f[i][j] =               (f[i][j] + f[i + 1][j - 1] + bin[sum[j - 1] - sum[i]]) % 998244353;       }     }     printf( %lld , f[1][n]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     cin >> s;     vector<set<int> > v(26);     for (int i = 0; i < s.size(); i++) v[s[i] -  a ].insert(i);     int q = 0, op = 0;     cin >> q;     while (q--) {       cin >> op;       if (op == 1) {         int pos = 0;         char x;         cin >> pos >> x;         v[s[pos - 1] -  a ].erase(pos - 1);         s[pos - 1] = x;         v[s[pos - 1] -  a ].insert(pos - 1);       } else {         int l = 0, r = 0, ans = 0;         cin >> l >> r;         for (int i = 0; i < 26; i++) {           auto it = v[i].lower_bound(l - 1);           if (it != v[i].end() && *it <= r - 1) ans++;         }         cout << ans << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int two(int n) { return 1 << n; }   inline int test(int n, int b) { return (n >> b) & 1; }   inline void set_bit(int& n, int b) { n |= two(b); }   inline void unset_bit(int& n, int b) { n &= ~two(b); }   inline int last_bit(int n) { return n & (-n); }   int dist[403][403];   void print(int a[][403], int n) {     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) cout << a[i][j] <<    ;       cout <<   n ;     }   }   int floyd_warshall(int a[][403], int n) {     for (int via = 1; via <= n; via++) {       for (int from = 1; from <= n; from++) {         for (int to = 1; to <= n; to++) {           a[from][to] = min(a[from][to], a[from][via] + a[via][to]);         }       }     }     return a[1][n];   }   int dist_dij[403];   bool visited[403];   int vertex_min_path_len(int n) {     int min_dist = INT_MAX, min_vertex = 0;     for (int i = 1; i <= n; i++) {       if (!visited[i] && dist_dij[i] <= min_dist)         min_dist = dist_dij[i], min_vertex = i;     }     return min_vertex;   }   int dijkstra(int src, int n) {     memset(visited, 0, sizeof visited);     for (int i = 1; i <= n; i++) dist_dij[i] = 403;     dist_dij[src] = 0;     int cnt = 1;     while (cnt <= n) {       int u = vertex_min_path_len(n);       visited[u] = true;       for (int v = 1; v <= n; v++) {         if (!visited[v] && dist[u][v] != 403 &&             dist_dij[u] + dist[u][v] <= dist_dij[v])           dist_dij[v] = dist_dij[u] + dist[u][v];       }       cnt++;     }     return dist_dij[n];   }   int main() {     ios::sync_with_stdio(false);     int n, m;     cin >> n >> m;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++) dist[i][j] = 403;     for (int i = 0; i < m; i++) {       int u, v;       cin >> u >> v;       dist[u][v] = dist[v][u] = 1;     }     if (dist[1][n] == 1) {       for (int i = 1; i <= n; i++) {         for (int j = 1; j <= n; j++) {           if (dist[i][j] == 403)             dist[i][j] = 1;           else             dist[i][j] = 403;           if (i == j) dist[i][j] = 403;         }       }     }     int ans = -2;     ans = dijkstra(1, n);     if (ans == 403)       cout <<  -1 n ;     else       cout << ans <<   n ;     return 0;   }
#include<bits/stdc++.h>   #define llong long long   #define mkpr make_pair   #define x first   #define y second   #define iter iterator   #define riter reverse_iterator   #define y1 Lorem_ipsum_   #define tm dolor_sit_amet_   using namespace std;      inline int read()   {    int x = 0,f = 1; char ch = getchar();    for(;!isdigit(ch);ch=getchar()) {if(ch== - ) f = -1;}    for(; isdigit(ch);ch=getchar()) {x = x*10+ch-48;}    return x*f;   }      const int P = 1e9+7;   const int mxN = 2e5;   int n,m; llong fact[mxN+3],facti[mxN+3],inv[mxN+3];      llong quickpow(llong x,llong y)   {    llong cur = x,ret = 1ll;    for(int i=0; y; i++)    {     if(y&(1ll<<i)) {y-=(1ll<<i); ret = ret*cur%P;}     cur = cur*cur%P;    }    return ret;   }   llong comb(llong x,llong y) {return x<0ll||y<0ll||x<y?0ll:fact[x]*facti[y]%P*facti[x-y]%P;}   llong combi(llong x,llong y) {return x<0ll||y<0ll||x<y?0ll:facti[x]*fact[y]%P*fact[x-y]%P;}      void initfact(int n)   {    fact[0] = 1ll; for(int i=1; i<=n; i++) fact[i] = fact[i-1]*i%P;    facti[n] = quickpow(fact[n],P-2); for(int i=n-1; i>=0; i--) facti[i] = facti[i+1]*(i+1ll)%P;   }      int main()   {    initfact(mxN);    int T = read(); while(T--)    {     n = read(),m = read(); llong ans = 0ll;     for(int i=0; i<=n; i++)     {      llong cur = comb(n-1ll*(i-1)*(m-1),i)*combi(n,i)%P;      ans = (ans+cur)%P;     }     printf( %lld n ,ans);    }    return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[10], nd[10], dad[10], root, ans;   int nopd(long long n) {     long long now = 2, ans = 0;     for (; now * now <= n; now++)       while (n && n % now == 0) {         n /= now;         ans++;       }     if (n > 1) ans++;     return ans;   }   bool prime(long long n) {     if (n == 1) return false;     for (long long i = 2; i * i <= n; i++)       if (n % i == 0) return false;     return true;   }   int nopd_pooyan(long long a) {     int ans = 0;     if (prime(a))       ans++;     else {       long long j = 2;       while (a > 1) {         if (a % j == 0) {           while (a % j == 0) {             a /= j;             ans++;           }           if (prime(a)) {             ans++;             break;           }         }         j++;       }     }     return ans;   }   int main() {     int n, best, ibest, flag;     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i];     sort(a, a + n);     reverse(a, a + n);     for (int i = 0; i < n; i++) {       nd[i] = nopd_pooyan(a[i]);       ans += nd[i];       if (nd[i] == 1) ans--;     }     for (int i = 0; i < n; i++) {       if (!dad[i]) root++;       flag = 1;       while (flag) {         best = ibest = -1;         for (int j = i + 1; j < n; j++)           if (a[i] % a[j] == 0 && !dad[j] && nd[j] > best) {             best = nd[j];             ibest = j;           }         if (ibest == -1)           flag = 0;         else {           ans -= (best - 1);           dad[ibest] = i + 1;           a[i] /= a[ibest];         }       }     }     ans += root;     if (root > 1) ans++;     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long a, n, b, x, y, s;     int q;     cin >> q;     while (q--) {       cin >> a >> b >> n >> s;       long long ts = a * n + b;       if (ts < s) {         cout <<  NO n ;         continue;       }       if (s % n > b) {         cout <<  NO n ;         continue;       }       cout <<  YES n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int uf[55];   int buc[55];   bool chk[55];   int ans[5000][2];   int fh(int idx) {     if (uf[idx] != idx) uf[idx] = fh(uf[idx]);     return uf[idx];   }   vector<int> edge[55];   void dfs(int idx) {     if (chk[idx]) return;     chk[idx] = true;     for (int i = 0; i < edge[idx].size(); i++) {       dfs(edge[idx][i]);     }   }   int main() {     int n, m, g1, g2;     scanf( %d %d , &n, &m);     for (int i = 1; i <= n; i++) {       uf[i] = i;     }     bool b = true;     for (int i = 0; i < m; i++) {       scanf( %d %d , &g1, &g2);       edge[g1].push_back(g2);       edge[g2].push_back(g1);       buc[g1]++;       buc[g2]++;       if (uf[g1] == uf[g2]) {         b = false;       }       uf[fh(g1)] = fh(g2);     }     if (n == 1) {       if (m == 0) {         printf( YES n1 n1 1 );       } else if (m == 1) {         printf( YES n0 );       } else {         printf( NO );       }       return 0;     }     for (int i = 1; i <= n; i++) {       if (buc[i] > 2) {         printf( NO );         return 0;       }     }     if (!b) {       dfs(1);       for (int i = 1; i <= n; i++) {         if (!chk[i]) {           printf( NO );           return 0;         }       }       printf( YES n0 );       return 0;     }     int cnt = 0;     for (int i = 1; i <= n; i++) {       for (int j = i + 1; j <= n; j++) {         if (fh(i) != fh(j) && buc[i] != 2 && buc[j] != 2) {           ans[cnt][0] = i;           ans[cnt][1] = j;           uf[fh(i)] = fh(j);           buc[i]++;           buc[j]++;           cnt++;         }       }     }     for (int i = 1; i <= n; i++) {       if (buc[i] != 2) {         for (int j = i + 1; j <= n; j++) {           if (buc[j] != 2) {             ans[cnt][0] = i;             ans[cnt][1] = j;             cnt++;             break;           }         }         break;       }     }     printf( YES n );     printf( %d n , cnt);     for (int i = 0; i < cnt; i++) {       printf( %d %d n , ans[i][0], ans[i][1]);     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 10;   int fst[N], v[2 * N], w[2 * N], nxt[2 * N], cnt = 1;   bool vis[2 * N];   int c[N], ans[N], n;   queue<int> q;   void add(int x, int y, int z) {     v[++cnt] = y, w[cnt] = z;     c[y] += z;     nxt[cnt] = fst[x], fst[x] = cnt;   }   void bfs() {     q.push(1);     while (!q.empty()) {       int x = q.front();       q.pop();       for (int i = fst[x]; i; i = nxt[i]) {         int y = v[i];         if (vis[i]) continue;         vis[i] = vis[i ^ 1] = 1, ans[i / 2] = i;         c[y] -= w[i];         if (!c[y] && y != n) q.push(y);       }     }   }   int main() {     int m, x, y, z;     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; i++) {       scanf( %d%d%d , &x, &y, &z);       add(x, y, z), add(y, x, z);     }     for (int i = 1; i <= n; i++) c[i] /= 2;     bfs();     for (int i = 1; i <= m; i++) printf( %d n , ans[i] - i * 2);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s, t;   double ans;   double solve(string s) {     int a = 0, b = 0, c = 0, p = 0;     for (int i = 0; i < s.size(); i++) {       char e = (b % 2) ?  R  :  L ;       if (s[i] ==  X )         b++;       else if (s[i] == e)         a++, b++, p = 0;       else         a++, b += 2, c += p, p = !p;     }     if (b % 2) b++, c += p;     if (a * 2 > b) a -= c, b -= 2 * c;     return 100.0 * a / b;   }   int main() {     cin >> t;     for (int i = 0; i + 1 < t.size(); i++) {       s += t[i];       if (t[i] == t[i + 1] && t[i] !=  X ) s +=  X ;     }     s += t.back();     if (s[0] == s.back() && s.back() !=  X )       ans = max(solve(s +  X ), solve( X  + s));     else       ans = solve(s);     int f = ans * 1000000;     ans = f / 1000000.0;     printf( %.6lf n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   int N;   int arr[300005];   int segf[4 * 300005];   int segb[4 * 300005];   int pow29[300005];   void inv(long long a, long long b, long long &x, long long &y) {     if (a == 0) {       x = 0;       y = 1;       return;     }     inv((b % a), a, x, y);     long long z = x;     long long zz = y;     x = zz - (b / a) * z;     y = z;   }   void updatef(int start, int end, int i, int node) {     if (start > i || end < i) return;     if (start == end) {       segf[node] += pow29[start];       if (segf[node] >= mod) segf[node] -= mod;       return;     }     updatef(start, (start + end) / 2, i, 2 * node);     updatef((start + end) / 2 + 1, end, i, 2 * node + 1);     segf[node] = segf[2 * node] + segf[2 * node + 1];     if (segf[node] >= mod) segf[node] -= mod;   }   void updateb(int start, int end, int i, int node) {     if (start > i || end < i) return;     if (start == end) {       segb[node] += pow29[N - start];       if (segb[node] >= mod) segb[node] -= mod;       return;     }     updateb(start, (start + end) / 2, i, 2 * node);     updateb((start + end) / 2 + 1, end, i, 2 * node + 1);     segb[node] = segb[2 * node] + segb[2 * node + 1];     if (segb[node] >= mod) segb[node] -= mod;   }   int queryf(int start, int end, int i, int j, int node = 1) {     if (start > j || end < i) return 0;     if (start >= i && end <= j) return segf[node];     return (queryf(start, (start + end) / 2, i, j, 2 * node) +             queryf((start + end) / 2 + 1, end, i, j, 2 * node + 1)) %            mod;   }   int queryb(int start, int end, int i, int j, int node = 1) {     if (start > j || end < i) return 0;     if (start >= i && end <= j) return segb[node];     return (queryb(start, (start + end) / 2, i, j, 2 * node) +             queryb((start + end) / 2 + 1, end, i, j, 2 * node + 1)) %            mod;   }   int main() {     pow29[0] = 1;     for (int g = 1; g <= 300005; g++) pow29[g] = (1LL * 29 * pow29[g - 1]) % mod;     scanf( %d , &N);     for (int g = 1; g <= N; g++) {       scanf( %d , &arr[g]);       arr[g]--;     }     for (int g = 1; g <= N; g++) {       int t = min(arr[g], N - 1 - arr[g]);       int first = queryf(0, N - 1, arr[g], arr[g] + t);       int second = queryb(0, N - 1, arr[g] - t, arr[g]);       long long R = pow29[arr[g]];       long long x = 0, y = 0;       inv(R, mod, x, y);       x %= mod;       x += mod;       x %= mod;       first = (1LL * first * x) % mod;       R = pow29[N - arr[g]], x = 0, y = 0;       inv(R, mod, x, y);       x %= mod;       x += mod;       x %= mod;       second = (1LL * second * x) % mod;       if (first != second) {         if (arr[g] > 0 && arr[g] < N - 1) {           puts( YES );           return 0;         }       }       updatef(0, N - 1, arr[g], 1);       updateb(0, N - 1, arr[g], 1);     }     puts( NO );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int T;     cin >> T;     for (int test_case = 0; test_case < T; test_case++) {       int num, round = 1;       vector<int> result;       cin >> num;       while (num > 0) {         if (num % 10 != 0) {           result.push_back((num % 10) * round);         }         num /= 10;         round *= 10;       }       cout << result.size() << endl;       for (int i = 0; i < result.size(); i++) {         cout << result[i] <<    ;       }       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 314000000;   int n, m, id[111111], dis[111111], dp[111111];   int val[111111], sum[111111], deg[111111];   int vis[111111];   vector<int> str[111111];   vector<int> to[111111];   vector<int> fr[111111];   int add(int x, int y) {     int s = x + y;     return min(s, inf);   }   void dijkstra() {     priority_queue<pair<int, int>, vector<pair<int, int> >,                    greater<pair<int, int> > >         q;     for (int i = 1; i <= n; i++) {       dis[i] = 0x3f3f3f3f;     }     for (int i = 1; i <= m; i++) {       if (to[i].empty()) {         if (val[i] < dis[id[i]]) {           dis[id[i]] = val[i];           q.push(make_pair(dis[id[i]], id[i]));         }       }     }     while (!q.empty()) {       int x = q.top().second, d = q.top().first;       q.pop();       if (dis[x] != d) continue;       for (int i = 0; i < fr[x].size(); i++) {         deg[fr[x][i]]--;         sum[fr[x][i]] = add(sum[fr[x][i]], dis[x]);         if (!deg[fr[x][i]] && dis[id[fr[x][i]]] > sum[fr[x][i]]) {           dis[id[fr[x][i]]] = sum[fr[x][i]];           q.push(make_pair(dis[id[fr[x][i]]], id[fr[x][i]]));         }       }     }   }   int dfs(int x) {     if (vis[x]) return -2;     if (dp[x] != -1) return dp[x];     vis[x] = 1;     for (int i = 0; i < str[x].size(); i++) {       int y = str[x][i], sum = 0, t = 0;       for (int j = 0; j < to[y].size(); t = ++j) {         if (dis[to[y][j]] == 0x3f3f3f3f) {           break;         }       }       if (t < to[y].size()) {         continue;       }       for (int j = 0; j < to[y].size(); j++) {         int t = dfs(to[y][j]);         if (t == -2) {           vis[x] = 0;           return dp[x] = -2;         }         sum = add(sum, t);       }       sum = add(sum, val[y]);       dp[x] = max(dp[x], sum);     }     vis[x] = 0;     return dp[x];   }   int main() {     scanf( %d%d , &m, &n);     for (int i = 1; i <= m; i++) {       int cnt;       scanf( %d%d , &id[i], &cnt);       str[id[i]].push_back(i);       while (cnt--) {         int x;         scanf( %d , &x);         if (x == -1) {           val[i]++;           sum[i]++;           continue;         }         to[i].push_back(x);         fr[x].push_back(i);       }       deg[i] = to[i].size();     }     dijkstra();     memset(dp, -1, sizeof(dp));     for (int i = 1; i <= n; i++) {       if (dis[i] == 0x3f3f3f3f) {         puts( -1 -1 );       } else {         printf( %d %d n , dis[i], dfs(i));       }     }     return 0;   }