malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     long n = 0, m = 0;     cin >> n;     vector<int> hit(n, -1);     map<int, pair<int, int> > circle;     for (int i = 0; i < n; i++) {       int c, r;       cin >> c >> r;       circle.insert(make_pair(c, make_pair(r, i)));     }     int hits = 0;     cin >> m;     for (int i = 0; i < m; i++) {       int x, y;       cin >> x >> y;       map<int, pair<int, int> >::iterator it = circle.upper_bound(x);       for (int j = 0; j < 2; j++) {         if (it == circle.end()) it--;         int c = it->first, r = it->second.first, n = it->second.second;         if ((x - c) * (x - c) + y * y <= r * r) {           if (hit[n] < 0) {             hits++;             hit[n] = i + 1;           }         }         if (it == circle.begin()) {           break;         }         --it;       }     }     cout << hits << endl;     for (int i = 0; i < hit.size(); i++) {       cout << hit[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = int(1e9) + 7;   const int maxn = 200010;   int n;   long long a[maxn];   long long fact[maxn];   long long ans;   void read() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i) scanf( %I64d , &a[i]);   }   long long exp(long long x) {     long long s = 1, times = mod - 2;     while (times) {       if (times & 1) s = s * x % mod;       x = x * x % mod;       times >>= 1;     }     return s;   }   long long calc(int x, int y) {     return (fact[x] * exp(fact[y] * fact[x - y] % mod) % mod);   }   void solve() {     if (n == 1) {       ans = a[1];       return;     }     if (n & 1) {       for (int i = 1; i < n; ++i) a[i] += ((i & 1) ? a[i + 1] : -a[i + 1]);       --n;     }     fact[0] = 1;     for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i % mod;     ans = 0;     if (n % 4 == 0) {       for (int i = 1; i <= n; ++i) {         long long tmp = calc(n / 2 - 1, (i - 1) / 2) * a[i] % mod;         if (i & 1)           ans = (ans + tmp) % mod;         else           ans = (ans - tmp + mod) % mod;       }     } else {       for (int i = 1; i <= n; ++i)         ans = (ans + calc(n / 2 - 1, (i - 1) / 2) * a[i] % mod) % mod;     }   }   int main() {     read();     solve();     while (ans < 0) ans += mod;     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int it[1000100 * 5], a[1000100];   char s[1000100];   void incIT(int node, int l, int r, int pos, int k) {     if (pos < l || pos > r) return;     if (l == r) {       it[node] += k;       return;     }     incIT(node * 2, l, (l + r) / 2, pos, k);     incIT(node * 2 + 1, (l + r) / 2 + 1, r, pos, k);     it[node] = it[node * 2] + it[node * 2 + 1];   }   int findAndDec(int node, int l, int r, int pos, int k) {     if (l == r) {       it[node] -= k;       return l;     }     int res = 0;     if (it[node * 2] >= pos)       res = findAndDec(node * 2, l, (l + r) / 2, pos, k);     else       res = findAndDec(node * 2 + 1, (l + r) / 2 + 1, r, pos - it[node * 2], k);     it[node] = it[node * 2] + it[node * 2 + 1];     return res;   }   int main() {     cin.sync_with_stdio(false);     int n, m;     cin >> n >> m;     for (int i = 0; i < m; ++i) cin >> a[i];     int cnt = 0;     for (int i = 0; i < n; ++i) {       int x;       cin >> x;       if (x == -1) {         int mm = upper_bound(a, a + m, it[1]) - a;         for (int j = mm - 1; j >= 0; --j) findAndDec(1, 1, n, a[j], 1);       } else {         s[++cnt] =  0  + x;         incIT(1, 1, n, cnt, 1);       }     }     int len = 0;     while (it[1] > 0) {       int pos = findAndDec(1, 1, n, 1, 1);       s[len++] = s[pos];     }     s[len] =   0 ;     if (len == 0)       cout <<  Poor stack!  << endl;     else       cout << s << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char a[1000005];   char b[1000005];   int main(void) {     int n;     cin >> n >> (a + 1) >> (b + 1);     int ok = 0;     for (int i = 1; i <= n; ++i) ok += a[i] != b[i];     if (!ok) return cout <<  26 n , 0;     if (ok == 1) return cout <<  2 n , 0;     string k =   , l =   ;     for (int i = 1; i <= n; ++i) k += a[i];     for (int i = 1; i <= n; ++i) l += b[i];     int cnt = 0, ans = 0;     while (k[cnt] == l[cnt]) ++cnt;     k.insert(k.begin() + cnt, l[cnt]);     while (k[cnt] == l[cnt]) ++cnt;     l.insert(l.begin() + cnt, k[cnt]);     ans += (k == l);     k =   ;     l =   ;     for (int i = 1; i <= n; ++i) k += a[i];     for (int i = 1; i <= n; ++i) l += b[i];     cnt = 0;     while (k[cnt] == l[cnt]) ++cnt;     l.insert(l.begin() + cnt, k[cnt]);     while (k[cnt] == l[cnt]) ++cnt;     k.insert(k.begin() + cnt, l[cnt]);     ans += (k == l);     return cout << ans <<   n , 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     char s[111111];     scanf( %s , s);     int len = strlen(s);     int i;     if (len == 1 && s[0] ==  a ) {       puts( z );       return 0;     }     i = 0;     while (s[i] ==  a ) {       i++;     }     if (i == len) {       s[len - 1] =  z ;     }     for (; i < len; i++) {       if (s[i] ==  a ) break;       s[i]--;     }     printf( %s n , s);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MX = 1005;   struct Edge {     int v, nxt;   } edge[MX * MX];   int head[MX], tot, c[MX], E[MX], V[MX], vis[MX];   void add(int u, int v) {     edge[tot].v = v;     edge[tot].nxt = head[u];     head[u] = tot++;   }   void dfs(int u, int &e, int &v) {     for (int i = head[u]; ~i; i = edge[i].nxt) {       int vv = edge[i].v;       e++;       if (vis[vv]) continue;       v++;       vis[vv] = 1;       dfs(vv, e, v);     }   }   int main() {     int n, m, k;     while (~scanf( %d%d%d , &n, &m, &k)) {       memset(head, -1, sizeof(head));       memset(vis, 0, sizeof(vis));       memset(E, 0, sizeof(E));       memset(V, 0, sizeof(V));       tot = 0;       for (int i = 0; i < k; i++) scanf( %d , &c[i]);       for (int i = 0; i < m; i++) {         int u, v;         scanf( %d%d , &u, &v);         add(u, v);         add(v, u);       }       int ans = 0, mx = 0, c1 = n, c2 = m;       for (int i = 0; i < k; i++) {         int v = c[i];         vis[v] = 1;         V[v]++;         dfs(v, E[v], V[v]);         c1 -= V[v];         c2 -= E[v] / 2;         if (V[mx] < V[v]) mx = v;         ans += V[v] * (V[v] - 1) / 2 - E[v] / 2;       }       ans += (V[mx] + c1) * (V[mx] + c1 - 1) / 2 - c2 - V[mx] * (V[mx] - 1) / 2;       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   bool check(int num) {     if (1 == num) return true;     for (int i = 2; i <= num / i; i++) {       if (num % i == 0) {         return false;       }     }     return true;   }   int main() {     cin >> n;     if (check(n)) {       printf( 1 n );       printf( %d n , n);     } else if (check(n - 2)) {       printf( 2 n );       printf( 2 %d n , n - 2);     } else if (check(n - 4)) {       printf( 3 n );       printf( 2 2 %d n , n - 4);     } else {       bool result = false;       int i, even;       int prime1, temp, prime2;       for (int num = 3; num < n / 3 + 10; num++) {         if (!check(num)) continue;         even = n - num;         for (prime1 = 3; prime1 <= even / 2; prime1 += 2) {           for (temp = 2; temp <= sqrt(prime1); temp++) {             if (prime1 % temp == 0) break;           }           if (temp > sqrt(prime1))             prime2 = even - prime1;           else             continue;           for (temp = 2; temp <= sqrt(prime2); temp++) {             if (prime2 % temp == 0) break;           }           if (temp > sqrt(prime2)) {             cout << 3 << endl << num <<     << prime1 <<     << prime2 << endl;             result = true;             break;           }         }         if (!result)           continue;         else           break;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100007;   int n, k, a[N];   bool solve() {     bool exists = false;     for (int i = 0; i < n; ++i) {       cin >> a[i];       if (a[i] == k) {         exists = true;       }     }     if (!exists) {       return false;     }     if (n == 1) return true;     for (int i = 0; i < n; ++i) {       int ct = 0;       for (int j = i; j < i + 3 && j < n; ++j) {         if (a[j] >= k) {           ct++;         }       }       if (ct >= 2) {         return true;       }     }     return false;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t;     cin >> t;     while (t--) {       cin >> n >> k;       if (solve()) {         cout <<  yes n ;       } else {         cout <<  no n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = acos(-1);   void fft(vector<complex<double> >& a, bool invert) {     int n = (int)a.size();     for (int i = 1, j = 0; i < n; ++i) {       int bit = n >> 1;       for (; j >= bit; bit >>= 1) j -= bit;       j += bit;       if (i < j) swap(a[i], a[j]);     }     for (int len = 2; len <= n; len <<= 1) {       double ang = 2 * PI / len * (invert ? -1 : 1);       complex<double> wlen(cos(ang), sin(ang));       for (int i = 0; i < n; i += len) {         complex<double> w(1);         for (int j = 0; j < len / 2; ++j) {           complex<double> u = a[i + j], v = a[i + j + len / 2] * w;           a[i + j] = u + v;           a[i + j + len / 2] = u - v;           w *= wlen;         }       }     }     if (invert)       for (int i = 0; i < n; ++i) a[i] /= n;   }   void multiply(const vector<long long int>& a, const vector<long long int>& b,                 vector<long long int>& res) {     vector<complex<double> > fa(a.begin(), a.end()), fb(b.begin(), b.end());     size_t n = 1;     while (n < max(a.size(), b.size())) n <<= 1;     n <<= 1;     fa.resize(n), fb.resize(n);     fft(fa, false), fft(fb, false);     for (size_t i = 0; i < n; ++i) fa[i] *= fb[i];     fft(fa, true);     res.resize(n);     for (size_t i = 0; i < n; ++i) res[i] = (long long int)(fa[i].real() + 0.5);   }   vector<long long int> now(1, 1);   int main() {     vector<long long int> res;     int n, x;     cin >> n >> x;     int need = n;     while (n--) {       int u;       cin >> u;       if (u < x) {         now.push_back(1);       } else {         ++now.back();       }     }     long long int w0 = 0;     for (auto e : now) {       w0 += e * (e - 1) / 2;     }     int k = now.size();     vector<long long int> nowr(now.rbegin(), now.rend());     nowr.back() = 0;     multiply(now, nowr, res);     cout << w0 <<    ;     for (int i = k - 2; i >= 0 && res[i]; i--) {       cout << res[i] <<    ;       --need;     }     while (need--) {       cout << 0 <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string proc(int a, int b) {     if (a * 2 > b) return  noob ;     if (a * 5 > b) return  random ;     if (a * 10 > b) return  average ;     if (a * 100 > b) return  hardcore ;     return  pro ;   }   int main() {     int i, n, x;     string s;     map<string, int> score;     cin >> n;     while (n--) {       cin >> s >> x;       if (score.find(s) == score.end()) score[s] = 0;       score[s] = max(score[s], x);     }     vector<int> list;     for (typeof(score.begin()) it = score.begin(); it != score.end(); it++)       list.push_back(it->second);     sort(list.rbegin(), list.rend());     cout << ((int)score.size()) << endl;     for (typeof(score.begin()) it = score.begin(); it != score.end(); it++) {       for (i = 0; i < (int)(((int)list.size())); i++)         if (list[i] == it->second) break;       cout << it->first <<     << proc(i, ((int)list.size())) << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s1, s2;     getline(cin, s1);     getline(cin, s2);     int yek1 = 0, yek2 = 0;     for (int i = 0; i < s1.size(); i++) {       if (s1[i] ==  1 ) yek1++;     }     for (int i = 0; i < s2.size(); i++) {       if (s2[i] ==  1 ) yek2++;     }     if (yek1 % 2 == 1) yek1++;     if (yek1 >= yek2) {       cout <<  YES ;       return 0;     }     cout <<  NO ;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   T min(T a, T b, T c) {     return min(a, min(b, c));   }   template <class T>   T min(T a, T b, T c, T d) {     return min(a, min(b, min(c, d)));   }   template <class T>   T max(T a, T b, T c) {     return max(a, max(b, c));   }   template <class T>   T max(T a, T b, T c, T d) {     return max(a, max(b, max(c, d)));   }   bool cmp(const pair<int, int>& a, const pair<int, int>& b) {     return (a.first > b.first || (a.first == b.first && a.second >= b.second));   }   long long GCD(long long a, long long b) { return (a % b) ? GCD(b, a % b) : b; }   const string namePro =  tmp ;   int nodes[4 * 1000007];   int a[1000007];   void initIT(int root, int left, int right) {     if (left == right) {       nodes[root] = a[left];       return;     }     int mid = (left + right) / 2;     initIT(2 * root, left, mid);     initIT(2 * root + 1, mid + 1, right);     nodes[root] = min(nodes[2 * root], nodes[2 * root + 1]);     return;   }   int queryIT(int root, int left, int right, int val) {     int mid = (left + right) / 2;     if (left == right) return left;     if (nodes[2 * root + 1] < val)       return queryIT(2 * root + 1, mid + 1, right, val);     else       return queryIT(2 * root, left, mid, val);   }   int main() {     int n;     scanf( %d , &n);     for (int i = (1); i <= (n); ++i) scanf( %d , &a[i]);     initIT(1, 1, n);     for (int i = (1); i <= (n); ++i) {       int k = queryIT(1, 1, n, a[i]);       if (k <= i)         printf( -1  );       else         printf( %d  , k - i - 1);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, s = 0;   int t[501][501];   int a = -1, b = -1, c = -1, d;   int g = -1;   int main() {     ios_base::sync_with_stdio(false);     cin >> n >> m;     for (int i = 0; i < n - 1; i++) {       for (int j = 0; j < m; j++) {         cin >> t[i][j];         if (j == 0) {           s = s ^ t[i][j];           a = t[i][j];         }         if (((!(t[i][j] == a)) && (j > 0)) && (b == -1)) {           b = i;           c = j + 1;         }       }     }     for (int j = 0; j < m; j++) {       cin >> d;       if (((s ^ d) > 0) && (g == -1)) {         g = j + 1;       }     }     if (g == -1) {       if (b == -1) {         cout <<  NIE  << endl;       } else {         cout <<  TAK  << endl;         for (int i = 0; i < n; i++) {           if (i == b) {             cout << c <<    ;           } else {             cout <<  1                   <<    ;           }         }       }     } else {       cout <<  TAK  << endl;       for (int i = 0; i < n - 1; i++) {         cout <<  1               <<    ;       }       cout << g <<    ;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline void umax(T &a, T b) {     if (a < b) a = b;   }   const int maxn = 4000 + 5;   const int INF = 1e9 + 7;   const double eps = 1e-8;   string a[10];   int dp[4][105];   int n, k;   int valid(int x, int y) {     if (x >= 0 && x < n && y >= 0 && y < 3) return true;     return false;   }   int rec(int posy, int posx) {     if (posy < 0 || posy >= 3) return 0;     if (posx >= n - 1) return 1;     if (dp[posy][posx] != -1) return dp[posy][posx];     int &ret = dp[posy][posx];     ret = 0;     if (posx >= n - 1) {       ret = 1;       return ret;     }     if (a[posy][posx + 1] !=  . ) {       ret = 0;       return ret;     }     for (int i = (-1); i < (2); i++) {       if (posy + i < 0 || posy + i >= 3) continue;       if (a[posy + i][posx + 1] !=  . ) continue;       if (a[posy + i][posx + 2] !=  . ) continue;       if (a[posy + i][posx + 3] !=  . ) continue;       ret |= rec(posy + i, posx + 3);     }     return ret;   }   inline void solve(void) {     int t;     cin >> t;     while (t--) {       memset(dp, -1, sizeof dp);       cin >> n >> k;       for (int i = (0); i < (3); i++) cin >> a[i];       for (int i = (0); i < (3); i++)         for (int j = (0); j < (7); j++) a[i].push_back( . );       int posy, posx;       for (int i = (0); i < (3); i++)         for (int j = (0); j < (n); j++)           if (a[i][j] ==  s ) posx = j, posy = i;       if (rec(posy, posx)) {         cout <<  YES n ;       } else         cout <<  NO n ;     }     return;   }   void init() {     ios::sync_with_stdio(false);     cin.tie(nullptr);   }   int main(int argc, const char *argv[]) {     init();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   namespace std {   template <typename T, typename U>   struct hash<pair<T, U>> {     hash<T> t;     hash<U> u;     size_t operator()(const pair<T, U>& p) const {       return t(p.first) ^ (u(p.second) << 7);     }   };   }  // namespace std   template <typename T, typename F>   T bsh(T l, T h, const F& f) {     T r = -1, m;     while (l <= h) {       m = (l + h) / 2;       if (f(m)) {         l = m + 1;         r = m;       } else {         h = m - 1;       }     }     return r;   }   template <typename T, typename F>   T bsl(T l, T h, const F& f) {     T r = -1, m;     while (l <= h) {       m = (l + h) / 2;       if (f(m)) {         h = m - 1;         r = m;       } else {         l = m + 1;       }     }     return r;   }   template <typename T>   T gcd(T a, T b) {     if (a < b) swap(a, b);     return b ? gcd(b, a % b) : a;   }   int main(int, char**) {     ios_base::sync_with_stdio(false);     int N;     cin >> N;     ;     int S;     cin >> S;     ;     vector<int> A(N);     for (auto& _cinv : A) cin >> _cinv;     ;     int err = 0;     if (A[S - 1] != 0) {       ++err;       A[S - 1] = 0;     }     vector<int> Q(N, 0);     for (int i = 0; i < N; i++) {       Q[A[i]]++;     }     int i = 1;     for (; i < N && (Q[0] > 1 || Q[i] > 0); ++i) {       if (Q[i] == 0) {         --Q[0];         ++Q[i];         ++err;       }     }     int j = N - 1;     while (i < j) {       if (Q[j] == 0)         --j;       else if (Q[i] > 0)         ++i;       else {         Q[i]++;         Q[j]--;         err++;       }     }     cout << err << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 5000 + 10;   bitset<MAXN> kna;   vector<int> G[MAXN];   int n, a, b, c, d, p[MAXN], sze[MAXN];   bool vis[MAXN];   bool check(int a, int b) {     memset(vis, 0, sizeof(vis));     kna.reset();     kna.flip(0);     for (int u = a; p[u]; u = p[u]) vis[u] = true;     for (int u = b; p[u]; u = p[u]) vis[u] = true;     for (int u = a; u; u = p[u])       for (auto i : G[u])         if (!vis[i]) {           kna |= kna << sze[i];         }     return kna.test(sze[1] / 2 - 1);   }   int main() {     scanf( %d%d%d%d%d , &n, &a, &b, &c, &d);     for (int i = 1; i <= n; i++) G[i].clear();     for (int i = 2; i <= n; i++) {       scanf( %d , &p[i]);       G[p[i]].push_back(i);     }     for (int u = n; u > 1; u--) {       sze[u] = max(sze[u], 1);       sze[p[u]] += sze[u];     }     if ((sze[1] % 2 == 0) && check(a, b) && check(c, d))       puts( YES n );     else       puts( NO n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int k, i, cn = 0, cnt = 0, j;     cin >> k;     string s;     cin >> s;     map<long long int, long long int> ans;     long long int a[s.length()], n = s.length();     for (i = 0; i < s.length(); i++) {       if (s[i] ==  1 ) cnt++;     }     if (k > cnt)       cout <<  0  << endl;     else {       a[0] = (s[0] -  0 );       for (i = 1; i < s.length(); i++) {         a[i] = a[i - 1] + (s[i] -  0 );       }       i = 0;       j = 0;       ans[0] = 1;       for (i = 0; i < n; i++) {         if (a[i] >= k) cn += ans[a[i] - k];         ans[a[i]]++;       }       cout << cn << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, k, p, a;     cin >> n >> k >> p;     if (n % 2 && k) {       n--;       k--;     }     if (2 * k > n) {       long long t = 2 * k - n;       n -= t;       k -= t;     }     while (p--) {       cin >> a;       if ((a > n) || ((a % 2 == 0) && ((n - a) / 2 < k)))         putchar( X );       else         putchar( . );     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, i, nu, ul, ka, c1ul, c1ka, c2ul, c2ka;     cin >> n;     c1ul = c1ka = c2ul = c2ka = 0;     for (i = 0; i < n; i++) {       cin >> nu >> ul >> ka;       if (nu == 1) {         c1ul += ul;         c1ka += ka;       } else {         c2ul += ul;         c2ka += ka;       }     }     if (c1ul >= (c1ul + c1ka) / 2) {       cout <<  LIVE  << endl;     } else {       cout <<  DEAD  << endl;     }     if (c2ul >= (c2ul + c2ka) / 2) {       cout <<  LIVE  << endl;     } else {       cout <<  DEAD  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int shr[10], mor[10], shrc[10], morc[10], n, i;     cin >> n;     for (i = 0; i < 10; i++) {       shr[i] = 0;       mor[i] = 0;       shrc[i] = 0;       morc[i] = 0;     }     char sher[n + 1], mr[n + 1];     cin >> sher >> mr;     for (i = 0; i < n; i++) {       shr[sher[i] -  0 ]++;       mor[mr[i] -  0 ]++;       shrc[sher[i] -  0 ]++;       morc[mr[i] -  0 ]++;     }     long sherlockmax = 0, sheri = 0, mori = 0, minmori = 0;     while (sheri < 10 && mori < 10) {       while (shr[sheri] == 0 && sheri < 10) sheri++;       while (mor[mori] == 0 && mori < 10) mori++;       while (sheri >= mori && mori < 10) {         mori++;       }       if (mori < 10 && sheri < 10 && mori > sheri) {         sherlockmax += min(shr[sheri], mor[mori]);         long k = min(shr[sheri], mor[mori]);         shr[sheri] -= k;         mor[mori] -= k;       }     }     sheri = 0;     mori = 0;     while (sheri < 10 && mori < 10) {       while (shrc[sheri] == 0 && sheri < 10) sheri++;       while (morc[mori] == 0 && mori < 10) mori++;       while (sheri > mori && mori < 10) {         minmori += morc[mori];         mori++;       }       if (mori < 10 && sheri < 10 && mori >= sheri) {         long k = min(shrc[sheri], morc[mori]);         shrc[sheri] -= k;         morc[mori] -= k;       }     }     cout << minmori << endl;     cout << sherlockmax << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char a;   int n, sum, flag = 1;   int main() {     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a;       if (a !=  0 )         sum++, flag = 1;       else if (flag == 1 && a ==  0 ) {         cout << sum;         sum = 0;         flag = 0;       } else if (a ==  0  && flag == 0)         cout <<  0 ;     }     cout << sum;   }