func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxm = 1e5 + 5;   vector<int> g[maxm];   int n, q;   int sz[maxm];   int d[maxm];   int f[maxm][25];   const int maxd = 20;   void dfs(int x, int fa) {     sz[x] = 1;     for (int j = 1; j <= maxd; j++) {       f[x][j] = f[f[x][j - 1]][j - 1];     }     for (int v : g[x]) {       if (v == fa) continue;       d[v] = d[x] + 1;       f[v][0] = x;       dfs(v, x);       sz[x] += sz[v];     }   }   int lca(int a, int b) {     if (d[a] < d[b]) swap(a, b);     for (int i = maxd; i >= 0; i--) {       if (d[f[a][i]] >= d[b]) {         a = f[a][i];       }     }     if (a == b) return a;     for (int i = maxd; i >= 0; i--) {       if (f[a][i] != f[b][i]) {         a = f[a][i];         b = f[b][i];       }     }     return f[a][0];   }   signed main() {     ios::sync_with_stdio(0);     cin >> n;     for (int i = 1; i < n; i++) {       int a, b;       cin >> a >> b;       g[a].push_back(b);       g[b].push_back(a);     }     d[1] = 1;     f[1][0] = 1;     dfs(1, 1);     cin >> q;     while (q--) {       int a, b;       cin >> a >> b;       if (a == b) {         cout << n << endl;         continue;       }       int lc = lca(a, b);       int dab = d[a] + d[b] - 2 * d[lc];       if (dab % 2) {         cout << 0 << endl;         continue;       }       if (d[a] < d[b]) swap(a, b);       int dist = dab / 2;       for (int i = maxd; i >= 0; i--) {         if (dist - (1 << i) > 0) {           a = f[a][i];           b = f[b][i];           dist -= (1 << i);         }       }       if (d[a] == d[b]) {         cout << n - sz[a] - sz[b] << endl;         continue;       }       cout << sz[f[a][0]] - sz[a] << endl;     }     return 0;   }   