malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, c, d;     cin >> a >> b >> c >> d;     int m = max((3 * a) / 10, a - (a * c) / 250);     int v = max((3 * b) / 10, b - (b * d) / 250);     if (m > v)       cout <<  Misha  << endl;     else if (v > m)       cout <<  Vasya  << endl;     else       cout <<  Tie  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long md = 1e9 + 7;   const long long arr = 2e5;   long long a[arr], aa[arr];   long long n, d, b;   bool check(long long u) {     for (long long i = 1; i <= n; i++) a[i] = aa[i];     long long pluss = 0;     long long uu = u;     long long start = 1;     long long mid = n / 2 + n % 2;     while (1) {       if (a[start] >= b)         pluss += a[start] - b;       else if (uu)         uu--, pluss += a[start];       else         break;       start++;       if (start > mid) break;     }     long long last = start;     pluss += a[start];     for (long long i = start; i <= mid; i++) {       while (last + 1 <= min(i + i * d, n)) {         last++;         pluss += a[last];         a[last] = 0;       }       if (pluss < b) return (0);       pluss -= b;     }     for (long long i = 1; i <= n; i++) a[i] = aa[i];     reverse(a + 1, a + 1 + n);     pluss = 0;     uu = u;     start = 1;     mid = n / 2;     while (1) {       if (a[start] >= b)         pluss += a[start] - b;       else if (uu)         uu--, pluss += a[start];       else         break;       start++;       if (start > mid) break;     }     last = start;     pluss += a[start];     for (long long i = start; i <= mid; i++) {       while (last + 1 <= min(i + i * d, n)) {         last++;         pluss += a[last];         a[last] = 0;       }       if (pluss < b) return (0);       pluss -= b;     }     return (1);   }   signed main() {     cin >> n >> d >> b;     for (long long i = 1; i <= n; i++) cin >> aa[i];     long long l = 0;     long long r = n;     while (r - l > 1) {       long long d = (l + r) / 2;       if (check(d))         r = d;       else         l = d;     }     if (check(l))       cout << l;     else       cout << r;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   int main() {     cin.tie(0);     ios_base::sync_with_stdio(0);     cin >> n >> m;     int finalPos[4 * n];     memset(finalPos, -1, sizeof(finalPos));     for (int i = (2 * n) + 1, j = 0; i <= m; i++, j += 2) {       finalPos[j] = i;     }     for (int i = 1, j = 1; i <= (2 * n) && i <= m; i++, j += 2) finalPos[j] = i;     for (int i = 0; i < (4 * n); i++) {       if (finalPos[i] != -1) cout << finalPos[i] <<    ;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long double pi = 3.1415926535897932384626433832795l;   template <typename T>   inline auto sqr(T x) -> decltype(x * x) {     return x * x;   }   template <typename T>   inline T abs(T x) {     return x > T() ? x : -x;   }   template <typename T1, typename T2>   inline bool umx(T1& a, T2 b) {     if (a < b) {       a = b;       return 1;     }     return 0;   }   template <typename T1, typename T2>   inline bool umn(T1& a, T2 b) {     if (b < a) {       a = b;       return 1;     }     return 0;   }   const int N = 100100;   struct Input {     int n;     vector<pair<int, int> > a[N];     int len[N];     int num[N], w[N];     int q;     bool read() {       if (scanf( %d , &n) != 1) return 0;       for (int i = 0; i < int(n - 1); ++i) {         int u, v;         scanf( %d %d %d , &u, &v, &len[i]);         u--, v--;         a[u].push_back(make_pair(v, i));         a[v].push_back(make_pair(u, i));       }       cin >> q;       for (int i = 0; i < int(q); ++i) {         scanf( %d %d , &num[i], &w[i]);         num[i]--;       }       return 1;     }     void init(const Input& input) { *this = input; }   };   struct Data : Input {     long double ans[N];     void write() {       for (int i = 0; i < int(q); ++i) {         printf( %0.15lf n , (double)ans[i]);       }     }     virtual void solve() {}     virtual void clear() { *this = Data(); }   };   struct Solution : Data {     int sz[N];     int kol[N];     bool use[N];     int dfs(int v, int idx = -1) {       use[v] = 1;       sz[v] = 1;       for (int i = 0; i < int(a[v].size()); ++i) {         int to = a[v][i].first;         if (use[to]) continue;         sz[v] += dfs(to, a[v][i].second);       }       if (idx >= 0) kol[idx] = sz[v];       return sz[v];     }     inline long double c(int a, int b) {       if (a < b) return 0;       if (b == 0) return 1;       if (b == 1) return a;       if (b == 2) {         return (long double)a * (a - 1) / 2.0;       }       return (long double)a * (a - 1) * (a - 2) / 6.0;     }     inline long double get(int i) {       return 2.0 * (long double)kol[i] * c((n - kol[i]), 2) +              2.0 * (long double)(n - kol[i]) * c(kol[i], 2);     }     void solve() {       dfs(0);       long double res = 0;       for (int i = 0; i < int(n - 1); ++i) {         res += get(i) * len[i];       }       for (int i = 0; i < int(q); ++i) {         res -= get(num[i]) * len[num[i]];         len[num[i]] = w[i];         res += get(num[i]) * len[num[i]];         ans[i] = res / c(n, 3);       }     }     void clear() { *this = Solution(); }   };   Solution sol;   int main() {     cout.setf(ios::showpoint | ios::fixed);     cout.precision(20);     sol.read();     sol.solve();     sol.write();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline T re() {     T N = 0;     char c = getchar();     bool neg = 0;     for (; c <  0  || c >  9 ; c = getchar()) neg |= c ==  - ;     for (; c >=  0  && c <=  9 ; c = getchar()) N = (N << 3) + (N << 1) + c -  0 ;     return neg ? -N : N;   }   const int MX = 200;   const int MXPOW5 = 8000;   int n, k;   long long a[MX + 5];   int two[MX + 5], five[MX + 5];   int dp[2][MX + 5][MXPOW5 + 5];   int main() {     n = re<int>();     k = re<int>();     for (int i = 1; i <= n; i++) a[i] = re<long long>();     for (int i = 1; i <= n; i++) {       for (long long t = a[i]; t % 2 == 0; t /= 2) two[i]++;       for (long long t = a[i]; t % 5 == 0; t /= 5) five[i]++;     }     int prv = 0, now = 1;     for (int i = 0; i <= k; i++)       for (int j = 0; j <= MXPOW5; j++) dp[prv][i][j] = -0x3f3f3f3f;     dp[prv][0][0] = 0;     for (int i = 1; i <= n; i++) {       for (int j = 0; j <= k; j++)         for (int l = 0; l <= MXPOW5; l++) dp[now][j][l] = dp[prv][j][l];       for (int j = 0; j < k; j++)         for (int l = 0; l + five[i] <= MXPOW5; l++)           dp[now][j + 1][l + five[i]] =               max(dp[now][j + 1][l + five[i]], dp[prv][j][l] + two[i]);       swap(now, prv);     }     int ans = 0;     for (int i = 0; i <= MXPOW5; i++) ans = max(ans, min(i, dp[prv][k][i]));     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   int n, m, i, j, w[2001][3], v[2001], ct, a, b, c, t, tt, r[2001][3];   int min(int a, int b) {     if (a > b) return b;     return a;   }   int main() {     scanf( %d%d , &n, &m);     for (i = 0; i < m; i++) {       scanf( %d%d%d , &a, &b, &c);       w[a][0] = b, w[b][1] = a, w[a][2] = c;     }     for (i = 1; i <= n; i++) {       if (w[i][1] == 0 && w[i][0] != 0) {         v[i] = 1;         t = w[i][0];         while (w[t][0] != 0) {           w[i][0] = w[t][0];           w[i][2] = min(w[i][2], w[t][2]);           tt = w[t][0];           w[t][0] = w[t][1] = w[t][2] = 0;           t = tt;         }       }     }     for (i = 1; i <= n; i++) {       if (w[i][0] != 0 && v[i] == 1)         r[ct][0] = i, r[ct][1] = w[i][0], r[ct++][2] = w[i][2];     }     printf( %d n , ct);     for (i = 0; i < ct; i++) printf( %d %d %d n , r[i][0], r[i][1], r[i][2]);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     cin >> n >> k;     int a = 97, z = 97 + 25, t = n;     string s =   ;     for (int i = 0; i < n; i++) {       if (t >= k) {         for (int j = 0; j < k; j++) {           s += a + j;         }         i += k;         i--;         t -= k;       } else {         s += a;         a++;       }     }     cout << s << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int N;     cin >> N;     int grandN;     vector<int> result;     for (int i = 0; i < N; i++) {       vector<int> grandmas;       int temp;       int res = 1;       cin >> grandN;       for (int j = 0; j < grandN; j++) {         cin >> temp;         grandmas.push_back(temp);       }       sort(grandmas.begin(), grandmas.end());       for (int j = 0; j < grandN; j++) {         if (grandmas.at(j) <= j + 1) {           res = j + 2;         }       }       result.push_back(res);     }     for (auto i : result) {       cout << i << endl;     }     return 0;   }
#include <bits/stdc++.h>   const int N = 1010;   int n, m, k;   int i, j, d, mi, t;   int a[N], b[N];   int main() {     scanf( %d %d , &n, &m);     for (i = 0; i <= n; i++) scanf( %d , &a[i]);     for (i = 0; i <= m; i++) scanf( %d , &b[i]);     if (n > m) {       if (a[0] * b[0] > 0)         printf( Infinity );       else         printf( -Infinity );     } else if (n == m) {       int ai = ((a[0]) < 0 ? (-(a[0])) : (a[0])),           bi = ((b[0]) < 0 ? (-(b[0])) : (b[0]));       while (ai != bi)         if (ai > bi)           ai -= bi;         else           bi -= ai;       if (a[0] * b[0] > 0)         printf( %d/%d , ((a[0]) < 0 ? (-(a[0])) : (a[0])) / ai,                ((b[0]) < 0 ? (-(b[0])) : (b[0])) / ai);       else         printf( -%d/%d , ((a[0]) < 0 ? (-(a[0])) : (a[0])) / ai,                ((b[0]) < 0 ? (-(b[0])) : (b[0])) / ai);     } else       printf( 0/1 );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1000010;   int n, m, cnt, head[maxn], vis[maxn], mark[maxn], ans[maxn], tot;   struct edge {     int to, next;   } e[maxn];   inline int read() {     int x = 0, f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = (x << 1) + (x << 3) + (ch ^ 48);       ch = getchar();     }     return x * f;   }   void add(int from, int to) {     e[++cnt] = (edge){to, head[from]};     head[from] = cnt;   }   void dfs(int now, int father, int edge) {     vis[now] = 1;     vector<int> bian;     for (int i = head[now]; i; i = e[i].next) {       int to = e[i].to;       if (!vis[to]) dfs(to, now, i);     }     for (int i = head[now]; i; i = e[i].next) {       int to = e[i].to;       if (to != father && !mark[i]) {         bian.push_back(i);         mark[i] = 1;         if (i & 1)           mark[i + 1] = 1;         else           mark[i - 1] = 1;       }     }     int size = bian.size();     for (int i = 0; i < size; i++) {       if (i & 1) ans[++tot] = now;       ans[++tot] = e[bian[i]].to;     }     if (size & 1) {       if (father)         ans[++tot] = now, ans[++tot] = father, mark[edge] = 1;       else         tot--;     }   }   int main() {     n = read(), m = read();     for (int i = 1; i <= m; i++) {       int u = read(), v = read();       add(u, v), add(v, u);     }     for (int i = 1; i <= n; i++)       if (!vis[i]) dfs(i, 0, 0);     printf( %d n , tot / 3);     for (int i = 1; i <= tot; i++) {       printf( %d  , ans[i]);       if (i % 3 == 0) puts(  );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<string, string> vars;   struct proc {     string name, arg[10];     int argn;     proc(string v, bool V) {       string til =   ;       int k = 0;       for (int i = 0; i < v.length(); i++) {         if (v[i] ==  ( ) {           name = til;           til =   ;           continue;         } else if (v[i] ==  ,  || v[i] ==  ) ) {           if (V)             arg[k++] = vars[til];           else             arg[k++] = til;           til =   ;           continue;         } else           til += v[i];       }       argn = k;     }     bool operator==(proc k) {       if (name == k.name) {         if (argn == k.argn) {           for (int i = 0; i < argn; i++) {             if (arg[i] ==  T  || arg[i] == k.arg[i]) continue;             return false;           }           return true;         }       }       return false;     }   };   vector<proc> p;   string DeleteSpaces(string k) {     string ans =   ;     for (int i = 0; i < k.length(); i++)       if (k[i] !=    ) ans += k[i];     return ans;   }   int main() {     int n, m, k;     cin >> n;     for (int i = 0; i < n; i++) {       string v;       cin >> v;       getline(cin, v);       proc Pro(DeleteSpaces(v), false);       p.push_back(Pro);     }     cin >> k;     for (int i = 0; i < k; i++) {       string type, name;       cin >> type >> name;       vars[name] = type;     }     cin >> m;     cin.ignore();     for (int i = 0; i < m; i++) {       string v;       getline(cin, v);       proc Pro(DeleteSpaces(v), true);       int ans = 0;       for (int j = 0; j < p.size(); j++) {         if (p[j] == Pro) ans++;       }       cout << ans << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int a[105];   double t[105];   int main() {     int n;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i];     }     int cnt;     for (int d = -1000; d <= 1000; d++) {       if (d != 0) {         for (int i = 0; i < n; i++) {           t[i] = a[i] * 1.0 / d;         }         cnt = 0;         for (int i = 0; i < n; i++) {           if (t[i] > 0) {             cnt++;           }         }         if (cnt >= (n + 1) / 2) {           cout << d << endl;           return 0;         }       }     }     cout << 0 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long mod = 1000000007;   bool is_prime(long long n) {     if (n == 1 || n == 0) return false;     if (n == 2 || n == 3) return true;     if (n % 2 == 0 || n % 3 == 0) return false;     for (long long i = 1; (6 * i + 1) <= n; i++) {       if (6 * i + 1 == n) return true;       if (6 * i - 1 == n) return true;     }     return false;   }   unordered_set<long long> prime_till_n(long long n) {     vector<long long> arr(n + 1);     arr[0] = 0;     arr[1] = 0;     for (long long i = 2; i <= n; i++) arr[i] = (long long)1;     for (long long i = 2; i <= (n - 1) / 2; i++) {       if (arr[i] == 1) {         long long j = i;         while (i + j <= n) {           if (arr[i + j] == 1) {             arr[i + j] = 0;           }           j += i;         }       }     }     unordered_set<long long> ans;     for (long long i = 0; i <= n; i++) {       if (arr[i] == 1) ans.insert(i);     }     return ans;   }   bool is_palindrome(string s) {     string r = s;     reverse(r.begin(), r.end());     if (s.compare(r) == 0) return true;     return false;   }   bool issubstr(string s1, string s2) {     int M = s1.length();     int N = s2.length();     for (int i = 0; i <= N - M; i++) {       int j;       for (j = 0; j < M; j++)         if (s2[i + j] != s1[j]) break;       if (j == M) return true;     }     return false;   }   long long xortilln(long long n) {     if (n % 4 == 0ll) return n;     if (n % 4 == 1ll) return 1ll;     if (n % 4 == 2ll) return n + 1ll;     return 0ll;   }   void solve() {     string s;     long long n;     cin >> n;     vector<long long> v(n);     for (long long i = 0; i < n; i++) cin >> v[i];     cin >> s;     vector<long long> up, down;     for (long long i = 0; i < n; i++) {       if (s[i] ==  1 )         up.push_back(v[i]);       else         down.push_back(v[i]);     }     sort(up.begin(), up.end());     sort(down.begin(), down.end());     unordered_map<long long, long long> up2, down2;     for (int i = 0; i < down.size(); i++) down2[down[i]] = i + 1;     for (int i = 0; i < up.size(); i++) up2[up[i]] = down.size() + i + 1;     for (int i = 0; i < n; i++) {       if (s[i] ==  1 )         cout << up2[v[i]] <<    ;       else         cout << down2[v[i]] <<    ;     }     cout <<   n ;   }   int main() {     ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);     long long i = 1, t = 1;     cin >> t;     while (t--) {       solve();       i++;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int h1, m1, h2, m2, result1, result2;     char c =  : ;     while (cin >> h1 >> c >> m1 >> h2 >> c >> m2) {       if (m1 < m2) {         h1 -= 1;         m1 += 60;       }       result2 = m1 - m2;       result1 = h1 - h2;       if (result1 < 0) result1 += 24;       if (result1 == 24) result1 = 0;       cout << setw(2) << setfill( 0 ) << abs(result1) << c << setw(2)            << setfill( 0 ) << abs(result2) << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1000 + 5;   map<string, int> mat;   int fonction(string a, string b, string c) {     int x = (mat[b] - mat[a] + 12) % 12;     int y = (mat[c] - mat[b] + 12) % 12;     int z = (mat[c] - mat[a] + 12) % 12;     if (x == 4 && y == 3 && z == 7) return 1;     if (x == 3 && y == 4) return 0;     return -1;   }   int main() {     mat[ C ] = 1;     mat[ C# ] = 2;     mat[ D ] = 3;     mat[ D# ] = 4;     mat[ E ] = 5;     mat[ F ] = 6;     mat[ F# ] = 7;     mat[ G ] = 8;     mat[ G# ] = 9;     mat[ A ] = 10;     mat[ B ] = 11;     mat[ H ] = 12;     string a, b, c;     cin >> a;     cin >> b;     cin >> c;     if (fonction(a, b, c) == 1 || fonction(a, c, b) == 1 ||         fonction(b, a, c) == 1 || fonction(b, c, a) == 1 ||         fonction(c, a, b) == 1 || fonction(c, b, a) == 1)       cout <<  major ;     else if (fonction(a, b, c) == 0 || fonction(a, c, b) == 0 ||              fonction(b, a, c) == 0 || fonction(b, c, a) == 0 ||              fonction(c, a, b) == 0 || fonction(c, b, a) == 0)       cout <<  minor ;     else       cout <<  strange ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   void scanv(vector<T>& v, int n) {     v.resize(n);     for (int i = 0; i < n; i++) cin >> v[i];   }   template <typename T>   void scanvv(vector<vector<T> >& v, int n, int m) {     v.resize(n);     for (int i = 0; i < n; i++) scanv(v[i], m);   }   vector<int> p, s;   int main() {     ios_base::sync_with_stdio(false);     int cs, n, i, j;     cin >> cs;     while (cs--) {       cin >> n;       scanv(p, n);       s.clear();       s.emplace_back(p[0]);       for (i = 1; i < n; i++) {         if (p[i] < p[i - 1]) {           j = i + 1;           while (j < n && p[j] < p[j - 1]) j++;           s.emplace_back(p[j - 1]);           i = j - 1;         } else {           j = i + 1;           while (j < n && p[j] > p[j - 1]) j++;           s.emplace_back(p[j - 1]);           i = j - 1;         }       }       cout << s.size() <<   n ;       for (i = 0; i < s.size(); i++) {         if (i) cout <<    ;         cout << s[i];       }       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, s[7];   long long lin[100005][1 << 7], cov[1 << 7];   char ch[100005], ans[100005];   vector<long long> e[100005];   bool hall(long long x) {     for (long long ss = 0; ss <= (1 << 6) - 1; ss++) {       long long sum = 0;       for (long long i = 1; i <= 6; i++)         if (ss >> i - 1 & 1) sum += s[i];       if (lin[x][ss] < sum) return 0;     }     return 1;   }   signed main() {     scanf( %s , ch + 1);     n = strlen(ch + 1);     for (long long i = 1; i <= n; i++) s[ch[i] -  a  + 1]++;     cin >> m;     for (long long i = 1, p; i <= m; i++) {       string pat;       cin >> p >> pat;       for (long long j = 0; j < pat.length(); j++)         e[p].push_back(pat[j] -  a  + 1), cov[p] |= 1 << pat[j] -  a ;     }     for (long long i = 1; i <= n; i++)       if (e[i].size() == 0) {         cov[i] = (1 << 6) - 1;         for (long long j = 1; j <= 6; j++) e[i].push_back(j);       }     for (long long i = n; i >= 1; i--) {       for (long long s = 0; s <= (1 << 6) - 1; s++)         if (s & cov[i])           lin[i][s] = lin[i + 1][s] + 1;         else           lin[i][s] = lin[i + 1][s];     }     for (long long i = 1; i <= n; i++) {       sort(e[i].begin(), e[i].end());       for (long long j = 0; j < e[i].size(); j++) {         s[e[i][j]]--;         if (hall(i + 1)) {           ans[i] = (char)(e[i][j] +  a  - 1);           break;         }         s[e[i][j]]++;       }     }     if (strlen(ans + 1) < n) return puts( Impossible ), 0;     for (long long i = 1; i <= n; i++) cout << ans[i];     return puts(  ), 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       int ans = INT_MAX;       for (int i = 0; i * i <= n; i++) {         ans = min(ans, i + (n + i) / (i + 1));       }       cout << ans - 1 <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   const int MAX_N = (int)5e5 + 4, MAX_M = (int)1e7 + 4;   const double eps = 1e-6;   const int mod = (int)1e9 + 7;   using namespace std;   int n;   int a[MAX_N];   bool pr[MAX_M];   int lp[MAX_M], mu[MAX_M];   inline void sieve() {     for (int i = 2; i < MAX_M; i++) {       if (pr[i]) continue;       lp[i] = i;       if (1ll * i * i < MAX_M)         for (int j = i * i; j < MAX_M; j += i)           if (!pr[j]) pr[j] = 1, lp[j] = i;     }     mu[1] = 1;     for (int i = 2; i < MAX_M; i++) {       if (i == lp[i])         mu[i] = -1;       else if (!mu[i / lp[i]] || lp[i] == lp[i / lp[i]])         mu[i] = 0;       else         mu[i] = (-1) * mu[i / lp[i]];     }   }   vector<int> add;   vector<pair<int, int> > first;   void rec(int v, int id, int now, vector<int> &add) {     if (v == int((first).size())) {       add.push_back(now);       return;     }     rec(v + 1, id, now, add);     for (int i = 1; i <= first[v].second; i++) {       now *= first[v].first;       rec(v + 1, id, now, add);     }   }   inline void fact(int id, int x) {     first.clear();     while (x > 1) {       if (first.empty() || first.back().first != lp[x])         first.push_back(make_pair(lp[x], 1));       else         first.back().second++;       x /= lp[x];     }     add.clear();     rec(0, id, 1, add);   }   int cnt[MAX_M], all;   unordered_set<int> q;   int ans;   int two[MAX_N];   inline int calc(int id) {     fact(id, a[id]);     int nw = all;     for (auto i : add) {       nw = (nw - mu[i] * two[cnt[i] - 1]) % mod;       if (nw < 0) nw += mod;     }     nw = two[n - 1] - 1 - nw;     if (nw < 0) nw += mod;     for (auto i : add) {       if (i == 1) continue;       nw = (nw + mu[i] * (two[cnt[i] - 1] - 1)) % mod;       if (nw < 0) nw += mod;     }     return nw;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     sieve();     for (int i = 1; i <= n; i++) {       fact(i, a[i]);       for (auto j : add) cnt[j]++, q.insert(j);     }     two[0] = 1;     for (int i = 1; i <= n; i++) two[i] = 2ll * two[i - 1] % mod;     for (auto i : q) {       all = (all + mu[i] * (two[cnt[i]] - 1)) % mod;       if (all < 0) all += mod;     }     for (int i = 1; i <= n; i++) ans = (ans + calc(i)) % mod;     printf( %d n , ans);     return 0;   }