malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int INF = 1 << 29;   const double EPS = 1e-10;   vector<int> G[50010];   vector<int> chil[50010];   int cnt[50010][510];   void dfs(int pos, int par) {     for (int i = 0; i < (int)G[pos].size(); i++) {       if (G[pos][i] != par) {         chil[pos].push_back(G[pos][i]);         dfs(G[pos][i], pos);       }     }   }   void init(int n) {     memset(cnt, 0, sizeof(cnt));     dfs(0, -1);   }   void calc(int v, int k, long long &sum) {     for (int i = 0; i < (int)chil[v].size(); i++) {       int c = chil[v][i];       calc(c, k, sum);       for (int j = 0; j < k; j++) {         sum += (long long)cnt[c][j] * cnt[v][k - j - 1];       }       for (int j = 0; j < k; j++) {         cnt[v][j + 1] += cnt[c][j];       }     }     cnt[v][0] = 1;     sum += (long long)cnt[v][0] * cnt[v][k];   }   int main() {     int n, k, a, b;     cin >> n >> k;     for (int i = 0; i < n - 1; i++) {       cin >> a >> b;       a--, b--;       G[a].push_back(b);       G[b].push_back(a);     }     init(n);     long long res = 0;     calc(0, k, res);     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k, a, b, c, d;     scanf( %d%d%d%d%d%d , &n, &k, &a, &b, &c, &d);     if (n <= 4 || k < n + 1) {       puts( -1 );       return 0;     }     printf( %d %d , a, c);     for (int i = 1; i <= n; i++) {       if (i != a && i != b && i != c && i != d) printf(  %d , i);     }     printf(  %d %d n , d, b);     printf( %d %d , c, a);     for (int i = 1; i <= n; i++) {       if (i != a && i != b && i != c && i != d) printf(  %d , i);     }     printf(  %d %d n , b, d);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   const int N = 2e5 + 10;   const long long inf = 1e18;   const int maxm = 1005;   vector<vector<char>> matrix(maxm, vector<char>(maxm));   struct event {     int x, y, size;   };   int dx[] = {0, 0, 1, -1};   int dy[] = {-1, 1, 0, 0};   class even {    public:     int a, b, c;   };   class evenl {    public:     int a, b, c, ind;   };   struct myComp {     constexpr bool operator()(evenl f, evenl s) const noexcept {       int z = f.b - f.a;       int z2 = s.b - s.a;       z -= f.c;       z2 -= s.c;       return z < z2;     }   };   long long poww(long long a, long long b, long long m) {     if (b == 0) return 1ll;     if (b % 2 == 1) return a * poww(a, b - 1, m) % m;     long long rs = poww(a, b / 2, m);     rs = rs * rs % m;     return rs;   }   long long fact[N];   long long ncr(long long n, long long r) {     long long num = fact[n];     long long deno = fact[n - r] * fact[r] % mod;     deno = poww(deno, mod - 2, mod);     num = num * deno;     num = num % mod;     return num;   }   long long convert(long long a, long long b) {     string s;     while (a > 0) {       long long p = a % b;       s += p +  0 ;       a = a / b;     }     reverse(s.begin(), s.end());     long long res = stoi(s);     return res;   }   long long make(long long a, long long b, long long c) {     while (a < b) a *= c;     return a % b;   }   long long frog_jump(long long pos, long long n) {     while (pos % 2 == 0) {       pos = pos + (n - pos / 2);     }     return (pos + 1) / 2;   }   void solve() {     long long n, q;     cin >> n >> q;     for (int i = 0; i < q; i++) {       long long x;       cin >> x;       if (x % 2 != 0) {         cout << (x + 1) / 2 <<   n ;         continue;       }       long long z = frog_jump(x, n);       cout << z <<   n ;     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     solve();   }
#include <bits/stdc++.h>   double aa[12];   int sign[12];   int compare(const void *a, const void *b) {     int i = *(int *)a;     int j = *(int *)b;     if (sign[i] != sign[j]) return sign[j] - sign[i];     if (sign[i] == 0) return i - j;     return aa[i] == aa[j] ? i - j : aa[i] > aa[j] ? -sign[i] : sign[i];   }   void power(int i, double x, double y, double z) {     if (x == 1)       sign[i] = 0;     else if (x > 1) {       sign[i] = 1;       aa[i] = z * log(y) + log(log(x));     } else {       sign[i] = -1;       aa[i] = z * log(y) + log(-log(x));     }   }   void power_(int i, double x, double yz) {     if (x == 1)       sign[i] = 0;     else if (x > 1) {       sign[i] = 1;       aa[i] = log(yz) + log(log(x));     } else {       sign[i] = -1;       aa[i] = log(yz) + log(-log(x));     }   }   int main() {     static char ss[12][16] = { x^y^z ,  x^z^y ,  (x^y)^z ,  (x^z)^y ,                                y^x^z ,  y^z^x ,  (y^x)^z ,  (y^z)^x ,                                z^x^y ,  z^y^x ,  (z^x)^y ,  (z^y)^x };     static int ii[12];     double x, y, z;     int i;     scanf( %lf%lf%lf , &x, &y, &z);     power(0, x, y, z);     power(1, x, z, y);     power_(2, x, y * z);     power_(3, x, y * z);     power(4, y, x, z);     power(5, y, z, x);     power_(6, y, x * z);     power_(7, y, x * z);     power(8, z, x, y);     power(9, z, y, x);     power_(10, z, x * y);     power_(11, z, x * y);     for (i = 0; i < 12; i++) ii[i] = i;     qsort(ii, 12, sizeof *ii, compare);     printf( %s n , ss[ii[0]]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     int n, m;     cin >> n >> m;     vector<int> a(n);     for (int i = 0; i < n; ++i) {       cin >> a[i];     }     vector<int> rightInc(n), leftInc(n);     int end = 0, cur_count = 1;     for (int i = 0; i < n; ++i) {       if (end < i) {         end = i, cur_count = 1;       }       while (end + 1 < n && a[end + 1] >= a[end]) {         end++, cur_count++;       }       rightInc[i] = end - i + 1, cur_count--;     }     reverse(a.begin(), a.end());     end = 0, cur_count = 1;     for (int i = 0; i < n; ++i) {       if (end < i) {         end = i, cur_count = 1;       }       while (end + 1 < n && a[end + 1] >= a[end]) {         end++, cur_count++;       }       leftInc[i] = end - i + 1, cur_count--;     }     reverse(leftInc.begin(), leftInc.end());     while (m--) {       int l, r;       cin >> l >> r;       --l, --r;       if (rightInc[l] + leftInc[r] >= r - l + 1)         cout <<  Yes n ;       else         cout <<  No n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 3e6 + 7;   const int INF = 0x7fffffff;   int n, m;   struct DATA {     int strid;     int index;   };   vector<DATA> vec;   string str[maxn];   char ans[maxn];   bool cmp(DATA a, DATA b) { return a.index < b.index; }   int main() {     while (cin >> n) {       memset(ans, 0, sizeof(ans));       vec.clear();       for (int i = 0; i < n; i++) {         int num;         cin >> str[i];         scanf( %d , &num);         for (int j = 0; j < num; j++) {           int k;           scanf( %d , &k);           k--;           DATA t;           t.strid = i;           t.index = k;           vec.push_back(t);         }       }       int last = -1;       sort(vec.begin(), vec.end(), cmp);       for (int i = 0; i < vec.size(); i++) {         for (int j = max(last + 1, vec[i].index);              j < vec[i].index + str[vec[i].strid].size(); j++) {           ans[j] = str[vec[i].strid][j - vec[i].index];           last = max(last, j);         }       }       for (int i = 0; i <= last; i++) {         if (ans[i] != 0)           printf( %c , ans[i]);         else {           printf( a );         }       }       puts(  );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int num[3];     cin >> num[0] >> num[1] >> num[2];     char c1 =  * , c2 =  * ;     if (num[0] == 1) c1 =  + ;     if (num[2] == 1) c2 =  + ;     if (num[1] == 1 && num[0] != 1 && num[2] != 1) {       cout << max(num[0] * (num[1] + num[2]), (num[0] + num[1]) * num[2]);       return 0;     }     if (c1 ==  +  && c2 ==  * ) {       cout << ((num[0] + num[1]) * num[2]);       return 0;     }     if (c2 ==  +  && c1 ==  * ) {       cout << (num[0] * (num[1] + num[2]));       return 0;     }     if (c1 ==  +  && c2 ==  + ) {       cout << (num[0] + num[1] + num[2]);       return 0;     }     cout << (num[0] * num[1] * num[2]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     scanf( %d , &n);     long long int arr[100];     for (int i = 0; i < n; i++) cin >> arr[i];     long long int cnt[5];     long long int p[5];     for (int i = 0; i < 5; i++) cin >> p[i];     long long int min = 1000000009;     for (int i = 0; i < 5; i++)       if (p[i] < min) min = p[i];     for (int i = 0; i < 5; i++) cnt[i] = 0;     long long int ps = 0;     for (int i = 0; i < n; i++) {       ps = ps + arr[i];       while (ps >= min) {         long long int pp;         for (int j = 4; j >= 0; j--) {           if (ps < min) break;           pp = ps / p[j];           ps = ps - pp * p[j];           cnt[j] += pp;         }       }     }     for (int i = 0; i < 5; i++) cout << cnt[i] <<    ;     cout <<   n  << ps << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long t, n, m, cap, lis[200500], high, low;   long long f(long long x) {     long long res = 0, cnt = 0, buf = 0;     for (int i = (0); i <= ((int)(n)-1); i++)       if (lis[i] <= x) {         if (!cnt) {           res += buf;           buf = 0;         }         cnt++;         buf += lis[i];         res += lis[i];         if (cnt == m) {           cnt = 0;         }       }     return res;   }   long long g(long long x) {     long long res = 0, task = 0, cnt = 0, buf = 0;     for (int i = (0); i <= ((int)(n)-1); i++)       if (lis[i] <= x) {         if (!cnt) {           res += buf;           buf = 0;         }         if (res + lis[i] > cap) break;         res += lis[i];         cnt++;         buf += lis[i];         task++;         if (cnt == m) {           cnt = 0;         }       }     return task;   }   int main() {     ios::sync_with_stdio(0);     cin >> t;     while (t--) {       cin >> n >> m >> cap;       for (int i = (0); i <= ((int)(n)-1); i++) cin >> lis[i];       high = cap, low = 1;       while (high > low) {         long long chs = (high + low) / 2;         if (f(chs) > cap)           high = chs;         else           low = chs + 1;       }       long long gh = g(high), gh1 = g(high - 1);       if (gh > gh1 || high == 1)         cout << gh <<     << high << endl;       else         cout << gh1 <<     << high - 1 << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   long long int dp[2010][2010];   long long int a[2010];   long long int b[2010];   int main() {     int n;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i] >> b[i];     }     for (int i = 0; i <= 2000; i++) {       for (int j = 0; j <= 2000; j++) {         dp[i][j] = 10000000000000000;       }     }     dp[0][0] = 0;     for (int i = 1; i <= n; i++) {       long long int o = a[i] + 1;       for (int j = 0; j <= n; j++) {         o = a[i] + 1;         if (j == 0) {           dp[i][j] = 0;         }         if (o >= j) {           o = j;         }         if (j >= o) {           dp[i][j] = min(b[i] + dp[i - 1][j - (o)], dp[i][j]);         }         dp[i][j] = min(dp[i][j], dp[i - 1][j]);       }     }     cout << dp[n][n] << endl;   }
#include <bits/stdc++.h>   const long long int MOD = 1e9 + 7;   const long long int INF = 1011111111;   const long long int LLINF = 1000111000111000111LL;   const long double EPS = 1e-10;   const long double PI = 3.14159265358979323;   using namespace std;   long long int power(int x, int n) {     if (n == 0)       return 1;     else if (n % 2 == 0)       return power((x * x), n / 2);     else       return x * power((x * x), (n - 1) / 2);   }   long long int dp[5005][5005];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long int n, m, i, j, k;     cin >> n >> k;     vector<long long int> v(n);     for (i = 0; i < n; i++) cin >> v[i];     sort(v.begin(), v.end());     vector<pair<pair<long long int, long long int>, long long int> > check;     vector<long long int>::iterator it;     for (i = 0; i < n; i++) {       long long int idx;       it = upper_bound(v.begin(), v.end(), v[i] + 5);       if (it == v.end())         idx = n - 1;       else {         idx = it - v.begin();         idx--;       }       check.push_back({{i, idx}, idx - i + 1});     }     long long int ans = 0;     for (i = 0; i < n; i++) {       for (j = 0; j <= k; j++) {         dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);         if (j + 1 <= k)           dp[i + check[i].second][j + 1] =               max(dp[i + check[i].second][j + 1], dp[i][j] + check[i].second);       }     }     cout << dp[n][k];   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 5, oo = 0x3f3f3f3f, mod = 1e9 + 7;   int a[N], n, tree[N], srt[N], ans[N];   void update(int a, int val) {     while (a <= n) {       tree[a] = max(val, tree[a]);       a += a & -a;     }   }   int query(int a) {     int mx = 0;     while (a > 0) {       mx = max(tree[a], mx);       a -= a & -a;     }     return mx;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , a + i);       srt[i] = a[i];     }     sort(srt + 1, srt + n + 1);     for (int i = n; i >= 1; i--) {       int idx = lower_bound(srt + 1, srt + n + 1, a[i]) - srt;       update(idx, i);       ans[i] = query(idx - 1);       if (ans[i] == 0)         ans[i]--;       else         ans[i] -= i + 1;     }     for (int i = 1; i <= n; i++) printf( %d  , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 9;   int n, maxx;   struct p {     int lei, num, x;   } a[maxn];   int da[maxn], b[maxn], vis[maxn];   int main() {     cin >> n;     for (int i = 1; i <= n; i++) cin >> b[i];     int w;     cin >> w;     for (int i = 1; i <= w; i++) {       cin >> a[i].lei;       if (a[i].lei == 1) {         cin >> a[i].num >> a[i].x;         vis[a[i].num] = i;         b[a[i].num] = a[i].x;       } else {         cin >> a[i].x;         maxx = max(maxx, a[i].x);       }     }     for (int i = w; i >= 1; i--) {       if (a[i].lei == 1)         da[i] = da[i + 1];       else         da[i] = max(da[i + 1], a[i].x);     }     for (int i = 1; i <= n; i++) {       if (vis[i] == 0)         cout << max(b[i], maxx) <<    ;       else {         int xu = vis[i];         cout << max(b[i], da[xu]) <<    ;       }     }   }
#include <bits/stdc++.h>   const int INF = 0x3f3f3f3f;   const int N = 579;   const long long P = 1000000007;   int n, b[N];   long long d[N][N];   long long solve(int l, int r) {     if (l == r) return 1;     static bool used[N][N];     static long long ans[N][N];     if (used[l][r]) return ans[l][r];     used[l][r] = true;     ++l;     ++r;     d[l][0] = 1;     for (int i = 0; i < r - l; ++i) {       if (d[l][i + 1] != -1) continue;       int c = l + i;       d[l][i + 1] = 0;       for (int j = 0; j <= i; ++j)         if (b[j + l] < b[c + 1]) (d[l][i + 1] += d[l][j] * solve(j + l, c)) %= P;     }     long long res = 0;     for (int j = 0; j <= r - l - 1; ++j)       (res += d[l][j] * solve(j + l, r - 1)) %= P;     --l;     --r;     return ans[l][r] = res;   }   int main() {     memset(d, -1, sizeof(d));     std::cin >> n;     for (int i = 0; i < n; ++i) std::cin >> b[i];     if (b[0] == 1)       std::cout << solve(0, n - 1) <<   n ;     else       std::cout << 0 <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a[4];     for (int i = 0; i < 4; i++) cin >> a[i];     int sumtotal = a[0] + a[1] + a[2] + a[3];     if (sumtotal % 2 != 0) {       cout <<  NO ;       return 0;     }     for (int i = 0; i < 4; i++) {       if (a[i] == sumtotal - a[i]) {         cout <<  YES ;         return 0;       } else         for (int j = 0; j < 4; j++) {           if (i != j)             if ((a[i] + a[j]) == (sumtotal - a[i] - a[j])) {               cout <<  YES ;               return 0;             }         }     }     cout <<  NO ;   }
#include <bits/stdc++.h>   using namespace std;   vector<pair<int, double>> ans[52];   int main() {     int n, w, m;     cin >> n >> w >> m;     double s = (n * w) / (m * 1.0), c = w, b = 1, k = 0;     for (int i = 0; i < m; i++) {       double ne = s;       while (1) {         if (ne + 10e-7 > c) {           ans[i].push_back(make_pair(b, c));           ne -= c;           c = w;           b++;           if (++k > 2) {             cout <<  NO ;             return 0;           }           k = 0;           if (abs(ne) < 10e-7) break;         } else {           ans[i].push_back(make_pair(b, ne));           c -= ne;           k++;           break;         }       }     }     cout <<  YES n ;     for (int i = 0; i < m; i++) {       for (auto it : ans[i])         cout << fixed << setprecision(0) << it.first <<     << setprecision(6)              << it.second <<    ;       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void quickly_quickly_kro() {     long long n;     cin >> n;     vector<long long> v(n);     for (long long i = 0; i < n; i++) cin >> v[i];     ;     map<long long, long long> M, N, I;     for (long long i = 0; i < n; i++) {       if (v[i] != 0)         M[v[i]]++;       else         I[i]++;     }     for (long long i = 1; i < n + 1; i++) {       if (M[i] == 0) {         N[i]++;       }     }     for (auto k : I) {       if ((N.find(k.first + 1) != N.end())) {         auto it = N.find(k.first + 1);         if (it != N.begin())           it--;         else           it++;         v[k.first] = it->first;         N.erase(it);       }     }     for (long long i = 0; i < n; i++) {       if (v[i] == 0) {         auto it = N.begin();         pair<long long, long long> p = *it;         v[i] = p.first;         N.erase(it);       }     }     for (long long i = 0; i < n; i++) cout << v[i] <<    ;   }   signed main() {     std::ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long t;     t = 1;     while (t--) {       quickly_quickly_kro();       cout <<   n ;       ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct HashMap {     vector<pair<int, int> > g[1000007];     void ins(int x, int y) {       int id = ((long long)x * 1000000007 + y) % 1000007;       g[id].push_back(make_pair(x, y));     }     bool get(int x, int y) {       int id = ((long long)x * 1000000007 + y) % 1000007;       for (int i = 0; i < g[id].size(); i++)         if (g[id][i].first == x && g[id][i].second == y) return true;       return false;     }   };   int n;   HashMap mp;   vector<int> row[100011];   vector<int> rateB;   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       int x, y;       scanf( %d%d , &x, &y);       row[y].push_back(x);       mp.ins(x, y);     }     int di = (int)sqrt(n);     long long int ans = 0;     for (int a = 0; a <= 100000; a++) {       if (row[a].size() != 0) {         sort(row[a].begin(), row[a].end());         if (row[a].size() <= di) {           for (int i = 0; i < row[a].size(); i++) {             for (int j = i + 1; j < row[a].size(); j++) {               int x1 = row[a][i];               int x2 = row[a][j];               int dis = x2 - x1;               if (mp.get(x1, a + dis) && mp.get(x2, a + dis)) ans++;               if (a - dis >= 0 && row[a - dis].size() > di &&                   (mp.get(x1, a - dis) && mp.get(x2, a - dis)))                 ans++;             }           }         } else           rateB.push_back(a);       }     }     for (int i = 0; i < rateB.size(); i++) {       for (int j = i + 1; j < rateB.size(); j++) {         int a = rateB[i];         int b = rateB[j];         int u = 0, p = 0;         int dis = b - a;         while (u < row[a].size() && p < row[b].size()) {           if (row[a][u] < row[b][p])             u++;           else if (row[a][u] > row[b][p])             p++;           else {             int x1 = row[a][u];             if (mp.get(x1 + dis, a) && mp.get(x1 + dis, b)) ans++;             u++;             p++;           }         }       }     }     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = (int)1.01e9;   const double eps = 1e-9;   const int maxn = (int)2e5 + 10;   set<int> S;   int main() {     int n, k, a;     scanf( %d%d%d , &n, &k, &a);     int cur = (n + 1) / (a + 1);     assert(cur >= k);     int m;     scanf( %d , &m);     for (int i = 0; (i) < (m); ++i) {       int x;       scanf( %d , &x);       set<int>::iterator it = S.lower_bound(x);       int left = 0;       int right = n + 1;       if (it != S.end()) {         right = *it;       }       if (it != S.begin()) {         --it;         left = *it;       }       cur -= (right - left) / (a + 1);       cur += (x - left) / (a + 1);       cur += (right - x) / (a + 1);       if (cur < k) {         printf( %d n , i + 1);         return 0;       }       S.insert(x);     }     printf( -1 n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool has[200009];   int left[200009];   int main() {     int Q;     cin >> Q;     for (int q = 0; q < Q; q++) {       int N;       cin >> N;       vector<int> v;       for (int i = 0; i < N; i++) {         int a;         cin >> a;         v.push_back(a);       }       sort(v.begin(), v.end());       reverse(v.begin(), v.end());       int res = v[0];       vector<int> w;       vector<int> t;       for (int i = 1; i < v.size(); i++)         if (v[i] != v[i - 1]) {           if (v[0] % v[i] != 0)             w.push_back(v[i]);           else             t.push_back(v[i]);         }       if (w.size() > 0) {         res += w[0];         for (int i = 1; i < w.size(); i++)           if (w[0] % w[i] != 0) {             res += w[i];             break;           }       }       if (t.size() >= 3 && t[0] + t[1] + t[2] > res) {         if (t[0] % t[1] != 0 && t[1] % t[2] != 0 && t[0] % t[2] != 0)           res = t[0] + t[1] + t[2];       }       if (t.size() >= 4 && t[0] + t[1] + t[3] > res) {         if (t[0] % t[1] != 0 && t[1] % t[3] != 0 && t[0] % t[3] != 0)           res = t[0] + t[1] + t[3];       }       cout << res <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct Segment {     int l, r, x, ls, rs, fa;   } seg[2000100];   int n, k, p[100100], cnt, pnt, b[2000100], w, ans[100100], res;   int Dfs(int &id, int l, int r) {     id = ++cnt;     seg[id].l = l, seg[id].r = r;     seg[id].x = 1;     if (r - l == 1) return 1;     int mid = (l + r) >> 1;     seg[id].x += Dfs(seg[id].ls, l, mid);     seg[id].x += Dfs(seg[id].rs, mid, r);     return seg[id].x;   }   void Vis(int x) {     if (!x) return;     b[x] = 1;     Vis(seg[x].ls);     Vis(seg[x].rs);   }   bool cmp(int x, int y) { return seg[x].l < seg[y].l; }   void Solve(int x) {     if (!x) return;     if (b[x]) {       for (int i = seg[x].l; i < seg[x].r; i++) ans[i] = res++;       return;     }     Solve(seg[x].rs);     Solve(seg[x].ls);   }   int main() {     scanf( %d%d , &n, &k);     Dfs(w, 0, n);     k = seg[1].x - k;     for (int i = 1; i <= cnt; i++)       if (!b[i]) {         if (k >= seg[i].x - 1 && seg[i].x > 1) {           k -= seg[i].x - 1;           p[++pnt] = i;           Vis(i);           if (!k) break;         }       }     if (k)       printf( -1 );     else {       res = 1;       Solve(1);       for (int i = n - 1; i >= 0; i--) ans[i] = ans[i] ? ans[i] : res++;       for (int i = 0; i < n; i++) printf( %d  , ans[i]);     }     return 0;   }