malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   int i, j, k, n, m, p[2001], a[2001], x[1002001][26], y[2001][26],       dp[2000][2002], dp2[2000][2002];   char t[1002001], s[2001];   int main() {     for (i = 0; i < 2000; i++)       for (j = 0; j < 2002; j++) dp[i][j] = 1e9;     scanf( %d , &n);     p[0] = 0;     for (i = 0; i < n; i++) {       scanf( %s , t + p[i]);       for (p[i + 1] = p[i]; t[p[i + 1]]; p[i + 1]++)         ;       p[i + 1]++;     }     scanf( %d , &m);     for (i = 0; i < m; i++) scanf( %d , a + i), a[i]--;     scanf( %s , s);     for (i = 0; i < n; i++) {       for (j = 0; j < 26; j++) x[p[i + 1] - 1][j] = 1e9;       for (j = p[i + 1] - 2; j >= p[i]; j--) {         memcpy(x[j], x[j + 1], sizeof(x[j]));         x[j][t[j] -  a ] = j + 1;       }     }     for (i = 0; i < 26; i++) y[m - 1][i] = 1e9;     for (i = m - 2; i >= 0; i--) {       for (j = 0; j < 26; j++) {         if (x[p[a[i + 1]]][j] != 1e9)           y[i][j] = i + 1;         else           y[i][j] = y[i + 1][j];       }     }     dp[0][0] = p[a[dp2[0][0] = 0]];     if (x[p[a[0]]][s[0] -  a ] != 1e9)       dp[0][1] = x[p[a[0]]][s[0] -  a ], dp2[0][1] = 0;     else if (y[0][s[0] -  a ] != 1e9)       dp[0][1] = x[p[a[y[0][s[0] -  a ]]]][s[0] -  a ],       dp2[0][1] = y[0][s[0] -  a ];     for (i = 1; s[i]; i++) {       dp[i][0] = p[a[dp2[i][0] = 0]];       for (j = 1; dp[i - 1][j] != 1e9; j++) {         dp[i][j] = dp[i - 1][j], dp2[i][j] = dp2[i - 1][j];         if (x[dp[i - 1][j - 1]][s[i] -  a ] != 1e9) {           if (dp2[i - 1][j - 1] < dp2[i][j] ||               dp2[i - 1][j - 1] == dp2[i][j] &&                   x[dp[i - 1][j - 1]][s[i] -  a ] < dp[i][j])             dp[i][j] = x[dp[i - 1][j - 1]][s[i] -  a ],             dp2[i][j] = dp2[i - 1][j - 1];         } else if (y[dp2[i - 1][j - 1]][s[i] -  a ] != 1e9) {           if (y[dp2[i - 1][j - 1]][s[i] -  a ] < dp2[i][j] ||               y[dp2[i - 1][j - 1]][s[i] -  a ] == dp2[i][j] &&                   x[p[a[y[dp2[i - 1][j - 1]][s[i] -  a ]]]][s[i] -  a ] <                       dp[i][j])             dp[i][j] = x[p[a[y[dp2[i - 1][j - 1]][s[i] -  a ]]]][s[i] -  a ],             dp2[i][j] = y[dp2[i - 1][j - 1]][s[i] -  a ];         }       }       if (x[dp[i - 1][j - 1]][s[i] -  a ] != 1e9)         dp[i][j] = x[dp[i - 1][j - 1]][s[i] -  a ], dp2[i][j] = dp2[i - 1][j - 1];       else if (y[dp2[i - 1][j - 1]][s[i] -  a ] != 1e9)         dp[i][j] = x[p[a[y[dp2[i - 1][j - 1]][s[i] -  a ]]]][s[i] -  a ],         dp2[i][j] = y[dp2[i - 1][j - 1]][s[i] -  a ];     }     for (k = 1; dp[i - 1][k] != 1e9; k++)       ;     printf( %d n , k - 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long freq[100001];   int dp[101];   int main() {     int h, a, p;     cin >> h >> a >> p;     int mh, ma;     cin >> mh >> ma;     vector<int> s;     while (h - ma > 0 || mh <= a) {       h -= ma;       mh -= a;       s.push_back(1);       if (mh <= 0) break;     }     while (mh > 0) {       s.push_back(0);       h += p - ma;       while (h - ma > 0 || mh <= a) {         h -= ma;         mh -= a;         s.push_back(1);         if (mh <= 0) break;       }     }     cout << s.size() << endl;     for (int i = 0; i < s.size(); i++) {       if (s[i])         cout <<  STRIKE  << endl;       else         cout <<  HEAL  << endl;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename Arg1>   void __f(const char* name, Arg1&& arg1) {     cerr << name <<   :   << arg1 << endl;   }   template <typename Arg1, typename... Args>   void __f(const char* names, Arg1&& arg1, Args&&... args) {     const char* comma = strchr(names + 1,  , );     cerr.write(names, comma - names) <<   :   << arg1 <<   |  ;     __f(comma + 1, args...);   }   typedef vector<vector<int> > VVI;   inline int mult(int x, int y) { return ((long long)x * y) % 1000000007; }   int power(int x, int y) {     int ret = 1;     while (y) {       if (y & 1) ret = mult(ret, x);       x = mult(x, x);       y = y / 2;     }     return ret;   }   int gcd(int a, int b) {     if (b) return gcd(b, a % b);     return a;   }   vector<int> prime;   void generateprime(int n) {     int i, j;     vector<int> num(n + 5);     num[1] = 1;     for (i = 4; i < n; i = i + 2) num[i] = 1;     for (i = 3; i < n; i++) {       if (num[i] == 0) {         for (j = 3 * i; j < n; j = j + 2 * i) num[j] = 1;       }     }     num[0] = 0;     for (i = 2; i < n; i++) {       if (num[i] == 0) prime.push_back(i);       num.clear();     }   }   int main() {     int count1, n, i, temp;     scanf( %d , &n);     if (n == 1) {       scanf( %d , &temp);       if (temp == 1) printf( YES n );       if (temp == 0) printf( NO n );     } else {       count1 = 0;       for (i = 0; i < n; i++) {         scanf( %d , &temp);         if (temp == 1) count1++;       }       if (count1 == n - 1)         printf( YES n );       else         printf( NO n );     }     return 0;   }
#include <bits/stdc++.h>   const int N = 1005;   int n, K;   int w[N][N];   std::vector<int> ansx, ansy;   int main() {     memset(w, -1, sizeof w);     bool f = true;     scanf( %d%d , &n, &K);     for (int i = 1; i <= n; ++i) {       int cnt = K;       for (int j = 1; j <= n && cnt > 0; ++j)         if (j != i && w[i][j] == -1) {           --cnt;           w[i][j] = 1;           w[j][i] = 0;           ansx.push_back(i);           ansy.push_back(j);         }       if (cnt != 0) {         f = false;         break;       }     }     if (!f)       puts( -1 );     else {       printf( %d n , ansx.size());       for (int i = 0; i < ansx.size(); ++i) printf( %d %d n , ansx[i], ansy[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   struct data {     int t, g;   };   int memo[250][4][66000];   int n, t;   data in[20];   int f(int time, int genre, int bit) {     if (memo[time][genre][bit] != -1) return memo[time][genre][bit];     if (time == t) return memo[time][genre][bit] = 1;     if (time > t) return memo[time][genre][bit] = 0;     int RE = 0;     for (int i = 0; i < n; i++)       if (in[i].g != genre && !(bit & (1 << i))) {         RE = (RE + f(time + in[i].t, in[i].g, bit | (1 << i))) % mod;       }     return memo[time][genre][bit] = RE;   }   int main() {     cin >> n >> t;     for (int i = 0; i < n; i++) cin >> in[i].t >> in[i].g;     memset(memo, -1, sizeof(memo));     cout << f(0, 0, 0);   }
#include <bits/stdc++.h>   using namespace std;   int go_to_hall(string maxx, string minn, int base) {     string h =   ;     int a = 0;     for (int i = minn.size() - 1, j = maxx.size() - 1; i >= 0; j--, i--) {       int q1 = minn[i] -  0 , q2 = maxx[j] -  0 ;       int q3 = q1 + q2 + a;       if (q3 >= base) {         int a1 = q3 - base;         string w;         ostringstream convert4;         convert4 << a1;         w = convert4.str();         h += w;         a = 1;       } else {         string w;         ostringstream convert5;         convert5 << q3;         w = convert5.str();         h += w;         a = 0;       }     }     if (a == 1 && maxx.size() == minn.size()) {       h +=  1 ;       return h.size();     } else {       int s = 0;       for (int r = maxx.size() - minn.size() - 1; r >= 0; r--) {         int e = s + (maxx[r] -  0 );         int x = maxx.size() - minn.size() - 1;         if (r == x) {           int y = e + a;           if (y >= base) {             int a1 = y - base;             string w;             ostringstream convert6;             convert6 << a1;             w = convert6.str();             h += w;             s = 1;           } else {             string w;             ostringstream convert7;             convert7 << y;             w = convert7.str();             h += w;             s = 0;           }         } else {           if (e >= base) {             int a1 = e - base;             string w;             ostringstream convert8;             convert8 << a1;             w = convert8.str();             h += w;             s = 1;           } else {             string w;             ostringstream convert9;             convert9 << e;             w = convert9.str();             h += w;             s = 0;           }         }       }       if (s == 1) {         h +=  1 ;       }       return h.size();     }   }   int main() {     int x, y, base = 0;     cin >> x >> y;     int k1 = x, k2 = y;     string q1;     ostringstream convert;     convert << x;     q1 = convert.str();     string q2;     ostringstream convert1;     convert1 << y;     q2 = convert1.str();     for (int y = 0; y < q1.size(); y++) {       int r = q1[y] -  0 ;       base = max(r, base);     }     for (int y = 0; y < q2.size(); y++) {       int r = q2[y] -  0 ;       base = max(r, base);     }     base++;     if (base == 10) {       int k3 = k1 + k2;       int i = 0;       while (k3 != 0) {         k3 = k3 / 10;         i++;       }       cout << i << endl;     } else {       string maxx, minn;       if (q1.size() >= q2.size()) {         maxx = q1;         minn = q2;       } else {         maxx = q2;         minn = q1;       }       cout << go_to_hall(maxx, minn, base) << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   struct BIT {     int n;     vector<T> dat;     BIT(int n = 0) { initialize(n); }     void initialize(int nin) {       n = nin;       dat.resize(n, 0);     }     T sum(int i) {       T s = 0;       while (i >= 0) {         s += dat[i];         i = (i & (i + 1)) - 1;       }       return s;     }     T sum_between(int i, int j) { return sum(j) - sum(i - 1); }     void plus(int i, T x) {       while (i < n) {         dat[i] += x;         i |= i + 1;       }     }     int lower_bound(T x) {       if (x < 0) return -1;       int ret = -1;       int k = 1;       while (2 * k <= n) k <<= 1;       for (; k > 0; k >>= 1) {         if (ret + k < n && dat[ret + k] < x) {           x -= dat[ret + k];           ret += k;         }       }       return ret + 1;     }   };   int main() {     int N, M;     cin >> N >> M;     vector<int> A(N + M), mn(N), mx(N);     for (int i = 0; i < N; i++) A[N - 1 - i] = mn[i] = mx[i] = i;     for (int i = 0; i < M; i++) {       scanf( %d , &A[i + N]);       A[i + N]--;       mn[A[i + N]] = 0;     }     M += N;     vector<vector<int>> pos(N);     for (int i = 0; i < M; i++) pos[A[i]].push_back(i);     vector<pair<int, int>> R2LI(M);     for (int i = 0; i < N; i++) {       int sz = pos[i].size();       for (int j = 0; j < sz - 1; j++) R2LI[pos[i][j + 1]] = {pos[i][j], i};     }     BIT<int> bit(M);     for (int r = N; r < M; r++) {       int l = R2LI[r].first, i = R2LI[r].second;       bit.plus(l, 1);       int res = r - l - bit.sum_between(l, r);       mx[i] = max(mx[i], res);     }     for (int i = 0; i < N; i++) {       int l = pos[i].back(), r = M - 1;       int res = r - l - bit.sum_between(l, r);       mx[i] = max(mx[i], res);     }     for (int i = 0; i < N; i++) printf( %d %d n , mn[i] + 1, mx[i] + 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 10;   const long long mo = 1e9 + 7;   const long long inf = 1e9;   const long long Inf = 1e18;   int a[N], b[N];   int main() {     int n, m, tot = 0;     scanf( %d%d , &n, &m);     int nw = 0;     for (int i = (1); i <= (m); ++i) {       scanf( %d , &a[i]);       int x = a[i];       if (x <= nw) {         b[i] = b[i - 1] + x;         nw -= x;       } else {         x -= nw;         tot += x / n;         x = x % n;         b[i] = x;         if (x)           nw = n - x, ++tot;         else           nw = 0;       }     }     sort(b + 1, b + m);     b[m] = n;     for (int i = (m); i >= (1); --i) b[i] = b[i] - b[i - 1];     printf( %d n , tot);     for (int i = (1); i <= (m); ++i) printf( %d  , b[i]);     printf(  n );     int x = 1;     for (int i = (1); i <= (m); ++i) {       while (a[i] > 0) {         a[i] -= b[x];         printf( %d  , i);         if (x == m)           x = 1, printf(  n );         else           ++x;       }     }     for (; x != 1 && x != m + 1; ++x) printf( %d  , m);   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native )   using namespace std;   const long long MOD = 1000000007;   const int INF = 1e9;   const long long LINF = 1LL * INF * INF;   const int MAXN = 100007;   const double EPS = 1e-7;   const int DX[4] = {1, 0, -1, 0}, DY[4] = {0, 1, 0, -1};   int n, m, r, k;   set<pair<int, int> > U;   priority_queue<pair<long long, pair<int, int> > > Q;   long long f(int i, int j) {     return (min(i, n - r) - max(0, i - r + 1) + 1LL) *            (min(j, m - r) - max(0, j - r + 1) + 1LL);   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     long long s = 0;     cin >> n >> m >> r >> k;     Q.push(make_pair(f(n / 2, m / 2), make_pair(n / 2, m / 2)));     U.insert(make_pair(n / 2, m / 2));     for (int j = (0); j < (k); ++j) {       s += Q.top().first;       int x = Q.top().second.first, y = Q.top().second.second;       Q.pop();       for (int i = (0); i < (4); ++i) {         if (x + DX[i] >= 0 && x + DX[i] < n && y + DY[i] >= 0 && y + DY[i] < m &&             !U.count(make_pair(x + DX[i], y + DY[i]))) {           Q.push(make_pair(f(x + DX[i], y + DY[i]),                            make_pair(x + DX[i], y + DY[i])));           U.insert(make_pair(x + DX[i], y + DY[i]));         }       }     }     cout << fixed << setprecision(12) << s / (n - r + 1.0) / (m - r + 1.0);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     scanf( %d , &n);     vector<int> a(2 * n);     for (int i = 0; i < 2 * n; i++) {       scanf( %d , &a[i]);     }     sort(a.begin(), a.end());     printf( %s n , (a[n - 1] != a[n]) ?  YES  :  NO );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, h;   long long dp[40][40];   int main() {     scanf( %d %d , &n, &h);     memset(dp, 0, sizeof(dp));     for (int i = 0; i <= n; i++) {       dp[0][i] = 1;     }     for (int h = 1; h <= n; h++) {       for (int i = 1; i <= n; i++) {         for (int j = 0; j < i; j++)           dp[i][h] += dp[j][h - 1] * dp[i - j - 1][h - 1];       }     }     printf( %I64d n , dp[n][n] - dp[n][h - 1]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int read(int f = 1, int x = 0, char ch =    ) {     while (!isdigit(ch = getchar()))       if (ch ==  - ) f = -1;     while (isdigit(ch)) x = x * 10 + ch -  0 , ch = getchar();     return f * x;   }   const int N = 1e5 + 5;   struct Edge {     int next, to;     Edge(int next = 0, int to = 0) : next(next), to(to){};   } edge[N << 1];   int tot, head[N];   void add(int x, int y) { edge[++tot] = Edge(head[x], y), head[x] = tot; }   int n, fa[N], dfn[N], t, f[N], to[N], d[N], ans;   void dfs(int x) {     dfn[++t] = x;     for (int i = head[x]; i; i = edge[i].next) {       int y = edge[i].to;       if (y == to[x]) continue;       dfs(y);     }     if (to[x]) dfs(to[x]);   }   int main() {     n = read();     for (int i = 2; i <= n; ++i) add(fa[i] = read() + 1, i), d[i] = d[fa[i]] + 1;     for (int i = n; i > 1; --i)       f[fa[i]] = max(f[fa[i]], f[i] + 1),       to[fa[i]] = f[i] >= f[to[fa[i]]] ? i : to[fa[i]];     dfs(1);     for (int i = 1; i <= n; ++i) printf( %d  , dfn[i] - 1);     puts(  );     for (int i = n; i > 1; --i) ans += d[dfn[i - 1]] - d[fa[dfn[i]]];     printf( %d n , ans);     for (int i = 2; i <= n; ++i)       for (int j = 1; j <= d[dfn[i - 1]] - d[fa[dfn[i]]]; ++j)         printf( %d  , dfn[i] - 1);     puts(  );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int binExp(long long int x, long long int n, long long int m) {     long long int res = 1;     while (n) {       if (n & 1) res = (res * x) % m;       x = (x * x) % m;       n >>= 1;     }     return res;   }   long long int modInv(long long int i, long long int m) {     return binExp(i, m - 2, m);   }   long long int add(long long int a, long long int b) {     long long int res = a + b;     if (res >= 1000000007) res -= 1000000007;     if (res < 0) res += 1000000007;     return res;   }   long long int mul(long long int a, long long int b) {     long long int res = (a) * (b);     res %= 1000000007;     if (res < 0) res += 1000000007;     return res;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int t, t1 = 1;     cin >> t;     while (t--) {       string str;       cin >> str;       int odd = 0, even = 0, oddq = 0, evenq = 0, oddt = 0, event = 0, ans = 0;       for (int i = 0; i < 10; i++) {         if (i % 2 != 0) {           event++;           if (str[i] ==  1 ) {             even++;           }           if (str[i] ==  ? ) {             evenq++;           }           int oddrem = 5 - oddt;           int evenrem = 5 - event;           if ((odd + oddq - even) > evenrem) {             ans = i + 1;             break;           }           if ((even + evenq - odd) > oddrem) {             ans = i + 1;             break;           }         } else {           oddt++;           if (str[i] ==  1 ) {             odd++;           }           if (str[i] ==  ? ) {             oddq++;           }           int oddrem = 5 - oddt;           int evenrem = 5 - event;           if ((odd + oddq - even) > evenrem) {             ans = i + 1;             break;           }           if ((even + evenq - odd) > oddrem) {             ans = i + 1;             break;           }         }       }       if (ans == 0) {         cout << 10 << endl;         continue;       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long t, k, i;     scanf( %lld %lld , &t, &k);     long long dp[100001];     dp[0] = 1;     for (i = 1; i < 100001; i++) {       dp[i] = dp[i - 1];       if (i >= k) dp[i] += dp[i - k];       dp[i] = dp[i] % 1000000007;     }     long long sum[100001];     sum[0] = dp[0];     for (i = 1; i < 100001; i++) sum[i] = (dp[i] + sum[i - 1]) % 1000000007;     while (t--) {       long long a, b;       scanf( %lld %lld , &a, &b);       printf( %lld n , (sum[b] - sum[a - 1] + 1000000007) % 1000000007);     }   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   int n;   long long p[200002], i[200002], v[200002], lvl[200002], ans;   vector<int> G[200002];   void dfs(int x, int par) {     if (par) lvl[x] = lvl[par] + 1;     for (auto it : G[x]) {       if (it == par) continue;       dfs(it, x);       ans = (ans +              2 * v[x] * (i[x] * p[it] % mod - p[x] * i[it] % mod + mod) % mod);       i[x] += p[it];       p[x] += i[it];     }     i[x]++;   }   int main() {     cin >> n;     for (int i = 1; i <= n; i++) cin >> v[i];     for (int i = 1; i < n; i++) {       int x, y;       cin >> x >> y;       G[x].push_back(y);       G[y].push_back(x);     }     dfs(1, 0);     for (int it = 1; it <= n; it++) {       if (lvl[it] % 2)         ans = (ans + 2 * v[it] *                          (i[it] * (p[1] - i[it] + 1) % mod -                           p[it] * (i[1] - p[it]) % mod + mod) %                          mod) %               mod;       else {         ans = (ans + 2 * v[it] *                          (i[it] * (i[1] - i[it] + 1) % mod -                           p[it] * (p[1] - p[it]) % mod + mod) %                          mod) %               mod;       }       ans = (ans - v[it] + mod) % mod;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N, M;   typedef struct node {     double x;     double y;     node operator-(node b) {       node ret;       ret.x = x - b.x;       ret.y = y - b.y;       return ret;     }     node operator+(node b) {       node ret;       ret.x = x + b.x;       ret.y = y + b.y;       return ret;     }     node operator/(double c) {       node ret;       ret.x = x / c;       ret.y = y / c;       return ret;     }     node operator*(double c) {       node ret;       ret.x = x * c;       ret.y = y * c;       return ret;     }   } node;   double xmul(node a, node b) { return a.x * b.y - b.x * a.y; }   void getit(double &A, double &B, double &C, node a, node b) {     double At = b.y - a.y;     double Bt = a.x - b.x;     A = -Bt;     B = At;     double x = (a.x + b.x) / 2;     double y = (a.y + b.y) / 2;     C = A * x + B * y;   }   node getcenter(node A, node B, node C) {     double A1, B1, C1;     getit(A1, B1, C1, A, B);     double A2, B2, C2;     getit(A2, B2, C2, B, C);     double det = A1 * B2 - A2 * B1;     node ret;     ret.x = (B2 * C1 - B1 * C2) / det;     ret.y = (A1 * C2 - A2 * C1) / det;     return ret;   }   bool solve(node a, node b, node c) {     node A = b * 2 - a;     node F = getcenter(A, b, c);     node G = c * 2 - F;     node E = b * 2 - F;     node D = a * 2 - E;     if (xmul(E - D, F - E) < 1e-7 || xmul(F - E, G - F) < 1e-7 ||         xmul(G - F, D - G) < 1e-7 || xmul(D - G, E - D) < 1e-7)       return false;     printf( YES n%.9lf %.9lf %.9lf %.9lf %.9lf %.9lf %.9lf %.9lf n , D.x, D.y,            E.x, E.y, F.x, F.y, G.x, G.y);     return true;   }   int main() {     int T;     scanf( %d , &T);     while (T--) {       node a, b, c;       scanf( %lf%lf%lf%lf%lf%lf , &a.x, &a.y, &b.x, &b.y, &c.x, &c.y);       if (fabs(xmul(a - c, b - c)) < 1e-7 ||           !solve(a, b, c) && !solve(a, c, b) && !solve(c, a, b) &&               !solve(c, b, a) && !solve(b, a, c) && !solve(b, c, a))         printf( NO n );     }     return 0;   }
#include <bits/stdc++.h>   template <typename T>   inline T max(T a, T b) {     return a > b ? a : b;   }   template <typename T>   inline T min(T a, T b) {     return a < b ? a : b;   }   template <typename T>   inline T abs(T a) {     return a > 0 ? a : -a;   }   template <typename T>   inline void repr(T &a, T b) {     if (a < b) a = b;   }   template <typename T>   inline void repl(T &a, T b) {     if (a > b) a = b;   }   int n, x, y, a[3001], f[3001][3001], fa[3001][3001][2], a1[3000], a2[3000], m1,       m2;   struct B {     int v, id;     bool operator<(const B &x) const { return v > x.v; }   } b[3001];   int main() {     scanf( %d%d%d , &n, &x, &y);     for (int i = 1; i <= n; i++) scanf( %d , a + i), f[0][0] += a[i];     for (int i = 1; i <= n; i++)       scanf( %d , &b[i].v), b[i].v -= a[i], b[i].id = i;     std::sort(b + 1, b + n + 1);     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         if (f[i - 1][j] - a[b[i].id] > f[i][j])           f[i][j] = f[i - 1][j] - a[b[i].id], fa[i][j][0] = i - 1,           fa[i][j][1] = j;         if (j <= y) {           if (f[i - 1][j - 1] + b[i].v > f[i][j])             f[i][j] = f[i - 1][j - 1] + b[i].v, fa[i][j][0] = i - 1,             fa[i][j][1] = j - 1;         } else {           if (f[i - 1][j - 1] > f[i][j])             f[i][j] = f[i - 1][j - 1], fa[i][j][0] = i - 1, fa[i][j][1] = j - 1;         }       }       f[i][0] = f[i - 1][0] - a[b[i].id];     }     printf( %d n , f[n][x + y]);     for (int i = n, j = x + y; j;) {       while (fa[i][j][1] == j) {         i = fa[i][j][0];       }       if (j <= y)         a2[m2++] = b[i].id;       else         a1[m1++] = b[i].id;       i = fa[i][j][0];       j--;     }     std::sort(a1, a1 + m1);     std::sort(a2, a2 + m2);     for (int i = 0; i < m1; i++) printf( %d  , a1[i]);     printf(  n );     for (int i = 0; i < m2; i++) printf( %d  , a2[i]);     printf(  n );   }