malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int x[110000];   char str[110000];   long long tail[110000], a[110000], b[110000], c[110000], sum[110000],       cm1[110000], cm2[110000];   int n, m;   const long long MOD = 1000000007L;   long long mod_reset(long long x) { return (x % MOD + MOD) % MOD; }   void extgcd(long long a, long long b, long long &x, long long &y) {     if (b == 0) {       x = 1L;       y = 0L;       return;     }     long long div = a / b;     extgcd(b, a % b, y, x);     y = mod_reset(y - div * x % MOD);   }   long long get_antimul(long long a) {     long long x, y;     extgcd(a, MOD, x, y);     return x;   }   void conduct() {     long long ans;     scanf( %s , str);     for (int i = 0; i < n; ++i) x[i + 1] = str[i] -  0 ;     if (m == 0) {       ans = 0L;       for (int i = 1; i <= n; ++i) ans = (ans * 10 + x[i]) % MOD;       cout << ans << endl;       return;     }     cm1[n - m] = cm2[n - m] = 1;     for (int i = n - m; i; --i) {       long long ref = get_antimul(n - i - m + 1);       cm1[i - 1] = (cm1[i] * (n - i)) % MOD * ref % MOD;       cm2[i - 1] = (cm2[i] * (n - i - 1)) % MOD * ref % MOD;     }     tail[0] = 0L;     for (int i = 1; i <= n; ++i) tail[i] = tail[i - 1] + x[n - i + 1];     a[0] = b[0] = sum[0] = ans = 0L;     c[0] = 1L;     for (int i = 1; i <= n - m; ++i) {       a[i] = (a[i - 1] * 10 + x[i]) % MOD;       c[i] = c[i - 1] * 10 % MOD;       b[i] = (b[i - 1] + c[i - 1] * x[n - i + 1]) % MOD;       sum[i] = (mod_reset(sum[i - 1] - b[i - 1]) * 10 + tail[n - i + 1]) % MOD;       ans = (ans + mod_reset(sum[i] - a[i] - b[i]) * cm2[i] +              (a[i] + b[i]) * cm1[i]) %             MOD;     }     cout << ans << endl;   }   int main() {     while (scanf( %d%d , &n, &m) != EOF) conduct();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1e9 + 7;   const double PI = 3.141592653589793238463;   const int MAXN = 100005;   long long n, s;   long long temp = 0;   long long arr[MAXN];   bool ok(long long mid) {     long long tArray[n];     for (long long i = 0; i < n; i++) {       tArray[i] = (arr[i] + ((i + 1) * mid));     }     sort(tArray, tArray + n);     temp = 0;     long long t = mid;     for (int i = 0; i < t; i++) {       if (temp + tArray[i] <= s) {         temp += tArray[i];       } else {         return 0;       }     }     return 1;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> s;     for (int i = 0; i < n; i++) {       cin >> arr[i];     }     long long l = 0, r = n;     long long ans = 0;     long long mn = 0;     while (l <= r) {       long long mid = l + (r - l) / 2;       if (ok(mid)) {         ans = mid;         mn = temp;         l = mid + 1;       } else {         r = mid - 1;       }     }     cout << ans <<     << mn <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e3 + 5;   const int INF = 0x3f3f3f3f;   const int MOD = 1e3;   int ans[MAXN];   char s[MAXN];   void solve() {     int n;     cin >> n;     int k, num;     int s12, s13, s23;     cout <<  ?   << 1 <<     << 2 << endl;     scanf( %d , &s12);     cout <<  ?   << 1 <<     << 3 << endl;     scanf( %d , &s13);     cout <<  ?   << 2 <<     << 3 << endl;     scanf( %d , &s23);     ans[1] = s13 - s23;     ans[2] = s12 - ans[1];     ans[3] = s13 - ans[1] - ans[2];     for (int i = 4; i <= n; i++) {       cout <<  ?   << i - 1 <<     << i << endl;       scanf( %d , &ans[i]);       ans[i] = ans[i] - ans[i - 1];     }     cout <<  !   << ans[1] << flush;     for (int i = 2; i <= n; i++) {       cout <<     << ans[i] << flush;     }     cout << endl;     return;   }   int main() {     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int r, g, b;     cin >> r >> g >> b;     int a[3] = {r, g, b};     int i = 0;     while (a[0] > 0 || a[1] > 0 || a[2] > 0) {       if (a[i % 3] > 0) a[i % 3] -= 2;       i++;     }     cout << 30 + i - 1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX_N = 1e5 + 1;   int MOD = 1e9 + 7;   const int INF = 1e9;   const long long LINF = 1e18;   void solve() {     int n;     cin >> n;     string s;     cin >> s;     vector<int> a;     int ans = 0;     bool ok = true;     bool all_s = true;     vector<int> pref(n);     for (int i = 0; i < n; ++i) {       if (i == 0) {         if (s[i] ==  G )           pref[i] = 1;         else           pref[i] = 0;       } else {         if (s[i] ==  G )           pref[i] = 1 + pref[i - 1];         else           pref[i] = pref[i - 1];       }     }     for (int i = 0; i < n; ++i) {       if (s[i] ==  S ) {         ok = false;         int l = 0, r = 0;         bool k1 = false, k2 = false;         int j = i - 1;         while (j >= 0 && s[j] ==  G ) {           l++;           j--;         }         if (j > 0) {           if (pref[j - 1]) k1 = true;         }         j = i + 1;         while (j < n && s[j] ==  G ) {           r++;           j++;         }         if (j < n - 1 && pref[n - 1] - pref[j] > 0) k2 = true;         if (k1 || k2)           ans = max(ans, r + l + 1);         else           ans = max(ans, r + l);       } else         all_s = false;     }     if (ok) ans = n;     if (all_s) ans = 0;     cout << ans << endl;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t = 1;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   long long ans, fac[101000], fac_inv[101000], sum, nn;   int n, k, len;   char s[101000];   inline long long C(int x, int y) {     if (x < y || x < 0 || y < 0) return 0;     if (y == 0) return 1;     return fac[x] * fac_inv[y] % 1000000007 * fac_inv[x - y] % 1000000007;   }   inline long long power(long long x, int y) {     long long ret = 1;     for (; y; y >>= 1, x = x * x % 1000000007)       if (y & 1) ret = ret * x % 1000000007;     return ret;   }   int main() {     scanf( %d%d , &n, &k);     scanf( %s , s + 1);     len = strlen(s + 1);     fac[0] = 1;     for (int i = 1; i <= 101000; i++) fac[i] = fac[i - 1] * i % 1000000007;     fac_inv[101000] = power(fac[101000], 1000000007 - 2);     for (int i = 101000 - 1; i + 1; i--)       fac_inv[i] = (i + 1) * fac_inv[i + 1] % 1000000007;     sum = ans = 0;     nn = 1;     for (int i = n, tmp; i; i--) {       tmp = s[i] -  0 ;       ans = (ans + sum * tmp % 1000000007 +              nn * C(i - 1, k) % 1000000007 * tmp % 1000000007) %             1000000007;       sum = (sum + C(i - 2, k - 1) * nn % 1000000007) % 1000000007;       nn = nn * 10 % 1000000007;     }     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<char, int> mp;   map<char, int> mp1;   map<char, int> mp2;   long long frq[100002] = {};   bool lol = true;   int main() {     bool u = false;     long long x, y, p;     scanf( %lld%lld , &x, &y);     long long num = y, sum = 0;     if (x == 1 && y == 10) {       printf( -1 n );       return 0;     }     if (y < 10) {       for (int i = 1; i <= x; i++) {         cout << num;       }     } else {       for (int i = 1; i <= x; i++) {         if (i == x) {           cout << num % 10;         } else           cout << num / 10;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string a, b;     int n;     cin >> n >> a >> b;     int T[n], pom[n];     for (int i = 0; i < n; ++i) T[i] = -1;     for (int i = 0; i < n; ++i) {       bool ud = false;       for (int j = 0; j < n; ++j) {         if (T[j] == -1 && a[j] == b[i]) {           ud = true;           T[j] = i;           break;         }       }       if (!ud) {         cout << -1 << endl;         return 0;       }     }     queue<int> ans;     int t = (T[n - 1] == 0 ? n - 1 : n);     while (t > 0) {       int np = -1;       for (int i = 0; i < n; ++i)         if (T[i] == n - t) {           np = i;           break;         }       ans.push(n - np - 1);       ans.push(1);       ans.push(n);       int id = 0;       for (int i = np - 1; i >= 0; --i) {         pom[id++] = T[i];       }       for (int i = np + 1; i < t; ++i) {         pom[i - 1] = T[i];       }       t--;       for (int i = 0; i < t; ++i) T[i] = pom[i];       for (int i = t; i < n; ++i) {         T[i] = i - t;       }     }     cout << ans.size() << endl;     while (!ans.empty()) {       cout << ans.front() <<    ;       ans.pop();     }     cout << endl;   }
#include <bits/stdc++.h>   template <class T>   std::vector<T> ReadVector(size_t size) {     std::vector<T> vector(size);     for (auto& element : vector) {       std::cin >> element;     }     return vector;   }   int64_t divisor(int64_t x) {     for (int64_t d = 2; d * d <= x; ++d) {       while (x % d == 0) {         x /= d;         return d;       }     }     return x;   }   void YES(bool yes) {     if (yes) {       std::cout <<  YES n ;     } else {       std::cout <<  NO n ;     }   }   class Solver {    public:     Solver() {}     void solve() {       int t;       std::cin >> t;       while (t--) {         one();       }     }     int lo(int& a, int& d) {       if (a + d == 0) return 0;       int losers = 0;       if (d > a) {         int m = std::max(0, a);         losers += m;         d -= m;         a -= m;       } else if (d < a) {         int m = std::max(0, d - 1);         losers += m;         a -= m;         d -= m;       } else {         losers += d - 1;         d = 1;         a = 1;       }       return losers;     }     int wi(int& a, int& d) {       int winners = 0;       if (d > a) {         int m = a;         winners += m;         d -= m;         a = 0;       } else if (d < a) {         int m = d;         winners += m;         a -= m;         d = 0;       } else {         winners += d;         d = 0;         a = 0;       }       return winners;     }     void one() {       int n, x, y;       std::cin >> n >> x >> y;       if (x > y) std::swap(x, y);       int a = x - 1;       int b = n - x;       int c = y - 1;       int d = n - y;       int losers = 0;       losers += lo(a, d);       losers += lo(c, b);       losers += std::min(b, d);       a = x - 1;       b = n - x;       c = y - 1;       d = n - y;       int winners = 1;       winners += wi(a, d);       winners += wi(c, b);       winners += std::min(a, c);       std::cout << n - losers <<     << winners << std::endl;     }   };   int main() {     Solver solver;     solver.solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool debug = 0;   int n, m, k;   int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};   string direc =  RDLU ;   long long ln, lk, lm;   void etp(bool f = 0) {     puts(f ?  YES  :  NO );     exit(0);   }   void addmod(int &x, int y, int mod = 1000000007) {     assert(y >= 0);     x += y;     if (x >= mod) x -= mod;     assert(x >= 0 && x < mod);   }   void et() {     puts( -1 );     exit(0);   }   long long fastPow(long long x, long long y, int mod = 1000000007) {     long long ans = 1;     while (y > 0) {       if (y & 1) ans = (x * ans) % mod;       x = x * x % mod;       y >>= 1;     }     return ans;   }   char s[525][525], qy[525];   int a[525][525 + 300], q;   void pp(int x, int y) {     for (int(i) = 1; (i) <= (int)(x); (i)++) {       for (int(j) = 1; (j) <= (int)(y); (j)++) printf( %d  , a[i][j]);       puts(  );     }   }   void Gaw() {     int SZ = n + q;     int fr = 0;     for (int(i) = 1; (i) <= (int)(m); (i)++) {       int j = -1, r = i;       while (r <= n) {         for (int k = i; k <= m; k++) {           if (abs(a[k][r]) != 0) {             j = k;             break;           }         }         if (j == -1)           r++;         else {           for (int k = i; k <= m; k++) swap(a[k][i], a[k][r]);           break;         }       }       if (n < r) break;       if (j == -1) {         continue;       }       fr++;       if (i != j)         for (int k = i; k <= SZ; k++) swap(a[i][k], a[j][k]);       for (int k = i + 1; k <= m; k++)         if (k != i && a[k][i] != 0) {           for (int p = SZ; p >= i; p--) {             a[k][p] = a[i][p] * (5 - a[k][i]) % 5 + a[k][p] * a[i][i] % 5;             a[k][p] %= 5;           }         }     }     int ans = fastPow(5, n - fr);     for (int(i) = 1; (i) <= (int)(q); (i)++) {       int ta = ans;       for (int(j) = 1; (j) <= (int)(m); (j)++)         if (a[j][n + i] != 0) {           bool ok = 0;           for (int(x) = 1; (x) <= (int)(n); (x)++)             if (a[j][x] != 0) {               ok = 1;               break;             }           if (ok) continue;           ta = 0;           break;         }       printf( %d n , ta);     }   }   void fmain(int tid) {     scanf( %d%d , &n, &m);     for (int(i) = 1; (i) <= (int)(n); (i)++) scanf( %s , s[i] + 1);     for (int(j) = 1; (j) <= (int)(m); (j)++) {       for (int(i) = 1; (i) <= (int)(n); (i)++) {         a[j][i] = s[i][j] -  a ;       }     }     scanf( %d , &q);     for (int(i) = 1; (i) <= (int)(q); (i)++) {       scanf( %s , qy + 1);       for (int(j) = 1; (j) <= (int)(m); (j)++) {         a[j][n + i] = qy[j] -  a ;       }     }     Gaw();   }   int main() {     int t = 1;     for (int(i) = 1; (i) <= (int)(t); (i)++) {       fmain(i);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char a[130000];   struct gg {     int x, y, z;   } b[130000];   int cmp(gg p, gg q) { return p.z < q.z; }   void solve() {     int n, m;     cin >> n >> m;     cin >> a;     int l = 0;     int p = 0, q = 0, o = 0;     for (int i = 0; i < n; i++)       if (a[i] ==  W ) {         p = i;         o = i;         break;       }     for (int i = 0; i < n; i++) {       if (a[i] ==  W ) {         q = i;         b[l].x = p;         b[l].z = q - p - 1;         b[l++].y = q;         p = q;       }     }     sort(b, b + l, cmp);     for (int i = 0; i < l && m > 0; i++) {       int gg = b[i].x, hh = b[i].y;       for (int j = gg + 1; j < hh && m > 0; j++)         if (a[j] ==  L ) {           a[j] =  W ;           m--;         }     }     for (int i = o; i >= 0 && m > 0; i--)       if (a[i] ==  L ) {         a[i] =  W ;         m--;       }     for (int i = q; i < n && m > 0; i++)       if (a[i] ==  L ) {         a[i] =  W ;         m--;       }     int s = 0;     for (int i = 0; i < n; i++)       if (a[i] ==  W ) {         if (i == 0 || a[i - 1] !=  W )           s++;         else           s += 2;       }     printf( %d n , s);   }   int main() {     int t;     cin >> t;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   struct point {     int x, l;   } pp[1000000 * 2];   int qq[1000000 * 2], sk;   int pcompare(const void *a, const void *b) {     struct point *pa = (struct point *)a;     struct point *pb = (struct point *)b;     return pa->x != pb->x ? pa->x - pb->x : pb->l - pa->l;   }   void sort(struct point *pp, int n) {     int i;     srand(time(NULL));     for (i = n - 1; i >= 0; i--) {       struct point tmp;       int j = rand() % (i + 1);       tmp = pp[i], pp[i] = pp[j], pp[j] = tmp;     }     qsort(pp, n, sizeof *pp, pcompare);   }   void sweep(struct point *pp, int n, int k) {     int d, i;     d = 0;     for (i = 0; i <= n; i++)       if (pp[i].l) {         d++;         if (d == k) qq[sk++] = pp[i].x;       } else {         d--;         if (d == k - 1) qq[sk++] = pp[i].x;       }     printf( %d n , sk / 2);     for (i = 0; i < sk; i++) printf( %d%c , qq[i], i % 2 == 0 ?     :   n );   }   int main() {     int n, k, i;     scanf( %d%d , &n, &k);     for (i = 0; i < n; i++) {       int l, r;       scanf( %d%d , &l, &r);       pp[i * 2].x = l, pp[i * 2].l = 1;       pp[i * 2 + 1].x = r, pp[i * 2 + 1].l = 0;     }     sort(pp, n * 2);     sk = 0;     sweep(pp, n * 2, k);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double pi = acos(-1.0);   long long f[110][110];   long long n, k;   char s[110];   long long ch2i[225];   long long ich2i[110][225];   int main() {     cin >> n >> k;     scanf( %s , s);     for (int i =  a ; i <  z  + 1; i++) {       ch2i[i] = -1;     }     for (int i = n - 1; i >= 0; i--) {       for (int ch =  a ; ch <  z  + 1; ch++) {         ich2i[i][ch] = ch2i[ch];       }       ch2i[s[i]] = i;     }     f[0][0] = 1;     for (int i = 0; i < n; i++) {       f[i][1] = 1;     }     for (int len = 2; len < n + 1; len++) {       for (int i = 0; i < n - len + 1; i++) {         for (int j = i + 1; j < n - len + 2; j++) {           if (ich2i[i][s[j]] != j) continue;           f[i][len] += f[j][len - 1];         }       }     }     long long cnt = 0;     long long ans = 0;     for (int len = n + 1 - 1; len >= 0; len--) {       for (int i = 0; i < n - len + 1; i++) {         if (i != ch2i[s[i]]) continue;         cnt += f[i][len];         ans += (n - len) * f[i][len];         if (cnt >= k) {           ans -= (cnt - k) * (n - len);           cout << ans << endl;           return 0;         }       }     }     cout << -1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a, b, sol;   int main() {     sol = 1;     scanf( %lld%lld , &a, &b);     sol *= ((1LL) << __builtin_popcountll(b));     if (((a - b) & 1) || (((a - b) >> 1) & b)) {       puts( 0 );       return 0;     }     if (a == b) sol -= 2;     if (!(a & 1) && !b) {       puts( 1 );       return 0;     }     cout << sol;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 110, MAXK = 22, mod = 1000000007;   struct edge {     int adj, next;   } e[MAXN << 1];   int n, k, f[MAXN][MAXK << 1];   int tot, head[MAXN], temp[MAXK << 1];   inline void AddEdge(int u, int v) {     tot++;     e[tot].adj = v, e[tot].next = head[u];     head[u] = tot;   }   inline void Init() {     scanf( %d%d , &n, &k);     for (int i = 1; i < n; i++) {       int u, v;       scanf( %d%d , &u, &v);       AddEdge(u, v), AddEdge(v, u);     }   }   void DFS(int u, int fa) {     f[u][0] = f[u][k + 1] = 1;     for (int i = head[u]; i; i = e[i].next) {       int &v = e[i].adj;       if (v == fa) continue;       DFS(v, u);       memset(temp, 0, sizeof(temp));       for (int i = 0; i <= 2 * k; i++)         for (int j = 0; j <= 2 * k; j++) {           if (i + j + 1 <= 2 * k + 1)             temp[min(i, j + 1)] =                 (temp[min(i, j + 1)] + (long long)f[u][i] * f[v][j]) % mod;           else             temp[max(i, j + 1)] =                 (temp[max(i, j + 1)] + (long long)f[u][i] * f[v][j]) % mod;         }       memcpy(f[u], temp, sizeof(temp));     }   }   int main() {     Init();     DFS(1, 0);     int ans = 0;     for (int i = 0; i <= k; i++) ans = (ans + f[1][i]) % mod;     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = int(500 * 1000 + 7);   int n, k;   vector<pair<int, int> > adj[N];   long long dp[N][2];   void dfs(int v, int p = -1) {     vector<long long> x;     long long curr = 0;     for (auto it : adj[v]) {       int to = it.first;       int w = it.second;       if (to == p) continue;       dfs(to, v);       curr += dp[to][0];       x.push_back(dp[to][1] + w - dp[to][0]);     }     sort(x.begin(), x.end(), greater<long long>());     for (int i = 0; i < min((int)x.size(), k); i++) {       if (x[i] > 0) curr += x[i];     }     dp[v][0] = dp[v][1] = curr;     if (k <= (int)x.size() && x[k - 1] > 0) dp[v][1] -= x[k - 1];   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int q;     cin >> q;     while (q--) {       cin >> n >> k;       for (int i = 0; i < n; i++) adj[i].clear();       for (int i = 0; i < n - 1; i++) {         int u, v, w;         cin >> u >> v >> w;         u--;         v--;         adj[u].push_back({v, w});         adj[v].push_back({u, w});       }       dfs(0, -1);       cout << dp[0][0] << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int oo = 0x3f3f3f3f;   const long long ooo = 9223372036854775807ll;   const int _cnt = 1000 * 1000 + 7;   const int _p = 1000 * 1000 * 1000 + 7;   const int N = 200005;   const double PI = acos(-1.0);   const double eps = 1e-9;   int o(int x) { return x % _p; }   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; }   void file_put() {     freopen( filename.in ,  r , stdin);     freopen( filename.out ,  w , stdout);   }   long long Pow(long long x, long long k) {     long long ans = 1;     for (; k; k >>= 1, x = x * x % _p)       if (k & 1) (ans *= x) %= _p;     return ans;   }   long long calc(int x, int k, int m) {     return (Pow(10, k) * Pow(100 - 9 * x, m) % _p - Pow(91 - 9 * x, m)) % _p * x %            _p * Pow(9, _p - 2) % _p;   }   char st[N];   int n, cnt[10], s = 0;   long long ans = 0;   int main() {     scanf( %s , st + 1);     n = strlen(st + 1);     for (int i = (1); i <= (n); ++i) {       for (int j = (0); j <= (st[i] -  0  - 1 + (i == n)); ++j) {         cnt[j]++, s = 0;         for (int k = (0); k <= (9); ++k) {           s += cnt[k];           (ans += Pow(10, i - s) * calc(k, cnt[k], n - i) % _p) %= _p;         }         cnt[j]--;       }       cnt[st[i] -  0 ]++;     }     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, c;     long long t, a;     scanf( %d%lld%d , &n, &t, &c);     int ans = 0, tmp = 0;     for (int i = 0; i < n; i++) {       scanf( %lld , &a);       if (a > t) {         tmp = 0;       } else {         tmp++;         if (tmp >= c) {           ans++;         }       }     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int i, j, k, p, q, mx = 0, sm = -1, smc = 0, cnt = 0, n;     scanf( %d , &n);     int arr[n + 5];     int a[100050];     memset(a, 0, sizeof(a));     for (i = 0; i < n; i++) {       scanf( %d , &p);       a[p]++;       arr[i] = p;     }     sort(arr, arr + n);     for (i = n - 1; i >= 0; i--) {       if (a[arr[i]] % 2) {         return !printf( Conan n );       }     }     printf( Agasa n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long mas[200100], k, s = 0, d;   long long n, p = 1, del = 0, a, b, c;   unsigned long long inf =       (unsigned long long)1000000000 * 1000000000 * (long long)10;   int main() {     cin >> n >> k;     for (int i = 1; i <= n; i++) scanf( %I64d , &mas[i]);     for (int i = 1; i <= n; i++, p++) {       a = (p - 1);       b = (n - del - p);       c = mas[i];       if (a * b > (s - k) / c) {         printf( %d n , i);         p--;         del++;       } else {         if (s < inf) s += (p - 1) * mas[i];       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int t, n, a[1000], k;   int main()   {       cin >> t;       while(t--)       {           cin >> n >> k;           if(k <= (n - 1)/2)           {               int spt = 0, spt1 = k + 1;               for(int i = 1; i <= 2*k + 1; i++)               {                   if(i%2 == 1)                       a[i] = ++spt;                   else a[i] = ++spt1;               }               for(int i = 2*k + 2; i <= n; ++i)                   a[i] = ++spt1;               for(int i = 1; i <= n; ++i)                   cout << a[i] <<    ;               cout <<   n ;           }           else cout << -1 <<   n ;       }       return 0;   }