func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 5;   const long long inf = (1ll << 60);   int n, m, k, cnt, a, b, v[N], p[N], ta[N], tb[N], td[N], ca[N << 2], cb[N << 2],       cd[N << 2], flag[N], pa, pb, pc, pd;   long long A[N], B[N], C[N], D[N], co[N], sum, ans = inf;   int read() {     int x = 0, f = 1;     char s;     while ((s = getchar()) >  9  || s <  0 )       if (s ==  - ) f = -1;     while (s <=  9  && s >=  0 )       x = (x << 1) + (x << 3) + (s ^ 48), s = getchar();     return x * f;   }   bool cmp(const int a, const int b) { return v[a] < v[b]; }   void build(const int o, const int l, const int r) {     if (l == r) {       ca[o] = ta[l], cb[o] = tb[l], cd[o] = td[l];       return;     }     int mid = l + r >> 1;     build(o << 1, l, mid);     build(o << 1 | 1, mid + 1, r);     ca[o] = ca[o << 1 | 1];     cb[o] = cb[o << 1 | 1];     cd[o] = cd[o << 1 | 1];   }   long long query(const int o, const int l, const int r, const int need) {     if (l == r)       return A[max(need, ca[o])] + B[max(need, cb[o])] + D[cd[o]] -              co[l] * (max(need, ca[o]) + max(need, cb[o]) + cd[o] + k - need - m);     int mid = l + r >> 1;     long long t =         max(need, ca[o << 1]) + max(need, cb[o << 1]) + cd[o << 1] + k - need;     if (t >= m)       return query(o << 1, l, mid, need);     else       return query(o << 1 | 1, mid + 1, r, need);   }   int main() {     n = read(), m = read(), k = read();     for (int i = 1; i <= n; ++i) v[i] = read(), p[i] = i;     sort(p + 1, p + n + 1, cmp);     for (int i = 1; i <= n; ++i) {       if (i == 1 || co[cnt] < v[p[i]]) co[++cnt] = v[p[i]];       v[p[i]] = cnt;     }     a = read();     for (int i = 1; i <= a; ++i) b = read(), flag[b] |= 1;     a = read();     for (int i = 1; i <= a; ++i) b = read(), flag[b] |= 2;     for (int i = 1; i <= n; ++i) {       if (flag[i] == 0) D[++pd] = co[v[i]], ++td[v[i]];       if (flag[i] == 1) A[++pa] = co[v[i]], ++ta[v[i]];       if (flag[i] == 2) B[++pb] = co[v[i]], ++tb[v[i]];       if (flag[i] == 3) C[++pc] = co[v[i]];     }     sort(A + 1, A + pa + 1);     sort(B + 1, B + pb + 1);     sort(C + 1, C + pc + 1);     sort(D + 1, D + pd + 1);     for (int i = 1; i <= cnt; ++i)       ta[i] += ta[i - 1], tb[i] += tb[i - 1], td[i] += td[i - 1];     for (int i = 1; i <= pa; ++i) A[i] += A[i - 1];     for (int i = 1; i <= pb; ++i) B[i] += B[i - 1];     for (int i = 1; i <= pd; ++i) D[i] += D[i - 1];     build(1, 0, cnt);     for (int i = 0; i <= min(m, pc); ++i) {       sum += C[i];       if (min(pa, pb) >= k - i && 2 * k - 2 * i <= m - i && i + pa + pb + pd >= m)         ans = min(ans, sum + query(1, 0, cnt, k - i));     }     printf( %lld n , ans == inf ? -1 : ans);     return 0;   }   