func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 15;   const int inf = 1e9;   const int md = 1e9 + 7;   const int shift = 1 << 17;   int n, m;   vector<vector<int> > g;   set<pair<int, int> > br;   int timer;   int tin[maxn], fup[maxn];   int used[maxn];   void dfs(int v, int p = -1) {     used[v] = 1;     tin[v] = fup[v] = timer++;     for (int i = 0; i < g[v].size(); ++i) {       int to = g[v][i];       if (to == p) continue;       if (used[to])         fup[v] = min(fup[v], tin[to]);       else {         dfs(to, v);         fup[v] = min(fup[v], fup[to]);         if (fup[to] > tin[v]) {           br.insert(make_pair(to, v));           br.insert(make_pair(v, to));         }       }     }   }   int color[maxn];   int first[maxn];   int d[maxn];   vector<int> eu;   int z[shift * 2];   int c;   void dfs2(int v, int tekc, int len, int p = -1) {     used[v] = 1;     color[v] = tekc;     d[tekc] = len;     for (int i = 0; i < g[v].size(); ++i) {       int to = g[v][i];       if (to == p) continue;       if (used[to]) continue;       if (br.find(make_pair(v, to)) != br.end()) {         eu.push_back(c + 1);         first[c + 1] = eu.size() - 1;         ++c;         dfs2(to, c, len + 1, v);         eu.push_back(tekc);       } else         dfs2(to, tekc, len, v);     }   }   void build() {     for (int i = 0; i < eu.size(); ++i) z[i + shift] = eu[i];     for (int i = eu.size(); i < shift; ++i) z[i + shift] = n + 1;     for (int i = shift - 1; i > 0; --i)       if (d[z[i * 2]] < d[z[i * 2 + 1]])         z[i] = z[i * 2];       else         z[i] = z[i * 2 + 1];   }   int get(int v, int tl, int tr, int l, int r) {     if (l > r) return n + 1;     if (l == tl && r == tr) return z[v];     int tm = (tl + tr) / 2;     int ans1 = get(v * 2, tl, tm, l, min(r, tm));     int ans2 = get(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r);     return d[ans1] < d[ans2] ? ans1 : ans2;   }   int main() {     cin >> n >> m;     g.resize(n);     for (int i = 0; i < m; ++i) {       int v, u;       cin >> v >> u;       --v, --u;       g[v].push_back(u);       g[u].push_back(v);     }     dfs(0);     memset(used, 0, sizeof(used));     memset(first, -1, sizeof(first));     eu.push_back(0);     first[0] = 0;     dfs2(0, 0, 0);     d[n + 1] = inf;     build();     int k;     cin >> k;     for (int i = 0; i < k; ++i) {       int s, l;       cin >> s >> l;       --s, --l;       int L = first[color[s]];       int R = first[color[l]];       if (L > R) swap(L, R);       int lca = get(1, 0, shift - 1, L, R);       cout << d[color[s]] + d[color[l]] - 2 * d[lca] << endl;     }     return 0;   }   