func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 5005;   int gcd[N];   int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }   vector<int> primes;   void Calc() {     for (int i = 2; i * i <= 1000000000; i++) {       bool is_prime = true;       for (int p : primes) {         if (p * p > i) {           break;         }         is_prime &= i % p != 0;       }       if (is_prime) {         primes.push_back(i);       }     }   }   vector<int> Factorize(int a) {     vector<int> res;     for (int p : primes) {       if (p * p > a) {         break;       }       while (a % p == 0) {         res.push_back(p);         a /= p;       }     }     if (a != 1) {       res.push_back(a);     }     return res;   }   int main() {     ios_base::sync_with_stdio(false);     Calc();     int n;     int m;     cin >> n >> m;     vector<int> a(n);     for (int i = 0; i < n; i++) {       cin >> a[i];     }     set<int> b;     for (int i = 0; i < m; i++) {       int p;       cin >> p;       b.insert(p);     }     gcd[0] = a[0];     for (int i = 1; i < n; i++) {       gcd[i] = GCD(gcd[i - 1], a[i]);     }     int res = 0;     int t = 1;     for (int i = n - 1; i >= 0; i--) {       auto factors = Factorize(gcd[i] / t);       int d = 0;       for (auto p : factors) {         d += b.count(p) ? 1 : -1;       }       if (d > 0) {         t = gcd[i];         res += d * (i + 1);       }     }     for (auto num : a) {       auto factors = Factorize(num);       int d = 0;       for (auto p : factors) {         d += b.count(p) ? -1 : 1;       }       res += d;     }     cout << res <<   n ;   }   