func_code_string: #include <bits/stdc++.h>   using namespace std;   const int INF = 1e9 + 5;   const int MOD = 1e9 + 7;   void solve() {     int n, m;     cin >> n >> m;     vector<int> a(n), b(m + 1), la(m + 1);     for (int i = 0; i < n; ++i) cin >> a[i];     for (int i = 1; i < m + 1; ++i) cin >> b[i];     int mid = 0, l = 0, r = n - 1, ans = -1;     while (l <= r) {       mid = (l + r) / 2;       for (int i = 0; i < m + 1; ++i) la[i] = -1;       for (int i = 0; i < mid + 1; ++i) {         if (a[i] != 0) la[a[i]] = i;       }       int p = 0, ctr = 0;       for (int i = 0; i < mid + 1; ++i) {         if (la[a[i]] != i)           ctr++;         else if (ctr >= b[a[i]]) {           ctr -= b[a[i]];           p++;         } else           break;       }       if (p == m) {         ans = mid + 1;         r = mid - 1;       } else {         l = mid + 1;       }     }     cout << ans;   }   int main() {     int t = 1;     while (t--) solve();     return 0;   }   