malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const long long N = 2e5 + 50;   const long long mod = 1e9 + 7;   const long long INF = 1e18;   long long dx[] = {-1, 0, 1, 0};   long long dy[] = {0, 1, 0, -1};   bool compare(const pair<long long, long long>& i,                const pair<long long, long long>& j) {     return i.second > j.second;   }   long long fact[N];   vector<bool> is_prime(100000, true);   vector<long long> prime;   void pre() {     fact[0] = 1;     for (long long i = 1; i < N; i++) {       fact[i] = i * fact[i - 1];       fact[i] %= mod;     }   }   long long modexp(long long x, long long n) {     long long r = 1;     while (n) {       if (n & 1) r = (r * x) % mod;       x = (x * x) % mod;       n >>= 1;     }     return r % mod;   }   long long modinv(long long x) { return modexp(x, mod - 2); }   long long ncr(long long n, long long r) {     if (n < r) return 0;     long long ans =         (fact[n] % mod * modinv(fact[r]) % mod * modinv(fact[n - r]) % mod) % mod;     return ans;   }   long long exp(long long x, long long n) {     long long r = 1;     while (n) {       if (n & 1) r = (r * x);       x = (x * x);       n >>= 1;     }     return r;   }   void solve() {     long long n;     cin >> n;     long long x = 1;     long long A[n + 2];     for (long long i = 1; i <= n; i += 2) {       A[i] = x;       x++;     }     for (long long i = n - n % 2; i >= 2; i -= 2) {       A[i] = x;       x++;     }     for (long long i = 1; i <= n; i++) cout << A[i] <<    ;     cout << endl;     return;   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long t = 1;     for (long long i = 0; i < t; i++) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long b, a, r;   int k;   int d0[360360 + 5], d1[360360 + 5];   void sim() {     assert(a <= b);     while (b > a) {       long long w = b - 1;       for (int i = 2, ThxDem = k + 1; i < ThxDem; ++i)         if (b / i * i >= a) w = min(w, b / i * i);       b = w;       r++;     }   }   int main() {     scanf( %lld%lld%d , &b, &a, &k);     memset(d0, -1, sizeof(d0));     d0[b % 360360] = d1[b % 360360] = 0;     while (1) {       long long w = b - 1;       for (int i = 2, ThxDem = k + 1; i < ThxDem; ++i) w = min(w, b / i * i);       if (w <= a) {         sim();         break;       }       if (d0[w % 360360] >= 0) {         int l0 = d0[b % 360360] - d0[w % 360360] + 1,             l1 = d1[b % 360360] - d1[w % 360360] + b - w;         long long nc = (w - a) / l1;         r += nc * l0;         b -= nc * l1;         sim();         break;       }       d0[w % 360360] = d0[b % 360360] + 1;       d1[w % 360360] = d1[b % 360360] + b - w;       b = w;       r++;     }     printf( %lld n , r);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     int songs = n + m - 1;     cout << songs << endl;     for (int i = 1; i <= n; i++) {       cout << i <<     << 1 << endl;     }     for (int i = 2; i <= m; i++) {       cout << 1 <<     << i << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     scanf( %d , &t);     while (t--) {       int a, b, c;       int d, e, f;       scanf( %d%d%d , &a, &b, &c);       scanf( %d%d%d , &d, &e, &f);       int sum = 0;       sum = min(c, e) * 2;       e = e - sum / 2;       c = c - sum / 2;       if (c > 0) {         f = f - min(c, f);       }       if (d + e < b) {         sum = sum - min((b - d - e), f) * 2;       }       printf( %d n , sum);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     int m = 0, c = 0;     while (t--) {       int a, b;       cin >> a >> b;       if (a > b)         m++;       else if (a < b)         c++;       else {         m++;         c++;       }     }     if (m > c)       cout <<  Mishka ;     else if (m < c)       cout <<  Chris ;     else {       cout <<  Friendship is magic!^^ ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = (int)6e4 + 2;   int n;   map<string, int> mp;   vector<pair<string, int>> v;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> n;     string str;     for (int i = 0; i < n; ++i) {       cin >> str;       mp[str] = i;     }     for (map<string, int>::iterator it = mp.begin(); it != mp.end(); ++it) {       v.push_back(*it);     }     sort(v.begin(), v.end(),          [](const pair<string, int>& a, pair<string, int>& b) {            return a.second > b.second;          });     for (int i = 0; i < v.size(); ++i) cout << v[i].first << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MAXN = 1e6, mod = 1000000007;   long long n, m, x, k, d, p, z, sum;   vector<long long> v, ans;   set<long long> st;   int main() {     cin >> n >> k;     for (long long i = 1; i <= 2 * n; i *= 2) v.push_back(i - 1);     if (k == 1) {       cout << n;       return 0;     } else {       for (int i = v.size() - 1; i >= 0; i--) {         if (i == 0 || (v[i] >= n && v[i - 1] < n)) {           cout << v[i];           return 0;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   string toStr(const T &x) {     stringstream s;     s << x;     return s.str();   }   template <class T>   int toInt(const T &x) {     stringstream s;     s << x;     int r;     s >> r;     return r;   }   vector<string> pals;   bool check(string s) {     for (int i = 0, j = s.size() - 1; i < s.size() / 2; i++, j--) {       if (s[i] != s[j]) return false;     }     return true;   }   void gen() {     for (int i = 0; i < 24; ++i) {       for (int j = 0; j < 60; ++j) {         string t1 = i < 10 ?  0  :   ;         string t2 = j < 10 ?  0  :   ;         string t = t1 + toStr(i) +  :  + t2 + toStr(j);         if (check(t)) pals.push_back(t);       }     }   }   int main() {     gen();     string line;     cin >> line;     if (line >  23:32 )       cout <<  00:00  << endl;     else {       vector<string>::iterator it = upper_bound(pals.begin(), pals.end(), line);       cout << pals[(it - pals.begin())] << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 1e5 + 5, MX = 2e5, MN = 0;   struct node;   extern node* empty;   struct node {     int mx;     node *LF, *RT;     node() : mx(0), LF(this), RT(this) {}     node(int val, node* lf = empty, node* rt = empty) : mx(val), LF(lf), RT(rt) {}   };   node* empty = new node();   node* insert(int val, int ind, node* cur, int ns = 0, int ne = MX) {     if (ind > ne or ind < ns) return cur;     if (ns == ne) return new node(val);     int mid = ns + (ne - ns) / 2;     node* lf = insert(val, ind, cur->LF, ns, mid);     node* rt = insert(val, ind, cur->RT, mid + 1, ne);     return new node(max(lf->mx, rt->mx), lf, rt);   }   int getMax(int qe, node* cur, int ns = 0, int ne = MX) {     if (qe < 0) return 0;     if (ns > qe) return 0;     if (ne <= qe) return cur->mx;     int mid = ns + (ne - ns) / 2;     return max(getMax(qe, cur->LF, ns, mid), getMax(qe, cur->RT, mid + 1, ne));   }   node* roots[N];   int main() {     int n, m;     scanf( %d%d , &n, &m);     for (long long i = 1; i <= n; i++) {       roots[i] = empty;     }     for (long long i = 0; i < m; i++) {       int a, b, w;       scanf( %d%d%d , &a, &b, &w);       roots[b] = insert(getMax(w - 1, roots[a]) + 1, w, roots[b]);     }     int ans = 0;     for (long long i = 1; i <= n; i++) {       ans = max(ans, getMax(MX, roots[i]));     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);     int n;     cin >> n;     int arr[n + 5][n + 5], a, b;     map<int, int> mp, mp2;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         arr[i][j] = 0;       }     }     for (int i = 1; i < n; i++) {       cin >> a >> b;       arr[a][b] = 1;       mp[a]++;       mp2[b]++;     }     vector<pair<int, pair<int, int>>> v;     int tmp = n;     while (tmp > 1) {       if (mp2[tmp]) {         for (int i = 1; i < tmp; i++) {           if (!mp2[i]) {             v.push_back({2, {i, tmp}});             mp2[i] = mp2[tmp];             for (int ii = 1; ii <= tmp; ii++) {               swap(arr[ii][tmp], arr[ii][i]);             }             break;           }         }       }       if (!mp[tmp]) {         for (int i = 1; i < tmp; i++) {           if (mp[i]) {             v.push_back({1, {i, tmp}});             mp[i] = mp[tmp];             for (int ii = 1; ii <= tmp; ii++) {               mp2[ii] -= arr[i][ii];               swap(arr[tmp][ii], arr[i][ii]);             }             break;           }         }       } else {         for (int ii = 1; ii <= tmp; ii++) {           mp2[ii] -= arr[tmp][ii];           arr[tmp][ii] = 0;         }       }       tmp--;     }     cout << v.size() <<   n ;     for (auto i : v) {       cout << i.first <<     << i.second.first <<     << i.second.second <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long res, rec, d, h, v, e, p = 3.1415926535;   int main() {     cin >> d >> h;     if (d == 1 && h == 1) {       cout << 0;       return 0;     }     while (d != 0 && h != 0) {       if (d <= h) {         d++;         h -= 2;       } else if (d > h) {         d -= 2;         h++;       }       e++;     }     cout << e;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int t = 1111;   bitset<t> a[t], q[t];   int x[t], y[t];   char s[t];   void cl(int l, int r, int u, int d) {     int i;     for (i = l; i <= r; i++) q[i][u] = q[i][d] = 1;     for (i = u; i <= d; i++) q[l][i] = q[r][i] = 1;   }   int main() {     int n, m, i, j, cx, cy, l1, r1, u1, d1, l2, r2, u2, d2, cnt;     scanf( %d%d , &n, &m);     for (i = 1; i <= n; i++) {       a[i] = 0;       scanf( %s , s);       for (j = 0; j < m; j++) a[i][j + 1] = s[j] ==  #  ? 1 : 0;     }     for (cx = 0, i = 1; i <= n; i++) {       for (cnt = 0, j = 1; j <= m && cnt < 3; j++) cnt = a[i][j] ? cnt + 1 : 0;       if (cnt == 3) x[cx++] = i;     }     if (cx > 4) {       x[2] = x[cx - 2];       x[3] = x[cx - 1];       cx = 4;     }     for (cy = 0, i = 1; i <= m; i++) {       for (cnt = 0, j = 1; j <= n && cnt < 3; j++) cnt = a[j][i] ? cnt + 1 : 0;       if (cnt == 3) y[cy++] = i;     }     if (cy > 4) {       y[2] = y[cy - 2];       y[3] = y[cy - 1];       cy = 4;     }     for (l1 = 0; l1 < cx; l1++)       for (r1 = l1 + 1; r1 < cx; r1++)         if (x[r1] - x[l1] > 1)           for (u1 = 0; u1 < cy; u1++)             for (d1 = u1 + 1; d1 < cy; d1++)               if (y[d1] - y[u1] > 1)                 for (l2 = l1; l2 < cx; l2++)                   for (r2 = l2 + 1; r2 < cx; r2++)                     if (x[r2] - x[l2] > 1)                       for (u2 = 0; u2 < cy; u2++)                         for (d2 = u2 + 1; d2 < cy; d2++)                           if (y[d2] - y[u2] > 1) {                             for (i = 1; i <= n; i++) q[i] = 0;                             cl(x[l1], x[r1], y[u1], y[d1]);                             cl(x[l2], x[r2], y[u2], y[d2]);                             for (i = 1; i <= n && q[i] == a[i]; i++)                               ;                             if (i == n + 1) {                               puts( YES );                               printf( %d %d %d %d n%d %d %d %d n , x[l1], y[u1],                                      x[r1], y[d1], x[l2], y[u2], x[r2], y[d2]);                               return 0;                             }                           }     puts( NO );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int kocka[25] = {};     for (int i = 1; i <= 24; i++) cin >> kocka[i];     if (kocka[1] == kocka[2] && kocka[2] == kocka[3] && kocka[3] == kocka[4] &&         kocka[17] == kocka[18] && kocka[18] == kocka[7] && kocka[7] == kocka[8] &&         kocka[21] == kocka[22] && kocka[22] == kocka[19] &&         kocka[19] == kocka[20]) {       cout <<  YES ;       exit(0);     }     if (kocka[1] == kocka[2] && kocka[2] == kocka[3] && kocka[3] == kocka[4] &&         kocka[13] == kocka[14] && kocka[14] == kocka[7] && kocka[7] == kocka[8] &&         kocka[5] == kocka[6] && kocka[6] == kocka[19] && kocka[19] == kocka[20]) {       cout <<  YES ;       exit(0);     }     if (kocka[1] == kocka[2] && kocka[2] == kocka[17] && kocka[17] == kocka[19] &&         kocka[5] == kocka[6] && kocka[6] == kocka[7] && kocka[7] == kocka[8] &&         kocka[10] == kocka[18] && kocka[18] == kocka[9] &&         kocka[9] == kocka[20]) {       cout <<  YES ;       exit(0);     }     if (kocka[1] == kocka[2] && kocka[2] == kocka[16] && kocka[16] == kocka[14] &&         kocka[5] == kocka[6] && kocka[6] == kocka[7] && kocka[7] == kocka[8] &&         kocka[3] == kocka[18] && kocka[18] == kocka[4] && kocka[4] == kocka[20]) {       cout <<  YES ;       exit(0);     }     if (kocka[5] == kocka[2] && kocka[2] == kocka[7] && kocka[7] == kocka[4] &&         kocka[9] == kocka[6] && kocka[6] == kocka[11] && kocka[11] == kocka[8] &&         kocka[17] == kocka[18] && kocka[18] == kocka[19] &&         kocka[19] == kocka[20]) {       cout <<  YES ;       exit(0);     }     if (kocka[24] == kocka[2] && kocka[2] == kocka[22] && kocka[22] == kocka[4] &&         kocka[1] == kocka[6] && kocka[6] == kocka[3] && kocka[3] == kocka[8] &&         kocka[17] == kocka[18] && kocka[18] == kocka[19] &&         kocka[19] == kocka[20]) {       cout <<  YES ;       exit(0);     }     cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e5 + 5;   const double eps = 1e-14;   char buf[1 << 12], *pp1 = buf, *pp2 = buf, nc;   int ny;   inline char gc() { return getchar(); }   inline long long read() {     long long x = 0;     for (ny = 1; nc = gc(), (nc < 48 || nc > 57) && nc != EOF;)       if (nc == 45) ny = -1;     if (nc < 0) return nc;     for (x = nc - 48; nc = gc(), 47 < nc && nc < 58 && nc != EOF;          x = (x << 3) + (x << 1) + (nc ^ 48))       ;     return x * ny;   }   int n, top, a[MAXN], b[MAXN];   long long t;   double p[MAXN], Max;   struct Point {     double x, y;     int id;     Point(double x = 0, double y = 0, int id = 0) : x(x), y(y), id(id) {}     double K() { return y / x; }   } s[MAXN], stk[MAXN];   inline Point operator-(Point a, Point b) { return Point(a.x - b.x, a.y - b.y); }   inline double operator^(Point a, Point b) { return a.x * b.y - a.y * b.x; }   inline int sig(double x) { return x < -eps ? -1 : x > eps ? 1 : 0; }   struct Mat {     double a[3][3];     inline double* operator[](int x) { return a[x]; }     inline friend Mat operator*(Mat a, Mat b) {       Mat c;       for (int i = (0); i <= (2); i++)         for (int j = (0); j <= (2); j++) c[i][j] = 0;       for (int i = (0); i <= (2); i++)         for (int j = (0); j <= (2); j++)           for (int k = (0); k <= (2); k++) c[i][j] += a[i][k] * b[k][j];       return c;     }   } coef, st, ST[40];   int main() {     n = read(), t = read();     for (int i = (1); i <= (n); i++)       scanf( %d%d%lf , a + i, b + i, p + i), s[i] = Point(p[i], p[i] * a[i], i),                                              Max = max(Max, p[i] * b[i]);     sort(s + 1, s + n + 1, [](Point x, Point y) {       return !sig(x.x - y.x) ? sig(x.y - y.y) > 0 : sig(x.x - y.x) < 0;     });     for (int i = (1); i <= (n); i++) {       if (i != 1 && !sig(s[i].x - s[i - 1].x)) continue;       for (;            top > 1 && sig((s[i] - stk[top - 1]) ^ (stk[top] - stk[top - 1])) <= 0;            top--)         ;       stk[++top] = s[i];     }     int now = 1;     st[2][0] = 1;     for (long long l = 0, r; l < t; l = r) {       double s = st[1][0] * Max - st[0][0];       for (; now < top && (stk[now + 1] - stk[now]).K() >= -s; now++)         ;       int j = stk[now].id;       coef[0][0] = 1 - p[j], coef[0][1] = p[j] * Max, coef[0][2] = p[j] * a[j];       coef[1][0] = 0, coef[1][1] = coef[1][2] = 1, coef[2][0] = coef[2][1] = 0,       coef[2][2] = 1;       ST[0] = coef;       for (int i = (1); i <= (34); i++) ST[i] = ST[i - 1] * ST[i - 1];       r = l;       for (int i = (34); i >= (0); i--)         if (r + (1ll << i) < t) {           Mat t = ST[i] * st;           double ss = t[1][0] * Max - t[0][0];           if (now == top || (stk[now + 1] - stk[now]).K() < -ss)             r += 1ll << i, st = t;         }       st = ST[0] * st, r++;     }     printf( %.10lf , st[0][0]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100005;   const long long INF = 1e18;   const long long MOD = 1000000007;   long double A[100005], B[100005];   int main() {     int n, p;     cin >> n >> p;     for (int i = 0; i < n; i++) {       int x, y;       cin >> x >> y;       A[i] = y / p;       A[i] -= (x - 1) / p;       B[i] = (y - x + 1);     }     long double res;     long double ans = 0;     for (int i = 1; i < n; i++) {       res = (A[i] * A[i - 1]) + (A[i] * (B[i - 1] - A[i - 1])) +             (A[i - 1] * (B[i] - A[i]));       long double d = B[i] * B[i - 1];       res = res / d;       res = res * 2000;       ans += res;     }     res = (A[0] * A[n - 1]) + (A[0] * (B[n - 1] - A[n - 1])) +           (A[n - 1] * (B[0] - A[0]));     long double d = B[0] * B[n - 1];     res = res / d;     res = res * 2000;     ans += res;     cout << setprecision(10) << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mxn = 105;   const long long mxm = 1;   const long long INF = 0x3f3f3f3f;   const long long mod = 1e9 + 7;   const double eps = 1e-7;   long long a[mxn];   signed main(void) {     long long q;     cin >> q;     while (q--) {       long long n;       cin >> n;       long long ct1 = 0, ct2 = 0, ct0 = 0, ans = 0;       for (long long i = 1; i <= n; i++) {         cin >> a[i];         a[i] = a[i] % 3;         if (a[i] == 1) ct1++;         if (a[i] == 2) ct2++;         if (a[i] == 0) ct0++;       }       ans = ct0;       if (ct1 >= ct2) {         ans += ct2;         ct1 -= ct2;         ans += ct1 / 3;       } else {         ans += ct1;         ct2 -= ct1;         ans += ct2 / 3;       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int a[n];     vector<int> v;     for (int i = 0; i < n; i++) cin >> a[i];     sort(a, a + n);     v.push_back(1);     int flag = 0;     for (int i = 1; i < n; i++) {       flag = 0;       for (int j = 0; j < v.size(); j++) {         if (a[i] >= v[j]) {           v[j]++;           flag = 1;           break;         }       }       if (!flag) v.push_back(1);     }     cout << v.size();   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5;   const int M = N + 7;   const int MOD = 1e9 + 7;   const long long INF = 1e16 + 17;   const int K = 5;   void ex() {     printf( -1 n );     exit(0);   }   int a[M];   int l[M], r[M], len[M];   int an[M];   bool dp[M][K + 3];   pair<int, int> par[M][K + 3];   bool cmp(int i, int j) { return l[i] < l[j]; }   void fillLR(int tl, int tr, int cnt, int st) {     if (tl > tr) return;     int d = tr - tl + 1;     int cur = d / cnt;     for (int i = st; i < st + cnt; ++i) {       int x = cur + (d % cnt > i - st);       while (x-- && tl <= tr) an[tl++] = i;     }   }   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; ++i) {       scanf( %d , &a[i]);       l[a[i]] = l[a[i]] ? l[a[i]] : i;       r[a[i]] = i;     }     vector<int> ord;     for (int i = 1; i <= N; ++i) {       if (l[i]) {         len[i] = r[i] - l[i] + 1;         ord.push_back(i);       }       if (len[i] > 5) ex();     }     l[0] = -4;     r[0] = 0;     len[0] = K;     ord.push_back(0);     sort(ord.begin(), ord.end(), cmp);     for (int t = 1; t < (int)ord.size(); ++t) {       if (l[ord[t]] <= r[ord[t - 1]]) ex();     }     dp[0][0] = true;     int m = (int)ord.size() - 1;     for (int t = 1; t <= m; ++t) {       int i = ord[t];       int j = ord[t - 1];       for (int rr = 0; rr + len[j] <= K; ++rr) {         if (!dp[t - 1][rr]) continue;         for (int tr = 0; tr + len[i] <= K; ++tr) {           for (int tl = 0; tl + tr + len[i] <= K; ++tl) {             if (tr + tl + len[i] < 2) continue;             int dist = (l[i] - tl) - (r[j] + rr) - 1;             int cnt = i - j - 1;             if (cnt * 2 <= dist && dist <= cnt * 5) {               dp[t][tr] = true;               par[t][tr] = make_pair(tl, rr);             }           }         }       }     }     int ans = 0, k = 0;     for (int tr = 0; tr + len[ord[m]] <= K && r[ord[m]] + tr <= n; ++tr) {       if (dp[m][tr]) {         int len = n - r[ord[m]] - tr;         if (len != 1) {           fillLR(r[ord[m]] + tr + 1, n, len / 2, ord[m] + 1);           k = tr;           ans = ord[m] + len / 2;           break;         }       }     }     if (!ans) ex();     while (m) {       int cnt = ord[m] - ord[m - 1] - 1;       pair<int, int> cur = par[m][k];       fillLR(l[ord[m]] - cur.first, r[ord[m]] + k, 1, ord[m]);       fillLR(r[ord[m - 1]] + cur.second + 1, l[ord[m]] - cur.first - 1, cnt,              ord[m - 1] + 1);       m--;       k = cur.second;     }     printf( %d n , ans);     for (int i = 1; i <= n; ++i) printf( %d  , an[i]);     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mxN = 302;   bool ar[mxN];   int p, n;   void solve() {     cin >> p >> n;     for (int i = 0; i < n; i++) {       int a;       cin >> a;       int temp = a % p;       if (ar[temp] == 0) {         ar[temp] = 1;       } else {         cout << i + 1;         return;       }     }     cout << -1;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int t = 1, i = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1.01E6;   vector<int> ans[MAXN];   char C[MAXN];   int A[MAXN];   int B[MAXN];   int n, top1, top2;   int main(void) {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     cin >> (C + 1), n = strlen(C + 1);     for (int i = 1; i <= n; ++i) {       if (C[i] ==  0 ) {         if (top2 == 0)           A[++top1] = i, ans[i].push_back(i);         else {           int nowPos = B[top2--];           ans[nowPos].push_back(i), A[++top1] = nowPos;         }       } else {         if (top1 == 0) return puts( -1 ) * 0;         int nowPos = A[top1--];         ans[nowPos].push_back(i), B[++top2] = nowPos;       }     }     if (top2) return puts( -1 ) * 0;     int o = 0;     cout << top1 <<   n ;     for (int i = 1; i <= top1; ++i) {       int id = A[i];       cout << ans[id].size() <<    ;       for (int a : ans[id]) cout << a <<    ;       cout <<   n ;     }     return 0;   }