malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   template <typename T, typename T2>   T2 fac(T n) {     return n < 2 ? 1 : fac<T, T2>(n - 1) * n;   }   template <typename T, typename T2, typename T3>   T2 fac(T n, T3 mod) {     return n < 2 ? 1 : (fac<T, T2, T3>(n - 1, mod) * n) % mod;   }   template <typename T>   T nb_combinaisons(T k, T n) {     if (n < k) return nb_combinaisons<T>(n, k);     return fac<T, long long int>(n) /            (fac<T, long long int>(n - k) * fac<T, long long int>(k));   }   template <typename T, typename T2>   T nb_permutations(vector<T2> v) {     T total = fac<T, T>(v.size());     map<T2, T> m;     bool distinct = true;     for (long long unsigned c = 0; c < v.size(); c++) {       m[v[c]]++;       if (m[v[c]] - 1) distinct = false;     }     for (typename map<T2, T>::iterator it = m.begin(); it != m.end(); it++)       total /= fac<T, T>(it->second);     return total;   }   template <typename T, typename T2, typename T3>   T nb_permutations(vector<T2> v, T3 mod) {     T total = fac<T, T, T3>(v.size(), mod);     map<T2, T> m;     bool distinct = true;     for (long long unsigned c = 0; c < v.size(); c++) {       m[v[c]]++;       if (m[v[c]] - 1) distinct = false;     }     for (typename map<T2, T>::iterator it = m.begin(); it != m.end(); it++)       total /= fac<T, T>(it->second);     return total % mod;   }   string itoa_2(long long int n) {     string s;     stringstream ss;     ss << n;     ss >> s;     while (s.size() != 9) s =  0  + s;     return s;   }   int pgcd(int a, int b) {     if (a == 0) return b;     if (b == 0) return a;     return pgcd(b, a % b);   }   string conversion(int n, int base) {     string res =   ;     while (n != 0) {       res = ((char)( 0  + n % base)) + res;       n /= base;     }     return res;   }   int main() {     int n, m;     cin >> n >> m;     int i = 0;     vector<int> v;     if (m % 2 == 0) {       int gauche = (m - 1) / 2 + 1;       int droite = (m - 1) / 2 + 2;       bool g = true;       for (int c = 0; c < n; c++) {         if (g) {           cout << gauche << endl;           if (gauche - 1 <= 0) {             gauche = (m - 1) / 2 + 1;           } else             gauche--;         } else {           cout << droite << endl;           if (droite + 1 > m)             droite = (m - 1) / 2 + 2;           else             droite++;         }         g = !g;       }     } else {       int gauche = (m) / 2;       int droite = (m) / 2 + 2;       bool g = true;       for (int c = 0; c < n; c++) {         if (c % m == 0)           cout << (m / 2) + 1 << endl;         else if (g) {           cout << gauche << endl;           if (gauche - 1 <= 0) {             gauche = (m) / 2;           } else             gauche--;         } else {           cout << droite << endl;           if (droite + 1 > m)             droite = (m) / 2 + 2;           else             droite++;         }         if (c % m != 0) g = !g;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int t;     cin >> t;     long long int a, b, c, r;     while (t--) {       long long int ans = 0, mx = 0, mn = 0;       cin >> a >> b >> c >> r;       if (a >= b) {         mx = a;         mn = b;       } else {         mx = b;         mn = a;       }       if (c == mx || c == mn) {         ans = mx - mn - r;         if (ans < 0) ans = 0;         cout << ans << endl;       } else if (c > mn && c < mx) {         if (abs(c - mn) < r)           ans = mx - mn - (r + abs(c - mn));         else if (abs(mx - c) < r)           ans = mx - mn - (r + abs(mx - c));         else           ans = mx - mn - 2 * r;         if (ans < 0) ans = 0;         cout << ans << endl;       } else {         if (mn > c && abs(mn - c) < r)           ans = mx - mn - (r - abs(mn - c));         else if (c > mx && abs(c - mx) < r)           ans = mx - mn - (r - abs(c - mx));         else           ans = mx - mn;         if (ans < 0) ans = 0;         cout << ans << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long t[45];   int n, i, k, m, kol, ans, ans2, j, l, ans3, ans1, sum;   void summ(int x) {     for (j = 0; j < k; j++) {       l = n - x;       while (ans2 <= m - t[j] and l > 0) {         l--;         ans2 += t[j];         kol++;       }     }   }   int main() {     cin >> n >> k >> m;     for (i = 0; i < k; i++) {       cin >> t[i];       sum += t[i];     }     i = 0;     sort(t, t + k);     for (i = 0; i <= n; i++) {       ans2 = 0;       kol = 0;       ans3 = 0;       if (sum * i > m) {         break;       }       if (sum * i == m) {         ans = max(ans, i * (k + 1));       }       ans2 = sum * i;       ans3 = (k + 1) * i;       summ(i);       ans3 += kol;       ans = max(ans, ans3);     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int gcd(long long int a, long long int b) {     long long int temp;     while (b > 0) {       temp = b;       b = a % b;       a = temp;     }     return a;   }   int main() {     long long int N, m;     cin >> N >> m;     long long int a[N], B[m];     for (long long int i = 0; i < N; i++) {       cin >> a[i];     }     long long int n = N - 1;     long long int A[n];     for (long long int i = 1; i < N; i++) {       A[i - 1] = a[i] - a[i - 1];     }     for (long long int i = 0; i < m; i++) {       cin >> B[i];     }     long long int result = A[0];     for (long long int i = 1; i < n; i++) {       result = gcd(result, A[i]);     }     long long int j = 0;     while (j < m && result % B[j] != 0) {       j++;     }     if (j < m) {       cout <<  YES  << endl;       cout << a[0] <<     << j + 1 << endl;     } else {       cout <<  NO  << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5;   vector<int> G[maxn + 5];   int dp[maxn + 5], d[maxn + 5];   int main() {     int n, x, ans = 0;     scanf( %d , &n);     for (int i = 2; i <= maxn; i++)       for (int j = i; j <= maxn; j += i) G[j].push_back(i);     for (int i = 0; i < n; i++) {       scanf( %d , &x);       for (int j = 0; j < G[x].size(); j++) dp[x] = max(dp[x], d[G[x][j]] + 1);       for (int j = 0; j < G[x].size(); j++) d[G[x][j]] = dp[x];       ans = max(ans, dp[x]);     }     if (x == 1)       printf( 1 n );     else       printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1111;   int n;   string a[N], b[N];   int t[N];   int d;   std::set<pair<string, string> > res;   int main() {     cin >> n >> d;     for (int i = 0; i < n; i++) cin >> a[i] >> b[i] >> t[i];     for (int i = 0; i < n; i++)       for (int j = i + 1; j < n; j++) {         if (!(a[i] == b[j] && a[j] == b[i])) continue;         int m = min(t[i], t[j]);         int M = max(t[i], t[j]);         if (M - m <= 0 || M - m > d) continue;         res.insert(make_pair(a[i], b[i]));         res.insert(make_pair(b[i], a[i]));       }     cout << res.size() / 2 << endl;     for (set<pair<string, string> >::iterator it = res.begin(); it != res.end();          ++it) {       string s1 = it->first, s2 = it->second;       if (s1 < s2) cout << s1 <<     << s2 << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 500;   long long dp[N];   long long n;   void init() {     dp[0] = 1ll;     dp[1] = 2ll;     for (int i = 2; i < N; i++) {       dp[i] = dp[i - 2] + dp[i - 1];     }   }   int main() {     init();     while (cin >> n) {       int cur = 0;       while (dp[cur] <= n) cur++;       cout << cur - 1 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     char str[100005];     cin >> str;     int flag = 0, i;     char checkString[100005];     for (i = 0; str[i] !=   0 ; i++) {       checkString[i] =  a ;     }     checkString[i] =   0 ;     if (strcmp(str, checkString) == 0) {       checkString[strlen(checkString) - 1] =  z ;       cout << checkString;     } else {       for (i = 0; str[i] !=   0 ; i++) {         if (!flag && str[i] ==  a ) continue;         if (flag && str[i] ==  a )           break;         else {           flag = 1;           str[i]--;         }       }       cout << str;     }   }
#include <bits/stdc++.h>   using namespace std;   const long long maxn = 1e7 + 50;   const double eps = 1e-7;   const int inf = 0x3f3f3f3f;   const long long lnf = 0x3f3f3f3f3f3f3f3f;   const long long mod = 1e9 + 7;   const double pi = 3.141592653589;   int vis[maxn], cnt = 0, h[maxn];   int sum1[maxn], sum2[maxn];   int spr[maxn];   void ol() {     memset(vis, 1, sizeof(vis));     vis[0] = vis[1] = 0;     for (long long i = 2; i < maxn; i++) {       if (vis[i]) spr[cnt++] = i;       for (long long j = 0; i * spr[j] < maxn && j < cnt; j++) {         vis[i * spr[j]] = 0;         if (i % spr[j] == 0) break;       }     }   }   int f(int x) {     int ans = 0;     for (int i = 1; i <= cnt; i++) {       if (spr[i] <= x) {         ans = i;         break;       }     }     return ans;   }   vector<int> v(12);   bool g(int x) {     v.clear();     while (x) {       v.push_back(x % 10);       x /= 10;     }     bool flage = true;     int len = v.size();     for (int i = 0; i < len / 2; i++) {       if (v[i] != v[len - i - 1]) {         flage = false;         break;       }     }     return flage;   }   bool is(int x) {     int xx = x, s = 0;     while (x) {       s = s * 10 + (x % 10);       x /= 10;     }     return s == xx;   }   int main() {     long long p, q;     scanf( %lld%lld , &p, &q);     ol();     for (int i = 1; i < maxn - 20; i++) {       if (vis[i])         sum1[i] = sum1[i - 1] + 1;       else         sum1[i] = sum1[i - 1];     }     for (int i = 1; i < 10000000; i++) {       if (g(i)) {         sum2[i] = sum2[i - 1] + 1;       } else {         sum2[i] = sum2[i - 1];       }     }     int ans = 0;     for (int i = 1; i < 1e7; i++) {       if ((long long)sum1[i] * q <= (long long)sum2[i] * p) {         ans = i;       }     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   ll MOD = 1000000007;   ll INF = 1LL << 60;   int main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     int n;     cin >> n;     vector<int> tree[n + 1];     int u, v;     for (int i = 0; i < n - 1; i++) {       cin >> u >> v;       tree[u].push_back(v);       tree[v].push_back(u);     }     bool ans = true;     for (int i = 1; i <= n; i++) {       if (tree[i].size() == 2) {         ans = false;         break;       }     }     cout << (ans ?  YES  :  NO ) <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   long long int gcd(long long int a, long long int b) {     if (a == 0) return b;     return gcd(b % a, a);   }   int main() {     long long int n, a, b, t, ans, g;     cin >> t >> a >> b;     if (a > b) swap(a, b);     n = (b / gcd(a, b));     if (n > LLONG_MAX / a) {       ans = min(a - 1, t);     } else {       n *= a;       ans = (t / n) * a + min(t % n, a - 1);     }     g = gcd(ans, t);     cout << (ans / g) <<  /  << (t / g) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 500500;   bool Ans[N];   int Weight[N];   pair<int, int> Edges1[N];   vector<int> Edges2[N];   vector<pair<int, vector<int> > > Query[N];   int P[N];   stack<pair<int, int> > Was;   void Clear() {     while (!Was.empty()) Was.pop();   }   void Restore() {     while (!Was.empty()) {       int x = Was.top().first;       int p = Was.top().second;       P[x] = p;       Was.pop();     }   }   int F(int x) {     if (x == P[x]) return x;     Was.push(make_pair(x, P[x]));     return P[x] = F(P[x]);   }   bool Un(int x, int y) {     if ((x = F(x)) == (y = F(y))) return false;     if (rand() & 1) swap(x, y);     Was.push(make_pair(x, P[x]));     P[x] = y;     return true;   }   int main() {     srand(time(0));     int n, m;     cin >> n >> m;     for (int i = 1; i <= m; i++) {       int x, y, w;       scanf( %d%d%d , &x, &y, &w);       Weight[i] = w;       Edges1[i] = pair<int, int>(x, y);       Edges2[w].push_back(i);     }     int q;     cin >> q;     for (int i = 1; i <= q; i++) {       int k;       scanf( %d , &k);       for (int j = 0; j < k; j++) {         int Idx;         scanf( %d , &Idx);         int w = Weight[Idx];         if (Query[w].empty() || Query[w].back().first != i)           Query[w].push_back(make_pair(i, vector<int>()));         Query[w].back().second.push_back(Idx);       }     }     for (int i = 1; i <= q; i++) Ans[i] = true;     for (int i = 1; i <= n; i++) P[i] = i;     for (int w = 1; w < N; w++) {       for (int i = 0; i < Query[w].size(); i++) {         int Idx = Query[w][i].first;         vector<int>& v = Query[w][i].second;         for (int j : v) {           int x = Edges1[j].first;           int y = Edges1[j].second;           Ans[Idx] &= Un(x, y);         }         Restore();       }       for (int i : Edges2[w]) {         int x = Edges1[i].first;         int y = Edges1[i].second;         Un(x, y);       }       Clear();     }     for (int i = 1; i <= q; i++) puts(Ans[i] ?  YES  :  NO );   }
#include <bits/stdc++.h>   using namespace std;   using INT = long long;   using pii = pair<int, int>;   using pi3 = pair<int, pii>;   int n, m;   int nxt[100010];   int a[100010], b[100010];   set<pii> A, B;   set<pi3> ans;   int calc_max(int u, set<pair<int, int> > &st) {     auto it = st.upper_bound({m - 1 - u, n + 100});     if (it == st.begin()) return 0;     return (*--it).second;   }   int update_A(int u) {     int id2 = calc_max(a[u], B);     if (id2 == 0) return 0;     int id1 = calc_max(b[id2], A);     if (id1 == 0) return 0;     ans.insert(pi3(a[id1] + b[id2], pii(id1, id2)));   }   int update_B(int u) {     int id2 = calc_max(b[u], A);     if (id2 == 0) return 0;     int id1 = calc_max(a[id2], B);     if (id1 == 0) return 0;     ans.insert(pi3(a[id2] + b[id1], pii(id2, id1)));   }   int del_A(int u) {     int id = calc_max(a[u], B);     if (id == 0) return 0;     if (calc_max(b[id], A) == u) {       auto p = pi3(a[u] + b[id], pii(u, id));       if (ans.find(p) != ans.end()) ans.erase(p);     }   }   int del_B(int u) {     int id = calc_max(b[u], A);     if (id == 0) return 0;     if (calc_max(b[id], B) == u) {       auto p = pi3(b[u] + a[id], pii(id, u));       if (ans.find(p) != ans.end()) ans.erase(p);     }   }   int main() {     cin >> n >> m;     for (int i = 1; i <= n; i++) {       int u;       scanf( %d , &u);       a[i] = u;       A.insert({u, i});     }     for (int i = 1; i <= n; i++) {       int u;       scanf( %d , &u);       b[i] = u;       B.insert({u, i});     }     for (int i = 1; i <= n; i++) {       update_A(i);       update_B(i);     }     while (!A.empty()) {       int u = 0, v = 0;       pi3 p;       if (!ans.empty()) p = *--ans.end();       if (ans.empty() ||           p.first < ((*--A.end()).first + (*--B.end()).first) % m) {         u = (*--A.end()).second, v = (*--B.end()).second;       } else         u = p.second.first, v = p.second.second;       printf( %d  , (a[u] + b[v]) % m);       del_A(u);       del_B(v);       A.erase({a[u], u});       B.erase({b[v], v});       auto it = A.lower_bound({a[u], u});       if (it != A.begin()) update_A((*--it).second);       it = B.lower_bound({b[v], v});       if (it != B.begin()) update_B((*--it).second);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int gcd(long long int a, long long int b) {     if (b == 0) return a;     return gcd(b, a % b);   }   long long int lcm(long long int a, long long int b) {     return (a * b) / gcd(a, b);   }   long long int dp[200001][18];   void solve() {     long long int n, m, rc, cc, rb, cb, tim = 0;     cin >> n >> m >> rc >> cc >> rb >> cb;     long long int dx = 1, dy = 1;     while ((rc != rb) && (cc != cb)) {       if ((rc == n) || (rc == 0)) dx = -dx;       if ((cc == m) || (cc == 0)) dy = -dy;       rc = rc + dx;       cc = cc + dy;       tim++;     }     cout << tim <<   n ;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     long long int t = 1;     for (long long int i = 1; i <= 200000; i++) {       for (long long int j = 0; j < 18; j++) {         dp[i][j] = dp[i - 1][j] + (((1 << j) & i) == 0);       }     }     cin >> t;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   int n, a[2005];   long long sum[10005], D[5005];   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     for (int i = 1; i <= n; i++)       for (int j = i + 1; j <= n; j++) D[abs(a[i] - a[j])]++;     sum[5000] = 0;     double ans = 0;     for (int i = 4999; i >= 0; i--) sum[i] = sum[i + 1] + D[i];     for (int i = 1; i <= 5000; i++)       for (int j = 1; i + j <= 5000; j++) ans += D[i] * D[j] * sum[i + j + 1];     double match = n * (n - 1) / 2.0;     printf( %.10lf n , ans / match / match / match);   }
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     long long n, x, y;     cin >> n >> x >> y;     long long l = y - (n - 1);     if ((n - 1) + l * l >= x && l > 0) {       for (long long i = 0; i < n - 1; i++) cout <<  1  ;       cout << l << endl;     } else {       cout << -1 << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   void pv(T a, T b) {     for (T i = a; i != b; ++i) cout << *i <<    ;     cout << endl;   }   template <typename T>   void chmin(T &t, const T &f) {     if (t > f) t = f;   }   template <typename T>   void chmax(T &t, const T &f) {     if (t < f) t = f;   }   int in() {     int x;     scanf( %d , &x);     return x;   }   int M, N, V, W;   char A[1010][20][20];   int D[1010][1010];   int ds[1010];   int prv[1010];   bool used[1010];   int ansLen;   pair<int, int> ans[1010];   int main() {     for (; ~scanf( %d%d%d%d , &M, &N, &V, &W);) {       for (int u = 0; u < V; ++u) {         for (int x = 0; x < M; ++x) {           scanf( %s , A[u][x]);         }       }       for (int u = 0; u < V; ++u)         for (int v = u + 1; v < V; ++v) {           int cnt = 0;           for (int x = 0; x < M; ++x)             for (int y = 0; y < N; ++y) {               if (A[u][x][y] != A[v][x][y]) {                 ++cnt;               }             }           D[u][v] = D[v][u] = cnt * W;         }       fill_n(ds, V, M * N);       fill_n(used, V, false);       fill_n(prv, V, -1);       int total = 0;       ansLen = 0;       for (;;) {         int um = -1;         for (int u = 0; u < V; ++u)           if (!used[u]) {             if (!~um || ds[um] > ds[u]) {               um = u;             }           }         if (!~um) {           break;         }         used[um] = true;         total += ds[um];         ans[ansLen++] = make_pair(um, prv[um]);         for (int v = 0; v < V; ++v) {           if (ds[v] > D[um][v]) {             ds[v] = D[um][v];             prv[v] = um;           }         }       }       printf( %d n , total);       for (int i = 0; i < ansLen; ++i) {         printf( %d %d n , ans[i].first + 1, ans[i].second + 1);       }     }     return 0;   }
#include <iostream>   #include<cmath>>   #include<algorithm>   #include <string>   using namespace std;   int arr[101];   int arrstr[200];   bool prime(int n)   {       if(n<=1)           return false;       if(n<=3)           return true;       for(int i=2;i<=sqrt(n);i++)       {           if(n%i==0)               return false;          }       return true;   }   bool have(int n,int d)   {          if(n<d)           return false;       int x=n;       while(x)       {           if(x%10==d)           {               return true;           }           x=x/10;       }       return false;   }   bool check(int n,int d)   {       bool a=false;       int c=n%d;       int v=n/d;       for(int i=1;i<=v;i++)       {           if(have(d*i+c,d))           {               return true;           }             }           return false;   }   void solve()   {   long long  n,k,x;   cin>>n>>k;   x=k;   if(n>k)   {       if(n%k==0)        cout<<1<<  n ;   else    cout<<2<<  n ;   return;   }   cout<<k/n+(k%n!=0)<<  n ;   }      string sp(int n)   {       string str=  ;       while(n>0)       {           str+=   ;           n--;       }       return str;   }   string st(int n)   {       string str=  ;       while(n>0)       {           str+= * ;           n--;       }       return str;   }   int main()   {       ios::sync_with_stdio(false);       cin.tie(NULL);       cout.tie(NULL);         int t;      cin>>t;      while(t--)       solve();             return 0;      }
#include <bits/stdc++.h>   int n;   struct mjj {     int x, y;   } a[500001], b[500001];   int fa[500001];   int head[500001], end[1000001], len[1000001], next[1000001], tp;   int head2[500001], end2[1000001], len2[1000001], next2[1000001], tp2;   int dad[500001], db[500001], dad2[500001], db2[500001], wz[500001], gs;   int ans;   int cmp(mjj x, mjj y) { return x.x < y.x || x.x == y.x && x.y < y.y; }   int find(int p) { return p == fa[p] ? p : fa[p] = find(fa[p]); }   void dfs(int p) {     int i, j, k;     wz[++gs] = p;     for (i = head[p]; i; i = next[i])       if (end[i] != dad[p]) {         dad[end[i]] = p;         db[end[i]] = len[i];         dfs(end[i]);       }   }   void dfs2(int p) {     int i, j, k;     for (i = head2[p]; i; i = next2[i])       if (end2[i] != dad2[p]) {         dad2[end2[i]] = p;         db2[end2[i]] = len2[i];         dfs2(end2[i]);       }   }   int main() {     int i, j, k;     scanf( %d , &n);     for (i = 1; i < n; i++) {       scanf( %d%d , &a[i].x, &a[i].y);       if (a[i].x > a[i].y) {         int t = a[i].x;         a[i].x = a[i].y;         a[i].y = t;       }     }     for (i = 1; i < n; i++) {       scanf( %d%d , &b[i].x, &b[i].y);       if (b[i].x > b[i].y) {         int t = b[i].x;         b[i].x = b[i].y;         b[i].y = t;       }     }     std::sort(a + 1, a + n, cmp);     std::sort(b + 1, b + n, cmp);     for (i = 1; i <= n; i++) fa[i] = i;     ans = n - 1;     for (i = 1, j = 1; i < n && j < n;) {       if (cmp(a[i], b[j]))         i++;       else if (cmp(b[j], a[i]))         j++;       else {         if (find(a[i].x) != find(a[i].y)) {           fa[fa[a[i].x]] = fa[a[i].y];           ans--;         }         i++;         j++;       }     }     for (i = 1; i <= n; i++) find(i);     for (i = 1; i < n; i++)       if (fa[a[i].x] != fa[a[i].y]) {         int x = fa[a[i].x], y = fa[a[i].y];         next[++tp] = head[x];         head[x] = tp;         end[tp] = y;         len[tp] = i;         next[++tp] = head[y];         head[y] = tp;         end[tp] = x;         len[tp] = i;       }     for (i = 1; i < n; i++)       if (fa[b[i].x] != fa[b[i].y]) {         int x = fa[b[i].x], y = fa[b[i].y];         next2[++tp2] = head2[x];         head2[x] = tp2;         end2[tp2] = y;         len2[tp2] = i;         next2[++tp2] = head2[y];         head2[y] = tp2;         end2[tp2] = x;         len2[tp2] = i;       }     dfs(fa[1]);     dfs2(fa[1]);     printf( %d n , ans);     for (i = gs; i > 1; i--)       printf( %d %d %d %d n , a[db[wz[i]]].x, a[db[wz[i]]].y, b[db2[wz[i]]].x,              b[db2[wz[i]]].y);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 12;   int rows, cols, k, n;   char mat[MAXN][MAXN];   int sol = 0;   int Calc(int a, int b, int c, int d) {     int ret = 0;     for (int i = a; i <= c; i++) {       for (int j = b; j <= d; j++) ret += (mat[i][j] ==  # );     }     return ret;   }   int main() {     scanf( %d %d %d %d , &rows, &cols, &n, &k);     for (int i = 0; i <= rows; i++)       for (int j = 0; j <= cols; j++) mat[i][j] =  . ;     for (int i = 0; i < n; i++) {       int x, y;       scanf( %d %d , &x, &y);       mat[x][y] =  # ;     }     for (int i = 1; i <= rows; i++) {       for (int j = 1; j <= cols; j++) {         for (int ii = i; ii <= rows; ii++) {           for (int jj = j; jj <= cols; jj++) {             int sum = Calc(i, j, ii, jj);             sol += (sum >= k);           }         }       }     }     printf( %d n , sol);     return 0;   }