malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   inline void pisz(int n) { printf( %d n , n); }   int dl[1000][1000];   int dr[1000][1000];   int ul[1000][1000];   int ur[1000][1000];   int g[1000][1000];   int n, m;   int recdl(int i, int j) {     if (i < 0 || i == n || j < 0 || j == m) return -1001001001;     if (i == n - 1 && j == 0) return g[i][j];     if (dl[i][j] != -1) return dl[i][j];     return dl[i][j] =                g[i][j] + (recdl(i + 1, j) < recdl(i, j - 1) ? recdl(i, j - 1)                                                             : recdl(i + 1, j));   }   int recdr(int i, int j) {     if (i < 0 || i == n || j < 0 || j == m) return -1001001001;     if (i == n - 1 && j == m - 1) return g[i][j];     if (dr[i][j] != -1) return dr[i][j];     return dr[i][j] =                g[i][j] + (recdr(i + 1, j) < recdr(i, j + 1) ? recdr(i, j + 1)                                                             : recdr(i + 1, j));   }   int recul(int i, int j) {     if (i < 0 || i == n || j < 0 || j == m) return -1001001001;     if (i == 0 && j == 0) return g[i][j];     if (ul[i][j] != -1) return ul[i][j];     return ul[i][j] =                g[i][j] + (recul(i - 1, j) < recul(i, j - 1) ? recul(i, j - 1)                                                             : recul(i - 1, j));   }   int recur(int i, int j) {     if (i < 0 || i == n || j < 0 || j == m) return -1001001001;     if (i == 0 && j == m - 1) return g[i][j];     if (ur[i][j] != -1) return ur[i][j];     return ur[i][j] =                g[i][j] + (recur(i - 1, j) < recur(i, j + 1) ? recur(i, j + 1)                                                             : recur(i - 1, j));   }   int main() {     cin >> n >> m;     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) cin >> g[i][j];     memset(dl, -1, sizeof(dl));     memset(dr, -1, sizeof(dr));     memset(ul, -1, sizeof(ul));     memset(ur, -1, sizeof(ur));     int res = 0;     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) {         int b1 = recul(i - 1, j) + recdl(i, j - 1);         int a1 = recdr(i + 1, j) + recur(i, j + 1);         int b2 = recul(i, j - 1) + recdl(i + 1, j);         int a2 = recdr(i, j + 1) + recur(i - 1, j);         res = (res < (b1 + a1 < b2 + a2 ? b2 + a2 : b1 + a1)                    ? (b1 + a1 < b2 + a2 ? b2 + a2 : b1 + a1)                    : res);       }     cout << res << endl;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = acos(-1.0);   const double eps = 0.0000000001;   const int N = 100000 + 100;   int head[N];   int tot;   struct node {     int to, next;   } edge[N << 1];   int color[N];   int vis[N];   int a[N];   int b[N];   int num[N];   void init() {     memset(head, -1, sizeof(head));     tot = 0;   }   void add(int u, int v) {     edge[tot].to = v;     edge[tot].next = head[u];     head[u] = tot++;   }   int DFS(int u, int t) {     if (vis[u] == 0) {       if (color[u] == 0) a[t]++;       if (color[u] == 1) b[t]++;       num[t]++;     }     vis[u] = 1;     for (int i = head[u]; i != -1; i = edge[i].next) {       int v = edge[i].to;       if (color[v] == 0) {         color[v] = color[u] ^ 1;         if (DFS(v, t) == 0) return 0;       } else if (color[u] == color[v]) {         return 0;       }     }     return 1;   }   int main() {     int n, m;     scanf( %d%d , &n, &m);     init();     int u, v;     for (int i = 1; i <= m; i++) {       scanf( %d%d , &u, &v);       add(u, v);       add(v, u);     }     if (m == 0) {       cout << 3 <<     << (long long)n * (n - 1) * (n - 2) / 6 << endl;       return 0;     }     memset(color, 0, sizeof(color));     memset(vis, 0, sizeof(vis));     int flag = 0;     int t = 0;     for (int i = 1; i <= n; i++) {       if (color[i] == 0 && vis[i] == 0) {         if (DFS(i, ++t) == 0) {           color[i] = 0;           flag = 1;           break;         }       }     }     if (flag == 1) {       cout << 0 <<     << 1 << endl;       return 0;     }     long long ans = 0;     flag = 0;     for (int i = 1; i <= t; i++) {       if (num[i] <= 2) {         flag++;         continue;       }       ans = ans + (long long)a[i] * (a[i] - 1) / 2 +             (long long)b[i] * (b[i] - 1) / 2;     }     if (flag != t)       cout << 1 <<     << ans << endl;     else {       cout << 2 <<     << (long long)m * (n - 2) << endl;     }   }
#include <bits/stdc++.h>   int main() {     int n, pur, foo = 0, quz = 1, bar = 0, baz = 0;     scanf( %d , &n);     for (int i = 1; i <= n; ++i) {       scanf( %d , &pur);       foo += pur, bar++;       if (foo * quz > bar * baz) quz = bar, baz = foo;     }     printf( %.6lf n , (double)baz / quz);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void fun() {}   long long int md = 998244353;   long long int __gcd(long long int a, long long int b) {     if (b == 0) return a;     return __gcd(b, a % b);   }   long long int poww(long long int a, long long int b, long long int md) {     if (b < 0) return 0;     if (a == 0) return 0;     long long int res = 1;     while (b) {       if (b & 1) {         res = (1ll * res * a) % md;       }       a = (1ll * a * a) % md;       b >>= 1;     }     return res;   }   long long int poww(long long int a, long long int b) {     if (b < 0) return 0;     if (a == 0) return 0;     long long int res = 1;     while (b) {       if (b & 1) {         res = (1ll * res * a);       }       a = (1ll * a * a);       b >>= 1;     }     return res;   }   void ainp(long long int arr[], long long int n) {     for (long long int i = 1; i <= n; i++) cin >> arr[i];   }   void disp(long long int arr[], long long int n) {     for (long long int i = 1; i <= n; i++) cout << arr[i] <<    ;     cout <<   n ;   }   void dispv(vector<long long int> &v) {     for (long long int i = 0; i < v.size(); i++) cout << v[i] <<    ;     cout <<   n ;   }   long long int divide(long long int a, long long int b, long long int md) {     long long int rr = a * (poww(b, md - 2, md));     rr %= md;     return rr;   }   const long long int size = 2e5 + 5;   long long int n, m, k, u, v;   vector<long long int> g[size];   pair<long long int, long long int> dis[size], prr[size];   queue<long long int> q;   long long int arr[size], suffmax[size];   bool fnn(pair<long long int, long long int> &p1,            pair<long long int, long long int> &p2) {     return (p1.first - p1.second < p2.first - p2.second);   }   void bfs() {     dis[1].first = 0;     q.push(1);     while (!q.empty()) {       long long int node = q.front();       q.pop();       for (long long int child : g[node]) {         if (dis[child].first > dis[node].first + 1 ||             (child != 1 && dis[child].first == 0)) {           dis[child].first = dis[node].first + 1;           q.push(child);         }       }     }     q.push(n);     dis[n].second = 0;     while (!q.empty()) {       long long int node = q.front();       q.pop();       for (long long int child : g[node]) {         if (dis[child].second > dis[node].second + 1 ||             (child != n && dis[child].second == 0)) {           dis[child].second = dis[node].second + 1;           q.push(child);         }       }     }   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     fun();     cin >> n >> m >> k;     ainp(arr, k);     for (long long int i = 1; i <= m; i++) {       cin >> u >> v;       g[u].push_back(v);       g[v].push_back(u);     }     bfs();     for (long long int i = 1; i <= k; i++) prr[i] = dis[arr[i]];     sort(prr + 1, prr + 1 + k, fnn);     for (long long int i = k; i > 0; i--)       suffmax[i] = max(suffmax[i + 1], prr[i].second);     long long int cost = dis[n].first;     long long int cst = 0;     for (long long int i = 1; i < k; i++) {       cst = max(suffmax[i + 1] + 1 + prr[i].first, cst);     }     cout << min(cst, cost) <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N, M, T;   int A[20000];   int rans;   vector<int> ans;   set<pair<int, int>> online;   multiset<pair<int, int>> events;   bool solve() {     bool good = false;     for (int i = 0; i < N; i++) events.insert({A[i], -1});     while (!events.empty()) {       int t = events.begin()->first;       int v = events.begin()->second;       events.erase(events.begin());       if (v == -1) {         if ((int)online.size() < M) {           rans++;           online.insert({t + T - 1, rans});           events.insert({t + T - 1, rans});           ans.push_back(rans);         } else {           pair<int, int> guy = *online.rbegin();           online.erase(guy);           events.erase(events.find(guy));           guy.first = t + T - 1;           online.insert(guy);           events.insert(guy);           ans.push_back(guy.second);         }         good |= (int)online.size() == M;       } else         online.erase({t, v});     }     return good;   }   int main() {     scanf( %d%d%d , &N, &M, &T);     int hh, mm, ss;     for (int i = 0; i < N; i++) {       scanf( %d:%d:%d , &hh, &mm, &ss);       A[i] = hh * 3600 + mm * 60 + ss;     }     if (!solve())       printf( No solution n );     else {       printf( %d n , rans);       for (auto& it : ans) printf( %d n , it);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void init_code() {}   int main() {     init_code();     long long t;     cin >> t;     while (t--) {       long long n, k;       cin >> n >> k;       long long num = 1, res = 0;       while (k) {         if (k & 1) {           res += num;           res %= 1000000000 + 7;         }         k >>= 1;         num *= n;         num %= 1000000000 + 7;       }       cout << res <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) {     for (; b; a %= b, swap(a, b))       ;     return a;   }   int dx[4] = {1, -1, 0, 0};   int dy[4] = {0, 0, 1, -1};   int main(void) {     ios::sync_with_stdio(0);     cin.tie(0), cout.tie(0);     int t;     cin >> t;     while (t--) {       int n, k;       cin >> n >> k;       int ones = 0;       vector<int> one(k);       string st;       cin >> st;       for (int i = 0; i < n; i++) {         if (st[i] ==  1 ) {           one[i % k]++;           ones++;         }       }       int ans = ones;       for (int i = 0; i < k; i++) {         int tmp = ones - one[i % k];         string t =   ;         vector<int> cnt;         cnt.push_back(0);         for (int j = i; j < n; j += k) {           t += st[j];           if (cnt.size() == 0)             cnt.push_back(st[j] -  0 );           else             cnt.push_back(cnt.back() + st[j] -  0 );         }         int len = t.size();         vector<int> dp(len + 1);         int res = 1e9;         for (int j = 1; j <= len; j++) {           int p = (t[j - 1] ==  0  ? 1 : 0);           dp[j] = min(dp[j - 1] + p, cnt[j - 1] + p);         }         for (int j = 1; j <= len; j++) res = min(res, dp[j] + cnt[len] - cnt[j]);         ans = min(ans, res + tmp);       }       cout << ans <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   long long a[15], y, k2, k3, r1, z, k4, r, max1, k5, k1, min1, b[1005], n1, n, m,       k, i, j;   vector<char> f;   int main() {     string s, s1;     cin >> k >> n;     cin >> s;     for (i = 0; i < n; i++) {       for (j = 0; j < 10; j++) a[j] = 0;       cin >> k1 >> k2;       s1.clear();       for (j = k1 - 1; j <= k2 - 1; j++) s1.push_back(s[j]);       j = 0;       k3 = 1;       z = 0;       while (j >= 0 && j < s1.size()) {         if ((int)s1[j] >= (int) 0  && (int)s1[j] <= (int) 9 ) {           a[(int)s1[j] - (int) 0 ]++;           if (s1[j] ==  0 )             s1[j] =  - ;           else             s1[j] = (char)((int)s1[j] - 1);           j += k3;           z = 0;         } else if (s1[j] ==  > ) {           if (z) s1[k4] =  - ;           k4 = j;           z = 1;           k3 = 1;           j += k3;         } else if (s1[j] ==  < ) {           if (z) s1[k4] =  - ;           k4 = j;           z = 1;           k3 = -1;           j += k3;         } else           j += k3;       }       for (j = 0; j < 10; j++) cout << a[j] <<    ;       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 501;   int a[N][N], b[N][N];   void solve() {     int n, m;     cin >> n >> m;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         cin >> a[i][j];       }     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         cin >> b[i][j];       }     }     for (int i = 0; i < m; i++) {       vector<int> comp1, comp2;       int x = 0, y = i;       while (x < n && y >= 0) {         comp1.push_back(a[x][y]);         comp2.push_back(b[x][y]);         x++, y--;       }       sort(comp1.begin(), comp1.end());       sort(comp2.begin(), comp2.end());       if (comp1 != comp2) {         cout <<  NO n ;         return;       }     }     for (int i = 1; i < n; i++) {       vector<int> comp1, comp2;       int x = i, y = m - 1;       while (x < n && y >= 0) {         comp1.push_back(a[x][y]);         comp2.push_back(b[x][y]);         x++, y--;       }       sort(comp1.begin(), comp1.end());       sort(comp2.begin(), comp2.end());       if (comp1 != comp2) {         cout <<  NO n ;         return;       }     }     cout <<  YES n ;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int t = 1;     for (int tt = 1; tt <= t; tt++) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   int mirror(int num) {     int res = 0;     for (int i = 0; i < 4; ++i) {       res |= (num & (1 << i)) << (7 - i - i);       res |= (num & (1 << (7 - i))) >> (7 - i - i);     }     return res;   }   int main() {     int num;     string s;     vector<int> res;     getline(cin, s);     num = (0 + 256 - mirror((int)s[0])) % 256;     res.push_back(num);     for (int i = 1; i < s.size(); ++i) {       num = (-mirror(s[i]) + 256 + mirror(s[i - 1])) % 256;       res.push_back(num);     }     for (int i = 0; i < res.size(); ++i) {       cout << res[i] << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 10;   struct edge {     int to, nxt, w;   } e[N << 1];   int head[N], tot = 0;   int n, m;   int vis[N], mxd, id;   int sum[N], dr[N], cnt = 0, pa[N], used[N];   int dp[N], a[N], b[N], siz[N], anc[N], mp[N];   void adde(int u, int v, int w) {     e[++tot] = edge{v, head[u], w}, head[u] = tot;   }   void dfs(int u, int fa, int dep) {     pa[u] = fa;     if (vis[u] && dep > mxd) id = u, mxd = dep;     for (int i = head[u]; i; i = e[i].nxt) {       int v = e[i].to;       if (v == fa) continue;       dfs(v, u, dep + e[i].w);     }     return;   }   void gtag(int u, int fa, int *a, int dep) {     a[u] = dep;     for (int i = head[u]; i; i = e[i].nxt) {       int v = e[i].to;       if (v == fa) continue;       gtag(v, u, a, dep + e[i].w);     }     return;   }   void Dfs(int u, int fa, int rt) {     siz[u] = vis[u];     anc[u] = rt;     for (int i = head[u]; i; i = e[i].nxt) {       int v = e[i].to;       if (v == fa) continue;       if (used[v]) continue;       Dfs(v, u, rt);       siz[u] += siz[v];       dp[u] = max(dp[u], dp[v] + e[i].w);     }     return;   }   int main() {     scanf( %d%d , &n, &m);     int x;     for (int i = 1; i <= m; i++) scanf( %d , &x), vis[x] = 1;     int u, v, w;     for (int i = 1; i < n; i++) {       scanf( %d%d%d , &u, &v, &w);       adde(u, v, w), adde(v, u, w);     }     id = mxd = -1;     dfs(1, 0, 0);     int s = id;     id = mxd = -1;     dfs(s, 0, 0);     int t = id;     swap(s, t);     for (int now = s; now; now = pa[now])       dr[++cnt] = now, used[now] = 1, mp[now] = cnt;     dr[cnt + 1] = n + 1;     mp[n + 1] = cnt + 1;     gtag(s, 0, a, 0);     gtag(t, 0, b, 0);     for (int i = 1; i <= cnt; i++) Dfs(dr[i], 0, dr[i]);     int ans = 0;     for (int i = 1; i <= n; i++)       if (!used[i] && !vis[i]) ans = max(ans, siz[i]);     for (int i = 1; i <= n; i++) {       if (!vis[i]) continue;       int u = anc[i];       int d = max(a[u], b[u]);       int k = mp[u];       if (dp[u] == d || (a[u] == d && b[u] == d))         sum[k]++, sum[k + 1]--;       else {         if (a[u] == d)           sum[0]++, sum[k + 1]--;         else           sum[k]++;       }     }     for (int i = 1; i <= cnt; i++) sum[i] += sum[i - 1];     for (int i = 1; i <= cnt; i++)       if (!vis[dr[i]]) ans = max(ans, sum[i]);     int amou = 0;     for (int i = 1; i <= n; i++)       if (!used[i] && !vis[i] && siz[i] == ans) amou++;     for (int i = 1; i <= cnt; i++)       if (!vis[dr[i]] && sum[i] == ans) amou++;     printf( %d %d n , ans, amou);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool isPrime(int n) {     if (n <= 1) return false;     if (n <= 3) return true;     if (n % 2 == 0 || n % 3 == 0) return false;     for (int i = 5; i * i <= n; i = i + 6)       if (n % i == 0 || n % (i + 2) == 0) return false;     return true;   }   void solve() {     int n;     cin >> n;     long double pi = 2.0 * acos(0.0), ans, x;     x = pi / (long double)(2.0 * n);     ans = tan(x);     cout << fixed << setprecision(9) << 1.0 / ans <<   n ;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     ;     int t;     cin >> t;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimise( Ofast ,  unroll-loops)   using namespace std;   void solve() {     int n, m, k;     cin >> n >> m >> k;     long long a[n][m], b[n * m + 3], c[n][m];     memset(a, 0, sizeof(a));     memset(b, 0, sizeof(b));     memset(c, 0, sizeof(c));     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         cin >> a[i][j];       }     }     for (int i = 0; i < k; i++) {       int x, y;       cin >> x >> y;       x--;       y--;       b[y]++;       c[x][y]++;     }     for (int i = 0; i < n - 1; i++) {       long long ans = 0;       for (int j = 0; j < m; j++) {         if (a[i][j] == 1) {           ans += (b[j] - c[i][j]);         }       }       cout << ans <<    ;     }     long long ans = 0;     for (int j = 0; j < m; j++) {       if (a[n - 1][j] == 1) {         ans += (b[j] - c[n - 1][j]);       }     }     cout << ans;     return;   }   int main() {     cin.tie(0);     ios_base::sync_with_stdio(0);     int t = 1;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long a[14], tmp[14];     for (long long i = 0; i < 14; i++) cin >> a[i];     long long anss = 0;     for (long long i = 0; i < 14; i++) {       for (long long j = 0; j < 14; j++) tmp[j] = a[j];       long long ans = 0;       if (tmp[i]) {         long long k = tmp[i];         long long add = k / 14;         long long rem = k % 14;         tmp[i] = 0;         long long p = i + 1;         for (long long j = 0; j < 14; j++) {           tmp[p % 14] += add;           p++;         }         p = i + 1;         while (rem) {           tmp[p % 14]++;           p++;           rem--;         }         for (long long j = 0; j < 14; j++)           if (tmp[j] % 2 == 0) ans += tmp[j];       }       anss = max(anss, ans);     }     cout << anss;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 300002;   int n, m, l[MAXN * 4], r[MAXN * 4], d[MAXN * 4], id[MAXN];   string s;   void input() {     scanf( %d%d , &n, &m);     cin.ignore(1);     getline(cin, s);     s =  0  + s;   }   void init(int x, int left, int right) {     l[x] = left;     r[x] = right;     if (left == right) {       d[x] = 0;       id[left] = x;       return;     }     int mid = (left + right) / 2;     init(x * 2, left, mid);     init(x * 2 + 1, mid + 1, right);     d[x] = d[x * 2] + d[x * 2 + 1];     if (s[mid] ==  .  && s[mid + 1] ==  . ) d[x]++;   }   void update(int a) {     int x = id[a];     x /= 2;     while (x > 0) {       d[x] = d[x * 2] + d[x * 2 + 1];       if (s[r[x * 2]] ==  .  && s[l[x * 2 + 1]] ==  . ) d[x]++;       x /= 2;     }   }   int main() {     input();     init(1, 1, n);     int a;     char b;     for (int q = 1; q <= m; q++) {       scanf( %d %c , &a, &b);       if ((s[a] ==  .  && b ==  . ) || (s[a] !=  .  && b !=  . )) {         printf( %d n , d[1]);         continue;       }       s[a] = b;       update(a);       printf( %d n , d[1]);     }   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, len;   long long a, b, c, l;   void solve() {     long long tot = ((l + 3) * (l + 2) * (l + 1)) / 6;     long long i;     for (i = 0; i <= l; i++) {       long long x = min(a - b - c + i, l - i);       if (x < 0) continue;       tot -= ((x + 2) * (x + 1)) >> 1;     }     for (i = 0; i <= l; i++) {       long long x = min(b - a - c + i, l - i);       if (x < 0) continue;       tot -= ((x + 2) * (x + 1)) >> 1;     }     for (i = 0; i <= l; i++) {       long long x = min(c - a - b + i, l - i);       if (x < 0) continue;       tot -= ((x + 2) * (x + 1)) >> 1;     }     cout << tot <<   n ;   }   int main() {     long long i, j, k, t;     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     cin >> a >> b >> c >> l;     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1000000009;   const int MAXN = 100000;   int n, m;   vector<pair<int, int> > graph[MAXN + 3];   bool vis[MAXN + 3];   bool color[MAXN + 3];   vector<int> ans[2], curr, output;   int counter;   void Read() {     scanf( %d %d , &n, &m);     for (int i = 0; i < m; i++) {       int a, b, c;       char col;       scanf( %d %d %c , &a, &b, &col);       if (col ==  B )         c = 1;       else         c = 0;       graph[a].push_back(make_pair(b, c));       graph[b].push_back(make_pair(a, c));     }   }   void Clean() {     for (int i = 1; i <= n; i++) vis[i] = false;     for (int i = 1; i <= n; i++) color[i] = 0;     for (int i = 1; i <= n; i++)       for (int j = 0; j < (int)graph[i].size(); j++)         graph[i][j].second = (graph[i][j].second + 1) % 2;     curr.clear();   }   bool Dfs(int v) {     vis[v] = true;     curr.push_back(v);     if (color[v] == 0) counter++;     for (int i = 0; i < (int)graph[v].size(); i++) {       int u = graph[v][i].first;       int sum = graph[v][i].second;       if (!vis[u]) {         color[u] = (sum - color[v] + 2) % 2;         if (Dfs(u) == false) return false;       } else {         if (color[u] != (sum - color[v] + 2) % 2) return false;       }     }     return true;   }   bool Solve(int ind) {     for (int v = 1; v <= n; v++) {       if (!vis[v]) {         if (Dfs(v) == false) return false;       }       for (int i = 0; i < (int)curr.size(); i++) {         if (color[curr[i]] == 0 && 2 * counter < (int)curr.size())           ans[ind].push_back(curr[i]);         else if (color[curr[i]] == 1 && 2 * counter >= (int)curr.size())           ans[ind].push_back(curr[i]);       }       curr.clear();       counter = 0;     }     return true;   }   int main() {     Read();     bool check0 = Solve(0);     Clean();     bool check1 = Solve(1);     if (!check0 && !check1) {       puts( -1 );       return 0;     }     if (!check1 || (ans[0].size() < ans[1].size() && check0))       output = ans[0];     else       output = ans[1];     printf( %d n , (int)output.size());     for (int i = 0; i < (int)output.size(); i++) {       printf( %d  , output[i]);     }     puts(  );     return 0;   }