malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int D = 505;   const int N = 5005;   pair<int, int> pre[D][N];   int ans[D][N];   void solve() {     memset(pre, -1, sizeof(pre));     memset(ans, -1, sizeof(ans));     int d, s;     cin >> d >> s;     queue<pair<int, int> > que;     que.push(pair<int, int>(0, 0));     vector<int> vec;     while (!que.empty()) {       pair<int, int> u = que.front();       que.pop();       if (u.first == 0 && u.second == s) {         pair<int, int> cur = u;         while (!(cur.first == 0 && cur.second == 0)) {           vec.push_back(ans[cur.first][cur.second]);           cur = pre[cur.first][cur.second];         }         break;       }       for (int i = 0; i <= 9; i++) {         pair<int, int> v = pair<int, int>((u.first * 10 + i) % d, u.second + i);         if (v.second <= s && ans[v.first][v.second] == -1) {           ans[v.first][v.second] = i;           pre[v.first][v.second] = u;           que.push(v);         }       }     }     if (!vec.size())       printf( -1 n );     else {       reverse(vec.begin(), vec.end());       for (auto i : vec) putchar(i +  0 );       printf(  n );     }   }   int main() {     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 1e6 + 5, MOD = 998244353;   int m, n, k;   long long res;   int free_Row, free_Col, line_vert, line_hori;   int Num_Row[N], Num_Row2[N][2], Num_Col[N], Num_Col2[N][2];   int c[2][2];   map<pair<int, int>, int> M;   long long power(long long x, int k) {     long long ans = 1;     while (k) {       if (k & 1) ans = ans * x % MOD;       x = x * x % MOD;       k >>= 1;     }     return ans;   }   void Calculate() {     res = 0;     if (line_vert && line_hori) return;     if (!line_vert) (res += power(2, free_Row)) %= MOD;     if (!line_hori) (res += power(2, free_Col)) %= MOD;     if (!line_vert && !line_vert) {       if (c[0][0] == 0 && c[1][1] == 0) (res += MOD - 1) %= MOD;       if (c[0][1] == 0 && c[1][0] == 0) (res += MOD - 1) %= MOD;     }   }   void Delete(int x, int y) {     if (!M.count({x, y})) return;     int z = M[{x, y}];     M.erase({x, y});     --c[z][(x + y) & 1];     if (--Num_Row[x] == 0) ++free_Row;     if (--Num_Row2[x][z ^ (y & 1)] == 0 && Num_Row[x]) --line_vert;     if (--Num_Col[y] == 0) ++free_Col;     if (--Num_Col2[y][z ^ (x & 1)] == 0 && Num_Col[y]) --line_hori;   }   void Add(int x, int y, int z) {     M[{x, y}] = z;     ++c[z][(x + y) & 1];     if (Num_Row[x]++ == 0) --free_Row;     if (Num_Row2[x][z ^ (y & 1)]++ == 0 && Num_Row[x] > 1) ++line_vert;     if (Num_Col[y]++ == 0) --free_Col;     if (Num_Col2[y][z ^ (x & 1)]++ == 0 && Num_Col[y] > 1) ++line_hori;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cin >> m >> n >> k;     free_Row = m;     free_Col = n;     line_hori = 0;     line_vert = 0;     int x, y, z;     while (k--) {       cin >> x >> y >> z;       Delete(x, y);       if (z >= 0) Add(x, y, z);       Calculate();       cout << res <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 10000;   vector<int> vec(N);   int main() {     int n, m;     cin >> n >> m;     for (int i = 0; i < n; i++) {       cin >> vec[i];     }     sort(vec.begin(), vec.begin() + n);     int sum = 0;     for (int i = 0; i < m; i++) {       sum += vec[i];     }     cout << sum << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t, i;     string s;     cin >> t;     while (t--) {       cin >> s;       int cap = 0, sm = 0, dig = 0;       for (i = 0; i < s.size(); i++) {         if (s[i] >= 65 && s[i] <= 90) {           cap++;         } else if (s[i] >= 97 && s[i] <= 122) {           sm++;         } else if (s[i] >= 48 && s[i] <= 57) {           dig++;         }       }       if (sm == 0) {         if (cap > 1) {           for (i = 0; i < s.size(); i++) {             if (s[i] >= 65 && s[i] <= 90) {               s[i] =  a ;               break;             }           }         } else if (dig > 1) {           for (i = 0; i < s.size(); i++) {             if (s[i] >= 48 && s[i] <= 57) {               s[i] =  a ;               break;             }           }         } else {           s = s +  a ;         }       }       if (cap == 0) {         if (sm > 1) {           for (i = 0; i < s.size(); i++) {             if (s[i] >= 97 && s[i] <= 122) {               s[i] =  A ;               break;             }           }         } else if (dig > 1) {           for (i = 0; i < s.size(); i++) {             if (s[i] >= 48 && s[i] <= 57) {               s[i] =  A ;               break;             }           }         } else {           s = s +  A ;         }       }       if (dig == 0) {         if (cap > 1) {           for (i = 0; i < s.size(); i++) {             if (s[i] >= 65 && s[i] <= 90) {               s[i] =  1 ;               break;             }           }         } else if (sm > 1) {           for (i = 0; i < s.size(); i++) {             if (s[i] >= 97 && s[i] <= 122) {               s[i] =  1 ;               break;             }           }         } else {           s = s +  1 ;         }       }       cout << s << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool BeauYear(int y) {     int a = y % 10;     int b = (y / 10) % 10;     int c = (y / 100) % 10;     int d = (y / 1000) % 10;     if (a != b && a != c && a != d && b != c && b != d && c != d) return true;     return false;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int year;     cin >> year;     for (int i = year + 1; i <= 9012; i++) {       if (BeauYear(i) == true) {         cout << i;         i = 9013;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100005;   int n, a, b, q, p[N], d[N];   vector<pair<int, int> > g[N];   int dp[N][17], v, ud[N], ans[N];   bool vis[N];   void dfs(int u) {     vis[u] = 1;     for (int i = 0; i < (int)g[u].size(); ++i) {       v = g[u][i].first;       if (!vis[v]) {         p[v] = u;         d[v] = d[u] + 1;         dfs(v);       }     }   }   int lca(int a, int b) {     if (d[a] < d[b]) swap(a, b);     int log = 0;     for (; (1 << log) <= d[a]; ++log)       ;     --log;     for (int i = log; i >= 0; --i) {       if (d[a] - (1 << i) >= d[b]) a = dp[a][i];     }     if (a == b) return a;     for (int i = log; i >= 0; --i) {       if (dp[a][i] != dp[b][i]) {         a = dp[a][i];         b = dp[b][i];       }     }     return p[a];   }   int DFS(int u) {     vis[u] = 1;     for (int i = 0; i < (int)g[u].size(); ++i) {       int v = g[u][i].first;       if (!vis[v]) {         ud[u] += DFS(v);         ans[g[u][i].second] = ud[v];       }     }     return ud[u];   }   int main(int argc, char **argv) {     scanf( %d , &n);     for (int i = 1; i < n; ++i) {       scanf( %d%d , &a, &b);       g[a].push_back(make_pair(b, i));       g[b].push_back(make_pair(a, i));     }     memset(p, -1, sizeof p);     memset(dp, -1, sizeof dp);     dfs(1);     for (int i = 0; i <= n; ++i) dp[i][0] = p[i];     for (int j = 1; (1 << j) <= n; ++j) {       for (int i = 0; i <= n; ++i) {         if (dp[i][j - 1] != -1) dp[i][j] = dp[dp[i][j - 1]][j - 1];       }     }     scanf( %d , &q);     int LCA;     while (q--) {       scanf( %d%d , &a, &b);       LCA = lca(a, b);       ++ud[a], ++ud[b], ud[LCA] -= 2;     }     memset(vis, 0, sizeof vis);     DFS(1);     for (int i = 1; i < n; ++i) {       if (i > 1) printf(   );       printf( %d , ans[i]);     }     puts(  );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string tobinary(long long x) {     string ret;     char ch;     while (x) ch =  0  + (x % 2), ret = ch + ret, x /= 2;     return ret;   }   long long todecimal(string s) {     int sz = s.size();     long long ret = 0;     for (int i = 0; i < sz; i++) ret = 2 * ret + (s[i] -  0 );     return ret;   }   bool _greater(string s, string t) {     int n = s.size(), m = t.size();     if (n > m) return true;     if (n < m) return false;     for (int i = 0; i < n; i++) {       if (s[i] > t[i])         return true;       else if (s[i] < t[i])         return false;     }     return false;   }   long long eval(long long l, long long r) {     string s = tobinary(l), t = tobinary(r), ret = s;     while (1) {       if (_greater(s, t)) break;       ret = s;       int sz = s.size();       bool ok = false;       for (int i = sz - 1; i >= 0; i--)         if (s[i] ==  0 ) {           s[i] =  1 ;           ok = true;           break;         }       if (!ok) {         s =  1  + s;         int n = s.size(), m = t.size();         if (n > m) break;       }     }     return todecimal(ret);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n;     cin >> n;     while (n--) {       long long l, r;       cin >> l >> r;       cout << eval(l, r) << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<pair<int, int> > points;   pair<int, int> dif(pair<int, int> pa, pair<int, int> pb) {     pair<int, int> res;     res.first = pb.first - pa.first;     res.second = pb.second - pa.second;     return res;   }   int dot(pair<int, int> a, pair<int, int> b) {     return a.first * b.first + a.second * b.second;   }   double dist(pair<int, int> a, pair<int, int> b) {     return ((double)((a.first - b.first) * (a.first - b.first) +                      (a.second - b.second) * (a.second - b.second)));   }   double len(pair<int, int> a) { return dist(a, make_pair(0, 0)); }   int main() {     for (int i = 0; i < 8; i++) {       int x, y;       cin >> x >> y;       points.push_back(make_pair(x, y));     }     vector<int> perm;     for (int i = 0; i < 8; i++) perm.push_back(i);     int cnt = 0;     bool found = false;     do {       cnt++;       bool fs = false, ss = false;       bool fis = true, sif = true;       pair<int, int> a = points[perm[0]];       pair<int, int> b = points[perm[1]];       pair<int, int> c = points[perm[2]];       pair<int, int> d = points[perm[3]];       pair<int, int> e = points[perm[4]];       pair<int, int> f = points[perm[5]];       pair<int, int> g = points[perm[6]];       pair<int, int> h = points[perm[7]];       pair<int, int> ab = dif(a, b);       pair<int, int> bc = dif(b, c);       pair<int, int> cd = dif(c, d);       pair<int, int> da = dif(d, a);       fs = (dot(ab, bc) == 0 && dot(bc, cd) == 0 && dot(cd, da) == 0 &&             dot(da, ab) == 0 && fabs(len(ab) - len(bc)) < 0.01 &&             fabs(len(bc) - len(cd)) < 0.01 && fabs(len(cd) - len(da)) < 0.01);       pair<int, int> ef = dif(e, f);       pair<int, int> fg = dif(f, g);       pair<int, int> gh = dif(g, h);       pair<int, int> he = dif(h, e);       ss = (dot(ef, fg) == 0 && dot(fg, gh) == 0 && dot(gh, he) == 0 &&             dot(he, ef) == 0 && fabs(len(ef) - len(gh)) < 0.01 &&             fabs(len(fg) - len(he)) < 0.01);       if (ss && fs) {         found = true;         break;       }     } while (next_permutation(perm.begin(), perm.end()));     if (found) {       cout <<  YES  << endl;       for (int i = 0; i < 4; i++) {         if (i != 0) cout <<    ;         cout << perm[i] + 1;       }       cout << endl;       for (int i = 4; i < 8; i++) {         if (i != 4) cout <<    ;         cout << perm[i] + 1;       }       cout << endl;     } else       cout <<  NO  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   int n;   char s[5001];   int dp[5001][5001];   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i) {       scanf(  n%c , &s[i]);     }     dp[1][0] = 1;     for (int j = 1; j <= n; ++j) {       dp[1][j] = 0;     }     for (int i = 2; i <= n; ++i) {       if (s[i - 1] ==  f ) {         for (int j = 1; j <= n; ++j) {           dp[i][j] = dp[i - 1][j - 1];         }       } else {         int x = 0;         for (int j = n; j >= 0; --j) {           x += dp[i - 1][j];           if (x >= mod) {             x -= mod;           }           dp[i][j] = x;         }       }     }     int res = 0;     for (int i = 0; i <= n; ++i) {       res += dp[n][i];       if (res >= mod) {         res -= mod;       }     }     cout << res <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using lli = long long;   using Double = long double;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     string s[9][3];     for (int i = 0; i < 9; ++i) {       for (int j = 0; j < 3; ++j) {         cin >> s[i][j];       }     }     int x, y, cnt = 0;     cin >> x >> y, --x, --y;     for (auto c : s[x % 3 * 3][y % 3]) cnt += c ==  . ;     for (auto c : s[x % 3 * 3 + 1][y % 3]) cnt += c ==  . ;     for (auto c : s[x % 3 * 3 + 2][y % 3]) cnt += c ==  . ;     if (cnt == 0) {       for (int i = 0; i < 9; ++i) {         for (int j = 0; j < 3; ++j) {           for (auto c : s[i][j]) {             cout << (c ==  .  ?  !  : c);           }           cout <<    n [j == 2];         }         if (i % 3 == 2) cout <<   n ;       }     } else {       for (int i = 0; i < 9; ++i) {         for (int j = 0; j < 3; ++j) {           for (auto c : s[i][j]) {             cout << (c ==  .  and i / 3 == x % 3 and j == y % 3 ?  !  : c);           }           cout <<    n [j == 2];         }         if (i % 3 == 2) cout <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char str[606];   long long tmp[80];   long long mat[2000][32];   int see[2000];   int main() {     int M;     scanf( %d , &M);     for (int i = 0; i < M; i++) {       scanf( %s , str);       int len = 0;       while (str[len]) len++;       for (int j = 0; j < 80; j++) tmp[j] = 0;       for (int j = 0; j < len; j++) {         long long &t = tmp[(len - j - 1) / 8];         t = t * 10 + str[j] -  0 ;       }       for (int j = 0; j < 250; j++) {         long long t = tmp[0] & 255;         for (int k = 0; k < 8; k++)           if (t & (1 << k)) mat[j * 8 + k][i / 64] |= 1ll << (i % 64);         for (int k = 79; k; k--) {           tmp[k - 1] += (tmp[k] & 255) * 100000000ll;           tmp[k] >>= 8;         }         tmp[0] >>= 8;       }     }     for (int i = 0, j = 0; i < 2000 && j < M; j++) {       bool seen = false;       for (int k = i; k < 2000; k++) {         if (mat[k][j / 64] & (1ll << (j % 64))) {           for (int l = j / 64; l < 32; l++) {             swap(mat[i][l], mat[k][l]);           }           seen = true;           break;         }       }       if (!seen) {         int cnt = 0;         for (int k = 0; k < i; k++)           if (mat[k][j / 64] & (1ll << (j % 64))) cnt++;         printf( %d , cnt);         for (int k = 0; k < i; k++)           if (mat[k][j / 64] & (1ll << (j % 64))) printf(  %d , see[k]);         puts(  );         continue;       }       see[i] = j;       printf( 0 n );       for (int k = 0; k < 2000; k++)         if (k != i && (mat[k][j / 64] & (1ll << (j % 64)))) {           for (int l = j / 64; l < 32; l++) mat[k][l] ^= mat[i][l];         }       i++;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxm = 2e5 + 10;   set<int> g;   queue<set<int> > q;   int m, n, x, y;   int dfs(int top) {     if (abs(top) <= 1) return 0;     int now = 0;     if ((-top) % 2 == 0)       now = top / 2;     else       now = (top + 1) / 2;     if (g.find(now) == g.end()) {       g.erase(top);       g.insert(now);       return 1;     } else       return dfs(now);   }   int main() {     cin >> m;     for (int i = 1; i <= m; i++) {       cin >> x;       g.insert(-x);     }     for (;;) {       int top = *g.begin();       if (!dfs(top)) break;     }     for (auto e : g) cout << -e <<    ;     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> v;   int qtd[100001];   int main() {     int n;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       int a;       scanf( %d , &a);       v.push_back(a);     }     sort(v.begin(), v.end());     int cont = 0;     for (int i = 1, tmp = 0; i < n; i++) {       if (v[i] > v[i - 1]) {         cont += i - tmp;         tmp = i;       }       qtd[i] = cont;     }     int ans = 0;     int used = 0;     for (int i = 0; i < n; i++) {       if (qtd[i] > used) {         used++;         ans++;       }     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct W {     int t, l, r;   } w[100010];   int n, m, s, f;   int main() {     while (cin >> n >> m >> s >> f) {       for (int i = (0); i < (m); i++) {         cin >> w[i].t >> w[i].l >> w[i].r;       }       int t = 1, p = 0;       int dir = f > s ? 1 : -1;       while (s != f) {         if (p < m && w[p].t == t &&             ((w[p].l <= s && s <= w[p].r) ||              (w[p].l <= s + dir && s + dir <= w[p].r))) {           cout <<  X ;         } else {           s += dir;           cout << (dir == 1 ?  R  :  L );         }         if (++t > w[p].t) p++;       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 1e9;   int n, d, p[30005], dp1[60005][700];   int occ[30005];   int main() {     scanf( %d%d , &n, &d);     int xb, x2, x3;     for (xb = 0; xb < n; xb++) {       scanf( %d , &p[xb]);       p[xb]--;       occ[p[xb]]++;     }     d--;     int res = 0;     for (xb = 0; xb < 60005; xb++) {       for (x3 = 0; x3 < 700; x3++) dp1[xb][x3] = -inf;     }     dp1[d][350] = 0;     for (xb = d; xb < 30000; xb++) {       for (x3 = 0; x3 < 700; x3++) {         if (dp1[xb][x3] == -inf) continue;         int tv = d + x3 - 349, adg = occ[xb];         if (tv > 0)           res = (((res) > (adg + dp1[xb][x3])) ? (res) : (adg + dp1[xb][x3]));         if (tv > 1)           dp1[xb + tv - 1][x3 - 1] =               (((dp1[xb + tv - 1][x3 - 1]) > (dp1[xb][x3] + adg))                    ? (dp1[xb + tv - 1][x3 - 1])                    : (dp1[xb][x3] + adg));         if (tv > 0)           dp1[xb + tv][x3] =               (((dp1[xb + tv][x3]) > (dp1[xb][x3] + adg)) ? (dp1[xb + tv][x3])                                                           : (dp1[xb][x3] + adg));         if (tv > -1)           dp1[xb + tv + 1][x3 + 1] =               (((dp1[xb + tv + 1][x3 + 1]) > (dp1[xb][x3] + adg))                    ? (dp1[xb + tv + 1][x3 + 1])                    : (dp1[xb][x3] + adg));       }     }     printf( %d n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 100;   int t, cnt[N];   int mx;   int check(int row, int col, int n, int m) {     if (row < 0 || row >= n || col < 0 || col >= m) return 0;     int i = 0, j = 0, ok = 1;     for (; i < n; i++) {       for (j = 0; j < m; j++) {         if (!cnt[abs(row - i) + abs(col - j)]--) {           ok = 0;           break;         }       }       if (!ok) break;     }     if (ok) {       cout << n <<     << m << endl;       cout << row + 1 <<     << col + 1 << endl;       return 1;     }     for (int a = 0; a <= i; a++)       for (int b = 0; b < m && (a != i || b <= j); b++)         ++cnt[abs(row - a) + abs(col - b)];     return 0;   }   bool solve(int row, int n, int m, int mxi, int mxj) {     if (check(row, mxj - (mx - abs(row - mxi)), n, m)) return 1;     return check(row, mxj + (mx - abs(row - mxi)), n, m);   }   int main() {     scanf( %d , &t);     for (int i = 0; i < t; ++i) {       int v;       scanf( %d , &v);       ++cnt[v];       mx = max(mx, v);     }     if (cnt[0] != 1) return puts( -1 );     int a;     if (cnt[1] != 4)       a = 0;     else {       a = 1;       while (cnt[a + 1] == (a + 1) * 4) a++;     }     for (int n = 1; n * n <= t; n++) {       if (t % n) continue;       int m = t / n;       if (solve(a, n, m, 0, 0)) return 0;       if (solve(a, n, m, 0, m - 1)) return 0;       if (solve(a, n, m, n - 1, 0)) return 0;       if (solve(a, n, m, n - 1, m - 1)) return 0;       if (solve(a, m, n, 0, 0)) return 0;       if (solve(a, m, n, 0, n - 1)) return 0;       if (solve(a, m, n, m - 1, 0)) return 0;       if (solve(a, m, n, m - 1, n - 1)) return 0;     }     return puts( -1 );   }
#include <bits/stdc++.h>   int main() {     int i, j;     int str[6];     int num[6];     char ch;     for (i = 0; i < 6; i++) {       str[i] = 0;       num[i] = 0;     }     for (i = 0; i < 6; i++) {       scanf( %c , &ch);       switch (ch) {         case  R :           str[0]++;           break;         case  O :           str[1]++;           break;         case  Y :           str[2]++;           break;         case  G :           str[3]++;           break;         case  B :           str[4]++;           break;         case  V :           str[5]++;           break;       }     }     for (j = 0; j < 6; j++) {       num[str[j]]++;     }     switch (num[0]) {       case 0:         printf( 30 n );         break;       case 1:         printf( 15 n );         break;       case 2:         switch (num[1]) {           case 2:             printf( 8 n );             break;           case 3:             printf( 5 n );             break;         }         break;       case 3:         switch (num[1]) {           case 2:             printf( 2 n );             break;           case 1:             printf( 3 n );             break;           case 0:             printf( 6 n );             break;         }         break;       case 4:         switch (num[1]) {           case 1:             printf( 1 n );             break;           case 0:             printf( 2 n );             break;         }         break;       case 5:         printf( 1 n );         break;     }   }
#include <bits/stdc++.h>   using namespace std;   int Head[1000010], Next[1000010], Go[1000010], Val[1000010], iscut[1000010],       Len[1000010], Dep[1000010], Fa[400010][21], Cnt = 1, n, m, q;   int Head2[1000010], Next2[1000010], Go2[1000010], Val2[1000010], Cnt2 = 1;   int DFN[1000010], MIN[1000010], ins[1000010], Bel[1000010], vis[1000010],       tim = 0, tt = 0;   vector<int> S;   void addedge(int x, int y) {     Go[++Cnt] = y;     Next[Cnt] = Head[x];     Head[x] = Cnt;   }   void addedge2(int x, int y, int v) {     Go2[++Cnt2] = y;     Next2[Cnt2] = Head2[x];     Head2[x] = Cnt2;     Val2[Cnt2] = v;   }   void Tarjan(int x, int f = 0) {     ins[x] = 1;     S.push_back(x);     DFN[x] = ++tim;     MIN[x] = DFN[x];     int las = x;     for (int T = Head[x]; T; T = Next[T])       if (Go[T] != f) {         if (!DFN[Go[T]]) {           Tarjan(Go[T], x);           MIN[x] = min(MIN[x], MIN[Go[T]]);           if (DFN[x] <= MIN[Go[T]]) {             tt++;             for (;;) {               if (S.back() == las) break;               addedge2(tt + n + 1, S.back(), 1);               addedge2(S.back(), tt + n + 1, 1);               S.pop_back();             }             addedge2(x, tt + n + 1, 1);             addedge2(tt + n + 1, x, 1);           } else             las = S.back();         } else if (ins[Go[T]])           MIN[x] = min(MIN[x], DFN[Go[T]]);       }     ins[x] = 0;   }   void DFS2(int x, int dep = 1, int len = 0) {     vis[x] = 1;     Len[x] = len;     Dep[x] = dep;     for (int T = Head[x]; T; T = Next[T])       if (!vis[Go[T]]) {         Fa[Go[T]][0] = x;         DFS2(Go[T], dep + 1, len + Val[T]);       }   }   int lca(int x, int y) {     if (Dep[x] < Dep[y]) swap(x, y);     int det = Dep[x] - Dep[y];     for (int i = 18; i >= 0; i--)       if ((det >> i) & 1) x = Fa[x][i];     if (x == y) return x;     for (int i = 18; i >= 0; i--)       if (Fa[x][i] != Fa[y][i]) x = Fa[x][i], y = Fa[y][i];     return Fa[x][0];   }   int main() {     scanf( %d%d%d , &n, &m, &q);     for (int i = 1; i <= m; i++) {       int a, b;       scanf( %d%d , &a, &b);       addedge(a, b);       addedge(b, a);     }     for (int i = 1; i <= n; i++)       if (!DFN[i]) Tarjan(i);     memcpy(Head, Head2, sizeof Head);     memcpy(Next, Next2, sizeof Next);     memcpy(Go, Go2, sizeof Go);     memcpy(Val, Val2, sizeof Val);     for (int i = 1; i <= n + tt + 1; i++)       if (!vis[i]) DFS2(i);     for (int i = 1; i <= 20; i++)       for (int j = 1; j <= n + tt + 1; j++) Fa[j][i] = Fa[Fa[j][i - 1]][i - 1];     for (int i = 1; i <= q; i++) {       int a, b;       scanf( %d%d , &a, &b);       printf( %d n , (Len[a] + Len[b] - 2 * Len[lca(a, b)]) / 2);     }     return 0;   }