func_code_string: #include <bits/stdc++.h>   using namespace std;   long long dp[100001];   bool seen[100001];   int n, q;   vector<int> v, c;   long long cal() {     long long a, b;     cin >> a >> b;     for (int i = 0; i < 100001; i++) seen[i] = false;     int c1, c2;     c1 = c2 = -1;     for (int i = 0; i < n; i++) {       long long maxV = b * v[i];       if (seen[c[i]]) {         maxV =             (((dp[c[i]] + a * v[i]) > (maxV)) ? (dp[c[i]] + a * v[i]) : (maxV));       }       if (c1 >= 0 && c1 != c[i]) {         maxV = (((dp[c1] + b * v[i]) > (maxV)) ? (dp[c1] + b * v[i]) : (maxV));       }       if (c2 >= 0 && c2 != c[i]) {         maxV = (((dp[c2] + b * v[i]) > (maxV)) ? (dp[c2] + b * v[i]) : (maxV));       }       if (!seen[c[i]]) dp[c[i]] = maxV;       seen[c[i]] = true;       dp[c[i]] = (((maxV) > (dp[c[i]])) ? (maxV) : (dp[c[i]]));       if (c1 < 0 || maxV > dp[c1]) {         c2 = c1;         c1 = c[i];       } else if (c2 < 0 || maxV > dp[c2] && c[i] != c1) {         c2 = c[i];       }     }     if (c1 >= 0) return (((dp[c1]) > (0LL)) ? (dp[c1]) : (0LL));     return 0LL;   }   int main() {     cin >> n >> q;     for (int i = 0; i < n; i++) {       int tmp;       cin >> tmp;       v.push_back(tmp);     }     for (int i = 0; i < n; i++) {       int tmp;       cin >> tmp;       c.push_back(tmp);     }     for (int i = 0; i < q; i++) cout << cal() << endl;     return 0;   }   