func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long inf = (long long)1e18;   int n, q;   int v[111111], c[111111];   long long first[111111];   long long calc(long long a, long long b) {     int m1 = 0, m2 = 0;     for (int i = 1; i <= n; ++i) first[i] = -inf;     first[0] = 0;     for (int i = 0; i < n; ++i) {       int &cc = c[i], &vv = v[i];       long long cur = b * vv;       if (first[cc] > -inf) {         cur = max(cur, first[cc] + a * vv);       }       if (m1 != cc) {         cur = max(cur, first[m1] + b * vv);       } else if (m2 != cc) {         cur = max(cur, first[m2] + b * vv);       }       if (cur > first[cc]) {         first[cc] = cur;         if (first[cc] > first[m1]) {           m2 = m1, m1 = cc;         } else if (first[cc] > first[m2] && cc != m1) {           m2 = cc;         }       }     }     return first[m1];   }   int main() {     scanf( %d%d , &n, &q);     for (int i = 0; i < n; ++i) scanf( %d , &v[i]);     for (int i = 0; i < n; ++i) scanf( %d , &c[i]);     while (q--) {       int a, b;       scanf( %d%d , &a, &b);       cout << calc((long long)a, (long long)b) << endl;     }     return 0;   }   