malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1000000007;   int N, M, K;   long long F[1111][1111], T[1111], G[111111];   map<int, int> P;   inline long long Pow(long long A, int B) {     long long Ret = 1;     for (; B; B >>= 1) {       if (B & 1) {         Ret = (Ret * A) % MOD;       }       A = (A * A) % MOD;     }     return Ret;   }   int main(int argc, char *argv[]) {     for (int l = 1; l < 10; l++) {       for (int i = 0; i < 1 << l; i++) {         int x = 0;         for (int k = 0; k < l; k++) {           x *= 10;           if (i & (1 << k)) {             x += 4;           } else {             x += 7;           }         }         P[x] = ++M;       }     }     scanf( %d%d , &N, &K);     for (int i = 0, x; i < N; i++) {       scanf( %d , &x);       if (P.find(x) != P.end()) {         T[P[x]]++;       } else {         T[0]++;       }     }     N = T[0];     F[0][0] = 1;     for (int i = 1; i <= M; i++) {       for (int j = 0; j <= M; j++)         if (F[i - 1][j]) {           F[i][j] = (F[i][j] + F[i - 1][j]) % MOD;           F[i][j + 1] = (F[i][j + 1] + F[i - 1][j] * T[i]) % MOD;         }     }     G[0] = 1;     for (int i = 1; i <= N; i++) {       G[i] = (G[i - 1] * (N + 1 - i)) % MOD;       G[i] = (G[i] * Pow(i, MOD - 2)) % MOD;     }     long long Ret = 0;     for (int i = 0; i <= M && i <= K; i++) {       Ret += F[M][i] * G[K - i];       Ret %= MOD;     }     printf( %I64d n , Ret);     return 0;   }
#include <bits/stdc++.h>   const int N = 100010;   int n;   int head[N], to[2 * N], next[2 * N], graphmr;   double ans;   inline void add(int x, int y) {     int p = graphmr++;     to[p] = y;     next[p] = head[x];     head[x] = p;   }   inline void dfs(int x, int fa, int dis) {     ans += 1.0 / dis;     for (int i = head[x]; ~i; i = next[i])       if (to[i] != fa) dfs(to[i], x, dis + 1);   }   int main() {     scanf( %d , &n);     memset(head, -1, sizeof head);     for (int i = 1, x, y; i < n; i++) {       scanf( %d%d , &x, &y);       add(x, y);       add(y, x);     }     dfs(1, 0, 1);     printf( %lf n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[300001];   int f[300001];   vector<int> g[33];   map<vector<int>, int> mp;   vector<pair<vector<int>, int> > v;   vector<int> cur;   int br = 0;   int n;   void F(int pos, int mask) {     if (pos == br) {       v.push_back({cur, mask});       return;     }     F(pos + 1, mask);     if (g[pos].empty() || g[pos].size() == n) return;     for (auto to : g[pos]) cur[to]++;     F(pos + 1, (mask ^ (1 << pos)));     for (auto to : g[pos]) cur[to]--;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     for (int i = 1; i <= n; i++) f[i] = __builtin_popcount(a[i]);     set<int> st;     for (int i = 1; i <= n; i++) st.insert(f[i] % 2);     if (st.size() == 2) {       cout << -1;       return 0;     }     for (int i = 1; i <= n; i++) f[i] /= 2;     for (int i = 1; i <= n; i++) {       for (int j = 0; j < 30; j++) {         if (a[i] & (1 << j)) continue;         g[j].push_back(i - 1);       }     }     cur.resize(n);     for (int i = 0; i < n; i++) cur[i] = 0;     br = 15;     F(0, 0);     for (auto cur : v) {       mp[cur.first] = cur.second;     }     for (int i = 0; i < n; i++) cur[i] = 0;     br = 30;     F(15, 0);     for (auto x : v) {       vector<int> cur = x.first;       int mask = x.second;       for (int t = 0; t <= 60; t++) {         vector<int> to(n, t);         for (int i = 0; i < n; i++) to[i] -= f[i + 1] + cur[i];         if (mp.find(to) != mp.end()) {           cout << (mask ^ mp[to]);           return 0;         }       }     }     cout << -1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, c;     cin >> n >> c;     int a[n];     int cnt = 0;     vector<int> b;     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 1; i < n; i++) {       if (abs(a[i] - a[i - 1]) <= c)         cnt++;       else {         cnt = 0;       }     }     cout << cnt + 1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string str;     int n;     cin >> n >> str;     int A[n], m = 0;     string RE[n];     A[0] = 0;     for (int i = 1, t = 0, tmp =  [ ; i < n; i++) {       if (str[i] == tmp) {         if (str[i] ==  ] )           t--;         else           t++;       }       A[i] = t;       if (t > m) m = t;       tmp = str[i];     }     for (int i = 0; i < m + 2; i++) {       for (int j = 0; j < n; j++) {         if (A[j] == i) {           if (str[j] ==  [ )             RE[i].append( +- );           else if (str[j] ==  ]  && str[j - 1] ==  [ )             RE[i].append(  -+ );           else             RE[i].append( -+ );         } else if (A[j] > i) {           if (str[j - 1] == str[j])             RE[i].append(   );           else if (str[j - 1] ==  [  && str[j] ==  ] )             RE[i].append(    );           else             RE[i].append(     );         } else {           if (str[j - 1] ==  [  && str[j] ==  ] ) {             RE[i].append(    | );           } else {             RE[i].append( | );           }         }       }       cout << RE[i] << endl;     }     for (int i = m; i >= 0; i--) {       cout << RE[i] << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int root, n, m, tot, ans, a[2000010], zy[2000010];   bool b[2000010], v[2000010];   void dfs(int k) {     if (b[a[k]]) {       b[a[k]] = v[a[k]] = false;       dfs(a[k]);       v[a[k]] = true;     } else {       if (!v[a[k]]) {         tot++;         if (root == 0) {           root = k;           zy[k] = k;         } else           zy[k] = root;       }     }   }   int work(int k) {     if (v[a[k]]) {       v[a[k]] = false;       return (work(a[k]));     } else       return k;   }   int main(int argc, const char* argv[]) {     memset(b, true, sizeof(b));     int i, j, k;     tot = 0;     cin >> n;     root = 0;     for (i = 1; i <= n; ++i) {       scanf( %d , &a[i]);       if (a[i] == i) root = i;       zy[i] = a[i];     }     if (root != 0) tot = -1;     for (i = 1; i <= n; ++i)       if (b[i]) {         b[i] = v[i] = false;         dfs(i);         v[i] = true;       }     cout << tot << endl;     for (i = 1; i <= n; ++i) cout << zy[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7;   const double PI = 3.14159265359;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n;     cin >> n;     vector<int> facts;     for (int i = 1; i * i <= n; i++) {       if (!(n % i)) {         facts.push_back(i);         facts.push_back(n / i);       }     }     vector<long long> ans;     for (int i : facts) {       long long a = (n - 1) / i;       ans.push_back(a * (a + 1) * i / 2 + a + 1);     }     sort(ans.begin(), ans.end());     auto it = unique(ans.begin(), ans.end());     ans.resize(it - ans.begin());     for (auto i : ans) {       cout << i <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[100005], n, x, minn = 3;   bool m1[100005], m2[100005];   int read() {     int w = 0, f = 1;     char c = getchar();     while (c >  9  || c <  0 ) {       if (c ==  - ) f = -1;       c = getchar();     }     while (c >=  0  && c <=  9 ) {       w = (w << 3) + (w << 1) + (c ^ 48);       c = getchar();     }     return w * f;   }   int main() {     n = read(), x = read();     for (int i = 1; i <= n; i++) {       a[i] = read();     }     for (int i = 1; i <= n; i++) {       if (m1[a[i]]) minn = min(0, minn);       if (m2[a[i]]) minn = min(1, minn);       if (m1[a[i] & x]) minn = min(1, minn);       if (m2[a[i] & x]) minn = min(2, minn);       m1[a[i]] = 1, m2[a[i] & x] = 1;     }     if (minn == 3)       puts( -1 );     else       printf( %d n , minn);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string str;     cin >> str;     int count = 0;     while (str.size() > 1) {       string temp;       int num = 0;       count++;       for (int i = 0; i < str.size(); i++) {         num += str[i] - 48;       }       str =   ;       str = to_string(num);     }     cout << count << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve(long long k) {     for (long long n = 3; n <= 2000; ++n) {       for (long long a = 2; a < n; ++a) {         if ((n + k) % a == 0) {           long long y = (n + k) / a;           if (y <= 1000000 && (n - a) * y >= (a - 1) &&               n * (y - 1) > (n - a) * y) {             vector<long long> ans(n, 0);             ans[0] = 1;             ans[a - 1] = -2;             ans[a] = y;             cout << n <<   n ;             for (long long x : ans) cout << x <<    ;             cout <<   n ;             return;           }         }       }     }     cout << k << endl;     exit(0);   }   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     long long k;     cin >> k;     solve(k);   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1e18, N = 1e6, mod = 1e9 + 7;   const long double PI = acos(-1), eps = -1e9;   inline void read(long long &a) {     char c;     bool neg = 0;     c = getchar();     a = 0;     if (c ==  - ) {       neg = 1;       c = getchar();     }     while (c >=  0  && c <=  9 ) {       a = (a << 3) + (a << 1) + (c -  0 );       c = getchar();     }     if (neg) a *= -1;   }   long long a[N];   void solve() {     long long n;     read(n);     long long sum = 0, cur = 0;     for (long long i = 1; i <= n; i++) {       long long x;       read(x);       if (a[x] != 0) {         cur -= a[x];       }       a[x] = i;       cur += a[x];       sum += cur;     }     sum -= n;     sum *= 2;     sum += n;     cout << setprecision(20) << (long double)sum / ((long double)n * n);   }   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long t = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int c, a, i, n;   int main() {     cin >> n;     for (i = 0; i < n; i++) {       cin >> a;       if (i == 0)         c = a;       else         c = min(c, a);     }     if (c == 1)       cout << -1;     else       cout << 1;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int num;     int a = 0;     int b = 0;     int n;     cin >> n;     int sol[n];     for (a = 0; a < n; a++) {       cin >> num;       sol[num - 1] = (a + 1);     }     for (b = 0; b < n; b++) {       cout << sol[b] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 200005;   const int E = 80;   vector<long long> pr, f;   mt19937_64 gen(time(0));   long long a[maxn];   map<long long, long long> val;   int n;   long long solve(long long p) {     if (val.find(p) != val.end()) return val[p];     long long ret = 0;     for (int i = 0; i < n; i++) {       if (a[i] < p)         ret += p - a[i];       else {         long long h = a[i] % p;         ret += min(h, p - h);       }     }     val[p] = ret;     return ret;   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) scanf( %lld , &a[i]);     for (int i = 0; i < n; i++) {       f.push_back(a[i] + 1);       if (a[i] > 1) f.push_back(a[i]);       if (a[i] > 2) f.push_back(a[i] - 1);     }     int m = f.size();     long long ans = n;     for (int _ = 0; _ < E; _++) {       long long x = f[gen() % m], j = 2;       f.clear();       while (j * j <= x) {         if (x % j == 0) {           while (x % j == 0) x /= j;           pr.push_back(j);         }         ++j;       }       if (x > 1) pr.push_back(x);       for (auto p : pr) ans = min(ans, solve(p));     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main(int argc, char const *argv[]) {     int n;     scanf( %d , &n);     long long int a[n], b[n], p = 0, q = 0;     for (int i = 0; i < n; ++i) {       scanf( %I64d , &a[i]);       p |= a[i];     }     for (int i = 0; i < n; ++i) {       scanf( %I64d , &b[i]);       q |= b[i];     }     printf( %I64d n , p + q);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int max_n = 1e5 + 10;   const long long inf = 10000000000000000;   vector<int> adj[max_n];   vector<long long> cst[max_n];   vector<int> arr[max_n];   vector<long long> closest[max_n];   void cmp_closest(int i) {     int s = arr[i].size();     if (s > 0) {       closest[i].reserve(s);       closest[i][s - 1] = arr[i][s - 1] + 1;       for (int j = s - 2; j >= 0; --j) {         if (arr[i][j] + 1 != arr[i][j + 1]) {           closest[i][j] = arr[i][j] + 1;         } else {           closest[i][j] = closest[i][j + 1];         }       }     }   }   int n, m;   void add_edge(int a, int b, int c) {     adj[a].push_back(b);     cst[a].push_back(c);     adj[b].push_back(a);     cst[b].push_back(c);   }   void read() {     ios_base::sync_with_stdio(false);     cin >> n >> m;     for (int i = 0; i < m; ++i) {       int a, b, c;       cin >> a >> b >> c;       --a;       --b;       add_edge(a, b, c);     }     for (int i = 0; i < n; ++i) {       int k;       cin >> k;       for (int j = 0; j < k; ++j) {         long long t;         cin >> t;         arr[i].push_back(t);       }       cmp_closest(i);     }   }   long long dist[max_n];   struct cmpl {     inline bool operator()(int a, int b) const {       return (dist[a] < dist[b] || (dist[a] == dist[b] && a < b));     }   };   int cost(int u, size_t i) {     vector<int>::iterator it = lower_bound(arr[u].begin(), arr[u].end(), dist[u]);     if (it != arr[u].end() && *it == dist[u]) {       return cst[u][i] + (closest[u][it - arr[u].begin()]) - dist[u];     } else {       return cst[u][i];     }   }   set<int, cmpl> pq;   int main() {     read();     for (int i = 1; i < n; ++i) {       dist[i] = inf;     }     pq.insert(0);     int res = -1;     while (!pq.empty()) {       int curr = *pq.begin();       pq.erase(pq.begin());       if (curr == n - 1) {         res = dist[curr];         break;       } else {         for (size_t i = 0; i < adj[curr].size(); ++i) {           int v = adj[curr][i];           int c = cost(curr, i);           if (dist[curr] + c < dist[v]) {             pq.erase(v);             dist[v] = dist[curr] + c;             pq.insert(v);           }         }       }     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<pair<long long, vector<int> > > out;   int n, k;   int a[64];   bool found(long long x) {     for (int i = 0; i < out.size(); i++)       if (out[i].first == x) return true;     return false;   }   int main() {     cin >> n >> k;     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 0; out.size() < k && i < n; i++) {       int sz = out.size();       if (found(a[i]) == false) {         vector<int> push;         push.push_back(i);         out.push_back(make_pair(a[i], push));       }       for (int j = 0; out.size() < k && j < sz; j++) {         if (found(a[i] + out[j].first) == false) {           out.push_back(out[j]);           out[out.size() - 1].second.push_back(i);           out[out.size() - 1].first += a[i];         }       }     }     for (int i = 0; i < out.size(); i++) {       cout << out[i].second.size();       for (int j = 0; j < out[i].second.size(); j++)         cout <<     << a[out[i].second[j]];       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   static const int INF = 0x3f3f3f3f;   static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;   void solve4() {     string s;     cin >> s;     int c = 0;     int n = int((s).size());     for (char ch : s) {       c += (ch ==  a );     }     long long ans;     cerr <<  n           <<  =  << n <<  ,           <<  c           <<  =  << c << endl;     if (c > n / 2)       ans = n;     else       ans = 2 * c - 1;     cout << ans << endl;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     solve4();   }
#include <bits/stdc++.h>   using namespace std;   int n, m, t;   set<pair<int, int> > s;   string s1;   vector<int> v, v1;   int kek[100000];   int main() {     cin >> n >> m >> t;     for (int i = 1; i <= n; i++) {       cin >> s1;       int cur = 0;       cur += 60 * 60 * 10 * (s1[0] -  0 );       cur += 60 * 60 * (s1[1] -  0 );       cur += 60 * 10 * (s1[3] -  0 );       cur += 60 * (s1[4] -  0 );       cur += 10 * (s1[6] -  0 );       cur += (s1[7] -  0 );       v.push_back(cur);     }     s.clear();     int cur = 0;     int ans = 0;     int mx = 0;     for (int i = 0; i < v.size(); i++) {       while (!s.empty()) {         set<pair<int, int> >::iterator it = (--s.end());         if (-(*it).first < v[i])           s.erase(it);         else           break;         cur--;       }       if (cur < m) {         ans++;         kek[i] = ans;         cur++;         s.insert(make_pair(-(v[i] + t - 1), ans));       } else {         kek[i] = (*s.begin()).second;         s.erase(s.begin());         s.insert(make_pair(-(v[i] + t - 1), kek[i]));       }       mx = max(mx, cur);     }     if (mx != m) {       cout <<  No solution ;       return 0;     }     cout << ans <<   n ;     for (int i = 0; i < v.size(); i++) cout << kek[i] <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 60;   long long h, n;   int step[MAXN];   inline long long calc(long long high) { return (1ll << (high + 1)) - 1; }   void solve() {     long long tmp = (1ll << h) - 1 + n;     int cnt = 0;     while (tmp != 1) {       if (tmp % 2 == 1)         step[cnt++] = 1;       else         step[cnt++] = 0;       tmp /= 2;     }     long long res = 0;     int curdir = 0, dep = 0;     for (int i = cnt - 1; i >= 0; i--) {       if (curdir == step[i]) {         dep++;         res++;         curdir ^= 1;       } else {         long long tmp = calc(h - dep - 1);         res += tmp;         curdir = step[i];         i++;       }     }     cout << res << endl;   }   int main() {     cin >> h >> n;     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long int t;     t = 1;     while (t--) {       long long int n, c1 = 0, c2 = 0, x;       cin >> n;       while (n--) {         cin >> x;         if (x == 1)           c1++;         else           c2++;       }       x = min(c1, c2);       c1 -= x;       c2 -= x;       cout << x + (c1 / 3);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int getint() {     unsigned int c;     int x = 0;     while (((c = getchar()) -  0 ) >= 10) {       if (c ==  - ) return -getint();       if (!~c) exit(0);     }     do {       x = (x << 3) + (x << 1) + (c -  0 );     } while (((c = getchar()) -  0 ) < 10);     return x;   }   char a1[] =  ### ..# .#. #.. ;   char a2[] =  .#. ### .#. ### ;   char a3[] =  .#. ..# ### #.. ;   vector<int> px[4], py[4];   int n, m, grid[10][10], mx, res[10][10];   void solve(int x, int y, int curr) {     if (y >= m) {       solve(x + 1, 0, curr);       return;     }     if (x >= n) {       if (curr > mx) mx = curr, memcpy(res, grid, sizeof(res));       return;     }     int i, j, k, d, tmp[10][10], nx, ny;     int mxPossible = 0;     for (i = y; i < m; i++)       if (grid[x][i] == 0) mxPossible++;     for (i = x; i < n; i++)       for (j = 0; j < m; j++)         if (grid[i][j] == 0) mxPossible++;     mxPossible /= 5;     if (mxPossible + curr <= mx) return;     memcpy(tmp, grid, sizeof(tmp));     for (d = 0; d < 4; d++) {       bool canPlace = 1;       memcpy(grid, tmp, sizeof(tmp));       for (i = 0; i < px[d].size(); i++) {         nx = x + px[d][i];         ny = y + py[d][i];         if (nx >= n or ny >= m or grid[nx][ny]) {           canPlace = 0;           break;         }         grid[nx][ny] = curr + 1;       }       if (canPlace) {         solve(x, y + 1, curr + 1);       }     }     memcpy(grid, tmp, sizeof(tmp));     solve(x, y + 1, curr);   }   int main() {     int i, j, tcc, tc = 1 << 28;     for (i = 0; i < 4; i++) {       for (j = 0; j < 3; j++)         if (a1[i * 4 + j] ==  # ) px[i].push_back(0), py[i].push_back(j);       for (j = 0; j < 3; j++)         if (a2[i * 4 + j] ==  # ) px[i].push_back(1), py[i].push_back(j);       for (j = 0; j < 3; j++)         if (a3[i * 4 + j] ==  # ) px[i].push_back(2), py[i].push_back(j);     }     for (tcc = 0; tcc < tc; tcc++) {       n = getint(), m = getint(), mx = 0;       if (n == 9 and m == 9) {         puts( 13 );         puts(              AAA.BCCC. n.ABBB.CD. n.AE.BFCD. nEEEFFFDDD nG.E.HFIII nGGGJHHHI.                nGK.JHL.IM n.KJJJLMMM nKKK.LLL.M n );         continue;       }       memset(res, 0, sizeof(res));       memset(grid, 0, sizeof(grid));       solve(0, 0, 0);       printf( %d n , mx);       for (i = 0; i < n; i++) {         for (j = 0; j < m; j++) {           if (res[i][j] == 0)             putchar( . );           else             putchar( A  + res[i][j] - 1);         }         puts(  );       }       puts(  );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int v[300001], sol[300001], S;   int cnt = 0, marked[300001], dp[300001][2];   vector<int> g[300001];   long long int dfs(int node, int p) {     sol[node] = v[node];     long long int res = sol[node];     for (auto it : g[node])       if (it != p) {         res = max(res, dfs(it, node));         if (sol[it] > 0) sol[node] += sol[it];       }     res = max(res, sol[node]);     return res;   }   void getcnt(int node, int p) {     for (auto it : g[node])       if (it != p) {         getcnt(it, node);         if (sol[it] > 0 && marked[it]) marked[node] = 1;       }     if (!marked[node] && sol[node] == S) {       cnt++;       marked[node] = 1;     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int n, m, i, a, b, k;     cin >> n;     for (i = 0; i < n; i++) cin >> v[i];     for (i = 0; i < n - 1; i++) {       int u, v;       cin >> u >> v;       g[u - 1].push_back(v - 1);       g[v - 1].push_back(u - 1);     }     S = dfs(0, 0);     getcnt(0, 0);     cout << S * cnt <<     << cnt <<   n ;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC target( avx2 )   #pragma GCC optimization( O3 )   #pragma GCC optimization( unroll-loops )   using namespace std;   using ll = long long;   using vll = int64_t;   const int N = 1e6 + 1;   vector<int> adj[N];   vector<bool> vis(N, false);   vector<short> col(N, -1);   inline bool bfs(int src) {     queue<pair<int, int>> q;     q.push({src, 0});     vis[src] = true;     col[src] = 0;     while (!q.empty()) {       auto p = q.front();       q.pop();       for (int i : adj[p.first]) {         if (vis[i]) {           if (col[i] == col[p.first]) {             return false;           }           continue;         }         vis[i] = true;         col[i] = (p.second == 1 ? 0 : 1);         q.push({i, col[i]});       }     }     return true;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n;     cin >> n;     int m;     cin >> m;     unordered_set<int> hs;     for (int i = 0; i < m; i++) {       int a, b;       cin >> a >> b;       a--;       b--;       adj[a].push_back(b);       adj[b].push_back(a);       hs.insert(a);       hs.insert(b);     }     for (int i = 0; i < n; i++) {       if (!vis[i] && hs.find(i) != hs.end()) {         bool ok = bfs(i);         if (!ok) {           cout <<  -1 n ;           return 0;         }       }     }     int red = 0, black = 0;     for (int i = 0; i < n; i++) {       if (col[i] == 1)         black++;       else if (col[i] == 0)         red++;     }     cout << red <<   n ;     for (int i = 0; i < n; i++) {       if (col[i] == 0) cout << 1 + i <<    ;     }     cout <<   n ;     cout << black <<   n ;     for (int i = 0; i < n; i++) {       if (col[i] == 1) cout << i + 1 <<    ;     }     return 0;   }