malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2000000;   int xx[1111111], yy[1111111];   int pos[1111111], n, m, op[1111111], np[1111111], ff;   int owner[3333333], first[3333333];   int ans[1111111];   bool used[1111111];   void imp() {     puts( -1 );     exit(0);   }   inline int sum(int x) {     int r = 0;     while (x >= 0) {       r += first[x];       x = (x & (x + 1)) - 1;     }     return r;   }   inline void add(int x, int d) {     while (x <= maxn) {       first[x] += d;       x = (x | (x + 1));     }   }   inline int getFirst(int x) {     int l = -1, r = maxn;     while (r - l > 1) {       int mid = ((l + r) >> 1);       if (sum(mid) >= x) {         r = mid;       } else {         l = mid;       }     }     return r;   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 0; i < m; ++i) {       scanf( %d%d , &xx[i], &yy[i]);       --xx[i];     }     memset(owner, -1, sizeof(owner));     memset(pos, -1, sizeof(pos));     int ff = m;     for (int i = 1; i <= n; ++i) {       add(ff + i, 1);     }     for (int i = 0; i < m; ++i) {       int &oldPlace = op[i];       int &newPlace = np[i];       int &x = xx[i];       int &y = yy[i];       oldPlace = getFirst(y);       if ((pos[x] != -1 && oldPlace != pos[x]) ||           (owner[oldPlace] != -1 && owner[oldPlace] != x)) {         imp();       }       newPlace = ff--;       owner[oldPlace] = -1;       add(oldPlace, -1);       add(newPlace, 1);       pos[x] = newPlace;       owner[newPlace] = x;     }     for (int i = m - 1; i >= 0; --i) {       int &oldPlace = op[i];       int &newPlace = np[i];       int &x = xx[i];       int &y = yy[i];       pos[x] = oldPlace;       owner[oldPlace] = x;       add(oldPlace, 1);       owner[newPlace] = -1;       add(newPlace, -1);     }     memset(ans, -1, sizeof(ans));     for (int i = 0; i < n; ++i)       if (pos[i] != -1) {         int p = sum(pos[i]);         ans[p - 1] = i;         used[i] = true;       }     int fx = 0;     for (int i = 0; i < n; ++i)       if (ans[i] == -1) {         while (used[fx]) {           ++fx;         }         ans[i] = fx;         used[fx] = true;       }     for (int i = 0; i < n; ++i) {       if (i > 0) {         putchar(   );       }       printf( %d , ans[i] + 1);     }     puts(  );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long spf[100001];   bool isPrime(long long n) {     if (n <= 1) return false;     if (n <= 3) return true;     if (n % 2 == 0 || n % 3 == 0) return false;     for (long long i = 5; i * i <= n; i = i + 6)       if (n % i == 0 || n % (i + 2) == 0) return false;     return true;   }   long long power(long long a, long long b) {     long long res = 1;     while (b > 0) {       if (b & 1) res = (res * a);       a = (a * a);       b >>= 1;     }     return res;   }   long long modpow(long long a, long long b, long long x) {     long long res = 1;     while (b > 0) {       if (b & 1) res = (res * a) % x;       a = (a * a) % x;       b >>= 1;     }     return res;   }   void sieve() {     spf[1] = 1;     for (long long i = 2; i < 100001; i++) spf[i] = i;     for (long long i = 4; i < 100001; i += 2) spf[i] = 2;     for (long long i = 3; i * i < 100001; i++)       if (spf[i] == i)         for (long long j = i * i; j < 100001; j += i)           if (spf[j] == j) spf[j] = i;   }   vector<long long> getFactorization(long long x) {     vector<long long> ret;     while (x != 1) {       ret.push_back(spf[x]);       x = x / spf[x];     }     return ret;   }   void solve() {     long long n, m;     cin >> n >> m;     vector<long long> adj[n + 1];     for (int i = 0; i < m; i++) {       long long a, b;       cin >> a >> b;       adj[a].push_back(b);       adj[b].push_back(a);     }     vector<pair<long long, long long>> topic(n);     for (int i = 0; i < n; i++) {       long long a;       cin >> a;       topic[i] = {a, i + 1};     }     sort(topic.begin(), topic.end());     vector<long long> res;     vector<set<long long>> around(n + 1);     for (int i = 0; i < topic.size(); i++) {       long long u = topic[i].second;       res.push_back(u);       if (around[u].find(topic[i].first) != around[u].end() ||           around[u].size() != topic[i].first - 1) {         cout << -1 <<   n ;         return;       }       for (auto j : adj[u]) {         around[j].insert(topic[i].first);       }     }     for (auto i : res) cout << i <<    ;     cout <<   n ;     ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long t = 1;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   vector<long long> v[N];   long long vis[N];   long long col[N];   set<long long> che;   void dfs(long long x) {     vis[x] = 1;     che.insert(x);     for (auto it : v[x]) {       if (!vis[it]) {         dfs(it);       }     }   }   void solve() {     long long n;     cin >> n;     long long i, x, y;     vector<pair<long long, long long> > e, spe;     for (i = 0; i < n - 1; i++) {       cin >> x >> y;       x--, y--;       e.push_back(make_pair(x, y));     }     for (i = 0; i < n; i++) {       cin >> col[i];     }     for (auto it : e) {       if (col[it.first] != col[it.second]) {         spe.push_back(make_pair(it.first, it.second));       }     }     long long m = spe.size();     long long f = 0, ind = 0;     long long cnt[n];     memset(cnt, 0, sizeof(cnt));     if (m == 0) {       cout <<  YES n1 ;       return;     }     for (auto it : spe) {       cnt[it.first]++;       cnt[it.second]++;     }     for (i = 0; i < n; i++) {       if (cnt[i] == m) {         cout <<  YES n  << i + 1;         return;       }     }     cout <<  NO n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     if (fopen( input.txt ,  r )) {       freopen( input.txt ,  r , stdin);       freopen( output.txt ,  w , stdout);     }     long long t = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n;     cin >> n;     int zD = 1;     int zABC = 0;     for (int i = 1; i <= n; i++) {       int nzD = zABC * 3LL % 1000000007;       int nzABC = (zABC * 2LL + zD) % 1000000007;       zD = nzD;       zABC = nzABC;     }     cout << zD;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int t;     cin >> t;     while (t--) {       int n, m;       cin >> n >> m;       auto chk = [&](int x, int y) { return 0 <= x && x < n && 0 <= y && y < m; };       vector<int> nxt(n * m, -1), deg(n * m), dp(n * m), dp2(n * m);       for (int i = 0; i < n; ++i) {         for (int j = 0; j < m; ++j) {           char c;           cin >> c;           int x = i, y = j;           if (c ==  L ) --y;           if (c ==  R ) ++y;           if (c ==  U ) --x;           if (c ==  D ) ++x;           if (chk(x, y)) {             nxt[i * m + j] = x * m + y;             deg[x * m + y] += 1;           }         }       }       for (int i = 0; i < n * m; ++i) dp2[i] = i;       queue<int> q;       for (int i = 0; i < n * m; ++i)         if (deg[i] == 0) q.push(i);       while (!q.empty()) {         int u = q.front();         q.pop();         if (nxt[u] != -1) {           int v = nxt[u];           if (dp[v] < dp[u] + 1) {             dp[v] = dp[u] + 1;             dp2[v] = dp2[u];           }           if (--deg[v] == 0) q.push(v);         }       }       int ans = 0;       for (int i = 0; i < n * m; ++i) {         if (deg[i] == 0) continue;         int p = nxt[i];         vector<int> loop;         while (p != i) {           loop.push_back(p);           p = nxt[p];         }         loop.push_back(i);         for (int j : loop) dp[j] += loop.size() - 1, deg[j] = 0;       }       int mx = -1, x = -1, y = -1;       for (int i = 0; i < n; ++i) {         for (int j = 0; j < m; ++j) {           if (dp[i * m + j] > mx) {             mx = dp[i * m + j];             x = dp2[i * m + j] / m;             y = dp2[i * m + j] % m;           }         }       }       cout << x + 1 <<     << y + 1 <<     << mx + 1 << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   void addmod(int &a, long long b) {     a = (a + b);     if (a >= 1000000007) a -= 1000000007;   }   void mulmod(int &a, long long b) { a = (a * b) % 1000000007; }   int gi() {     int a;     scanf( %d , &a);     return a;   }   long long gll() {     long long a;     scanf( %lld , &a);     return a;   }   class rangesum {     vector<long long> s;       public:     rangesum(const vector<int> &inp, const int &n) {       s.resize(n + 1);       for (int i = 0; i < n; i++) s[i + 1] = s[i] + inp[i];     }     long long get(int x, int y) { return s[y + 1] - s[x]; }   };   int main() {     int n = gi(), l, u;     vector<int> a(n);     for (auto i = 0; i < n; i++) {       a[i] = gi();     }     rangesum rs(a, n);     set<int> rm;     multiset<long long, greater<long long>> v;     rm.insert(-1);     rm.insert(n);     v.insert(rs.get(0, n - 1));     for (int i = 0; i < n; i++) {       int ix = gi() - 1;       auto it = rm.upper_bound(ix);       u = (*it) - 1;       it--;       l = (*it) + 1;       auto mit = v.find(rs.get(l, u));       assert(mit != v.end());       v.erase(mit);       if (ix > l) v.insert(rs.get(l, ix - 1));       if (ix < u) v.insert(rs.get(ix + 1, u));       rm.insert(ix);       printf( %lld n , (v.size() ? *v.begin() : 0));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long BIG = 1000000000000000000LL;   void solve();   signed main() {     ios::sync_with_stdio(false);     cin.tie(0);     solve();     return 0;   }   long long nbBoxes;   long long reqSom = 0;   bool cycor[1 << 15];   pair<long long, pair<long long, long long> > cymem[1 << 15];   long long dpGo[1 << 15];   long long origSom[15];   vector<long long> yolo[15];   map<long long, long long> loc;   map<long long, long long> ds;   vector<long long> maskOk;   pair<long long, long long> finRes[15];   long long osef[15];   long long getMap(long long x) {     auto it = loc.find(x);     if (it == loc.end())       return -1;     else       return it->second;   }   void tester(long long dep, long long valEnvoi, long long suiv,               bool act = false) {     if (dep == suiv) {       if (origSom[dep] == reqSom) {         cycor[1LL << dep] = true;         cymem[1LL << dep] = {dep, {valEnvoi, suiv}};         if (act) finRes[dep] = {dep, osef[dep]};       }       return;     }     long long gauche = dep;     long long cg = reqSom - (origSom[dep] - valEnvoi);     long long mask = (1LL << gauche);     if (act) finRes[dep] = {suiv, valEnvoi};     while (true) {       long long prev = gauche;       gauche = getMap(cg);       if (gauche != -1 && act) finRes[gauche] = {prev, cg};       if (gauche == -1 || gauche == dep) break;       if (mask & (1LL << gauche)) break;       cg = reqSom - (origSom[gauche] - cg);       mask |= (1LL << gauche);     }     if (gauche == dep && cg == valEnvoi) {       cycor[mask] = true;       cymem[mask] = {dep, {valEnvoi, suiv}};     }   }   void solve() {     cin >> nbBoxes;     for (long long i = (0); i < (nbBoxes); ++i) {       long long ni;       cin >> ni;       for (long long i00 = (0); i00 < (ni); ++i00) {         long long x;         cin >> x;         yolo[i].push_back(x);         reqSom += x;         origSom[i] += x;         loc[x] = i;         osef[i] = x;       }     }     if (reqSom % nbBoxes != 0) {       cout <<  No n ;       return;     }     reqSom /= nbBoxes;     for (long long i = (0); i < (nbBoxes); ++i) {       for (long long x : yolo[i]) {         tester(i, x, -1);         tester(i, x, i);       }     }     for (long long i = (0); i < ((1 << 15)); ++i) {       dpGo[i] = -1;     }     dpGo[0] = 0;     for (long long mask = 1; mask < (1 << 15); ++mask) {       for (long long s = mask; s > 0; s = ((s - 1) & mask)) {         if (cycor[s] && dpGo[mask ^ s] != -1) {           dpGo[mask] = s;           break;         }       }     }     long long cur = (1LL << nbBoxes) - 1;     while (dpGo[cur] != 0) {       if (dpGo[cur] == -1) {         cout <<  No n ;         return;       }       long long ret = dpGo[cur];       long long dep = cymem[ret].first, valEnv = cymem[ret].second.first,                 suiv = cymem[ret].second.second;       tester(dep, valEnv, suiv, true);       cur ^= ret;     }     cout <<  Yes n ;     for (long long i = (0); i < (nbBoxes); ++i)       cout << finRes[i].second <<     << finRes[i].first + 1 <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   long long n, k, a[300010], sum[300010], ans;   int main() {     scanf( %lld%lld , &n, &k);     for (int i = 1; i <= n; i++) scanf( %lld , &a[i]);     for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + a[i];     ans += k * sum[n];     sort(sum + 1, sum + n);     for (int i = 1; i < k; i++) ans -= sum[i];     printf( %lld , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using LL = long long;   using LD = long double;   using ULL = unsigned long long;   template <class T1, class T2>   using P = pair<T1, T2>;   using PII = P<int, int>;   using PLL = P<LL, LL>;   using PLD = P<LD, LD>;   template <class T>   using V = vector<T>;   using VI = V<int>;   using VLL = V<LL>;   using VLD = V<LD>;   using VB = V<bool>;   using VS = V<string>;   template <class T, class Comp = greater<T>>   using PQ = priority_queue<T, V<T>, Comp>;   template <class T>   int sz(const T& x) {     return (int)size(x);   }   template <class T>   bool amin(T& a, const T& b) {     if (b < a) {       a = b;       return true;     }     return false;   }   template <class T>   bool amax(T& a, const T& b) {     if (b > a) {       a = b;       return true;     }     return false;   }   const size_t rseed =       std::chrono::high_resolution_clock::now().time_since_epoch().count();   mt19937 rnd(rseed);   int randint(int lo, int hi) {     return uniform_int_distribution<int>{lo, hi}(rnd);   }   int main() {     int T;     scanf( %d , &T);     for (int t = (1); t <= (T); t++) {       int n;       scanf( %d , &n);       string s(n + 1,    );       scanf( %s , &s[0]);       string a(n,    ), b(n,    );       bool f = false;       for (int i = (0); i <= (n - 1); i++) {         if (f) {           a[i] =  0 ;           b[i] = s[i];         } else {           if (s[i] ==  1 ) {             f = true;             a[i] =  1 ;             b[i] =  0 ;           } else if (s[i] ==  2 )             a[i] = b[i] =  1 ;           else             a[i] = b[i] =  0 ;         }       }       printf( %s n%s n , a.c_str(), b.c_str());     }   }
#include <bits/stdc++.h>   using namespace std;   int seq[100];   int main() {     int n;     int acc, t, pen;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d , seq + i);     }     sort(seq, seq + n);     acc = 10;     t = 0;     pen = 0;     for (int i = 0; i < n; i++) {       acc += seq[i];       if (acc > 720) {         break;       }       t++;       if (acc > 360) {         pen += ((acc - 360) < 0 ? -(acc - 360) : (acc - 360));       }     }     printf( %d %d n , t, pen);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long maxx = 1e5 + 20, sqr = 150, mod = 1e9 + 7;   long long len, n, dp[maxx][sqr][2], q, pw25[maxx], pw26[maxx], pwmod[maxx],       fac[maxx], tmp[maxx];   string s;   long long pw(long long a, long long b) {     if (!b) return 1ll;     long long x = pw(a, b / 2);     x = (x * x) % mod;     if (b % 2) x = (x * a) % mod;     return x;   }   long long sel(long long a, long long b) {     long long x = 1ll;     x = (x * fac[a]) % mod;     x = (x * pwmod[b]) % mod;     x = (x * pwmod[a - b]) % mod;     return x;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     pw25[0] = pw26[0] = 1;     for (long long i = 1; i < maxx; i++)       pw25[i] = (pw25[i - 1] * 25) % mod, pw26[i] = (pw26[i - 1] * 26) % mod;     fac[0] = 1;     for (long long i = 1; i < maxx; i++) fac[i] = (fac[i - 1] * i) % mod;     for (long long i = 0; i < maxx; i++) pwmod[i] = pw(fac[i], mod - 2);     for (long long j = 0; j < sqr; j++) {       dp[j][j][1] = dp[j][j][0] = 1;       for (long long i = j + 1; i < maxx; i++) {         dp[i][j][0] = (((dp[i - 1][j][0] * 26) % mod) +                        (j >= 1 ? dp[i - 1][j - 1][1] : 0)) %                       mod;         dp[i][j][1] = (((dp[i - 1][j][1] * 25) % mod) +                        (j >= 1 ? dp[i - 1][j - 1][1] : 0)) %                       mod;       }     }     long long c = 0;     cin >> n >> s;     len = s.length();     if (len >= sqr) {       fill(tmp, tmp + maxx, 0);       tmp[len - 1] = 1;       for (long long j = len; j < maxx; j++)         tmp[j] = (((tmp[j - 1] * 26ll) % mod) +                   (((long long)sel(j, len - 1) * pw25[j + 1 - len]) % mod)) %                  mod;     }     for (long long i = 0; i < n; i++) {       long long type;       cin >> type;       if (type == 1) {         cin >> s, len = s.length();         if (len >= sqr) {           fill(tmp, tmp + maxx, 0);           tmp[len - 1] = 1;           for (long long j = len; j < maxx; j++)             tmp[j] = (((tmp[j - 1] * 26ll) % mod) +                       (((long long)sel(j, len - 1) * pw25[j + 1 - len]) % mod)) %                      mod;         }       } else {         c++;         cin >> q;         if (len < sqr) {           if (len > q)             cout << 0 <<   n ;           else             cout << dp[q][len][0] <<   n ;           continue;         }         long long ans = 0ll;         cout << tmp[q - 1] <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<array<int, 2>> tree(1);   int terminal[110];   unsigned long long inf = (1ull << 63) - 1;   int s;   struct Mat {     vector<unsigned long long> data;     Mat() { data.assign(s * s, inf); }   };   Mat operator*(const Mat& a, const Mat& b) {     Mat r;     for (int i = 0; i < s; i++) {       for (int k = 0; k < s; k++) {         for (int j = 0; j < s; j++) {           r.data[i * s + j] =               min(r.data[i * s + j], a.data[i * s + k] + b.data[k * s + j]);         }       }     }     return r;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int g, n, m;     cin >> g >> n >> m;     vector<pair<int, vector<int>>> mut;     vector<vector<vector<int>>> node(g);     for (int i = 0; i < n; i++) {       int a, k;       cin >> a >> k;       node[a].push_back(vector<int>(k));       mut.emplace_back(a, vector<int>());       for (int& v : node[a].back()) {         cin >> v;         mut.back().second.push_back(v);       }     }     for (int i = 0; i < m; i++) {       int k;       cin >> k;       int p = 0;       while (k--) {         int c;         cin >> c;         if (!tree[p][c]) {           tree[p][c] = tree.size();           tree.push_back({0, 0});         }         p = tree[p][c];       }       terminal[p] = 1;     }     {       vector<int> link(tree.size());       queue<int> q;       q.push(0);       while (q.size()) {         int p = q.front();         q.pop();         int par = link[p];         terminal[p] |= terminal[par];         for (int c : {0, 1}) {           if (!tree[p][c]) {             tree[p][c] = tree[par][c];           } else {             link[tree[p][c]] = p ? tree[par][c] : 0;             q.push(tree[p][c]);           }         }       }     }     s = tree.size();     for (int p = 0; p < s; p++)       if (terminal[p]) tree[p][0] = tree[p][1] = p;     vector<Mat> mat(g);     for (int c : {0, 1}) {       for (int i = 0; i < s; i++) {         mat[c].data[i * s + tree[i][c]] = 1;       }     }     vector<int> changed(g, 1);     while (1) {       int found = 0;       vector<int> nchanged(g);       for (auto& [a, v] : mut) {         int need = 0;         for (int b : v)           if (changed[b]) need = 1;         if (!need) continue;         Mat prod = mat[v[0]];         for (int i = 1; i < (int)v.size(); i++) {           prod = prod * mat[v[i]];         }         for (int i = 0; i < s * s; i++) {           if (prod.data[i] < mat[a].data[i]) {             mat[a].data[i] = prod.data[i];             nchanged[a] = 1;             found = 1;           }         }       }       changed = nchanged;       if (!found) break;     }     for (int a = 2; a < g; a++) {       unsigned long long mi = inf;       for (int i = 0; i < s; i++) {         if (!terminal[i]) mi = min(mi, mat[a].data[i]);       }       if (mi < inf)         cout <<  NO   << mi << endl;       else         cout <<  YES  << endl;     }   }
#include <bits/stdc++.h>   #pragma GCC optimize  -O3    using namespace std;   const int MAXN = 310000;   int n;   int a[MAXN];   vector<int> pr;   int bb[MAXN];   int go[MAXN];   int cc[MAXN];   int ans[MAXN];   vector<int> fc[MAXN];   int gcd(int a, int b) {     while (b) {       int q = a % b;       a = b;       b = q;     }     return a;   }   int dp[1 << 7];   int gg;   int gog[1 << 7];   void run(int x, int msk, int ml, int k) {     if (x == k) {       dp[msk] = cc[ml];       gog[msk] = ml;       return;     }     run(x + 1, msk, ml, k);     run(x + 1, msk + (1 << x), ml * fc[gg][x], k);   }   int main() {     ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);     for (int i = 0; i < MAXN; ++i) bb[i] = i;     for (int i = 2; i < MAXN; ++i) {       if (bb[i] == i) pr.push_back(i);       for (int j : pr) {         if (j * i >= MAXN || bb[i] < j) break;         bb[j * i] = j;       }     }     for (int i = 1; i < MAXN; ++i) {       int cur = 1;       int x = i;       while (x != 1) {         int d = bb[x];         while (x % d == 0) x /= d;         cur *= d;         fc[i].push_back(d);       }       go[i] = cur;     }     cin >> n;     int now = 0;     fill(ans, ans + MAXN, 1000);     for (int i = 0; i < n; ++i) {       cin >> a[i];       now = gcd(now, a[i]);       a[i] = go[a[i]];       ++cc[a[i]];       ans[a[i]] = 1;     }     if (now != 1) {       cout << -1 <<   n ;       return 0;     }     for (int i = 1; i < MAXN; ++i) {       for (int j = 2 * i; j < MAXN; j += i) cc[i] += cc[j];     }     for (int i = MAXN - 1; i > 1; --i) {       if (go[i] != i) continue;       int k = fc[i].size();       gg = i;       run(0, 0, 1, k);       for (int i = (1 << k) - 1; i > 0; --i) {         for (int j = (i - 1) & i; j > 0; j = (j - 1) & i) dp[j] -= dp[i];         dp[0] -= dp[i];       }       for (int j = 0; j < (1 << k); ++j)         if (dp[j]) ans[gog[j]] = min(ans[gog[j]], ans[i] + 1);     }     cout << ans[1] <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, x, m;   priority_queue<int> s;   int main() {     scanf( %d , &n);     m = n;     for (int i = 0; i < int(n); i++) {       scanf( %d , &x);       if (x < m) {         s.push(x);         cout <<    ;       } else if (x == m) {         cout << x <<    ;         m--;         while (!s.empty() && m == s.top()) {           cout << s.top() <<    ;           s.pop();           m--;         }       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char s[12000];   int n, i, j;   vector<int> ans;   int cek(int v, int t, string e) {     if (v >= strlen(s) - 1) return v;     int i = v;     do {       string tmp =   ;       for (i = i;; i++) {         tmp.push_back(s[i]);         if (s[i] ==  > ) break;       }       i++;       if (e ==  <table>  && tmp ==  </table> ) break;       if (e ==  <tr>  && tmp ==  </tr> ) break;       if (e ==  <td>  && tmp ==  </td> ) {         ans[t]++;         break;       }       if (tmp ==  <table> ) {         ans.push_back(0);         i = cek(i, ans.size() - 1, tmp);       } else if (tmp ==  <tr> ) {         i = cek(i, t, tmp);       } else if (tmp ==  <td> ) {         i = cek(i, t, tmp);       }     } while (i < strlen(s));     return i;   }   int main() {     n = 0;     bool f = 1;     while (scanf( %c , &s[n]) != EOF) {       if (s[n] !=   n ) n++;     }     int k = cek(0, -1,    );     sort(ans.begin(), ans.end());     for (i = 0; i < ans.size(); i++) {       if (f)         f = 0;       else         printf(   );       cout << ans[i];     }     cout << endl;     return 0;   }