malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   const int N = 2e5L + 11, M = N * 2;   int a[M], b[M], c[M];   int back[M];   struct SegTree {     ll flag[N * 8];     ll val[N * 4];     void push(int x) {       val[x] += flag[x];       flag[2 * x] += flag[x];       flag[2 * x + 1] += flag[x];       flag[x] = 0;     }     void change(int l, int r, int ql, int qr, int c, int x = 1) {       push(x);       if (ql == l && qr == r) {         flag[x] = c;         push(x);       } else {         if (qr <= (l + r) / 2) {           change(l, (l + r) / 2, ql, qr, c, 2 * x);           push(2 * x + 1);         } else if (ql >= (l + r) / 2) {           push(2 * x);           change((l + r) / 2, r, ql, qr, c, 2 * x + 1);         } else {           change(l, (l + r) / 2, ql, (l + r) / 2, c, 2 * x);           change((l + r) / 2, r, (l + r) / 2, qr, c, 2 * x + 1);         }         val[x] = min(val[2 * x], val[2 * x + 1]);       }     }     ll query(int l, int r, int ql, int qr, int x = 1) {       push(x);       if (ql == l && qr == r) return val[x];       if (qr <= (l + r) / 2)         return query(l, (l + r) / 2, ql, qr, 2 * x);       else if (ql >= (l + r) / 2)         return query((l + r) / 2, r, ql, qr, 2 * x + 1);       else         return min(query(l, (l + r) / 2, ql, (l + r) / 2, 2 * x),                    query((l + r) / 2, r, (l + r) / 2, qr, 2 * x + 1));     }   } st;   vector<int> e[N];   int cnt = 0;   int in[N], out[N], id[N];   void dfs(int x) {     id[x] = ++cnt;     in[x] = cnt;     for (int i : e[x]) dfs(i);     out[x] = cnt;   }   int n;   ll query(int x) { return st.query(1, n + 1, id[x], id[x] + 1) - back[x]; }   int main() {     int q;     cin >> n >> q;     for (int i = 1; i <= 2 * n - 2; i++) {       scanf( %d%d%d , a + i, b + i, c + i);       if (i <= n - 1)         e[a[i]].push_back(b[i]);       else         back[a[i]] = c[i];     }     dfs(1);     for (int i = 1; i <= n - 1; i++)       st.change(1, n + 1, in[b[i]], out[b[i]] + 1, c[i]);     for (int i = 2; i <= n; i++) st.change(1, n + 1, id[i], id[i] + 1, back[i]);     while (q--) {       int t, u, v;       scanf( %d%d%d , &t, &u, &v);       if (t == 1) {         int i = u, w = v;         if (i <= n - 1) {           st.change(1, n + 1, in[b[i]], out[b[i]] + 1, w - c[i]);           c[i] = w;         } else {           st.change(1, n + 1, id[a[i]], id[a[i]] + 1, w - c[i]);           back[a[i]] = w;           c[i] = w;         }       } else {         ll ans = st.query(1, n + 1, in[u], out[u] + 1) - query(u) + query(v);         if (id[v] >= in[u] && id[v] <= out[u])           ans = min(ans, query(v) - query(u));         printf( %lld n , ans);       }     }   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 2e5 + 30, Mod = 1e9 + 7;   const long long SQ = 330;   map<long long, vector<long long> > mp;   pair<long long, long long> E[N];   long long p[N], sz[N], M[N], cnt[N];   vector<long long> G[N];   long long r[N], ans[N];   void DFS(long long v, long long R) {     cnt[v] = sz[v];     M[v] = 1;     r[v] = R;     for (auto u : G[v]) {       if (!M[u]) {         DFS(u, R);         cnt[v] += cnt[u];       }     }   }   long long get(long long x) { return (p[x] ? p[x] = get(p[x]) : x); }   void add(long long x, long long y) {     x = get(x);     y = get(y);     if (x == y) return;     if (rand() % 2) swap(x, y);     p[x] = y;     sz[y] += sz[x];   }   int main() {     ios::sync_with_stdio(0), cin.tie(0);     long long n;     cin >> n;     fill(sz, sz + N, 1);     for (int i = 1; i < n; i++) {       long long v, u, w;       cin >> v >> u >> w;       mp[w].push_back(i);       E[i] = {v, u};     }     for (auto R : mp) {       vector<long long> V = R.second;       set<long long> second;       for (auto x : V) {         second.insert(get(E[x].first));         second.insert(get(E[x].second));       }       for (auto x : second) G[x].clear(), M[x] = false, cnt[x] = 0;       for (auto x : V) {         G[get(E[x].first)].push_back(get(E[x].second));         G[get(E[x].second)].push_back(get(E[x].first));       }       for (auto u : second)         if (!M[u]) DFS(u, u);       for (auto x : V) {         long long v = E[x].first, u = E[x].second;         v = get(v);         u = get(u);         if (cnt[v] > cnt[u]) swap(v, u);         ans[x] = cnt[v] * (cnt[r[v]] - cnt[v]);       }       for (auto x : V) add(E[x].first, E[x].second);     }     long long mx = 0;     for (int i = 1; i < n; i++) mx = max(mx, ans[i]);     long long C = 0;     for (int i = 1; i < n; i++)       if (ans[i] == mx) C++;     cout << 2 * mx <<     << C <<   n ;     for (int i = 1; i < n; i++)       if (ans[i] == mx) cout << i <<    ;     return (0);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, l = 0, r = 0;     cin >> n;     for (int i = 0; i < n; i++) {       bool a, b;       cin >> a >> b;       l += a;       r += b;     }     int left = 2 * l > n ? (n - l) : l;     int right = 2 * r > n ? (n - r) : r;     int count = left + right;     cout << count;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7, NMAX = 100010;   int N, M;   int color[NMAX];   vector<int> Left[NMAX], Right[NMAX];   void DFS(int node, int current_color) {     if (color[node] && color[node] != current_color) {       cout <<  0 n ;       exit(0);     }     if (color[node] == 0) {       color[node] = current_color;       for (int i = 0; i < int(Left[node].size()); ++i)         DFS(Left[node][i], current_color);       for (int i = 0; i < int(Right[node].size()); ++i)         DFS(Right[node][i], 3 - current_color);     }   }   int FastExponentiation(int exponent) {     int base = 2, ret = 1;     while (exponent) {       if (exponent & 1) ret = (int64_t(ret) * base) % MOD;       base = (int64_t(base) * base) % MOD;       exponent >>= 1;     }     return ret;   }   int main() {     ios_base::sync_with_stdio(false);     int i, x, y, c;     cin >> N >> M;     while (M--) {       cin >> x >> y >> c;       c == 1 ? (Left[x].push_back(y), Left[y].push_back(x))              : (Right[x].push_back(y), Right[y].push_back(x));     }     int components = 0;     for (i = 1; i <= N; ++i) {       if (color[i]) continue;       DFS(i, 1);       ++components;     }     cout << FastExponentiation(components - 1) <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n = 0, m = 0;   char** values;   bool** values1;   void PrintArray() {     cout <<  Values n ;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         cout << values[i][j] <<    ;       }       cout << endl;     }     cout <<  Values1 n ;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         cout << values1[i][j] <<    ;       }       cout << endl;     }   }   void Check(int i, int j) {     char valueToCheck = values[i][j];     if (i == n - 1) goto second;     for (int i1 = i + 1; i1 < n; i1++) {       if (valueToCheck == values[i1][j]) {         values1[i][j] = true;         values1[i1][j] = true;       }     }   second:     if (j == m - 1) return;     for (int j1 = j + 1; j1 < m; j1++) {       if (valueToCheck == values[i][j1]) {         values1[i][j] = true;         values1[i][j1] = true;       }     }   }   void ConstructString() {     string result =   ;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (values1[i][j] != true) result += values[i][j];       }     }     cout << result;   }   int main() {     string str, temp;     cin >> n >> m;     values = new char*[n + 1];     values1 = new bool*[n + 1];     for (int i = 0; i < n; i++) {       values[i] = new char[m + 1];       values1[i] = new bool[m + 1];       memset(values1[i], 0, m + 1);       cin >> values[i];     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (values[i][j] ==  * ) continue;         Check(i, j);       }     }     ConstructString();     for (int i = 0; i < n; ++i) {       delete[] values[i];       delete[] values1[i];     }     delete[] values;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int Imx = 2147483647;   const long long Lbig = 2e18;   const int mod = 1e9 + 7;   struct fastio {     char s[100000];     int it, len;     fastio() { it = len = 0; }     inline char get() {       if (it < len) return s[it++];       it = 0;       len = fread(s, 1, 100000, stdin);       if (len == 0)         return EOF;       else         return s[it++];     }     bool notend() {       char c = get();       while (c ==     || c ==   n ) c = get();       if (it > 0) it--;       return c != EOF;     }   } _buff;   inline long long getnum() {     long long r = 0;     bool ng = 0;     char c;     c = _buff.get();     while (c !=  -  && (c <  0  || c >  9 )) c = _buff.get();     if (c ==  - ) ng = 1, c = _buff.get();     while (c >=  0  && c <=  9 ) r = r * 10 + c -  0 , c = _buff.get();     return ng ? -r : r;   }   template <class T>   inline void putnum(T x) {     if (x < 0) putchar( - ), x = -x;     register short a[20] = {}, sz = 0;     while (x) a[sz++] = x % 10, x /= 10;     if (sz == 0) putchar( 0 );     for (int i = sz - 1; i >= 0; i--) putchar( 0  + a[i]);   }   inline char getreal() {     char c = _buff.get();     while (c <= 32) c = _buff.get();     return c;   }   long long qpow(long long x, long long k) {     return k == 0 ? 1                   : 1ll * qpow(1ll * x * x % mod, k >> 1) * (k & 1 ? x : 1) % mod;   }   char s[100111];   bitset<100005> ch[26], A, all;   char t[100111];   int main() {     scanf( %s , s);     int n = strlen(s);     for (int i = 0; i < n; i++) ch[s[i] -  a ][i] = 1, all[i] = 1;     int q;     scanf( %d , &q);     while (q--) {       int op, x;       scanf( %d%d , &op, &x);       x--;       if (op == 1) {         char c = getchar();         while (c <  a  || c >  z ) c = getchar();         ch[s[x] -  a ][x] = 0;         s[x] = c;         ch[s[x] -  a ][x] = 1;       } else {         int y;         scanf( %d , &y);         y--;         scanf( %s , t);         int l = strlen(t);         A = (all >> (n - (y - x + 1) + l - 1)) << x;         for (int i = 0; i < l; i++) A = (A & ch[t[i] -  a ]) << 1;         printf( %d n , A.count());       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int dig(long long int n) {     long long int r = 0;     while (n) {       ++r;       n = n / 10;     }     return (r - 1);   }   long long int func(long long int n) {     if (n <= 9) return (n + 1);     long long int lt = dig(n);     lt = pow(10, lt);     long long int ret = lt - 1;     long long int mul = ret / 10;     long long int mid = (n % lt) / 10;     lt = n / lt;     long long int rt = n % 10;     if (rt >= lt) {       return (lt * (mul + 1) + func(ret));     } else {       return (lt * (mul + 1) + func(ret));     }   }   long long int fun(long long int n) {     if (n <= 9) return (n + 1);     long long int lt = dig(n);     lt = pow(10, lt);     long long int ret = lt - 1;     long long int mul = ret / 10;     long long int mid = (n % lt) / 10;     lt = n / lt;     long long int rt = n % 10;     if (rt >= lt) {       return ((mid + 1) + (lt - 1) * (mul + 1) + func(ret));     } else {       return (mid + (lt - 1) * (mul + 1) + func(ret));     }   }   int main() {     long long int l, r;     cin >> l >> r;     cout << fun(r) - fun(l - 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double inf = 1e14;   const double pi = acos(-1);   const double eps = 1e-10;   const int maxn = 25010;   int n, x[maxn], y[maxn], dx[maxn], dy[maxn], s[maxn];   double ans = inf, ddx[maxn], ddy[maxn], K[maxn], B[maxn];   inline double solve(int a, int b) {     double b1, k1, b2, k2;     k1 = K[a];     b1 = B[a];     k2 = K[b];     b2 = B[b];     if (k1 == k2) {       double kk =           sqrt((x[a] - x[b]) * (x[a] - x[b]) + (y[a] - y[b]) * (y[a] - y[b]));       double X, Y, XX, YY, t;       t = kk / double(s[a] + s[b]);       X = (double)x[a] + (double)ddx[a] * t * s[a];       Y = (double)y[a] + (double)ddy[a] * t * s[a];       XX = (double)x[b] + (double)ddx[b] * t * s[b];       YY = (double)y[b] + (double)ddy[b] * t * s[b];       if (abs(X - XX) <= eps && abs(Y - YY) <= eps) return t;       if (s[a] == s[b]) return inf;       t = kk / double(s[a]);       X = (double)x[a] + (double)ddx[a] * t * s[a];       Y = (double)y[a] + (double)ddy[a] * t * s[a];       if (abs(X - x[b]) <= eps && abs(Y - y[b]) <= eps) return t;       t = kk / double(s[b]);       X = (double)x[b] + (double)ddx[b] * t * s[b];       Y = (double)y[b] + (double)ddy[b] * t * s[b];       if (abs(X - x[a]) <= eps && abs(Y - y[a]) <= eps) return t;       return inf;     }     double X = (b2 - b1) / (k1 - k2), Y;     Y = k1 * X + b1;     if ((Y - y[a]) * dy[a] < 0) return inf;     if ((Y - y[b]) * dy[b] < 0) return inf;     if ((X - x[a]) * dx[a] < 0) return inf;     if ((X - x[b]) * dx[b] < 0) return inf;     double now1 = sqrt((X - x[a]) * (X - x[a]) + (Y - y[a]) * (Y - y[a])) / s[a];     double now2 = sqrt((X - x[b]) * (X - x[b]) + (Y - y[b]) * (Y - y[b])) / s[b];     return max(now1, now2);   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i) {       scanf( %d%d%d%d%d , &x[i], &y[i], &dx[i], &dy[i], &s[i]);       double v = sqrt(dx[i] * dx[i] + dy[i] * dy[i]);       ddx[i] = dx[i] / v;       ddy[i] = dy[i] / v;       K[i] = (double)dy[i] / dx[i];       B[i] = y[i] - (double)dy[i] / dx[i] * x[i];     }     for (int i = 1; i <= n; ++i)       for (int j = i + 1; j <= n; ++j) {         ans = min(ans, solve(i, j));       }     if (ans > 1e12)       printf( No show :( n );     else       printf( %.15f n , ans);     return 0;   }
#include<iostream>   typedef long long ll;   using namespace std;      const int maxn =1e5+5;   int n,q;   ll sum[maxn];   string s;      int main() {       cin>>n>>q;       cin>>s;       s =  # +s;       for(int i=1;i<=n;i++) sum[i] = sum[i-1]+s[i]- a +1;       while (q--) {           int l,r;           cin>>l>>r;           cout<<sum[r]-sum[l-1]<<endl;       }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, a[100010];   int la, ra;   void update(int i, int delta) {     for (; i < n; i = i | (i + 1)) {       a[i] += delta;     }   }   int get(int fr, int to) {     int res = 0;     for (int i = to; i >= 0; i = (i & (i + 1)) - 1) {       res += a[i];     }     for (int i = fr - 1; i >= 0; i = (i & (i + 1)) - 1) {       res -= a[i];     }     return res;   }   int main(void) {     int q;     scanf( %d%d , &n, &q);     for (int i = 0; i < n; ++i) {       update(i, 1);     }     int la = 0;     int ra = n;     for (int i = 0; i < q; ++i) {       int t;       scanf( %d , &t);       if (t == 1) {         int p, len, mid;         scanf( %d , &p);         if (la < ra) {           len = ra - la;           mid = la + p;         } else {           len = la - ra;           mid = la - p;         }         if (p > len / 2) {           swap(la, ra);           p = len - p;         }         if (la < ra) {           for (int i = 0; i < p; ++i) {             update(mid + i, get(mid - 1 - i, mid - 1 - i));           }         } else {           for (int i = 0; i < p; ++i) {             update(mid - 1 - i, get(mid + i, mid + i));           }         }         la = mid;       } else {         int l, r;         scanf( %d%d , &l, &r);         if (la < ra) {           l += la;           r += la;         } else {           l = la - l;           r = la - r;           swap(l, r);         }         printf( %d n , get(l, r - 1));       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const short maxn = 5000 + 5;   const int mod = 1000000000 + 7;   int n;   short x[maxn], y[maxn];   short d[maxn][maxn];   short md;   char col[maxn];   void dfs(int x) {     for (int i = 0, _n = (int)(n); i < _n; i++)       if (d[x][i] > md) {         if (col[x] == col[i]) throw 0;         if (col[i]) continue;         col[i] = 3 - col[x];         dfs(i);       }   }   int cnt() {     memset(col, 0, sizeof col);     int r = 1;     for (int i = 0, _n = (int)(n); i < _n; i++)       if (col[i] == 0) {         col[i] = 1;         try {           dfs(i);         } catch (...) {           return 0;         }         (r += r) >= mod ? r -= mod : 0;       }     return r;   }   int main() {     ios::sync_with_stdio(false);     cin >> n;     for (int i = 0, _n = (int)(n); i < _n; i++) cin >> x[i] >> y[i];     for (int i = 0, _n = (int)(n); i < _n; i++)       for (int j = (int)(i + 1), _n = (int)(n); j < _n; j++)         d[i][j] = d[j][i] = abs(x[i] - x[j]) + abs(y[i] - y[j]);     short lo = -1, hi = 10000;     while (lo + 1 < hi) {       md = (lo + hi) / 2;       if (cnt() != 0)         hi = md;       else         lo = md;     }     md = hi;     cout << hi << endl << cnt() << endl;     {       int _;       cin >> _;     }   }
#include <bits/stdc++.h>   using namespace std;   struct edge {     int u, v;     long long g, s;     bool operator<(const edge &cmp) const { return s < cmp.s; }   } e[50005], a[50005];   int n, m, cnt, p[205], tam;   long long gt, st;   bool cmpG(edge a, edge b) { return a.g < b.g; }   int find(int x) {     if (p[x] == x) return x;     return p[x] = find(p[x]);   }   bool link(int &a, int &b) {     if (find(a) == find(b)) return false;     p[find(a)] = find(b);     return true;   }   long long kruskal() {     long long res = 0;     cnt = 0;     for (int i = 1; i <= n; ++i) p[i] = i;     sort(a, a + tam);     for (int i = 0; i < tam; ++i) {       if (link(a[i].u, a[i].v)) {         res = a[i].s;         a[cnt++] = a[i];       }     }     tam = cnt;     return res;   }   int main() {     scanf( %d%d , &n, &m);     scanf( %I64d%I64d , &gt, &st);     long long res = 1ll << 62, sil;     cnt = tam = 0;     for (int i = 0; i < m; ++i) {       scanf( %d%d%I64d%I64d , &e[i].u, &e[i].v, &e[i].g, &e[i].s);       e[i].g *= gt;       e[i].s *= st;     }     sort(e, e + m, cmpG);     for (int i = 0; i < m; ++i) {       a[tam++] = e[i];       sil = kruskal();       if (cnt == n - 1) {         sil += e[i].g;         if (sil < res) res = sil;       }     }     if (res < 1ll << 62)       printf( %I64d n , res);     else       printf( -1 n );     return 0;   }
#include <bits/stdc++.h>   const int MAXN = 2e5 + 10;   using namespace std;   long long read() {     long long x = 0, f = 1;     char ch = getchar();     while (!isdigit(ch)) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (isdigit(ch)) x = x * 10 + ch -  0 , ch = getchar();     return f * x;   }   int n, q;   long long a[MAXN];   typedef struct node {     long long maxx;     long long sum;   } node;   node d[MAXN << 2];   void up(int x) {     d[x].sum = d[x << 1].sum + d[x << 1 | 1].sum;     d[x].maxx = max(d[x << 1].maxx, d[x << 1 | 1].maxx);   }   void built(int rt, int l, int r) {     if (l == r) {       d[rt].maxx = d[rt].sum = a[l];       return;     }     int mid = (l + r) >> 1;     built(rt << 1, l, mid);     built(rt << 1 | 1, mid + 1, r);     up(rt);   }   void update(int rt, int l, int r, int t, long long vul) {     if (l == r) {       d[rt].maxx = d[rt].sum = vul;       return;     }     int mid = (l + r) >> 1;     if (t <= mid)       update(rt << 1, l, mid, t, vul);     else       update(rt << 1 | 1, mid + 1, r, t, vul);     up(rt);   }   bool flag;   int pos1;   void querty2(int rt, int l, int r, long long vul) {     if (l == r) {       pos1 = l;       return;     }     int mid = (l + r) >> 1;     if (d[rt << 1].maxx >= vul)       querty2(rt << 1, l, mid, vul);     else       querty2(rt << 1 | 1, mid + 1, r, vul);   }   void querty(int rt, int l, int r, int ql, int qr, long long vul) {     if (flag) return;     if (ql <= l && r <= qr) {       if (d[rt].maxx >= vul) {         flag = 1;         querty2(rt, l, r, vul);       }       return;     }     int mid = (l + r) >> 1;     if (ql <= mid) querty(rt << 1, l, mid, ql, qr, vul);     if (qr > mid) querty(rt << 1 | 1, mid + 1, r, ql, qr, vul);   }   long long ans;   void querty1(int rt, int l, int r, int ql, int qr) {     if (ql <= l && r <= qr) {       ans += d[rt].sum;       return;     }     int mid = (l + r) >> 1;     if (ql <= mid) querty1(rt << 1, l, mid, ql, qr);     if (qr > mid) querty1(rt << 1 | 1, mid + 1, r, ql, qr);   }   int main() {     n = read();     q = read();     for (int i = 1; i <= n; i++) a[i] = read();     a[n + 1] = 1e18;     int pos, ans1;     long long vul, key, pre;     n++;     built(1, 1, n);     for (int i = 1; i <= q; i++) {       pos = read();       vul = read();       a[pos] = vul;       update(1, 1, n, pos, vul);       ans1 = -1;       key = 0;       if (!a[1]) {         printf( 1 n );         continue;       }       if (a[1] == a[2]) {         printf( 2 n );         continue;       }       key = a[1] + a[2];       pre = 3;       while (1) {         if (pre > n) break;         flag = 0;         querty(1, 1, n, pre, n, key);         ans = 0;         querty1(1, 1, n, 1, pos1 - 1);         if (ans == a[pos1]) {           ans1 = pos1;           break;         }         key = ans + a[pos1];         pre = pos1 + 1;       }       printf( %d n , ans1);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int tree[6000005], a[3000005], minp[3000005], upd[3000005];   long long int cun[3000005];   long long int d[3000005];   long long int n;   void sieve() {     a[0] = 1;     a[1] = 1;     for (long long int i = 1; i < 1e6 + 1; i++) {       for (long long int j = i; j < 1e6 + 1; j += i) {         d[j]++;       }     }   }   long long int lazy[3000005], tree2[3000005];   long long int b[3000005];   void build_tree(long long int node, long long int c, long long int en) {     if (c > en) return;     if (c == en) {       tree[node] = b[c];       tree2[node] = (tree[node] != 2 && tree[node] != 1);       return;     }     build_tree(node * 2, c, (c + en) / 2);     build_tree(node * 2 + 1, 1 + (c + en) / 2, en);     tree[node] = tree[2 * node] + tree[2 * node + 1];     tree2[node] = tree2[node * 2] | tree2[node * 2 + 1];   }   long long int query(long long int node, long long int st, long long int en,                       long long int l, long long int r) {     if (st > r || en < l || st > en) return 0;     if (st >= l && en <= r) {       return tree[node];     }     long long int r1 = query(2 * node, st, (st + en) / 2, l, r);     long long int r2 = query(2 * node + 1, (st + en) / 2 + 1, en, l, r);     return r1 + r2;   }   void update(long long int node, long long int st, long long int en,               long long int l, long long int r) {     if (st > r || en < l || st > en) return;     if (st == en) {       int p = d[tree[node]];       tree[node] = p;       tree2[node] = (tree[node] != 2 && tree[node] != 1);       return;     }     if (tree2[2 * node]) update(2 * node, st, (st + en) / 2, l, r);     if (tree2[2 * node + 1]) update(2 * node + 1, (st + en) / 2 + 1, en, l, r);     tree[node] = tree[2 * node] + tree[2 * node + 1];     tree2[node] = tree2[node * 2] | tree2[node * 2 + 1];   }   int main() {     sieve();     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int q;     cin >> n >> q;     for (long long int i = 0; i < n; i++) cin >> b[i];     build_tree(1, 0, n - 1);     for (long long int i = 0; i < q; i++) {       long long int ty, l, r;       cin >> ty >> l >> r;       l--;       r--;       if (ty == 1)         update(1, 0, n - 1, l, r);       else         cout << query(1, 0, n - 1, l, r) <<   n ;     }   }