func_code_string: #include <bits/stdc++.h>   using namespace std;   const double eps = 1e-8;   const int inf = 0x3f3f3f3f;   const int Minf = 0x7f7f7f7f;   const long long INF = 0x3f3f3f3f3f3f3f3fll;   const long long MINF = 0x7f7f7f7f7f7f7f7fll;   const int N = 2e5 + 50;   vector<int> t[N];   int dfn[N], rig[N];   int fa[N][20], dep[N];   void dfs(int now, int f) {     fa[now][0] = f;     dfn[now] = ++dfn[0];     dep[now] = dep[f] + 1;     for (int i = (1); i <= 19; ++i) fa[now][i] = fa[fa[now][i - 1]][i - 1];     for (int to : t[now]) {       if (to == f) continue;       dfs(to, now);     }     rig[now] = dfn[0];   }   struct node {     int l, r;     int tag;     int mxn;     int cnt;   };   struct seg {     node t[N << 2];     void updata(int now) {       t[now].mxn = max(t[(now << 1)].mxn, t[(now << 1 | 1)].mxn);       t[now].cnt = 0;       if (t[now].mxn == t[(now << 1)].mxn) t[now].cnt += t[(now << 1)].cnt;       if (t[now].mxn == t[(now << 1 | 1)].mxn)         t[now].cnt += t[(now << 1 | 1)].cnt;     }     void bt(int now, int l, int r) {       t[now].l = l;       t[now].r = r;       if (l == r) {         t[now].mxn = 0;         t[now].cnt = 1;         return;       }       bt((now << 1), l, ((t[now].l + t[now].r) >> 1));       bt((now << 1 | 1), ((t[now].l + t[now].r) >> 1) + 1, r);       updata(now);     }     void pushdown(int now) {       if (!t[now].tag) return;       t[(now << 1)].mxn += t[now].tag;       t[(now << 1)].tag += t[now].tag;       t[(now << 1 | 1)].mxn += t[now].tag;       t[(now << 1 | 1)].tag += t[now].tag;       t[now].tag = 0;     }     void change(int now, int l, int r, int v) {       if (l <= t[now].l && t[now].r <= r) {         t[now].mxn += v;         t[now].tag += v;         return;       }       pushdown(now);       if (l <= ((t[now].l + t[now].r) >> 1)) change((now << 1), l, r, v);       if (r > ((t[now].l + t[now].r) >> 1)) change((now << 1 | 1), l, r, v);       updata(now);     }   } sgt;   bool in_tree(int y, int x) { return dfn[y] <= rig[x]; }   int main() {     int n, q, x, y;     scanf( %d%d , &n, &q);     for (int i = (2); i <= n; ++i)       scanf( %d%d , &x, &y), t[x].push_back(y), t[y].push_back(x);     dfs(1, 0);     sgt.bt(1, 1, n);     map<pair<int, int>, int> vis;     int link = 0, v = 0;     for (int i = (1); i <= q; ++i) {       scanf( %d%d , &x, &y);       if (dfn[x] > dfn[y]) swap(x, y);       if (vis[make_pair(x, y)])         vis[make_pair(x, y)] = 0, v = -1, --link;       else         vis[make_pair(x, y)] = 1, v = 1, ++link;       if (in_tree(y, x)) {         int u = y;         for (int i = (19); i >= 0; --i)           if (dep[fa[u][i]] > dep[x]) u = fa[u][i];         sgt.change(1, 1, n, v);         sgt.change(1, dfn[u], rig[u], -1 * v);         sgt.change(1, dfn[y], rig[y], v);       } else {         sgt.change(1, dfn[x], rig[x], v);         sgt.change(1, dfn[y], rig[y], v);       }       node ans = sgt.t[1];       if (ans.mxn == link) {         printf( %d n , ans.cnt);       } else         puts( 0 );     }     return 0;   }   