malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int solveA(pair<pair<int, int>, int> x, pair<pair<int, int>, int> y,              pair<pair<int, int>, int> z) {     pair<int, int> a = x.first;     pair<int, int> b = y.first;     pair<int, int> c = z.first;     int n = a.first + b.first + c.first;     if (n != a.second) return -1;     if (n != b.second) return -1;     if (n != c.second) return -1;     cout << n <<   n ;     for (int i = 1; i <= a.first; ++i) {       for (int j = 1; j <= a.second; ++j) {         cout << (char)( A  + x.second);       }       cout <<   n ;     }     for (int i = 1; i <= b.first; ++i) {       for (int j = 1; j <= b.second; ++j) {         cout << (char)( A  + y.second);       }       cout <<   n ;     }     for (int i = 1; i <= c.first; ++i) {       for (int j = 1; j <= c.second; ++j) {         cout << (char)( A  + z.second);       }       cout <<   n ;     }     return n;   }   int solveB(pair<pair<int, int>, int> x, pair<pair<int, int>, int> y,              pair<pair<int, int>, int> z) {     pair<int, int> a = x.first;     pair<int, int> b = y.first;     pair<int, int> c = z.first;     int n = a.first;     if (n != b.first + c.first) return -1;     if (n != b.second + a.second) return -1;     if (n != c.second + a.second) return -1;     cout << n <<   n ;     for (int i = 1; i <= a.second; ++i) {       for (int j = 1; j <= n; ++j) {         cout << (char)( A  + x.second);       }       cout <<   n ;     }     for (int i = 1; i <= b.second; ++i) {       for (int j = 1; j <= b.first; ++j) {         cout << (char)( A  + y.second);       }       for (int j = 1; j <= c.first; ++j) {         cout << (char)( A  + z.second);       }       cout <<   n ;     }     return n;   }   int main(int argc, const char* argv[]) {     pair<int, int> a[3];     cin >> a[0].first >> a[0].second;     cin >> a[1].first >> a[1].second;     cin >> a[2].first >> a[2].second;     pair<pair<int, int>, int> b[3];     for (int i = 0; i < 8; ++i) {       if (i & 1)         b[0].first = a[0];       else         b[0].first = make_pair(a[0].second, a[0].first);       if (i >> 1 & 1)         b[1].first = a[1];       else         b[1].first = make_pair(a[1].second, a[1].first);       if (i >> 2 & 1)         b[2].first = a[2];       else         b[2].first = make_pair(a[2].second, a[2].first);       for (int i = 0; i <= 2; ++i) {         b[i].second = i;       }       sort(b, b + 3);       do {         int n;         n = solveA(b[0], b[1], b[2]);         if (n != -1) {           return 0;         }         n = solveB(b[0], b[1], b[2]);         if (n != -1) {           return 0;         }       } while (next_permutation(b, b + 3));     }     cout << -1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3005;   const int inf = 5e8;   vector<int> to[N], from[N];   int d[N][N], b[N][N];   vector<pair<int, int>> go[N], back[N];   bool done[N];   int n;   void bfs(vector<int>* edge, int dist[N][N], vector<pair<int, int>>* ret) {     for (int i = 0; i < N; i++) {       for (int j = 0; j < N; j++) {         dist[i][j] = -inf;       }     }     for (int i = 1; i <= n; i++) {       memset(done, 0, sizeof(done));       queue<int> q;       done[i] = 1;       q.push(i);       dist[i][i] = 0;       while (!q.empty()) {         int now = q.front();         q.pop();         for (auto it : edge[now]) {           if (!done[it]) {             done[it] = 1;             dist[i][it] = dist[i][now] + 1;             q.push(it);           }         }       }     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         if (i != j) {           ret[i].emplace_back(dist[i][j], j);         }       }       sort(ret[i].begin(), ret[i].end());       reverse(ret[i].begin(), ret[i].end());     }   }   pair<int, int> get(int p, vector<pair<int, int>>* ret, vector<int>& ojo) {     for (auto it : ret[p]) {       bool ada = 0;       for (auto j : ojo) {         if (it.second == j) {           ada = 1;           break;         }       }       if (!ada) return it;     }     return {-inf, -inf};   }   int main() {     int m;     scanf( %d %d , &n, &m);     while (m--) {       int u, v;       scanf( %d %d , &u, &v);       to[u].push_back(v);       from[v].push_back(u);     }     bfs(to, d, go);     bfs(from, b, back);     int ans = -inf, ai, aj, ak, al;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         assert(d[i][j] == b[j][i]);         if (i == j) continue;         vector<int> ojo = {i, j};         pair<int, int> lef = get(i, back, ojo);         pair<int, int> rig = get(j, go, ojo);         vector<int> tmp;         if (lef.second == rig.second) {           tmp = {i, j, lef.second};           pair<int, int> l = get(i, back, tmp);           int cur = d[i][j] + l.first + rig.first;           if (cur > ans) {             ans = cur;             ai = l.second;             aj = i;             ak = j;             al = rig.second;           }           pair<int, int> r = get(j, go, tmp);           cur = d[i][j] + lef.first + r.first;           if (cur > ans) {             ans = cur;             ai = lef.second;             aj = i;             ak = j;             al = r.second;           }         } else {           int cur = d[i][j] + lef.first + rig.first;           if (cur > ans) {             ans = cur;             ai = lef.second;             aj = i;             ak = j;             al = rig.second;           }         }       }     }     printf( %d %d %d %d n , ai, aj, ak, al);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dr[] = {-1, -1, -1, 0, 0, 1, 1, 1};   int dc[] = {-1, 0, 1, -1, 1, -1, 0, 1};   struct node {     int r, c, dist;     node() {}     node(int _r, int _c, int _dist) : r(_r), c(_c), dist(_dist) {}   };   set<pair<int, int> > valid, visited;   int main() {     int r0, c0, r1, c1, n;     int i, j, r, a, b;     scanf( %d%d%d%d%d , &r0, &c0, &r1, &c1, &n);     for (i = 1; i <= n; ++i) {       scanf( %d%d%d , &r, &a, &b);       for (j = a; j <= b; ++j) valid.insert(make_pair(r, j));     }     int ans = -1;     queue<node> Q;     Q.push(node(r0, c0, 0));     visited.insert(make_pair(r0, c0));     while (Q.size() > 0) {       node cur = Q.front();       Q.pop();       if (cur.c == c1 && cur.r == r1) {         ans = cur.dist;         break;       }       for (i = 0; i < 8; ++i) {         int r2 = cur.r + dr[i];         int c2 = cur.c + dc[i];         if (valid.find(make_pair(r2, c2)) != valid.end() &&             visited.find(make_pair(r2, c2)) == visited.end()) {           visited.insert(make_pair(r2, c2));           Q.push(node(r2, c2, cur.dist + 1));         }       }     }     printf( %d , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b;     cin >> a >> b;     vector<int> arr;     arr.push_back(b);     while (b > a) {       if (b % 10 == 1)         arr.push_back(b /= 10);       else if (b % 2 == 1) {         cout <<  NO  << endl;         return 0;       } else         arr.push_back(b /= 2);     }     if (arr.back() != a) {       cout <<  NO  << endl;       return 0;     }     cout <<  YES n  << arr.size() << endl;     for (auto it = arr.rbegin(); it != arr.rend(); ++it) cout << *it <<    ;   }
#include <bits/stdc++.h>   int main() {     int num;     scanf( %d , &num);     int res = 0;     for (int i = 0; i < num; i++) {       char shape[30];       scanf( %s , shape);       switch (shape[0]) {         case  T :           res += 4;           break;         case  C :           res += 6;           break;         case  O :           res += 8;           break;         case  D :           res += 12;           break;         case  I :           res += 20;           break;       }     }     printf( %d n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, len, vf, va, k;     cin >> n >> len >> vf >> va >> k;     long long bl = (n + k - 1) / k;     double eff = static_cast<double>(va - vf) / (va + vf);     double koef = (va + (bl + (bl - 1) * eff - 1) * vf);     double ta = len / koef;     double ans = ta * (bl + (bl - 1) * eff);     cout << setprecision(15) << ans << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize  trapv    using namespace std;   void solveEachTest(long long int T35TC453N = 1) {     unsigned long long int a, b;     cin >> a >> b;     bool ok = true;     bitset<64> xandy((a - b) / 2);     bitset<64> xxory(b);     unsigned long long int x = (a - b) / 2;     unsigned long long int y = x + b;     if (a < b) ok = false;     for (auto i = (0); (((1) < 0) ? (i) > (64) : (i) < (64)); (i) += (1)) {       if (xandy[i] == 1 and xxory[i] == 1) {         ok = false;         break;       }     }     if (!ok)       cout <<  -1 ;     else       cout << x <<     << y;     cout <<   n ;     return;   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     long long int T3X0 = 0, T353 = 1;     solveEachTest(T353 - T3X0);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int k;   string res;   int c[500];   int main(void) {     for (int i = 2; i < 449; i++) {       c[i] = i * (i - 1) / 2;     }     scanf( %d , &k);     if (k == 0) {       cout <<  a  << endl;     }     char cur =  a ;     while (k > 0) {       int takeind = upper_bound(c + 2, c + 449, k) - c - 1;       k -= c[takeind];       for (int i = 0; i < takeind; i++) {         res += cur;       }       cur++;     }     cout << res << endl;   }
#include <bits/stdc++.h>   int main() {     double n2, a, b, c, n1;     scanf( %lf %lf %lf , &a, &b, &c);     n1 = ((-b + pow((b * b - 4 * a * c), 0.5)) / (a * 2));     n2 = ((-b - pow((b * b - 4 * a * c), 0.5)) / (a * 2));     if (n1 >= n2)       printf( %lf %lf , n1, n2);     else       printf( %lf %lf , n2, n1);     return 0;   }
#include <bits/stdc++.h>   const int inf = 1e9 + 7;   const int md = 1e9 + 7;   const double eps = -1e5;   using namespace std;   int n, ans, x, y;   bool a[1001][1001];   bool isin(int x, int y) { return x > 0 && x <= 1000 && y > 0 && y <= 1000; }   int main() {     cin >> n;     for (int i = 0; i < n; i++) {       cin >> x >> y;       a[x][y] = true;     }     for (int x = 1; x <= 1000; x++)       for (int y = 1; y <= 1000; y++)         if (a[x][y]) {           for (int xx = x, yy = y; isin(xx, yy); xx--, yy--) ans += a[xx][yy];           ans--;           for (int xx = x, yy = y; isin(xx, yy); xx++, yy--) ans += a[xx][yy];           ans--;           for (int xx = x, yy = y; isin(xx, yy); xx--, yy++) ans += a[xx][yy];           ans--;           for (int xx = x, yy = y; isin(xx, yy); xx++, yy++) ans += a[xx][yy];           ans--;         }     cout << ans / 2;   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-9;   const int maxn = 1e5 + 5;   long long h[maxn], l[maxn], r[maxn];   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; ++i) scanf( %lld , &h[i]);     l[1] = r[n] = 1;     for (int i = 2; i <= n; ++i) l[i] = min(h[i], l[i - 1] + 1);     for (int i = n - 1; i >= 1; --i) r[i] = min(h[i], r[i + 1] + 1);     long long ans = 0;     for (int i = 1; i <= n; ++i) {       long long now = min(l[i], r[i]);       if (now > ans) ans = now;     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, k, tot, i;     cin >> n >> k;     tot = n * (n - 1) / 2;     if (tot <= k) {       cout <<  no solution ;     } else {       for (i = 0; i < n; i++) {         cout << 0 <<     << i << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 300000;   int parent[N], size[N];   vector<pair<int, pair<int, int>>> v;   pair<int, int> q[N];   long long ans[N];   int Find(int a) {     if (parent[a] == a) return a;     return parent[a] = Find(parent[a]);   }   void Union(int a, int b) { parent[Find(b)] = Find(a); }   long long doit(int a, int b) {     int x = Find(a);     int y = Find(b);     long long p = size[x];     long long qq = size[y];     long long anss = p * qq;     size[x] += size[y];     Union(x, y);     return anss;   }   int main(int argc, char const *argv[]) {     for (int i = 0; i < N; i++) parent[i] = i, size[i] = 1;     int n, m, a, b, c;     scanf( %d%d , &n, &m);     for (int i = 0; i < n - 1; ++i) {       scanf( %d%d%d , &a, &b, &c);       v.push_back({c, {a, b}});     }     sort(v.begin(), v.end());     for (int i = 0; i < m; i++) {       scanf( %d , &a);       q[i] = {a, i};     }     sort(q, q + m);     int at = 0;     long long sum = 0;     for (int i = 0; i < m; i++) {       if (at < v.size()) {         while (v[at].first <= q[i].first) {           if (at >= v.size()) break;           long long kk = doit(v[at].second.first, v[at].second.second);           sum += kk;           at++;           if (at >= v.size()) break;         }       }       ans[q[i].second] = sum;     }     for (int i = 0; i < m; i++) {       printf( %lld  , ans[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main(int argc, char *argv[]) {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     string line;     while (getline(cin, line)) {       map<int, vector<string> > answer;       line +=  , ;       istringstream iss(line);       string s;       stack<int> stk;       string tmp;       while (getline(iss, s,  , )) {         getline(iss, tmp,  , );         int children = stoi(tmp);         answer[stk.size()].push_back(s);         if (stk.size() && stk.top() > 0) {           stk.top()--;         }         stk.push(children);         while (stk.size() && stk.top() <= 0) stk.pop();       }       cout << answer.size() << endl;       for (auto i = 0; i < answer.size(); i++) {         for (auto &word : answer[i]) cout << word <<    ;         cout << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k;   long long sum, s[1000005], ans = -(1LL << 62);   struct el {     long long val;     int poz;     bool operator<(const el &A) const { return val < A.val; }   };   el a[1000005];   int main() {     int i, poz;     cin.sync_with_stdio(0);     cin >> n;     for (i = 1; i <= n; ++i) {       cin >> a[i].val;       a[i].poz = i;     }     cin >> k;     sort(a + 1, a + n + 1);     for (i = 1; i <= n; ++i) s[i] = s[i - 1] + a[i].val;     for (i = 1, sum = 0; i <= k; ++i) sum += a[i].val * (2 * i - 1 - k);     ans = sum;     poz = 1;     for (i = k + 1; i <= n; ++i) {       sum = sum - a[i - k].val * (1 - k) + a[i].val * (k - 1) -             2 * (s[i - 1] - s[i - k]);       if (sum < ans) {         ans = sum;         poz = i - k + 1;       }     }     for (i = poz; i < poz + k; ++i) cout << a[i].poz <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int a, b, x, y, aa;     scanf( %I64d %I64d , &x, &y);     if (y > x) {       printf( -1 n );       return 0;     }     a = x / y;     if ((x % y) && (a % 2)) a++;     if (!(a % 2))       aa = a - 1;     else       aa = a;     double cc = (double)(x - aa * y);     double c = cc / (double)a;     double res = y + c;     printf( %0.11lf n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100010;   int N, M;   int ar[MAXN];   char s[MAXN];   int dn[MAXN][2];   int used[MAXN][2];   int f(int k, int flag) {     if (k == -1) return 0;     if (used[k][flag]) return dn[k][flag];     used[k][flag] = 1;     if (!flag) return dn[k][flag] = f(k - 1, 0) + ar[k];     if (s[k] ==  0 ) return dn[k][flag] = f(k - 1, 1);     if (s[k] ==  1 ) return dn[k][flag] = max(f(k - 1, 1) + ar[k], f(k - 1, 0));   }   int main() {     cin >> N;     for (int i = 0; i < N; i++) scanf(  %d , &ar[i]);     scanf(  %s , s);     cout << f(N - 1, 1) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char a[15];   char rr[15];   char ans[15];   int main() {     int maxx = -99;     cin >> a;     int len = strlen(a);     for (int i = 1; i < 1 << len; i++) {       int cnt = 0;       for (int j = 0; j <= len - 1; j++) {         if (i >> j & 1) rr[++cnt] = a[j];       }       int flag = 0;       for (int l = 1, r = cnt; l <= r; l++, r--) {         if (rr[l] != rr[r]) {           flag = 1;           break;         }       }       if (flag == 0) {         if (strcmp(ans + 1, rr + 1) < 0) {           for (int i = 1; i <= 14; i++) {             if (i <= cnt)               ans[i] = rr[i];             else               ans[i] =   0 ;           }         }       }     }     cout << ans + 1 << endl;   }
#include <bits/stdc++.h>   using namespace std;   int dist(int a, int b) { return min(abs(a - b), 360 - abs(a - b)); }   long long d;   int main() {     scanf( %I64d , &d);     d = (d % 360 + 360) % 360;     int ans = 1000;     for (int i = 0; i < 4; i++) ans = min(ans, dist(d, 90 * i));     for (int i = 0; i < 4; i++) {       if (dist(d, 90 * i) == ans) {         printf( %d n , i);         return 0;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e5 + 5;   const int MOD = 1e9 + 7;   int a[MAXN];   class Matrix {    public:     void prinf() {       for (int i = 0; i < 2; i++) {         for (int j = 0; j < 2; j++) {           cout << a[i][j];         }         cout << endl;       }     }     long long a[2][2];     Matrix() { memset(a, 0, sizeof a); }     void init() {       for (int i = 0; i < 2; i++)         for (int j = 0; j < 2; j++) a[i][j] = (i == j);     }     Matrix operator+(const Matrix &B) const {       Matrix C;       for (int i = 0; i < 2; i++)         for (int j = 0; j < 2; j++) C.a[i][j] = (a[i][j] + B.a[i][j]) % MOD;       return C;     }     Matrix operator*(const Matrix &B) const {       Matrix C;       for (int i = 0; i < 2; i++)         for (int k = 0; k < 2; k++)           for (int j = 0; j < 2; j++)             C.a[i][j] = (C.a[i][j] + 1LL * a[i][k] * B.a[k][j]) % MOD;       return C;     }     Matrix operator^(const int &t) const {       Matrix A = (*this), res;       res.init();       int p = t;       while (p) {         if (p & 1) res = res * A;         A = A * A;         p >>= 1;       }       return res;     }   };   Matrix sum[MAXN << 2], add[MAXN << 2], f;   void pushdown(int rt) {     sum[rt << 1] = sum[rt << 1] * add[rt];     sum[rt << 1 | 1] = sum[rt << 1 | 1] * add[rt];     add[rt << 1] = add[rt << 1] * add[rt];     add[rt << 1 | 1] = add[rt << 1 | 1] * add[rt];     add[rt].init();   }   void pushup(int rt) { sum[rt] = sum[rt << 1] + sum[rt << 1 | 1]; }   void build(int l, int r, int rt) {     sum[rt].init();     add[rt].init();     if (l == r) {       sum[rt] = f ^ (a[l] - 1);       return;     }     int m = (l + r) >> 1;     build(l, m, rt << 1);     build(m + 1, r, rt << 1 | 1);     pushup(rt);   }   void update(int L, int R, Matrix v, int l, int r, int rt) {     if (L <= l && R >= r) {       sum[rt] = sum[rt] * v;       add[rt] = add[rt] * v;       return;     }     pushdown(rt);     int m = (l + r) >> 1;     if (L <= m) update(L, R, v, l, m, rt << 1);     if (R > m) update(L, R, v, m + 1, r, rt << 1 | 1);     pushup(rt);   }   long long query(int L, int R, int l, int r, int rt) {     if (L <= l && R >= r) {       return sum[rt].a[0][0];     }     pushdown(rt);     int m = (l + r) >> 1;     int cnt = 0;     if (L <= m) cnt = (cnt + query(L, R, l, m, rt << 1)) % MOD;     if (R > m) cnt = (cnt + query(L, R, m + 1, r, rt << 1 | 1)) % MOD;     return cnt;   }   int main() {     int m, n;     f.a[0][0] = 1;     f.a[0][1] = 1;     f.a[1][0] = 1;     f.a[1][1] = 0;     scanf( %d %d , &n, &m);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     build(1, n, 1);     int a1, b, c;     for (int i = 0; i < m; i++) {       scanf( %d %d %d , &a1, &b, &c);       if (a1 == 1) {         int s;         scanf( %d , &s);         update(b, c, f ^ s, 1, n, 1);       } else {         cout << query(b, c, 1, n, 1) % MOD << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   vector<int> v[100146];   int val[100146], a[100146], b[100146];   long long cnt[1 << 18], sum[1 << 18];   int leftError[100146], rightError[100146];   void countDps(int e) {     if (v[e].size() == 0)       leftError[e] = rightError[e] = val[e];     else {       countDps(v[e][0]);       countDps(v[e][1]);       if (val[v[e][0]] < val[v[e][1]]) {         leftError[e] = leftError[v[e][0]];         rightError[e] = rightError[v[e][1]];       } else {         leftError[e] = leftError[v[e][1]];         rightError[e] = rightError[v[e][0]];       }     }   }   void add(long long* tree, int cur, int l, int r, int cl, int cr, long long c) {     if (r < cl || cr < l) return;     if (cl <= l && r <= cr)       tree[cur] += c;     else {       int mid = (l + r) / 2;       add(tree, cur * 2, l, mid, cl, cr, c);       add(tree, cur * 2 + 1, mid + 1, r, cl, cr, c);     }   }   void addToSegment(long long* tree, int l, int r, long long c) {     if (l > r) return;     add(tree, 1, 0, (1 << 17) - 1, l, r, c);   }   void dfs(int e, int l, int r) {     if (v[e].size() == 0) return;     int mid = lower_bound(a + l, a + r, val[e]) - a;     if (val[v[e][0]] < val[v[e][1]]) {       dfs(v[e][0], l, mid);       dfs(v[e][1], mid, r);       addToSegment(cnt, l, mid - 1, 1);       addToSegment(sum, l, mid - 1, leftError[v[e][1]]);       addToSegment(cnt, mid, r - 1, 1);       addToSegment(sum, mid, r - 1, rightError[v[e][0]]);     } else {       dfs(v[e][1], l, mid);       dfs(v[e][0], mid, r);       addToSegment(cnt, l, mid - 1, 1);       addToSegment(sum, l, mid - 1, leftError[v[e][0]]);       addToSegment(cnt, mid, r - 1, 1);       addToSegment(sum, mid, r - 1, rightError[v[e][1]]);     }   }   long long getValue(long long* tree, int el) {     long long cur = el + (1 << 17);     long long ans = 0;     while (cur) {       ans += tree[cur];       cur /= 2;     }     return ans;   }   int main() {     int n;     scanf( %d , &n);     int root = -1;     for (int i = 0; i < n; i++) {       int p;       scanf( %d%d , &p, &val[i]);       if (p != -1)         v[p - 1].push_back(i);       else         root = i;     }     int m;     scanf( %d , &m);     for (int i = 0; i < m; i++) {       scanf( %d , &a[i]);       b[i] = a[i];     }     sort(a, a + m);     countDps(root);     memset(sum, 0, sizeof(sum));     memset(cnt, 0, sizeof(cnt));     dfs(root, 0, m);     for (int i = 0; i < m; i++) {       int ind = lower_bound(a, a + m, b[i]) - a;       double ans = (double)getValue(sum, ind) / getValue(cnt, ind);       printf( %.9lf n , ans);     }   }
#include <bits/stdc++.h>   using namespace std;   int n;   vector<vector<int> > G;   vector<vector<int> > ID;   vector<vector<int> > ans;   void addp(int id, int t) {     while (ans.size() <= t) ans.push_back(vector<int>());     ans[t].push_back(id);   }   void solve(int from, int lab, int v) {     int ctr = 0;     for (int i = 0; i < G[v].size(); ++i) {       if (ctr == lab) ++ctr;       if (G[v][i] == from) continue;       addp(ID[v][i], ctr);       solve(v, ctr++, G[v][i]);     }   }   int main() {     ios::sync_with_stdio(0);     cin >> n;     G = vector<vector<int> >(n, vector<int>());     ID = vector<vector<int> >(n, vector<int>());     for (int i = 1; i < n; ++i) {       int a, b;       cin >> a >> b;       G[--a].push_back(--b);       G[b].push_back(a);       ID[a].push_back(i);       ID[b].push_back(i);     }     solve(-1, -1, 0);     cout << ans.size() <<   n ;     for (int i = 0; i < ans.size(); ++i) {       cout << ans[i].size();       for (int j = 0; j < ans[i].size(); ++j) cout <<     << ans[i][j];       cout <<   n ;     }     return 0;   }