malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   using i64 = long long;   int n, p[666][666], quad[666];   bool alive[666];   i64 x[666], y[666], px[666], py[666];   int gopos[666][666], goneg[666][666], f[666], id[666];   i64 dp[666][666][4], ans;   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %lld%lld , &x[i], &y[i]);     }     for (int i = 1; i <= n; i++) {       auto getquad = [&](int px, int py) {         if (px == 0 && py == 0) return 0;         if (py < 0 || (py == 0 && px < 0)) return 1;         return 2;       };       for (int j = 1; j <= n; j++) {         px[j] = x[j] - x[i];         py[j] = y[j] - y[i];         p[i][j] = j;         quad[j] = getquad(px[j], py[j]);       }       for (int j = 1; j <= n; j++) {         px[j + n] = x[i] - x[j];         py[j + n] = y[i] - y[j];         p[i][j + n] = j + n;         quad[j + n] = getquad(px[j + n], py[j + n]);       }       sort(p[i] + 1, p[i] + 2 * n + 1, [&](int a, int b) {         return quad[a] != quad[b] ? quad[a] < quad[b]                                   : (px[a] * py[b] < px[b] * py[a]);       });       for (int j = 1; j <= 2 * n; j++)         if (p[i][j] > n) p[i][j] = n - p[i][j];     }     for (int i = 1; i <= n; i++) {       int m = 0;       for (int j = 1; j <= n; j++) {         if (y[j] > y[i] || (y[j] == y[i] && x[j] >= x[i]))           alive[j] = 1;         else           alive[j] = 0;         px[j] = x[j] - x[i];         py[j] = y[j] - y[i];         if (alive[j] && j != i) {           f[++m] = j;         }       }       sort(f + 1, f + m + 1,            [&](int a, int b) { return px[a] * py[b] < px[b] * py[a]; });       f[0] = i;       for (int i = 0; i <= m; i++) id[f[i]] = i;       memset(gopos, -1, sizeof(gopos));       memset(goneg, -1, sizeof(goneg));       for (int i = 0; i <= m; i++) {         int nxtpos = -1;         for (int j = 4 * n; j >= 1; j--) {           int aj = (j - 1) % (2 * n) + 1;           int u = p[f[i]][aj];           if (u > 0 && alive[u] && nxtpos >= 0) {             gopos[i][id[u]] = nxtpos;           }           if (u < 0 && alive[-u] && nxtpos >= 0) {             goneg[i][id[-u]] = nxtpos;           }           if (u > 0 && alive[u] && u != f[i]) {             nxtpos = id[u];           }         }       }       memset(dp, 0, sizeof(dp));       dp[0][1][0] = 1;       for (int i = 0; i <= m; i++) {         int u = goneg[i][0];         for (int j = 0; j < m - 1; j++) {           int v = gopos[i][u];           for (int k = 0; k <= 3; k++) {             dp[i][v][k] += dp[i][u][k];           }           u = v;         }         for (int j = i + 1; j <= m; j++) {           ans += dp[i][j][3];           int nxt = goneg[j][i];           if (nxt > j) {             for (int k = 0; k <= 2; k++) {               dp[j][nxt][k + 1] += dp[i][j][k];             }           }         }       }     }     printf( %lld n , ans);   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   typename T::value_type arr_sum(const T& v, int n) {     typename T::value_type sum = 0;     for (int i = 0; i < n; ++i) sum += v[i];     return sum;   }   struct Sync_stdio {     Sync_stdio() {       cin.tie(NULL);       ios_base::sync_with_stdio(false);     }   } _sync_stdio;   int main() {     int n, m;     cin >> n >> m;     vector<int> left;     vector<int> right(n);     for (int i = 0; i < n; ++i) {       int t;       cin >> t;       left.push_back(t);     }     sort(left.begin(), left.end());     for (int i = 0, j = n / 2; i < n; ++i, j = (j + 1) % n) {       right[i] = left[j];     }     int res = 0;     for (int i = 0; i < n; ++i) {       if (left[i] == right[i]) {         ++res;       }     }     cout << n - res <<   n ;     for (int i = 0; i < n; ++i) {       cout << left[i] <<     << right[i] <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   long long mod = 1e9 + 7;   long long min(long long a, long long b) { return (a < b) ? a : b; }   long long max(long long a, long long b) { return (a > b) ? a : b; }   long long fp(long long a, long long b) {     if (b == 0) return 1;     long long x = fp(a, b / 2);     x = (x * x) % mod;     if (b & 1) x = (x * a) % mod;     return x;   }   const long long N = 2000;   long long bit[4 * N];   void update(long long id, long long l, long long r, long long point,               long long val) {     if (point < l || point > r) return;     if (l == r) {       bit[id] += val;       return;     }     long long mid = (l + r) / 2;     update(2 * id, l, mid, point, val);     update(2 * id + 1, mid + 1, r, point, val);     bit[id] = bit[2 * id] + bit[2 * id + 1];   }   long long get(long long id, long long l, long long r, long long point) {     if (point < l) {       return 0;     }     if (r <= point) {       return bit[id];     }     long long mid = (l + r) / 2;     return get(2 * id, l, mid, point) + get(2 * id + 1, mid + 1, r, point);   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long n;     cin >> n;     long long a[n + 1];     for (long long i = 1; i <= n; i++) {       cin >> a[i];     }     map<long long, vector<array<long long, 2>>> mp;     for (long long i = 1; i <= n; i++) {       long long sm = 0;       for (long long j = i; j <= n; j++) {         sm += a[j];         mp[sm].push_back({i, j});       }     }     vector<array<long long, 2>> ans;     for (auto i : mp) {       vector<array<long long, 2>> tmp;       sort(i.second.begin(), i.second.end());       for (long long j = 0; j < i.second.size(); j++) {         update(1, 1, n, i.second[j][1], 1);       }       long long st = 1;       for (long long j = 0; j < i.second.size(); j++) {         update(1, 1, n, i.second[j][1], -1);         if (i.second[j][0] < st) continue;         if (i.second[j][0] == i.second[j][1]) {           tmp.push_back(i.second[j]);           st = i.second[j][1] + 1;         } else {           long long x =               get(1, 1, n, i.second[j][1] - 1) - get(1, 1, n, i.second[j][0]);           if (x > 0) {             continue;           } else {             tmp.push_back(i.second[j]);             st = i.second[j][1] + 1;           }         }       }       if (tmp.size() > ans.size()) ans = tmp;     }     cout << ans.size() <<   n ;     for (auto i : ans) cout << i[0] <<     << i[1] <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     std::cout << std::setprecision(6) << std::fixed;     double tux;     cin >> tux;     double foo = 0, bar = 0, baz = 0, quz = 1;     for (; tux != 0.0; tux--) {       double pur;       cin >> pur;       foo = foo + pur;       bar = bar + 1;       if ((foo * quz) >= (bar * baz)) {         baz = foo;         quz = bar;       }     }     cout << (double)(baz / quz);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, a, d, t, v;   double tim[200000];   double jisuan(double a, double vmax, double s) {     double t = (vmax) / a;     if (0.5 * a * t * t > s)       return sqrt(s * 2 / a);     else       return t + (s - 0.5 * a * t * t) / vmax;   }   int main() {     scanf( %d%d%d , &n, &a, &d);     scanf( %d%d , &t, &v);     tim[1] = t + jisuan(a, v, d);     for (int i = 2; i <= n; ++i) {       scanf( %d%d , &t, &v);       tim[i] = t + jisuan(a, v, d);       if (tim[i] < tim[i - 1]) tim[i] = tim[i - 1];     }     for (int i = 1; i <= n; ++i) printf( %.10lf n , tim[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = (int)2e5 + 7;   vector<int> G[MAXN];   int pic[1007][1007], vis[MAXN], siz[MAXN];   unordered_map<int, int> mp;   int tot, val[MAXN];   int fa[MAXN], sz;   int findfa(int x) {     if (x == fa[x]) return x;     return fa[x] = findfa(fa[x]);   }   void unite(int x, int y, bool flag = 1) {     int u = findfa(x), v = findfa(y);     if (u == v) return;     fa[u] = v;     if (flag) siz[v] += siz[u];     sz++;   }   int main() {     int N, M;     scanf( %d %d , &N, &M);     for (int i = (int)1; i <= (int)N; i++) fa[i] = i, siz[i] = 1;     for (int i = (int)1; i <= (int)M; i++) {       int u, v;       scanf( %d %d , &u, &v);       G[u].push_back(v);       G[v].push_back(u);     }     int mn = 1e9, id = 0;     for (int i = (int)1; i <= (int)N; i++) {       if (G[i].size() < mn) {         mn = G[i].size();         id = i;       }     }     for (int v : G[id]) vis[v] = 1;     vis[id] = 1;     for (int i = (int)1; i <= (int)N; i++)       if (vis[i] == 0) unite(id, i);     for (int i = (int)1; i <= (int)N; i++) {       if (findfa(i) == i) {         mp[i] = ++tot;         val[tot] = i;       }     }     for (int u = (int)1; u <= (int)N; u++) {       for (int v : G[u]) {         int f1 = mp[findfa(u)];         int f2 = mp[findfa(v)];         if (f1 == f2) continue;         pic[f1][f2]++;       }     }     for (int i = (int)1; i <= (int)tot; i++) {       for (int j = (int)i + 1; j <= (int)tot; j++) {         if (1LL * siz[val[i]] * siz[val[j]] != pic[i][j]) {           unite(val[i], val[j], 0);         }       }     }     int ans = N - sz - 1;     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, k;     cin >> n >> k;     long long int i, a[n];     for (i = 0; i < n; i++) cin >> a[i];     sort(a, a + n);     if (a[0] == a[n - 1] && a[0] == 0) {       while (k--) cout << 0 << endl;     }     long long int b[n], ct = 0;     for (i = 0; i < n; i++) {       while (i < n && a[i] == a[i + 1]) i++;       b[ct++] = a[i];     }     i = 0;     long long int cnt = 0;     while (k--) {       while (b[i] == 0) i++;       if (i >= ct)         cout << 0 << endl;       else         cout << b[i] - cnt << endl;       cnt = b[i];       i++;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 55;   int r[N][N], c[N][N], s[N][N], f[N][N][N][N], n;   int sol(int x1, int y1, int x2, int y2) {     if (x1 <= 0 || x2 <= 0 || y1 <= 0 || y2 <= 0 || x1 > n || x2 > n || y1 > n ||         y2 > n || x1 > x2 || y1 > y2)       return 0;     if (f[x1][y1][x2][y2] >= 0) return f[x1][y1][x2][y2];     if (s[x2][y2] + s[x1 - 1][y1 - 1] - s[x2][y1 - 1] - s[x1 - 1][y2] ==         (y2 - y1 + 1) * (x2 - x1 + 1))       return f[x1][y1][x2][y2] = max(x2 - x1 + 1, y2 - y1 + 1);     if (s[x2][y2] + s[x1 - 1][y1 - 1] - s[x2][y1 - 1] - s[x1 - 1][y2] == 0)       return f[x1][y1][x2][y2] = 0;     int ans = max(x2 - x1 + 1, y2 - y1 + 1);     for (int i = x1; i <= x2; i++) {       if (r[i][y2] - r[i][y1 - 1] == 0)         ans = min(ans, sol(x1, y1, i - 1, y2) + sol(i + 1, y1, x2, y2));     }     for (int j = y1; j <= y2; j++) {       if (c[x2][j] - c[x1 - 1][j] == 0)         ans = min(ans, sol(x1, y1, x2, j - 1) + sol(x1, j + 1, x2, y2));     }     return f[x1][y1][x2][y2] = ans;   }   int main() {     cin >> n;     for (int i = (1); i <= (n); i++)       for (int j = (1); j <= (n); j++) {         char ch;         cin >> ch;         if (ch ==  # ) s[i][j] = 1;       }     for (int i = (1); i <= (n); i++)       for (int j = (1); j <= (n); j++) r[i][j] = r[i][j - 1] + s[i][j];     for (int i = (1); i <= (n); i++)       for (int j = (1); j <= (n); j++) c[i][j] = c[i - 1][j] + s[i][j];     for (int i = (1); i <= (n); i++)       for (int j = (1); j <= (n); j++)         s[i][j] += s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1];     memset(f, -63, sizeof(f));     cout << sol(1, 1, n, n) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   class C_ {};   template <typename T>   C_& operator<<(C_& __m, const T& __s) {     if (!1) cerr <<   E[91m  << __s <<   E[0m ;     return __m;   }   C_ merr;   struct __s {     __s() {       if (1) {         ios_base::Init i;         cin.sync_with_stdio(0);         cin.tie(0);       }     }     ~__s() {       merr <<  Execution time:   << (double)clock() / CLOCKS_PER_SEC <<   s. n ;     }   } __S;   char A[2222][2222];   bool u[2222][2222];   int n, m;   bool check(int x, int y) {     int i = x, j = y;     int cnt = 0;     if (!(0 <= x && x < n) || !(0 <= y && y < m) || A[x][y] !=  . ) return false;     cnt += (i == 0 || A[i - 1][j] !=  . );     cnt += (j == 0 || A[i][j - 1] !=  . );     cnt += (i == n - 1 || A[i + 1][j] !=  . );     cnt += (j == m - 1 || A[i][j + 1] !=  . );     return !u[i][j] && cnt == 3;   }   void add(queue<pair<int, int> >& Q, int x, int y) {     if (check(x, y)) {       Q.push(make_pair(x, y));       u[x][y] = 1;     }   }   int main() {     int left = 0;     queue<pair<int, int> > Q;     cin >> n >> m;     for (int i = 0; i < n; i++) {       string s;       cin >> s;       for (int j = 0; j < m; j++) {         A[i][j] = s[j];         if (A[i][j] ==  . ) {           left++;         }       }     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (A[i][j] !=  . ) continue;         add(Q, i, j);       }     }     while (Q.size()) {       int x = Q.front().first, y = Q.front().second;       Q.pop();       if (A[x][y] !=  . ) continue;       if (x != n - 1 && A[x + 1][y] ==  . ) {         A[x][y] =  ^ ;         A[x + 1][y] =  v ;         left -= 2;         add(Q, x - 1, y);         add(Q, x, y - 1);         add(Q, x, y + 1);         add(Q, x + 1, y - 1);         add(Q, x + 1, y + 1);         add(Q, x + 2, y);       } else if (x != 0 && A[x - 1][y] ==  . ) {         A[x - 1][y] =  ^ ;         A[x][y] =  v ;         left -= 2;         add(Q, x - 2, y);         add(Q, x, y - 1);         add(Q, x, y + 1);         add(Q, x - 1, y - 1);         add(Q, x - 1, y + 1);         add(Q, x + 1, y);       } else if (y != m - 1 && A[x][y + 1] ==  . ) {         A[x][y] =  < ;         A[x][y + 1] =  > ;         left -= 2;         add(Q, x, y - 1);         add(Q, x - 1, y);         add(Q, x - 1, y + 1);         add(Q, x + 1, y);         add(Q, x + 1, y + 1);         add(Q, x + 2, y);       } else if (y != 0 && A[x][y - 1] ==  . ) {         A[x][y - 1] =  < ;         A[x][y] =  > ;         left -= 2;         add(Q, x, y - 2);         add(Q, x - 1, y);         add(Q, x - 1, y - 1);         add(Q, x + 1, y);         add(Q, x + 1, y - 1);         add(Q, x + 2, y);       }       for (int dx = -3; dx <= 3; dx++) {         for (int dy = -3; dy <= 3; dy++) {           add(Q, x + dx, y + dy);         }       }     }     if (left != 0) {       cout <<  Not unique  <<   n ;       return 0;     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         cout << A[i][j];       }       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t;     cin >> t;     while (t--) {       int n, k;       cin >> n >> k;       int arr[n], brr[n];       for (int i = 0; i < n; i++) {         cin >> arr[i];       }       sort(arr, arr + n, greater<int>());       for (int j = 0; j < n; j++) {         cin >> brr[j];       }       sort(brr, brr + n, greater<int>());       int ans = 0;       int i = 0, j = 0;       int cnt = n;       while (cnt--) {         if (arr[i] >= brr[j])           ans += arr[i], i += 1;         else if (k > 0)           ans += brr[j], j += 1, k -= 1;         else           ans += arr[i], i += 1;       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int n, c0, c1, h;     cin >> n >> c0 >> c1 >> h;     string s;     cin >> s;     int ans = 0;     for (char ch : s) {       if (ch ==  0 ) {         ans += min(c0, c1 + h);       } else {         ans += min(c1, c0 + h);       }     }     cout << ans <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int tc = 1;     cin >> tc;     while (tc--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> AL[100005];   int main() {     int n;     scanf( %d , &n);     for (int i = 0; i < n - 1; i++) {       int u, v;       scanf( %d , &u);       scanf( %d , &v);       AL[u].push_back(v);       AL[v].push_back(u);     }     long long int l = 0;     int fl = 0;     for (int i = 1; i <= n; i++) {       if (AL[i].size() == 2) {         fl = 1;       }     }     if (fl == 0) {       printf( YES n );     } else {       printf( NO n );     }     return 0;   }
#include<bits/stdc++.h>   #define ll long long   #define ull unsigned long long      #define  in(ar,n) for(int i=0;i<n;i++)cin>>ar[i];   #define invec(ar,n)for(int i  =0 ; i<n;i++){int temp;cin>>temp;ar.push_back(temp);}   #define in2d(ar,n,m) for(int i=0;i<n;i++)for(int i=0;i<m;i++)cin>>ar[i]   #define out(ar,n)     for(int i=0;i<n;i++)     cout<<ar[i]<<   ;     cout<<endl;   #define swap(a,b)    int t = a;     a = b;     b = t;   #define print(val) cout<<val<<endl;   #define set(ar,n,val) for(int i=0;i<n;i++)ar[i]=val   #define for2d(n,m) for(int i=0;i<n;i++)for(int j=0;j<m;j++)   #define minar(ar,n,mn) for(int i=0;i<n;i++)mn =min(mn,ar[i])   #define maxar(ar,n,mx) for(int i=0;i<n;i++)mx =max(mx,ar[i])   #define fori(i,a,b) for(ll i=a;i<b;++i)   #define all(ar) ar.begin(),ar.end()   using namespace std;   typedef pair<ll,ll> pll;   typedef pair<int,int> pii;   typedef vector<vector<int>> vvi;   const ll mod = 1e9 + 7;      int main(){       int t;cin>>t;       while(t--){          int n;cin>>n;          string s;cin>>s;          vector<int> ar,ans;          fori(i,0,n){              ar.push_back(s[i]- 0 );             }           ans.push_back(1);          int c = ar[0]+1;             fori(i,1,n){              if(c==2){                  if(ar[i]==1){                      ans.push_back(0);                      c = 1;                  }                  else {                      ans.push_back(1);                      c = 1;                  }              }              else if(c==1){                  if(ar[i]==1){                      ans.push_back(1);                       c = 2;                  }                  else {ans.push_back(0);c = 0;}              }              else {                  if(ar[i]==0){                      ans.push_back(1);                      c = 1;                  }                  else {                      ans.push_back(1);                      c = 2;                  }              }          }          fori(i,0,n){              cout<<ans[i];          }          cout<<endl;       }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, d, h, i, p, q, s;     cin >> n >> d >> h;     if (d > (2 * h)) {       cout <<  -1 ;     } else if ((d == 1) && (h == 1)) {       if (n == 2) {         cout <<  1 2 ;       } else {         cout <<  -1 ;       }     } else if ((d == h)) {       for (i = 1; i <= h - 1; i++) {         cout << i <<     << i + 1 << endl;       }       p = h + 2;       for (i = h + 1; i <= n; i++) {         cout << h <<     << i << endl;       }     } else {       if (d > h) {         for (i = 1; i <= h; i++) {           cout << i <<     << i + 1 << endl;         }         cout <<  1   << h + 2 << endl;         for (i = (h + 2); i <= d; i++) {           cout << i <<     << i + 1 << endl;         }         for (i = (d + 2); i <= n; i++) {           cout <<  1   << i << endl;         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 25;   const int mo = 1000000007;   const int inf = (int)1e9;   inline int IN() {     char ch;     (ch = getchar());     int f = 0, x = 0;     for (; ((ch) ==   n  || (ch) ==   r  || (ch) ==   t  || (ch) ==    );          (ch = getchar()))       ;     if (ch ==  - ) f = 1, (ch = getchar());     for (; !((ch) ==   n  || (ch) ==   r  || (ch) ==   t  || (ch) ==    );          (ch = getchar()))       x = x * 10 + ch -  0 ;     return (f) ? (-x) : (x);   }   int Pow(int x, int y, int p) {     int A = 1;     for (; y; y >>= 1, x = (long long)x * x % p)       if (y & 1) A = (long long)A * x % p;     return A;   }   int n, m, laba[N], labb[N], visa[N], visb[N], tim, mat[N], ans;   int w[N][N], a[N][N], b[N][N], c[N][N], tot_done;   bool extend(int x) {     if (!x) return 1;     visa[x] = tim;     for (int i = (int)1; i <= (int)n; i++) {       if (visb[i] != tim && laba[x] + labb[i] == w[x][i]) {         visb[i] = tim;         if (extend(mat[i])) {           mat[i] = x;           return 1;         }       }     }     return 0;   }   void change() {     int delta = inf;     for (int i = (int)1; i <= (int)n; i++)       if (visa[i] == tim)         for (int j = (int)1; j <= (int)n; j++)           if (visb[j] != tim) {             delta = min(delta, laba[i] + labb[j] - w[i][j]);           }     for (int i = (int)1; i <= (int)n; i++)       if (visa[i] == tim) laba[i] -= delta;     for (int i = (int)1; i <= (int)n; i++)       if (visb[i] == tim) labb[i] += delta;   }   int KM() {     for (int i = (int)1; i <= (int)n; i++) visa[i] = visb[i] = mat[i] = 0;     for (int i = (int)1; i <= (int)n; i++) laba[i] = w[i][0], labb[i] = 0;     tim = 0;     for (int i = (int)1; i <= (int)n; i++) {       for (;;) {         ++tim;         if (extend(i)) break;         change();       }     }     int re = 0;     for (int i = (int)1; i <= (int)n; i++) re += w[mat[i]][i];     return re;   }   void dfs(int x, int cnt) {     int now = KM();     if (now <= ans) return;     if (x == n) {       ans = now;       return;     }     ++tot_done;     if (tot_done >= 1e5) return;     ++x;     if (m - cnt < n - x + 1) {       for (int i = (int)0; i <= (int)n; i++) w[x][i] = a[x][i];       dfs(x, cnt);     }     if (cnt < m) {       for (int i = (int)0; i <= (int)n; i++) w[x][i] = b[x][i];       dfs(x, cnt + 1);     }     for (int i = (int)0; i <= (int)n; i++) w[x][i] = c[x][i];   }   int main() {     scanf( %d , &n);     m = n >> 1;     for (int i = (int)1; i <= (int)n; i++)       for (int j = (int)1; j <= (int)n; j++) {         a[i][j] = IN();         a[i][0] = max(a[i][0], a[i][j]);       }     for (int i = (int)1; i <= (int)n; i++)       for (int j = (int)1; j <= (int)n; j++) {         b[i][j] = IN();         b[i][0] = max(b[i][0], b[i][j]);       }     for (int i = (int)1; i <= (int)n; i++)       for (int j = (int)1; j <= (int)n; j++) {         w[i][j] = c[i][j] = max(a[i][j], b[i][j]);         w[i][0] = c[i][0] = max(w[i][0], c[i][j]);       }     dfs(0, 0);     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 2e3 + 10, big = 1e18, mod = 1e9 + 7;   vector<long long> a[N], now, ans;   long long n, x, y, m, maxi;   bool vis[N], mp[N][N];   void dfs(long long i) {     vis[i] = 1, now.push_back(i);     for (int j = 0; j < a[i].size(); j++)       if (!vis[a[i][j]]) dfs(a[i][j]);   }   int main() {     cin >> n;     cin >> m;     while (m--) {       cin >> x >> y;       a[x].push_back(y);       a[y].push_back(x);     }     cin >> m;     while (m--) {       cin >> x >> y;       mp[x][y] = mp[y][x] = 1;     }     for (int i = 1; i <= n; i++)       if (!vis[i]) {         now.clear();         dfs(i);         bool check = 1;         if (now.size() == 1)           maxi = max(1LL, maxi);         else {           for (int j = 0; j < now.size() - 1; j++)             for (int k = j + 1; k < now.size(); k++)               if (mp[now[j]][now[k]]) check = 0;           if (check) maxi = max((long long)now.size(), maxi);         }       }     cout << maxi;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> V;   void initSet(int _size) {     V.resize(_size);     for (int i = int(0); i <= int(_size - 1); i++) V[i] = i;   }   int findSet(int i) { return (V[i] == i) ? i : (V[i] = findSet(V[i])); }   void unionSet(int i, int j) { V[findSet(i)] = findSet(j); }   bool isSameSet(int i, int j) { return findSet(i) == findSet(j); }   long long a, b, s, N, M, A, B, r[123450];   int find(int node) {     if (r[node]) return r[node] = find(r[node]);     return node;   }   int main() {     int N = 0;     cin >> N >> M;     s = 1;     for (int i = 1; i <= M; ++i) {       cin >> a >> b;       A = find(a);       B = find(b);       if (A == B) {         s = s * 2 % 1000000009;       } else {         r[B] = A;       }       if (s > 0)         cout << s - 1 << endl;       else         cout << 1000000009 - 1 << endl;     }     return 0;   }