func_code_string: #include <bits/stdc++.h>   using namespace std;   template <class _Tp>   _Tp gcd(_Tp a, _Tp b) {     return (b == 0) ? (a) : (gcd(b, a % b));   }   const long long Inf = 1000000000000000000ll;   const int inf = 1000000000;   char buf[1 << 25], *p1 = buf, *p2 = buf;   inline int getc() {     return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 25, stdin), p1 == p2)                ? EOF                : *p1++;   }   inline int read() {     int x = 0, f = 0;     char c = getc();     while (!isdigit(c)) (c ==  - ) && (f = 1), c = getc();     while (isdigit(c)) x = x * 10 + (c & 15), c = getc();     return f ? -x : x;   }   const int N = 200005;   const int Lg = 19;   int dfn[N], fa[N][Lg], dep[N], siz[N];   int sum[N * 4], t[N * 4], cnt;   vector<int> e[N];   map<int, int> added[N];   void dfs(int u, int f) {     dfn[u] = ++cnt;     fa[u][0] = f;     dep[u] = dep[f] + 1;     siz[u] = 1;     for (int i = 0; i < e[u].size(); ++i) {       int to = e[u][i];       if (to == f) continue;       dfs(to, u);       siz[u] += siz[to];     }   }   void pushup(int o, int len) {     if (t[o])       sum[o] = len;     else if (len == 1)       sum[o] = 0;     else       sum[o] = sum[o << 1] + sum[o << 1 | 1];   }   void update(int o, int l, int r, int L, int R, int val) {     if (L <= l && r <= R) {       t[o] += val;       pushup(o, r - l + 1);       return;     }     int mid = l + r >> 1;     if (L <= mid) update(o << 1, l, mid, L, R, val);     if (R > mid) update(o << 1 | 1, mid + 1, r, L, R, val);     pushup(o, r - l + 1);   }   int n, q;   int main() {     n = read();     q = read();     for (int i = 1; i < n; ++i) {       int x = read(), y = read();       e[x].push_back(y);       e[y].push_back(x);     }     dfs(1, 0);     for (int w = 1; w < Lg; ++w)       for (int i = 1; i <= n; ++i) fa[i][w] = fa[fa[i][w - 1]][w - 1];     while (q--) {       int u = read(), v = read(), k;       if (dfn[u] > dfn[v]) swap(u, v);       if (added[u][v])         added[u][v] = 0, k = -1;       else         added[u][v] = 1, k = 1;       if (dfn[u] + siz[u] - 1 >= dfn[v] + siz[v] - 1) {         int x = v;         for (int w = Lg - 1; ~w; --w)           if (dep[fa[x][w]] > dep[u]) x = fa[x][w];         update(1, 1, n, dfn[x], dfn[v] - 1, k);         update(1, 1, n, dfn[v] + siz[v], dfn[x] + siz[x] - 1, k);       } else {         update(1, 1, n, 1, dfn[u] - 1, k);         update(1, 1, n, dfn[u] + siz[u], dfn[v] - 1, k);         update(1, 1, n, dfn[v] + siz[v], n, k);       }       printf( %d n , n - sum[1]);     }     return 0;   }   