malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long int MOD = 998244353;   long long int INF = 1e18;   long long int vv;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long int i, j, k = 0, l = 0, r = 0, m = 0, n, c, p = 0, cnt = 0,                         cnt1 = 0, x, y, z = 0, a, b, low, mid, high, ans = 0,                         maxi = 0, mini = INF, t, x1, y1;     string s;     cin >> s;     n = s.size();     queue<long long int> q;     long long int V[n];     bool visited[10];     long long int dist[10];     long long int ds[10][10];     for (i = 0; i < n; i++) {       k = s[i];       k = k - 48;       V[i] = k;     }     for (i = 0; i <= 9; i++) {       for (j = 0; j <= 9; j++) {         for (l = 0; l <= 9; l++) {           for (r = 0; r <= 9; r++) {             ds[l][r] = -1;           }         }         for (l = 0; l <= 9; l++) {           for (r = 0; r <= 9; r++) {             visited[r] = false;             dist[r] = INF;           }           q.push(l);           dist[l] = 0;           if (i == 0 || j == 0) {             ds[l][l] = 1;             visited[l] = true;           }           while (!q.empty()) {             k = q.front();             q.pop();             r = (k + i) % 10;             if (visited[r] == false) {               visited[r] = true;               dist[r] = (dist[k] + 1);               ds[l][r] = dist[r];               q.push(r);             }             r = (k + j) % 10;             if (visited[r] == false) {               visited[r] = true;               dist[r] = (dist[k] + 1);               ds[l][r] = dist[r];               q.push(r);             }           }         }         cnt = 0;         for (l = 0; l < n - 1; l++) {           if (ds[V[l]][V[l + 1]] == -1) {             cnt = -1;             goto last;           } else {             cnt += ds[V[l]][V[l + 1]] - 1;           }         }       last:         cout << cnt <<    ;       }       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   long long n, m;   long long a[201];   char s[30];   long long b[30];   long long dp[2000000];   long long f(long long mask) {     if (mask == (1 << m) - 1) return 0;     if (dp[mask] != -1) return dp[mask];     long long count = __builtin_popcount(mask);     char ch = s[count];     long long move = b[count];     long long ans = -1e8;     long long sign = 1;     if (move == 2) sign = -1;     ans *= sign;     for (long long i = 0; i < m; i++) {       if ((mask) & (1 << i)) continue;       if (ch ==  p ) {         if (sign == 1)           ans = max(ans, f((mask | (1 << i))) + sign * a[i]);         else           ans = min(ans, f((mask | (1 << i))) + sign * a[i]);       } else {         if (sign == 1)           ans = max(ans, f((mask | (1 << i))));         else           ans = min(ans, f((mask | (1 << i))));       }     }     return dp[mask] = ans;   }   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     cin >> n;     for (long long i = 0; i < n; i++) cin >> a[i];     sort(a, a + n);     reverse(a, a + n);     cin >> m;     for (long long i = 0; i < m; i++) cin >> s[i] >> b[i];     memset(dp, -1, sizeof(dp));     cout << f(0);   }
#include <bits/stdc++.h>   using namespace std;   int a[2010], b[2010];   bool vis[2010];   char *p1, *p2, buf[100000];   int rd() {     int x = 0, f = 1;     char c =         (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)              ? EOF              : *p1++);     while (c < 48) {       if (c ==  - ) f = -1;       c = (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)                ? EOF                : *p1++);     }     while (c > 47) {       x = (((x << 2) + x) << 1) + (c ^ 48),       c = (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)                ? EOF                : *p1++);     }     return x * f;   }   map<int, int> MP;   int n;   bool check(int x) {     for (int i = 1; i <= n - x + 1; i++) {       memset(vis, false, sizeof vis);       bool flag = true;       for (int j = 1; j < i; j++) {         if (vis[a[j]]) {           flag = false;         }         vis[a[j]] = true;       }       for (int j = i + x; j <= n; j++) {         if (vis[a[j]]) {           flag = false;         }         vis[a[j]] = true;       }       if (flag) {         return true;       }     }     return false;   }   int main() {     n = rd();     for (int i = 1; i <= n; i++) {       a[i] = rd();       b[i] = a[i];     }     sort(b + 1, b + n + 1);     b[0] = b[1] - 1;     int cnt = 0;     for (int i = 1; i <= n; i++) {       if (b[i] != b[i - 1]) {         MP[b[i]] = ++cnt;       }     }     for (int i = 1; i <= n; i++) {       a[i] = MP[a[i]];     }     if (cnt == n) {       puts( 0 );       return 0;     }     int ans = n;     int l = 1, r = n;     while (l <= r) {       int mid = (l + r) >> 1;       if (check(mid)) {         ans = mid;         r = mid - 1;       } else {         l = mid + 1;       }     }     cout << ans << endl;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O2 )   using namespace std;   inline long long input() {     long long n;     cin >> n;     return n;   }   string base2(long long n) {     string a =   ;     while (n >= 2) {       a += (char)(n % 2 +  0 );       n /= 2;     }     a += (char)(n +  0 );     reverse((a).begin(), (a).end());     return a;   }   const int MAXN = 1e6 + 10;   const int MOD = 1e9 + 7;   const int MOD2 = 998244353;   const long long INF = 8e18;   long long pw(long long a, long long b) {     return (!b ? 1                : (b & 1 ? (a * pw(a * a % MOD, b / 2)) % MOD                         : pw(a * a % MOD, b / 2)));   }   int cnt[256], p[256];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     int q;     cin >> q;     while (q--) {       for (int i = 0; i < 256; i++) {         cnt[i] = 0;         p[i] = 0;       }       string s, s2, t;       cin >> s >> s2;       int n = (int)s.size();       for (int i = 0; i < n; i++) {         p[(int)s[i]] = i;         cnt[(int)s[i]]++;       }       for (int i = 0; i < 256; i++) {         for (int j = 0; j < cnt[i]; j++) {           t += string(1, i);         }       }       for (int i = 0; i < n; i++) {         if (s[i] != t[i]) {           swap(s[i], s[p[(int)t[i]]]);           break;         }       }       if (s >= s2) {         cout <<  ---               <<   n ;       } else {         cout << s <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100000 + 5;   int g[10][10];   int a[5];   int ans;   int cal() {     int sum = 0;     for (int i = 0; i < 5; ++i) {       for (int j = i; j < 4; j += 2) sum += g[a[j]][a[j + 1]] + g[a[j + 1]][a[j]];     }     return sum;   }   int main() {     for (int i = 0; i < 5; ++i)       for (int j = 0; j < 5; ++j) cin >> g[i][j];     for (int i = 0; i < 5; ++i) a[i] = i;     ans = -1;     do {       ans = max(ans, cal());     } while (next_permutation(a, a + 5));     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long arr[330];   set<long long> st;   map<long long, bool> mp;   int main() {     long long t, n, i, j, k, l, m;     ios_base::sync_with_stdio(0);     cin.tie(0);     long long p;     cin >> t;     while (t--) {       cin >> n;       for (i = 1; i <= n; i++) cin >> arr[i], mp[arr[i]] = 1;       sort(arr + 1, arr + n + 1);       i = 1, j = n;       while (i <= j) {         long long op = arr[i] * arr[j];         st.insert(op);         i++;         j--;       }       if (st.size() == 1) {         bool flag = 1;         long long ans = *(st.begin());         for (i = 2; i <= sqrt(ans); i++) {           if (ans % i == 0) {             if (mp.find(i) == mp.end() || mp.find(ans / i) == mp.end())               flag = false;           }         }         if (flag)           cout << *(st.begin()) <<   n ;         else           cout << -1 <<   n ;       } else         cout << -1 <<   n ;       st.clear();       mp.clear();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, s;   int even_odd[100005][2];   int visited[100005];   vector<int> ans;   vector<int> v[100005];   int dfs(int s, int p) {     if (v[s].empty() && p) {       ans.push_back(s);       return 1;     }     for (auto it : v[s]) {       if (even_odd[it][p ^ 1] == 0) {         even_odd[it][p ^ 1] = s;         if (dfs(it, p ^ 1) == 1) {           ans.push_back(s);           return 1;         }       }     }     return 0;   }   bool dfs2(int source) {     visited[source] = 1;     for (auto it : v[source])       if (visited[it] == 1 || (visited[it] == 0 && dfs2(it))) return true;     visited[source] = 2;     return false;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> m;     for (int i = 0; i < n; i++) {       int k;       cin >> k;       for (int j = 0; j < k; j++) {         int a;         cin >> a;         v[i + 1].push_back(a);       }     }     cin >> s;     if (dfs(s, 0)) {       cout <<  Win n ;       for (int i = ans.size() - 1; i >= 0; i--) cout << ans[i] <<    ;       return 0;     }     if (dfs2(s)) {       cout <<  Draw n ;       return 0;     }     cout <<  Lose n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long t;     scanf( %lld , &t);     while (t--) {       long long a, b, c, d, k;       scanf( %lld%lld%lld , &a, &b, &c);       scanf( %lld %lld , &d, &k);       long long x = (a - 1 + c) / c;       long long y = (b + d - 1) / d;       if (x + y <= k) {         printf( %lld %lld n , k - y, y);       } else {         printf( -1 n );       }     }     return 0;   }
#include <bits/stdc++.h>   int a[100010], i, j, k, n, x, y;   int main() {     while (scanf( %d , &n) == 1) {       if (n % 4 != 1 && n % 4 != 0) {         printf( -1 n );         continue;       }       if (n == 1) {         printf( 1 n );         continue;       }       if (n % 4 == 1) {         a[n / 2 + 1] = n / 2 + 1;         x = 1;         y = n;         while (y != x) {           a[x] = x + 1;           a[x + 1] = y;           a[y - 1] = x;           a[y] = y - 1;           x += 2;           y -= 2;         }       } else {         x = 1;         y = n;         while (x - 1 != y) {           a[x] = x + 1;           a[x + 1] = y;           a[y - 1] = x;           a[y] = y - 1;           x += 2;           y -= 2;         }       }       for (i = 1; i <= n - 1; i++) printf( %d  , a[i]);       printf( %d n , a[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double n, sum = 0;   int a[21], b[21];   int main() {     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i];     }     for (int i = 0; i < n; i++) {       cin >> b[i];     }     for (int i = 0; i < 1000000; i++) {       for (int j = 0; j < n; j++) {         if (i % a[j] == b[j]) {           sum++;           break;         }       }     }     printf( %.6f , (double)sum / 1000000.0);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxc = 1000000000;   int main() {     long long n, k, l, r;     scanf( %lld%lld%lld%lld , &n, &l, &r, &k);     long long d = r - l + 1;     if (l > r) {       d = n - l + 1 + r;     }     if (d == n) {       long long ans = -1;       for (long long i = 1; i * i <= k + 1; i++) {         if (k % i == 0) {           if (i >= n && i <= 2 * n) ans = max(ans, i - n);           if (k / i >= n && k / i <= 2 * n) ans = max(ans, k / i - n);         }         if ((k + 1) % i == 0) {           if (i > n && i <= 2 * n) ans = max(ans, i - n);           if ((k + 1) / i > n && (k + 1) / i <= 2 * n)             ans = max(ans, (k + 1) / i - n);         }       }       printf( %lld n , ans);       return 0;     }     if (n < 3e7) {       long long ans = -1;       for (int i = 0; i <= n; i++) {         long long res = k % (n + i);         if (res < d) continue;         if (res > 2 * d) continue;         long long u = res - d;         if (u > i) continue;         long long uu = i - u;         if (n - d < uu - 1) continue;         ans = i;       }       printf( %lld n , ans);       return 0;     }     long long best = -1;     for (int cyc = 0; cyc < 5000; cyc++) {       long long l = -1, r = 1e12;       long long lo = 0, hi = n + 1;       while (lo != hi) {         long long mid = (lo + hi) / 2;         int ok = 1;         if (k / (n + mid) > cyc) ok = 0;         long long res = k - (long long)cyc * (n + mid);         if (res > 2 * d) ok = 0;         if (res > d + mid) ok = 0;         if (ok)           hi = mid;         else           lo = mid + 1;       }       l = lo;       lo = -1, hi = n + 1;       while (lo != hi) {         long long mid = (lo + hi + 1) / 2;         int ok = 1;         if (k / (n + mid) < cyc) ok = 0;         long long res = k - (long long)cyc * (n + mid);         if (res < d) ok = 0;         long long need = max(0ll, mid - (n - d) - 1);         if (cyc == 0 && mid == 5) ( ! %lld %lld n , need, res);         if (res < d + need) ok = 0;         if (ok)           lo = mid;         else           hi = mid - 1;       }       r = lo;       if (l == n + 1 || k < (long long)cyc * n) r = -1;       ( cyc %d l %lld r %lld n , cyc, l, r);       if (l > r) continue;       best = max(best, r);       ;     }     printf( %lld n , best);   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 10;   signed main() {     int a, b, c, d, e, f;     cin >> a >> b >> c >> d >> e >> f;     int ans = 0;     if (e >= f) {       int dec = min(a, d);       a -= dec;       d -= dec;       ans += dec * e;       ans += min(min(b, c), d) * f;     } else {       int dec = min(min(b, c), d);       b -= dec, c -= dec, d -= dec;       ans += dec * f;       ans += min(a, d) * e;     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int M = 1e9 + 7;   template <class T>   T ABS(const T& x) {     return x > 0 ? x : -x;   }   long long int gcd(long long int n1, long long int n2) {     return n2 == 0 ? ABS(n1) : gcd(n2, n1 % n2);   }   long long int lcm(long long int n1, long long int n2) {     return n1 == 0 && n2 == 0 ? 0 : ABS(n1 * n2) / gcd(n1, n2);   }   long long int ceil2(long long int a, long long int b) {     return (a + b - 1) / b;   }   int n;   void divisors(vector<int>& d) {     vector<int> v;     for (int i = 1; i <= sqrt(n); ++i) {       if (n % i == 0) {         if (n / i == i) {           d.push_back(i);         } else {           d.push_back(i);           v.push_back(n / i);         }       }     }     for (int i = v.size() - 1; i >= 0; --i) {       d.push_back(v[i]);     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> n;     int arr[n];     for (int i = 0; i < (n); ++i) {       cin >> arr[i];     }     vector<int> d;     divisors(d);     bool v[n];     for (int i = d.size() - 1; i >= 0; --i) {       int size = n / d[i];       if (size < 3) continue;       memset(v, false, sizeof(v));       int k = d[i], cnt = 0;       for (int l = 0; l < n; ++l) {         int prev = (l - k + n) % n, next = (l + k) % n;         if (arr[l] && arr[prev] && arr[next]) {           v[l] = true;           cnt++;         } else {           v[l] = false;         }       }       if (cnt >= size) {         cout <<  YES n ;         return 0;       }     }     cout <<  NO n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   namespace jyy {   const int mod = 998244353, N = 600010;   const double eps = 1e-8;   inline int read() {     static int x = 0, f = 1;     x = 0, f = 1;     static char ch = getchar();     while (ch <  0  || ch >  9 ) {       (ch ==  - ) ? f *= -1 : f;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) x = x * 10 + int(ch - 48), ch = getchar();     return x * f;   }   inline void fw(int x) {     if (x < 0) putchar( - ), x = -x;     x >= 10 ? fw(x / 10), 1 : 0;     putchar(char(x % 10 + 48));   }   inline int qmo(int x) { return x + ((x >> 31) & mod); }   inline int ksm(int x, int y) {     int tmp = 1;     for (; y; y >>= 1, x = 1ll * x * x % mod)       if (y & 1) tmp = 1ll * tmp * x % mod;     return tmp;   }   inline int inv(int x) { return ksm(x, mod - 2); }   int tot, head[N], fa[N];   struct edge {     int to, next;   } dat[N * 2];   void add_edge(int x, int y) { dat[++tot] = (edge){y, head[x]}, head[x] = tot; }   inline int find(int x) { return fa[x] ? fa[x] = find(fa[x]) : x; }   inline int merge(int x, int y) {     return find(x) != find(y) ? fa[find(x)] = find(y), 0 : 1;   }   inline int low(int x) { return x & -x; }   int ifac[N], fac[N];   inline void init(int x) {     fac[0] = ifac[0] = 1;     for (int i = 1; i <= x; i++) fac[i] = 1ll * fac[i - 1] * i % mod;     ifac[x] = inv(fac[x]);     for (int i = x - 1; i >= 1; i--) ifac[i] = 1ll * ifac[i + 1] * (i + 1) % mod;   }   inline int C(int x, int y) {     return (x < y || y < 0 || x < 0)                ? 0                : 1ll * fac[x] * ifac[y] % mod * ifac[x - y] % mod;   }   }  // namespace jyy   using namespace jyy;   int pd[N], n, R[N], a[N], vis[N], dep[N], m, b[N];   char c[N];   void dfs(int x, int f) {     vis[x] = 1;     dep[x] = dep[f] + 1;     fa[x] = f;     for (int i = head[x]; i; i = dat[i].next) {       int t = dat[i].to;       if (t == f || vis[t]) continue;       dfs(t, x);     }   }   void work(int x, int y) {     deque<int> q1, q2;     while (dep[x] > dep[y]) q1.push_back(x), x = fa[x];     while (dep[x] < dep[y]) q2.push_front(y), y = fa[y];     while (x != y) q1.push_back(x), q2.push_front(y), x = fa[x], y = fa[y];     q1.push_back(x);     cout << q1.size() + q2.size() << endl;     while (q1.size()) printf( %d  , q1.front()), q1.pop_front();     while (q2.size()) printf( %d  , q2.front()), q2.pop_front();     puts(  );   }   void solve() {     n = read(), m = read();     for (int i = 1, x, y; i <= m; i++)       x = read(), y = read(), add_edge(x, y), add_edge(y, x);     dfs(1, 0);     int q = read();     for (int i = 1; i <= q; i++) {       a[i] = read(), b[i] = read();       pd[a[i]] ^= 1;       pd[b[i]] ^= 1;     }     int cnt = 0;     for (int i = 1; i <= n; i++) cnt += pd[i];     if (cnt) {       puts( NO );       cout << cnt / 2 << endl;       return;     }     puts( YES );     for (int i = 1; i <= q; i++) {       work(a[i], b[i]);     }   }   int main() {     int T = 1;     while (T--) solve();   }
#include <bits/stdc++.h>   using namespace std;   bool sortinrev(const pair<int, int> &a, const pair<int, int> &b) {     return (a.first > b.first);   }   double gcd(double a, double b) {     if (b == 0) return a;     return gcd(b, double(int(a) % int(b)));   }   long long int power(long long int b, long long int e, long long int m) {     if (e == 0) return 1;     if (e & 1) return b * power(b * b % m, e / 2, m) % m;     return power(b * b % m, e / 2, m);   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     long long int a;     cin >> a;     ;     long long int b;     cin >> b;     ;     long long int c;     cin >> c;     ;     long long int d;     cin >> d;     ;     long long int e;     cin >> e;     ;     long long int f;     cin >> f;     ;     long long int z = 0, ans = 0;     if (f >= e) {       z = min(c, d);       z = min(z, b);       ans += (f * z);       d -= z;       z = min(d, a);       ans += (e * z);     } else {       z = min(a, d);       ans += (e * z);       d -= z;       z = min(b, c);       z = min(z, d);       ans += (f * z);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long n, k, p;     cin >> n >> k >> p;     bool odd = false, even = false;     string ans =   ;     if (n % 2 == 0)       even = true;     else {       odd = true;       k--;     }     for (int i = 0; i < p; i++) {       long long tmp;       cin >> tmp;       if (even) {         if (tmp % 2 == 0 && n - 2 * k < tmp)           ans +=  X ;         else if (tmp % 2 == 1 && n - 2 * (k - n / 2) < tmp)           ans +=  X ;         else           ans +=  . ;       } else {         if (tmp == n && k >= 0) {           ans +=  X ;           continue;         }         if (tmp % 2 == 0 && n - 2 * k <= tmp)           ans +=  X ;         else if (tmp % 2 == 1 && n - 2 * (k - n / 2) <= tmp)           ans +=  X ;         else           ans +=  . ;       }     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   int n, start, x;   int order[50005];   pair<int, int> ask(int idx) {     printf( ? %d n , idx);     fflush(stdout);     int val, nxt;     scanf( %d%d , &val, &nxt);     return pair<int, int>(val, nxt);   }   int main() {     srand(time(0));     for (int i = 1; i < 50005; i++) order[i] = i;     scanf( %d%d%d , &n, &start, &x);     random_shuffle(order + 1, order + n + 1);     int ptr = start, ptr_val = INT_MIN;     for (int i = 1; i <= min(n, 1200); i++) {       pair<int, int> p = ask(order[i]);       if (p.first <= x && p.first >= ptr_val) ptr = order[i], ptr_val = p.first;     }     int ans = -1;     while (ptr != -1) {       pair<int, int> y = ask(ptr);       if (y.first >= x) {         ans = y.first;         break;       }       ptr = y.second;     }     printf( ! %d n , ans);   }
#include <bits/stdc++.h>   int main() {     long int i, j, l, i1, k = 0, c1 = 0, t, c[100000];     char a[100000], b[100000];     scanf( %s , &a);     l = strlen(a);     for (j = 0; j < l; j++) {       if (((int)a[j]) % 2 == 0) {         b[k] = a[j];         c[k] = j;         k++;       }     }     if (k == 0)       printf( -1 );     else {       for (i = 0; i < k; i++) {         if (a[l - 1] > b[i]) {           c1 = 1;           break;         }       }       if (c1 == 0) {         t = a[c[k - 1]];         a[c[k - 1]] = a[l - 1];         a[l - 1] = t;       } else if (c1 == 1) {         t = a[c[i]];         a[c[i]] = a[l - 1];         a[l - 1] = t;       }       for (i = 0; i < l; i++) {         printf( %c , a[i]);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void optIO() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);   }   const long long mod = 1e9 + 7, mod2 = 998244353, mod3 = 1e9 + 9;   long long p[5020], pp = 31, hh[5020];   long long p2[5020], pp2 = 37, hh2[5020];   int dp[5020];   bool can[5020][5020];   map<long long, bool> ms;   void solve() {     int n, a, b;     cin >> n >> a >> b;     string s;     cin >> s;     p[0] = 1;     p2[0] = 1;     for (int i = 1; i < n + 1; ++i) {       p[i] = (p[i - 1] * pp) % mod;       p2[i] = (p2[i - 1] * pp2) % mod2;       hh[i] = (hh[i - 1] + (s[i - 1] -  a  + 1) * p[i]) % mod;       hh2[i] = (hh2[i - 1] + (s[i - 1] -  a  + 1) * p2[i]) % mod2;     }     for (int j = 1; j < n + 1; ++j) {       for (int i = 1; i < n + 1; ++i) {         if (i - 2 * j < 0) continue;         long long y =             ((hh[i - j] - hh[i - 2 * j] + mod) % mod * p[n - (i - j)]) % mod;         long long y2 =             ((hh2[i - j] - hh2[i - 2 * j] + mod2) % mod2 * p2[n - (i - j)]) %             mod2;         ms[y * mod2 + y2] = 1;         long long x = ((hh[i] - hh[i - j] + mod) % mod * p[n - i]) % mod;         long long x2 = ((hh2[i] - hh2[i - j] + mod2) % mod2 * p2[n - i]) % mod2;         if (ms.find(x * mod2 + x2) != ms.end()) can[i][j] = 1;       }       ms.clear();     }     for (int i = 1; i < n + 1; ++i) {       dp[i] = dp[i - 1] + a;       for (int j = 1; j < i + 1; ++j) {         if (can[i][j]) dp[i] = min(dp[i], dp[i - j] + b);       }     }     cout << dp[n] <<   n ;   }   int main() {     optIO();     int t = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   int n, x, y, att, cnt;   using namespace std;   int main() {     cin >> n >> x >> y;     if (x > y) return cout << n, 0;     for (int i = (1); i <= (n); i++) {       cin >> att;       if (att <= x) cnt++;     }     cout << (cnt + 1) / 2;   }