func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long MAXN = 5e5 + 5;   bool vis[MAXN];   long long sp[MAXN];   long long f[MAXN];   bool is[MAXN];   long long ar[MAXN];   long long POWER[25];   long long F[25];   void sieve() {     for (long long i = 0; i < MAXN; i++) vis[i] = false, sp[i] = 2;     for (long long i = 3; i < MAXN; i += 2) {       if (!vis[i]) {         sp[i] = i;         for (long long j = i * i; j < MAXN; j += 2 * i) {           vis[j] = true;           sp[j] = i;         }       }     }   }   int main() {     long long n, q;     cin >> n >> q;     for (long long i = 1; i <= n; i++) scanf( %lld , &ar[i]);     sieve();     long long added = 0;     POWER[0] = 1;     for (long long i = 1; i < 15; i++) POWER[i] = POWER[i - 1] << 1;     long long ans = 0;     while (q--) {       long long x;       long long temp = 0;       scanf( %lld , &x);       long long cc = 0;       long long val = ar[x];       while (val != 1) {         long long div = sp[val];         F[cc++] = div;         while (val % div == 0) val /= div;       }       for (long long i = 1; i < POWER[cc]; i++) {         long long p = 1;         long long counter = 0;         for (long long j = 0; j < cc; j++)           if (POWER[j] & i) counter++, p *= F[j];         if (counter & 1)           temp += f[p];         else           temp -= f[p];       }       if (is[x]) {         ans -= added - temp;         if (ar[x] == 1) ans++;         is[x] = false;         for (long long i = 1; i < POWER[cc]; i++) {           long long p = 1;           for (long long j = 0; j < cc; j++)             if (POWER[j] & i) p *= F[j];           f[p]--;         }         added--;       } else {         ans += added - temp;         is[x] = true;         for (long long i = 1; i < POWER[cc]; i++) {           long long p = 1;           for (long long j = 0; j < cc; j++)             if (POWER[j] & i) p *= F[j];           f[p]++;         }         added++;       }       printf( %lld n , ans);     }     return 0;   }   