malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <iostream>   #include <vector>   #include <numeric>   #include <algorithm>      using namespace std;       int main(){       ios_base::sync_with_stdio(false);       cin.tie(NULL);       cout.tie(NULL);       int t;       cin >> t;       while(t--){           int n;           cin >> n;           vector<long long> a(n);           for (int i = 0; i < n; ++i){               cin >> a[i];           }           sort(a.begin(), a.end());           long long ans = 0;           for (int k = 1; k < n; ++k){               ans += a[k] * (2 * k + 1 - n);           }           ans -= a[n-1];                      cout << -ans << endl;       }   }
#include <bits/stdc++.h>   using namespace std;   int i, j, k, n, t, f[4], ans, a[2048], l1[2048], r2[2048];   int main() {     scanf( %d , &n);     for (i = 1; i <= n; ++i) {       scanf( %d , a + i);       l1[i] = l1[i - 1] + (a[i] == 1);       for (j = a[i]; ~j; --j)         if (f[j] + 1 > f[a[i]]) f[a[i]] = f[j] + 1;     }     ans = f[1] > f[2] ? f[1] : f[2];     for (i = n; i; --i) r2[i] = r2[i + 1] + (a[i] == 2);     for (i = 1; i <= n; ++i) {       f[1] = f[2] = 0;       for (k = i; k <= n; ++k) {         for (j = a[k]; j < 4; ++j)           if (f[j] + 1 > f[a[k]]) f[a[k]] = f[j] + 1;         t = l1[i - 1] + r2[k + 1] + (f[1] > f[2] ? f[1] : f[2]);         ans = ans < t ? t : ans;       }     }     printf( %d , ans);   }
#include <bits/stdc++.h>   using namespace std;   int n, m1, q;   int m[102][102];   struct query {     int t;     int a;     int b;     int c;   };   void rote(int type, int val) {     if (type == 1) {       int aux = m[val][m1];       for (int i = m1 - 1; i >= 1; i--) m[val][i + 1] = m[val][i];       m[val][1] = aux;     } else {       int aux = m[n][val];       for (int i = n - 1; i >= 1; i--) m[i + 1][val] = m[i][val];       m[1][val] = aux;     }   }   int main() {     cin >> n >> m1 >> q;     stack<query> st;     for (int i = 0; i < q; i++) {       int in;       cin >> in;       if (in == 3) {         int a, b, c;         cin >> a >> b >> c;         query qu;         qu.t = in;         qu.a = a;         qu.b = b;         qu.c = c;         st.push(qu);       } else {         int a;         cin >> a;         query qu;         qu.t = in;         qu.a = a;         st.push(qu);       }     }     memset(m, 0, sizeof(m));     while (!st.empty()) {       int type = st.top().t;       if (type == 3) {         int x, y, v;         x = st.top().b;         y = st.top().a;         v = st.top().c;         st.pop();         m[y][x] = v;       } else {         int a = st.top().a;         st.pop();         rote(type, a);       }     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m1; j++) cout << m[i][j] <<    ;       cout << endl;     }   }
#include <bits/stdc++.h>   const int maxn = 1005;   int n, m;   int a[maxn], b[maxn];   bool solve(double v) {     for (int i = 0; i < n; i++) {       if ((m + v) / a[i] <= v)         v -= (m + v) / a[i];       else         return false;       if ((m + v) / b[i] <= v)         v -= (m + v) / b[i];       else         return false;     }     if (v >= 0) return true;     return false;   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 0; i < n; i++) {       scanf( %d , &a[i]);     }     scanf( %d , &b[n - 1]);     for (int i = 0; i < n - 1; i++) {       scanf( %d , &b[i]);     }     double left = -1, right = 1e9 + 1;     while (left + 0.000001 < right) {       double mid = (left + right) / 2;       if (solve(mid)) {         right = mid;       } else {         left = mid;       }     }     if (right > 1e9 + 0.00001)       puts( -1 );     else       printf( %f n , right);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct info {     long long int val, in;   };   long long int arr[100010];   info tree[100010 * 4], temp;   void init(long long int node, long long int b, long long int e) {     if (b == e) {       tree[node].val = arr[b];       tree[node].in = b;       return;     }     long long int Left = node * 2;     long long int Right = node * 2 + 1;     long long int mid = (b + e) / 2;     init(Left, b, mid);     init(Right, mid + 1, e);     if (tree[Left].val >= tree[Right].val) {       tree[node].val = tree[Right].val;       tree[node].in = tree[Right].in;     } else {       tree[node].val = tree[Left].val;       tree[node].in = tree[Left].in;     }   }   info query(long long int node, long long int b, long long int e,              long long int i, long long int j) {     if (i > e || j < b) {       temp.in = temp.val = 30;       return temp;     }     if (b >= i && e <= j) return tree[node];     long long int Left = node * 2;     long long int Right = node * 2 + 1;     long long int mid = (b + e) / 2;     info p1 = query(Left, b, mid, i, j);     info p2 = query(Right, mid + 1, e, i, j);     if (p1.val >= p2.val)       return p2;     else       return p1;   }   int main() {     long long int i, j, len, mn = 30, m, last = 1, in;     long long int used = -1;     string s;     vector<char> v, ans;     char mxx =  a  - 1;     cin >> m >> s;     len = s.length();     for (i = 0; i < s.length(); i++) {       arr[i + 1] = s[i] -  a  + 1;     }     init(1, 1, len);     for (i = 1; i <= len - m + 1; i++) {       info ret = query(1, 1, len, i, i + m - 1);       if (used == -1) {         used = ret.in;         i = ret.in;         last = ret.val;         v.push_back(last - 1 +  a );         mxx = max(mxx, (char)(last - 1 +  a ));       } else {         if (ret.val == last && used == ret.in) {         } else {           used = ret.in;           i = ret.in;           last = ret.val;           v.push_back(last - 1 +  a );           mxx = max(mxx, (char)(last - 1 +  a ));         }       }     }     if (v.size() == 0) v.push_back(s[0]);     sort(v.begin(), v.end());     long long int inx = v.size() - 1;     long long int cnt = 0;     for (i = 0; i < v.size(); i++) {       if (v[i] == v[inx]) cnt++;     }     for (i = 0; i < s.length(); i++) {       if (s[i] < v[inx]) ans.push_back(s[i]);     }     for (i = 1; i <= cnt; i++) {       ans.push_back(v[inx]);     }     sort(ans.begin(), ans.end());     for (i = 0; i < ans.size(); i++) {       cout << ans[i];     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 5e3 + 3;   const int INF = 2000000000;   inline long long ab(long long x) { return x < 0 ? -x : x; }   long long a[MAXN];   int c_a[MAXN];   int l[MAXN], r[MAXN], x[MAXN], t[MAXN];   int main() {     int n, m;     cin >> n >> m;     for (int i = 0; i < n; i++) {       a[i] = INF;     }     for (int q = 0; q < m; q++) {       cin >> t[q] >> l[q] >> r[q] >> x[q];       --l[q], --r[q];     }     for (int q = m - 1; q >= 0; q--) {       if (t[q] == 1) {         for (int i = l[q]; i <= r[q]; i++) {           a[i] -= x[q];         }       } else {         bool found = false;         for (int i = l[q]; i <= r[q]; i++) {           if (a[i] >= x[q]) {             a[i] = x[q];             found = true;           }         }         if (!found) {           cout <<  NO ;           return 0;         }       }     }     for (int i = 0; i < n; i++) {       if (a[i] < 0) {         if (ab(a[i]) > INF / 2) a[i] = -INF / 2;       } else {         if (a[i] > INF / 2) a[i] = INF / 2;       }     }     for (int i = 0; i < n; i++) {       c_a[i] = a[i];     }     for (int q = 0; q < m; q++) {       if (t[q] == 1) {         for (int i = l[q]; i <= r[q]; i++) {           a[i] += x[q];         }       } else {         long long maxv = -INF;         for (int i = l[q]; i <= r[q]; i++) {           maxv = max(maxv, a[i]);         }         if (maxv != x[q]) {           cout <<  NO ;           return 0;         }       }     }     cout <<  YES n ;     for (int i = 0; i < n; i++) {       if (i > 0) cout <<    ;       cout << c_a[i];     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 2000000000000000000LL;   const int inf = 0x3f3f3f3f;   const long double EPS = 1e-9;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     long long x, i, j, n = 0, t;     cin >> x;     while (x / 2 != 0) {       if (x % 2 == 1) n++;       x = x / 2;     }     cout << n + 1 <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 105;   long long g[N][N], f[N][N], a[N], d;   int n;   pair<int, int> p[N];   void FloydWarshall() {     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) f[i][j] = g[i][j];       f[i][i] = 0;     }     for (int k = 1; k <= n; k++) {       for (int i = 1; i <= n; i++) {         for (int j = 1; j <= n; j++) {           f[i][j] = min(f[i][j], f[i][k] + f[k][j]);         }       }     }   }   int main() {     scanf( %d%lld , &n, &d);     for (int i = 2; i < n; i++) scanf( %lld , &a[i]);     for (int i = 1; i <= n; i++) scanf( %d%d , &p[i].first, &p[i].second);     for (int i = 2; i < n; i++) {       for (int j = 1; j <= n; j++) {         if (i == j) continue;         g[i][j] -= a[i];       }     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         if (i == j) continue;         g[i][j] +=             1ll * d *             (abs(p[i].first - p[j].first) + abs(p[i].second - p[j].second));       }     }     FloydWarshall();     printf( %lld , f[1][n]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int lpd(int n) {     int ans = -1;     for (int i = 2; i * i <= n; i++) {       if (n % i == 0) {         ans = i;         while (n % i == 0) n /= i;       }     }     if (n > 1) ans = n;     return ans;   }   int x, p[1000006], pd, t, ans;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     p[0] = p[1] = 1;     for (int i = 2; i * i <= 1e6; i++) {       if (p[i] == 0) {         for (int j = i * i; j <= 1e6; j += i) {           p[j] = 1;         }       }     }     cin >> x;     ans = 1e9;     pd = lpd(x);     t = x / pd;     t -= 1;     if (p[pd * t + 1] == 0 && (pd * t + 2 == x)) {       cout << (x - 1) <<   n ;       return 0;     }     for (int i = pd * t + 1; i < x; i++) {       if (p[i] == 0) continue;       pd = lpd(i);       t = i / pd;       t -= 1;       ans = min(ans, pd * t + 1);     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   long long int dp[4011][4011];   long long int b[2000000];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int n;     cin >> n;     long long int a[n];     set<long long int> st;     for (int i = 0; i < n; i++) {       cin >> a[i];       st.insert(a[i]);     }     long long int k = 0;     for (auto u : st) {       b[u] = k;       k++;     }     for (int i = 0; i < n; i++) {       a[i] = b[a[i]];     }     for (int i = 0; i < n; i++) {       long long int f = 0;       for (int j = i - 1; j >= 0; j--) {         if (a[i] == a[j]) {           if (f == 1) continue;           f = 1;           dp[a[i]][a[j]]++;         } else {           dp[a[i]][a[j]] = max(dp[a[i]][a[j]], 1 + dp[a[j]][a[i]]);         }       }     }     long long int ans = 0;     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) ans = max(ans, dp[i][j]);     }     cout << ans + 1;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a = 1, b, c = 0, d = 0, e = 0, f, i = 0, k = 0, j = 0, n = 0, t = 0,         l = 0, m = 0, h[3000] = {0};     string s, x;     cin >> t;     n = 1000000;     for (i = 0; i < t; i++) {       cin >> b;       j = max(j, min(b - 1, 1000000 - b));     }     cout << j;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, k;   long long cp1[102];   long long cp2[102];   long long dp[102][10002];   long long comb[102][102];   bool mark[102][10002];   long long Calculate_Pow(long long x, long long y) {     long long val = 1;     for (long long i = 1, t = x; i <= y; i <<= 1, t = (t * t) % 1000000007)       if (y & i) val = (val * t) % 1000000007;     return val;   }   void Calculate_Combination() {     for (long long i = 0; i <= n; i++) comb[i][0] = 1;     for (long long i = 1; i <= n; i++)       for (long long j = 1; j <= i; j++)         comb[i][j] = (comb[i - 1][j - 1] + comb[i - 1][j]) % 1000000007;   }   long long f(long long col, long long last) {     if (last < 0) return 0;     if (col == n && last) return 0;     if (col == n) return 1;     if (mark[col][last]) return dp[col][last];     mark[col][last] = true;     if (col >= m % n) {       for (long long i = 0; i <= n; i++)         dp[col][last] =             (dp[col][last] + cp1[i] * f(col + 1, last - i)) % 1000000007;     } else {       for (long long i = 0; i <= n; i++)         dp[col][last] =             (dp[col][last] + cp2[i] * f(col + 1, last - i)) % 1000000007;     }     return dp[col][last];   }   int main() {     scanf( %I64d%I64d%I64d , &n, &m, &k);     Calculate_Combination();     for (long long i = 0; i <= n; i++) {       cp1[i] = Calculate_Pow(comb[n][i], m / n);       cp2[i] = Calculate_Pow(comb[n][i], m / n + 1);     }     printf( %I64d n , f(0, k));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e6 + 5;   const int mod = 1e9 + 7;   vector<int> G[maxn];   char s[maxn];   int vis[maxn];   map<string, int> mp;   long long a[maxn], n, L, R, t;   void solve1() {     L = 0, R = n;     for (int i = 0; i <= n - 2; i++) {       if (s[i] ==  < )         L++;       else {         for (int i = R - L; i <= R; i++) printf( %d  , i);         R = R - L - 1, L = 0;       }     }     for (int i = R - L; i <= R && i >= 1; i++) printf( %d  , i);     printf(  n );   }   void solve2() {     L = 0, R = 1;     for (int i = 0; i <= n - 2; i++) {       if (s[i] ==  > )         L++;       else {         for (int i = R + L; i >= R; i--) printf( %d  , i);         R = R + L + 1, L = 0;       }     }     for (int i = R + L; i >= R && i <= n; i--) printf( %d  , i);     printf(  n );   }   int main() {     cin >> t;     while (t--) {       scanf( %lld%s , &n, s);       solve1();       solve2();     }   }
#include <bits/stdc++.h>   using namespace std;   int n;   vector<int> a[2002];   int b[2002];   vector<int> ans[4];   void Work() {     int l;     int maxT = 0;     int specialNum = -1;     for (int i = 0; i < n; i++) {       cin >> l;       a[l].push_back(i + 1);       if (l > maxT) maxT = l;       b[l]++;       if (b[l] >= 3) specialNum = l;     }     int check = 0;     for (int i = 0; i <= maxT; i++) {       if (b[i] >= 2) check++;       if (b[i] >= 3) check++;       if (check == 2) break;     }     if (check < 2) {       cout <<  NO ;       return;     }     for (int i = 1; i <= maxT; i++) {       for (int j = 0; j < a[i].size(); j++) {         if (a[i][j] > 0) {           ans[1].push_back(a[i][j]);         }       }     }     for (int i = 1; i <= maxT; i++) {       for (int j = a[i].size() - 1; j >= 0; j--) {         if (a[i][j] > 0) {           ans[2].push_back(a[i][j]);         }       }     }     bool tt = false;     if (specialNum == -1)       for (int i = 1; i <= maxT; i++) {         if (b[i] >= 2 && !tt) {           for (int j = a[i].size() - 1; j >= 0; j--) {             if (a[i][j] > 0) {               ans[3].push_back(a[i][j]);               tt = true;             }           }         } else {           for (int j = 0; j < a[i].size(); j++) {             if (a[i][j] > 0) {               ans[3].push_back(a[i][j]);             }           }         }       }     else {       for (int i = 1; i <= specialNum; i++) {         if (i != specialNum)           for (int j = a[i].size() - 1; j >= 0; j--) {             if (a[i][j] > 0) {               ans[3].push_back(a[i][j]);               tt = true;             }           }       }       for (int i = 0; i < a[specialNum].size() / 2; i++) {         if (a[specialNum][i] > 0) {           ans[3].push_back(a[specialNum][i]);         }       }       for (int i = a[specialNum].size() - 1; i >= a[specialNum].size() / 2; i--) {         if (a[specialNum][i] > 0) {           ans[3].push_back(a[specialNum][i]);         }       }       for (int i = specialNum + 1; i <= maxT; i++) {         if (i != specialNum)           for (int j = a[i].size() - 1; j >= 0; j--) {             if (a[i][j] > 0) {               ans[3].push_back(a[i][j]);               tt = true;             }           }       }     }     cout <<  YES  << endl;     for (int i = 1; i <= 3; i++) {       for (int j = 0; j < ans[i].size(); j++) {         cout << ans[i][j];         if (j < ans[i].size() - 1) cout <<    ;       }       if (i != 3) cout << endl;     }   }   int main() {     cin >> n;     Work();   }
#include <bits/stdc++.h>   using namespace std;   int read() {     char ch = getchar();     int w = 1, c = 0;     for (; !isdigit(ch); ch = getchar())       if (ch ==  - ) w = -1;     for (; isdigit(ch); ch = getchar()) c = (c << 3) + (c << 1) + (ch ^ 48);     return w * c;   }   const int mod = 998244353, M = 1e6 + 10;   int n;   long long fac[M], inv[M];   long long C(int x, int y) {     if (y > x || y < 0) return 0;     return fac[x] * inv[y] % mod * inv[x - y] % mod;   }   char s[M];   long long fast(long long x, long long p) {     long long ret = 1;     for (; p; p >>= 1, x = x * x % mod)       if (p & 1) ret = ret * x % mod;     return ret;   }   int main() {     scanf( %s , s + 1);     n = strlen(s + 1);     fac[0] = 1;     for (int i = 1; i <= n; ++i) fac[i] = fac[i - 1] * i % mod;     inv[n] = fast(fac[n], mod - 2);     for (int i = n; i >= 1; --i) inv[i - 1] = inv[i] * i % mod;     int l = 0, x = 0, y = 0, r = 0;     for (int i = 1; i <= n; ++i) {       if (s[i] ==  ( ) l++;       if (s[i] ==  ? ) x++;     }     long long ans = 0;     for (int i = n; i >= 1; --i) {       if (s[i] ==  ( ) l--;       if (s[i] ==  ) ) r++;       if (s[i] ==  ? ) x--, y++;       ans =           (ans + C(x + y, y + r - l) * l + C(x + y - 1, y + r - l - 1) * x) % mod;     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1000010;   int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }   int lcm(int a, int b) { return a * b / gcd(a, b); }   int main(void) {     int c, d, n, m, k, i, j, ans = 10000;     scanf( %d %d %d %d %d , &c, &d, &n, &m, &k);     for (i = 0; i <= 10000; i++)       for (j = 0; j <= 10000; j++)         if (i * n + j >= n * m - k) ans = min(ans, i * c + j * d);     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   static const int INF = 0x3f3f3f3f;   static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;   const int lim = 2001;   int A[lim];   int main() {     int n;     scanf( %d , &n);     for (int i = 0; i < n; ++i) scanf( %d , &A[i]);     long long int total = 0ll;     for (int i = 0; i < n; ++i) {       for (int j = i + 1; j < n; ++j) {         if (A[i] > A[j]) total = total + 1ll;       }     }     int q;     scanf( %d , &q);     while (q--) {       int a, b;       scanf( %d %d , &a, &b);       total = total + ((b - a + 1) * 1ll * (b - a)) / 2ll;       if (total % 2 == 1ll)         printf( odd n );       else         printf( even n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int p[105][105];   char s[105][105];   int n, m;   long long k;   void color(int x, int y, char c) {     while (x < n && y >= 0) {       s[x][y] = c;       x++;       y--;     }   }   vector<pair<pair<int, int>, pair<int, int> > > v;   vector<int> vals;   long long mem[305][305];   int vis[305][305];   int id;   long long add(long long x, long long y) {     if (x < 0 || y < 0) return -1;     long long z = x + y;     if (z >= k) return -1;     return z;   }   long long solve(int ind, int r) {     if (r < 0) return 0;     if (ind >= int(vals.size())) return r == 0;     if (vis[ind][r] == id) return mem[ind][r];     vis[ind][r] = id;     long long ans = 0;     if (vals[ind] != 1) ans = add(ans, solve(ind + 1, r + 1));     if (vals[ind] != 0) ans = add(ans, solve(ind + 1, r - 1));     return mem[ind][r] = ans;   }   void gen(int ind) {     if (ind >= int(vals.size())) return;     vals[v[ind].first.second] = 0;     id++;     long long tmp = solve(0, 0);     if (tmp == -1) {       color(v[ind].second.first, v[ind].second.second,  ( );       gen(ind + 1);     } else {       vals[v[ind].first.second] = 1;       k -= tmp;       color(v[ind].second.first, v[ind].second.second,  ) );       gen(ind + 1);     }   }   int main() {     ios::sync_with_stdio(false);     cin >> n >> m;     cin >> k;     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) cin >> p[i][j];     for (int j = 0; j < m; j++) {       int x = 0, y = j, pr = n * m + 1;       while (x < n && y >= 0) {         pr = min(pr, p[x][y]);         x++;         y--;       }       v.push_back(make_pair(make_pair(pr, v.size()), make_pair(0, j)));       vals.push_back(-1);     }     for (int i = 1; i < n; i++) {       int x = i, y = m - 1, pr = n * m + 1;       while (x < n && y >= 0) {         pr = min(pr, p[x][y]);         x++;         y--;       }       v.push_back(make_pair(make_pair(pr, v.size()), make_pair(i, m - 1)));       vals.push_back(-1);     }     sort(v.begin(), v.end());     gen(0);     for (int i = 0; i < n; i++) cout << s[i] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }   int lcm(int a, int b) { return a / gcd(a, b) * b; }   long long powmod(long long a, long long b, long long MOD) {     long long ans = 1;     while (b) {       if (b % 2) ans = ans * a % MOD;       a = a * a % MOD;       b /= 2;     }     return ans;   }   int main() {     int t;     int n, x, y, d;     ios::sync_with_stdio(false);     string a;     cin >> n;     cin >> a;     int l = a.size();     vector<int> v;     v.push_back(-1);     int fa = n + 12, fb = -23;     for (int i = 0; i < l; i++) {       if (a[i] ==  S ) v.push_back(i);       if (fa == n + 12 && a[i] ==  G ) fa = i;       if (a[i] ==  G ) fb = i;     }     v.push_back(n);     if (v.size() == 2) {       cout << n << endl;       return 0;     } else {       int ma = 0;       for (int i = 1; i < v.size() - 1; i++) {         int xa = v[i + 1] - v[i - 1] - 1;         if (v[i + 1] > fb && v[i - 1] < fa) xa--;         if (ma < xa) ma = xa;       }       cout << ma << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const int mod = 1e9 + 7;   const double eps = 1e-6;   const int maxn = 1 << 17;   int a[maxn];   void merge(int l, int r, int from, int to, int& res) {     if (res <= 0 || l + 1 == r) {       for (int i = l, j = from; i <= r; i++, j++) a[i] = j;       return;     }     res -= 2;     int m = (l + r) >> 1;     int mid = (from + to + 1) >> 1;     merge(l, m, mid, to, res);     merge(m, r, from, mid, res);   }   int main() {     int n, k;     while (cin >> n >> k) {       k--;       merge(0, n, 0, n, k);       if (k)         cout << -1 << endl;       else {         for (int i = 0; i < n; i++) {           if (i) cout <<    ;           cout << a[i] + 1;         }         cout << endl;       }     }     return 0;   }