malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   using vi = vector<int>;   using ii = pair<int, int>;   using ld = long double;   const int N = 5e5;   bool flip[N], still[N];   int par[N], asdjashsgggg[N], x[N];   int find(int v, bool& b) {     b = flip[v];     while (par[v] != v) {       v = par[v];       b ^= flip[v];     }     return v;   }   tuple<int, int, bool, bool> merge(int u, int v) {     bool bu, bv;     u = find(u, bu);     v = find(v, bv);     if (u == v) {       if (bu == bv)         throw true;       else         throw false;     } else {       int from = u, to = v;       bool flipped = bu == bv, delta = 0;       if (asdjashsgggg[u] == asdjashsgggg[v])         delta = 1;       else if (asdjashsgggg[to] < asdjashsgggg[from])         swap(from, to);       par[from] = to;       flip[from] ^= flipped;       asdjashsgggg[to] += delta;       return {from, to, flipped, delta};     }   }   int main() {     cin.tie(nullptr);     ios_base::sync_with_stdio(false);     int n, m, k;     cin >> n >> m >> k;     for (int i = 0; i < n; i++) {       cin >> x[i];       x[i]--;     }     iota(par, par + n, 0);     fill(still, still + k, true);     vector<ii> e;     while (m--) {       int u, v;       cin >> u >> v;       u--, v--;       if (x[u] == x[v] && still[x[u]]) {         try {           merge(u, v);         } catch (bool oc) {           if (oc) still[x[u]] = false;         }       }       e.emplace_back(u, v);     }     int cnt = accumulate(still, still + k, 0);     sort(e.begin(), e.end(), [&](ii a, ii b) {       a = minmax(x[a.first], x[a.second]);       b = minmax(x[b.first], x[b.second]);       return a < b;     });     ii pre = {-1, -1};     stack<tuple<int, int, bool, bool>> s;     bool bad = false;     long long ans = (long long)cnt * (cnt - 1) >> 1;     for (auto [u, v] : e) {       ii cur = minmax(x[u], x[v]);       if (cur.first == cur.second || !still[cur.first] || !still[cur.second])         continue;       if (pre < cur) {         while (!s.empty()) {           auto [from, to, flipped, delta] = s.top();           s.pop();           par[from] = from;           flip[from] ^= flipped;           asdjashsgggg[to] -= delta;         }         pre = cur;         ans -= bad;         bad = false;       }       if (bad) continue;       try {         s.push(merge(u, v));       } catch (bool oc) {         if (oc) bad = true;       }     }     ans -= bad;     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int dfn[200002], low[200002], tot, head[200002], num, f[200002];   int p[20][200002];   int deep[200002], n, m, q, st[200002], top, dep[200002];   bool vis[200002];   inline long long rd() {     long long x = 0;     char c = getchar();     bool f = 0;     while (!isdigit(c)) {       if (c ==  - ) f = 1;       c = getchar();     }     while (isdigit(c)) {       x = (x << 1) + (x << 3) + (c ^ 48);       c = getchar();     }     return f ? -x : x;   }   struct edge {     int n, to;   } e[200002];   inline void add(int u, int v) {     e[++tot].n = head[u];     e[tot].to = v;     head[u] = tot;   }   vector<int> vec[200002];   void tarjan(int u, int fa) {     dfn[u] = low[u] = ++dfn[0];     st[++top] = u;     vis[u] = 1;     for (vector<int>::iterator it = vec[u].begin(); it != vec[u].end(); ++it) {       int v = *it;       if (v == fa) continue;       if (!dfn[v]) {         tarjan(v, u);         low[u] = min(low[u], low[v]);         if (low[v] == dfn[u]) {           ++num;           add(u, num);           int x = 0;           while (x != v) {             x = st[top];             add(num, x);             vis[x] = 0;             top--;           }         }         if (low[v] > dfn[u]) {           add(u, v);           vis[st[top]] = 0;           top--;         }       } else if (vis[v])         low[u] = min(low[u], dfn[v]);     }   }   void dfs(int u, int fa) {     for (int i = 1; (1 << i) <= deep[u]; ++i) p[i][u] = p[i - 1][p[i - 1][u]];     for (int i = head[u]; i; i = e[i].n)       if (e[i].to != fa) {         int v = e[i].to;         f[v] = u;         deep[v] = deep[u] + 1;         p[0][v] = u;         dep[v] = dep[u] + (v > n);         dfs(v, u);       }   }   inline int getlca(int u, int v) {     if (deep[u] < deep[v]) swap(u, v);     for (int i = 19; i >= 0; --i)       if (deep[u] - (1 << i) >= deep[v]) u = p[i][u];     if (u == v) return u;     for (int i = 19; i >= 0; --i)       if (p[i][u] != p[i][v]) u = p[i][u], v = p[i][v];     return p[0][u];   }   inline int dist(int u, int v) {     int lca = getlca(u, v);     return deep[u] + deep[v] - 2 * deep[lca] -            (dep[u] + dep[v] - dep[lca] - dep[f[lca]]);   }   int main() {     n = rd();     m = rd();     q = rd();     int u, v;     for (int i = 1; i <= m; ++i) {       u = rd();       v = rd();       vec[u].push_back(v);       vec[v].push_back(u);     }     num = n;     tarjan(1, 0);     dfs(1, 0);     while (q--) {       u = rd();       v = rd();       printf( %d n , dist(u, v));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int cnt_list, pos[20200], pa[20100], len[20100], fs[20100], pc[20100],       ls[20100], cnt_ls, tmp[20100], cnt, n, num_q;   struct pp {     int id;     char ch;   };   vector<pp> adj[20201];   pp now;   void dfs(int id, int pr) {     int i, j, s, p, q, ip;     pos[id] = cnt_list++;     pa[pos[id]] = pr;     for (i = 0; i < adj[id].size(); i++) {       ip = adj[id][i].id;       if (pos[ip] >= 0) continue;       pc[cnt_list] = adj[id][i].ch -  a ;       dfs(ip, pos[id]);     }   }   int main() {     int id1, id2, i, j, s, p, q, x, y, fg;     char ch;     scanf( %d%d , &n, &num_q);     for (i = 0; i < n - 1; i++) {       scanf( %d%d , &id1, &id2);       ch = getchar();       while (ch <  a  || ch >  z ) ch = getchar();       id1--;       id2--;       now.id = id2;       now.ch = ch;       adj[id1].push_back(now);       now.id = id1;       now.ch = ch;       adj[id2].push_back(now);     }     memset(pos, -1, sizeof(pos));     dfs(0, -1);     while (num_q--) {       scanf( %d%d , &x, &y);       x--;       y--;       x = pos[x];       y = pos[y];       int u, v;       u = x;       v = y;       cnt_ls = cnt = 0;       while (u != v) {         if (u > v) {           ls[cnt_ls++] = pc[u];           u = pa[u];         } else {           tmp[cnt++] = pc[v];           v = pa[v];         }       }       while (cnt > 0) ls[cnt_ls++] = tmp[--cnt];       for (i = 0; i < n; i++) len[i] = -1;       u = x;       fs[u] = len[u] = 0;       int ans = 0;       while (u != 0) {         len[pa[u]] = len[u] + 1;         if (fs[u] == 0) {           if (len[u] < cnt_ls) {             if (ls[len[u]] > pc[u])               fs[pa[u]] = -1;             else if (ls[len[u]] < pc[u])               fs[pa[u]] = 1;             else               fs[pa[u]] = 0;           } else             fs[pa[u]] = 1;         } else           fs[pa[u]] = fs[u];         if (fs[pa[u]] < 0 || (fs[pa[u]] == 0 && len[pa[u]] != cnt_ls)) ans++;         u = pa[u];       }       for (i = 1; i < n; i++) {         if (len[pa[i]] >= 0 && len[i] < 0) {           len[i] = len[pa[i]] + 1;           if (fs[pa[i]] == 0) {             if (len[pa[i]] < cnt_ls) {               if (ls[len[pa[i]]] > pc[i])                 fs[i] = -1;               else if (ls[len[pa[i]]] < pc[i])                 fs[i] = 1;               else                 fs[i] = 0;             } else               fs[i] = 1;           } else             fs[i] = fs[pa[i]];           if (fs[i] < 0 || (fs[i] == 0 && len[i] != cnt_ls)) ans++;         }       }       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1e9 + 7;   const long long INF = 1e18;   const string nl =   n ;   long long n, k, hld = 0, sum, hld1 = 0;   vector<long long> a;   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(nullptr);     cin >> n >> k;     a.resize(n);     for (auto& i : a) {       cin >> i;     }     for (long long i = 0; i < n; ++i) {       sum += a[i];       hld = max(hld, sum);       hld1 = min(hld1, sum);     }     cout << max(0LL, k - (hld - hld1 - 1)) << nl;   }
#include <bits/stdc++.h>   const int ms = 200200;   const int eps =  z  -  a  + 1;   void print(int x) {     for (int i = 0; i < eps; i++) {       std::cout << ((x & (1 << i)) ? 1 : 0);     }     std::cout <<   n ;   }   char t[200200];   std::string str[200200];   int main() {     int n;     std::cin >> n;     int isnt = 0;     int know = (1 << eps) - 1;     int ans = 0;     for (int i = 0; i < n; i++) {       std::cin >> t[i] >> str[i];     }     for (int i = 0; i < n; i++) {       int tot = (~isnt & know);       bool hmm = tot - (tot & -tot) == 0;       int mask = 0;       for (auto a : str[i]) {         mask |= 1 << (a -  a );       }       if (t[i] ==  ! ) {         if (hmm) {           ans++;         }         know &= mask;       } else if (t[i] ==  . ) {         isnt |= mask;       } else {         if (hmm && (1 << (str[i][0] -  a )) != tot) {           ans++;         }         if (!hmm && str[i][0] != str[n - 1][0]) {           isnt |= 1 << (str[i][0] -  a );         }       }     }     std::cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e5 + 10;   const int MOD = 1e9 + 7;   const int INF = 0x3f3f3f3f;   int N, M;   int a[110];   int b[110];   int sum[110];   int num[110][30];   char ans[110];   void solve(int n) {     string temp;     memset(a, 0, sizeof(a));     memset(b, 0, sizeof(b));     memset(sum, 0, sizeof(sum));     cout <<  ? 1   << n << endl;     cout.flush();     for (int i = n * (n + 1) / 2; i > 0; i--) {       cin >> temp;       for (int j = 0; j < temp.size(); j++) {         a[temp.size()] += temp[j] -  a ;       }     }     cout <<  ? 1   << n - 1 << endl;     cout.flush();     for (int i = n * (n - 1) / 2; i > 0; i--) {       cin >> temp;       for (int j = 0; j < temp.size(); j++) {         b[temp.size()] += temp[j] -  a ;       }     }     for (int i = 1; i <= n; i++) {       sum[i] = a[i] - b[i];       ans[n - i] = sum[i] - sum[i - 1] +  a ;     }   }   int main() {     string temp;     int limit;     int now;     while (~scanf( %d , &N)) {       if (N <= 3) {         char c;         for (int i = 1; i <= N; i++) {           cout <<  ?   << i <<     << i << endl;           cout.flush();           cin >> c;           ans[i - 1] = c;         }       } else {         memset(num, 0, sizeof(num));         limit = (N + 1) >> 1;         solve(limit);         cout <<  ?   << 1 <<     << N << endl;         cout.flush();         for (int i = N * (N + 1) / 2; i > 0; i--) {           cin >> temp;           for (int j = 0; j < temp.size(); j++) {             num[temp.size()][temp[j] -  a ]++;           }         }         for (int i = N; i >= limit; i--) {           for (int j = 1; j <= min(N - i + 1, limit); j++) {             now = j;             num[i][ans[j - 1] -  a ] -= now;           }           for (int j = now + 1; j <= limit; j++) {             num[i][ans[j - 1] -  a ] -= now;           }         }         for (int i = N; i > limit; i--) {           for (int j = 0; j < 30; j++) {             if (num[i][j] / (N - i + 1) * (N - i + 2) != num[i - 1][j]) {               ans[i - 1] = j +  a ;               for (int k = i - 1; k >= limit; k--) {                 num[k][j] -= N - i + 1;               }               break;             }           }         }       }       ans[N] =   0 ;       printf( ! %s n , ans);       cout.flush();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) {     if (a < b) swap(a, b);     if (b == 0) return a;     return gcd(b, a % b);   }   vector<string> getWords(string s) {     string cur =   ;     vector<string> vec;     for (int i = 0; i < s.size(); i++) {       if (s[i] ==    ) {         vec.push_back(cur);         cur =   ;       } else         cur += s[i];     }     vec.push_back(cur);     return vec;   }   int dist[213456], sz[213456];   vector<vector<int> > vec;   void dfs(int n, int p) {     sz[n] = 1;     for (auto x : vec[n]) {       if (x != p) {         dist[x] = dist[n] + 1;         dfs(x, n);         sz[n] += sz[x];       }     }   }   int main() {     int n, k;     cin >> n >> k;     vec.resize(n + 1);     for (int i = 0; i < n - 1; i++) {       int u, v;       cin >> u >> v;       vec[u].push_back(v);       vec[v].push_back(u);     }     dfs(1, 0);     vector<long long> vec1;     for (int i = 2; i <= n; i++) {       int val = dist[i] - (sz[i] - 1);       vec1.push_back(val);     }     sort(vec1.begin(), vec1.end());     reverse(vec1.begin(), vec1.end());     long long ans = 0;     for (int i = 0; i < k; i++) ans += vec1[i];     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   int n, k, r, c;   vector<string> grip;   int main() {     grip.clear();     cin >> r >> c >> n >> k;     string ful =   ;     for (int i = 0; i < c; i++) ful +=  . ;     for (int i = 0; i < r; i++) grip.push_back(ful);     for (int i = 0; i < n; i++) {       int y, x;       cin >> y >> x;       y--, x--;       grip[y][x] =  # ;     }     int ans = 0;     for (int il = 0; il < r; il++) {       for (int ir = il; ir < r; ir++) {         for (int jl = 0; jl < c; jl++) {           for (int jr = jl; jr < c; jr++) {             int con = 0;             for (int p = il; p <= ir; p++) {               for (int q = jl; q <= jr; q++)                 if (grip[p][q] ==  # ) con++;             }             if (con >= k) ans++;           }         }       }     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 100;   int h[N], nex[N << 1], to[N << 1], tot, dis[N];   void add(int x, int y) {     to[++tot] = y;     nex[tot] = h[x];     h[x] = tot;   }   int fa[N][30], dep[N], lg[N];   void dfs(int u, int fath, int d) {     dis[u] = d;     fa[u][0] = fath;     dep[u] = dep[fath] + 1;     for (int i = 1; i <= lg[dep[u]]; i++) fa[u][i] = fa[fa[u][i - 1]][i - 1];     for (int j = h[u]; j; j = nex[j])       if (to[j] != fath) dfs(to[j], u, d + 1);   }   int lca(int x, int y) {     if (dep[x] < dep[y]) swap(x, y);     while (dep[x] > dep[y]) x = fa[x][lg[dep[x] - dep[y]] - 1];     if (x == y) return x;     for (int i = lg[dep[x] - 1]; i >= 0; i--)       if (fa[x][i] != fa[y][i]) x = fa[x][i], y = fa[y][i];     return fa[x][0];   }   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i < n; i++) {       int u, v;       scanf( %d%d , &u, &v);       add(u, v);       add(v, u);     }     for (int i = 1; i <= n; i++) lg[i] = lg[i - 1] + (1 << lg[i - 1] == i);     dfs(1, 0, 0);     int q;     scanf( %d , &q);     for (int i = 1; i <= q; i++) {       int x, y, a, b, k;       scanf( %d%d%d%d%d , &x, &y, &a, &b, &k);       int lcab = lca(a, b);       int d1 = dis[a] + dis[b] - 2 * dis[lcab];       if (k >= d1 && (k % 2) == (d1 % 2)) {         printf( Yes n );         continue;       }       int lcax = lca(a, x);       int lcay = lca(a, y);       int lcby = lca(b, y);       int lcbx = lca(b, x);       int d2 = dis[x] + dis[a] - 2 * dis[lcax];       int d3 = dis[a] + dis[y] - 2 * dis[lcay];       int d4 = dis[b] + dis[y] - 2 * dis[lcby];       int d5 = dis[b] + dis[x] - 2 * dis[lcbx];       if (k >= (d2 + 1 + d4) && (k % 2) == ((d2 + 1 + d4) % 2)) {         printf( Yes n );       } else if (k >= (d3 + 1 + d5) && (k % 2) == ((d3 + 1 + d5) % 2)) {         printf( Yes n );       } else {         printf( No n );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100005;   const long long M = 1000000007;   long long a;   int main() {     scanf( %I64d , &a);     a %= 360;     a += 360;     long long ans = 0, mx = -1;     for (int i = 0; i < 4; i++) {       if (mx < abs((a + i * 270) % 360 - 180)) {         mx = abs((a + i * 270) % 360 - 180);         ans = i;       }     }     printf( %I64d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   int pos[100005];   pair<int, int> tree[100005];   bool func(pair<int, int> x, pair<int, int> y) { return (x.first) < (y.first); }   int main() {     int n;     for (int i = 1; i < 100005; i++) {       pos[i] = 2e9 + 1000;     }     pos[0] = -2e9;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d %d , &tree[i].first, &tree[i].second);     }     sort(tree, tree + n, func);     int mx = 0, g;     for (int i = 0; i < n; i++) {       if (i != 0 && tree[i].first - tree[i].second <= tree[i - 1].first) {       } else {         g = lower_bound(pos, pos + n, tree[i].first - tree[i].second) - pos;         pos[g] = min(pos[g], tree[i].first);         mx = max(mx, g);       }       if (i != n - 1 && tree[i].first + tree[i].second >= tree[i + 1].first) {       } else {         g = lower_bound(pos, pos + n, tree[i].first) - pos;         pos[g] = min(pos[g], tree[i].first + tree[i].second);         mx = max(mx, g);       }     }     printf( %d , mx);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<char> s(n);     for (int i = 0; i < n; i++) {       cin >> s[i];     }     vector<char> t(n);     for (int i = 0; i < n; i++) {       cin >> t[i];     }     vector<int> ans;     for (int i = 0; i < n; i++) {       if (s[i] == t[i]) {         continue;       } else {         char target = t[i];         for (int j = n - 2; j >= i; j--) {           if (s[j + 1] == target) {             swap(s[j], s[j + 1]);             ans.push_back(j + 1);           }         }         if (s[i] != t[i]) {           cout << -1;           return 0;         }       }     }     cout << ans.size() << endl;     for (int i = 0; i < ans.size(); i++) {       cout << ans[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a[200], n, c = 0;     double sum = 0;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i];       sum += a[i];     }     sort(a, a + n);     while (double(sum / n) < 4.5) {       sum += (5 - a[c]);       c++;     }     cout << c;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char buffer[2000020], *p1, *p2;   template <class T>   void read(T& x) {     char ch = ((p1 == p2 &&                 (p2 = (p1 = buffer) + fread(buffer, 1, 2000020, stdin), p1 == p2))                    ? EOF                    : *p1++);     x = 0;     bool f = 1;     while (!( 0  <= ch && ch <=  9 ) && ch !=  - )       ch = ((p1 == p2 &&              (p2 = (p1 = buffer) + fread(buffer, 1, 2000020, stdin), p1 == p2))                 ? EOF                 : *p1++);     if (ch ==  - )       f = 0,       ch = ((p1 == p2 &&              (p2 = (p1 = buffer) + fread(buffer, 1, 2000020, stdin), p1 == p2))                 ? EOF                 : *p1++);     while ( 0  <= ch && ch <=  9 )       x = (x << 1) + (x << 3) + ch -  0 ,       ch = ((p1 == p2 &&              (p2 = (p1 = buffer) + fread(buffer, 1, 2000020, stdin), p1 == p2))                 ? EOF                 : *p1++);     x = (f) ? x : -x;   }   int _num[20];   template <class T>   void write(T x) {     if (!x) {       putchar( 0 ), putchar(  n );       return;     }     if (x < 0) putchar( - ), x = -x;     int c = 0;     while (x) _num[++c] = x % 10, x /= 10;     while (c) putchar( 0  + _num[c--]);     putchar(  n );   }   int bc[128];   int masks[] = {119, 18, 93, 91, 58, 107, 111, 82, 127, 123};   int a[2020], res[2020];   int n, k;   bool vis[2020][2020], dp[2020][2020];   bool DP(int pos, int rest) {     if (pos > n) return rest == 0;     if (vis[pos][rest]) return dp[pos][rest];     vis[pos][rest] = 1;     bool& ans = dp[pos][rest];     ans = false;     for (register int i = 9; i >= 0; i--) {       if ((a[pos] | masks[i]) != masks[i]) continue;       if (rest < bc[masks[i] ^ a[pos]]) continue;       if (DP(pos + 1, rest - bc[masks[i] ^ a[pos]])) {         res[pos] = i;         return ans = true;       }     }     return ans;   }   int main() {     bc[0] = 0;     for (register int i = 1; i <= 127; i++) bc[i] = bc[i >> 1] + (i & 1);     read(n), read(k);     for (register int i = 1; i <= n; i++) {       char ch =           ((p1 == p2 &&             (p2 = (p1 = buffer) + fread(buffer, 1, 2000020, stdin), p1 == p2))                ? EOF                : *p1++);       while (ch !=  0  && ch !=  1 )         ch = ((p1 == p2 &&                (p2 = (p1 = buffer) + fread(buffer, 1, 2000020, stdin), p1 == p2))                   ? EOF                   : *p1++);       while (ch ==  0  || ch ==  1 )         a[i] = (a[i] << 1) + ch -  0 ,         ch = ((p1 == p2 &&                (p2 = (p1 = buffer) + fread(buffer, 1, 2000020, stdin), p1 == p2))                   ? EOF                   : *p1++);     }     if (!DP(1, k))       printf( -1 );     else       for (register int i = 1; i <= n; i++) printf( %d , res[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxN = 100010;   int n, parent[maxN], child[maxN];   long long f[maxN], g[maxN], res;   struct ioi {     int v, w;   };   vector<ioi> adj[maxN];   void dfs(int u) {     child[u] = 1;     for (int i = 0; i < adj[u].size(); ++i) {       int v = adj[u][i].v;       if (parent[u] == v) continue;       parent[v] = u;       dfs(v);       child[u] = child[u] + child[v];       f[u] += ((adj[u][i].w) ? child[v] : f[v]);     }   }   void dfs_g(int u) {     for (int i = 0; i < adj[u].size(); ++i) {       int v = adj[u][i].v;       if (parent[u] == v) continue;       int tmp = ((adj[u][i].w) ? child[v] : f[v]);       g[v] = (adj[u][i].w) ? (n - child[v]) : (f[u] + g[u] - tmp);       dfs_g(v);     }   }   bool check(int x) {     while (x) {       if (((x % 10) != 4) && ((x % 10) != 7)) return false;       x /= 10;     }     return true;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n - 1; ++i) {       int u, v, w;       scanf( %d%d%d , &u, &v, &w);       w = check(w);       ioi tmp;       tmp.v = v;       tmp.w = w;       adj[u].push_back(tmp);       tmp.v = u;       tmp.w = w;       adj[v].push_back(tmp);     }     dfs(1);     dfs_g(1);     for (int i = 1; i <= n; ++i) res += ((f[i] + g[i]) * (f[i] + g[i] - 1));     cout << res;     fclose(stdin);     fclose(stdout);   }