func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, m, l;   vector<vector<int>> adj;   int timer;   vector<int> tin, tout;   vector<vector<int>> up;   vector<int> dist;   vector<int> down;   void dfs(int v, int p) {     dist[v] = dist[p] + 1;     down[v] = 1;     tin[v] = ++timer;     up[v][0] = p;     for (int i = 1; i <= l; ++i) up[v][i] = up[up[v][i - 1]][i - 1];     for (int u : adj[v]) {       if (u != p) {         dfs(u, v);         down[v] += down[u];       }     }     tout[v] = ++timer;   }   bool is_ancestor(int u, int v) {     return tin[u] <= tin[v] && tout[u] >= tout[v];   }   int lca(int u, int v) {     if (is_ancestor(u, v)) return u;     if (is_ancestor(v, u)) return v;     for (int i = l; i >= 0; --i) {       if (!is_ancestor(up[u][i], v)) u = up[u][i];     }     return up[u][0];   }   int pre(int u, int v) {     for (int i = l; i >= 0; --i) {       if (!is_ancestor(up[u][i], v)) u = up[u][i];     }     return u;   }   void preprocess(int root) {     tin.resize(n + 1);     tout.resize(n + 1);     timer = 0;     l = ceil(log2(n + 1));     up.assign(n + 1, vector<int>(l + 2));     dfs(root, root);   }   void trav(int x, int d) {     int to = x;     for (int i = l; i >= 0; i--) {       if (dist[x] - dist[up[to][i]] < d) {         to = up[to][i];       }     }     cout << down[up[to][0]] - down[to] <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> n;     adj.resize(n + 1);     dist.resize(n + 1);     down.resize(n + 1);     for (int i = 0; i < n - 1; i++) {       int x, y;       cin >> x >> y;       adj[x].push_back(y);       adj[y].push_back(x);     }     preprocess(1);     cin >> m;     for (int i = 0; i < m; i++) {       int x, y;       cin >> x >> y;       int L = lca(x, y);       if (x == y) {         cout << n <<   n ;         continue;       }       int d = (dist[x] - dist[L] + dist[y] - dist[L] + 1);       if (d % 2 == 0) {         cout << 0 <<   n ;       } else {         if (dist[x] - dist[L] == dist[y] - dist[L]) {           cout << n - down[pre(x, L)] - down[pre(y, L)] <<   n ;         } else {           d = (dist[x] - dist[L] + dist[y] - dist[L]);           if (dist[x] < dist[y]) swap(x, y);           int z = d / 2;           trav(x, z);         }       }     }     return 0;   }   