malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   double areaa(int x1, int x2, int x3, int y1, int y2, int y3);   int gcd(int x, int y);   int lcm(int x, int y);   int egcd(int a, int b, int& x, int& y);   vector<int> prime_possible_factors(int n);   vector<int> primes_included(int n, int m);   map<int, int> factor(int N);   bool isPrime(int N);   int charType(char c);   double areaa(int x1, int x2, int x3, int y1, int y2, int y3) {     double area = abs((x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2)) / 4.0);     return area;   }   int gcd(int x, int y) { return y == 0 ? x : gcd(y, x % y); }   int lcm(int x, int y) { return (x * y / gcd(x, y)); }   int egcd(int a, int b, int& x, int& y) {     if (b == 0) {       x = 1;       y = 0;       return a;     } else {       int d = egcd(b, a % b, x, y);       x -= a / b * y;       swap(x, y);       return d;     }   }   vector<int> prime_possible_factors(int n) {     bool* isPrime = new bool[n];     for (int i = 0; i < n; i++) {       isPrime[i] = true;     }     vector<int> primes;     for (int i = 2; i * i <= n; ++i) {       if (isPrime[i]) {         primes.push_back(i);         for (int j = i; j < n; j += i) isPrime[j] = false;       }     }     return primes;   }   vector<int> primes_included(int n, int m) {     bool* isPrime = new bool[m];     for (int i = 0; i < m; i++) {       isPrime[i] = true;     }     vector<int> primes;     for (int i = 2; i < m; ++i) {       if (isPrime[i]) {         if (i >= n) primes.push_back(i);         for (int j = i; j < m; j += i) isPrime[j] = false;       }     }     return primes;   }   map<int, int> factor(int N) {     vector<int> primes;     primes = primes_included(0, N);     map<int, int> factors;     for (int i = 0; i < primes.size(); ++i) {       int prime = primes[i], power = 0;       while (N % prime == 0) {         power++;         N /= prime;       }       factors[prime] = power;     }     return factors;   }   bool isPrime(int N) {     vector<int> check = prime_possible_factors(N);     for (int i = 0; i < check.size(); i++) {       if (N % check[i] == 0) {         return false;       }     }     return true;   }   int main() {     int T;     long long int n, s, t;     cin >> T;     int i = 0;     for (i; i < T; i++) {       cin >> n >> s >> t;       cout << max(n - s, n - t) + 1 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s, t, tmp1, tmp2;   vector<int> ans;   int cnt, n;   int main() {     cin >> n;     cin >> s >> t;     tmp1 = s, tmp2 = t;     sort(tmp1.begin(), tmp1.end());     sort(tmp2.begin(), tmp2.end());     if (tmp1 != tmp2) return cout << -1, 0;     if (s[0] == t[n - 1]) cnt++;     while (cnt != n) {       int i;       for (i = cnt; i < n; i++) {         if (s[i] == t[n - cnt - 1]) break;       }       ans.push_back(n);       for (int j = 0; j < n / 2; j++) swap(s[j], s[n - j - 1]);       s = s.substr(n - i, i) + s.substr(0, n - i);       for (int j = 0; j < i / 2; j++) swap(s[j], s[i - j - 1]);       s = s.substr(n - 1, 1) + s.substr(0, n - 1);       ans.push_back(i);       ans.push_back(1);       cnt++;     }     cout << ans.size() << endl;     for (int i = 0; i < (int)ans.size(); i++) cout << ans[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 2;   int a[N], b[N];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     for (int i = 0; i < (int)n; i++) cin >> a[i], b[i + 1] += b[i] + a[i];     int t = 0;     for (int i = 0; i < (int)n; i++) {       for (int j = 0; j < (int)i + 1; j++) {         if (b[i + 1] - b[j] > 100 * (i - j + 1)) t = max(t, i - j + 1);       }     }     cout << t <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int MIN(int a, int b) { return a < b ? a : b; };   int MAX(int a, int b) { return a > b ? a : b; };   int gcd(int a, int b) {     if (b == 0)       return a;     else       return gcd(b, a % b);   }   int n, m, q;   int h;   int a[20] = {2,  4,  3,  9,  5,  25, 7,  49, 11, 13,                17, 19, 23, 29, 31, 37, 41, 43, 47, 53};   int main() {     int i, j, x, y, T, num, t;     string str;     t = num = 0;     for (i = 0; i < 20; i++) {       cout << a[i] << endl;       cin >> str;       num++;       x = a[i];       if (str ==  yes ) {         t++;       }       if (t > 1) break;     }     if (i == 20)       cout <<  prime n ;     else       cout <<  composite n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   struct edge {     int from;     int to;     int next;   } E[500005 << 1];   int head[100005];   int deg[100005];   int tmp[500005];   int used[500005 << 1];   int size = 1;   void add_edge(int u, int v) {     size++;     E[size].from = u;     E[size].to = v;     E[size].next = head[u];     head[u] = size;   }   stack<int> s, ans;   void euler() {     s.push(1);     while (!s.empty()) {       int x = s.top();       int i = head[x];       while (i != 0 && used[i] == 1) i = E[i].next;       if (i != 0) {         s.push(E[i].to);         used[i] = used[i ^ 1] = 1;         head[x] = E[i].next;       } else {         s.pop();         ans.push(x);       }     }   }   int main() {     int u, v;     scanf( %d %d , &n, &m);     for (int i = 1; i <= m; i++) {       scanf( %d %d , &u, &v);       add_edge(u, v);       add_edge(v, u);       deg[u]++;       deg[v]++;     }     int pre = 0;     int cnt = 0;     for (int i = 1; i <= n; i++) {       if (deg[i] % 2 == 1) {         if (pre != 0) {           add_edge(pre, i);           add_edge(i, pre);           pre = 0;         } else           pre = i;       }     }     if (((size - 1) / 2) % 2 == 1) {       add_edge(1, 1);       size++;     }     euler();     printf( %d n , (size - 1) / 2);     int ptr = 0;     while (!ans.empty()) {       tmp[++ptr] = ans.top();       ans.pop();     }     for (int i = 1; i <= ptr - 1; i++) {       if (i & 1)         printf( %d %d n , tmp[i], tmp[i + 1]);       else         printf( %d %d n , tmp[i + 1], tmp[i]);     }   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1123456;   const int MAXINT = 2147483098;   const long long MAXLL = 9223372036854775258LL;   set<pair<int, int> > s;   int ans[MAXN];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n, m, d, pos = 0, mx = 0;     cin >> n >> m >> d;     for (int i = 1; i <= n; ++i) {       int a;       cin >> a;       s.insert(make_pair(a, i));     }     for (int i = 1; i <= n; ++i) {       if (!s.size()) break;       ans[s.begin()->second] = i;       mx = i;       long long val = s.begin()->first;       s.erase(s.begin());       while (1) {         if (!s.size()) break;         auto it = s.lower_bound(make_pair(val + d + 1, 0LL));         if (it == s.end()) break;         ans[it->second] = i;         val = it->first;         s.erase(it);       }     }     cout << mx <<   n ;     for (int i = 1; i <= n; ++i) cout << ans[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   char s[200005];   using namespace std;   int main() {     int n, k;     cin >> n >> k;     getchar();     cin >> s;     int maxn1 = 0;     for (int i = 0; i < 26; i++) {       char t =  a  + i;       int sum1 = 0;       int maxn = 0;       for (int j = 0; j < n; j++) {         if (s[j] == t && s[j + 1] == t)           sum1++;         else if (s[j] == t && s[j + 1] != t) {           sum1++;           maxn += sum1 / k;           sum1 = 0;         }       }       maxn1 = max(maxn, maxn1);     }     cout << maxn1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 200010;   vector<int> G[maxn];   int n, k;   int u, v;   int siz[maxn], dep[maxn];   int val[maxn], fa[maxn];   void dfs(int x, int d) {     dep[x] = d;     siz[x] = 1;     for (int i = 0; i < G[x].size(); ++i) {       int to = G[x][i];       if (to == fa[x]) continue;       fa[to] = x;       dfs(to, d + 1);       siz[x] += siz[to];     }     val[x] = siz[x] - dep[x];   }   int main() {     scanf( %d%d , &n, &k);     for (int i = 1; i < n; ++i) {       scanf( %d%d , &u, &v);       G[u].push_back(v);       G[v].push_back(u);     }     dfs(1, 1);     sort(val + 1, val + 1 + n);     long long ans = 0;     for (int i = k + 1; i <= n; ++i) ans += (long long)val[i];     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, k;     cin >> n >> k;     pair<long long, long long> a[n];     for (long long i = 0; i < n; i++) {       cin >> a[i].first;       a[i].second = i;     }     sort(a, a + n);     queue<long long> q;     set<long long> s;     bool turn = true;     long long ans[n];     for (long long i = n - 1; i >= 0; i--) {       q.push(a[i].second);       s.insert(i);     }     while (!q.empty()) {       long long top = q.front();       q.pop();       if (s.find(top) == s.end()) continue;       vector<long long> v;       long long count = 0;       for (auto itr = prev(s.find(top)); count < k && itr != prev(s.begin());            itr--) {         v.push_back(*itr);         count++;       }       count = 0;       for (auto itr = s.find(top); count <= k && itr != s.end(); itr++) {         v.push_back(*itr);         count++;       }       for (long long i = 0; i < v.size(); i++) {         s.erase(v[i]);         ans[v[i]] = turn;       }       turn = !turn;     }     for (long long i = 0; i < n; i++) {       if (ans[i])         cout << 1;       else         cout << 2;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int n, m;     cin >> n >> m;     vector<pair<string, int>> a(n);     int c = 1;     for (auto &t : a) {       cin >> t.first;       t.second = c++;     }     for (auto &t : a) {       for (int i = 1; i < m; i += 2) {         t.first[i] =  z  - t.first[i] +  a ;       }     }     sort(a.begin(), a.end());     for (auto t : a) {       cout << t.second <<    ;     }   }   int main() {     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> g[100005];   double dfs(int i, int ult) {     double ans = 0;     int c = g[i].size() - (i != 1);     for (int j = 0; j < g[i].size(); j++) {       if (g[i][j] != ult) {         ans += (dfs(g[i][j], i) + 1.0) / c;       }     }     return ans;   }   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i < n; i++) {       int a, b;       scanf( %d %d , &a, &b);       g[a].push_back(b);       g[b].push_back(a);     }     printf( %.15lf n , dfs(1, 0));   }
#include <bits/stdc++.h>   using namespace std;   const long long MXN = 2e5 + 10;   const long long LOG = 21;   const long long MXM = (1LL << LOG);   const long long INF = 1e9;   int n, m, ans;   int dp[MXN], ps[MXN], Best[LOG][MXM];   string S[MXN];   int Cost(int i, int j) {     for (int x = m; x; x--) {       if (S[i].substr(m - x + 1, x) == S[j].substr(1, x)) {         return m - x;       }     }     return m;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     memset(dp, 31, sizeof dp), memset(Best, 31, sizeof Best);     cin >> n, ans = INF;     for (int i = 1; i <= n; i++) {       cin >> S[i], m = (long long)S[i].size();       S[i] =  0  + S[i];     }     ps[1] = dp[1] = m;     for (int i = 2; i <= n; i++) ps[i] = ps[i - 1] + Cost(i - 1, i);     for (int i = 2; i <= n; i++) {       dp[i] = ps[i - 1] + m;       long long mask = 0;       for (int x = 0; x <= m; x++) {         mask = mask * 2 + (S[i][x] -  0 );         if (Best[x][mask] < INF) {           dp[i] = min(dp[i], ps[i - 1] + m - x + Best[x][mask]);         }       }       mask = 0;       for (int x = 0; x <= m; x++) {         if (x && S[i - 1][m - x + 1] ==  1 ) {           mask += (1LL << (x - 1));         }         Best[x][mask] = min(Best[x][mask], dp[i] - ps[i]);       }     }     for (int i = 1; i <= n; i++) ans = min(ans, dp[i] + ps[n] - ps[i]);     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> idb[100002];   int dp[301];   int main() {     int n, m, s, e;     cin >> n >> m >> s >> e;     vector<int> a(n);     for (int i = 0; i < n; i++) scanf( %d , &a[i]);     for (int i = 0; i < m; i++) {       int b;       scanf( %d , &b);       idb[b].push_back(i);     }     int ans = 0;     memset(dp, 127, sizeof dp);     dp[0] = 0;     for (int i = 0; i < n; i++) {       for (int j = 300; j >= 1; j--) {         int pos2array = dp[j - 1];         int nextPos = lower_bound(idb[a[i]].begin(), idb[a[i]].end(), pos2array) -                       idb[a[i]].begin();         if (nextPos == idb[a[i]].size()) continue;         int abspos2ar = idb[a[i]][nextPos];         dp[j] = min(dp[j], abspos2ar + 1);         if (i + 1 + dp[j] + j * e <= s) ans = max(ans, j);       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, K, a[100100], f[30030][205][4][2];   bool vis[30030][205][4][2];   void work() {     memset(f, -127, sizeof(f));     for (int i = 1; i <= n; i++) {       f[i][1][0][0] = -a[i];       f[i][1][2][0] = a[i];       vis[i][1][0][0] = 1;       vis[i][1][2][0] = 1;     }     for (int i = 1; i < n; i++)       for (int j = 1; j <= min(K, i); j++)         for (int k = 0; k <= 3; k++)           for (int l = 0; l <= 1; l++) {             if (!vis[i][j][k][l]) continue;             int v = f[i][j][k][l], sign = 0;             if (k == 0) sign = -2;             if (k == 3) sign = 2;             if (j == 1) {               if (k == 0) sign = -1;               if (k == 2) sign = 1;             }             if (j == K) {               if (k == 0 || k == 2)                 sign = -1;               else                 sign = 1;             }             if (!l) {               vis[i + 1][j][k][l] = 1;               f[i + 1][j][k][l] = max(f[i + 1][j][k][l], v + sign * a[i + 1]);             }             vis[i + 1][j][k][1] = 1;             f[i + 1][j][k][1] = max(f[i + 1][j][k][1], v);             for (int w = 0; w <= 1; w++) {               int s = (w << 1) | ((k & 2) == 0);               sign = 0;               if (s == 0) sign = -2;               if (s == 3) sign = 2;               if (j + 1 == K) {                 if (s == 0 || s == 2)                   sign = -1;                 else                   sign = 1;               }               vis[i + 1][j + 1][s][0] = 1;               f[i + 1][j + 1][s][0] =                   max(f[i + 1][j + 1][s][0], v + sign * a[i + 1]);             }           }     int ans = 0;     for (int i = 0; i <= 3; i++)       ans = max(ans, max(f[n][K][i][1], f[n][K][i][0]));     cout << ans;   }   int main() {     cin >> n >> K;     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     work();   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     scanf( %d , &n);     if ((n / 2) % 2 == 0) {       for (int i = 1; i <= n; ++i) {         if (i <= n / 2 && i % 2 == 1) {           printf( %d  , i + 1);         } else if (i <= n / 2 && i % 2 == 0) {           printf( %d  , n - i + 2);         } else if (i > (n + 1) / 2 && i % 2 == n % 2) {           printf( %d  , i - 1);         } else if (i > (n + 1) / 2 && i % 2 != n % 2) {           printf( %d  , n - i);         } else {           printf( %d  , i);         }       }       printf(  n );     } else {       printf( -1 n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, K, m;   set<pair<int, int> > Set;   set<int> SS;   int O[524288];   struct Tree {     int K[524288 + 524288], M[524288 + 524288];     void UDT(int nd) { M[nd] = max(M[nd * 2], M[nd * 2 + 1]); }     void init(int nd, int b, int e) {       K[nd] = 0;       if (b == e) {         M[nd] = b;         return;       }       int m = (b + e) >> 1;       init(nd * 2, b, m);       init(nd * 2 + 1, m + 1, e);       UDT(nd);     }     void Add2(int nd, int x) {       M[nd] += x;       K[nd] += x;     }     void Spread(int nd) {       Add2(nd * 2, K[nd]);       Add2(nd * 2 + 1, K[nd]);       K[nd] = 0;     }     void Add(int nd, int b, int e, int s, int l, int x) {       if (s > l) return;       if (s <= b && e <= l) {         Add2(nd, x);         return;       }       Spread(nd);       int m = (b + e) >> 1;       if (s <= m) Add(nd * 2, b, m, s, l, x);       if (l > m) Add(nd * 2 + 1, m + 1, e, s, l, x);       UDT(nd);     }     int Max(int nd, int b, int e, int s, int l) {       if (s > l) return -99999999;       if (s <= b && e <= l) return M[nd];       Spread(nd);       int m = (b + e) >> 1, r = -99999999;       if (s <= m) r = max(r, Max(nd * 2, b, m, s, l));       if (l > m) r = max(r, Max(nd * 2 + 1, m + 1, e, s, l));       return r;     }   } T;   void Solve() {     int i;     for (i = 1; i < 524288; i++) O[i] = 1;     T.init(1, 0, 524288 - 1);     scanf( %d%d%d , &n, &K, &m);     for (i = 1; i <= m; i++) {       int x, y;       scanf( %d%d , &x, &y);       int t = abs(x - K) + y;       if (Set.find(pair<int, int>(x, y)) != Set.end()) {         Set.erase(pair<int, int>(x, y));         O[t]++;         if (O[t] == 1) SS.erase(t);         T.Add(1, 0, 524288 - 1, t, 524288 - 1, 1);       } else {         Set.insert(pair<int, int>(x, y));         O[t]--;         if (O[t] == 0) SS.insert(t);         T.Add(1, 0, 524288 - 1, t, 524288 - 1, -1);       }       if (SS.empty()) {         puts( 0 );         continue;       }       t = *SS.rbegin();       int t1 = T.Max(1, 0, 524288 - 1, 0, t);       int t2 = T.Max(1, 0, 524288 - 1, t, t);       printf( %d n , max(t + (t1 - t2) - n, 0));     }   }   int main() {     int TC = 1;     while (TC--) {       Solve();     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 5;   int a[maxn], b[maxn];   bool v[maxn];   int main() {     int n;     cin >> n;     a[0] = -1;     for (int i = 1; i <= n; ++i) {       cin >> a[i];       v[a[i]] = 1;       if (a[i] > a[i - 1])         b[i] = a[i - 1];       else         b[i] = -1;     }     int c = 0;     for (int i = 1; i <= n; ++i) {       if (b[i] == -1) {         while (v[c]) c++;         b[i] = c++;       }     }     for (int i = 1; i <= n; ++i) cout << b[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int isTandom(string s, int n) {     if (n > s.size() / 2) return 0;     for (int i = 0; i < n; i++)       if (s[i + n] !=     && s[i] != s[i + n]) return 0;     return 1;   }   int main() {     string s;     int k;     cin >> s >> k;     int len = s.size();     for (int i = 0; i < k; i++) s +=    ;     for (int i = s.size() / 2; i >= 1; i--)       for (int j = 0; j + i < s.size(); j++)         if (isTandom((s.substr(j, 2 * i)), i)) {           cout << 2 * i << endl;           return 0;         }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, i, x, y;     cin >> n;     long long a[n], b[n - 1], c[n - 2];     for (i = 0; i < n; i++) cin >> a[i];     sort(a, a + n);     for (i = 0; i < n - 1; i++) cin >> b[i];     sort(b, b + (n - 1));     for (i = 0; i < n - 2; i++) cin >> c[i];     sort(c, c + (n - 2));     for (i = 0; i < n; i++) {       if (a[i] != b[i]) {         x = a[i];         break;       }     }     for (i = 0; i < n - 1; i++) {       if (b[i] != c[i]) {         y = b[i];         break;       }     }     cout << x << endl;     cout << y << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, t, x, c, d, ch = 0, caser = 0, lol = 0, sum = 0, rating = -1,                        upper = 1e9, lower = -1e9;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> c >> d;       if (i == 0) {         if (d == 1)           lower = 1900;         else           upper = 1899;       } else {         if (d == 2) {           upper = min(upper, sum + 1899);         } else {           lower = max(lower, sum + 1900);         }       }       sum -= c;     }     if (upper == 1e9)       cout <<  Infinity n ;     else if (lower > upper)       cout <<  Impossible n ;     else       cout << upper - sum << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long f[6][10010], b = 1;   int main() {     for (int i = 1; i <= 5; ++i)       for (int j = 1; j <= (i == 5 ? 1 : 10000); ++j) {         long long now = f[i - 1][j];         for (int k = 1; k <= j; ++k)           now += f[i - 1][min(now + j + 1, 10000ll)] + 1;         f[i][j] = now;       }     for (int i = 5, d; i >= 1; --i) {       long long now = 0;       printf( %lld  , min(b, 10000ll));       for (int j = 1; j <= min(b, 10000ll); ++j) {         now += f[i - 1][min(b + now, 10000ll)];         printf( %lld  , b + now);         ++now;       }       printf(  n );       fflush(stdout);       scanf( %d , &d);       if (d == -1)         break;       else {         now = 0;         for (int j = 1; j <= d; ++j) now += f[i - 1][min(b + now, 10000ll)] + 1;         b += now;       }     }   }
#include <bits/stdc++.h>   using namespace std;   bool kjg[100002];   int isi[100002];   long long dp[100002];   vector<int> adlis[100002], radlis[100002];   int rut, nvert, u, v;   void ruted(int x) {     kjg[x] = 1;     for (int i = 0; i < adlis[x].size(); i++) {       if (!kjg[adlis[x][i]]) {         radlis[x].push_back(adlis[x][i]);         ruted(adlis[x][i]);       }     }   }   long long rek(int x) {     if (radlis[x].size() == 0) {       return 0;     } else if (dp[x] != -1) {       return dp[x];     } else {       dp[x] = 0;       if (x != rut) {         isi[x]--;       }       int jum = 0;       vector<long long> cal;       cal.clear();       for (int i = 0; i < radlis[x].size(); i++) {         if (isi[radlis[x][i]] <= 1) continue;         if (rek(radlis[x][i]) > 0) {           cal.push_back(rek(radlis[x][i]));         }       }       for (int i = 0; i < radlis[x].size(); i++) {         jum += isi[radlis[x][i]];       }       sort(cal.begin(), cal.end());       if (cal.size() > 0) {         for (int i = cal.size() - 1; i >= 0; i--) {           dp[x] += (long long)cal[i];           dp[x] += 2LL;           isi[x]--;           if (isi[x] == 0) break;         }       }       if (isi[x] > 0) {         if (isi[x] < jum) {           dp[x] += 2LL * isi[x];           isi[x] = 0;         } else {           dp[x] += 2LL * jum;           isi[x] -= jum;         }       }       return dp[x];     }   }   int main() {     scanf( %d , &nvert);     for (int i = 0; i < nvert; i++) {       scanf( %d , &isi[i]);     }     for (int i = 0; i < nvert - 1; i++) {       scanf( %d%d , &u, &v);       u--;       v--;       adlis[u].push_back(v);       adlis[v].push_back(u);     }     scanf( %d , &rut);     rut--;     memset(kjg, 0, sizeof kjg);     ruted(rut);     memset(dp, -1, sizeof dp);     printf( %I64d n , rek(rut));     return 0;   }