func_code_string: #include <bits/stdc++.h>   using namespace std;   template <class A, class B>   istream &operator>>(istream &o, pair<A, B> &p) {     o >> p.first >> p.second;     return o;   }   template <class type>   istream &operator>>(istream &o, vector<type> &v) {     for (int i = 0; i < (int)v.size(); i++) o >> v[i];     return o;   }   template <class A, class B>   ostream &operator<<(ostream &o, pair<A, B> p) {     o <<  (  << p.first <<  ,  << p.second <<  ) ;     return o;   }   template <class type>   ostream &operator<<(ostream &o, vector<type> v) {     o <<  { ;     for (int i = 0; i < (int)v.size(); i++) {       if (i > 0) o <<  , ;       o << v[i];     }     o <<  } ;     return o;   }   long long toNum(string a) {     if (a.size() == 0u) return 0;     long long ret = 0;     for (int i = (a[0] ==  - ); i < int(a.size()); i++)       ret = ret * 10 + a[i] -  0 ;     return ret * (a[0] ==  -  ? -1 : 1);   }   string toStr(long long a) {     string ret =   ;     bool sgn = a < 0;     a = a < 0 ? -a : a;     do {       ret.push_back(a % 10 +  0 );       a /= 10;     } while (a > 0);     if (sgn) ret.push_back( - );     reverse(ret.begin(), ret.end());     return ret;   }   int dp[1005][2][2];   vector<int> cost, a, b;   int countCost(int a, int t) {     switch (t) {       case 0:         return a * cost[t];       default:         return cost[t];     }   }   int solve(int n, int bs, int tr) {     if (n < 0) return 0;     if (bs == 1 && tr == 1) return 0;     int &ret = dp[n][bs][tr];     if (ret != -1) return ret;     ret = (1 << 30);     for (int i = 0; i < int(3); i++)       for (int j = 0; j < int(3); j++) {         int t = countCost(a[n] * (!bs), i) + countCost(b[n] * (!tr), j);         ret = min(ret, t + solve(n - 1, (i == 2) || bs, (j == 2) || tr));       }     return ret;   }   int main() {     ios_base::sync_with_stdio(false);     cost = vector<int>(4);     cin >> cost;     int m, n;     cin >> m >> n;     a = b = vector<int>(max(m, n));     for (int i = 0; i < int(m); i++) cin >> a[i];     for (int i = 0; i < int(n); i++) cin >> b[i];     n = max(m, n);     memset(dp, -1, sizeof(dp));     cout << min(cost[3], solve(n - 1, 0, 0));     return 0;   }   