malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N = 5e5 + 11;   int n, m;   int cha[N], fa[N];   int dfn[N], tot, sz[N];   int U, V;   int head[N], nex[N << 1], to[N << 1], size = 1;   bool vis[N << 1];   int fr[N];   int dl[N], zh[N], tp;   void add(int x, int y) {     to[++size] = y;     nex[size] = head[x];     head[x] = size;   }   void dfs(int u) {     dfn[u] = ++tot;     sz[u] = 1;     for (int i = head[u]; i; i = nex[i]) {       int v = to[i];       if (v == fa[u]) continue;       if (!dfn[v]) {         fa[v] = u;         dfs(v);         sz[u] += sz[v];         cha[u] += cha[v];       } else if (dfn[v] < dfn[u]) {         cha[u]++;         cha[v]--;       }     }     if (!U && cha[u] > 1) {       U = u;       return;     }   }   void bfs(int x, int id) {     int hd = 0, tl = 1;     dl[1] = x;     for (int i = 1; i <= n; i++) fr[i] = 0;     fr[x] = -1;     while (hd < tl) {       int u = dl[++hd];       for (int i = head[u]; i; i = nex[i]) {         int v = to[i];         if (fr[v] != 0 || vis[i]) continue;         fr[v] = i;         if (v == V) break;         dl[++tl] = v;       }     }     for (int v = V; v != U; v = to[fr[v] ^ 1]) {       zh[++tp] = v;       vis[fr[v]] = vis[fr[v] ^ 1] = 1;     }     zh[++tp] = U;   }   void get_V() {     for (int u = fa[U]; u; u = fa[u]) {       int cnt = 0;       for (int i = head[u]; i; i = nex[i]) {         int v = to[i];         if (dfn[v] >= dfn[U] + (u == fa[U]) && dfn[v] <= dfn[U] + sz[U] - 1) {           cnt++;         }       }       if (cnt >= 1) {         V = u;         return;       }     }   }   int main() {     cin >> n >> m;     int u, v;     for (int i = 1; i <= m; i++) {       scanf( %d%d , &u, &v);       add(u, v);       add(v, u);     }     for (int i = 1; i <= n; i++) {       if (!dfn[i]) dfs(i);     }     if (!U) {       puts( NO );     } else {       puts( YES );       get_V();       for (int i = 1; i <= 3; i++) {         bfs(U, i);         printf( %d  , tp);         while (tp) {           printf( %d  , zh[tp]);           tp--;         }         puts(  );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b, long long &x, long long &y) {     if (b == 0) {       x = 1;       y = 0;       return a;     }     long long x1, y1;     long long d = gcd(b, a % b, x1, y1);     x = y1;     y = x1 - y1 * (a / b);     return d;   }   bool find_any_solution(long long a, long long b, long long c, long long &x0,                          long long &y0, long long &g) {     g = gcd(abs(a), abs(b), x0, y0);     if (c % g) {       return false;     }     x0 *= c / g;     y0 *= c / g;     if (a < 0) x0 = -x0;     if (b < 0) y0 = -y0;     return true;   }   int32_t main() {     ios_base ::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long a, b, c, x, y, g;     cin >> a >> b >> c;     if (!find_any_solution(a, b, -c, x, y, g)) {       cout << -1 << endl;     } else {       cout << x <<     << y << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   long long int a, b, x1, y, x2, y2;   int main() {     cin >> a >> b >> x1 >> y >> x2 >> y2;     long long int da;     long long int k1 = x1 + y;     long long int k2 = x2 + y2;     long long int mi = min(k1, k2);     long long int ma = max(k1, k2);     long long int c = mi % (2 * a);     if (c < 0) c += 2 * a;     if (c != 0) mi += 2 * a - c;     c = ma % (2 * a);     if (c < 0) c += 2 * a;     ma -= c;     if (mi > ma)       da = 0;     else       da = (ma - mi) / (2 * a) + 1;     long long int db;     long long int t1 = x1 - y;     long long int t2 = x2 - y2;     mi = min(t1, t2);     ma = max(t1, t2);     c = mi % (2 * b);     if (c < 0) c += 2 * b;     if (c != 0) mi += 2 * b - c;     c = ma % (2 * b);     if (c < 0) c += 2 * b;     ma -= c;     if (mi > ma)       db = 0;     else       db = (ma - mi) / (2 * b) + 1;     cout << max(da, db);   }
#include <bits/stdc++.h>   using namespace std;   long long m;   int matrix[2][2] = {{3, 1}, {0, 1}};   class Matrix {    public:     long long c[2][2];     Matrix() {       for (int i = 0; i < 2; i++)         for (int j = 0; j < 2; j++) c[i][j] = 0;     }     void deal() {       for (int i = 0; i < 2; i++)         for (int j = 0; j < 2; j++) c[i][j] = matrix[i][j];     }   };   Matrix mul(const Matrix& t1, const Matrix& t2) {     int i, j, k;     Matrix t3;     for (i = 0; i < 2; i++) {       for (j = 0; j < 2; j++) {         for (k = 0; k < 2; k++) {           t3.c[i][j] = (t3.c[i][j] + t1.c[i][k] * t2.c[k][j]) % m;         }       }     }     return t3;   }   Matrix power(long long n) {     Matrix a, b;     b.deal();     if (n == 1)       return b;     else if (n % 2 == 1) {       a = (power(n / 2));       return mul(mul(a, a), b);     } else {       a = (power(n / 2));       return mul(a, a);     }   }   int main() {     long long n;     while (cin >> n >> m) {       if (n == 1) {         cout << 2 % m << endl;         continue;       } else {         Matrix s = power(n - 1);         cout << (s.c[0][0] * 2 + s.c[0][1] * 2) % m << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long double pi = acos(-1);   void boos() {     ios_base ::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);   }   void file() {     freopen( array.in ,  r , stdin);     freopen( array.out ,  w , stdout);   }   const long long INF = 1e9 + 7;   const int INF1 = 998244353;   const long long LLINF = (long long)1e18;   const int INTmx = (int)1e9;   const int N = 2e3 + 1;   int main() {     boos();     string second;     cin >> second;     int kol = 0;     for (int i = 0; i < second.size(); i++) {       if (second[i] ==  a ) kol++;     }     int n = second.size() - kol;     if (n % 2) {       cout <<  :( ;       return 0;     }     int m = n / 2;     int gg = m + kol;     string a, b;     for (int i = 0; i < gg; i++) {       a += second[i];       if (second[i] !=  a ) b += second[i];     }     if (a + b != second) {       cout <<  :( ;       return 0;     }     cout << a;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, q, e[65][65][65], d[65][65][65];   int main() {     scanf( %d %d %d , &n, &m, &q);     for (int i = (1); i <= (n); i++)       for (int j = (1); j <= (n); j++)         for (int k = (0); k <= (n); k++) d[i][j][k] = 1e9;     for (int i = (1); i <= (m); i++) {       for (int j = (1); j <= (n); j++)         for (int k = (1); k <= (n); k++) scanf( %d , &e[i][j][k]);       for (int w = (1); w <= (n); w++)         for (int j = (1); j <= (n); j++)           for (int k = (1); k <= (n); k++)             e[i][j][k] = min(e[i][j][k], e[i][j][w] + e[i][w][k]);       for (int j = (1); j <= (n); j++)         for (int k = (1); k <= (n); k++) d[j][k][0] = min(d[j][k][0], e[i][j][k]);     }     for (int z = (1); z <= (n); z++)       for (int k = (1); k <= (n); k++)         for (int i = (1); i <= (n); i++)           for (int j = (1); j <= (n); j++)             d[i][j][z] = min(d[i][j][z], min(d[i][k][z - 1] + d[k][j][0],                                              d[i][k][0] + d[k][j][z - 1]));     while (q--) {       int a, b, c;       scanf( %d %d %d , &a, &b, &c);       c = min(c, n);       printf( %d n , d[a][b][c]);     }     scanf(  n );   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   int main() {     scanf( %d%d , &n, &m);     if (m == 3) {       if (n == 4) {         printf( 0 0 n3 0 n0 3 n1 1 n );         return 0;       }       if (n >= 5) {         printf( -1 n );         return 0;       }     }     for (int i = 0; i < m; i++) printf( %d %d n , i, 100000 + i * i);     for (int i = 0; i < n - m; i++) printf( %d %d n , i, -100000 - i * i);     return 0;   }
#include <iostream>   #include <algorithm>   using namespace std;      int INF = 2e9;      int pre[200001];   struct node{       int l, r, max, min;   } segtree[800001];      void build(int ind, int l, int r){       if (l == r){           segtree[ind] = (node){l, r, pre[l], pre[l]};       } else {           build(2*ind, l, (l+r)/2);           build(2*ind+1, (l+r)/2+1, r);           segtree[ind] = (node){l, r, max(segtree[2*ind].max, segtree[2*ind+1].max),                min(segtree[2*ind].min, segtree[2*ind+1].min)};       }   }      int find_min(int ind, int l, int r){       if (segtree[ind].l >= l && segtree[ind].r <= r) return segtree[ind].min;       if (segtree[ind].r < l || segtree[ind].l > r) return INF;       return min(find_min(ind*2, l, r), find_min(ind*2+1,l,r));   }         int find_max(int ind, int l, int r){       if (segtree[ind].l >= l && segtree[ind].r <= r) return segtree[ind].max;       if (segtree[ind].r < l || segtree[ind].l > r) return -INF;       return max(find_max(ind*2, l, r), find_max(ind*2+1,l,r));   }   int main(){       int t; cin >> t;       for (int i=0;i<t;i++){           int n,m; string s; cin >> n >> m; cin >> s;           pre[0] = 0;           for (int j=0;j<n;j++){               if (s[j] ==  + ) pre[j+1] = pre[j] + 1; else pre[j+1] = pre[j] - 1;           }           build(1, 0, n);           for (int j=0;j<m;j++){               int l,r; cin >> l >> r;               int M = find_max(1, 0, l-1), m = find_min(1, 0, l-1);               //cout << M <<     << m << endl;               int subsum = pre[r] - pre[l-1];               M = max(M, find_max(1, r+1, n) - subsum);               m = min(m, find_min(1, r+1, n) - subsum);               cout << M-m+1 << endl;           }                  }                }
#include <bits/stdc++.h>   using namespace std;   char b[9], s[9];   struct tm t;   int k, i;   string m(int i) {     if (i == 8) return  September ;     t.tm_mon = i;     strftime(b, 9,  %B , &t);     return b;   }   int main() {     cin >> s >> k;     for (;; i++)       if (m(i) == s) return cout << m((i + k) % 12), 0;   }
#include <bits/stdc++.h>   int main() {     char ai[105];     while (~scanf( %s , ai)) {       int t = 1, max = 1;       for (int i = 0; ai[i] !=   0 ; i++) {         if (ai[i] !=  A  && ai[i] !=  E  && ai[i] !=  I  && ai[i] !=  O  &&             ai[i] !=  U  && ai[i] !=  Y ) {           t++;           max = max > t ? max : t;         } else           t = 1;       }       printf( %d n , max);     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 200010;   int mx[maxn << 2], ls[maxn << 2], rs[maxn << 2], lp[maxn << 2], rp[maxn << 2];   bool col[maxn << 2];   void make(int rt, int l, int r) {     lp[rt] = l;     rp[rt] = r;     ls[rt] = rs[rt] = r - l + 1;     mx[rt] = (ls[rt] - 1) / 2;     col[rt] = true;   }   void build(int l, int r, int rt) {     make(rt, l, r);     if (l == r) return;     int m = l + r >> 1;     build(l, m, rt << 1);     build(m + 1, r, rt << 1 | 1);   }   void pushup(int rt, int l, int r) {     int L = rt << 1, R = L + 1, m = l + r >> 1;     mx[rt] = mx[L], lp[rt] = lp[L], rp[rt] = rp[L], col[rt] = col[L];     if (!col[rt] || (rs[L] + ls[R] - 1) / 2 > mx[rt]) {       mx[rt] = rs[L] + ls[R] - 1 >> 1;       lp[rt] = m - rs[L] + 1;       rp[rt] = m + ls[R];       col[rt] = (lp[rt] <= rp[rt]);     }     if (!col[rt] || mx[R] > mx[rt]) {       mx[rt] = mx[R];       lp[rt] = lp[R];       rp[rt] = rp[R];       col[rt] = col[R];     }     ls[rt] = ls[L] + (ls[L] == m - l + 1) * ls[R];     rs[rt] = rs[R] + (rs[R] == r - m) * rs[L];   }   int n, m;   void update(int p, int l = 0, int r = n - 1, int rt = 1) {     if (l == r) {       col[rt] ^= 1;       if (col[rt])         make(rt, l, r);       else         ls[rt] = rs[rt] = 0;       mx[rt] = -1;       return;     }     int m = l + r >> 1;     if (p <= m)       update(p, l, m, rt << 1);     else       update(p, m + 1, r, rt << 1 | 1);     pushup(rt, l, r);   }   int pos[1000010];   int main() {     scanf( %d%d , &n, &m);     build(0, n - 1, 1);     int op, id;     while (m--) {       scanf( %d%d , &op, &id);       if (op == 2) {         update(pos[id]);       } else {         int a = ls[1] - 1, b = rs[1] - 1, c = mx[1];         if (a >= b && a >= c) {           printf( 1 n );           pos[id] = 0;           update(0);         } else if (c >= b) {           int t = (lp[1] + rp[1]) / 2;           pos[id] = t;           update(t);           printf( %d n , t + 1);         } else {           printf( %d n , n);           pos[id] = n - 1;           update(n - 1);         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   ifstream in;   ofstream out;   const long long kk = 1000;   const long long ml = kk * kk;   const long long mod = ml * kk + 7;   const long long inf = ml * ml * ml + 7;   long long n, i, j;   vector<long long> m;   vector<pair<long long, long long> > x;   bool viv = false;   map<pair<long long, long long>, bool> was;   pair<long long, string> ans;   string ll_to_str(long long v) {     string s =   ;     if (v == 0) return  0 ;     bool obr = false;     if (v < 0) obr = true;     v = abs(v);     while (v > 0) {       short e = v % 10;       s += char( 0  + e);       v /= 10;     }     reverse(s.begin(), s.end());     if (obr) s =  -  + s;     return s;   }   void write(pair<long long, long long> a) {     if (was[a]) return;     was[a] = true;     ans.first++;     ans.second += ll_to_str(a.first);     ans.second +=    ;     ans.second += ll_to_str(a.second);     ans.second +=   n ;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     x.assign(3, {0, 0});     for (long long i = 0; i < 3; i++) cin >> x[i].first >> x[i].second;     sort(x.begin(), x.end());     pair<long long, long long> cur = x[0];     while (cur.first < x[1].first) {       write(cur);       cur.first++;     }     while (cur.second < x[1].second) {       write(cur);       cur.second++;     }     while (cur.second > x[1].second) {       write(cur);       cur.second--;     }     while (cur.second < x[2].second) {       write(cur);       cur.second++;     }     while (cur.second > x[2].second) {       write(cur);       cur.second--;     }     while (cur.first < x[2].first) {       write(cur);       cur.first++;     }     write(cur);     cout << ans.first << endl;     cout << ans.second << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long x;     while (cin >> x) {       long long c = x / 2, t = 0;       if (x % 2 == 1) c--, t = 1;       cout << c + t << endl;       for (int i = 0; i < c; i++) cout <<  2  ;       for (int i = 0; i < t; i++) cout <<  3  ;       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MX = 6e4, C = 10, L = 20;   long long nxt[MX][C], sz;   bitset<170> b[MX];   unordered_map<bitset<170>, long long> id;   inline long long low_bit(bitset<170> s) {     for (long long i = 0; i < 10; i++)       if (s.test(i)) return i;     return -1;   }   inline long long extend(bitset<170> s) {     if (id.count(s)) return id[s];     id[s] = sz;     b[sz] = s;     return sz++;   }   void find_states() {     bitset<170> s;     s.reset();     s.set(0);     extend(s);     for (long long i = 0; i < sz; i++) {       for (long long j = 0; j < C; j++) {         bitset<170> s = (b[i] << j | b[i] >> j);         for (long long k = 0; k <= j; k++)           if (b[i].test(k)) s.set(j - k);         nxt[i][j] = extend(s);       }     }   }   long long dp[L][MX][C];   void calc_dps() {     for (long long state = 0; state < sz; state++)       for (long long k = 0; k < C; k++)         dp[0][state][k] = (low_bit(b[state]) <= k);     for (long long len = 1; len < L; len++) {       for (long long state = 0; state < sz; state++) {         for (long long k = 0; k < C; k++) {           for (long long c = 0; c < C; c++) {             dp[len][state][k] += dp[len - 1][nxt[state][c]][k];           }         }       }     }   }   long long q;   long long digit[L];   inline long long get(long long lim, long long k) {     long long cp = lim;     for (long long i = 0; i < L; i++, cp /= 10) {       digit[i] = cp % 10;     }     long long res = 0;     long long state = 0;     for (long long i = L - 1; i >= 0; i--) {       for (long long j = 0; j < digit[i]; j++) {         res += dp[i][nxt[state][j]][k];       }       state = nxt[state][digit[i]];     }     return res;   }   int32_t main() {     ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);     find_states();     calc_dps();     cin >> q;     while (q--) {       long long l, r, k;       cin >> l >> r >> k;       r++;       cout << get(r, k) - get(l, k) <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 202020, INF = 0x3f3f3f3f;   vector<int> G[MAXN], iG[MAXN];   int n, m, k, p[MAXN];   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; ++i) {       static int u, v;       scanf( %d%d , &u, &v);       G[u].push_back(v);       iG[v].push_back(u);     }     scanf( %d , &k);     for (int i = 1; i <= k; ++i) scanf( %d , &p[i]);     vector<int> d(MAXN, INF);     queue<int> q;     q.push(p[k]), d[p[k]] = 0;     while (!q.empty()) {       int f = q.front();       q.pop();       for (auto g : iG[f])         if (d[g] == INF) {           d[g] = d[f] + 1;           q.push(g);         }     }     int mn = 0, mx = 0;     for (int i = 1; i < k; ++i) {       if (d[p[i]] <= d[p[i + 1]])         mn++, mx++;       else {         int deg = 0;         for (auto g : G[p[i]])           if (d[g] == d[p[i]] - 1) deg++;         mx += deg > 1;       }     }     printf( %d %d n , mn, mx);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int dx[9] = {-1, 0, 1, 0, -1, -1, 1, 1, 0};   const int dy[9] = {0, 1, 0, -1, -1, 1, -1, 1, 0};   long long n;   void solve() {     int a = sqrt(n);     int b = cbrt(n);     int c = sqrt(cbrt(n));     cout << a + b - c <<   n ;   }   int main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     int T;     cin >> T;     while (T--) {       cin >> n;       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = (int)2e5 + 5;   const int MOD = 998244353;   int bit[MAXN];   bool got[MAXN];   int p[MAXN];   void gcd(long long a, long long b, long long& x, long long& y) {     if (b == 0) {       x = 1;       y = 0;       return;     }     gcd(b, a % b, y, x);     y -= (a / b) * x;     return;   }   long long inv(long long a) {     long long x, y;     gcd(a, MOD, x, y);     return (x % MOD + MOD) % MOD;   }   void add(int idx, int n) {     while (idx <= n) {       bit[idx]++;       idx += idx & -idx;     }     return;   }   int query(int idx) {     int sum = 0;     while (idx > 0) {       sum += bit[idx];       idx -= idx & -idx;     }     return sum;   }   void init(int n) {     for (int i = 1; i <= n; i++) {       bit[i] = 0;     }     return;   }   long long calc(int n) {     long long ans = 0;     init(n);     for (int i = n; i >= 1; i--) {       if (p[i] != -1) {         ans += query(p[i]);         add(p[i], n);       }     }     return ans % MOD;   }   long long expected(int n) {     long long ans = (1LL * n * (n - 1)) % MOD;     ans *= inv(4);     return ans % MOD;   }   bool compatible(vector<int> v, int n) {     for (int i = 1; i <= n; i++) {       if (p[i] != -1 && v[i - 1] != p[i]) {         return false;       }     }     return true;   }   long long get_inversions(vector<int> v, int n) {     init(n);     long long ans = 0;     for (int i = n - 1; i >= 0; i--) {       ans += query(v[i]);       add(v[i], n);     }     return ans % MOD;   }   long long brute(int n) {     vector<int> v(n);     for (int i = 0; i < n; i++) {       v[i] = i + 1;     }     long long ans = 0;     long long perm = 0;     do {       if (compatible(v, n)) {         ans += get_inversions(v, n);         perm++;       }     } while (next_permutation(v.begin(), v.end()));     printf( here ans = %lld, perm = %lld, inv = %lld n , ans, perm, inv(perm));     return (1LL * ans * inv(perm)) % MOD;   }   int main(void) {     int n;     int vacant = 0;     int start_vacant = 0;     scanf(  %d , &n);     for (int i = 1; i <= n; i++) {       scanf(  %d , &p[i]);       got[p[i]] = true;       if (p[i] == -1) {         vacant++;       }     }     init(n);     start_vacant = vacant;     for (int i = 1; i <= n; i++) {       if (!got[i]) {         add(i, n);       }     }     long long ans = 0;     int left = 0;     for (int i = 1; i <= n; i++) {       if (p[i] != -1) {         long long aux = 1LL * query(p[i]) * vacant;         aux %= MOD;         ans += aux * inv(start_vacant);         ans %= MOD;         aux = 1LL * (query(n) - query(p[i])) * left;         aux %= MOD;         ans += aux * inv(start_vacant);         ans %= MOD;       } else {         left++;         vacant--;       }     }     ans += expected(start_vacant);     ans += calc(n);     ans %= MOD;     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char a[15][15], b[15][15], t[15][15];   int n;   void copy() {     for (int i = 0; i < n; ++i)       for (int j = 0; j < n; ++j) t[i][j] = a[i][j];   }   int check() {     for (int i = 0; i < n; ++i)       for (int j = 0; j < n; ++j)         if (a[i][j] != b[i][j]) return 0;     return 1;   }   void Upd() {     copy();     for (int i = 0; i < n; ++i)       for (int j = 0; j < n; ++j) a[i][j] = t[n - j - 1][i];   }   void put() {     for (int i = 0; i < n; ++i, puts(  )) printf( %s , a[i]);   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; ++i) scanf( %s , a[i]);     for (int i = 0; i < n; ++i) scanf( %s , b[i]);     for (int i = 0; i < 4; ++i) {       if (check()) return puts( Yes ), 0;       Upd();     }     copy();     for (int i = 0; i < n; ++i)       for (int j = 0; j < n; ++j) a[i][j] = t[n - i - 1][j];     for (int i = 0; i < 4; ++i) {       if (check()) return puts( Yes ), 0;       Upd();     }     copy();     for (int i = 0; i < n; ++i)       for (int j = 0; j < n; ++j) a[i][j] = t[i][n - j - 1];     for (int i = 0; i < 4; ++i) {       if (check()) return puts( Yes ), 0;       Upd();     }     return puts( No ), 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, cnt;   bool f;   vector<int> p, m, z;   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) {       int x;       scanf( %d , &x);       if (x < 0) m.push_back(x);       if (x > 0) p.push_back(x);       if (x == 0) z.push_back(x);     }     printf( 1 %d n , m[0]);     if (p.size() > 0)       printf( 1 %d  n , p[0]);     else {       printf( 2 %d %d n , m[1], m[2]);       f = true;     }     cnt = z.size();     for (int i = (f ? 0 : 1); i < p.size(); i++) cnt++;     for (int i = (f ? 3 : 1); i < m.size(); i++) cnt++;     printf( %d  , cnt);     for (int i = 0; i < z.size(); i++) printf( %d  , z[0]);     for (int i = (f ? 0 : 1); i < p.size(); i++) printf( %d  , p[i]);     for (int i = (f ? 3 : 1); i < m.size(); i++) printf( %d  , m[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf_int = 2e9;   const long long inf_ll = 2e18;   int Gcd(int p, int q) { return q == 0 ? p : Gcd(q, p % q); }   int Pow(int p, int q) {     int ans = 1;     while (q) {       if (q & 1) ans = ans * p;       p = p * p;       q >>= 1;     }     return ans;   }   inline int read() {     int ra, fh;     char rx;     rx = getchar(), ra = 0, fh = 1;     while ((rx <  0  || rx >  9 ) && rx !=  - ) rx = getchar();     if (rx ==  - ) fh = -1, rx = getchar();     while (rx >=  0  && rx <=  9 ) ra *= 10, ra += rx - 48, rx = getchar();     return ra * fh;   }   int n, q;   vector<int> v[300010];   vector<bool> vis;   int op, x;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     scanf( %d%d , &n, &q);     int ans = 0, k = 0;     for (int i = 1; i <= q; i++) {       scanf( %d%d , &op, &x);       if (op == 1) {         x--;         v[x].push_back(vis.size());         vis.push_back(true);         ans++;       } else if (op == 2) {         x--;         for (int j : v[x]) {           if (vis[j]) {             ans--;             vis[j] = false;           }         }         v[x].clear();       } else {         for (int j = k; j < x; j++) {           if (vis[j]) {             vis[j] = false;             ans--;           }         }         k = max(k, x);       }       printf( %d n , ans);     }     return 0;   }