malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   void read(long long &x) {     char ch = getchar();     x = 0;     while (!isdigit(ch)) ch = getchar();     while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();   }   const long long N = 2e5 + 10;   long long n, mx, rt, tmp, sum, f[N], fr[N], tot, st[N], fl[N], p[N];   long long cnt, h[N], to[N << 1], nxt[N << 1], len[N << 1], d[N], vis[N];   void add(long long u, long long v, long long l) {     to[++cnt] = v, len[cnt] = l, nxt[cnt] = h[u], h[u] = cnt;     to[++cnt] = u, len[cnt] = l, nxt[cnt] = h[v], h[v] = cnt;   }   void dfs(long long u, long long la) {     if (d[u] > d[mx]) mx = u;     fr[u] = la;     for (long long i = h[u], v; i; i = nxt[i]) {       if ((v = to[i]) == la) continue;       fl[v] = len[i], d[v] = d[u] + len[i], dfs(v, u);     }   }   void get_dis(long long u, long long deep) {     f[u] = deep;     vis[u] = 1;     for (long long i = h[u]; i; i = nxt[i])       if (!vis[to[i]]) get_dis(to[i], deep + len[i]);   }   long long ff[N], dp[N];   void get_fa(long long u, long long deep) {     dp[u] = deep;     for (long long i = h[u], v; i; i = nxt[i])       if ((v = to[i]) != ff[u]) ff[v] = u, get_fa(v, deep + 1);   }   bool cmp(long long x, long long y) {     return f[x] == f[y] ? dp[x] < dp[y] : f[x] < f[y];   }   long long fa[N], sz[N];   long long find(long long x) { return fa[x] == x ? x : (fa[x] = find(fa[x])); }   void work(long long l) {     long long res = 0;     for (long long i = 1; i <= n; ++i) fa[i] = i, sz[i] = 1;     for (long long i = n, j = n; i >= 1; --i) {       while (f[p[j]] > f[p[i]] + l) --sz[find(p[j--])];       res = max(res, sz[p[i]]);       fa[p[i]] = find(ff[p[i]]);       sz[find(ff[p[i]])] += sz[p[i]];     }     printf( %lld n , res);   }   signed main() {     read(n);     for (long long i = 1, u, v, l; i < n; ++i)       read(u), read(v), read(l), add(u, v, l);     dfs(1, 0);     d[mx] = fl[mx] = 0, dfs(mx, 0);     while (mx) sum += fl[mx], st[++tot] = mx, vis[mx] = 1, mx = fr[mx];     long long now = 0, mn = 1e15;     for (long long i = 1; i <= tot; ++i) {       get_dis(st[i], max(now, sum - now));       if (max(now, sum - now) < mn) mn = max(now, sum - now), rt = st[i];       now += fl[st[i]];     }     get_fa(rt, 0);     for (long long i = 1; i <= n; ++i) p[i] = i;     sort(p + 1, p + n + 1, cmp);     long long m, x;     read(m);     while (m--) read(x), work(x);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct E {     int x, y;   };   E map1[1010], map2[1010], map3[1010];   int vis[1010];   int n, flag;   void dfs(int k) {     if (k == n + 1) {       cout << map3[n].x <<     << map3[n].y;       flag = 1;       return;     } else {       for (int i = 1; i <= n; i++) {         if (!vis[i]) {           if (map1[k].x + map2[i].x == map3[k - 1].x &&               map1[k].y + map2[i].y == map3[k - 1].y) {             vis[i] = 1;             map3[k].x = map1[k].x + map2[i].x;             map3[k].y = map1[k].y + map2[i].y;             dfs(k + 1);             if (flag) {               break;             }             vis[i] = 0;           }         }       }     }   }   int main(int argc, char *argv[]) {     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> map1[i].x >> map1[i].y;     }     for (int i = 1; i <= n; i++) {       cin >> map2[i].x >> map2[i].y;     }     for (int i = 1; i <= n; i++) {       map3[1].x = map1[1].x + map2[i].x;       map3[1].y = map1[1].y + map2[i].y;       vis[i] = 1;       dfs(2);       vis[i] = 0;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char arr[205];   int main() {     ios::sync_with_stdio(0);     int n;     cin >> n;     for (int i = (0); i < (n); i++) cin >> arr[i];     long long res = 0;     pair<int, int> udlr;     for (int i = (0); i < (n); i++) {       udlr.first = 0;       udlr.second = 0;       for (int j = (i); j < (n); j++) {         if (arr[j] ==  U ) udlr.first += 1;         if (arr[j] ==  D ) udlr.first -= 1;         if (arr[j] ==  L ) udlr.second += 1;         if (arr[j] ==  R ) udlr.second -= 1;         if (udlr.second == 0 && udlr.first == 0) res++;       }     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   using namespace std;   const long double pi = acos(-1.0);   const long double log23 = 1.58496250072115618145373894394781;   const long double eps = 1e-8;   const long long INF = 1e18 + 239;   const long long prost = 239;   const int two = 2;   const int th = 3;   const long long MOD = 998244353;   const long long MOD2 = MOD * MOD;   const int BIG = 1e9 + 239;   const int alf = 26;   const int dx[4] = {-1, 0, 1, 0};   const int dy[4] = {0, 1, 0, -1};   const int dxb[4] = {-1, 1, 1, -1};   const int dyb[4] = {-1, 1, -1, 1};   const int dxo[8] = {-1, -1, -1, 0, 1, 1, 1, 0};   const int dyo[8] = {-1, 0, 1, 1, 1, 0, -1, -1};   const int dig = 10;   const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};   const int digarr[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};   const long long bt = 62;   template <typename T>   inline T gcd(T a, T b) {     while (a) {       b %= a;       swap(a, b);     }     return b;   }   template <typename T>   inline T lcm(T a, T b) {     return (a / gcd(a, b)) * b;   }   inline bool is_down(char x) { return ( a  <= x && x <=  z ); }   inline bool is_upper(char x) { return ( A  <= x && x <=  Z ); }   inline bool is_digit(char x) { return ( 0  <= x && x <=  9 ); }   mt19937_64 rnd(239);   const int M = 3e5 + 239;   const int N = 2e3 + 239;   const int L = 103;   const int T = (1 << 18);   const int B = trunc(sqrt(M)) + 1;   const int X = 1e4 + 239;   long long dp[two][M];   int n, kol;   vector<int> v[M];   long long pref[M], suf[M], now, fl[M];   void dfs(int p, int pr) {     for (int i : v[p])       if (i != pr) dfs(i, p);     dp[0][p] = 1;     for (int i : v[p])       if (i != pr) dp[0][p] = (dp[0][p] * (dp[0][i] + dp[1][i])) % MOD;     dp[1][p] = 0;     kol = 0;     pref[0] = 1;     for (int i : v[p])       if (i != pr) {         kol++;         pref[kol] = (pref[kol - 1] * (2LL * dp[1][i] + dp[0][i])) % MOD;       }     reverse(v[p].begin(), v[p].end());     suf[kol] = 1;     for (int i : v[p])       if (i != pr) {         kol--;         suf[kol] = (suf[kol + 1] * (2LL * dp[1][i] + dp[0][i])) % MOD;       }     reverse(v[p].begin(), v[p].end());     for (int i : v[p])       if (i != pr) {         now = (pref[kol] * suf[kol + 1]) % MOD;         kol++;         now = (now * fl[i]) % MOD;         dp[1][p] = (dp[1][p] + now) % MOD;       }     fl[p] = pref[kol];   }   int main() {     ios::sync_with_stdio(0);     cin.tie();     cout.tie(0);     cin >> n;     for (int i = 0; i < n - 1; i++) {       int s, f;       cin >> s >> f;       s--, f--;       v[s].push_back(f);       v[f].push_back(s);     }     dfs(0, -1);     cout << (dp[0][0] + dp[1][0]) % MOD;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   ostream& operator<<(ostream& os, const vector<T>& v) {     os <<  [ ;     for (auto u : v) {       os << u;       os <<  , ;     }     os <<  ]         <<   n ;     return os;   }   template <typename T>   ostream& operator<<(ostream& os, const set<T>& s) {     os <<  { ;     for (auto u : s) {       os << u;       if (u != *s.rbegin()) os <<  , ;     }     os <<  }         <<   n ;     return os;   }   template <typename T, typename U>   ostream& operator<<(ostream& os, const pair<T, U>& p) {     os <<  { ;     os << p.first <<  ,  << p.second;     os <<  }         <<   n ;     return os;   }   template <typename T, typename U>   ostream& operator<<(ostream& os, const map<T, U>& mp) {     for (auto p : mp) os << p.first <<   :   << p.second <<   n ;     return os;   }   void boost() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cout << fixed << setprecision(3);   }   int32_t main() {     boost();     long long t = 1;     while (t--) {       long long a[3], d;       cin >> a[0] >> a[1] >> a[2] >> d;       sort(a, a + 3);       if (a[1] >= a[0] + d && a[2] >= a[1] + d)         cout << 0 <<   n ;       else {         if (a[1] >= a[0] + d) {           if (a[2] >= a[0] + 2 * d) {             long long get = a[2] - d;             long long ans = a[1] - get;             cout << ans <<   n ;           } else {             long long have = (a[1] + d) - a[2];             cout << have <<   n ;           }         } else if (a[2] >= a[1] + d) {           if (a[2] >= a[0] + 2 * d) {             long long get = a[0] + d;             long long ans = get - a[1];             cout << ans <<   n ;           } else {             long long have = abs((a[1] - d) - a[0]);             cout << have <<   n ;           }         } else {           long long ans = abs(d - (a[1] - a[0]));           ans = ans + abs(d - (a[2] - a[1]));           cout << ans <<   n ;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline string tostring(const T &x) {     ostringstream os;     os << x;     return os.str();   }   inline int toint(const string &s) {     istringstream is(s);     int x;     is >> x;     return x;   }   inline int todecimal(string s) {     int a = 0;     for (int i = 0; i < s.size(); i++) a = 2 * a + (s[i] -  0 );     return a;   }   inline string tobinary(int a) {     string s;     while (a != 0) {       s = (char)(a % 2 +  0 ) + s;       a >>= 1;     }     return s;   }   template <typename T>   inline T sqr(T x) {     return x * x;   }   template <typename T>   T gcd(T a, T b) {     return (b == 0) ? abs(a) : gcd(b, a % b);   }   inline int isvowel(char c) {     if (c ==  a  || c ==  e  || c ==  i  || c ==  o  || c ==  u ) return 1;     return 0;   }   inline int isprime(int a) {     for (int i = 2; i * i <= a; i++)       if (!(a % i)) return 0;     return 1;   }   inline void inp(int &n) {     n = 0;     int ch = getchar();     int sign = 1;     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) sign = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 )       n = (n << 3) + (n << 1) + ch -  0 , ch = getchar();     n = n * sign;   }   const int dx4[4] = {0, 0, 1, -1};   const int dy4[4] = {1, -1, 0, 0};   const int dx8[8] = {0, 0, 1, 1, 1, -1, -1, -1};   const int dy8[8] = {1, -1, 0, 1, -1, 1, 0, -1};   class node {    public:     int x, y, z;     node(int a, int b, int c) {       x = a;       y = b;       z = c;     }   };   bool operator<(const node &a, const node &b) { return a.x > b.x; }   bool compare(const node &a, const node &b) { return a.x < b.x; }   void solve() {}   void input() {     int n, k;     cin >> n >> k;     int ans = INT_MIN;     int f, t;     for (int i = 0; i < n; i++) {       cin >> f >> t;       if (t > k)         ans = max(ans, f - t + k);       else         ans = max(ans, f);     }     cout << ans << endl;   }   int main() {     int testcase = 1;     for (int i = 0; i < testcase; i++) {       input();       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, k, a[2005][2005], ans, p;   int main() {     cin >> n >> m >> k;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) {         char c;         c = getchar();         while (c !=  .  && c !=  * ) c = getchar();         a[i][j] = c;         if (c ==  . ) p++;       }     if (k == 1) {       cout << p;       return 0;     }     int x = 0;     for (int i = 1; i <= n; i++) {       x = 0;       for (int j = 1; j <= m; j++) {         if (a[i][j] == a[i][j - 1] && a[i][j] ==  . )           x++;         else if (a[i][j] ==  . )           x = 1;         else {           if (x >= k) ans += x - k + 1;           x = 0;         }       }       if (x >= k) ans += x - k + 1;     }     for (int j = 1; j <= m; j++) {       x = 0;       for (int i = 1; i <= n; i++) {         if (a[i][j] == a[i - 1][j] && a[i][j] ==  . )           x++;         else if (a[i][j] ==  . )           x = 1;         else {           if (x >= k) ans += x - k + 1;           x = 0;         }       }       if (x >= k) ans += x - k + 1;     }     cout << endl << ans;   }
#include <bits/stdc++.h>   using namespace std;   int arr[300], book[300], n, a, b, flag = 0, tun = 0;   int main() {     cin >> n >> a >> b;     arr[a] = arr[b] = 2;     while (!flag) {       tun++;       memset(book, 0, sizeof(book));       for (int i = 1; i <= n; i++) {         if (!book[i] && (arr[i] == 0 || arr[i] == 2)) {           for (int j = i + 1; j <= n; j++) {             if (!book[j] && (arr[j] == 0 || arr[j] == 2)) {               if (arr[i] == 2 && arr[j] == 2) {                 flag = 1;               } else if (arr[i] == 0 && arr[j] == 2) {                 arr[i] = 1;               } else if (arr[i] == 2 && arr[j] == 0)                 arr[j] = 1;               else                 arr[i] = 1;               book[i] = book[j] = 1;               break;             }           }         }       }       if (flag) break;     }     int ans = (int)pow(2, tun);     if (ans == n)       cout <<  Final!  << endl;     else       cout << tun << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, t[1000 * 1000], a[1000 * 1000], b[1000 * 1000], v, ans;   map<long long, long long> w;   long long get(int v, int tl, int tr, int l, int r) {     if (r < tl || tr < l) return 0;     if (l <= tl && tr <= r) return t[v];     int m = (tl + tr) >> 1;     return max(get(v + v, tl, m, l, min(r, m)),                get(v + v + 1, m + 1, tr, max(l, m + 1), r));   }   void upd(int v, int l, int r, int p, long long x) {     if (l == r)       t[v] = x;     else {       int m = (l + r) >> 1;       if (p <= m)         upd(v + v, l, m, p, x);       else         upd(v + v + 1, m + 1, r, p, x);       t[v] = max(t[v + v], t[v + v + 1]);     }   }   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       long long r, h;       cin >> r >> h;       b[i] = a[i] = ((r) * (r)) * h;     }     sort(b + 1, b + 1 + n);     for (int i = 1; i <= n; i++) w[b[i]] = i;     for (int i = 1; i <= n; i++) {       v = get(1, 1, n, 1, w[a[i]] - 1) + a[i];       upd(1, 1, n, w[a[i]], v);       ans = max(ans, v);     }     printf( %.7f , ans * acos(-1));   }
#include <bits/stdc++.h>   using namespace std;   constexpr int inf = 1e9;   int main() {     int n, q;     cin >> n >> q;     vector<int> t(q), l(q), r(q), v(q);     vector<int> added(n), ub(n, inf);     for (int j = 0; j < q; ++j) {       cin >> t[j] >> l[j] >> r[j] >> v[j];       l[j]--;       if (t[j] == 1) {         for (int i = l[j]; i < r[j]; ++i) {           added[i] += v[j];         }       } else {         for (int i = l[j]; i < r[j]; ++i) {           ub[i] = min(ub[i], v[j] - added[i]);         }       }     }     vector<int> ans = ub;     for (int i = 0; i < q; ++i) {       if (t[i] == 1) {         for (int j = l[i]; j < r[i]; ++j) {           ans[j] += v[i];         }       } else {         int maxi = -inf;         for (int j = l[i]; j < r[i]; ++j) {           maxi = max(maxi, ans[j]);         }         if (maxi != v[i]) {           cout <<  NO  << endl;           return 0;         }       }     }     cout <<  YES  << endl;     for (int i = 0; i < n; ++i) {       cout << ub[i] <<    n [i + 1 == n];     }   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 5e5 + 5;   vector<long long> g[N];   map<long long, long long> cnt;   long long n, c, a[N], pref[N];   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> c;     for (long long i = 1; i <= n; i++) {       cin >> a[i];       cnt[a[i]]++;       g[a[i]].push_back(i);       pref[i] = pref[i - 1] + (a[i] == c);     }     long long ans = cnt[c];     for (long long i = 1; i < N; i++) {       if (!g[i].size() || i == c) continue;       long long prev = g[i][0];       long long cur = 0, max_so_far = 0;       for (auto it : g[i]) {         cur = cur + 1 - (pref[it] - pref[prev]);         prev = it;         if (cur <= 0) cur = 1;         max_so_far = max(max_so_far, cur);       }       ans = max(ans, pref[n] + max_so_far);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, q;   char s2[10000006];   char s[205][205];   int vis[205][205];   int dp[205 * 205][20];   int dx[10];   int dy[10];   vector<int> Q;   int id(int x, int y) { return x * m + y; }   void dfs(int x, int y) {     vis[x][y] = 1;     int t = (s[x][y] -  0 ), p = id(x, y);     int xx = x + dx[t], yy = y + dy[t];     if (xx < 0 || xx >= n || yy < 0 || yy >= m)       dp[p][t] = p;     else {       int v = id(xx, yy);       dp[p][t] = id(xx, yy);       if (vis[xx][yy] == 0) dfs(xx, yy);       for (int i = 0; i < 10; i++)         if (i != t) dp[p][i] = dp[v][i];     }   }   int check(char s2[]) {     int len = strlen(s2);     for (int i = 0; i < Q.size(); i++) {       int x = Q[i];       for (int j = 0; j < len; j++) {         x = dp[x][s2[j] -  0 ];         if (x < 0) break;       }       if (x >= 0) return 1;     }     return 0;   }   int main() {     memset(dp, -1, sizeof(dp));     scanf( %d%d%d , &n, &m, &q);     for (int i = 0; i < n; i++) scanf( %s , s[i]);     for (int i = 0; i < 10; i++) scanf( %d%d , &dx[i], &dy[i]);     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (!vis[i][j]) {           dfs(i, j);           Q.push_back(id(i, j));         }       }     }     for (int i = 0; i < q; i++) {       scanf( %s , s2);       if (check(s2))         printf( YES n );       else         puts( NO );     }   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:66777216 )   using namespace std;   int RAND() { return (rand() << 16) + rand(); }   const long long MOD = 1000000007;   const int N = 2000007;   int n;   long long f[N];   long long power(long long a, long long b) {     if (b == 0) return 1;     if (b & 1) return a * power(a, b - 1) % MOD;     long long r = power(a, b >> 1);     return r * r % MOD;   }   long long inv(long long a) { return power(a, MOD - 2); }   long long C(int n, int k) { return f[n] * inv(f[k] * f[n - k] % MOD) % MOD; }   void solve() {     f[0] = 1;     for (int i = 1; i < N; ++i) f[i] = i * f[i - 1] % MOD;     cin >> n;     long long ans = ((n + 2) * C(2 * n + 2, n) - n - 1) % MOD * inv(n + 1) % MOD;     if (ans < 0) ans += MOD;     cout << ans << endl;   }   void testgen() {     FILE* f = fopen( input.txt ,  w );     fclose(f);   }   int main() {     cout << fixed;     cout.precision(16);     cerr << fixed;     cerr.precision(3);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long calc(int *a, int n) {     long long ret = 0, suml = 0;     stack<pair<int, int> > st;     for (int i = 2; i <= n; i++) {       int l = 1;       while (!st.empty() && abs(a[i] - a[i - 1]) > st.top().first) {         suml -= st.top().first * (long long)st.top().second;         l += st.top().second;         st.pop();       }       st.push(make_pair(abs(a[i] - a[i - 1]), l));       suml += abs(a[i] - a[i - 1]) * (long long)l;       ret += suml;     }     return ret;   }   int n, m, a[100010];   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     for (int i = 1; i <= m; i++) {       int l, r;       scanf( %d%d , &l, &r);       printf( %I64d n , calc(a + l - 1, r - l + 1));     }     return 0;   }
#include <bits/stdc++.h>   int n, m;   long long ans;   int main() {     int i, j, k;     scanf( %d%d , &n, &m);     for (i = m + 1; (i << 1) <= n; ++i) {       k = n - m;       for (j = m + 1; j <= n - m; ++j) {         while (k > m && 0 <= (i << 1) * ((i << 1) - j - ((n << 1) - k + 2)) +                                  3 * j * k + j * ((n << 1) - k + 2))           --k;         ans += k - m;       }     }     ans <<= 1;     if (n & 1) {       i = (n >> 1) + 1;       k = n - m;       for (j = m + 1; j <= n - m; ++j) {         while (k > m && 0 <= (i << 1) * ((i << 1) - j - ((n << 1) - k + 2)) +                                  3 * j * k + j * ((n << 1) - k + 2))           --k;         ans += k - m;       }     }     printf( %I64d n , ans * 3);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, rooms = 0;     char a, b;     scanf( %d n , &n);     int arr[30];     for (int i = 0; i < 26; i++) arr[i] = 0;     for (int i = 0; i < 2 * (n - 1); i += 2) {       scanf( %c%c , &a, &b);       arr[(int)(a -  a )]++;       if (arr[(int)(tolower(b) -  a )] > 0)         arr[(int)(tolower(b) -  a )]--;       else         rooms++;     }     cout << rooms << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using namespace std;   int main() {     string s;     int t[128];     t[ > ] = 8;     t[ < ] = 9;     t[ + ] = 10;     t[ - ] = 11;     t[ . ] = 12;     t[ , ] = 13;     t[ [ ] = 14;     t[ ] ] = 15;     cin >> s;     int ans = 0;     for (int i = 0; i < (int)(s).size(); ++i) {       ans = (ans * 16 + t[(int)s[i]]) % 1000003;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long n, x, i, m = 1, second = 0;     cin >> n >> x;     long long a[n];     for (i = 0; i < n; i++) cin >> a[i];     sort(a, a + n);     for (i = n - 1; i >= 0; i--) {       second += a[i];       if (((second * 1.0) / m) < (x * 1.0)) break;       m++;     }     cout << m - 1 <<   n ;   }   signed main() {     long long t = 1;     cin >> t;     while (t--) solve();   }
#include <bits/stdc++.h>   using namespace std;   int n;   vector<char> veq;   void getVeq() {     string s;     cin >> s;     veq.clear();     n = s.length();     veq.push_back( x );     veq.push_back( x );     for (int i = 0; i < s.length(); i++) veq.push_back(s[i]);     veq.push_back( x );     veq.push_back( x );   }   vector<int> ind;   void getRes() {     char a, b, curr, c, d;     ind.clear();     a = veq[0];     b = veq[1];     curr = veq[2];     c = veq[3];     d = veq[4];     for (int i = 2; i <= n + 1; i++) {       curr = veq[i];       c = veq[i + 1];       d = veq[i + 2];       if (curr ==  e  && b ==  n  && a ==  o ) {         ind.push_back(i - 2);         b =  e ;       } else if (curr ==  o  && b ==  w  && a ==  t ) {         if (c ==  n  && d ==  e ) {           ind.push_back(i - 1);         } else {           ind.push_back(i - 2);           b =  o ;         }       } else {         a = b;         b = curr;       }     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int t;     cin >> t;     while (t--) {       getVeq();       getRes();       cout << ind.size() <<   n ;       for (int i = 0; i < ind.size(); i++) cout << ind[i] <<    ;       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, k, p, x, y, f, kek, all, a[100005];   int main() {     cin >> n >> k >> p >> x >> y;     for (int i = 1; i <= k; i++) cin >> a[i];     int kol = (n + 1) / 2;     for (int i = 1; i <= k; i++)       if (a[i] >= y) kol--;     if (n - k < kol) {       cout << -1;       return 0;     }     if (kol > 0)       for (int j = k + 1; j <= k + kol; j++) a[j] = y;     kol = max(0, kol);     for (int j = k + kol + 1; j <= n; j++) a[j] = 1;     int all = 0;     for (int i = 1; i <= n; i++) all += a[i];     if (all > x) {       cout << -1;       return 0;     }     for (int i = k + 1; i <= n; i++) cout << a[i] <<    ;   }