malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long int power(long long int x, long long int y, long long int p) {     long long int res = 1;     x = x % p;     if (x == 0) return 0;     while (y > 0) {       if (y & 1) res = (res * x) % p;       y = y >> 1;       x = (x * x) % p;     }     return res;   }   bool sortinrev(const pair<int, int>& a, const pair<int, int>& b) {     if (a.first == b.first) return b.second > a.second;     return a.first > b.first;   }   void run(vector<int> v) {     for (int i = 0; i < v.size(); i++) cout << v[i] <<    ;     cout << endl;   }   int modInverse(long long int a, long long int m) {     long long int m0 = m;     long long int y = 0, x = 1;     if (m == 1) return 0;     while (a > 1) {       long long int q = a / m;       long long int t = m;       m = a % m, a = t;       t = y;       y = x - q * y;       x = t;     }     if (x < 0) x += m0;     return x;   }   void numberOfNodes(int n, vector<long long int> adj[],                      vector<long long int>& count1, int s, int e) {     vector<long long int>::iterator u;     count1[s] = 1;     for (u = adj[s].begin(); u != adj[s].end(); u++) {       if (*u == e) continue;       numberOfNodes(n, adj, count1, *u, s);       count1[s] += count1[*u];     }   }   void solve() {     int n, k, unhappy = 0;     cin >> n >> k;     vector<pair<int, int>> edges;     vector<int> adj[n + 1];     unordered_map<int, int> mp[n + 1];     vector<bool> vis(n + 1, 0);     for (int i = 0; i < k; i++) {       int x, y;       cin >> x >> y;       if (mp[x].find(y) == mp[x].end()) {         mp[x][y]++;         mp[y][x]++;         edges.push_back({x, y});         adj[x].push_back(y);         adj[y].push_back(x);       }     }     unhappy += (k - edges.size());     k -= unhappy;     queue<int> q;     int ans = 0;     for (int i = 1; i <= n; i++) {       if (!vis[i]) {         q.push(i);         vector<int> vec;         vis[i] = 1;         vec.push_back(i);         while (!q.empty()) {           int p = q.front();           q.pop();           for (int j = 0; j < adj[p].size(); j++) {             if (!vis[adj[p][j]]) {               vec.push_back(adj[p][j]);               vis[adj[p][j]] = 1;               q.push(adj[p][j]);             }           }         }         ans += (vec.size() - 1);       }     }     cout << unhappy + k - ans << endl;   }   int main() {     int t;     t = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const double esp = 0.0000000001;   const double PI = acos(-1.0);   const int mod = 1e9 + 7;   const int MY = 1400 + 5;   const int MX = 1010 + 5;   int num, n, k;   vector<int> G[MX];   int d[MX * MX], g[MX][MX], vis[MX];   struct node {     int x, y;   } P[MX];   bool dfs(int cnt, int m) {     if (cnt > n) return true;     if (vis[cnt]) return dfs(cnt + 1, m);     for (int i = 0; i < (int)G[cnt].size(); ++i) {       m += !vis[G[cnt][i]];       vis[G[cnt][i]]++;     }     if (m <= k && dfs(cnt + 1, m)) return true;     int temp = m;     for (int i = 0; i < (int)G[cnt].size(); ++i) {       vis[G[cnt][i]]--;       m -= !vis[G[cnt][i]];     }     if (G[cnt].size() != 1) {       vis[cnt]++;       if (m + 1 <= k && m + 1 < temp && dfs(cnt + 1, m + 1)) return true;       vis[cnt]--;     }     return false;   }   bool judge(int dist) {     memset(vis, false, sizeof(vis));     for (int i = 1; i <= n; ++i) G[i].clear();     for (int i = 1; i < n; ++i)       for (int j = i + 1; j <= n; ++j)         if (g[i][j] > dist) {           G[i].push_back(j);           G[j].push_back(i);         }     return dfs(1, 0);   }   int binary_search(int le, int rt) {     int mid;     while (le < rt) {       mid = (le + rt) >> 1;       if (judge(d[mid]))         rt = mid;       else         le = mid + 1;     }     return le;   }   int main() {     while (~scanf( %d%d , &n, &k)) {       num = 0;       d[0] = 0;       for (int i = 1; i <= n; ++i) scanf( %d%d , &P[i].x, &P[i].y);       for (int i = 1; i < n; ++i)         for (int j = i + 1; j <= n; ++j)           d[++num] = g[i][j] = (P[i].x - P[j].x) * (P[i].x - P[j].x) +                                (P[i].y - P[j].y) * (P[i].y - P[j].y);       sort(d, d + num + 1);       num = unique(d, d + num + 1) - d - 1;       int mx = binary_search(0, num);       judge(d[mx]);       bool first = false;       for (int i = n; i >= 1; --i)         if (vis[i]) {           if (first) putchar(   );           printf( %d , i);           k--;           first = true;         }       for (int i = n; i >= 1 && k > 0; --i)         if (!vis[i]) {           if (first) putchar(   );           printf( %d , i);           k--;           first = true;         }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long int MAXN = 2e5 + 51;   long long int n, r;   long long int prefix[MAXN], f[MAXN];   inline long long int read() {     register long long int num = 0, neg = 1;     register char ch = getchar();     while (!isdigit(ch) && ch !=  - ) {       ch = getchar();     }     if (ch ==  - ) {       neg = -1;       ch = getchar();     }     while (isdigit(ch)) {       num = (num << 3) + (num << 1) + (ch -  0 );       ch = getchar();     }     return num * neg;   }   int main() {     n = read();     for (register int i = 1; i <= n; i++) {       prefix[i] = prefix[i - 1] + read();     }     r = prefix[n];     for (register int i = n - 1; i >= 1; i--) {       f[i] = r, r = max(r, prefix[i] - f[i]);     }     printf( %lld n , f[1]);   }
#include <bits/stdc++.h>   using namespace std;   const long long int INF = 2e18;   const long long int N = 2e5 + 5;   bool isPrime(long long int n) {     if (n <= 1) return false;     if (n <= 3) return true;     if (n % 2 == 0 || n % 3 == 0) return false;     for (long long int i = 5; i * i <= n; i = i + 6) {       if (n % i == 0 || n % (i + 2) == 0) return false;     }     return true;   }   long long int factorial(long long int n) {     long long int ans = 1;     for (long long int i = 1; i <= n; i++) ans = (ans * i) % 1000000007;     return ans;   }   long long int exp(long long int x, long long int n) {     long long int res = 1;     while (n > 0) {       if (n % 2 == 1) res = (res * x) % 1000000007;       x = (x * x) % 1000000007;       n = n / 2;     }     return res;   }   void null() {     long long int n;     cin >> n;     char a[n][n];     for (long long int i = 0; i < n; i++) {       for (long long int j = 0; j < n; j++) {         cin >> a[i][j];       }     }     long long int ans = 0;     if (a[0][1] == a[1][0]) {       if (a[n - 1][n - 2] == a[n - 2][n - 1]) {         if (a[n - 1][n - 2] == a[0][1]) {           cout << 2 <<   n ;           cout << 1 <<     << 2 <<   n ;           cout << 2 <<     << 1 <<   n ;           return;         } else {           cout << 0 <<   n ;           return;         }       }       if (a[n - 1][n - 2] != a[n - 2][n - 1]) {         if (a[n - 1][n - 2] == a[0][1]) {           cout << 1 <<   n ;           cout << n <<     << n - 1 <<   n ;           return;         } else if (a[n - 2][n - 1] == a[0][1]) {           cout << 1 <<   n ;           cout << n - 1 <<     << n <<   n ;           return;         }       }     } else {       if (a[n - 1][n - 2] == a[n - 2][n - 1]) {         if (a[0][1] == a[n - 1][n - 2]) {           cout << 1 <<   n ;           cout << 1 <<     << 2 <<   n ;           return;         } else {           cout << 1 <<   n ;           cout << 2 <<     << 1 <<   n ;           return;         }       } else {         cout << 2 <<   n ;         if (a[0][1] == a[n - 1][n - 2]) {           cout << 1 <<     << 2 <<   n ;           cout << n - 1 <<     << n <<   n ;           return;         } else if (a[0][1] == a[n - 2][n - 1]) {           cout << 1 <<     << 2 <<   n ;           cout << n <<     << n - 1 <<   n ;           return;         }       }     }   }   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long int t = 1;     clock_t start, end;     start = clock();     cin >> t;     while (t--) {       null();     }     end = clock();     double time_taken = double(end - start) / double(CLOCKS_PER_SEC);   }
#include <bits/stdc++.h>   using namespace std;   void optimise() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);   }   void solve() {     string s;     cin >> s;     string s2;     cin >> s2;     sort(s.begin(), s.end());     for (long long int i = 0; i < s.size(); i++) {       for (long long int j = i + 1; j < s.size(); j++) {         string k = s;         swap(k[i], k[j]);         if (stoll(k) >= stoll(s) && stoll(k) <= stoll(s2)) s = k;       }     }     cout << s;   }   signed main() {     optimise();     long long int t = 1;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline T modinv(T a, T n) {     T i = n, v = 0, d = 1;     while (a > 0) {       T t = i / a, x = a;       a = i % x;       i = x;       x = d;       d = v - t * x;       v = x;     }     return (v + n) % n;   }   long long modpow(long long n, long long k, long long mod) {     if (k == 0) return 1LL;     long long ans = 1;     while (k > 0) {       if (k & 1) ans = (ans * n) % mod;       k >>= 1;       n = (n * n) % mod;     }     return ans % mod;   }   template <class T>   struct Fraction {     T a, b;     Fraction(T a = 0, T b = 1);     string toString();   };   template <class T>   Fraction<T>::Fraction(T a, T b) {     T d = GCD(a, b);     a /= d;     b /= d;     if (b < 0) a = -a, b = -b;     this->a = a;     this->b = b;   }   template <class T>   string Fraction<T>::toString() {     ostringstream sout;     sout << a <<  /  << b;     return sout.str();   }   template <class T>   Fraction<T> operator+(Fraction<T> p, Fraction<T> q) {     return Fraction<T>(p.a * q.b + q.a * p.b, p.b * q.b);   }   template <class T>   Fraction<T> operator-(Fraction<T> p, Fraction<T> q) {     return Fraction<T>(p.a * q.b - q.a * p.b, p.b * q.b);   }   template <class T>   Fraction<T> operator*(Fraction<T> p, Fraction<T> q) {     return Fraction<T>(p.a * q.a, p.b * q.b);   }   template <class T>   Fraction<T> operator/(Fraction<T> p, Fraction<T> q) {     return Fraction<T>(p.a * q.b, p.b * q.a);   }   template <class T>   string str(T Number) {     string Result;     ostringstream convert;     convert << Number;     Result = convert.str();     return Result;   }   int StringToNumber(const string &Text) {     istringstream ss(Text);     int result;     return ss >> result ? result : 0;   }   template <class T>   inline vector<pair<T, int> > FACTORISE(T n) {     vector<pair<T, int> > R;     for (T i = 2; n > 1;) {       if (n % i == 0) {         int C = 0;         for (; n % i == 0; C++, n /= i)           ;         R.push_back(make_pair(i, C));       }       i++;       if (i > n / i) i = n;     }     if (n > 1) R.push_back(make_pair(n, 1));     return R;   }   template <class T>   inline T TOTIENT(T n) {     vector<pair<T, int> > R = FACTORISE(n);     T r = n;     for (int i = 0; i < R.size(); i++) r = r / R[i].first * (R[i].first - 1);     return r;   }   template <class T>   inline T gcd(T a, T b) {     return b ? gcd(b, a % b) : a;   }   double rnd(float d) { return floor(d + 0.49); }   int main() {     string s;     cin >> s;     int k = ({       int x;       scanf( %d , &x);       x;     });     long long ans = 0;     long long n = ((int)(s).size());     long long t = (modpow(2, n, 1000000007) - 1 + 1000000007);     long long inv = modpow(t + 1000000007, 1000000007 - 2, 1000000007);     for (long long i = 0; i < n; i++) {       if ((s[i] - 48) % 5 == 0) {         ans = (ans + modpow(2, i, 1000000007)) % 1000000007;       }     }     cout << (ans * (modpow(2, (k)*n, 1000000007) - 1 + 1000000007) % 1000000007 *              inv) %                 1000000007          <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[50], p[50], b[50];   bool cmp(int x, int y) {     if (a[x] < a[y]) return 1;     return 0;   }   int main() {     int n;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d , &a[i]);       p[i] = i;     }     sort(p, p + n, cmp);     for (int i = 0; i < n - 1; i++) {       b[p[i + 1]] = a[p[i]];     }     b[p[0]] = a[p[n - 1]];     for (int i = 0; i < n; i++) {       printf( %d  , b[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e6 + 100;   int f[maxn];   int a[maxn];   char s[maxn];   int main() {     int d;     scanf( %d , &d);     scanf( %s , s);     int len = strlen(s);     a[1] = s[0] -  0 ;     for (int i = 1; i < len; i++) {       a[i + 1] = a[i] + (s[i] -  0 );     }     for (int i = 1; i <= len; i++) {       for (int j = 0; j < i; j++) {         f[a[i] - a[j]]++;       }     }     long long ans = 0;     for (int i = 1; i < maxn; i++) {       if (d % i) continue;       if ((d / i) >= maxn) continue;       ans += (long long)f[i] * f[d / i];     }     if (d == 0) {       ans = 0;       for (int i = 0; i < maxn; i++) ans += (long long)f[0] * f[i];       ans *= 2;       ans -= (long long)f[0] * f[0];     }     printf( %I64d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   const int kN = 2e5 + 10;   int N, M;   struct Ele {     long long len;     char c;     void read() {       len = 0;       char s[30];       scanf( %s , s);       for (int i = 0; s[i]; i++) {         if (s[i] ==  - ) {           c = s[i + 1];           break;         } else {           len *= 10;           len += s[i] -  0 ;         }       }     }     bool operator==(const Ele &e) const { return len == e.len && c == e.c; }     bool operator!=(const Ele &e) const { return !((*this) == e); }   };   Ele A[kN], B[kN], T[kN];   int tn;   void merge(Ele a[], int &n) {     int p = 0;     for (int i = 1; i <= n; i++) {       if (p && a[p].c == a[i].c) {         a[p].len += a[i].len;       } else {         p++;         a[p] = a[i];       }     }     n = p;   }   bool check(int i, int j) {     return i >= 1 && i <= N && A[i].len >= B[j].len && A[i].c == B[j].c;   }   int lst[kN];   int main() {     scanf( %d %d , &N, &M);     for (int i = 1; i <= N; i++) A[i].read();     for (int i = 1; i <= M; i++) B[i].read();     merge(A, N);     merge(B, M);     for (int i = 2; i < M; i++) T[++tn] = B[i];     long long ans = 0;     if (M == 1) {       for (int i = 1; i <= N; i++) {         if (A[i].c == B[1].c && A[i].len >= B[1].len) {           ans += A[i].len - B[1].len + 1;         }       }     } else {       lst[1] = 0;       for (int i = 2; i <= tn; i++) {         int p = lst[i - 1];         while (p && T[p + 1] != T[i]) p = lst[p];         if (T[p + 1] == T[i]) p++;         lst[i] = p;       }       int j = 0;       for (int i = 1; i <= N; i++) {         while (j < tn && j && T[j + 1] != A[i]) j = lst[j];         if (tn && T[j + 1] == A[i]) j++;         if (j == tn) {           if (check(i + 1, M) && check(i - tn, 1)) {             ans++;           }           j = lst[j];         }       }     }     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 200005;   vector<int> g[N];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n, s;     cin >> n >> s;     for (int i = 0; i < n - 1; ++i) {       int a, b;       cin >> a >> b;       g[a].push_back(b);       g[b].push_back(a);     }     int leaves = 0;     for (int i = 1; i <= n; ++i) {       if (g[i].size() == 1) leaves++;     }     long double ans = (long double)(2 * s) / (long double)leaves;     cout << fixed << setprecision(8) << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void fast() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);   }   long long gcd(long long a, long long b) {     if (b == 0)       return a;     else       gcd(b, a % b);   }   long long lcd(long long a, long long b) { return (a * b) / gcd(a, b); }   int main() {     int t;     cin >> t;     while (t--) {       int n, a[100] = {0};       vector<int> v;       cin >> n;       for (int i = 0; i < 2 * n; i++) {         int temp;         cin >> temp;         if (a[temp] == 0) v.push_back(temp);         a[temp] = 1;       }       for (int i = 0; i < v.size(); i++) cout << v[i] <<    ;       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, a[1010], b[1010], cnt, x[1010], y[1010], z[1010], w[1010];   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i) scanf( %d , &a[i]);     for (int i = 1; i <= n; ++i) scanf( %d , &b[i]);     for (int i = 1; i <= n; ++i) {       if (a[i] == i && b[i] == i) continue;       ++cnt;       for (int j = i; j <= n; ++j)         if (a[j] == i) x[cnt] = j, y[cnt] = i, swap(a[j], a[i]);       for (int j = i; j <= n; ++j)         if (b[j] == i) z[cnt] = i, w[cnt] = j, swap(b[j], b[i]);     }     printf( %d n , cnt);     for (int i = 1; i <= cnt; ++i)       printf( %d %d %d %d n , x[i], y[i], z[i], w[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void fast() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);   }   map<int, int> mpi;   map<string, int> mps;   map<int, vector<int> > path;   map<int, int> visited;   set<int> st;   vector<int> v;   map<int, int>::iterator iti;   map<string, int>::iterator its;   set<int>::iterator sit;   vector<int>::iterator itv;   void fresh() {     mpi.clear();     mps.clear();     st.clear();     v.clear();     path.clear();     visited.clear();   }   int main() {     fast();     int n, a, b, c, d, x1, x2, y1, y2;     int tst;     cin >> tst;     while (tst--) {       cin >> n >> a >> b >> c >> d;       bool flag = false;       for (int i = c - d; i <= c + d; i++) {         if ((i / n) >= (a - b) && (i / n) <= (a + b)) {           int x = ceil((float)i / (float)n);           if (x >= (a - b) && x <= (a + b)) {             flag = true;             break;           }         }       }       if (flag) {         cout <<  YES  << endl;         ;       } else         cout <<  NO  << endl;       ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n;     cin >> n;     long long ans = 1;     for (long long int i = 2; i * i <= n; i++) {       long long int temp = 0;       while (n % i == 0) {         temp++;         n /= i;       }       ans *= (temp + 1);     }     if (n > 1) ans *= 2;     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   bool isGeometrical(int *a, int n) {     if (a[0] == 0) {       for (int i = 0; i < n; i++)         if (a[i] != 0) return false;       return true;     }     for (int i = 0; i < n - 1; i++)       if (a[i + 1] * a[0] != a[i] * a[1]) return false;     return true;   }   int main() {     int n;     scanf( %d , &n);     int a[100000], num0 = 0, pos0 = -1;     for (int i = 0; i < n; i++) {       scanf( %d , a + i);       if (a[i] == 0) {         num0++;         if (pos0 == -1) pos0 = i;       }     }     if (n <= 2) {       printf( %d n , isGeometrical(a, n) ? 0 : 1);       return 0;     }     if (n == 3) {       int ans = 2;       if (isGeometrical(a, n))         ans = 0;       else {         int b[2];         b[0] = a[0], b[1] = a[1];         if (isGeometrical(b, 2)) ans = 1;         b[0] = a[0], b[1] = a[2];         if (isGeometrical(b, 2)) ans = 1;         b[0] = a[1], b[1] = a[2];         if (isGeometrical(b, 2)) ans = 1;       }       printf( %d n , ans);       return 0;     }     if (num0 >= 2) {       int cnt = 0;       for (int i = 1; i < n; i++)         if (a[i] != 0) cnt++;       printf( %d n , min(cnt, 2));       return 0;     }     if (num0 == 1) {       for (int i = pos0; i < n - 1; i++) a[i] = a[i + 1];       printf( %d n , isGeometrical(a, n - 1) ? 1 : 2);       return 0;     }     if (isGeometrical(a, n)) {       puts( 0 );       return 0;     }     if (isGeometrical(a + 1, n - 1)) {       puts( 1 );       return 0;     }     swap(a[0], a[1]);     if (isGeometrical(a + 1, n - 1)) {       puts( 1 );       return 0;     }     swap(a[0], a[1]);     int cnt = 0;     for (int i = 0; i < n - 1; i++) {       if (a[i + 1] * a[0] != a[i] * a[1]) {         cnt++;         a[i + 1] = a[i];       }       if (cnt == 2) break;     }     printf( %d n , cnt);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, kk, a, b;   double dp[1123][111][111];   int arr[111];   void solve() {     scanf( %d , &n);     ;     scanf( %d , &kk);     ;     kk = min(kk, 1000);     double dd = n * (n + 1) / 2;     double ans = 0.0;     for (int i = 0; i < n; i++) {       scanf( %d , &arr[i]);       ;       for (int j = i + 1; j < n; j++) {         dp[0][i][j] = 1.0;       }     }     for (int k = 1; k <= kk; k++) {       for (int i = 0; i < n; i++) {         for (int j = i + 1; j < n; j++) {           dp[k][i][j] +=               dp[k - 1][i][j] * ((i * (i + 1)) / 2 + ((n - 1 - j) * (n - j)) / 2 +                                  ((j - i - 1) * (j - i)) / 2);           for (int sum = j; sum <= i + (n - 1); sum++) {             a = (sum - n + 1 > 0 ? sum - n + 1 : 0);             b = (i < sum - j ? i : sum - j);             dp[k][i][j] += (1.0 - dp[k - 1][sum - j][sum - i]) * (b - a + 1);           }           for (int sum = i; sum <= i + (j - 1); sum++) {             a = (sum - j + 1 > 0 ? sum - j + 1 : 0);             b = (i < sum - i ? i : sum - i);             dp[k][i][j] += dp[k - 1][sum - i][j] * (b - a + 1);           }           for (int sum = (i + 1) + j; sum <= j + (n - 1); sum++) {             a = (i + 1 > sum - n + 1 ? i + 1 : sum - n + 1);             b = (j < sum - j ? j : sum - j);             dp[k][i][j] += dp[k - 1][i][sum - j] * (b - a + 1);           }           dp[k][i][j] /= dd;         }       }     }     for (int i = 0; i < n; i++) {       for (int j = i + 1; j < n; j++) {         if (arr[i] > arr[j]) {           ans += dp[kk][i][j];         } else {           ans += 1 - dp[kk][i][j];         }       }     }     printf( %.11f n , ans);   }   int main() {     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 10, mod = 1e9 + 7, L = 20;   vector<int> G[N], g[N];   int h[N], x[5 * N], y[5 * N], par[N][L];   map<int, bool> mp[N];   void dfs(int v, int p) {     par[v][0] = p;     for (int i = 1; i < L; i++) par[v][i] = par[par[v][i - 1]][i - 1];     for (int u : g[v])       if (u != p && h[u] == -1) h[u] = h[v] + 1;     for (int u : g[v])       if (h[u] == h[v] + 1) dfs(u, v);   }   int pr(int v, int x) {     for (int i = 0; i < L; i++)       if ((1 << i) & x) v = par[v][i];     return v;   }   int lca(int u, int v) {     if (h[u] > h[v]) swap(u, v);     v = pr(v, h[v] - h[u]);     if (u == v) return v;     for (int i = L - 1; i >= 0; i--)       if (par[v][i] != par[u][i]) u = par[u][i], v = par[v][i];     return par[v][0];   }   int solve(int u, int v) {     int p = lca(u, v);     int ret = h[u] + h[v] - 2 * h[p];     if (p == u || p == v) return ret;     int x = pr(u, h[u] - h[p] - 1), y = pr(v, h[v] - h[p] - 1);     if (x > y) swap(x, y);     if (mp[x][y]) ret--;     return ret;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     memset(h, -1, sizeof(h));     int n, m, q;     cin >> n >> m >> q;     h[0] = 0;     for (int i = 0; i < m; i++) {       cin >> x[i] >> y[i];       x[i]--;       y[i]--;       if (x[i] > y[i]) swap(x[i], y[i]);       g[x[i]].push_back(y[i]);       g[y[i]].push_back(x[i]);       mp[x[i]][y[i]] = true;     }     dfs(0, 0);     for (int i = 0; i < q; i++) {       int x, y;       cin >> x >> y;       x--;       y--;       cout << solve(x, y) <<   n ;     }     return 0;   }