func_code_string: #include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n;     cin >> n;     vector<long long> a(n);     for (long long& v : a) cin >> v;     vector<long long> p(n);     for (long long& v : p) cin >> v;     int m;     cin >> m;     vector<long long> b(m);     for (long long& v : b) cin >> v;     vector<long long> cost(m + 1);     for (int i = 0; i < n; i++) {       int j = lower_bound(b.begin(), b.end(), a[i]) - b.begin();       if (j == m)         cost[m] += p[i];       else if (p[i] < 0) {         cost[j] += p[i];       }     }     vector<long long> dp(m + 1, 1e18);     dp[0] = 0;     for (int i = 0; i < n; i++) {       int j = lower_bound(b.begin(), b.end(), a[i]) - b.begin();       if (j == m) continue;       if (b[j] == a[i]) {         long long take_cost = 0;         if (p[i] < 0) take_cost = -p[i];         dp[j + 1] = min(dp[j + 1], dp[j] + cost[j] + take_cost);       }       if (p[i] > 0) {         cost[j] += p[i];       }     }     if (dp[m] > 1e17) {       cout <<  NO  << endl;       return 0;     }     cout <<  YES  << endl;     cout << dp[m] + cost[m] << endl;   }   