func_code_string: #include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }   const int MAXVAL = 1000000;   const int MAXCNT = 200000;   const int MOD = 1000000007;   int n, want, nq;   int cnt[MAXVAL + 1];   int dv[MAXVAL + 1];   int tot[MAXVAL + 1];   int fac[MAXCNT + 1];   int inv[MAXCNT + 1];   int ifac[MAXCNT + 1];   int ans;   int C(int n, int k) {     if (k > n) return 0;     return (long long)fac[n] * ifac[k] % MOD * ifac[n - k] % MOD;   }   void inc(int x, int y) {     if (x == 1) {       ans -= (long long)tot[y] * C(cnt[y], want) % MOD;       if (ans < 0) ans += MOD;       ++cnt[y];       ans += (long long)tot[y] * C(cnt[y], want) % MOD;       if (ans >= MOD) ans -= MOD;     } else {       int t = 0, z = dv[x];       while (dv[x] == z) x /= dv[x], ++t;       for (int i = (0); i <= (t); ++i) {         inc(x, y);         y *= z;       }     }   }   void run() {     memset(dv, -1, sizeof(dv));     for (int i = (2); i <= (MAXVAL); ++i)       if (dv[i] == -1)         for (int j = i; j <= MAXVAL; j += i) dv[j] = i;     tot[1] = 1;     for (int i = (2); i <= (MAXVAL); ++i) {       int j = i / dv[i];       tot[i] = tot[j] * (dv[i] - (dv[j] != dv[i] ? 1 : 0));     }     fac[0] = 1;     for (int i = (1); i <= (MAXCNT); ++i)       fac[i] = (long long)fac[i - 1] * i % MOD;     inv[1] = 1;     for (int i = (2); i <= (MAXCNT); ++i)       inv[i] = (MOD - (long long)(MOD / i) * inv[MOD % i] % MOD) % MOD;     ifac[0] = 1;     for (int i = (1); i <= (MAXCNT); ++i)       ifac[i] = (long long)ifac[i - 1] * inv[i] % MOD;     scanf( %d%d%d , &n, &want, &nq);     ans = 0;     for (int i = (0); i < (n); ++i) {       int x;       scanf( %d , &x);       inc(x, 1);     }     for (int i = (0); i < (nq); ++i) {       int x;       scanf( %d , &x);       inc(x, 1);       printf( %d n , ans);     }   }   int main() {     run();     return 0;   }   