malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   void move(char b[], int n, int i) {     for (int j = i; j < n - 1; ++j) {       b[j] = b[j + 1];     }   }   int main() {     int a[10];     char b[101];     char d[101];     int c;     int n, q, nd, nn;     cin >> n >> q;     for (int i = 0; i < n; ++i) {       cin >> b[i];     }     for (int i = 0; i < q; ++i) {       for (int j = 0; j < 10; ++j) a[j] = 0;       int l, r;       cin >> l >> r;       nn = 0;       for (int j = l - 1; j < r; ++j) {         d[j - (l - 1)] = b[j];         if (d[j - (l - 1)] >=  0  && d[j - (l - 1)] <=  9 ) ++nn;       }       nd = r - l + 1;       int cp = 0;       char dp =  > ;       while (1) {         if (nn <= 0 || cp < 0 || cp >= nd) {           break;         }         if (d[cp] ==  < ) {           dp =  < ;           if (cp == 0) {             break;           }           if (d[cp - 1] ==  >  || d[cp - 1] ==  < ) {             move(d, nd, cp);             --nd;           }         } else if (d[cp] ==  > ) {           dp =  > ;           if (cp == nd - 1) {             break;           }           if (d[cp + 1] ==  >  || d[cp + 1] ==  < ) {             move(d, nd, cp);             --cp;             --nd;           }         } else if (d[cp] >=  1  && d[cp] <=  9 ) {           ++a[d[cp] -  0 ];           --d[cp];         } else if (d[cp] ==  0 ) {           ++a[0];           move(d, nd, cp);           if (dp ==  > ) {             --cp;           }           --nn;           --nd;         }         if (dp ==  < ) {           --cp;         } else {           ++cp;         }       }       for (int j = 0; j < 9; ++j) {         cout << a[j] <<    ;       }       cout << a[9] << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 51;   const int mod = (int)1e9 + 7;   long long dp0[N][N];   long long dp1[N][N];   long long C[N][N];   inline long long modpow(long long x, long long p) {     long long res = 1;     while (p) {       if (p & 1) res = res * x % mod;       x = x * x % mod;       p >>= 1;     }     return res;   }   void solve() {     long long i2 = modpow(2, mod - 2);     C[0][0] = 1;     for (int i = 1; i < N; i++) {       C[i][0] = 1;       for (int j = 1; j <= i; j++) {         C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod;       }     }     memset(dp0, 0, sizeof(dp0));     memset(dp1, 0, sizeof(dp1));     int n, K;     cin >> n >> K;     dp1[0][0] = 1;     dp0[1][0] = 1;     for (int sz = 2; sz <= n; sz++) {       for (int k = 0; k <= sz / 2; k++) {         for (int szl = 0; szl < sz; szl++) {           int szr = sz - 1 - szl;           if (szl > szr) break;           long long enumerate = sz == n ? 1 : sz;           enumerate = enumerate * C[sz - 1][szl] % mod;           for (int kl = 0; kl <= k; kl++) {             if (szl == szr && kl > k - kl) break;             if (szl == szr && kl == k - kl) enumerate = enumerate * i2 % mod;             dp0[sz][k] += dp1[szl][kl] * dp1[szr][k - kl] % mod * enumerate;             dp0[sz][k] %= mod;             dp1[sz][k + 1] += (dp1[szl][kl] * dp0[szr][k - kl] +                                dp0[szl][kl] * dp1[szr][k - kl] +                                dp0[szl][kl] * dp0[szr][k - kl]) %                               mod * enumerate;             dp1[sz][k + 1] %= mod;             if (szl == szr && kl == k - kl) enumerate = enumerate * 2 % mod;           }         }       }     }     cout << (dp0[n][K] + dp1[n][K]) % mod << endl;   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n = 0, temp1 = 0, temp2 = 0;     cin >> n;     std::vector<long long int> v1;     std::vector<long long int> v2;     long long int hash1[100001], hash2[100001];     for (long long int i = 0; i < 100001; ++i) {       hash1[i] = 0;       hash2[i] = 0;     }     for (long long int i = 0; i < n; ++i) {       cin >> temp1 >> temp2;       v1.push_back(temp1);       v2.push_back(temp2);     }     for (long long int i = 0; i < n; ++i) {       hash1[v1[i]]++;       hash2[v2[i]]++;     }     for (long long int i = 0; i < n; ++i) {       cout << (n - 1 + hash1[v2[i]]) <<     << (n - 1 - hash1[v2[i]]) << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long row[1000], col[1000];   char ch[1000][1000];   list<int> ax, ay;   int main() {     int i, j, x, y;     long long res = 0;     cin >> x >> y;     memset((row), (-1), sizeof((row)));     memset((col), (-1), sizeof((col)));     for (i = 0; i < x; i++) {       for (j = 0; j < y; j++) {         cin >> ch[i][j];         if (ch[i][j] ==  * ) {           ax.push_back(i);           ay.push_back(j);           row[i]++;           col[j]++;         }       }     }     list<int>::iterator it, it2;     it = ax.begin();     it2 = ay.begin();     while (it != ax.end()) {       if (row[*it] >= 1 && col[*it2] >= 1) res += row[*it] * col[*it2];       it++;       it2++;     }     cout << res <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, L, a;   void read() {     int x = 0, y = 0, lx = 0, ly = 0, ans = 0;     scanf( %d %d %d , &n, &L, &a);     for (int i = 0; i < n; i++) {       scanf( %d %d , &x, &y);       ans += (x - (lx + ly)) / a;       lx = x;       ly = y;     }     ans += (L - (x + y)) / a;     printf( %d n , ans);   }   int main() {     read();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long powmod(long long a, long long b, long long MOD) {     long long res = 1;     a %= MOD;     for (; b; b >>= 1) {       if (b & 1) res = res * a % MOD;       a = a * a % MOD;     }     return res;   }   const int N = 1e5 + 5;   double pos[N];   double getExpe(int l, int r, int p) {     int ans = ((r / p) - ((l - 1) / p));     return double(ans) / (r - l + 1);   }   double calculate(int x, int n, int p) {     int l = (x == 1 ? n : x - 1);     int r = (x == n ? 1 : x + 1);     return pos[x] * (2.0 - pos[l] / 2 - pos[r] / 2);   }   int main() {     int l, r, n, p;     double ans = 0.0;     scanf( %d%d , &n, &p);     for (int i = 1; i <= n; i++) {       scanf( %d%d , &l, &r);       pos[i] = getExpe(l, r, p);     }     for (int i = 1; i <= n; i++) {       ans += calculate(i, n, p);     }     printf( %.9f n , ans * 1000.0 * 2);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int const N = 200000;   long long const inf = 1e18;   int w[N + 1], h[N + 1];   long long dp[N + 1][2];   vector<int> tr[N + 1];   void up(long long &x, long long y) {     if (y < x) x = y;   }   void fn(int v, vector<long long> const &ch, long long s, int in, int out,           bool d) {     for (int i = 0; i < (int)(ch.size() + 1); ++i) {       if (i) {         s += ch[i - 1];         --out;         ++in;       }       up(dp[v][d], s + (long long)w[v] * max(in, out));     }   }   void go(int v = 1, int p = 0) {     dp[v][0] = dp[v][1] = inf;     vector<long long> ch;     int in = 0, out = 0;     long long s = 0;     for (int u : tr[v])       if (u != p) {         go(u, v);         if (dp[u][0] < inf) {           ++out;           s += dp[u][0];           if (dp[u][1] < inf) ch.push_back(dp[u][1] - dp[u][0]);         } else {           ++in;           s += dp[u][1];         }       }     sort(ch.begin(), ch.end());     if (p) {       if (h[v] <= h[p]) fn(v, ch, s, in, out + 1, true);       if (h[v] >= h[p]) fn(v, ch, s, in + 1, out, false);     } else       fn(v, ch, s, in, out, false);   }   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i < (int)(n + 1); ++i) scanf( %d , w + i);     for (int i = 1; i < (int)(n + 1); ++i) scanf( %d , h + i);     for (int i = 1; i < (int)(n); ++i) {       int a, b;       scanf( %d%d , &a, &b);       tr[a].push_back(b);       tr[b].push_back(a);     }     go();     printf( %lld n , dp[1][0]);   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100005;   int n;   long long sol(long long* data) {     long long ans = 0, fang = 0, sum = 0;     for (int i = 1; i <= n; i++) {       ans += data[i] * data[i] * (i - 1);       ans -= sum * data[i] * 2;       ans += fang;       fang += data[i] * data[i];       sum += data[i];     }     return ans;   }   long long x[maxn], y[maxn];   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %lld%lld , x + i, y + i);     sort(x + 1, x + n + 1);     sort(y + 1, y + n + 1);     cout << sol(x) + sol(y) << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1e4;   vector<string> pri;   string s;   int X, n;   bool check(string cur) {     for (int i = 0; i < cur.size(); i++) {       int sum = 0;       for (int j = i; j < cur.size(); j++) {         sum += cur[j] -  0 ;         if (sum < X && X % sum == 0) return 0;       }     }     return 1;   }   void generate(string cur, int sum) {     if (sum == X) {       if (check(cur)) pri.push_back(cur);       return;     }     for (int i = 1; i < 10 && sum + i <= X; i++)       generate(cur + (char)(i +  0 ), sum + i);   }   int cnt, nxt[100000][10], fal[100000];   bool flg[100000];   void add(string s) {     int cur = 0;     for (int i = 0; i < s.size(); i++) {       if (!nxt[cur][s[i] -  0 ]) nxt[cur][s[i] -  0 ] = ++cnt;       cur = nxt[cur][s[i] -  0 ];     }     flg[cur] = 1;   }   void getnxt() {     queue<int> que;     for (int i = 1; i < 10; i++)       if (nxt[0][i]) {         fal[nxt[0][i]] = 0;         que.push(nxt[0][i]);       }     while (!que.empty()) {       int u = que.front();       que.pop();       for (int i = 1; i < 10; i++) {         if (nxt[u][i]) {           fal[nxt[u][i]] = nxt[fal[u]][i];           que.push(nxt[u][i]);         }       }       for (int i = 1; i < 10; i++)         if (nxt[u][i] < 1) nxt[u][i] = nxt[fal[u]][i];     }   }   int main() {     cin >> s >> X, n = s.size();     generate(  , 0);     for (int i = 0; i < pri.size(); i++) add(pri[i]);     getnxt();     vector<int> dp(cnt + 1, INF);     dp[0] = 0;     for (int i = 0; i < n; i++) {       vector<int> dps(cnt + 1, INF);       for (int j = 0; j <= cnt; j++)         if (dp[j] < INF) {           dps[j] = min(dps[j], dp[j] + 1);           if (!flg[nxt[j][s[i] -  0 ]])             dps[nxt[j][s[i] -  0 ]] = min(dps[nxt[j][s[i] -  0 ]], dp[j]);         }       swap(dp, dps);     }     cout << (*min_element(dp.begin(), dp.end()));   }
#include <bits/stdc++.h>   using namespace std;   int BIN[30], P[1000005], vis[1000005];   int _bin(int n) {     int i, now;     for (i = 0; BIN[i] <= n; i++) now = BIN[i];     return BIN[i];   }   int main() {     int i, j, n, k, now, t;     long long ans = 0;     for (i = 1, BIN[0] = 1; i < 30; i++) BIN[i] = BIN[i - 1] * 2;     for (scanf( %d , &n), i = n; i; i--)       if (vis[i] == 0) {         now = _bin(i);         t = (now - 1) ^ i;         ans += t + i + t + i;         P[i] = t, P[t] = i;         vis[t] = 1;       }     for (i = 0, printf( %I64d n , ans); i <= n; i++)       printf( %d%c , P[i], i == n ?   n  :    );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   const long long maxn = 2e5 + 5;   long long rowdp[101][101];   vector<long long> a[101];   void f(long long id) {     vector<long long> dp(101, 0);     for (long long i = 0; i < a[id].size(); ++i) {       if (i == 0)         dp[i] = a[id][i];       else         dp[i] = dp[i - 1] + a[id][i];     }     long long tot = rowdp[id][a[id].size()] = dp[a[id].size() - 1];     for (long long l = 1; l <= a[id].size(); ++l) {       for (long long i = 0; i + l - 1 < a[id].size(); ++i) {         long long curr = 0;         if (i) curr = dp[i - 1];         rowdp[id][a[id].size() - l] =             max(rowdp[id][a[id].size() - l], tot - (dp[i + l - 1] - curr));       }     }   }   long long dp[101][10001];   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     long long n, m;     cin >> n >> m;     for (long long i = 0; i < n; ++i) {       long long x;       cin >> x;       while (x--) {         long long y;         cin >> y;         a[i].emplace_back(y);       }       f(i);     }     long long tot = 0;     for (long long i = 0; i < n; ++i) {       if (i) {         for (long long j = 0; j <= min(m, tot); ++j) {           for (long long k = 0; k <= a[i].size(); ++k) {             if (j + k > m) continue;             dp[i][j + k] = max(dp[i][j + k], dp[i - 1][j] + rowdp[i][k]);           }         }       } else {         for (long long j = 1; j <= a[0].size(); ++j) {           dp[0][j] = rowdp[0][j];         }       }       tot += a[i].size();     }     cout << dp[n - 1][m] <<   n ;     ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 2147483647;   int main() {     int n, size = 1, arr[200005], arr1[200005];     long long sum = 0;     memset(arr, 0, sizeof(arr));     memset(arr1, 0, sizeof(arr1));     cin >> n;     for (int i = 0; i < n; i++) {       int a;       cin >> a;       if (a == 1) {         int b, c;         cin >> b >> c;         arr[b - 1] += c;         sum += b * c;       } else if (a == 2) {         int b;         cin >> b;         arr1[size] = b;         sum += b;         size++;       } else {         size--;         sum -= arr1[size];         arr1[size] = 0;         sum -= arr[size];         arr[size - 1] += arr[size];         arr[size] = 0;       }       printf( %.15f n , 1.0 * sum / size);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int cp(int a, int b) { return a > b; }   int main() {     int a[55], i, j, k, l, coun, flag;     int n;     scanf( %d%d , &n, &k);     for (i = 1; i <= n; i++) {       scanf( %d , &a[i]);     }     sort(a + 1, a + n + 1, cp);     if (k <= n) {       for (i = 1; i <= k; i++) {         printf( 1 %d n , a[i]);       }     } else {       for (i = 1; i <= n; i++) {         printf( 1 %d n , a[i]);       }       coun = n;       flag = 0;       for (i = 2; i <= n; i++) {         for (j = i; j <= n; j++) {           printf( %d , i);           for (l = 1; l < i; l++) {             printf(  %d , a[l]);           }           printf(  %d n , a[j]);           coun++;           if (coun >= k) {             flag = 1;             break;           }         }         if (flag == 1) {           break;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct point {     int x, y;   };   int F[500][500];   int x, y;   void Init() {     F[0 + 200][0 + 200] = 0;     F[1 + 200][0 + 200] = 0;     F[1 + 200][1 + 200] = 1;     F[-1 + 200][1 + 200] = 2;     F[-1 + 200][-1 + 200] = 3;     for (int i = 2; i <= 110; i++)       F[i + 200][i + 200] = F[i - 1 + 200][i - 1 + 200] + 4;     for (int i = 2; i <= 110; i++)       F[-i + 200][i + 200] = F[-i + 1 + 200][i - 1 + 200] + 4;     for (int i = 2; i <= 110; i++)       F[-i + 200][-i + 200] = F[-i + 1 + 200][-i + 1 + 200] + 4;     for (int i = 2; i <= 110; i++)       F[i + 200][-i + 1 + 200] = F[i - 1 + 200][-i + 2 + 200] + 4;   }   void thuchien() {     if (x == 0 && y == 0) {       cout << 0 << endl;       return;     }     if (x == 1 && y == 0) {       cout << 0 << endl;       return;     }     if (y - x > 0 && x + y >= 0 && y > 0) {       cout << F[-y + 200][y + 200] << endl;       return;     }     if (x + y < 0 && y - x >= 0 && x < 0) {       cout << F[x + 200][x + 200] << endl;       return;     }     if (y - x < 0 && x + y - 1 <= 0 && y < 0) {       cout << F[-y + 1 + 200][y + 200] << endl;       return;     }     if (x + y - 1 > 0 && y - x <= 0 && x > 0) {       cout << F[x + 200][x + 200] << endl;       return;     }   }   int main() {     Init();     while (cin >> x >> y) thuchien();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 100000005;   const int p = 31;   const int mod = (1 << 8) - 1;   char s[200005];   const int siz = 5;   struct node {    public:     int c[5][5];     void out() {       for (int i = 0; i < siz; i++) {         for (int j = 0; j < siz; j++) {           printf( %8d  , c[i][j]);         }         puts(  );       }       puts(  );     }     node operator^(long long m) {       int i;       node tmp, a = (*this);       memset(tmp.c, 0, sizeof(tmp.c));       for (i = 1; i <= siz; i++) tmp.c[i][i] = 1;       while (m) {         if (m & 1) {           tmp = (tmp * a);         }         a = (a * a);         m >>= 1;       }       return tmp;     }     node operator*(node& b) {       node tmp;       int i, j, k;       for (i = 0; i < siz; i++)         for (j = i; j < siz; j++) {           tmp.c[i][j] = INF;           for (k = i; k <= j; k++)             tmp.c[i][j] = min(tmp.c[i][j], c[i][k] + b.c[k][j]);           if (tmp.c[i][j] > INF) tmp.c[i][j] = INF;         }       return tmp;     }     node operator+(node& b) {       node tmp;       int i, j;       for (i = 1; i <= siz; i++)         for (j = 1; j <= siz; j++) {           tmp.c[i][j] = (c[i][j] + b.c[i][j]) % mod;         }       return tmp;     }     void init() {       for (int i = 0; i < siz; i++)         for (int j = i; j < siz; j++) c[i][j] = INF;     }   };   struct Tree {     node a;     int l, r;   } tr[200005 << 2];   int n;   void upd(int x, int num) {     int i, j;     for (i = 0; i < siz; i++) tr[x].a.c[i][i] = 0;     if (num == 6) tr[x].a.c[3][3] = tr[x].a.c[4][4] = 1;     if (num == 2) tr[x].a.c[0][1] = 0, tr[x].a.c[0][0] = 1;     if (num == 0) tr[x].a.c[1][2] = 0, tr[x].a.c[1][1] = 1;     if (num == 1) tr[x].a.c[2][3] = 0, tr[x].a.c[2][2] = 1;     if (num == 7) tr[x].a.c[3][4] = 0, tr[x].a.c[3][3] = 1;   }   void pushup(int x) { tr[x].a = tr[x << 1].a * tr[x << 1 | 1].a; }   void build(int l, int r, int x) {     tr[x].l = l, tr[x].r = r;     tr[x].a.init();     if (l == r) {       upd(x, s[l] -  0 );       return;     }     int mid = (l + r) / 2;     build(l, mid, x << 1);     build(mid + 1, r, x << 1 | 1);     pushup(x);   }   node query(int L, int R, int x) {     int l = tr[x].l, r = tr[x].r;     if (l == L && R == r) {       return tr[x].a;     }     int mid = (l + r) / 2;     if (R <= mid)       return query(L, R, x << 1);     else if (L > mid)       return query(L, R, x << 1 | 1);     else {       node nw, n1, n2;       nw.init();       n1 = query(L, mid, x << 1);       n2 = query(mid + 1, R, x << 1 | 1);       nw = n1 * n2;       return nw;     }   }   int main() {     int l, r, i, j, m;     scanf( %d %d , &n, &m);     scanf( %s , s + 1);     build(1, n, 1);     while (m--) {       scanf( %d %d , &l, &r);       node nw;       nw = query(l, r, 1);       if (nw.c[0][4] == INF)         printf( -1 n );       else         printf( %d n , nw.c[0][4]);     }   }
#include <bits/stdc++.h>   using namespace std;   #pragma GCC optimize( Ofast )   #pragma GCC optimize( unroll-loops )   #pragma GCC optimize( -ffloat-store )   #pragma GCC optimize( -fno-defer-pop )   long long int power(long long int a, long long int b, long long int m) {     if (b == 0) return 1;     if (b == 1) return a % m;     long long int t = power(a, b / 2, m) % m;     t = (t * t) % m;     if (b & 1) t = ((t % m) * (a % m)) % m;     return t;   }   long long int modInverse(long long int a, long long int m) {     return power(a, m - 2, m);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long int i, j, k, l, n, M;     cin >> n >> k >> M;     long long int ar[k], s = 0;     for (i = 0; i < k; i++) {       cin >> ar[i];       s += ar[i];     }     sort(ar, ar + k);     long long int an = 0;     for (i = 0; i <= n; i++) {       long long int mx = 0, v = M, x;       if (v >= i * s) {         mx = i * (k + 1);         v = v - i * s;         for (j = 0; j < k; j++) {           x = min(v / ar[j], n - i);           mx = mx + x;           v = v - x * ar[j];         }       }       an = max(an, mx);     }     cout << an;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, i, c = 0, j = 0, index[3], sum = 0, avg;     cin >> n;     long long int a[n];     for (i = 0; i < n; i++) {       cin >> a[i];       sum += a[i];     }     avg = sum / n;     if (avg * n != sum)       cout <<  Unrecoverable configuration. ;     else {       for (i = 0; i < n; i++) {         if (a[i] == avg)           c++;         else {           index[j] = i;           j++;         }         if (j == 3) break;       }       if (c == n)         cout <<  Exemplary pages. ;       else if (c == n - 2) {         if (a[index[1]] > a[index[0]])           cout << (a[index[1]] - a[index[0]]) / 2 <<   ml. from cup #                 << index[0] + 1 <<   to cup #  << index[1] + 1 <<  . ;         else           cout << (a[index[0]] - a[index[1]]) / 2 <<   ml. from cup #                 << index[1] + 1 <<   to cup #  << index[0] + 1 <<  . ;       } else         cout <<  Unrecoverable configuration. ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long n, k, a, b;     cin >> n >> k >> a >> b;     if (k == 1) {       cout << (n - 1) * a << endl;       return 0;     }     long long ans = 0;     while (n != 1) {       if (n >= k) {         long long md = n % k;         ans += md * a;         n -= md;         long long prev = n;         long long curr = n / k;         ans += min(a * (prev - curr), b);         n /= k;       } else if (n < k) {         ans += (n - 1) * a;         break;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dcmp(double a, double b) {     return fabs(a - b) <= 0.0000000001 ? 0 : (a > b) ? 1 : -1;   }   int main() {     int x1, y1, x2, y2, r1, r2, R1, R2;     cin >> x1 >> y1 >> r1 >> R1 >> x2 >> y2 >> r2 >> R2;     double dis = sqrt((y2 - y1) * (y2 - y1) + (x2 - x1) * (x2 - x1));     int ans = 0;     if (dcmp(abs(dis - r1), R2) != -1 || dcmp(dis + r1, r2) != 1) ans++;     if (dcmp(abs(dis - R1), R2) != -1 || dcmp(dis + R1, r2) != 1) ans++;     if (dcmp(abs(dis - r2), R1) != -1 || dcmp(dis + r2, r1) != 1) ans++;     if (dcmp(dis + R2, r1) != 1 || dcmp(abs(dis - R2), R1) != -1) ans++;     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int x[100005], y[100005];     int i, n, d = 0, k = 0, cnt = 0;     cin >> n;     cin >> x[0] >> y[0];     d = x[0];     k = y[0];     for (i = 1; i <= n; i++) {       cin >> x[i] >> y[i];       if (y[i] > y[i - 1]) {         k = y[i];       }     }     cnt = (n - 4) / 2;     cout << cnt;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize(3,  inline,Ofast )   using namespace std;   int siz[1505], ans[1505], X, Y, n;   bool vis[1505];   vector<int> fir[1505];   struct P {     int x, y, d;     bool operator<(const P& o) const {       if (x - X >= 0 && o.x - X <= 0) return 1;       if (x - X <= 0 && o.x - X >= 0) return 0;       return 1ll * (y - Y) * (o.x - X) < 1ll * (o.y - Y) * (x - X);     }   } poi[1505];   void dfs(int u, int f) {     siz[u] = 1;     for (int v : fir[u])       if (v != f) dfs(v, u), siz[u] += siz[v];   }   void get(int l, int r, int o) {     vis[o] = 1;     int t = l;     for (int i = l + 1; i <= r; ++i)       if ((poi[i].y < poi[t].y) || (poi[t].y == poi[i].y && poi[i].x < poi[t].x))         t = i;     if (t != l) swap(poi[l], poi[t]);     ans[poi[l].d] = o;     X = poi[l].x;     Y = poi[l].y;     sort(poi + l + 1, poi + r + 1);     int pos = l + 1;     for (int v : fir[o])       if (!vis[v]) {         get(pos, pos + siz[v] - 1, v);         pos += siz[v];       }   }   int main() {     scanf( %d , &n);     for (int i = 1, u, v; i < n; ++i) {       scanf( %d%d , &u, &v);       fir[u].push_back(v);       fir[v].push_back(u);     }     for (int i = 1, x, y; i <= n; ++i) {       scanf( %d%d , &x, &y);       poi[i] = P{x, y, i};     }     dfs(1, 0);     get(1, n, 1);     for (int i = 1; i <= n; ++i) printf( %d  , ans[i]);     return 0;   }