func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 5e5 + 5;   const int inf = 1e9 + 5e5 + 19;   int n, k;   int a[maxn];   bool in_b[maxn];   struct fenwick {     int n;     vector<int> val;     void init(int _n) {       n = _n;       val.assign(n + 5, -1);     }     void update(int x, int k) {       for (; x <= n; x += x & -x) val[x] = max(val[x], k);     }     int get(int x) {       int res = -1;       for (; x > 0; x -= x & -x) res = max(res, val[x]);       return res;     }   } tree;   void read_input() {     cin >> n >> k;     for (int i = 1; i <= n; ++i) cin >> a[i];     for (; k > 0; --k) {       int x;       cin >> x;       in_b[x] = true;     }     in_b[0] = in_b[n + 1] = true;     a[0] = -inf;     a[n + 1] = inf;   }   int calc(const vector<int>& arr, int L, int R) {     if ((int)arr.size() == 0) return 0;     vector<int> vals;     for (int i = 0; i < (int)arr.size(); ++i) vals.push_back(arr[i] - i);     sort(vals.begin(), vals.end());     vals.erase(unique(vals.begin(), vals.end()), vals.end());     tree.init((int)vals.size());     int max_val = 0;     for (int i = 0; i < (int)arr.size(); ++i) {       if (arr[i] <= L || arr[i] >= R) continue;       if (arr[i] - L - 1 >= i && R - arr[i] - 1 >= (int)arr.size() - i - 1) {         int val = 1;         int p =             lower_bound(vals.begin(), vals.end(), arr[i] - i) - vals.begin() + 1;         val = max(val, tree.get(p) + 1);         tree.update(p, val);         max_val = max(max_val, val);       }     }     return (int)arr.size() - max_val;   }   void solve() {     int ans = 0;     for (int i = 0; i <= n;) {       int j = i + 1;       while (j <= n && !in_b[j]) ++j;       int L = a[i], R = a[j];       if (R - L < j - i) {         cout <<  -1 n ;         return;       }       vector<int> arr;       ++i;       for (; i < j; ++i) arr.push_back(a[i]);       ans += calc(arr, L, R);     }     cout << ans <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     read_input();     solve();   }   