func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long N = 100005, LOG = 25;   long long n, f[N][LOG + 5], cnt = 0, head[N], dep[N];   long long size[N];   struct CLANNAD {     long long to, nxt;   } a[N << 1];   inline void add(long long u, long long v) {     a[++cnt].to = v;     a[cnt].nxt = head[u];     head[u] = cnt;   }   inline long long getnode(long long x, long long deep) {     for (long long i = LOG; i >= 0; i--)       if (dep[f[x][i]] >= deep) x = f[x][i];     return x;   }   inline long long LCA(long long x, long long y) {     if (dep[x] < dep[y]) swap(x, y);     long long ox = x, oy = y;     for (long long i = LOG; i >= 0; i--)       if (dep[f[x][i]] >= dep[y]) x = f[x][i];     long long lca;     if (x == y)       lca = x;     else {       for (long long i = LOG; i >= 0; i--)         if (f[x][i] != f[y][i]) x = f[x][i], y = f[y][i];       lca = f[x][0];     }     long long dis = dep[ox] + dep[oy] - dep[lca] * 2;     if (dis & 1)       return 0;     else if (oy == lca) {       long long mid = (dep[ox] + dep[oy]) >> 1;       return size[getnode(ox, mid)] - size[getnode(ox, mid + 1)];     } else if (dep[ox] != dep[oy]) {       long long mid = dep[ox] - dis / 2;       return size[getnode(ox, mid)] - size[getnode(ox, mid + 1)];     } else       return n - size[getnode(ox, dep[lca] + 1)] -              size[getnode(oy, dep[lca] + 1)];   }   void dfs(long long x, long long fx) {     size[x] = 1;     dep[x] = dep[fx] + 1;     f[x][0] = fx;     for (long long i = 1; i <= LOG; i++) f[x][i] = f[f[x][i - 1]][i - 1];     for (long long i = head[x]; i; i = a[i].nxt)       if (a[i].to != fx) dfs(a[i].to, x), size[x] += size[a[i].to];   }   signed main() {     cin >> n;     long long u, v;     for (long long i = 1; i <= n - 1; i++)       scanf( %lld%lld , &u, &v), add(u, v), add(v, u);     dfs(1, 0);     long long T, x, y;     cin >> T;     while (T--) {       scanf( %lld%lld , &x, &y);       if (x == y)         printf( %lld n , n);       else         printf( %lld n , LCA(x, y));     }     return 0;   }   