malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long n, sav, mn = 1e9;   struct point {     long long x, y, uz;   } p[2005];   string s;   int det(point A, point B, point C) {     if (A.x * B.y + A.y * C.x + B.x * C.y - A.x * C.y - A.y * B.x - B.y * C.x < 0)       return -1;     return 1;   }   int main() {     ios::sync_with_stdio(false);     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> p[i].x >> p[i].y;       if (p[i].y < mn) {         mn = p[i].y;         sav = i;       }     }     cin >> s;     p[sav].uz = 1;     cout << sav <<    ;     for (int i = 0; i < s.size(); i++) {       int crt = 1, j, sgn;       while (p[crt].uz) crt++;       j = crt + 1;       if (s[i] ==  R )         sgn = 1;       else         sgn = -1;       while (j <= n) {         while (j <= n && p[j].uz) j++;         if (j > n) break;         if (det(p[sav], p[crt], p[j]) == sgn) crt = j;         j++;       }       sav = crt;       p[crt].uz = 1;       cout << sav <<    ;     }     for (int i = 1; i <= n; i++)       if (!p[i].uz) cout << i <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int va, id;   } a[200015], b[200015];   int n, Q, rv[200015];   long long dp[200015];   inline bool cmp(node x, node y) { return x.va > y.va; }   int main() {     scanf( %d%d , &n, &Q);     for (int i = 1; i <= n; i++) scanf( %d , &a[i].va), a[i].id = i;     for (int i = 1; i <= n; i++) scanf( %d , &b[i].va), b[i].id = i;     sort(a + 1, a + 1 + n, cmp);     sort(b + 1, b + 1 + n, cmp);     for (int i = 1; i <= n; i++) rv[b[i].id] = i;     while (Q--) {       int x, y;       scanf( %d%d , &x, &y);       swap(rv[x], rv[y]);       b[rv[x]].id = x, b[rv[y]].id = y;       for (int i = 1; i <= n; i++) {         dp[i] = 0;         if (a[i].id ^ b[i].id)           dp[i] = max(dp[i], dp[i - 1] + 1ll * a[i].va * b[i].va);         if (i > 1) {           if ((a[i].id ^ b[i - 1].id) && (a[i - 1].id ^ b[i].id)) {             dp[i] = max(dp[i], dp[i - 2] + 1ll * a[i].va * b[i - 1].va +                                    1ll * a[i - 1].va * b[i].va);           }         }         if (i > 2) {           if ((a[i].id ^ b[i - 2].id) && (a[i - 1].id ^ b[i].id) &&               (a[i - 2].id ^ b[i - 1].id)) {             dp[i] = max(dp[i], dp[i - 3] + 1ll * a[i - 2].va * b[i - 1].va +                                    1ll * a[i - 1].va * b[i].va +                                    1ll * a[i].va * b[i - 2].va);           }           if ((a[i - 2].id ^ b[i].id) && (a[i - 1].id ^ b[i - 2].id) &&               (a[i].id ^ b[i - 1].id)) {             dp[i] = max(dp[i], dp[i - 3] + 1ll * a[i - 2].va * b[i].va +                                    1ll * a[i - 1].va * b[i - 2].va +                                    1ll * a[i].va * b[i - 1].va);           }           if ((a[i].id ^ b[i - 2].id) && (a[i - 2].id ^ b[i].id) &&               (a[i - 1].id ^ b[i - 1].id)) {             dp[i] = max(dp[i], dp[i - 3] + 1ll * a[i].va * b[i - 2].va +                                    1ll * a[i - 1].va * b[i - 1].va +                                    1ll * a[i - 2].va * b[i].va);           }         }       }       printf( %lld n , dp[n]);     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<int> a;     vector<string> ss;     bool possible = false;     for (int i = 0; i < n; ++i) {       string s;       cin >> s;       if (!possible) {         if (s.substr(0, 2) ==  OO ) {           possible = true;           s[0] =  + ;           s[1] =  + ;         } else if (s.substr(3, 2) ==  OO ) {           possible = true;           s[3] =  + ;           s[4] =  + ;         }       }       ss.push_back(s);     }     if (possible) {       cout <<  YES n ;       for (int j = 0; j < n; ++j) {         cout << ss[j] <<   n ;       }     } else {       cout <<  NO ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int maxd(long long int n) {     long long int temp = 10 * n, mm = 0;     while (temp /= 10) mm = max(mm, temp % 10);     return mm;   }   int main() {     long long int n, ans = 0;     cin >> n;     while (n) {       n -= maxd(n);       ans++;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 1e9 + 1;   const int N = 100123;   int z, n;   int a[N];   int best[N];   long long ans[N];   long long res;   pair<int, int> tree[N << 2];   void build(int v, int l, int r) {     if (l == r) {       tree[v] = {a[l], l};       return;     }     int mid = (l + r) >> 1;     build(2 * v, l, mid);     build(2 * v + 1, mid + 1, r);     tree[v] = max(tree[2 * v], tree[2 * v + 1]);   }   pair<int, int> query(int v, int l, int r, int ql, int qr) {     if (ql <= l && qr >= r) {       return tree[v];     }     int mid = (l + r) >> 1;     pair<int, int> res = {0, 0};     if (ql <= mid) res = max(res, query(2 * v, l, mid, ql, qr));     if (qr >= mid + 1) res = max(res, query(2 * v + 1, mid + 1, r, ql, qr));     return res;   }   int main() {     ios_base::sync_with_stdio(0);     cin >> n;     for (int i = 1; i <= n - 1; i++) {       cin >> a[i];     }     a[n] = n;     build(1, 1, n);     for (int i = 1; i <= n; i++) {       pair<int, int> b = query(1, 1, n, i, a[i]);       best[i] = b.second;     }     ans[n - 1] = 1;     res++;     for (int i = n - 2; i >= 1; i--) {       ans[i] = ans[best[i]] + (best[i] - i) + (n - a[i]);       res += ans[i];     }     cout << res << endl;   }
#include <bits/stdc++.h>   using namespace std;   const long long md = 1e9 + 7;   const int N = 2e6 + 34;   char s[N];   long long p[N];   int n, k, m;   int lst[100];   int c, cur, mn;   int main() {     scanf( %d %d n , &n, &k);     gets(s);     m = strlen(s);     for (int i = 0; i < k; i++) lst[i] = -1;     p[0] = 0;     p[1] = 1;     for (int i = 0; i < m; i++) {       c = s[i] -  a ;       cur = p[i + 1] - p[lst[c] + 1];       p[i + 2] = (p[i + 1] + cur + md) % md;       lst[c] = i;     }     for (int i = m; i < m + n; i++) {       mn = 0;       for (int j = 1; j < k; j++)         if (lst[j] < lst[mn]) mn = j;       c = mn;       cur = p[i + 1] - p[lst[c] + 1];       p[i + 2] = (p[i + 1] + cur + md) % md;       lst[c] = i;     }     cout << p[n + m + 1];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<string, string> mp;   set<string> st;   int n;   char in[30];   string read() {     scanf(  %s , in);     return (string)in;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i += 1) {       string a = read();       string b = read();       if (st.find(b) != st.end()) {         continue;       }       st.insert(a);       if (mp.find(a) != mp.end()) {         mp[b] = mp[a];         mp.erase(a);         continue;       }       mp[b] = a;     }     printf( %d n , mp.size());     for (auto x : mp) {       if (x.second ==  _ ) {         continue;       }       printf( %s %s n , x.second.c_str(), x.first.c_str());     }   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   vector<vector<int>> p;   bool is(int val) {     int c = 0;     vector<bool> pres(n, 0);     bool flag = 0;     for (int i = 0; i < m; i++) {       c = 0;       for (int j = 0; j < n; j++) {         if (p[i][j] >= val) {           pres[j] = true;           c++;         }       }       if (c > 1) flag = 1;     }     if (!flag) return false;     bool ans = 1;     for (bool i : pres)       if (!i) return false;     return true;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int t;     cin >> t;     while (t--) {       cin >> m >> n;       p.assign(m, vector<int>(n));       int minn = INT_MAX, maxx;       for (int i = 0; i < m; i++)         for (int j = 0; j < n; j++) cin >> p[i][j];       for (int i = 0; i < n; i++) {         maxx = -1;         for (int j = 0; j < m; j++) {           maxx = max(maxx, p[j][i]);         }         minn = min(maxx, minn);       }       int l = 1, r = minn + 3;       while (r - l > 1) {         int mid = (l + r) / 2;         if (is(mid))           l = mid;         else           r = mid;       }       cout << l <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dp[80][80][80][80];   int dfs(int l1, int r1, int l2, int r2, int dep) {     if (l1 > r1 || l2 > r2) return 0;     if (l1 == l2 && r1 == r2) return r1 - l1 + 1;     if (r1 < 80 && r2 < 80 && dp[l1][r1][l2][r2] != -1) return dp[l1][r1][l2][r2];     int mid = (1 << dep - 1) - 1;     int res = 0;     if (l1 <= mid && mid <= r1 && l2 <= mid && mid <= r2) {       res = max(res, min(r1, r2) - max(l1, l2) + 1);     }     int l1_next[] = {l1, max(l1, mid + 1) - (mid + 1)};     int r1_next[] = {min(r1, mid - 1), r1 - (mid + 1)};     int l2_next[] = {l2, max(l2, mid + 1) - (mid + 1)};     int r2_next[] = {min(r2, mid - 1), r2 - (mid + 1)};     for (int i = 0; i < (2); i++)       for (int j = 0; j < (2); j++)         res = max(res,                   dfs(l1_next[i], r1_next[i], l2_next[j], r2_next[j], dep - 1));     if (r1 < 80 && r2 < 80) dp[l1][r1][l2][r2] = res;     return res;   }   int main() {     int l1, r1, l2, r2;     scanf( %d%d%d%d , &l1, &r1, &l2, &r2);     l1--;     r1--;     l2--;     r2--;     memset(dp, -1, sizeof dp);     printf( %d n , dfs(l1, r1, l2, r2, 30));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 4e5 + 123;   long long n, m, k;   int num[maxn];   int dp[maxn][5];   int presum[maxn];   int tmp[maxn];   int main(int argc, char const *argv[]) {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     std::cin >> n;     for (int i = 1; i <= n; i++) {       long long u;       std::cin >> u;       int one = 0;       while (u) {         if (u % 2 == 1) {           one++;         }         u /= 2;       }       num[i] = one;     }     long long ans = 0;     for (int i = 1; i <= n; i++) {       dp[i][1] = dp[i - 1][1];       dp[i][0] = dp[i - 1][0];       presum[i] = presum[i - 1] + num[i];       if (presum[i] % 2 == 1) {         dp[i][1] += 1;       } else {         dp[i][0] += 1;       }     }     int cur = n + 1;     for (int i = n; i >= 0; --i) {       tmp[i] = cur;       if (num[i] != 0) {         cur = i;       }     }     for (int i = 1; i <= n; i++) {       int k = presum[i - 1] % 2;       int cur = i;       int sum = num[i];       int maxx = num[i];       for (int j = 1; j < 71; j++) {         int kk = tmp[cur];         if (maxx <= sum / 2) {           ans += dp[kk - 1][k] - dp[cur - 1][k];         }         maxx = max(maxx, num[kk]);         sum += num[kk];         cur = kk;         if (cur > n) {           break;         }       }       ans += dp[n][k] - dp[cur - 1][k];     }     std::cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int cnt(long long int x) {     long long int ans = 0;     while (x) {       x /= 2;       ans++;     }     return ans;   }   int main() {     int t;     cin >> t;     while (t--) {       long long int d, m;       cin >> d >> m;       long long int temp = cnt(d) - 1;       long long int ans = d - pow(2, temp) + 2;       for (long long int i = temp - 1; i >= 0; i--) {         ans = ans * (pow(2, i) + 1);         ans %= m;       }       ans = (ans - 1) % m;       if (ans < 0) ans = m + ans;       cout << ans << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   inline int nextint() {     int res = 0;     char c = 0;     while (c <  0  || c >  9 ) c = getchar();     while (c >=  0  && c <=  9 ) {       res = res * 10 + c -  0 ;       c = getchar();     }     return res;   }   int n;   long long a[200000], b[200000];   bool good[200000];   bool ans[200000];   long long diff[200000];   const int maxh = 17;   const int maxn = (1 << maxh);   long long tree[2 * maxn];   void build() {     for (int i = maxn - 1; i; i--) tree[i] = min(tree[i + i], tree[i + i + 1]);   }   long long get(int i, int j) {     long long result = (long long)1e18;     for (i += maxn - 1, j += maxn; i + 1 != j; i >>= 1, j >>= 1) {       if (!(i & 1)) result = min(result, tree[i + 1]);       if (j & 1) result = min(result, tree[j - 1]);     }     return result;   }   long long get_min(int i, int j) {     long long result = (long long)1e18;     if (i <= j) result = get(i + 1, j + 2);     return result;   }   void go() {     memset(tree, 0, sizeof(tree));     for (int i = 0; i < (int)(n); ++i)       tree[maxn + i + 1] = tree[maxn + i] + diff[i];     build();     for (int i = 0; i < (int)(n); ++i) {       long long presum = tree[maxn + i];       long long postsum = tree[maxn + n] - presum;       long long m_main = get_min(i, n - 1);       long long m_oth = get_min(0, i - 1);       bool ok = true;       if (-presum + m_main < 0) ok = false;       if (postsum + m_oth < 0) ok = false;       good[i] = ok;     }   }   int main() {     cin >> n;     for (int i = 0; i < (int)(n); ++i) {       int _a;       scanf( %d , &_a);       a[i] = _a;     }     for (int i = 0; i < (int)(n); ++i) {       int _b;       scanf( %d , &_b);       b[i] = _b;     }     for (int i = 0; i < (int)(n); ++i) diff[i] = a[i] - b[i];     go();     for (int i = 0; i < (int)(n); ++i)       if (good[i]) ans[i] = true;     memset(good, 0, sizeof(good));     reverse(a + 1, a + n);     reverse(b, b + n);     for (int i = 0; i < (int)(n); ++i) diff[i] = a[i] - b[i];     go();     for (int i = 0; i < (int)(n); ++i)       if (good[i]) ans[(n - i) % n] = true;     int ans_size = 0;     for (int i = 0; i < (int)(n); ++i)       if (ans[i]) ans_size++;     cout << ans_size << endl;     for (int i = 0; i < (int)(n); ++i)       if (ans[i]) cout << (i + 1) <<    ;     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> edges[8];   int calc(int a, int b) {     vector<int> cnt(8);     for (auto e : edges[a]) cnt[e]++;     for (auto e : edges[b]) cnt[e]++;     int sol = 0;     for (int i = 1; i <= 7; i++)       if (cnt[i] == 2) sol++;     return sol;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n, m, a, b;     cin >> n >> m;     for (int i = 0; i < m; i++) {       cin >> a >> b;       edges[a].push_back(b);       edges[b].push_back(a);     }     if (n <= 6) {       cout << m <<   n ;       return 0;     }     int mmin = 1e9;     for (int i = 1; i <= n; i++) {       for (int j = i + 1; j <= n; j++) {         mmin = min(mmin, calc(i, j));       }     }     cout << m - mmin <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 300010;   const int M = 1000010;   const int MOD = 1000000007;   const int INF = 2e9;   const double eps = 1e-8;   const double PI = acos(-1.0);   int fx[] = {1, -1, 0, 0};   int fy[] = {0, 0, 1, -1};   int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }   int lcm(int x, int y) {     x /= gcd(x, y);     return x * y;   }   int Min(int a, int b) { return a < b ? a : b; }   int Max(int a, int b) { return a > b ? a : b; }   bool prime[M + 5], isprime[M + 5];   vector<int> v;   int n, m, q, cs, ar[123456];   void sieve() {     v.push_back(2);     prime[1] = 1;     int limit = (int)sqrt(M);     for (int i = 4; i <= M; i += 2) prime[i] = 1;     for (int i = 3; i <= M; i += 2) {       if (!prime[i]) {         v.push_back(i);         if (i <= limit) {           for (int j = i * i; j <= M; j += 2 * i) prime[j] = 1;         }       }     }   }   int br[123456];   int main() {     long long n, tot = 0;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> ar[i];       tot += ar[i];     }     for (int i = 0; i < n; i++) cin >> br[i];     sort(br, br + n);     long long a = br[n - 1], b = br[n - 2];     if (tot <= a + b)       cout <<  YES ;     else       cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, e = 0, st[100005], d[100005], T[100005], s[100005], Time;   struct Node {     int v, t;     double p;   };   struct {     int v, t, nx;   } edge[200005];   vector<Node> E[100005];   bool cmp(Node a, Node b) { return a.p < b.p; }   void add(int u, int v, int t) {     edge[e].v = v;     edge[e].t = t;     edge[e].nx = st[u];     st[u] = e++;   }   void dfs(int u, int fa, int t) {     s[u] = 1;     d[u] = 2 * t;     for (int i = st[u]; ~i; i = edge[i].nx) {       int v = edge[i].v;       if (v != fa) {         Node tmp;         t = edge[i].t;         tmp.v = v;         tmp.t = t;         E[u].push_back(tmp);         dfs(v, u, t);         s[u] += s[v];         d[u] += d[v];       }     }   }   void Dfs(int u) {     int m = E[u].size();     for (int i = 0; i < m; i++)       E[u][i].p = (double)d[E[u][i].v] / (double)s[E[u][i].v];     sort(E[u].begin(), E[u].end(), cmp);     for (int i = 0; i < m; i++) {       int v = E[u][i].v;       int t = E[u][i].t;       Time += t;       T[v] = Time;       Dfs(v);       Time += t;     }   }   int main() {     while (~scanf( %d , &n)) {       e = 0;       memset(st, -1, sizeof(st));       int a, b, t;       for (int i = 1; i < n; i++) {         scanf( %d%d%d , &a, &b, &t);         add(a, b, t);         add(b, a, t);       }       dfs(1, -1, 0);       Time = 0;       Dfs(1);       double ans = 0;       for (int i = 2; i <= n; i++) ans += 1.0 * T[i];       printf( %.12f n , ans / 1.0 / (n - 1));     }   }
#include <bits/stdc++.h>   const int INT_INF = 0x3f3f3f3f;   const int INT_M_INF = 0x7f7f7f7f;   const long long LL_INF = 0x3f3f3f3f3f3f3f3f;   const long long LL_M_INF = 0x7f7f7f7f7f7f7f7f;   const double pi = acos(-1.0);   using namespace std;   inline void debug(char ch) {     for (int __ii = 0; __ii < 20; ++__ii) putchar(ch);     printf(  n );   }   const double eps = 1e-8;   inline int dcmp(double a, double b) {     if (fabs(a - b) < eps) return 0;     return a < b ? -1 : 1;   }   const int dr[] = {0, 0, -1, 1, -1, -1, 1, 1};   const int dc[] = {-1, 1, 0, 0, -1, 1, -1, 1};   const int MAXN = 4000 + 10;   const int MAXT = 10000 + 10;   char s[MAXN], t[MAXN];   int main() {     memset(s, 0, sizeof s);     memset(t, 0, sizeof t);     while (scanf( %s%s , s, t) == 2) {       int slen = strlen(s), tlen = strlen(t), ans = 0;       for (int i = 0; i < slen; ++i) {         int num = 0;         for (int j = 0; j < tlen; ++j)           if (s[i + j] == t[j]) ++num;         ans = max(ans, num);       }       for (int i = 0; i < tlen; ++i) {         int num = 0;         for (int j = 0; j < slen; ++j)           if (t[i + j] == s[j]) ++num;         ans = max(ans, num);       }       printf( %d n , tlen - ans);       memset(s, 0, sizeof s);       memset(t, 0, sizeof t);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int nump;     int arr[7];     scanf( %d , &nump);     scanf( %d , &arr[0]);     for (int i = 1; i < 7; i++) {       scanf( %d , &arr[i]);       arr[i] += arr[i - 1];     }     int tmp = (nump / arr[6]), idx = 0;     if (tmp && arr[6] * tmp >= nump)       tmp = (tmp - 1) * arr[6];     else       tmp *= arr[6];     while (tmp + arr[idx] < nump) idx++;     printf( %d n , idx + 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s, s1, s2;     getline(cin, s);     getline(cin, s1);     getline(cin, s2);     int substr = s.find(s1), substr1;     int forward = 0, backward = 0;     if (substr != -1) {       substr1 = s.find(s2, substr + s1.length());       if (substr1 != -1) forward = 1;     }     string inverted;     for (substr = 0; substr <= s.length() - 1; substr++)       inverted = s[substr] + inverted;     substr = inverted.find(s1);     if (substr != -1) {       substr1 = inverted.find(s2, substr + s1.length());       if (substr1 != -1) backward = 1;     }     if (forward == 1 && backward == 0) cout <<  forward  << endl;     if (forward == 0 && backward == 1) cout <<  backward  << endl;     if (forward == 1 && backward == 1) cout <<  both  << endl;     if (forward == 0 && backward == 0) cout <<  fantasy  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int Maxn = 50005;   char str[Maxn];   int hs[26];   int main() {     scanf( %s , str);     int len = strlen(str), cCnt = 0;     int xNum = 0, sta = 0;     bool ok = false;     int i;     for (i = 0; i < len; i++) {       if (i - sta >= 26 && cCnt + xNum == 26) {         ok = true;         for (int j = sta; j < sta + 26; j++) {           if (str[j] ==  ? ) {             for (int k = 0; k < 26; k++) {               if (hs[k] == 0) {                 hs[k] = 1;                 str[j] =  A  + k;                 break;               }             }           }         }         break;       }       if (str[i] ==  ? )         xNum++;       else {         if (hs[str[i] -  A ] == 0) {           hs[str[i] -  A ] = 1;           cCnt++;         } else {           hs[str[i] -  A ]++;           cCnt++;           for (int j = sta; j < i; j++) {             if (str[j] == str[i]) {               hs[str[j] -  A ]--;               cCnt--;               sta = j + 1;               break;             } else {               if (str[j] ==  ? )                 xNum--;               else {                 hs[str[j] -  A ]--;                 cCnt--;               }             }           }         }       }     }     if (!ok && i - sta >= 26 && cCnt + xNum == 26) {       ok = true;       for (int j = sta; j < sta + 26; j++) {         if (str[j] ==  ? ) {           for (int k = 0; k < 26; k++) {             if (hs[k] == 0) {               hs[k] = 1;               str[j] =  A  + k;               break;             }           }         }       }     }     if (ok) {       for (int i = 0; i < len; i++) {         if (str[i] ==  ? ) str[i] =  A ;       }       printf( %s n , str);     } else {       puts( -1 );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 30;   int n, a[maxn];   long long k, res;   bool check(long long x) {     long long sum = 0;     for (int i = 0; i < n; ++i) {       sum += min((long long)a[i], x);       if (sum > k) return false;     }     return true;   }   int main() {     scanf( %d%I64d , &n, &k);     long long sum = 0;     for (int i = 0; i < n; ++i) {       scanf( %d , &a[i]);       sum += a[i];     }     if (k > sum) {       printf( -1 n );       return 0;     }     long long l = 0, r = sum;     while (l <= r) {       long long m = l + (r - l) / 2;       if (check(m))         l = m + 1;       else         r = m - 1;     }     sum = 0;     for (int i = 0; i < n; ++i) sum += min((long long)a[i], r);     res = k - sum;     int st = 0, flag = 1;     for (int i = 0; i < n; ++i) {       a[i] -= min((long long)a[i], r);       if (a[i]) {         if (res == 0 && flag) {           flag = 0;           st = i;         } else if (res > 0) {           --res;           --a[i];         }       }     }     for (int i = st; i < n; ++i)       if (a[i]) printf( %d  , i + 1);     for (int i = 0; i < st; ++i)       if (a[i]) printf( %d  , i + 1);     puts(  );     return 0;   }