func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   unordered_map<string, int> ma;   int T, n, tot;   int a[1000010], b[1000010];   long long dp[1000010][2], ans;   struct node {     int per, to;   } e[1000010];   int head[1000010];   long long sum;   void addedge(int from, int to) {     e[++tot].to = to;     e[tot].per = head[from];     head[from] = tot;   }   void dfs(int u, int fa) {     dp[u][b[u]]++;     for (int i = head[u]; i > 0; i = e[i].per) {       int v = e[i].to;       if (v == fa) continue;       dfs(v, u);       sum += dp[v][0] * dp[u][1] + dp[v][1] * dp[u][0];       if (b[u] > 0) {         dp[u][0] += dp[v][1];         dp[u][1] += dp[v][0];       } else {         dp[u][0] += dp[v][0];         dp[u][1] += dp[v][1];       }     }     sum += b[u];   }   int main() {     T = 1;     while (T--) {       memset(head, -1, sizeof(head));       scanf( %d , &n);       for (int i = 1; i <= n; ++i) {         scanf( %d , &a[i]);       }       for (int i = 1; i < n; ++i) {         int u, v;         scanf( %d%d , &u, &v);         addedge(u, v);         addedge(v, u);       }       for (int i = 0; i <= 20; ++i) {         sum = 0;         for (int j = 1; j <= n; ++j) {           b[j] = (a[j] & (1 << i)) > 0;           dp[j][0] = dp[j][1] = 0;         }         dfs(1, -1);         ans += sum << i;       }       printf( %lld n , ans);     }     return 0;   }   