malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   inline int read() {     int n = 0, f = 1;     char c;     for (c = getchar(); c !=  -  && (c <  0  || c >  9 ); c = getchar())       ;     if (c ==  - ) c = getchar(), f = -1;     for (; c >=  0  && c <=  9 ; c = getchar()) n = n * 10 + c - 48;     return n * f;   }   struct ar {     int x, y, id, d;   } now;   bool operator<(ar a, ar b) { return a.x == b.x ? a.y < b.y : a.x < b.x; }   int i, a, b, d[3005];   vector<ar> p, an;   bool cmp(ar a, ar b) { return a.x * b.y > a.y * b.x; }   void solve(vector<ar> p) {     int i, j, k, D, n = p.size() - 1;     if (!n) return;     for (i = 1; i <= n; i++)       if (p[i] < p[0]) swap(p[i], p[0]);     for (i = 1; i <= n; i++) p[i].x -= p[0].x, p[i].y -= p[0].y;     sort(p.begin() + 1, p.end(), cmp);     for (i = 1; i <= n; i++) p[i].x += p[0].x, p[i].y += p[0].y;     if (p[0].d < 0) {       for (i = 1; i <= n; i++) {         j = i, D = 0;         for (;; i++) {           D += p[i].d;           if (D >= 0) break;         }         p[i].d--, an.push_back((ar){p[i].id, p[0].id});         p[i].d -= D;         solve(vector<ar>(p.begin() + j, p.begin() + i + 1));         p[j = i].d = D - 1;         for (; D;) D += p[++i].d;         solve(vector<ar>(p.begin() + j, p.begin() + i + 1));       }       return;     }     for (i = 1; p[0].d >= 0;) {       for (j = i, D = 1; D; i++) D += p[i].d;       p[0].d--, an.push_back((ar){p[0].id, p[i - 1].id});       solve(vector<ar>(p.begin() + j, p.begin() + i));     }     solve(vector<ar>(p.begin() + i - 1, p.end()));   }   void work() {     a = read(), b = read();     for (i = 1; i <= b; i++) d[i] = read();     p.clear(), an.clear();     for (i = 1; i <= a + b; i++) {       now.x = read(), now.y = read();       if (i <= a)         now.id = i, now.d = -1;       else         now.d = d[now.id = i - a] - 1;       p.push_back(now);     }     solve(p);     puts( YES );     for (i = 0; i <= a + b - 2; i++) printf( %d %d n , an[i].x, an[i].y);   }   int main() {     for (int t = read(); t--;) work();   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 1e9;   void query() {     int n, m;     cin >> n >> m;     vector<string> t(n);     for (auto& i : t) cin >> i;     vector<vector<int>> col(n, vector<int>(m, 0));     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++)         col[i][j] = (i > 0 ? col[i - 1][j] : 0) + t[i][j] -  0 ;     int res = inf;     queue<pair<int, int>> q;     for (int a = 5; a <= n; a++) {       for (int i = 0; i <= n - a; i++) {         while (!q.empty()) q.pop();         pair<int, int> X(inf, 0);         int add = 0;         for (int j = 0; j < m; j++) {           while (q.size() >= 3) {             if (q.front().first - q.front().second < X.first - X.second)               X = q.front();             q.pop();           }           int A = col[i + a - 2][j] - col[i][j];           if (j - 3 >= 0) res = min(res, X.first - X.second + add + a - 2 - A);           if (j > 0)             add += A + 2 - (int)(t[i][j] -  0 ) - (int)(t[i + a - 1][j] -  0 );           q.push({a - 2 - A, add});         }       }     }     cout << res <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     int q = 1;     cin >> q;     while (q--) query();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void add(long long &a, long long b) {     a += b;     if (a >= (233333333 * 4 + 23333333 * 2 + 2333333 * 8 + 233333 * 5 +               23333 * 7 + 2333 + 233 * 4 + 23 * 3 + 2 + 2 + 2 + 3 + 3 + 3)) {       a -= (233333333 * 4 + 23333333 * 2 + 2333333 * 8 + 233333 * 5 + 23333 * 7 +             2333 + 233 * 4 + 23 * 3 + 2 + 2 + 2 + 3 + 3 + 3);     }   }   struct BitchIsThere {     int N;     pair<long long, long long> dt[500005];     void upd(pair<long long, long long> &a, pair<long long, long long> b) {       if (a.first > b.first) {         a = b;       } else if (a.first == b.first) {         add(a.second, b.second);       }     }     void init(int nn) {       N = nn;       for (int i = 1; i <= nn; i++) {         dt[i] = make_pair(             (233333333 * 4 + 23333333 * 2 + 2333333 * 8 + 233333 * 5 + 23333 * 7 +              2333 + 233 * 4 + 23 * 3 + 2 + 2 + 2 + 3 + 3 + 3),             0);       }     }     void insert(int x, pair<long long, long long> num) {       while (x <= N) {         upd(dt[x], num);         x += x & -x;       }     }     pair<long long, long long> qsum(int x) {       pair<long long, long long> ans =           make_pair((233333333 * 4 + 23333333 * 2 + 2333333 * 8 + 233333 * 5 +                      23333 * 7 + 2333 + 233 * 4 + 23 * 3 + 2 + 2 + 2 + 3 + 3 + 3),                     0);       while (x) {         upd(ans, dt[x]);         x -= x & -x;       }       return ans;     }   } bit;   int n;   vector<pair<long long, long long> > pills;   int main() {     scanf( %d , &n);     vector<int> ds;     ds.push_back(-1);     ds.push_back(0);     for (int i = 0; i < n; i++) {       int x, y;       scanf( %d%d , &x, &y);       pills.push_back(make_pair(y, x));       ds.push_back(x);       ds.push_back(y);     }     sort(ds.begin(), ds.end());     ds.resize(unique(ds.begin(), ds.end()) - ds.begin());     sort(pills.begin(), pills.end());     bit.init(ds.size());     bit.insert(1, make_pair(0, 1));     pair<long long, long long> ans =         make_pair((233333333 * 4 + 23333333 * 2 + 2333333 * 8 + 233333 * 5 +                    23333 * 7 + 2333 + 233 * 4 + 23 * 3 + 2 + 2 + 2 + 3 + 3 + 3),                   0);     for (pair<long long, long long> p : pills) {       int x = lower_bound(ds.begin(), ds.end(), p.first) - ds.begin();       int y = lower_bound(ds.begin(), ds.end(), p.second) - ds.begin();       pair<long long, long long> res = bit.qsum(x);       if (p.second > pills.back().first) {         bit.upd(ans, make_pair(res.first + p.first, res.second));       } else {         bit.insert(y, make_pair(p.first + res.first - p.second, res.second));       }     }     printf( %lld n , ans.second);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MAX = 101;   long long mat[MAX][MAX], ans[MAX][MAX], arr1[MAX], arr2[MAX];   int main() {     long long n, m, h;     cin >> n >> m >> h;     for (long long i = 0; i < m; i++) cin >> arr2[i];     for (long long i = 0; i < n; i++) cin >> arr1[i];     for (long long i = 0; i < n; i++)       for (long long j = 0; j < m; j++) cin >> mat[i][j];     for (long long i = 0; i < m; i++) {       for (long long j = 0; j < n; j++)         if (arr2[i] <= arr1[j] && mat[j][i]) {           ans[j][i] = arr2[i];           break;         }     }     for (long long j = 0; j < n; j++) {       for (long long i = 0; i < m; i++)         if (arr1[j] <= arr2[i] && mat[j][i] && !ans[j][i]) {           ans[j][i] = arr1[j];           break;         }     }     for (long long i = 0; i < n; i++) {       for (long long j = 0; j < m; j++) {         if (mat[i][j] && !ans[i][j])           cout << 1 <<    ;         else           cout << ans[i][j] <<    ;       }       cout <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int s, v1, v2, t1, t2, q1, q2;     cin >> s >> v1 >> v2 >> t1 >> t2;     q1 = 2 * t1 + s * v1;     q2 = 2 * t2 + s * v2;     if (q1 < q2) {       cout <<  First n ;     } else if (q1 > q2) {       cout <<  Second n ;     } else {       cout <<  Friendship n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int n, k, ans;   long long int check(long long int v) {     long long int sum = 0;     while (v > 0) {       sum += v;       v /= k;     }     return sum;   }   void BS(long long int l, long long int r) {     while (l <= r) {       long long int mid = (l + (r - l) / 2);       long long int sum = check(mid);       if (sum >= n) {         r = mid - 1;         ans = min(ans, mid);       } else         l = mid + 1;     }   }   void solve() {     cin >> n >> k;     ans = n;     long long int l, r;     l = 1;     r = n;     BS(l, r);     cout << ans <<   n ;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void qmax(long long &x, long long y) {     if (x < y) x = y;   }   void qmin(long long &x, long long y) {     if (x > y) x = y;   }   inline long long read() {     char s;     long long k = 0, base = 1;     while ((s = getchar()) !=  -  && s != EOF && !(isdigit(s)))       ;     if (s == EOF) exit(0);     if (s ==  - ) base = -1, s = getchar();     while (isdigit(s)) {       k = k * 10 + (s ^  0 );       s = getchar();     }     return k * base;   }   inline void write(long long x) {     static char cnt, num[15];     cnt = 0;     if (!x) {       printf( 0 );       return;     }     for (; x; x /= 10) num[++cnt] = x % 10;     for (; cnt; putchar(num[cnt--] + 48))       ;   }   long long n, l[70], x, f[70], ans[2001010];   vector<long long> a[70];   long long flag;   signed main() {     n = read();     for (long long i = 1; i <= n; i++) {       x = read();       for (long long i = 59; i >= 0; i--) {         if (x & (1ll << i)) {           a[i].push_back(x);           l[i]++;           break;         }       }     }     long long lst = 0;     for (long long i = 0; i < 60; i++)       if (l[i] != 0) sort(a[i].begin(), a[i].end());     for (long long j = 1; j <= n; j++) {       flag = 0;       for (long long i = 0; i < 60; i++) {         if (f[i] == l[i]) continue;         if (((lst >> (long long)i) & 1ll) != 0) continue;         f[i]++;         ans[j] = a[i][f[i] - 1];         flag = 1;         lst ^= ans[j];         break;       }       if (!flag) break;     }     if (!flag) {       printf( No );       return 0;     }     printf( Yes n );     for (long long i = 1; i <= n; i++) {       printf( %lld  , ans[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct wut {     int op;     int val;     int nval;     wut() {}     wut(int a, int b) : op(a), val(b) {}   };   struct node {     long long sum[5];     int ile;     node() {       for (int i = 0; i < (5); ++i) sum[i] = 0;       ile = 0;     }   };   const int N = 100010;   wut tab[N];   int n;   char tax[10];   int c;   set<int> h;   map<int, int> et;   node tree[3 * N];   int roz;   void insert(int value, int pos, bool add) {     pos = roz + pos - 1;     if (add) {       tree[pos].sum[0] += value;       tree[pos].ile++;     } else {       tree[pos].sum[0] -= value;       tree[pos].ile--;     }     while (pos >> 1) {       for (int i = 0; i < (5); ++i)         tree[pos >> 1].sum[i] = tree[(pos >> 1) << 1].sum[i];       for (int i = 0; i < (5); ++i) {         tree[pos >> 1].sum[i] +=             tree[((pos >> 1) << 1) + 1]                 .sum[(((i - tree[(pos >> 1) << 1].ile) % 5) + 5) % 5];       }       tree[pos >> 1].ile =           tree[(pos >> 1) << 1].ile + tree[((pos >> 1) << 1) + 1].ile;       pos >>= 1;     }   }   long long query() { return tree[1].sum[2]; }   int main() {     scanf( %d , &n);     for (int i = 0; i < (n); ++i) {       scanf( %s %d , tax, &c);       if (tax[0] ==  a )         tab[i] = wut(0, c);       else if (tax[0] ==  d )         tab[i] = wut(1, c);       else         tab[i] = wut(2, 0);       if (tab[i].op <= 1) h.insert(tab[i].val);     }     int ind = 0;     for (typeof((h).begin()) p = ((h).begin()); p != (h).end(); ++p) {       et[*p] = ++ind;     }     for (int i = 0; i < (n); ++i)       if (tab[i].op <= 1) {         tab[i].nval = et[tab[i].val];       }     roz = 1;     while (roz < ind) roz <<= 1;     for (int i = 0; i < (n); ++i) {       if (tab[i].op == 2) {         cout << query() << endl;       } else {         insert(tab[i].val, tab[i].nval, !tab[i].op);       }     }   }
#include <bits/stdc++.h>   const int maxn = 1e5 + 10;   using namespace std;   int head[maxn], deep[maxn], k;   int f[maxn][23];   int n, q, root;   struct edge {     int v, next;   } e[maxn << 1];   void adde(int u, int v) {     e[k].v = v;     e[k].next = head[u];     head[u] = k++;   }   void init() {     k = 0;     memset(head, -1, sizeof(head));     memset(f, 0, sizeof(f));     memset(deep, -1, sizeof(deep));   }   void dfs(int u, int fa) {     f[u][0] = fa;     deep[u] = deep[fa] + 1;     for (int j = 1; j <= 20; j++) f[u][j] = f[f[u][j - 1]][j - 1];     for (int i = head[u]; i != -1; i = e[i].next) {       int v = e[i].v;       if (v == fa) continue;       dfs(v, u);     }   }   int lca(int u, int v) {     if (deep[u] > deep[v]) swap(u, v);     for (int j = 20; j >= 0; j--) {       if (deep[v] - (1 << j) >= deep[u]) v = f[v][j];     }     if (u == v) return u;     for (int j = 20; j >= 0; j--) {       if (f[u][j] == f[v][j]) continue;       u = f[u][j];       v = f[v][j];     }     return f[u][0];   }   int dis(int u, int v) {     int ans = deep[u] + deep[v] - 2 * deep[lca(u, v)];     return ans;   }   int main() {     init();     scanf( %d%d , &n, &q);     int x;     for (int i = 2; i <= n; i++) {       scanf( %d , &x);       adde(x, i);       adde(i, x);     }     dfs(1, 0);     int u1, u2, u3;     while (q--) {       scanf( %d%d%d , &u1, &u2, &u3);       int lca1 = lca(u1, u2);       int lca2 = lca(u1, u3);       int lca3 = lca(u2, u3);       if (deep[lca3] > deep[lca1]) lca1 = lca3;       if (deep[lca2] > deep[lca1]) lca1 = lca2;       int ans = max(dis(lca1, u3), max(dis(lca1, u2), dis(lca1, u1))) + 1;       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   using namespace std;   constexpr int LG = 60;   int N;   long long int ai, bi, bs;   long long int x[LG + 1];   inline bool ins(long long int v) {     for (int i = LG; i >= 0; --i) {       if (!((v >> i) & 1)) continue;       if (x[i]) {         v ^= x[i];       } else {         for (int j = i - 1; j >= 0; --j)           if ((v >> j) & 1) v ^= x[j];         for (int j = i + 1; j <= LG; ++j)           if ((x[j] >> i) & 1) x[j] ^= v;         x[i] = v;         return true;       }     }     return false;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cin >> N;     int s = 0;     for (int i = 0; i < N; ++i) {       cin >> ai >> bi;       bs ^= bi, ai ^= bi;       if (ins(ai)) ++s;     }     for (int i = LG; i >= 0; --i)       if ((bs >> i) & 1) bs ^= x[i];     if (bs)       cout <<  1/1 n ;     else       cout << (1ll << s) - 1 <<  /  << (1ll << s) <<   n ;     return 0;   }
#include <bits/stdc++.h>   const int INF = 0x3f3f3f3f;   const int mod = 1e9 + 7;   const int maxn = 1e5 + 10;   using namespace std;   int a[105];   int b[105];   int main() {     int n, m;     scanf( %d %d , &n, &m);     for (int i = 0; i < n; i++) {       scanf( %d , &a[i]);     }     int x = 0;     int y = 0;     int cnt = 0;     for (int i = 2; i != n; i += 2) {       a[i - 2] % 2 == 1 ? x++ : y++;       a[i - 1] % 2 == 1 ? x++ : y++;       if (x == y) b[cnt++] = max(a[i], a[i - 1]) - min(a[i], a[i - 1]);     }     sort(b, b + cnt);     int num = 0;     for (int i = 0; i < cnt; i++) {       if (m >= b[i]) {         num++;         m -= b[i];       } else         break;     }     printf( %d n , num);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1000000007;   long long powmod(long long a, long long b) {     long long res = 1;     a %= mod;     for (; b; b >>= 1) {       if (b & 1) res = res * a % mod;       a = a * a % mod;     }     return res;   }   const int N = 2010;   bitset<N> base[N], d, sel, Sel[N];   bool bs[N];   string p;   int n, a[N];   void trans(string p) {     d = 0;     int l = ((int)(p).size()) / 8 + 1;     reverse((p).begin(), (p).end());     while (((int)(p).size()) <= 8 * l) p.push_back( 0 );     for (int i = 0; i < l; i++) {       a[i] = 0;       for (int j = 8 - 1; j >= 0; j--) a[i] = a[i] * 10 + p[8 * i + j] -  0 ;     }     long long s = 0;     int tot = 0;     while (l) {       s = 0;       for (int i = l - 1; i >= 0; i--) {         s = s * 100000000 + a[i];         a[i] = s >> 32;         s = s % (1ll << 32);       }       for (int i = 0; i < 32; i++) d[tot++] = (s >> i) & 1;       while (l && a[l - 1] == 0) --l;     }   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) {       cin >> p;       trans(p);       sel = 0;       bool sol = 0;       for (int k = 2000; k >= 0; k--)         if (d[k]) {           if (bs[k]) {             d = d ^ base[k];             sel ^= Sel[k];           } else {             sol = 1;             sel[i].flip();             bs[k] = 1;             base[k] = d;             Sel[k] = sel;             break;           }         }       if (sol)         puts( 0 );       else {         int cnt = 0;         for (int j = 0; j < i; j++)           if (sel[j]) cnt++;         printf( %d , cnt);         for (int j = 0; j < i; j++)           if (sel[j]) printf(  %d , j);         puts(  );       }     }   }
#include <bits/stdc++.h>   using namespace std;   long long f[200];   int main() {     int n;     cin >> n;     f[1] = 0;     for (int i = 0; i < 101; i++) {       f[i] = f[i - 1] + (i / 2);     }     cout << f[n] << endl;     for (int i = 1; i <= n; i++) {       int x = i - 1;       while (x > 0) {         cout << i <<     << x;         x -= 2;         cout << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n, k = 0;     cin >> n;     int arr[n], brr[n], crr[n];     for (int i = 0; i < n; i++) {       cin >> arr[i] >> brr[i];       crr[i] = arr[i];     }     sort(crr, crr + n);     for (int i = 0; i < n; i++) {       int upper = upper_bound(crr, crr + n, brr[i]) - crr;       int lower = lower_bound(crr, crr + n, brr[i]) - crr;       cout << n - 1 + upper - lower <<     << n - 1 + lower - upper << endl;     }   }
#include <bits/stdc++.h>   inline char gc() {     static char buf[10000], *p1 = buf, *p2 = buf;     return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 10000, stdin), p1 == p2)                ? EOF                : *p1++;   }   inline long long read() {     long long x = 0;     int f = 1;     char c = gc();     for (; !isdigit(c); c = gc())       if (c ==  - ) f = -1;     for (; isdigit(c); c = gc()) x = (x << 1) + (x << 3) + (c ^ 48);     return x * f;   }   inline void write(long long x) {     if (x < 0) putchar( - ), x = -x;     if (x > 9) write(x / 10);     putchar(x % 10 | 48);   }   const int N = 1e3 + 10;   long long V, ans, A, B, C;   int n;   struct node {     long long s;     int num;     inline bool operator<(const node& res) const { return s < res.s; }   } s[N];   inline long long pow(long long x, int y) {     if (y == 1) return x;     long long k = 1;     for (; y; y >>= 1, x = x * x)       if (y & 1) k = k * x;     return k;   }   inline void dfs1(long long a, int x, long long b) {     if (!x) {       if (b < a) return;       long long c = V / b / a;       if (a * b + a * c + b * c < ans) {         ans = a * b + a * c + b * c;         A = a, B = b, C = c;       }       return;     }     for (int i = 0; i <= s[x].num; ++i) {       if (a * b * 2 + b * b >= ans || a * b * b > V) return;       dfs1(a, x - 1, b);       if (i == s[x].num) break;       b *= s[x].s;     }     return;   }   inline void dfs(int x, long long a) {     if (x > n) {       double tem = sqrt(V / a);       if (tem * tem + a * tem * 2 >= ans) return;       dfs1(a, n, 1);       return;     }     for (register int i = 0; i <= s[x].num; ++i) {       if (a * a * 3 >= ans || a * a * a > V) return;       s[x].num -= i;       dfs(x + 1, a);       s[x].num += i;       if (i == s[x].num) break;       a *= s[x].s;     }     return;   }   int main() {     for (register int T = read(); T; --T) {       n = read();       V = 1;       for (register int i = 1; i <= n; ++i)         s[i].s = read(), s[i].num = read(), V *= pow(s[i].s, s[i].num);       std::sort(s + 1, s + 1 + n);       ans = V << 1 | 1;       A = B = 1, C = V;       dfs(1, 1);       write(ans << 1), putchar(   );       write(A), putchar(   );       write(B), putchar(   );       write(C), puts(  );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, k, p, q, x = 0, y = 0, ans;     cin >> n >> k;     p = q = n;     while (p % 2 == 0) {       p /= 2;       x++;     }     while (q % 5 == 0) {       q /= 5;       y++;     }     p = k - x;     q = k - y;     if (p < 0) p = 0;     if (q < 0) q = 0;     ans = n * pow(2, p) * pow(5, q);     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n;       long long w;       cin >> n >> w;       pair<long long, int> wt[n];       for (int i = 0; i < n; i++) {         cin >> wt[i].first;         wt[i].second = i + 1;       }       vector<int> taken;       sort(wt, wt + n);       long long current = 0;       for (int i = n - 1; i >= 0; i--) {         if (current + wt[i].first <= w) {           taken.push_back(wt[i].second);           current += wt[i].first;         }         assert(current <= w);       }       if (current * 2 >= w) {         cout << taken.size() <<   n ;         for (int i : taken) cout << i <<    ;         cout <<   n ;       } else {         cout <<  -1 n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int Maxn = 1e4 + 100;   struct Date {     int x, y;     bool z;   };   stack<Date> S;   int n, m, x, y, flag;   struct dsu {     int f[Maxn];     bool odd[Maxn];     void clear() {       for (int i = 1; i <= n; i++) f[i] = i, odd[i] = false;     }     int find(int x, int w) {       if (x == f[x]) return x;       if (w) S.push((Date){x, f[x], odd[x]});       int ans = find(f[x], w);       odd[x] ^= odd[f[x]];       return f[x] = ans;     }     bool merge(int x, int y, int w) {       int u = find(x, w), v = find(y, w);       if (u == v) return odd[x] == odd[y];       if (w) S.push((Date){u, f[u], odd[u]});       f[u] = y;       odd[u] = odd[x] ^ 1;       return false;     }     void restore() {       while (!S.empty()) {         Date i = S.top();         f[i.x] = i.y;         odd[i.x] = i.z;         S.pop();       }     }   } Dsu;   struct Edge {     int from, to;   };   vector<Edge> edges;   vector<int> ans;   int main() {     scanf( %d %d , &n, &m);     if (m == 0) {       printf( 0 );       return 0;     }     for (int i = 1; i <= m; i++) {       scanf( %d %d , &x, &y);       edges.push_back((Edge){x, y});     }     int Len = sqrt(m + 0.5), N = (m - 1) / Len + 1;     for (int i = 1; i <= N; i++) {       Dsu.clear();       flag = false;       for (int j = 0; j < m; j++) {         if (j < i * Len && j >= (i - 1) * Len) continue;         int from = edges[j].from, to = edges[j].to;         if (Dsu.merge(from, to, 0)) {           flag = true;           break;         }       }       if (flag) continue;       for (int j = (i - 1) * Len; j < min(i * Len, m); j++) {         for (int k = (i - 1) * Len; k < min(i * Len, m); k++) {           if (j == k) continue;           if (Dsu.merge(edges[k].from, edges[k].to, 1)) {             flag = true;             break;           }         }         if (!flag) ans.push_back(j + 1);         Dsu.restore();         flag = false;       }     }     printf( %d n , ans.size());     for (int i = 0; i < ans.size(); i++) printf( %d  , ans[i]);   }