malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   double revs, a, b, c, d, C, totdist;   const double pi = atan(1) * 4;   int n, r, v, s, f;   double distcovered(double t) { return max(r * (t + sin(t)), r * (t - sin(t))); }   int main() {     cout << fixed << setprecision(8);     cin >> n >> r >> v;     for (int c = 0; c < n; c++) {       scanf( %d%d , &s, &f);       a = f - s;       a = a / 2;       double up, low;       low = 0;       up = a / r + 2 * pi;       for (int c = 0; c < 100; c++) {         double mid = (low + up) / 2;         b = distcovered(mid);         if (b == a)           break;         else if (b > a)           up = mid;         else           low = mid;       }       double mid = (low + up) / 2;       double speed = (double)v / r;       double time = mid / speed * 2;       printf( %.8f n , time);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1e15;   const int MOD = 1e9 + 7;   const double EPS = 1e-7;   const double PI = acos(-1.0);   const int N = 3e5 + 5;   long long n, a[N];   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL), cout.tie(NULL);     cin >> n;     for (int i = 0; i < n; ++i) {       cin >> a[i];     }     long long ans = 0, left = 0;     for (int i = 0; i < n; ++i) {       if (i) {         ans += min(a[i] / 2, left);         long long tmp = left;         left -= min(a[i] / 2, left);         a[i] -= min(a[i] / 2 * 2, tmp * 2);       }       ans += a[i] / 3;       a[i] -= a[i] / 3 * 3;       left += a[i];     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   void make(vector<pair<int, int> > &a, long long int b) {     int last = 0;     int n = a.size();     for (int i = 0; i < a.size() - 1; i++) {       if (b >= pow(2, n - 2 - i)) {         a[i].first = n - last;         last++;         b = b - pow(2, n - 2 - i);       } else {         a[i].first = i + 1 - last;       }     }     a[n - 1].first = n - last;   }   int main() {     long long int n, b;     cin >> n >> b;     vector<pair<int, int> > a;     for (int i = 0; i < n; i++) {       a.push_back(make_pair(0, i + 1));     }     make(a, b - 1);     sort(a.begin(), a.end());     for (int i = 0; i < n; i++) cout << a[i].second <<    ;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1000000007;   const int MAX = 1000005;   int n, k;   int st1[MAX][20];   int st2[MAX][20];   int v[MAX];   int c[MAX];   int ans[MAX];   double factor[MAX];   int log(int x) {     int ct = 0;     int k = 1;     while (k <= x) {       k *= 2;       ct++;     }     return ct - 1;   }   int pow2(int x) {     int ans = 1;     for (int i = 0; i < x; i++) {       ans *= 2;     }     return ans;   }   void process2() {     for (int j = 1; (1 << j) <= n; j++) {       for (int i = 1; i + (1 << j) - 1 <= n; i++) {         if (st2[i][j - 1] < st2[i + (1 << (j - 1))][j - 1]) {           st2[i][j] = st2[i][j - 1];         } else {           st2[i][j] = st2[i + (1 << (j - 1))][j - 1];         }       }     }   }   int rmq2(int i, int j) {     int k = log(j - i + 1);     if (st2[i][k] <= st2[j - pow2(k) + 1][k]) {       return st2[i][k];     }     return st2[j - pow2(k) + 1][k];   }   void process1() {     for (int j = 1; (1 << j) <= n; j++) {       for (int i = 1; i + (1 << j) - 1 <= n; i++) {         if (st1[i][j - 1] > st1[i + (1 << (j - 1))][j - 1]) {           st1[i][j] = st1[i][j - 1];         } else {           st1[i][j] = st1[i + (1 << (j - 1))][j - 1];         }       }     }   }   int rmq1(int i, int j) {     int k = log(j - i + 1);     if (st1[i][k] >= st1[j - pow2(k) + 1][k]) {       return st1[i][k];     }     return st1[j - pow2(k) + 1][k];   }   int first(int l, int r) { return 100 * rmq1(l, r); }   int g(int l, int r) { return rmq2(l, r); }   int p(int l, int r) { return min(g(l, r), first(l, r)); }   int main() {     scanf( %d %d , &n, &k);     for (int i = 0; i < n; i++) {       scanf( %d , &v[i + 1]);       st1[i + 1][0] = v[i + 1];     }     for (int i = 0; i < n; i++) {       scanf( %d , &c[i + 1]);       st2[i + 1][0] = c[i + 1];     }     process1();     process2();     factor[1] = (k + 0.0) / n;     for (int i = 2; i < n + 1; i++) {       factor[i] = factor[i - 1] * (0.0 + n - k - (i - 2)) / (n - i + 1);     }     for (int l = 1; l < n + 1; l++) {       int lo = l;       int hi = n;       while (lo < hi) {         int mid = (lo + hi) / 2;         if (first(l, mid) == g(l, mid)) {           lo = mid;           ans[l] = first(l, mid);           break;         }         if (first(l, mid) < g(l, mid)) {           lo = mid + 1;         } else {           hi = mid;         }       }       if (ans[l] == 0) {         ans[l] = p(l, lo);         if (l <= lo - 1) {           ans[l] = max(ans[l], p(l, lo - 1));         }       }     }     sort(ans + 1, ans + n + 1);     double fin = 0;     for (int i = 1; i < n + 1; i++) {       fin += ans[i] * factor[i];     }     printf( %.10f n , fin);   }
#include <bits/stdc++.h>   using namespace std;   void fast_in_out() {     std::ios_base::sync_with_stdio(NULL);     cin.tie(NULL);     cout.tie(NULL);   }   int main() {     fast_in_out();     int n, x, y, c = 0;     cin >> n;     for (int(i) = 0; (i) < (n); ++(i)) {       cin >> x >> y;       if (y >= x + 2) c++;     }     cout << c << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int w, h;     cin >> w >> h;     long long int cnt = 0;     for (int i = 2; i <= w; i += 2) {       for (int j = 2; j <= h; j += 2) {         cnt += ((w - i + 1) * (h - j + 1));       }     }     cout << cnt;     return 0;   }
#include <bits/stdc++.h>   const int mxn = 1e5 * 4 + 10, mod = 1e9 + 7;   using namespace std;   long long phi(long long n);   long long gcd(long long a, long long b);   long long lcm(long long a, long long b);   long long n, m, t = 0, l, k, a, tmp, d;   int mn = 1e9, mx = -1;   int main() {     cin >> n >> t >> k >> d;     long long ao, bo, c, g;     c = (n + k - 1) / k;     ao = c * t;     c -= d / t;     g = d / t * t;     c -= (d - g) / t;     g += (d - g) / t * t;     if (c % 2) {       g += (c / 2 + 1) * t;       d += (c / 2) * t;     } else {       g += (c / 2) * t;       d += (c / 2) * t;     }     bo = max(d, g);     cout << ((ao > bo) ?  YES  :  NO );   }   long long phi(long long n) {     long long res = n, i = 2;     for (; i * i <= n; i++)       if (n % i == 0) {         while (n % i == 0) n = n / i;         res -= res / i;       }     if (n > 1) res -= res / n;     return res;   }   long long gcd(long long a, long long b) { return (b == 0) ? a : gcd(b, a % b); }   long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
#include <bits/stdc++.h>   using namespace std;   int x[10007], y[10007];   int n, w, v, u;   int main() {     cin >> n >> w >> v >> u;     double maxer = -1;     for (int i = 0; i < n; i++) {       cin >> x[i] >> y[i];     }     double lim = u * 1.0 / v;     bool flag1 = false;     bool flag2 = false;     for (int i = 0; i < n; i++) {       if (y[i] * 1.0 / x[i] > lim || y[i] * 1.0 / x[i] < 0) {         flag1 = true;       }       if (y[i] * 1.0 / x[i] < lim) {         flag2 = true;       }       double tmp = x[i] * 1.0 / v + (w - y[i]) * 1.0 / u;       maxer = max(maxer, tmp);     }     if (flag1 == false || flag2 == false) {       printf( %.10f n , w * 1.0 / u);       return 0;     }     printf( %.10f n , maxer);   }
#include <bits/stdc++.h>   using namespace std;   int a[200002], ans[200002];   int main() {     int n, i, k = 0, sum = 0;     scanf( %d , &n);     for (i = 0; i < n; i++) {       scanf( %d , &a[i]);       sum += a[i];     }     for (i = 0; i < n; i++) {       if (((sum - a[i]) / (n - 1) == a[i]) && ((sum - a[i]) % (n - 1) == 0))         ans[k++] = i + 1;     }     printf( %d n , k);     for (i = 0; i < k; i++) printf( %d  , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int cnt[22];   int main() {     int n;     cin >> n;     int a;     for (int i = 0; i < n; i++) {       cin >> a;       cnt[a + 10]++;     }     long long int ans = cnt[10] * (cnt[10] - 1) / 2;     for (int i = 1; i <= 10; i++) ans += cnt[-i + 10] * cnt[i + 10];     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3e5 + 10, size = 1 << 20, mod = 998244353;   template <class o>   void qr(o &x) {     char c = getchar();     x = 0;     int f = 1;     while (!isdigit(c)) {       if (c ==  - ) f = -1;       c = getchar();     }     while (isdigit(c)) x = x * 10 + c -  0 , c = getchar();     x *= f;   }   template <class o>   void qw(o x) {     if (x / 10) qw(x / 10);     putchar(x % 10 +  0 );   }   template <class o>   void pr1(o x) {     if (x < 0) x = -x, putchar( - );     qw(x);     putchar(   );   }   template <class o>   void pr2(o x) {     if (x < 0) x = -x, putchar( - );     qw(x);     puts(  );   }   long long mult(long long a, long long b, long long p) {     a = (a % p + p) % p;     b = (b % p + p) % p;     long long c = (long double)a * b / p;     return a * b - c * p;   }   long long gcd(long long a, long long b) { return !a ? b : gcd(b % a, a); }   long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }   long long power(long long a, long long b = mod - 2) {     long long c = 1;     while (b) {       if (b & 1) c = c * a % mod;       b /= 2;       a = a * a % mod;     }     return c;   }   long long Power(long long a, long long b = mod - 2) {     long long c = 1;     while (b) {       if (b & 1) c = mult(c, a, mod);       b /= 2;       a = mult(a, a, mod);     }     return c;   }   int n;   long long inv, a[N];   int main() {     qr(n);     inv = power(n);     for (int i = 1; i <= n; i++) qr(a[i]);     sort(a + 1, a + n + 1);     for (int i = 1; i <= n; i++) (a[i] += a[i - 1]) %= mod;     for (int i = 1; i <= n; i++) {       int pos = n - i, t = 1;       long long ans = 0;       while (pos >= i) {         ans += (a[pos] - a[pos - i] + mod) * t++ % mod;         pos -= i;       }       (ans += a[pos] * t) %= mod;       pr1(ans * inv % mod);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     while (n--) {       int a;       cin >> a;       string s;       cin >> s;       set<char> st;       for (int i = 0; i < s.size(); i++) {         st.insert(s[i]);       }       if (st.size() == 1) {         cout << -1 <<     << -1 << endl;       } else {         for (int i = 0; i < s.size(); i++) {           if (s[i] ==  a  && s[i + 1] ==  b ) {             cout << i + 1 <<     << i + 2 << endl;             break;           }           if (s[i] ==  b  && s[i + 1] ==  a ) {             cout << i + 1 <<     << i + 2 << endl;             break;           }         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int MOD = 998244353;     long long int n;     cin >> n;     pair<long long int, long long int> arr[n];     for (long long int i = 0; i < n; ++i) cin >> arr[i].first >> arr[i].second;     long long int fact[n + 1];     fact[0] = 1;     for (long long int i = 1; i <= n; ++i) {       fact[i] = (fact[i - 1] * i + MOD) % MOD;     }     map<long long int, long long int> count1;     map<long long int, long long int> count2;     map<pair<long long int, long long int>, long long int> count3;     for (long long int i = 0; i < n; ++i) {       count1[arr[i].first]++;       count2[arr[i].second]++;       count3[make_pair(arr[i].first, arr[i].second)]++;     }     long long int n1 = 1, n2 = 1, n3 = 1;     map<long long int, long long int>::iterator it;     for (it = count1.begin(); it != count1.end(); ++it) {       n1 = (n1 * (fact[it->second]) + MOD) % MOD;     }     for (it = count2.begin(); it != count2.end(); ++it) {       n2 = (n2 * (fact[it->second]) + MOD) % MOD;     }     map<pair<long long int, long long int>, long long int>::iterator itd;     long long int last2 = -1;     for (itd = count3.begin(); itd != count3.end(); ++itd) {       n3 = (n3 * (fact[itd->second]) + MOD) % MOD;       if (itd->first.second < last2) {         n3 = 0;         break;       }       last2 = itd->first.second;     }     long long int ans = (fact[n] - n1 - n2 + n3 + 2 * MOD) % MOD;     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long h, w;     cin >> h >> w;     long long pow2max = 1;     while (2 * pow2max <= h && 2 * pow2max <= w) pow2max *= 2;     long long hmax = min(h, (long long)(1.25 * pow2max));     long long wmax = min(w, (long long)(1.25 * pow2max));     if (hmax >= wmax)       cout << hmax <<     << pow2max;     else       cout << pow2max <<     << wmax;     return;   }   signed main() {     ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);     long long t = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long Ax, Ay, Bx, By, Cx, Cy;   bool solvable(long long A, long long B) {     return (Cx * A + Cy * B) % (Cx * Cx + Cy * Cy) == 0 &&            (-Cy * A + Cx * B) % (Cx * Cx + Cy * Cy) == 0;   }   bool possible() {     cin >> Ax >> Ay >> Bx >> By >> Cx >> Cy;     if (Cx == 0 && Cy == 0) {       if (Bx == Ax && By == Ay) return true;       if (Bx == Ay && By == -Ax) return true;       if (Bx == -Ax && By == -Ay) return true;       if (Bx == -Ay && By == Ax) return true;       return false;     }     if (solvable(Bx - Ax, By - Ay)) return true;     if (solvable(Bx - Ay, By + Ax)) return true;     if (solvable(Bx + Ax, By + Ay)) return true;     if (solvable(Bx + Ay, By - Ax)) return true;     return false;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout << (possible() ?  YES  :  NO ) << endl;     cout << flush;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool a[1000][1000];   int main() {     ios::sync_with_stdio(false);     int n, m, ans = 0;     cin >> n >> m;     bool tmp = 0;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         cin >> a[i][j];       }     }     for (int i = 0; i < n; i++) {       tmp = 0;       for (int j = 0; j < m; j++) {         tmp = max(tmp, a[i][j]);         if (a[i][j] == 0 && tmp) ans++;       }     }     for (int i = 0; i < m; i++) {       tmp = 0;       for (int j = 0; j < n; j++) {         tmp = max(tmp, a[j][i]);         if (a[j][i] == 0 && tmp) ans++;       }     }     for (int i = 0; i < n; i++) {       tmp = 0;       for (int j = m - 1; j >= 0; j--) {         tmp = max(tmp, a[i][j]);         if (a[i][j] == 0 && tmp) ans++;       }     }     for (int i = 0; i < m; i++) {       tmp = 0;       for (int j = n - 1; j >= 0; j--) {         tmp = max(tmp, a[j][i]);         if (a[j][i] == 0 && tmp) ans++;       }     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   char s[6][8], t[10];   int n;   bool match(char* a, char* b) {     for (int i = 0; i < 7; i++)       if (b[i] !=  .  && a[i] != b[i]) return 0;     return 1;   }   int main() {     sprintf(s[0],  jolteon );     sprintf(s[1],  flareon );     sprintf(s[2],  umbreon );     sprintf(s[3],  leafeon );     sprintf(s[4],  glaceon );     sprintf(s[5],  sylveon );     scanf( %d%s , &n, t);     if (n == 6) return 0 * printf( espeon n );     if (n == 8) return 0 * printf( vaporeon n );     for (int i = 0; i < 6; i++)       if (match(s[i], t)) return 0 * printf( %s n , s[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s, v;   int ans, p, t;   char c;   char tr[1000];   int mypow(int k) {     int c = 1;     for (int i = 1; i <= k; i++) {       c *= 2;     }     return c;   }   int main() {     gets(tr);     s = (string)tr;     p = 0;     for (int i = 0; i < s.length(); i++) {       v =   ;       c = s[i];       int k = 7;       ans = 0;       while ((c > 0) && (k >= 0)) {         if (c % 2 == 1) ans += mypow(k);         k--;         c /= 2;       }       t = (p - ans) % 256;       if (t < 0) t += 256;       cout << t << endl;       p = ans;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct ruchy {     bool kol[55];     bool wiersze[55];   };   int dl, szer, ilosc_ruchow;   int kolumny[55];   int wiersze[55];   ruchy gra[2510];   char palnsza[54][54];   bool dasie = 1;   void wypisgry() {     for (int k = 0; k < ilosc_ruchow; k++) {       cout <<  ruch numer  << k + 1 << endl;       cout <<  kolumny;  << endl;       for (int i = 1; i < 50; i++)         if (gra[k + 1].kol[i]) cout << i <<  , ;       cout << endl;       cout <<  wiersze;  << endl;       for (int i = 1; i < 50; i++)         if (gra[k + 1].wiersze[i]) cout << i <<  , ;       cout << endl;     }   }   int main() {     cin >> dl >> szer;     for (int j = 0; j < dl; j++) {       for (int i = 0; i < szer; i++) {         cin >> palnsza[i + 1][j + 1];       }     }     for (int j = 0; j < dl; j++) {       for (int i = 0; i < szer; i++) {         if (palnsza[i + 1][j + 1] ==  # ) {           if (kolumny[i + 1] != 0) {             if (wiersze[j + 1] != 0 && wiersze[j + 1] != kolumny[i + 1])               dasie = 0;             wiersze[j + 1] = kolumny[i + 1];             gra[kolumny[i + 1]].wiersze[j + 1] = 1;           } else {             if (wiersze[j + 1] != 0) {               if (kolumny[i + 1] != 0 && kolumny[i + 1] != wiersze[j + 1])                 dasie = 0;               kolumny[i + 1] = wiersze[j + 1];               gra[wiersze[j + 1]].kol[i + 1] = 1;             } else {               ilosc_ruchow++;               kolumny[i + 1] = ilosc_ruchow;               wiersze[j + 1] = ilosc_ruchow;               gra[ilosc_ruchow].kol[i + 1] = 1;               gra[ilosc_ruchow].wiersze[j + 1] = 1;             }           }         }       }     }     for (int k = 0; k < ilosc_ruchow; k++) {       for (int j = 0; j < dl; j++) {         for (int i = 0; i < szer; i++) {           if (gra[k + 1].wiersze[j + 1] && gra[k + 1].kol[i + 1] &&               palnsza[i + 1][j + 1] ==  . )             dasie = 0;         }       }     }     if (dasie)       printf( Yes );     else       printf( No );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dx[] = {1, -1, 0, 0};   int dy[] = {0, 0, 1, -1};   int dx2[] = {1, -1, 0, 0, -1, 1, -1, 1};   int dy2[] = {0, 0, 1, -1, 1, -1, -1, 1};   int read() {     int x;     scanf( %d , &x);     return x;   }   int ans[100005];   int a[100005];   int used[1000001];   int main() {     int n = read();     int m = read();     for (int i = 1; i <= n; i++) a[i] = read();     for (int i = n; i >= 1; i--) {       if (used[a[i]])         ans[i] = ans[i + 1];       else         ans[i] = ans[i + 1] + 1, used[a[i]] = 1;     }     while (m--) {       printf( %d n , ans[read()]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, c;     cin >> n >> m >> c;     vector<int> a(n);     for (int i = 0; i < n; i++) cin >> a[i];     vector<int> b(n);     for (int i = 0; i < m; i++) cin >> b[i];     int cur = 0;     for (int i = 0; i < a.size(); i++) {       if (i >= 0 && i < m) cur += b[i];       a[i] += cur;       if (i >= (n)-m) cur -= b[i - ((n)-m)];     }     for (int i = 0; i < n; i++) cout << a[i] % c <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long Mo = 1e9 + 7;   int cnt[1 << 6], sz;   void add(long long &x, long long y) {     x += y;     x %= Mo;   }   void gao(int n, int C, int R, vector<vector<long long>> &Ma) {     int loop = 1 << R;     for (int i = 0; i < sz; i++) {       int c = i / loop, r = i % loop;       int a1 = r >> 1, a2 = r >> 1 | (1 << (R - 1));       if ((r & 1) && c != 0) {         Ma[c * loop + a1 - loop][i] += cnt[a1] + 1;         Ma[c * loop + a2 - loop][i] += cnt[a2] + 1;       } else if (!(r & 1)) {         Ma[c * loop + a1][i] += 1;         Ma[c * loop + a2][i] += 1;       }     }   }   void mul(vector<vector<long long>> &a, vector<vector<long long>> b) {     vector<vector<long long>> ret(sz, vector<long long>(sz));     for (int i = 0; i < sz; i++) {       for (int j = 0; j < sz; j++) {         for (int k = 0; k < sz; k++) {           add(ret[i][j], a[i][k] * b[k][j]);         }       }     }     a = ret;   }   void matpw(vector<vector<long long>> &a, long long b) {     vector<vector<long long>> ret(sz, vector<long long>(sz));     for (int i = 0; i < sz; i++) ret[i][i] = 1;     while (b) {       if (b & 1) mul(ret, a);       mul(a, a);       b >>= 1;     }     a = ret;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     for (int i = 0; i < (1 << 6); i++) {       for (int j = 0; j < 6; j++) {         if (i & (1 << j)) cnt[i]++;       }     }     int n, K, m;     cin >> n >> K >> m;     sz = (K + 1) * (1 << m);     vector<vector<long long>> Ma(sz, vector<long long>(sz));     gao(sz, K + 1, m, Ma);     matpw(Ma, n);     vector<vector<long long>> base(sz, vector<long long>(sz));     for (int i = 0; i < sz; ++i) base[i][0] = 1;     mul(base, Ma);     long long ans = 0;     for (int i = 0; i < (1 << m); ++i) add(ans, base[0][sz - i - 1]);     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:1000000 )   using namespace std;   int c, v, c1, v1, *a[262144], *s[262144];   void l(int w, int e, int t) {     w <<= 1;     if ((c <= e) && (e + t - 1 <= v)) {       c1 += a[w][v1];       v1 = s[w][v1];     } else if (min(v, e + t - 1) - max(c, e) >= 0)       l(w, e, t >> 1);     if ((c <= e + t) && (e + t + t - 1 <= v)) {       c1 += a[w + 1][v1];       v1 = s[w + 1][v1];     } else if (min(v, e + t + t - 1) - max(c, e + t) >= 0)       l(w + 1, e + t, t >> 1);   }   int main() {     int q, w, e, r, t, o;     for (w = 0; w < 262144; w++) {       a[w] = new int[60];       s[w] = new int[60];     }     cin >> q;     for (w = 0; w < q; w++) {       cin >> e;       for (r = 0; r < 60; r++) {         c = 1;         if (r % e == 0) c++;         a[w + 131072][r] = c;         s[w + 131072][r] = (c + r) % 60;       }     }     for (; w < 131072; w++)       for (r = 0; r < 60; r++) a[w + 131072][r] = s[w + 131072][r] = 1;     for (w = 131071; w; w--)       for (e = 0; e < 60; e++) {         c = s[w << 1][e];         a[w][e] = a[w << 1][e] + a[(w << 1) + 1][c];         s[w][e] = s[(w << 1) + 1][c];       }     char d[2];     for (cin >> o; o; o--) {       scanf( %s%d%d , &d, &c, &v);       if (d[0] ==  A ) {         c1 = v1 = 0;         c--;         v -= 2;         l(1, 0, 65536);         printf( %d n , c1);       } else {         c += 131071;         for (e = 0; e < 60; e++) {           r = 1;           if (e % v == 0) r++;           a[c][e] = r;           s[c][e] = (r + e) % 60;         }         for (c >>= 1; c; c >>= 1)           for (e = 0; e < 60; e++) {             r = s[c << 1][e];             a[c][e] = a[c << 1][e] + a[(c << 1) + 1][r];             s[c][e] = s[(c << 1) + 1][r];           }       }     }     return 0;   }