malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 2 * 200000;   const int MAXM = 199999 * 2 * 2 + 200000 * 2;   int n, m, a, b;   string s[2];   int dsu[MAXN];   int to[MAXM], head[MAXN], nxt[MAXM], E;   int p[MAXN][19];   int d[MAXN];   int tin[MAXN], tout[MAXN], timer;   inline int root(int x) { return ~dsu[x] ? dsu[x] = root(dsu[x]) : x; }   inline void merge(int a, int b) { dsu[root(a)] = root(b); }   inline void addEdge(int a, int b) {     to[E] = b;     nxt[E] = head[a];     head[a] = E++;     to[E] = a;     nxt[E] = head[b];     head[b] = E++;     merge(a, b);   }   void dfs(int v, int par, int dist = 0) {     tin[v] = ++timer;     p[v][0] = par;     d[v] = dist;     for (int i = 1; i < 19; ++i) p[v][i] = p[p[v][i - 1]][i - 1];     for (int i = head[v]; ~i; i = nxt[i]) {       if (to[i] != par) {         dfs(to[i], v, dist + 1);       }     }     tout[v] = ++timer;   }   bool ancestor(int a, int b) { return tin[a] <= tin[b] && tout[a] >= tout[b]; }   int lca(int a, int b) {     if (ancestor(a, b)) return a;     if (ancestor(b, a)) return b;     for (int i = 18; i > -1; --i)       if (!ancestor(p[a][i], b)) a = p[a][i];     return p[a][0];   }   int Distance(int a, int b) {     int c = lca(a, b);     return d[a] + d[b] - 2 * d[c];   }   int dist(int a, int b) {     if (root(a) != root(b)) return -1;     int d1, d2;     d1 = Distance(a, b);     if (b < n)       d2 = Distance(a, b + n);     else       d2 = Distance(a, b - n);     return min(d1, d2 + 1);   }   int main() {     ios_base::sync_with_stdio(false);     memset(dsu, 0xff, sizeof dsu);     memset(head, 0xff, sizeof head);     cin >> n >> m;     cin >> s[0] >> s[1];     for (int i = 0; i < n; ++i) {       if (s[0][i] ==  . ) {         if (s[1][i] ==  .  &&             (i + 1 == n || max(s[0][i + 1], s[1][i + 1]) ==  X ))           addEdge(i, n + i);         if (i + 1 != n && s[0][i + 1] ==  . ) addEdge(i, i + 1);       }       if (s[1][i] ==  .  && i + 1 != n && s[1][i + 1] ==  . )         addEdge(n + i, n + i + 1);     }     for (int i = 0; i < 2 * n; ++i)       if (root(i) == i) dfs(i, i);     while (m-- > 0) {       cin >> a >> b;       --a, --b;       if (a % n > b % n) swap(a, b);       cout << dist(a, b) <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline void Read(T &x) {     char c = getchar();     bool f = false;     for (x = 0; !isdigit(c); c = getchar()) {       if (c ==  - ) {         f = true;       }     }     for (; isdigit(c); c = getchar()) {       x = x * 10 + c -  0 ;     }     if (f) {       x = -x;     }   }   template <typename T>   inline bool CheckMax(T &a, const T &b) {     return a < b ? a = b, true : false;   }   template <typename T>   inline bool CheckMin(T &a, const T &b) {     return a > b ? a = b, true : false;   }   const int N = 205;   unsigned int ans, mod, c[N][N], f[N][N], s[N][N];   int n, m;   int main() {     Read(n), Read(m), Read(mod);     for (int i = 0; i <= n; ++i) {       c[i][0] = 1;       for (int j = 1; j <= i; ++j) {         c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;       }     }     f[1][0] = 1;     for (int i = 0; i <= m; ++i) {       s[1][i] = 1;     }     for (int i = 2; i <= n; ++i) {       for (int j = 1; j < i; ++j) {         for (int k = 0; k < m; ++k) {           f[i][k + 1] = (1LL * s[j][m - 1] * c[i - 2][j - 1] % mod * f[i - j][k] +                          f[i][k + 1]) %                         mod;         }       }       for (int j = 1; j <= m; ++j) {         s[i][j] = (s[i][j - 1] + f[i][j]) % mod;       }     }     for (int i = 0; i < n; ++i) {       for (int j = 0; j <= m; ++j) {         for (int k = 0; j + k <= m; ++k) {           if (k != 1) {             ans = (1LL * f[i + 1][j] * f[n - i][k] + ans) % mod;           }         }       }     }     ans = 2LL * n * (n - 1) * ans % mod;     printf( %u n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int g[5][5] = {0}, tes;     for (int x = 1; x < 4; x++)       for (int y = 1; y < 4; y++) {         cin >> tes;         if (tes % 2 == 0)           continue;         else {           g[x][y + 1]++;           g[x][y - 1]++;           g[x + 1][y]++;           g[x - 1][y]++;           g[x][y]++;         }       }     for (int x = 1; x < 4; x++) {       for (int y = 1; y < 4; y++) {         cout << ((g[x][y] + 1) % 2);       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int const xn = 1e4 + 105, xm = 105;   int n, m, cnt, hd[xn], ct, to[xn], nxt[xn], w[xn], s1, s2, f;   long long dis[2][xn], inf = 1e17;   bool vis[xn];   struct E {     int u, v, bh, l, r, w;   } ed[xm];   struct N {     long long d;     int id;     N(long long d = 0, int i = 0) : d(d), id(i) {}     bool operator<(const N &y) const { return d > y.d; }   };   priority_queue<N> q;   int rd() {     int ret = 0, f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = 0;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) ret = ret * 10 + ch -  0 , ch = getchar();     return f ? ret : -ret;   }   void add(int x, int y, int z) {     to[++ct] = y;     nxt[ct] = hd[x];     hd[x] = ct;     w[ct] = z;   }   void dij(int t) {     for (int i = 1; i <= n; i++) dis[t][i] = inf;     for (int i = 1; i <= n; i++) vis[i] = 0;     int st = (t ? s2 : s1);     dis[t][st] = 0;     q.push(N(0, st));     while (q.size()) {       int x = q.top().id;       q.pop();       if (vis[x]) continue;       vis[x] = 1;       for (int i = hd[x], u; i; i = nxt[i])         if (dis[t][u = to[i]] > dis[t][x] + w[i]) {           dis[t][u] = dis[t][x] + w[i];           q.push(N(dis[t][u], u));         }     }   }   int main() {     n = rd();     m = rd();     cnt = rd();     s1 = rd();     s2 = rd();     f = rd();     for (int i = 1, x, y, z; i <= m; i++)       x = rd(), y = rd(), z = rd(), add(x, y, z);     for (int i = 1; i <= cnt; i++)       ed[i].u = rd(), ed[i].v = rd(), ed[i].l = rd(), ed[i].r = rd(),       ed[i].bh = ct + 1, ed[i].w = 1, add(ed[i].u, ed[i].v, ed[i].r);     dij(0);     dij(1);     while (dis[0][f] >= dis[1][f]) {       int i;       for (i = 1; i <= cnt; i++)         if (dis[0][ed[i].u] <= dis[1][ed[i].u] && ed[i].w) break;       if (i > cnt) {         if (dis[0][f] > dis[1][f])           puts( LOSE );         else {           puts( DRAW );           for (int j = 1; j <= cnt; j++)             printf( %d  , ed[j].w ? ed[j].r : ed[j].l);           puts(  );         }         return 0;       }       ed[i].w = 0;       w[ed[i].bh] = ed[i].l;       dij(0);       dij(1);     }     puts( WIN );     for (int j = 1; j <= cnt; j++) printf( %d  , ed[j].w ? ed[j].r : ed[j].l);     puts(  );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct edg {     int cost, id, parity;     bool operator<(edg other) const { return cost > other.cost; }   };   vector<int> g[1000011 >> 1][2];   int from[1000011], to[1000011], l[1000011], r[1000011];   int N, M;   bool cmp(int &a, int &b) { return l[a] > l[b]; }   int main() {     int i;     priority_queue<edg, vector<edg>, less<edg>> q;     scanf( %d%d , &N, &M);     if (N == 1) {       printf( 0 n );       return 0;     }     for (i = 1; i <= M; ++i) {       scanf( %d%d%d%d , &from[i * 2], &to[i * 2], &l[i * 2], &r[i * 2]);       r[i * 2]--;       from[i * 2 + 1] = to[i * 2];       to[i * 2 + 1] = from[i * 2];       l[i * 2 + 1] = l[i * 2];       r[i * 2 + 1] = r[i * 2];       g[from[i * 2]][0].push_back(i * 2);       g[from[i * 2]][1].push_back(i * 2);       g[to[i * 2]][0].push_back(i * 2 + 1);       g[to[i * 2]][1].push_back(i * 2 + 1);     }     for (i = 1; i <= N; ++i) {       sort(g[i][0].begin(), g[i][0].end(), cmp);       sort(g[i][1].begin(), g[i][1].end(), cmp);     }     while (!g[1][0].empty() && l[g[1][0].back()] == 0) {       edg e = {0, g[1][0].back(), 0};       q.push(e);       g[1][0].pop_back();     }     while (!q.empty()) {       edg curr = q.top();       q.pop();       if (to[curr.id] == N) {         printf( %d n , curr.cost + 1);         return 0;       }       int mxright = r[curr.id] - ((r[curr.id] % 2) != curr.parity);       while (!g[to[curr.id]][curr.parity ^ 1].empty() &&              l[g[to[curr.id]][curr.parity ^ 1].back()] <= mxright + 1) {         int nxtid = g[to[curr.id]][curr.parity ^ 1].back();         int ncost = l[nxtid];         ncost += (ncost % 2 == curr.parity);         ncost = max(ncost, curr.cost + 1);         if (ncost <= r[nxtid]) {           q.push(edg{ncost, nxtid, curr.parity ^ 1});         }         g[to[curr.id]][curr.parity ^ 1].pop_back();       }     }     printf( -1 n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     long long n, a, b, t;     string str;     cin >> n >> a >> b >> t >> str;     str += str;     long long len = 1, l = n, r, remain = t - 1 - (str[n] ==  w ) * b, ans = 1;     if (remain < 0) {       cout <<  0 n ;       return 0;     }     while (len < n) {       long long require = 2 * a + 1 + (str[l - 1] ==  w ) * b;       if (remain < require) {         break;       } else {         l--;         len++;         remain -= require;       }     }     for (r = n + 1; r < str.size(); r++) {       remain -= a + 1 + (str[r] ==  w ) * b;       while (r - l + 1 > n || (l < n && remain < 0)) {         remain += 2 * a + 1 + (str[l] ==  w ) * b;         l++;       }       if (l >= n && remain < 0) break;       ans = max(ans, r - l + 1);     }     len = 1, l = r = n, remain = t - 1 - (str[n] ==  w ) * b;     while (len < n) {       long long require = 2 * a + 1 + (str[r + 1] ==  w ) * b;       if (remain < require) {         break;       } else {         r++;         len++;         remain -= require;       }     }     for (l = n - 1; l > 0; l--) {       remain -= a + 1 + (str[l] ==  w ) * b;       while (r - l + 1 > n || (r > n && remain < 0)) {         remain += 2 * a + 1 + (str[r] ==  w ) * b;         r--;       }       if (r <= n && remain < 0) break;       ans = max(ans, r - l + 1);     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = (int)1e9 + 7;   const int INF = (int)1e9;   const long long LINF = (long long)1e18;   const long double PI = 2 * acos((long double)0);   long long gcd(long long a, long long b) {     long long r;     while (b) {       r = a % b;       a = b;       b = r;     }     return a;   }   long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }   long long fpow(long long n, long long k, int p = MOD) {     long long r = 1;     for (; k; k >>= 1) {       if (k & 1) r = r * n % p;       n = n * n % p;     }     return r;   }   template <class T>   void setmin(T& a, T val) {     if (a > val) a = val;   }   template <class T>   void setmax(T& a, T val) {     if (a < val) a = val;   }   void addmod(int& a, int val, int p = MOD) {     if ((a = (a + val)) >= p) a -= p;   }   void submod(int& a, int val, int p = MOD) {     if ((a = (a - val)) < 0) a += p;   }   int mult(int a, int b, int p = MOD) { return (long long)a * b % p; }   int inv(int a, int p = MOD) { return fpow(a, p - 2, p); }   const int maxn = 200010;   long long n, d, m;   long long x[maxn];   long long p[maxn];   long long st[4 * maxn];   void build(int node, int L, int R) {     if (L == R) {       st[node] = p[L];       return;     }     build(node << 1, L, (L + R) >> 1);     build((node << 1) + 1, ((L + R) >> 1) + 1, R);     st[node] = min(st[node << 1], st[(node << 1) + 1]);   }   long long query(int node, int l, int r, int L, int R) {     if (l > R || r < L) return LINF;     if (l <= L && r >= R) return st[node];     return min(query(node << 1, l, r, L, (L + R) >> 1),                query((node << 1) + 1, l, r, ((L + R) >> 1) + 1, R));   }   void solve() {     cin >> d >> n >> m;     vector<pair<int, int> > v;     for (int i = (1); i < (m + 1); i++) {       cin >> x[i] >> p[i];       v.push_back(make_pair(x[i], p[i]));     }     sort((v).begin(), (v).end());     for (int i = (1); i < (m + 1); i++) {       x[i] = v[i - 1].first;       p[i] = v[i - 1].second;     }     x[m + 1] = d;     build(1, 0, m + 1);     int cur = 0;     long long ans = 0, r = 0;     while (cur < m + 1) {       if (x[cur] + n < x[cur + 1]) {         cout << -1;         return;       }       int lo = cur + 1, hi = upper_bound(x, x + m + 2, x[cur] + n) - x - 1;       while (lo < hi) {         int mid = (lo + hi) >> 1;         if (query(1, cur + 1, mid, 0, m + 1) > p[cur])           lo = mid + 1;         else           hi = mid;       }       if (query(1, cur + 1, lo, 0, m + 1) <= p[cur]) {         ans += p[cur] * max(0LL, x[lo] - x[cur] - r);         r = max(0LL, x[cur] + r - x[lo]);         cur = lo;       } else {         ans += (n - r) * p[cur];         r = x[cur] + n - x[cur + 1];         cur++;       }     }     cout << ans;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int gcd(int a, int b) {     if (a == 0) return b;     if (b == 0) return a;     if (a == b) return a;     if (a > b) return gcd(a - b, b);     return gcd(a, b - a);   }   int main() {     long long int n, m;     cin >> n >> m;     long long int a[n + 1], b[m + 1];     for (long long int i = 0; i < n + 1; i++) {       cin >> a[i];     }     for (long long int i = 0; i < m + 1; i++) {       cin >> b[i];     }     if (m > n)       cout <<  0/1 ;     else if (n > m) {       int sign = 1;       if ((a[0] < 0 && b[0] > 0) || (a[0] > 0 && b[0] < 0)) sign = 0;       if (sign == 0)         cout <<  -Infinity ;       else         cout <<  Infinity ;     } else {       int sign = 1;       if ((a[0] < 0 && b[0] > 0) || (a[0] > 0 && b[0] < 0)) sign = 0;       int g = gcd(a[0], b[0]);       a[0] /= g;       b[0] /= g;       if (sign == 1) {         if (a[0] < 0) a[0] = -a[0];         if (b[0] < 0) b[0] = -b[0];         cout << a[0] <<  /  << b[0];       } else {         if (a[0] < 0) a[0] = -a[0];         if (b[0] < 0) b[0] = -b[0];         cout <<  -  << a[0] <<  /  << b[0];       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct heap {     int v, x;   } h[1000010];   int n, m, a[500010];   int tmp, sz, ans, tot;   int v[500010], cnt;   int nxt[500010], pre[500010], pos[500010];   inline int read() {     char ch = getchar();     int f = 1, x = 0;     while (!(ch >=  0  && ch <=  9 )) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = x * 10 + (ch -  0 );       ch = getchar();     }     return x * f;   }   void pushup(int x) {     while (h[x].v < h[x >> 1].v) {       pos[h[x >> 1].x] = x;       swap(h[x], h[x >> 1]);       x = x >> 1;     }     pos[h[x].x] = x;   }   void push(int v, int x) {     sz++;     h[sz].v = v;     h[sz].x = x;     pos[x] = sz;     pushup(sz);   }   void pushdown(int x) {     int to;     while ((x << 1) <= sz) {       to = (x << 1);       if (to < sz && h[to].v > h[to + 1].v) to++;       if (h[x].v > h[to].v) {         pos[h[to].x] = x;         swap(h[to], h[x]);         x = to;       } else         break;     }     pos[h[x].x] = x;   }   void del(int x) {     h[x].v = 0x7fffffff;     pushdown(x);   }   void init() {     m = read();     n = read();     for (int i = 1; i <= n; i++) a[i] = read();     sort(a + 1, a + n + 1);     for (int i = 2; i <= n; i++) {       push(a[i] - a[i - 1], i);       pre[i] = i - 1;       nxt[i] = i + 1;     }     pre[2] = nxt[n] = -1;   }   void solve() {     int a, b;     heap k;     for (int i = 1; i <= m; i++) {       k = h[1];       if (pre[k.x] == -1) {         ans += k.v;         del(1);         del(pos[nxt[k.x]]);         pre[nxt[nxt[k.x]]] = -1;       } else if (nxt[k.x] == -1) {         ans += k.v;         del(1);         del(pos[pre[k.x]]);         nxt[pre[pre[k.x]]] = -1;       } else {         ans += k.v;         a = nxt[k.x];         b = pre[k.x];         pre[k.x] = pre[b];         nxt[pre[b]] = k.x;         nxt[k.x] = nxt[a];         pre[nxt[a]] = k.x;         h[1].v = h[pos[a]].v + h[pos[b]].v - h[1].v;         pushdown(1);         del(pos[a]);         del(pos[b]);       }     }     printf( %d n , ans);   }   int main() {     init();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7, N = 2e5 + 5;   int par[N], over[N];   int getpar(int u) {     if (par[par[u]] == par[u]) return par[u];     return par[u] = getpar(par[u]);   }   bool unite(int a, int b) {     a = getpar(a);     b = getpar(b);     if (a == b) {       if (over[a]) return false;       over[a] += 1;       return true;     } else {       if (over[a] && over[b]) {         return false;       }       par[a] = b;       over[b] += over[a];       return true;     }     assert(false);   }   struct Edge {     int a, b, c;     bool operator<(const Edge &t) const { return c > t.c; }   };   int main() {     iota(par, par + N, 0);     int n, m;     cin >> n >> m;     vector<Edge> edges(m);     for (int i = 0; i < m; ++i)       scanf( %d %d %d , &edges[i].a, &edges[i].b, &edges[i].c);     sort(edges.begin(), edges.end());     int ans = 0;     for (auto cur : edges)       if (unite(cur.a, cur.b)) ans += cur.c;     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   class Solution {     int max_free;     vector<bool> visited;     vector<int> parent;     vector<set<int>> children;     void dfs(int i) {       visited[i] = true;       for (int j : children[i]) {         if (!visited[j]) {           if (i != 0) cout << i <<     << j << endl;           dfs(j);         }       }     }       public:     void solve() {       int n;       cin >> n;       vector<int> a(n);       for (int i = 1; i < n; ++i) scanf( %d , &a[i]);       children = vector<set<int>>(n + 1);       parent = vector<int>(n + 1, -1);       children[0].insert(n);       parent[n] = 0;       max_free = n;       for (int i = 1; i < n; ++i) {         if (parent[a[i]] == -1) {           if (!children[a[i]].empty()) {             max_free--;             while (!children[max_free].empty()) max_free--;           }           if (parent[max_free] != -1) {             int p = parent[max_free];             children[p].erase(max_free);             children[p].insert(a[i]);           }         } else {           max_free--;           while (!children[max_free].empty()) max_free--;         }         children[a[i]].insert(max_free);         parent[max_free] = a[i];       }       cout << a[1] << endl;       visited = vector<bool>(n + 1);       dfs(0);     }   };   int main() {     Solution solution = Solution();     solution.solve();   }
#include <bits/stdc++.h>   using namespace std;   int n, m, ha1[50][50], ha2[50][50], ans1[50][50], ans2[50][50], x = 0, flag = 0;   int main() {     memset(ha1, 0, sizeof(ha1));     memset(ha2, 0, sizeof(ha2));     memset(ans1, 0, sizeof(ans1));     memset(ans2, 0, sizeof(ans2));     cin >> n >> m;     for (int i = 1, xx, yy; i <= n; ++i) {       cin >> xx >> yy;       ha1[xx][yy] = 1;       ha1[yy][xx] = 1;     }     for (int i = 1, xx, yy; i <= m; ++i) {       cin >> xx >> yy;       ha2[xx][yy] = 1;       ha2[yy][xx] = 1;     }     for (int i = 1; i <= 9; ++i)       for (int j = 1; j <= 9; ++j) {         if (i == j) continue;         for (int k = 1; k <= 9; ++k) {           if (k == i || k == j) continue;           if (ha1[i][j] == ha2[i][k] && ha1[i][j]) {             ++ans1[i][j];             ++ans2[i][k];             x = i;           }         }       }     for (int i = 1; i <= 9; ++i)       for (int j = 1; j <= 9; ++j)         if (ans1[i][j]) {           flag++;           break;         }     if (flag == 1) {       cout << x << endl;       return 0;     }     x = 0;     for (int i = 1; i <= 9; ++i)       for (int j = 1; j <= 9; ++j) {         if (i == j) continue;         if ((ans1[i][j] && ans1[j][i]) || (ans2[i][j] && ans2[j][i])) x = -1;       }     cout << x << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int parent[100000], Size[100000];   void init(int n) {     for (int i = 0; i < n; i++) {       parent[i] = i;       Size[i] = 1;     }   }   int Find(int u) {     if (u != parent[u]) parent[u] = Find(parent[u]);     return parent[u];   }   void Union(int u, int v) {     u = Find(u);     v = Find(v);     if (u != v) {       if (Size[u] < Size[v]) swap(u, v);       parent[v] = u;       Size[u] += Size[v];     }   }   int qa[100000], qb[100000], big[100000], table[450][100000] = {};   bool visited[100000] = {}, match[100000] = {};   vector<int> bigVertices, temp[100000], appear[100000];   vector<vector<int>> comp;   vector<pair<int, int>> edges[100000];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n, m;     cin >> n >> m;     for (int i = 0; i < m; i++) {       int a, b, c;       cin >> a >> b >> c;       a--, b--, c--;       edges[c].emplace_back(a, b);     }     int q;     cin >> q;     for (int i = 0; i < q; i++) {       cin >> qa[i] >> qb[i];       qa[i]--, qb[i]--;     }     init(n);     for (int c = 0; c < m; c++) {       for (auto e : edges[c]) Union(e.first, e.second);       for (auto e : edges[c]) {         if (!visited[e.first]) {           temp[Find(e.first)].push_back(e.first);           visited[e.first] = true;         }         if (!visited[e.second]) {           temp[Find(e.second)].push_back(e.second);           visited[e.second] = true;         }       }       for (auto e : edges[c]) {         if (!temp[e.first].empty()) {           comp.push_back(temp[e.first]);           temp[e.first].clear();         }         if (!temp[e.second].empty()) {           comp.push_back(temp[e.second]);           temp[e.second].clear();         }         visited[e.first] = visited[e.second] = false;         parent[e.first] = e.first, parent[e.second] = e.second;         Size[e.first] = Size[e.second] = 1;       }     }     for (int i = 0; i < comp.size(); i++)       for (int j = 0; j < comp[i].size(); j++) appear[comp[i][j]].push_back(i);     for (int i = 0; i < n; i++) {       if (appear[i].size() > 450) {         big[i] = bigVertices.size();         bigVertices.push_back(i);       } else         big[i] = -1;     }     for (int i = 0; i < bigVertices.size(); i++)       for (int c : appear[bigVertices[i]])         for (int j : comp[c]) table[i][j]++;     for (int i = 0; i < q; i++) {       int a = qa[i], b = qb[i];       if (big[a] == -1) swap(a, b);       if (big[a] != -1)         cout << table[big[a]][b] <<   n ;       else {         int ret = 0;         for (int c : appear[a]) match[c] = true;         for (int c : appear[b]) ret += match[c];         for (int c : appear[a]) match[c] = false;         cout << ret <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ld = long double;   const ll OO = 1e18, oo = 1e12 + 21;   int di[8] = {0, 0, 1, -1, -1, 1, -1, 1};   int dj[8] = {1, -1, 0, 0, 1, 1, -1, -1};   string ys =  YES , no =  NO ;   const long double dgr = acos(-1) / 180, rad = 180 / acos(-1);   const ll mod = 1e9 + 7, N = 1e6 + 5, M = 5005;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     vector<ll> v(3);     cin >> v[0] >> v[1] >> v[2];     do {       if ((v[0] % 3) == 2 && (v[1] % 3) == 2 && (v[2] % 3) == 0 && v[2] > 1) {         return cout << 2 + v[0] / 3 + v[1] / 3 + (v[2] - 2) / 3 <<   n , 0;       }     } while (next_permutation(v.begin(), v.end()));     do {       if ((v[0] % 3) == 2 && (v[1] % 3) == 2 && (v[2] % 3) == 2) {         return cout << 2 + v[0] / 3 + v[1] / 3 + v[2] / 3 <<   n , 0;       }     } while (next_permutation(v.begin(), v.end()));     do {       if ((v[0] % 3) == 2 && (v[1] % 3) == 2 && v[2] > 1) {         return cout << 2 + v[0] / 3 + v[1] / 3 + (v[2] - 2) / 3 <<   n , 0;       }     } while (next_permutation(v.begin(), v.end()));     cout << v[0] / 3 + v[1] / 3 + v[2] / 3 + min({v[0] % 3, v[1] % 3, v[2] % 3})          <<   n ;   }