malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int n, k;   long long a[10010];   int main() {     scanf( %d%d , &n, &k);     for (int i = 1; i <= n; i++) scanf( %lld , &a[i]);     sort(a + 1, a + 1 + n);     long long sum = 0;     for (int i = 1; i <= k; i++) sum += a[i];     printf( %lld n , sum);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void err() { cout << endl; }   template <class T, class... Ts>   void err(const T &arg, const Ts &...args) {     cout << arg <<    ;     err(args...);   }   using ll = long long;   using db = double;   const int N = 1e5 + 10;   int n, m, q;   int deg[N];   vector<vector<int>> G;   ll f(ll x) { return 1ll * (deg[x] - G[x].size()) * G[x].size(); }   void RUN() {     while (cin >> n >> m) {       G.clear();       G.resize(n + 1);       memset(deg, 0, sizeof deg);       for (int i = 1, u, v; i <= m; ++i) {         cin >> u >> v;         if (u > v) {           swap(u, v);         }         deg[u]++, deg[v]++;         G[u].push_back(v);       }       ll res = 0;       for (int i = 1; i <= n; ++i) {         res += f(i);       }       cout << res <<   n ;       cin >> q;       while (q--) {         int u;         cin >> u;         res -= f(u);         for (auto &v : G[u]) {           res -= f(v);           G[v].push_back(u);           res += f(v);         }         G[u].clear();         res += f(u);         cout << res <<   n ;       }     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr), cout.tie(nullptr);     RUN();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e6 + 5;   int t, n, h, m, a[maxn], x;   int sum;   int main() {     ios::sync_with_stdio(0);     cin >> n >> h >> m;     for (int i = 1; i <= n; ++i) a[i] = h;     for (int i = 0; i < m; ++i) {       int l, r, w;       cin >> l >> r >> w;       for (int i = l; i <= r; ++i) {         a[i] = min(a[i], w);       }     }     long long ac = 0;     for (int i = 1; i <= n; ++i) {       ac += a[i] * a[i];     }     cout << ac << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool check(long long int n, long long int k) {     long long int sum = k;     long long int A[k];     fill(A, A + k, 1);     for (long long int i = k - 1; i >= 0; --i) {       while (sum + A[i] <= n) {         sum += A[i];         A[i] *= 2;       }     }     if (sum != n) {       return 0;     }     return 1;   }   int main() {     ios_base ::sync_with_stdio(false), cin.tie(NULL);     long long int a, b;     cin >> a >> b;     for (long long int i = 0; i < 33; i++) {       long long int x = a - i * (b);       if (check(x, i)) return cout << i <<   n , 0;     }     cout << -1 <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k;   char arr[2 * 1000 + 5];   int cum[2 * 1000 + 5];   void read_input() {     cin >> n;     cum[0] = 0, k = 0;     for (int i = 1; i <= n; i++) {       cin >> arr[i];       arr[i + n] = arr[i];       cum[i] = cum[i - 1];       if (arr[i] ==  T )         cum[i] += 1;       else         k++;     }     for (int i = n + 1; i < n + k; i++) {       cum[i] = cum[i - 1];       if (arr[i] ==  T ) cum[i] += 1;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cerr.tie(0);     read_input();     int min_swaps = INT_MAX;     for (int i = k; i < n + k; i++) {       min_swaps = min(min_swaps, cum[i] - cum[i - k]);     }     cout << min_swaps <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   set<pair<long long, long long> > s1;   long long a[212345], ans[212345];   long long b[212345];   signed main() {     std::ios::sync_with_stdio(false);     long long n, m;     cin >> n >> m;     for (long long i = 1; i <= n; i++) cin >> a[i];     for (long long i = 1; i <= m; i++) {       long long b2;       cin >> b[i] >> b2;       pair<long long, long long> now = make_pair(b2, i);       s1.insert(now);       while (*s1.begin() != now) s1.erase(s1.begin());     }     s1.insert(make_pair(0, 0));     set<pair<long long, long long> >::iterator t = s1.end();     t--;     for (long long i = (*t).first + 1; i <= n; i++) ans[i] = a[i];     sort(a + 1, a + (*t).first + 1);     long long l = 0, r = (*t).first + 1;     while (t != s1.begin()) {       set<pair<long long, long long> >::iterator tl = t;       tl--;       for (long long i = (*t).first; i > (*tl).first; i--) {         if (b[(*t).second] == 1)           ans[i] = a[--r];         else           ans[i] = a[++l];       }       t--;     }     for (long long i = 1; i <= n; i++) cout << ans[i] <<    ;     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #pragma comment(linker,  /STACK:256000000 )   template <typename T>   int size(T& a) {     return (int)a.size();   }   template <typename T>   T sqr(T a) {     return a * a;   }   int main() {     int a, b, mod;     cin >> a >> b >> mod;     int ta = a, tb = b;     a %= mod;     b %= mod;     a += mod;     b += mod;     a = min(a, ta);     b = min(b, tb);     int r = 1;     for (int i = (0); i < (9); ++i) r = (r * 10) % mod;     for (int i = 0; i <= a; ++i) {       int c = (long long)r * i % mod;       int z = (mod - c);       if (z >= mod) z -= mod;       if (z <= b) {         continue;       }       printf( 1  );       printf( %0*d , 9, i);       return 0;     }     printf( 2 );   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using PII = pair<int, int>;   const int mod = 998244353;   const int inf = 1 << 30;   const int maxn = 100000 + 5;   int n, k, alive[maxn];   int query(int x) {     cout <<  ?   << x << endl;     string s;     cin >> s;     if (s ==  Y ) {       alive[x] = false;       return true;     } else {       return false;     }   }   void reset() { cout <<  R  << endl; }   int main() {     cin >> n >> k;     fill(alive + 1, alive + 1 + n, true);     int B = max(k / 2, 1), Bcnt = n / B;     for (int i = 1; i <= Bcnt; i++) {       for (int j = 0; j < i && i + j < Bcnt; j++) {         for (int k = j; k < Bcnt; k += i) {           for (int p = 1; p <= B; p++) {             query(k * B + p);           }         }         reset();       }     }     cout <<  !   << count(alive + 1, alive + 1 + n, true) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n;       int nLund0 = 0;       int nRund0 = 0;       int n00 = 0;       int nL = 0;       int nR = 0;       auto zaehle = [&](char c1, char c2) -> void {         if ((c1 ==  >  && c2 ==  - ) || (c2 ==  >  && c1 ==  - )) nRund0++;         if ((c1 ==  <  && c2 ==  - ) || (c2 ==  <  && c1 ==  - )) nLund0++;         if (c1 ==  >  && c2 ==  > ) nR++;         if (c1 ==  <  && c2 ==  < ) nL++;         if (c1 ==  -  && c2 ==  - ) n00++;       };       cin >> n;       char c1 = 0, c2 = 0;       char c0;       for (int i = 0; i < n; ++i) {         if (i > 0) c1 = c2;         cin >> c2;         if (i == 0) {           c0 = c2;           continue;         }         zaehle(c1, c2);       }       zaehle(c2, c0);       cout << nRund0 + nLund0 + n00 + nL * ((nLund0 + nL + n00) == n ? 1 : 0) +                   nR * ((nRund0 + nR + n00) == n ? 1 : 0)            << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int M = 1e5, INF = 1e9;   const double PI = 3.141592653589793238462643383279502884197, eps = 1e-9;   int sum;   void getstring(int st, int ed, int n, bool val) {     string s;     sum = 0;     cout <<  ?  ;     for (int i = 0; i < st; i++) cout << 0;     for (int i = st; i < ed; i++)       cout << (i % 2 ? !val : val),           sum += ((val && i % 2 == 0) || (!val && i % 2));     for (int i = ed; i < n; i++) cout << 0;     cout << endl;   }   bool check(int cnt, int total, bool x) {     return (cnt != total + sum && x) || (cnt != total - sum && !x);   }   int main() {     int n, total, cnt, st, ed, md;     bool val, x;     string s1, s2;     cin >> n;     cout <<  ?  ;     for (int i = 0; i < n; i++) cout << 0;     cout << endl;     cin >> total;     cout <<  ?  ;     for (int i = 1; i < n; i++) cout << 0;     cout << 1 << endl;     cin >> cnt;     x = (cnt == total - 1);     getstring(0, n, n, 0);     cin >> cnt;     val = !check(cnt, total, !x);     st = 0, ed = n - 1;     while (st < ed) {       md = (st + ed) / 2;       getstring(st, md + 1, n, val);       cin >> cnt;       if (check(cnt, total, !x))         ed = md;       else         st = md + 1;     }     if (x)       cout <<  !   << st + 1 <<     << n;     else       cout <<  !   << n <<     << st + 1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     if (n & 1) {       cout << 0;     } else {       int res = n / 4;       if (n % 4 == 0) {         res--;       }       cout << res;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 4e5 + 5, M = 205, INF = 1e9, MOD2 = 1e9 + 7;   int n, k, y, x[N], mem[N][3], freq[N];   int cur = 0, last = -1;   vector<int> vec;   int solve(int idx, int rem) {     if (!rem) return 0;     if (idx > cur) return 0;     int& ret = mem[idx][rem];     if (~ret) return ret;     ret = 0;     ret = solve(idx + 1, rem);     int last =         upper_bound(vec.begin(), vec.end(), vec[idx] + k) - vec.begin() - 1;     int c2 = freq[last];     if (idx) c2 -= freq[idx - 1];     ret = max(ret, solve(last + 1, rem - 1) + c2);     return ret;   }   void runtestcase() {     cin >> n >> k;     vec.clear();     for (int i = 0; i < n; ++i) {       cin >> x[i];       vec.push_back(x[i]);       mem[i][2] = mem[i][1] = -1;       freq[i] = 0;     }     freq[n] = 0;     sort(vec.begin(), vec.end());     cur = -1, last = -1;     for (int i = 0; i < n; ++i) {       if (last != vec[i]) last = vec[i], ++cur;       freq[cur]++;     }     for (int i = 1; i <= cur; ++i) freq[i] += freq[i - 1];     for (int i = 0; i < n; ++i) cin >> y;     vec.erase(unique(vec.begin(), vec.end()), vec.end());     cout << solve(0, 2);   }   int main() {     cout << fixed << setprecision(12), ios::sync_with_stdio(false),         cin.tie(nullptr), cout.tie(nullptr);     int t = 1, tt = 1;     cin >> t;     while (t) {       runtestcase();       cout <<   n ;       --t, ++tt;     }   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   T gcd(T a, T b) {     T r;     while (b != 0) {       r = a % b;       a = b;       b = r;     }     return a;   }   template <class T>   T lcm(T a, T b) {     return a / gcd(a, b) * b;   }   template <class T>   int getbit(T s, int i) {     return (s >> i) & 1;   }   template <class T>   T onbit(T s, int i) {     return s | (T(1) << i);   }   template <class T>   T offbit(T s, int i) {     return s & (~(T(1) << i));   }   const double PI = 2 * acos(0.0);   const double eps = 1e-9;   const int infi = 1e9;   const long long Linfi = (long long)1e18;   const long long MOD = 1000000007;   const int c1 = 11;   const int c2 = 13;   int n, m, dx, dy;   int a[100005], b[100005];   map<int, int> M;   long long power(int a, int p, int M) {     if (p == 0) return 1;     if (p == 1) return a % M;     long long ans = power(a, p / 2, M);     ans = (ans * ans) % M;     if (p % 2 == 1) ans = (ans * a) % M;     return ans;   }   int phiEuler(int n) {     int res = n;     for (int i = 2; i * i <= n; i++) {       if (n % i == 0) res -= res / i;       while (n % i == 0) n /= i;     }     if (n > 1) res -= res / n;     return res;   }   void solve() {     int phi = phiEuler(n);     for (int i = 1; i <= m; i++) {       long long inver = power(dx, phi - 1, n);       long long k = inver * (n - a[i]);       k %= n;       long long tmp = (b[i] + k * dy) % n;       M[tmp]++;     }     int maxx = 0, val = -1;     for (typeof(M.begin()) i = M.begin(); i != M.end(); i++) {       if (i->second > maxx) {         maxx = i->second;         val = i->first;       }     }     cout << 0 <<     << val << endl;   }   int main() {     ios::sync_with_stdio(false);     cin >> n >> m >> dx >> dy;     for (int i = 1; i <= m; i++) {       cin >> a[i] >> b[i];     }     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     long long a, b;     cin >> a >> b;     long long count = 0;     while (b >= a) {       ostringstream str1;       str1 << a;       string str2 = str1.str();       for (long long i = 0; i < str2.length(); i++) {         if (str2[i] ==  2  || str2[i] ==  3  || str2[i] ==  5 ) {           count += 5;         } else if (str2[i] ==  0  || str2[i] ==  6  || str2[i] ==  9 ) {           count += 6;         } else if (str2[i] ==  1 ) {           count += 2;         } else if (str2[i] ==  4 ) {           count += 4;         } else if (str2[i] ==  7 ) {           count += 3;         } else if (str2[i] ==  8 ) {           count += 7;         }       }       a++;     }     cout << count << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n;     cin >> n;     set<long long int> s;     long long int a[n];     for (int i = 0; i < n; i++) {       cin >> a[i];       if (a[i] > 0) {         s.insert(a[i]);       }     }     long long int len1 = s.size();     cout << len1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct Q {     int r1, r2, c1, c2, idx;   };   int n, m, k, q;   Q qs[200001];   vector<int> qAtRow[100001];   vector<int> qAtCol[100001];   vector<int> atCol[100001];   vector<int> atRow[100001];   bool must[200000];   bool res[200000];   int v[100001];   int Z = 400001;   int seg[400001];   int at, val;   void update(int n, int s, int e) {     if (at < s || at > e) return;     if (s == e) {       if (seg[n] == (1 << 29))         seg[n] = val;       else         seg[n] = val;       return;     }     update(n * 2, s, (s + e) / 2);     update(n * 2 + 1, (s + e) / 2 + 1, e);     seg[n] = max(seg[n * 2], seg[n * 2 + 1]);   }   int l, r;   int get(int n, int s, int e) {     if (l > e || r < s) return -1;     if (s >= l && e <= r) return seg[n];     return max(get(n * 2, s, (s + e) / 2), get(n * 2 + 1, (s + e) / 2 + 1, e));   }   int main() {     scanf( %d%d%d%d , &n, &m, &k, &q);     for (int i = 0; i < k; ++i) {       int r, c;       scanf( %d%d , &r, &c);       atCol[c].push_back(r);       atRow[r].push_back(c);     }     for (int i = 0; i < q; ++i) {       Q &t = qs[i];       scanf( %d%d%d%d , &t.r1, &t.c1, &t.r2, &t.c2);       t.idx = i;       qAtCol[t.c1].push_back(i);       qAtRow[t.r1].push_back(i);     }     for (int i = 0; i < Z; ++i) seg[i] = 1 << 29;     for (int i = n; i > 0; --i) {       for (int j = 0; j < atRow[i].size(); ++j) {         at = atRow[i][j];         val = i;         update(1, 1, m);       }       for (int j = 0; j < qAtRow[i].size(); ++j) {         Q &t = qs[qAtRow[i][j]];         l = t.c1;         r = t.c2;         int a = get(1, 1, m);         if (a <= 0 || a > t.r2) must[t.idx] = true;       }     }     for (int i = 0; i < Z; ++i) seg[i] = 1 << 29;     for (int i = m; i > 0; --i) {       for (int j = 0; j < atCol[i].size(); ++j) {         at = atCol[i][j];         val = i;         update(1, 1, n);       }       for (int j = 0; j < qAtCol[i].size(); ++j) {         Q &t = qs[qAtCol[i][j]];         l = t.r1;         r = t.r2;         int a = get(1, 1, n);         if (must[t.idx] && (a <= 0 || a > t.c2)) res[t.idx] = true;       }     }     for (int i = 0; i < q; ++i)       if (res[i])         puts( NO );       else         puts( YES );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long int> glen(100001);   long long int M = 1000000007;   long long int n1, n2 = 0, sum = 0;   long long int gcd(long long int a, long long int b) {     return (b == 0) ? a : gcd(b, a % b);   }   long long int lcm(long long int a, long long int b) {     long long int g = gcd(a, b);     long long int l = (a * b) / g;     return l;   }   long long int po(long long int a, long long int b) {     if (b == 0) return 1;     long long int temp = po(a, b / 2);     long long int z = ((temp % M) * (temp % M)) % M;     if (b % 2)       return ((z % M) * (a % M)) % M;     else       return z;   }   bool fun1(char c) {     if (c ==  1  || c ==  2 ) return true;     return false;   }   bool fun3(char c) {     if (c ==  1  || c ==  2 ) return false;     return true;   }   long long int fun(long long int dp[], long long int n, long long int left) {     if (dp[n] != 0) return dp[n];     if (n == left) return 1;     long long int ans = 0;     long long int limit = n - left;     for (long long int i = 1; i < limit + 1; i++) {       ans += fun(dp, n - i, left - 1);     }     return ans;   }   bool compare(pair<double, long long int> p1, pair<double, long long int> p2) {     if (p1.first != p2.first) {       return p1.first > p2.first;     }     return p1.second < p2.second;   }   struct HASH {     size_t operator()(const pair<double, long long int>& x) const {       return hash<long long>()(((long long)x.first) ^                                (((long long)x.second) << 32));     }   };   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long int t = 1;     long long int cs = 1;     while (t--) {       long long int n, k, m;       cin >> n >> k >> m;       long long int ans = 0;       long long int a[n];       for (long long int i = 0; i < n; i++) cin >> a[i];       long long int b;       map<long long int, vector<long long int>> mp;       for (long long int i = 0; i < n; i++) {         b = a[i] % m;         mp[b].push_back(a[i]);       }       long long int f = 0;       for (auto i : mp) {         if (mp[i.first].size() >= k) {           f = 1;           cout <<  Yes n ;           long long int s = 0;           for (auto j : mp[i.first]) {             cout << j <<    ;             s++;             if (s == k) break;           }           break;         }       }       if (f == 0) cout <<  No n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ld = long double;   using pii = pair<int, int>;   const int maxn = 2e5 + 100;   const int mod = 998244353;   mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());   ll fact[maxn], inv[maxn];   ll pwr(ll a, ll pw) {     ll ret = 1;     while (pw > 0) {       if (pw & 1) ret = ret * a % mod;       a = a * a % mod;       pw >>= 1;     }     return ret;   }   ll modinv(ll a) { return pwr(a, mod - 2); }   ll choose(ll N, ll K) { return fact[N] * inv[K] % mod * inv[N - K] % mod; }   int main() {     ios_base::sync_with_stdio(false), cin.tie(0);     fact[0] = inv[0] = 1;     for (ll i = 1; i < maxn; i++) {       fact[i] = fact[i - 1] * i % mod;       inv[i] = modinv(fact[i]);     }     int n, k;     cin >> n >> k;     vector<int> v(n);     for (int i = 0; i < n; i++) cin >> v[i];     int cnt = 0;     for (int i = 0; i < n; i++)       if (v[i] != v[(i + 1) % n]) ++cnt;     ll same = 0;     for (int c = 0; c * 2 <= cnt; c++)       same = (same + choose(cnt, c) * choose(cnt - c, c) % mod *                          pwr(k - 2, cnt - 2 * c)) %              mod;     same = same * pwr(k, n - cnt) % mod;     ll ans = ((pwr(k, n) - same + mod) % mod) * modinv(2) % mod;     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   int main() {     int n;     scanf( %d , &n);     while (n--) {       int tenth = 10;       int F = 0;       char input[15];       char A[15] = {           0,       };       scanf( %s , input);       for (int i = 4; i < strlen(input); i++) A[i - 4] = input[i];       for (int i = 1; i < strlen(A); i++) {         F += tenth;         tenth *= 10;       }       int year = atoi(A);       while (year < 1989 + F) year += tenth;       printf( %d n , year);     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = (int)3e5 + 1;   int n, m, a[N][10], p1 = 1, p2 = 1;   int ok[(1 << 8) + 1];   bool check(int x) {     memset(ok, 0, sizeof(ok));     for (int i = 1; i <= n; ++i) {       int mask = 0;       for (int j = 0; j < m; ++j) {         if (a[i][j] >= x) mask |= (1 << j);       }       for (int j = 0; j < (1 << m); ++j) {         if (ok[j] && (mask | j) == (1 << m) - 1) {           p1 = ok[j];           p2 = i;           return true;         }       }       ok[mask] = i;     }     return false;   }   void solve() {     cin >> n >> m;     for (int i = 1; i <= n; ++i) {       for (int j = 0; j < m; ++j) cin >> a[i][j];     }     int l = 0, r = (int)1e9;     while (l <= r) {       int mid = (l + r) / 2;       if (check(mid)) {         l = mid + 1;       } else         r = mid - 1;     }     cout << p1 <<     << p2;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main(void) {     int num[102];     int a, i, sum = 0, flag = 1;     scanf( %d , &a);     for (i = 0; i < a; i++) {       scanf( %d , &num[i]);     }     if (a < 3) {       printf( -1 n );     } else {       for (i = a - 1; i >= 0; i--) {         if (i == a - 1 && i % 2 && num[i]) {           flag = 0;           break;         }         if (num[i] > 0) {           if (i % 2) {             sum += num[i];             num[i / 2] -= num[i];             num[i] = 0;           } else {             sum += num[i];             if (i) {               num[i - 1] -= num[i];               num[i / 2 - 1] -= num[i];             }             num[i] = 0;           }         }       }       if (flag) {         printf( %d n , sum);       } else {         printf( -1 n );       }     }     return 0;   }
#include <bits/stdc++.h>   #define F(i,j,k) for(int i=(j);i<=(k);++i)   #define D(i,j,k) for(int i=(j);i>=(k);--i)   #define rep(it,s) for(__typeof(s.begin()) it=s.begin();it!=s.end();++it)   #define Rep(a,s) for(auto a:s)   #define PB push_back   #define MP make_pair   #define FF first   #define SS second   typedef long long ll;   typedef unsigned long long ull;   using namespace std;   ll quick_pow(ll x,ll y,ll Mod){       ll res=1;       while(y){           if(y&1)res=res*x%Mod;           x=x*x%Mod,y>>=1;       }       return res;   }   ll inv(ll x,ll Mod){return quick_pow(x,Mod-2,Mod);}   namespace IO{       template <class T>       inline void read(T &x){           x=0;int f=1;char ch=getchar();           while(ch< 0 ||ch> 9 ){if(ch== - )f=-1;ch=getchar();}           while(ch<= 9 &&ch>= 0 )x=x*10+ch- 0 ,ch=getchar();           x*=f;       }   };   using namespace IO;   const int N=100005;   vector<int>ans,vec0,vec1;   bool calc(int x,int y){    if(x==0||x==2)return 0;//没间隔     if(x>1&&y==0)return 0;    if(x%2==0&&y<=1)return 0;    if(x%2==0){     ans.PB(2);     x-=3;    }    while(x>1){     ans.PB(1);     x-=2;    }    return 1;   }   void solve(int x){    int flag=1;    ans.clear();    //Rep(y,vec0){    for(int i=0;i<vec0.size();i++){     int y=vec0[i];     flag&=calc(y-x,x);     if(i+1!=vec0.size())ans.PB(vec1[i]+x);    }    if(flag){     cout<<ans.size()<<  n ;     Rep(y,ans)cout<<y<<   ;     exit(0);    }   }   char s[N];   int cnt0,cnt1;   int main(){       #ifndef ONLINE_JUDGE           freopen( in.txt , r ,stdin);           //freopen( out.txt , w ,stdout);       #endif       scanf( %s n ,s+1);    int n=strlen(s+1);    //if(s[1]== # )vec0.PB(1);    F(i,1,n){     if(s[i]== _ ){      if(cnt1)vec1.PB(cnt1);      cnt1=0,cnt0++;     }     else{      if(!vec0.size())vec0.PB(cnt0+1);      else if(cnt0)vec0.PB(cnt0);      cnt0=0,cnt1++;     }    }    vec0.PB(cnt0+1);    if(cnt1)vec1.PB(cnt1);    //Rep(y,vec0)cout<<y<<   ;cout<<endl;    //Rep(y,vec1)cout<<y<<   ;cout<<endl;    if(!vec1.size()){     cout<<0<<  n n ;     return 0;    }    int mink=1e9;    Rep(y,vec0)mink=min(mink,y);    F(i,0,min(mink,3)){     solve(i);    }    cout<<-1;       return 0;   }