func_code_string: #include <bits/stdc++.h>   using namespace std;   int arr[500005], brr[500005];   vector<int> vv[500005], ans;   int Now[500005];   int total[500005];   int tree[500005 * 4];   void update(int node, int b, int e, int i, int v) {     if (i < b || i > e) return;     if (b == e && b == i) {       tree[node] = v;       return;     }     int left = 2 * node, right = left + 1, mid = (b + e) / 2;     update(left, b, mid, i, v);     update(right, mid + 1, e, i, v);     tree[node] = tree[left] + tree[right];   }   int query(int node, int b, int e, int v) {     if (b == e) return b;     int left = 2 * node, right = left + 1, mid = (b + e) / 2;     int ret;     if (tree[left] >= v)       ret = query(left, b, mid, v);     else       ret = query(right, mid + 1, e, v - tree[left]);     return ret;   }   int main() {     int n, k, m, s;     scanf( %d %d %d %d , &n, &k, &m, &s);     for (int i = 1; i <= n; i++) {       scanf( %d , &arr[i]);       vv[arr[i]].push_back(i);     }     for (int i = 1; i <= s; i++) {       int x;       scanf( %d , &x);       brr[x]++;     }     if (k < s) {       cout <<  -1 ;       return 0;     }     for (int i = 1; i <= n; i++) {       if (total[arr[i]] == brr[arr[i]]) continue;       Now[arr[i]] = i;       update(1, 1, n, i, 1);       total[arr[i]]++;     }     if (tree[1] < s) {       cout <<  -1 ;       return 0;     }     bool flag = 0;     int id = 0, id2 = 0;     for (int i = 1; i <= n; i++) {       int pp = query(1, 1, n, s);       int z = 0;       z = i / k;       if (i % k == 0) z--;       int ppp = max(pp, i + k - 1);       z++;       z += ((n - ppp) / k);       if (z >= m) {         flag = 1;         id = i;         id2 = pp;         break;       }       update(1, 1, n, i, 0);       int idd = upper_bound(vv[arr[i]].begin(), vv[arr[i]].end(), Now[arr[i]]) -                 vv[arr[i]].begin();       if (idd == vv[arr[i]].size() && brr[arr[i]]) break;       if (brr[arr[i]]) {         update(1, 1, n, vv[arr[i]][idd], 1);         Now[arr[i]] = vv[arr[i]][idd];       }     }     if (flag == 0) {       printf( -1 n );     } else {       for (int i = 1; i <= 500000; i++) total[i] = 0;       for (int i = 1; i < id; i++) {         if ((id - i) % k)           ans.push_back(i);         else           break;       }       if (id2 - id + 1 > k) {         int tt = id2 - id + 1;         for (int i = id; i <= id2 && tt > k; i++) {           if (total[arr[i]] >= brr[arr[i]]) {             tt--;             ans.push_back(i);           } else             total[arr[i]]++;         }       }       printf( %d n , ans.size());       for (int i = 0; i < ans.size(); i++) printf( %d  , ans[i]);     }   }   