malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   vector<pair<int, int> > res;   int n;   int tx[1000000], add[1000000];   void up(int i, int l, int r, int a, int b, int x) {     if (b < l || a > r) return;     if (a <= l && b >= r) {       tx[i] += x;       add[i] += x;       return;     }     int m = (l + r) / 2;     up(2 * i, l, m, a, b, x);     up(2 * i + 1, m + 1, r, a, b, x);     tx[i] = min(tx[2 * i], tx[2 * i + 1]) + add[i];   }   int getmin(int i, int l, int r, int a, int b) {     if (b < l || a > r) return 1000000000;     if (a <= l && b >= r) return tx[i];     int m = (l + r) / 2;     return min(getmin(2 * i, l, m, a, b), getmin(2 * i + 1, m + 1, r, a, b)) +            add[i];   }   void com(int l, int r) {     if (l > r) return;     if (l == r) {       for (int i = 0; i < getmin(1, 1, n, l, l); i++)         res.push_back(make_pair(l, r));       return;     }     int m = getmin(1, 1, n, l, r);     if (m == 0) {       int mid = (l + r) / 2;       int left = l;       int right = r;       while (1) {         mid = (left + right) / 2;         if (getmin(1, 1, n, l, mid) == 0) {           if (getmin(1, 1, n, mid, mid) == 0) {             com(l, mid - 1);             com(mid + 1, r);             return;           } else             right = mid;         } else           left = mid + 1;       }     } else if (m > 0) {       up(1, 1, n, l, r, -m);       for (int i = 0; i < m; i++) res.push_back(make_pair(l, r));       com(l, r);     }   }   int main() {     int k;     scanf( %d , &n);     ;     for (int i = 0; i < n; i++) {       scanf( %d , &k);       ;       up(1, 1, n, i + 1, i + 1, k);     }     com(1, n);     cout << res.size() << endl;     for (int i = 0; i < res.size(); i++)       printf( %d %d n , res[i].first, res[i].second);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, ans = 1, res = 1, x, mn = 0, mx = 1e9;   set<int> S;   set<int>::iterator it;   char s[10];   int main() {     scanf( %d , &n);     S.insert(1e9), S.insert(0);     for (int i = 1; i <= n; ++i) {       scanf( %s%d , s, &x);       if (s[1] ==  D )         S.insert(x), res += (x >= mn && x <= mx) ? 1 : 0;       else {         if (x < mn || x > mx) ans = 0;         if (x != mn && x != mx) ans = 2 * ans % 1000000007;         S.erase(x);         res = 1;         it = S.lower_bound(x);         mx = *it;         mn = *(--it);       }     }     printf( %d n , 1ll * ans * res % 1000000007);   }
#include <bits/stdc++.h>   using namespace std;   int n;   vector<int> g[100005];   int dep[100005], f[20][100005], mrk[100005], ans[100005];   map<pair<int, int>, int> mp;   void dfs(int x, int p, int d) {     for (int i = 0; i < g[x].size(); i++)       if (g[x][i] != p) dfs(g[x][i], f[0][g[x][i]] = x, dep[g[x][i]] = d + 1);   }   int dfs2(int x, int p) {     int cnt = 0;     for (int i = 0; i < g[x].size(); i++)       if (g[x][i] != p) {         int num = dfs2(g[x][i], x);         ans[mp[make_pair(x, g[x][i])]] = num;         cnt += num;       }     cnt += mrk[x];     return cnt;   }   int lca(int x, int y) {     if (dep[x] < dep[y]) swap(x, y);     int sub = dep[x] - dep[y];     for (int i = 0; i < 20; i++)       if (sub & (1 << i)) x = f[i][x];     if (x == y) return x;     for (int i = 19; i >= 0; i--)       if (f[i][x] != f[i][y]) {         x = f[i][x];         y = f[i][y];       }     x = f[0][x];     y = f[0][y];     return x;   }   int main() {     scanf( %d , &n);     for (int i = 1; i < n; i++) {       int x, y;       scanf( %d%d , &x, &y);       g[x].push_back(y);       g[y].push_back(x);       mp[make_pair(x, y)] = i;       mp[make_pair(y, x)] = i;     }     dfs(1, f[0][1] = 0, dep[1] = 1);     for (int i = 1; i < 20; i++)       for (int j = 1; j <= n; j++) f[i][j] = f[i - 1][f[i - 1][j]];     int q;     scanf( %d , &q);     while (q--) {       int x, y;       scanf( %d%d , &x, &y);       mrk[x]++;       mrk[y]++;       mrk[lca(x, y)] -= 2;     }     dfs2(1, 0);     for (int i = 1; i < n; i++) printf( %d  , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = acos(-1);   const long long INF = 1e18;   const int MAXN = 1e5 + 1;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int b, g, n;     cin >> b >> g >> n;     cout << min(b, min(g, n)) + 1 - max(0, n - max(b, g));     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   using namespace std;   int n, l[100100], r[100100];   int rs[100100], dp[2][100100];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n;     for (int i = 1; i <= n; i++) cin >> l[i];     for (int i = 1; i <= n; i++) cin >> r[i];     int val = n, cnt = n;     for (int i = 1; i <= n; i++) {       if (l[i] == r[i] && !r[i]) rs[i] = val, cnt--;     }     int cn = 0;     while (cnt && cn <= 10000) {       val--;       for (int i = 1; i <= n; i++) dp[0][i] = dp[0][i - 1] + (rs[i] > 0);       for (int i = n; i; i--) dp[1][i] = dp[1][i + 1] + (rs[i] > 0);       for (int i = 1; i <= n; i++) {         if (!rs[i] && dp[0][i] == l[i] && dp[1][i] == r[i]) rs[i] = val, cnt--;       }       cn++;     }     if (cn >= 10000) return cout <<  NO , 0;     for (int i = 1; i <= n; i++)       if (rs[i] <= 0) return cout <<  NO , 0;     cout <<  YES n ;     for (int i = 1; i <= n; i++) cout << rs[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double dist(int x, int y, int a, int b) {     return sqrt((x - a) * (x - a) + (y - b) * (y - b));   }   int main() {     ios_base::sync_with_stdio(false);     cout.tie(0);     cout << fixed;     cout.precision(10);     int n, m;     cin >> n;     int c, r;     vector<pair<pair<int, int>, int> > arr;     for (int i = 0; i < n; i++) {       cin >> c >> r;       arr.emplace_back(pair<int, int>(c, r), i);     }     sort(arr.begin(), arr.end());     int centre[n];     for (int i = 0; i < n; i++) {       centre[i] = arr[i].first.first;     }     int count[n];     for (int i = 0; i < n; i++) {       count[i] = INT_MAX;     }     cin >> m;     for (int i = 1; i <= m; i++) {       int x, y;       cin >> x >> y;       if (x <= centre[0]) {         if (dist(x, y, arr[0].first.first, 0) <= arr[0].first.second) {           count[0] = min(count[0], i);         }       } else if (x >= arr[n - 1].first.first) {         if (dist(x, y, arr[n - 1].first.first, 0) <= arr[n - 1].first.second) {           count[n - 1] = min(count[n - 1], i);         }       } else {         int pos = upper_bound(centre, centre + n, x) - centre;         if (dist(x, y, arr[pos].first.first, 0) <= arr[pos].first.second) {           count[pos] = min(count[pos], i);         }         if (dist(x, y, arr[pos - 1].first.first, 0) <=             arr[pos - 1].first.second) {           count[pos - 1] = min(count[pos - 1], i);         }       }     }     int sol[n];     int res = 0;     for (int i = 0; i < n; i++) {       sol[arr[i].second] = count[i];       if (count[i] != INT_MAX) {         res++;       }     }     cout << res << (  n );     for (int i = 0; i < n; i++) {       if (sol[i] != INT_MAX) {         cout << sol[i] <<    ;       } else {         cout << -1 <<    ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int p[2001];   int a[2001];   int find(int v) {     if (p[v] != v) p[v] = find(p[v]);     return p[v];   }   void merge(int u, int v) {     int pu = find(u);     int pv = find(v);     p[pu] = pv;   }   int main() {     int n, m, k, i, l, r;     cin >> n >> m >> k;     for (i = 0; i < n; i++) p[i] = i;     for (i = 0; i < n; i++) {       l = i;       r = i + k - 1;       if (r >= n) break;       while (l < r) {         merge(l, r);         l++;         r--;       }     }     for (i = 0; i < n; i++) {       p[i] = find(i);       a[p[i]]++;     }     long long re = 1;     for (i = 0; i < n; i++)       if (a[i] > 0) {         re *= m;         re %= 1000000007;       }     cout << re;     return 0;   }
#include <bits/stdc++.h>   int main() {     long long int n, a, b, i, t;     scanf( %lld %lld %lld , &n, &a, &b);     t = n / a + 1;     for (i = 0; i < t; i++) {       if ((n - (a * i)) % b == 0 && n - (a * i) >= 0) {         printf( YES n%lld %lld , i, (n - (a * i)) / b);         return 0;       }     }     printf( NO );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int max(long long int a, long long int b) {     if (a > b)       return a;     else       return b;   }   long long int min(long long int a, long long int b) {     if (a < b)       return a;     else       return b;   }   const int dx[4] = {-1, 1, 0, 0};   const int dy[4] = {0, 0, -1, 1};   int XX[] = {-1, -1, -1, 0, 0, 1, 1, 1};   int YY[] = {-1, 0, 1, -1, 1, -1, 0, 1};   int main() {     ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);     long long int k, i, j, t, a, b, l, r, x, n;     cin >> n >> k;     long long int arr[n];     for (i = 0; i < n; i++) {       cin >> arr[i];     }     sort(arr, arr + n);     long long int maxi = k, count = 0;     for (i = 0; i < n; i++) {       long long int z = ceil(arr[i] * 1.0 / 2);       if (maxi >= z) {         maxi = max(maxi, arr[i]);         continue;       }       while (maxi < z) {         maxi = 2 * maxi;         count++;       }       maxi = max(maxi, arr[i]);     }     cout << count;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline void read(T &x) {     char c;     bool nega = 0;     while ((!isdigit(c = getchar())) && (c !=  - ))       ;     if (c ==  - ) {       nega = 1;       c = getchar();     }     x = c - 48;     while (isdigit(c = getchar())) x = x * 10 + c - 48;     if (nega) x = -x;   }   template <typename T>   inline void writep(T x) {     if (x > 9) writep(x / 10);     putchar(x % 10 + 48);   }   template <typename T>   inline void write(T x) {     if (x < 0) {       putchar( - );       x = -x;     }     writep(x);   }   template <typename T>   inline void writeln(T x) {     write(x);     putchar(  n );   }   int n, h[300003], dp[300003];   set<int> st[300003];   vector<pair<int, int> > ve;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int i, j;     cin >> n;     for (i = 0; i < n; i++) cin >> h[i];     pair<int, int> t;     ve.push_back({0, h[0]});     for (i = 1; i < n; i++) {       t = ve.back();       while (h[i] <= t.second) {         st[t.first].insert(i);         ve.pop_back();         if (ve.empty()) break;         t = ve.back();       }       ve.push_back({i, h[i]});     }     ve.clear();     ve.push_back({0, h[0]});     for (i = 1; i < n; i++) {       t = ve.back();       while (h[i] >= t.second) {         st[t.first].insert(i);         ve.pop_back();         if (ve.empty()) break;         t = ve.back();       }       ve.push_back({i, h[i]});     }     ve.clear();     ve.push_back({n - 1, h[n - 1]});     for (i = n - 2; i >= 0; i--) {       t = ve.back();       while (h[i] >= t.second) {         st[i].insert(t.first);         ve.pop_back();         if (ve.empty()) break;         t = ve.back();       }       ve.push_back({i, h[i]});     }     ve.clear();     ve.push_back({n - 1, h[n - 1]});     for (i = n - 2; i >= 0; i--) {       t = ve.back();       while (h[i] <= t.second) {         st[i].insert(t.first);         ve.pop_back();         if (ve.empty()) break;         t = ve.back();       }       ve.push_back({i, h[i]});     }     dp[n - 1] = 0;     set<int>::iterator it;     for (i = n - 2; i >= 0; i--) {       dp[i] = 0x3f3f3f3f;       for (it = st[i].begin(); it != st[i].end(); it++) {         dp[i] = ((dp[i]) < (dp[*it] + 1) ? (dp[i]) : (dp[*it] + 1));       }     }     cout << dp[0] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, s = 0, i, x, vs = 0;     vector<int> a;     cin >> n;     for (i = 0; i < n; i++) {       cin >> x;       a.push_back(x);       vs += x;     }     sort(a.begin(), a.end(), std::greater<int>());     if (n == 1)       cout << a[0] << endl;     else if (n == 2)       cout << 2 * vs << endl;     else {       while (a.size() > 1) {         s += vs;         s += a.back();         vs -= a.back();         a.pop_back();       }       s += a[0];       cout << s << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   struct pp {     int val;     int same;   };   vector<pp> with[100005];   vector<int> v[100005];   int color[100005];   int currcolor[100005];   bool ending = false;   void dfs(int parent, int curr) {     if (ending == true) return;     for (int i = 1; i <= with[curr][0].val; i++) {       if (ending == true) return;       if (with[curr][i].val == parent) continue;       int vertex = with[curr][i].val;       if ((currcolor[vertex] != -1) &&           ((currcolor[vertex] + currcolor[curr] + with[curr][i].same) % 2 == 0)) {         cout <<  NO n ;         ending = true;         return;       }       if (currcolor[vertex] != -1) continue;       if (with[curr][i].same == 1)         currcolor[vertex] = currcolor[curr];       else         currcolor[vertex] = 1 - currcolor[curr];       dfs(curr, vertex);     }   }   int main() {     int n, m;     cin >> n >> m;     pp nullpp;     nullpp.val = 0, nullpp.same = 0;     for (int i = 1; i <= m; i++) with[i].push_back(nullpp);     for (int i = 1; i <= n; i++) cin >> color[i];     for (int i = 1; i <= m; i++) {       int k, val;       cin >> k;       for (int j = 1; j <= k; j++) {         cin >> val;         v[val].push_back(i);       }     }     for (int i = 1; i <= n; i++) {       with[v[i][0]][0].val++;       pp ed;       ed.val = v[i][1];       ed.same = color[i];       with[v[i][0]].push_back(ed);       with[v[i][1]][0].val++;       ed.val = v[i][0];       with[v[i][1]].push_back(ed);     }     for (int i = 1; i <= m; i++) currcolor[i] = -1;     for (int i = 1; i <= m; i++)       if (currcolor[i] == -1) {         currcolor[i] = 1;         dfs(-1, i);       }     if (ending == false) cout <<  YES n ;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 5;   int m[N];   int main(void) {     int n, a, b, k;     scanf( %d %d %d %d , &n, &a, &b, &k);     int ans = 0;     for (int i = 1; i <= n; i++) {       scanf( %d , &m[i]);       m[i] = m[i] % (a + b);       if (m[i] == 0) {         m[i] = a + b;       }     }     sort(m + 1, m + 1 + n);     for (int i = 1; i <= n; i++) {       int need = m[i] / a;       if (m[i] % a) need++;       if (need > 1) {         k -= need - 1;       }       if (k >= 0) {         ans++;       } else         break;     }     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   int v[55];   double dp[55][55][55];   int main() {     int n, p, sum = 0;     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , &v[i]);       sum += v[i];     }     scanf( %d , &p);     if (sum <= p) {       printf( %d n , n);       return 0;     }     double ans = 0;     for (int i = 1; i <= n; i++) {       memset(dp, 0, sizeof dp);       dp[0][0][0] = 1;       swap(v[i], v[n]);       for (int j = 1; j < n; j++) {         for (int cnt = 0; cnt < j; cnt++) {           for (int k = 0; k <= p; k++) {             if (k + v[j] <= p)               dp[j][cnt + 1][k + v[j]] += dp[j - 1][cnt][k] * (cnt + 1) / j;             dp[j][cnt][k] += dp[j - 1][cnt][k] * (j - cnt) / j;           }         }       }       for (int cnt = 0; cnt < n; cnt++) {         for (int k = 0; k + v[n] <= p; k++) {           ans += dp[n - 1][cnt][k] / n;         }       }       swap(v[i], v[n]);     }     printf( %.15lf n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> p;   bool first[5000] = {0};   void gen() {     p.push_back(0);     for (int i = 2; i <= 500; i++) {       if (!first[i]) {         p.push_back(i);         for (int j = 2 * i; j <= 500; j += i) {           first[j] = 1;         }       }     }   }   bool isprime(int x) {     int sz = sqrt(x) + 1;     for (int i = 2; i <= sz; i++) {       if (x % i == 0) return 0;     }     return 1;   }   int main() {     gen();     int n;     cin >> n;     if (n <= 500) {       vector<int> ans;       for (int i = 0; i < p.size(); i++) {         if (p[i] > n) break;         for (int j = 0; j <= i; j++) {           for (int k = 0; k <= j; k++) {             if (p[i] + p[j] + p[k] == n) {               if (p[i]) ans.push_back(p[i]);               if (j) ans.push_back(p[j]);               if (k) ans.push_back(p[k]);               cout << ans.size() <<   n ;               for (auto x : ans) {                 cout << x <<    ;               }               return 0;             }           }         }       }     } else {       vector<int> ans;       for (int i = n; i >= n - 500; i--) {         if (isprime(i)) {           ans.push_back(i);           n -= i;           break;         }       }       for (int i = 0; i < p.size(); i++) {         if (p[i] > n) break;         for (int j = 0; j <= i; j++) {           if (p[i] + p[j] == n) {             if (p[i]) ans.push_back(p[i]);             if (p[j]) ans.push_back(p[j]);             cout << ans.size() <<   n ;             for (auto x : ans) {               cout << x <<    ;             }             return 0;           }         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, i, k;     cin >> n >> k;     if (k == 0) {       cout <<  0 0 ;       return 0;     }     if (n == k)       cout << 0;     else       cout << 1;     cout <<    ;     if (n % 2 == 0) {       long long temp = 3 * k;       if (temp <= n)         cout << 2 * k;       else {         cout << n - k;       }     } else {       long long temp = 3 * k;       if (temp <= n)         cout << 2 * k;       else {         cout << n - k;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, a, b;   char seats[200001];   int main() {     scanf( %d%d%d , &n, &a, &b);     scanf( %s , seats);     int ans = 0;     char prev =  . ;     for (int i = 0; i < n; ++i) {       if (seats[i] ==  * ) {         prev =  . ;         continue;       }       if (prev ==  A  && b > 0) {         prev =  B ;         ++ans;         --b;       } else if (prev ==  B  && a > 0) {         prev =  A ;         ++ans;         --a;       } else if (prev ==  .  && a > b) {         prev =  A ;         ++ans;         --a;       } else if (prev ==  .  && b > 0) {         prev =  B ;         ++ans;         --b;       } else         prev =  . ;     }     printf( %d n , ans);     return 0;   }
#include <iostream>   #include <vector>   #include <algorithm>   #include <map>      using namespace std;      const int64_t INF = 1e15;      struct Dinic {    struct Edge {     int v;     int64_t f, c;     Edge(int _v = 0, int64_t _f = 0, int64_t _c = 0): v(_v), f(_f), c(_c) {};    };       int n;    vector<int> idx, dep, qu;    vector<vector<int>> adj;    vector<Edge> edges;       Dinic(int _n): n(_n), idx(_n), dep(_n), adj(_n), edges(0) {}       void addEdge(int u, int v, int64_t c) {     adj[u].push_back((int) edges.size());     edges.emplace_back(v, 0, c);     adj[v].push_back((int) edges.size());     edges.emplace_back(u, 0, 0);    }       bool levelGraph(int s, int t) {     qu.clear();     fill(dep.begin(), dep.end(), n + 1);     fill(idx.begin(), idx.end(), 0);        qu.push_back(s);     dep[s] = 0;     for (int qi = 0; qi < (int) qu.size() && qu.back() != t; ++qi) {      int u = qu[qi];      for (int i : adj[u]) {       auto &e = edges[i];       if (e.f < e.c && dep[u] + 1 < dep[e.v]) {        dep[e.v] = dep[u] + 1;        qu.push_back(e.v);       }      }     }     return dep[t] <= n;    }       int64_t sendFlow(int u, int t, int64_t f) {     if (u == t) return f;     for (int &i = idx[u]; i < (int) adj[u].size(); ++i) {      auto &e = edges[adj[u][i]];      if (e.f < e.c && dep[u] + 1 == dep[e.v]) {       int64_t g = sendFlow(e.v, t, min(f, e.c - e.f));       if (g > 0) {        edges[adj[u][i]].f += g;        edges[adj[u][i] ^ 1].f -= g;        return g;        }      }     }     return 0;    }       int64_t maxFlow(int s, int t) {     while (levelGraph(s, t)) {      while (sendFlow(s, t, INF));     }        int64_t flow = 0;     for (int i : adj[s]) {      flow += edges[i].f;     }     return flow;    }   };      int main() {    ios_base::sync_with_stdio(0);    cin.tie(0);       int n;    map<pair<int, int>, int> a;    auto get = [&](int x, int y) {     auto it = a.find(make_pair(x, y));     return (it == a.end() ? -1 : it->second);    };       cin >> n;    Dinic dinic(n * 2 + 2);    int s = n * 2, t = n * 2 + 1;    int64_t total = 0;    for (int i = 0; i < n; ++i) {     int x, y, w;     cin >> x >> y >> w;     dinic.addEdge(2 * i, 2 * i + 1, w);     total += w;        a[make_pair(x, y)] = i;    }       for (auto rit = a.begin(); rit != a.end(); ++rit) {     int x = rit->first.first, y = rit->first.second, i = rit->second, j;        if (x % 2 == 0 && y % 2 == 0) {      for (int y0 = y - 1; y0 <= y + 1; y0 += 2) {       if (~(j = get(x, y0))) dinic.addEdge(2 * i + 1, 2 * j, INF);      }      for (int x0 = x - 1; x0 <= x + 1; x0 += 2) {       if (~(j = get(x0, y))) dinic.addEdge(2 * j + 1, 2 * i, INF);      }     } else if (x % 2 == 0) {      for (int x0 = x - 1; x0 <= x + 1; x0 += 2) {       if (~(j = get(x0, y))) dinic.addEdge(2 * i + 1, 2 * j, INF);      }     } else if (y % 2 == 0) {      dinic.addEdge(s, 2 * i, INF);     } else {      dinic.addEdge(2 * i + 1, t, INF);     }    }       cout << total - dinic.maxFlow(s, t) << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3000020, M = 120;   int L, R, p, ans, tot, cnt, g[N], f[N], P[M];   bool buc[N], vis[M];   void dfs(int k, int res) {     g[++cnt] = res;     for (int i = k; i <= tot; i++) {       if (1ll * P[i] * res <= 1ll * R) dfs(i, res * P[i]);     }   }   signed main() {     memset(f, 0x3f, sizeof(f));     cin >> L >> R >> p;     for (int i = 2; i <= p; i++) {       if (!vis[i]) P[++tot] = i;       for (int j = 1; j <= tot && i * P[j] <= p; j++) {         vis[i * P[j]] = 1;         if (i % P[j] == 0) break;       }     }     dfs(1, 1);     sort(g + 1, g + cnt + 1);     f[1] = 0;     for (int i = 2; i <= p; i++) {       int j = 1;       for (int k = 1; k <= cnt; k++) {         while (j <= cnt && 1ll * g[j] != 1ll * g[k] * i) j++;         if (j == cnt + 1) break;         f[j] = min(f[j], f[k] + 1);         if (f[j] + i <= p && g[j] >= L && !buc[j]) buc[j] = 1, ans++;       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   const long long oo = 1e9;   const long long mod = 95542721;   const long long MAX = 1e9;   const long long ARR = 1e5;   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     long long n, m;     set<long long> x, y;     cin >> n >> m;     for (long long i = (0); i < (long long)(m); ++i) {       int a, b;       cin >> a >> b;       x.insert(a), y.insert(b);       cout << (n - x.size()) * (n - y.size()) <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int a, b, x, y;       cin >> a >> b >> x >> y;       if (a == x || b == y) {         cout << abs(x - a) + abs(b - y) <<   n ;         goto v;       } else         cout << abs(a - x) + abs(b - y) + 2 <<   n ;     v:;     }   }
#include <bits/stdc++.h>   using namespace std;   char s[92], sl[10][10], str[10];   bool cmp(char* a, char* b) {     for (int i = 0; i < 10; i++)       if (a[i] != b[i]) return false;     return true;   }   int main() {     scanf( %s , &s);     for (int i = 0; i < 10; i++) scanf( %s , sl[i]);     for (int i = 0; i < 80; i += 10) {       for (int k = 0; k < 10; k++) str[k] = s[i + k];       for (int i = 0; i < 10; i++)         if (cmp(str, sl[i])) {           printf( %d , i);           break;         }     }     return 0;   }