func_code_string: #include <bits/stdc++.h>   using namespace std;   inline int ni() {     int a;     scanf( %d , &a);     return a;   }   inline double nf() {     double a;     scanf( %lf , &a);     return a;   }   template <class T>   void out(T a, T b) {     bool first = true;     for (T i = a; i != b; i++) {       if (!first) printf(   );       first = false;       cout << *i;     }     puts(  );   }   template <class T>   void outl(T a, T b) {     for (T i = a; i != b; i++) cout << *i <<   n ;   }   const int MAXN = 5010;   int gcd(int x, int y) {     while (x) {       y %= x;       swap(x, y);     }     return y;   }   int n, m;   int a[MAXN], b[MAXN], g[MAXN];   long long d[MAXN];   long long balance[MAXN], gb[MAXN];   int main() {     n = ni();     m = ni();     for (int i = 0; i < (int)(n); i++) a[i] = ni();     for (int i = 0; i < (int)(m); i++) b[i] = ni();     sort(b, b + m);     g[0] = a[0];     for (int i = 1; i < n; i++) g[i] = gcd(g[i - 1], a[i]);     for (int i = 0; i < (int)(n); i++) {       int c = a[i];       for (int j = 2; j * j <= c; j++) {         if (c % j) continue;         bool flag = binary_search(b, b + m, j);         while (c % j == 0) {           if (flag)             balance[i]--;           else             balance[i]++;           c /= j;         }       }       if (c != 1) {         bool flag = binary_search(b, b + m, c);         if (flag)           balance[i]--;         else           balance[i]++;       }     }     for (int i = 0; i < (int)(n); i++) {       int c = g[i];       for (int j = 2; j * j <= c; j++) {         if (c % j) continue;         bool flag = binary_search(b, b + m, j);         while (c % j == 0) {           if (flag)             gb[i]--;           else             gb[i]++;           c /= j;         }       }       if (c != 1) {         bool flag = binary_search(b, b + m, c);         if (flag)           gb[i]--;         else           gb[i]++;       }     }     for (int i = n - 1; i >= 0; i--) {       d[i] = -(1LL << 60);       long long sum = 0;       for (int j = i; j < n; j++) {         sum += balance[j];         d[i] = max(d[i], d[j + 1] + sum - ((j - i + 1) * 1LL) * gb[j]);       }       d[i] = max(d[i], sum);     }     cout << d[0] << endl;   }   