malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long x[1000006] = {}, y[1000006] = {}, a[1000006] = {}, b[1000006] = {},             x2[1000006][3], y2[1000006][3];   long long dfs(int i, long long xx, long long yy, long long px[4][2]) {     int k = i % 4;     for (int jj = 0; jj < k - 1; jj++) {       if (xx == px[jj][0] && yy == px[jj][1]) return -1;     }     px[k][0] = xx;     px[k][1] = yy;     if (i % 4 < 3) {       long long c1 = dfs(i + 1, x[i + 1], y[i + 1], px);       long long c2 = -1;       for (int jj = 0; jj < 3; jj++) {         long long c3 = dfs(i + 1, x2[i + 1][jj], y2[i + 1][jj], px);         if (c3 >= 0 && c2 == -1)           c2 = c3 + jj + 1;         else if (c3 >= 0 && c2 >= 0)           c2 = min(c2, c3 + jj + 1);       }       if (c1 < 0 && c2 < 0)         return -1;       else if (c1 >= 0 && c2 >= 0)         return min(c1, c2);       else if (c1 >= 0)         return c1;       else         return c2;     }     vector<long long> vm;     map<long long, long long> jk;     for (int ii = 0; ii < 4; ii++) {       for (int jj = ii + 1; jj < 4; jj++) {         long long rr = (px[ii][0] - px[jj][0]) * (px[ii][0] - px[jj][0]) +                        (px[ii][1] - px[jj][1]) * (px[ii][1] - px[jj][1]);         if (jk.find(rr) == jk.end()) {           jk[rr] = 1;           vm.push_back(rr);         } else           jk[rr]++;       }     }     if (vm.size() > 2) return -1;     sort(vm.begin(), vm.end());     if (jk[vm[0]] == 4 && jk[vm[1]] == 2 && 2 * vm[0] == vm[1])       return 0;     else       return -1;   }   long long check(int st) {     int i = st;     long long px[4][2] = {};     long long c1 = dfs(st, x[st], y[st], px);     long long c2 = -1;     for (int jj = 0; jj < 3; jj++) {       long long c3 = dfs(st, x2[i][jj], y2[i][jj], px);       if (c3 >= 0 && c2 == -1)         c2 = c3 + jj + 1;       else if (c3 >= 0 && c2 >= 0)         c2 = min(c2, c3 + jj + 1);     }     if (c1 < 0 && c2 < 0)       return -1;     else if (c1 >= 0 && c2 >= 0)       return min(c1, c2);     else if (c1 >= 0)       return c1;     else       return c2;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n;     cin >> n;     for (int i = 0; i < 4 * n; i++) {       cin >> x[i] >> y[i] >> a[i] >> b[i];       int fx = x[i] - a[i];       int fy = y[i] - b[i];       for (int j = 2; j >= 0; j--) {         x2[i][j] = fy;         y2[i][j] = (-1) * fx;         fx = x2[i][j];         fy = y2[i][j];       }       for (int j = 0; j < 3; j++) {         x2[i][j] += a[i];         y2[i][j] += b[i];       }     }     for (int i = 0; i < 4 * n; i += 4) {       long long ct = 0;       ct = check(i);       if (ct >= 0)         cout << ct << endl;       else         cout <<  -1 n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int count = 0, sum = 0;     int n;     cin >> n;     int arr[101];     for (int i = 0; i < n; i++) {       cin >> arr[i];     }     for (int i = 0; i < n; i++) {       sum += arr[i];     }     for (int i = 0; i < n; i++) {       if ((sum - arr[i]) % 2 == 0) count++;     }     cout << count;     return 0;   }
#include <bits/stdc++.h>   int cnt[1001][1001], que[1000001][2], head = -1, tail;   char map[1001][1001];   int n, m;   int main() {     int i, j, a, go[4][2] = {1, 0, 0, 1, -1, 0, 0, -1}, print;     scanf( %d %d , &n, &m);     for (i = 0; i < n; i++) {       scanf( %s , map[i]);       for (j = 0; j < m; j++) {         if (map[i][j] ==  E ) {           que[++head][0] = i;           que[head][1] = j;           cnt[i][j] = 1;         }       }     }     while (head >= tail) {       i = que[tail][0];       j = que[tail++][1];       for (a = 0; a < 4; a++) {         if (i + go[a][0] >= 0 && j + go[a][1] >= 0 && i + go[a][0] < n &&             j + go[a][1] < m && map[i + go[a][0]][j + go[a][1]] !=  T  &&             cnt[i + go[a][0]][j + go[a][1]] == 0) {           que[++head][0] = i + go[a][0];           que[head][1] = j + go[a][1];           cnt[i + go[a][0]][j + go[a][1]] = cnt[i][j] + 1;         }       }     }     for (i = 0; i < n; i++) {       for (j = 0; j < m; j++) {         if (map[i][j] ==  S ) print = cnt[i][j];       }     }     int sum = 0;     for (i = 0; i < n; i++) {       for (j = 0; j < m; j++) {         if (print >= cnt[i][j] && map[i][j] >=  0  && map[i][j] <=  9  &&             cnt[i][j] != 0)           sum += map[i][j] -  0 ;       }     }     printf( %d n , sum);     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:256000000 )   using namespace std;   const int maxN = 80;   long long f[maxN];   int d[maxN];   const int maxD = 1000;   const int K = 13;   int dp[maxD][maxD];   bool filled = false;   pair<int, int> get(int order, long long x) {     if (order == K && filled) {       return make_pair(dp[x][1], dp[x][f[K]]);     }     if (order == 0) {       return make_pair(0, 0);     }     if (order == 1) {       return make_pair(x != 1, x != 2);     }     if (x > f[order - 1]) {       int add = 0;       while (order > 1 && x > f[order - 1]) {         x -= f[order - 1];         order -= 2;         ++add;       }       pair<int, int> current = get(order, x);       return make_pair(current.first + add, current.second);     }     pair<int, int> current = get(order - 1, x);     int toOne = min(current.first, current.second + 2);     int toN = min(current.first, current.second) + 1 + d[order - 2];     return make_pair(toOne, toN);   }   int calc(int order, long long x, long long y) {     if (order == K && filled) {       return dp[x][y];     }     if (x == y) {       return 0;     }     if (x > y) {       swap(x, y);     }     if (order == 1) {       return x != y;     }     if (order == 0) {       return 0;     }     if (f[order - 1] >= y) {       pair<int, int> a = get(order - 1, x);       pair<int, int> b = get(order - 1, y);       int score = min(a.first + b.second, a.second + b.first) + 2;       return min(score, calc(order - 1, x, y));     }     if (x > f[order - 1]) {       while (order > 1 && x > f[order - 1]) {         x -= f[order - 1];         y -= f[order - 1];         order -= 2;       }       return calc(order, x, y);     }     pair<int, int> a = get(order - 2, y - f[order - 1]);     pair<int, int> b = get(order - 1, x);     return min(b.first, b.second) + 1 + a.first;   }   void gen() {     int t = 100000;     int n = 1000;     cout << t <<     << n << endl;     for (int i = 0; i < t; ++i) {       long long x = 1LL * rand() * rand() * rand() + 1LL;       long long y = 1LL * rand() * rand() * rand() + 1LL;       cout << x <<     << y << endl;     }   }   int main() {     f[0] = 1;     f[1] = 2;     for (int i = 2; i < maxN; ++i) {       f[i] = f[i - 1] + f[i - 2];     }     d[0] = 0;     d[1] = 1;     for (int i = 2; i < maxN; ++i) {       d[i] = d[i - 2] + 1;     }     for (int i = 1; i <= f[K]; ++i) {       for (int j = i; j <= f[K]; ++j) {         dp[i][j] = dp[j][i] = calc(K, i, j);       }     }     cerr << clock() << endl;     filled = true;     int t, n;     scanf( %d%d , &t, &n);     if (n >= maxN) {       n = maxN - 1;     }     for (int i = 1; i <= t; ++i) {       long long u, v;       scanf( %I64d%I64d , &u, &v);       if (u > v) {         swap(u, v);       }       int m = n;       while (m > 20 && f[m - 5] >= v) {         --m;       }       printf( %d n , calc(m, u, v));     }     cerr << clock() << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, i, m, r = 0, t;     cin >> n;     for (i = 0; i < n; i++) {       cin >> m;       while ((m) && (r)) {         if (m > r)           m %= r;         else           r %= m;       }       r += m;     }     cout << r * n << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 8;   const int M = 100010;   const int INF = 1 << 30;   int n, q;   map<int, int> sum, val;   void init() {     sum.clear();     val.clear();   }   void add(int p, int v) {     if (val.find(p) == val.end()) val[p] = 0;     val[p] += v;     while (p) {       if (sum.find(p) == sum.end()) sum[p] = 0;       sum[p] += v;       p /= 2;     }   }   double dfs(int h, int u, double Max) {     if (h == n) {       if (val.find(u) == val.end())         return 0.0;       else         return max(Max, (double)val[u]);     }     int l = u * 2, r = u * 2 + 1;     double L = (sum[u] - sum[r]);     double R = (sum[u] - sum[l]);     double ans1 = max(Max, R);     double ans2 = max(Max, L);     if ((double)sum[l] > Max) ans1 = max(ans1, dfs(h + 1, l, ans1));     if ((double)sum[r] > Max) ans2 = max(ans2, dfs(h + 1, r, ans2));     return (ans1 + ans2) * 0.5;   }   void solve() {     char qry[3];     while (q--) {       scanf( %s , &qry);       if (qry[0] ==  a ) {         int p, v;         scanf( %d %d , &p, &v);         add(p, v);       } else {         double res = dfs(0, 1, 0.0);         printf( %.10lf n , res);       }     }   }   int main() {     while (cin >> n >> q) {       init();       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   const int M = 220000;   vector<int> e1[M], e2[M];   int p[M], dis[M];   int main() {     int n, m;     cin >> n >> m;     for (int i = 0; i < m; i++) {       int u, v;       cin >> u >> v;       e1[u].push_back(v);       e2[v].push_back(u);     }     int k;     cin >> k;     for (int i = 0; i < k; i++) cin >> p[i];     queue<int> q;     q.push(p[k - 1]);     dis[p[k - 1]] = 1;     while (!q.empty()) {       int u = q.front();       q.pop();       for (int v : e2[u]) {         if (dis[v] == 0) {           dis[v] = dis[u] + 1;           q.push(v);         }       }     }     int mi = 0, mx = 0;     for (int i = 0; i < k - 1; i++) {       if (dis[p[i]] != dis[p[i + 1]] + 1) ++mi;       for (int v : e1[p[i]]) {         if (v != p[i + 1] && dis[p[i]] == dis[v] + 1) {           ++mx;           break;         }       }     }     cout << mi <<     << mx << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int nums[n];     for (int i = 0; i < n; i++) {       cin >> nums[i];     }     if ((nums[0] % 2 == 0)) {       cout <<  No ;       return 0;     }     if ((nums[n - 1] % 2 == 0)) {       cout <<  No ;       return 0;     }     if ((n % 2) == 0) {       cout <<  No ;       return 0;     }     cout <<  Yes ;     return 0;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int treeNo[111111];   vector<vector<int> > BIT;   vector<pair<int, int> > E[111111];   int in[111111];   int base[111111];   int P[111111], depth[111111];   void update(int x, int val, int id) {     for (; x < BIT[id].size(); x += (x & -x)) BIT[id][x] += val;   }   int read(int x, int id) {     int sum = 0;     for (; x; x -= (x & -x)) sum += BIT[id][x];     return sum;   }   void dfs(int first, int par, int d, int id) {     P[first] = par;     depth[first] = d;     BIT[id].push_back(0);     treeNo[first] = id;     for (int i = 0; i < E[first].size(); i++) {       int u = E[first][i].first;       if (u == par) continue;       dfs(u, first, d + 1, id);       base[E[first][i].second] = u;     }   }   int main() {     int N;     cin >> N;     int u, first;     for (int i = 1; i < N; i++) {       cin >> u >> first;       E[u].push_back({first, i});       E[first].push_back({u, i});       in[u]++;       in[first]++;     }     int root = 0;     for (int i = 1; i <= N; i++)       if (in[i] > 2) root = i;     if (root == 0)       for (int i = 1; i <= N; i++)         if (in[i] == 1) root = i;     BIT.resize(E[root].size());     for (int i = 0; i < E[root].size(); i++) {       BIT[i].push_back(0);       dfs(E[root][i].first, root, 1, i);       base[E[root][i].second] = E[root][i].first;     }     int Q, t;     cin >> Q;     while (Q--) {       scanf( %d %d , &t, &first);       if (t == 3) {         scanf( %d , &u);         if (u == root or first == root) {           if (u == root) swap(u, first);           int sum = read(depth[u], treeNo[u]);           if (sum == 0)             printf( %d n , depth[u]);           else             printf( -1 n );         } else if (treeNo[u] == treeNo[first]) {           if (depth[u] == depth[first])             printf( 0 n );           else {             if (depth[first] < depth[u]) swap(u, first);             int sum =                 read(depth[first], treeNo[first]) - read(depth[u], treeNo[first]);             if (sum == 0)               printf( %d n , depth[first] - depth[u]);             else               printf( -1 n );           }         } else {           int sum = read(depth[u], treeNo[u]) + read(depth[first], treeNo[first]);           if (sum == 0)             printf( %d n , depth[first] + depth[u]);           else             printf( -1 n );         }       } else if (t == 2) {         int b = base[first];         update(depth[b], 1, treeNo[b]);       } else if (t == 1) {         int b = base[first];         update(depth[b], -1, treeNo[b]);       }     }   }
#include <bits/stdc++.h>   long long exp(long long x, long long p) {     long long ret = 1;     while (p > 0) {       if (p & 1) {         ret = (ret * x) % 1000000007;       }       p >>= 1;       x = (x * x) % 1000000007;     }     return ret;   }   signed main() {     std::ios::sync_with_stdio(false);     std::cin.tie(0);     std::cout.tie(0);     long long t;     std::cin >> t;     std::vector<long long> powers(2000000, 0);     while (t--) {       long long n, p;       std::cin >> n >> p;       long long arr[n];       for (long long i = 0; i < n; i++) {         std::cin >> arr[i];       }       std::sort(arr, arr + n);       if (p == 1) {         if (n % 2)           std::cout << 1 << std::endl;         else           std::cout << 0 << std::endl;         continue;       }       long long ans = 0;       std::set<long long> pows;       long long r = n - 1;       long long cur = -1;       while (r >= 0) {         cur = arr[r];         r--;         while (r >= 0) {           powers[arr[r]]++;           pows.insert(arr[r]);           long long next = arr[r];           while (powers[next] == p) {             powers[next] = 0;             pows.erase(next);             powers[next + 1]++;             pows.insert(next + 1);             next++;           }           if (powers[cur]) {             powers[cur] = 0;             cur = -1;             pows.erase(cur);             r--;             break;           }           r--;         }       }       while (!pows.empty()) {         long long u = *pows.begin();         pows.erase(pows.begin());         ans = (ans + (exp(p, u) * powers[u]) % 1000000007) % 1000000007;         powers[u] = 0;       }       if (cur != -1) {         ans = (exp(p, cur) + 1000000007 - ans) % 1000000007;       }       std::cout << ans << std::endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 99999999;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n;     cin >> n;     if (n == 1) {       cout << 1;       return 0;     }     vector<int> a(n);     ;     for (int i = 0; i < (n); ++i) cin >> a[i];     ;     vector<int> c;     for (int j = 1; j < n; ++j) {       if (a[j] > a[j - 1])         c.push_back(1);       else if (a[j] < a[j - 1])         c.push_back(-1);       else         c.push_back(0);     }     vector<pair<int, int>> d;     int p = 1;     for (int k = 1; k < c.size(); ++k) {       if (c[k] == c[k - 1])         p++;       else {         d.push_back({p, c[k - 1]});         p = 1;       }     }     d.push_back({p, c[c.size() - 1]});     vector<int> answ;     if (d[0].second == 0)       answ.push_back(3);     else if (d[0].second == -1)       answ.push_back(5);     else       answ.push_back(1);     int last = 0;     for (int i = 0; i < d.size(); ++i) {       int cnt = d[i].first;       int type = d[i].second;       if (type == 0) {         bool f = answ[last] == 3;         for (int j = 0; j < cnt - 1; ++j) {           if (f)             answ.push_back(4);           else             answ.push_back(3);           f = !f;           last++;         }         if (i + 1 < d.size() && d[i + 1].second == -1) {           if (answ[last] == 5)             answ.push_back(4);           else             answ.push_back(5);           last++;         } else if (i + 1 < d.size() && d[i + 1].second == 1) {           if (answ[last] == 1)             answ.push_back(2);           else             answ.push_back(1);           last++;         } else {           if (answ[last] == 4)             answ.push_back(3);           else             answ.push_back(4);           last++;         }       } else {         for (int j = 0; j < cnt - 1; ++j) {           answ.push_back(answ[last] + type);           last++;         }         if (answ[last] > 5 || answ[last] < 1) {           cout << -1;           return 0;         }         if (i + 1 < d.size() && d[i + 1].second == -1) {           if (answ[last] == 5) {             cout << -1;             return 0;           }           answ.push_back(5);           last++;         } else if (i + 1 < d.size() && d[i + 1].second == 1) {           if (answ[last] == 1) {             cout << -1;             return 0;           }           answ.push_back(1);           last++;         } else {           answ.push_back(answ[last] + type);           last++;           if (answ[last] > 5 || answ[last] < 1) {             cout << -1;             return 0;           }         }       }     }     for (int l = 0; l < n; ++l) {       cout << answ[l] <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int LIM = 3e5 + 7;   int T[LIM][10], n, m, ans1, ans2;   bool spr(int x) {     vector<int> V[1 << m];     for (int i = 0; i < (n); ++i) {       int l = 0;       for (int j = 0; j < (m); ++j) {         if (T[i][j] >= x) l += 1 << j;       }       V[l].push_back(i);     }     for (int i = 0; i < (1 << m); ++i) {       if (!V[i].size()) continue;       for (int j = 0; j < (1 << m); ++j) {         if (!V[j].size()) continue;         if ((i | j) == (1 << m) - 1) {           ans1 = V[i][0];           ans2 = V[j][0];           return true;         }       }     }     return false;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n >> m;     for (int i = 0; i < (n); ++i)       for (int j = 0; j < (m); ++j) cin >> T[i][j];     int p = 0, k = 1000000000;     while (p < k) {       int sr = (p + k) / 2;       if (spr(sr))         p = sr + 1;       else         k = sr - 1;     }     spr(p);     cout << ans1 + 1 <<     << ans2 + 1 <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int minimumStones(string s, int n) {     int i = 0, counts = 0;     while (s[i] ==  - ) {       counts++;       i++;     }     for (int i = 0; i < n; i++) {       if (s[i] ==  - )         counts--;       else         counts++;       if (counts == 0) {         int j = i + 1;         while (s[j] ==  - ) {           counts++;           j++;         }       }     }     return counts;   }   int main() {     int n;     cin >> n;     string s;     cin >> s;     cout << minimumStones(s, n);   }
#include <bits/stdc++.h>   using namespace std;   const double EPS = 1e-3;   const int SZ = 4000050, INF = 0x7FFFFFFF;   const double PI = acos(-1);   struct nd {     double a, b, c, d, e;     nd(double _a = 0, double _b = 0, double _c = 0, double _d = 0, double _e = 0)         : a(_a), b(_b), c(_c), d(_d), e(_e) {}     nd operator-(nd &rbs) {       return nd(a - rbs.a, b - rbs.b, c - rbs.c, d - rbs.d, e - rbs.e);     }   };   double len(nd &x) {     double res = sqrt(x.a * x.a + x.b * x.b + x.c * x.c + x.d * x.d + x.e * x.e);     return res;   }   double Dot(nd &x, nd &y) {     return (x.a * y.a + x.b * y.b + x.c * y.c + x.d * y.d + x.e * y.e) / len(x) /            len(y);   }   bool test(nd &x, nd &y) {     double ang = acos(Dot(x, y));     return ang < (PI / 2) && fabs(ang - (PI / 2)) > EPS;   }   int main() {     int pnum;     cin >> pnum;     vector<nd> vct;     if (pnum > 11) {       cout << 0 << endl;       return 0;     }     for (int i = 0; i < pnum; ++i) {       nd tmp;       cin >> tmp.a >> tmp.b >> tmp.c >> tmp.d >> tmp.e;       vct.push_back(tmp);     }     vector<int> res;     for (int i = 0; i < pnum; ++i) {       bool ok = 1;       for (int j = 0; j < pnum; ++j) {         if (j == i) continue;         for (int k = 0; k < pnum; ++k) {           if (k == j) continue;           nd ac = vct[j] - vct[i];           nd bc = vct[k] - vct[i];           if (test(ac, bc)) ok = 0;         }       }       if (ok) {         res.push_back(i + 1);       }     }     cout << res.size() << endl;     for (int i = 0; i < res.size(); ++i) {       cout << res[i] << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 5, K = 300;   int n, mx, ct, ans, a[N], buc[N], lst[N * 2], tp[N], cnt;   inline void Add(int x, int k) {     cnt -= (tp[x] == ct), tp[x] += k, cnt += (tp[x] == ct);   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i) scanf( %d , a + i), ++buc[a[i]];     mx = max_element(buc + 1, buc + n + 1) - buc;     for (ct = 1; ct <= K; ++ct) {       memset(tp, 0, sizeof(tp)), cnt = 0;       for (int l = 1, r = 1; r <= n; ++r) {         Add(a[r], 1);         while (tp[a[r]] > ct) Add(a[l++], -1);         if (cnt > 1) ans = max(ans, r - l + 1);       }     }     for (int i = 1, s; i <= n; ++i)       if (i != mx && buc[i] > K) {         memset(lst, -1, sizeof(lst)), lst[s = n] = 0;         for (int j = 1; j <= n; ++j) {           s += a[j] == mx ? 1 : (a[j] == i ? -1 : 0);           if (~lst[s])             ans = max(ans, j - lst[s]);           else             lst[s] = j;         }       }     printf( %d , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long getnum() {     char c = getchar();     long long num, sign = 1;     for (; c <  0  || c >  9 ; c = getchar())       if (c ==  - ) sign = -1;     for (num = 0; c >=  0  && c <=  9 ;) {       c -=  0 ;       num = num * 10 + c;       c = getchar();     }     return num * sign;   }   int main() {     int n = getnum(), m = getnum();     int ans = 0;     while (1) {       if ((ans * n) % 10 == 0 && ans > 0) {         cout << ans;         return 0;       }       if ((ans * n - m) % 10 == 0) {         cout << ans;         return 0;       }       ans++;     }   }
#include <bits/stdc++.h>   using namespace std;   long long tree[400005];   int n;   long long r[100005], h[100005], v[100005];   pair<long long, int> p[100005];   int mp[100005];   void update(int nd, int bb, int ee, int ii, long long vv) {     if (bb == ee && bb == ii) {       tree[nd] = vv;       return;     }     if (bb > ii || ee < ii) return;     int ll = nd << 1, rr = ll | 1, mm = (bb + ee) >> 1;     update(ll, bb, mm, ii, vv);     update(rr, mm + 1, ee, ii, vv);     tree[nd] = max(tree[ll], tree[rr]);     return;   }   long long query(int nd, int bb, int ee, int ii, int jj) {     if (jj < ii) return 0;     if (bb >= ii && ee <= jj) return tree[nd];     if (bb > jj || ee < ii) return 0;     int ll = nd << 1, rr = ll | 1, mm = (bb + ee) >> 1;     return max(query(ll, bb, mm, ii, jj), query(rr, mm + 1, ee, ii, jj));   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(nullptr);     cin >> n;     for (int i = 0; i < n; i++) {       cin >> r[i] >> h[i];       p[i] = {r[i] * r[i] * h[i], i};     }     sort(p, p + n);     for (int i = 0, ii = 0; i < n; i++) {       if (i > 0 && p[i].first == p[i - 1].first) ii--;       mp[p[i].second] = ii;       ii++;     }     for (int i = 0; i < n; i++) {       update(1, 0, n - 1, mp[i],              r[i] * r[i] * h[i] + query(1, 0, n - 1, 0, mp[i] - 1));     }     cout << fixed << setprecision(9) << double(tree[1]) * acos(-1.0) <<   n ;     return 0;   }