malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   template <typename T>   string NumberToString(T Number) {     std::ostringstream second;     second << Number;     return second.str();   }   long long qpow(long long p, long long q) {     long long f = 1;     while (q) {       if (q & 1) f = f * p % 1000000007LL;       p = p * p % 1000000007LL;       q >>= 1;     }     return f;   }   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 * 10 + ch -  0 ;       ch = getchar();     }     return x * f;   }   const long long mod7 = 998244353LL;   inline long long add(long long _x, long long _y, long long _mod = mod7) {     _x += _y;     return _x >= _mod ? _x - _mod : _x;   }   inline long long sub(long long _x, long long _y, long long _mod = mod7) {     _x -= _y;     return _x < 0 ? _x + _mod : _x;   }   inline long long mul(long long _x, long long _y, long long _mod = mod7) {     _x *= _y;     return _x >= _mod ? _x % _mod : _x;   }   int const N = 553;   long long t[N][N], cum[N][N];   int main() {     for (auto ik = 0; ik < (501); ++ik) cum[0][ik] = 1LL;     for (int in = 1; in <= 500; ++in) {       for (int ik = 1; ik <= in; ++ik) {         for (int before = 0; (in - ik - before) >= 0; ++before) {           t[in][ik] =               add(t[in][ik],                   mul(cum[before][min(before, ik - 1)],                       cum[(in - ik - before)][min((in - ik - before), ik)]));         }         cum[in][ik] = add(cum[in][ik - 1], t[in][ik]);       }     }     int n, k;     cin >> n >> k;     long long sol = 0LL;     for (int a = 1; a < min(k, n + 1); ++a) {       if (k % a == 0)         sol = add(sol, mul(t[n][a], cum[n][min(n, (k - 1) / a)]));       else         sol = add(sol, mul(t[n][a], cum[n][min(n, k / a)]));     }     cout << mul(sol, 2LL);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }   inline int gcd(int a, int b) {     if (b == 0) return a;     return gcd(b, a % b);   }   template <typename T>   string to_str(T str) {     stringstream stream;     stream << str;     return stream.str();   }   template <typename T>   int to_int(T num) {     int val;     stringstream stream;     stream << num;     stream >> val;     return val;   }   vector<string> split(const string& s, char delim) {     vector<string> elems;     stringstream ss(s);     string item;     while (getline(ss, item, delim)) elems.push_back(item);     return elems;   }   const int dr[] = {-1, -1, 0, 1, 1, 1, 0, -1};   const int dc[] = {0, 1, 1, 1, 0, -1, -1, -1};   const int T2 = 105;   const int T3 = 1005;   const int T4 = 10005;   const int T5 = 100005;   int a[T3], b[T3];   const int M = 475;   bool check(int s, int p) {     int i = (s / 50) % M;     int loop = 25;     while (loop--) {       i = (i * 96 + 42) % M;       if (26 + i == p) {         return true;       }     }     return false;   }   int main() {     ios_base::sync_with_stdio(0);     int p, x, y;     cin >> p >> x >> y;     int s = x;     bool f = 0;     while (s >= y) {       if (check(s, p)) {         f = 1;         break;       }       s -= 50;     }     if (!f) {       s = x;       while (1) {         if (check(s, p)) {           f = 1;           break;         }         s += 50;       }     }     int diff = s - x;     if (diff < 0)       cout <<  0 n ;     else       cout << ceil(diff * 1.0 / 100) <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long double esp = 1e-11;   const long double PI = acos(-1.0);   const long long int INF = 0x3f3f3f3f;   const long long int MOD = 1000000007;   const int maxn = 10010;   const int NUM = 25;   long long int wn[NUM];   long long int mu(long long int a, long long int b, long long int P) {     long long int ans = 1;     a %= P;     while (b) {       if (b & 1) ans = ans * a % P;       a = a * a % P;       b >>= 1;     }     return ans;   }   void GetWn(long long int G, long long int P) {     long long int t;     for (int i = 0; i < NUM; i++) {       t = 1ll << i;       wn[i] = mu(G, (P - 1) / t, P);     }   }   void Rader(long long int a[], int len) {     int j = len >> 1, k;     for (int i = 1; i < len - 1; i++) {       if (i < j) swap(a[i], a[j]);       k = len >> 1;       while (j >= k) {         j -= k;         k >>= 1;       }       if (j < k) j += k;     }   }   void NTT(long long int a[], int len, int on, long long int P) {     Rader(a, len);     long long int id = 0, w, u, t;     for (int h = 2; h <= len; h <<= 1) {       id++;       for (int j = 0; j < len; j += h) {         w = 1;         for (int k = j; k < j + h / 2; k++) {           u = a[k] % P;           t = w * a[k + h / 2] % P;           a[k] = (u + t) % P;           a[k + h / 2] = (u - t + P) % P;           w = w * wn[id] % P;         }       }     }     if (on == -1) {       for (int i = 1; i < len / 2; i++) swap(a[i], a[len - i]);       long long int inv = mu(len, P - 2, P);       for (int i = 0; i < len; i++) a[i] = a[i] * inv % P;     }   }   long long int a[1ll << 20];   int main() {     int n, k, tem;     scanf( %d%d , &n, &k);     memset(a, 0, sizeof(a));     for (int x = 1; x <= n; x++) {       scanf( %d , &tem);       a[tem] = 1;     }     long long int N = 1ll << 20, G = 3, P = 469762049ll;     GetWn(G, P);     NTT(a, N, 1, P);     for (int i = 0; i < N; i++) a[i] = mu(a[i], k, P);     NTT(a, N, -1, P);     for (int i = 0; i < N; i++)       if (a[i]) printf( %d  , i);     return 0;   }
#include <bits/stdc++.h>   int res[1000008];   using namespace std;   int main() {     bool pr[1000008 + 1];     memset(pr, true, sizeof(pr));     int cnt = 0;     for (int p = 2; p * p <= 1000008; p++) {       if (pr[p] == true) {         for (int j = p * p; j <= 1000008; j += p) pr[j] = false;       }     }     for (int i = 2; i <= 1000008; i++) {       if (pr[i]) {         cnt++;       }       res[i] = cnt;     }     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       int k = sqrt(n);       int r = res[n] - res[k];       cout << r + 1 <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   long long ans[1000005];   long long n;   struct cht {     vector<pair<long long, long long> > v;     long long pt = 0;     long long val(long long pos, long long x) {       return v[pos].first * x + v[pos].second;     }     bool lmao(pair<long long, long long> p0, pair<long long, long long> p1,               pair<long long, long long> p2) {       double lel = 1.0 * (p1.second - p0.second) * (p1.first - p2.first) -                        1.0 * (p2.second - p1.second) * (p0.first - p1.first) >=                    1e-7;       if (lel > 0) return true;       return false;     }     void add(long long first, long long second) {       for (pair<long long, long long> hic = {first, second};            v.size() > 1 && lmao(hic, v[v.size() - 1], v[v.size() - 2]);            v.pop_back())         ;       v.push_back({first, second});     }     long long get(long long x) {       for (pt = min(pt, (long long)v.size() - 1);            pt + 1 < (long long)v.size() && val(pt, x) < val(pt + 1, x); pt++)         ;       return val(pt, x);     }   } C;   pair<long long, pair<long long, long long> > first[1000005];   signed main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n;     C.add(0, 0);     for (long long i = 1; i <= n; i++) {       cin >> first[i].first >> first[i].second.first >> first[i].second.second;     }     sort(first + 1, first + n + 1);     long long hihi = -1000000000000000000;     for (long long i = 1; i <= n; i++) {       ans[i] = C.get(first[i].second.first) - first[i].second.second +                first[i].first * first[i].second.first;       C.add(-first[i].first, ans[i]);       hihi = max(hihi, ans[i]);     }     cout << hihi;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ld = long double;   using uint = unsigned int;   using ull = unsigned long long;   using ii = pair<int, int>;   using pli = pair<ll, int>;   using vi = vector<int>;   using vll = vector<ll>;   using pll = pair<ll, ll>;   using pil = pair<int, ll>;   using vvi = vector<vi>;   using vpi = vector<ii>;   const int N = 100100;   ll mod = 1000000007;   vvi adj;   vi p, h;   int n, m;   vi vis;   ii solve(int i) {     int tot_people = p[i];     int good = 0;     vis[i] = true;     for (auto x : adj[i]) {       if (vis[x]) continue;       auto temp = solve(x);       if (temp.first == -1) {         return temp;       }       tot_people += temp.first;       good += temp.second;     }     int good_calculated = (tot_people + h[i]) / 2;     if (good_calculated > tot_people || (tot_people + h[i]) % 2 ||         good > good_calculated) {       return make_pair(-1, -1);     } else {       return make_pair(tot_people, good_calculated);     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int tt;     cin >> tt;     while (tt--) {       int n, m;       cin >> n >> m;       adj.resize(n);       for (int i = 0; i <= n - 1; i++) adj[i].clear();       p.clear();       p.resize(n);       vis.clear();       vis.resize(n);       for (int i = 0; i <= n - 1; i++) cin >> p[i];       assert(accumulate(p.begin(), p.end(), 0) == m);       h.resize(n);       for (int i = 0; i <= n - 1; i++) {         cin >> h[i];       }       for (int i = 0; i <= n - 2; i++) {         int x, y;         cin >> x >> y;         x--, y--;         adj[x].push_back(y);         adj[y].push_back(x);       }       auto ans = solve(0);       if (ans.first != -1) {         cout <<  YES               <<   n ;       } else {         cout <<  NO               <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7;   const int N = 1e6 + 5;   int a[N], m[N];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int n, b;     cin >> n >> b;     for (int i = 1; i <= n; ++i) cin >> a[i];     for (int i = n; i >= 0; --i) m[i] = max(m[i + 1], a[i]);     int ans = b;     for (int i = 1; i <= n; ++i) {       ans = max(ans, b % a[i] + b / a[i] * m[i + 1]);     }     cout << (n == 1 ? b : ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[1005];   int main() {     int n, maxp, mx2p;     scanf( %d , &n);     for (register int i = 1; i <= n; ++i) {       scanf( %d , a + i);     }     if (a[1] > a[2]) {       maxp = 1;       mx2p = 2;     } else {       maxp = 2;       mx2p = 1;     }     for (register int i = 3; i <= n; ++i) {       if (a[i] > a[maxp]) {         mx2p = maxp;         maxp = i;       } else if (a[i] > a[mx2p]) {         mx2p = i;       }     }     printf( %d %d , maxp, a[mx2p]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long add(long long x, long long y) {     x += y;     if (x >= 1000000007) x -= 1000000007;     return x;   }   inline long long sub(long long x, long long y) {     x -= y;     if (x < 0) x += 1000000007;     return x;   }   inline long long mul(long long x, long long y) {     return ((x % 1000000007) * (y % 1000000007)) % 1000000007;   }   inline long long pwr(long long a, long long b) {     long long x = 1LL;     while (b) {       if (b & 1) x = mul(x, a);       a = mul(a, a);       b >>= 1;     }     return x;   }   bool CHK(long long n) {     if (n == 1) return 0;     if (n == 2 or n == 3) return 1;     if (n % 2 == 0 or n % 3 == 0) return 0;     for (long long i = 5; i * i <= n; i += 6)       if (n % i == 0 or n % (i + 2) == 0) return 0;     return 1;   }   int main() {     ios_base::sync_with_stdio(false), cin.tie(NULL);     long long n = 0;     cin >> n;     string s;     cin >> s;     long long cnt = 0;     for (long long i = 0; i < n - 1; i++) {       if (s[i] ==  * ) continue;       if (s[i] == s[i + 1]) cnt++, s[i + 1] =  * ;     }     cout << cnt <<   n ;     for (long long i = 0; i < n; i++) {       if (s[i] ==  *  and i != n - 1) {         if (s[i - 1] ==  R  and s[i + 1] ==  G )           s[i] =  B ;         else if (s[i - 1] ==  G  and s[i + 1] ==  B )           s[i] =  R ;         else if (s[i - 1] ==  R  and s[i + 1] ==  B )           s[i] =  G ;         else if (s[i - 1] ==  R  and s[i + 1] ==  R )           s[i] =  G ;         else if (s[i - 1] ==  B  and s[i + 1] ==  B )           s[i] =  G ;         else if (s[i - 1] ==  G  and s[i + 1] ==  G )           s[i] =  R ;         else if (s[i - 1] ==  G  and s[i + 1] ==  R )           s[i] =  B ;         else if (s[i - 1] ==  B  and s[i + 1] ==  G )           s[i] =  R ;         else if (s[i - 1] ==  B  and s[i + 1] ==  R )           s[i] =  G ;       } else if (s[i] ==  *  and i == n - 1) {         if (s[i - 1] ==  R )           s[i] =  G ;         else if (s[i - 1] ==  B )           s[i] =  G ;         else if (s[i - 1] ==  G )           s[i] =  B ;       }     }     for (auto u : s) cout << u;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 3e5;   set<int> v[MAXN];   int last = -1, lastx = -1;   vector<int> f;   int ans = 0;   int t[MAXN], x_[MAXN];   bool find(vector<int> &d, int k) {     if (d.empty()) return false;     int l = 0, r = int(d.size());     while (r - l > 1) {       int m = (l + r) / 2;       if (d[m] <= k)         l = m;       else         r = m;     }     return d[l] == k;   }   int main() {     ios_base::sync_with_stdio(false);     int n, q;     cin >> n >> q;     for (int i = 0; i < q; i++) {       int type, x;       cin >> type >> x;       x--;       t[i] = type, x_[i] = x;       if (type == 1) {         v[x].insert(i);         f.push_back(i);         ans++;       } else if (type == 2) {         ans -= (int)v[x].size();         v[x].clear();       } else if (type == 3)         if (last < f[x]) {           for (int j = lastx + 1; j <= x; j++) {             int id = f[j];             if (v[x_[id]].find(id) != v[x_[id]].end()) v[x_[id]].erase(id), ans--;           }           last = f[x], lastx = x;         }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, a, b;     cin >> n >> a >> b;     int r = 0;     for (int i = 1; i < 300; i++) {       int x1 = a / i;       int x2 = b / i;       if (x1 + x2 >= n && x1 != 0 && x2 != 0) r = i;     }     cout << r;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5;   long long dmod(long long x, long long MOD) { return x % MOD; }   long long m;   long long fe(long long x, long long p) {     if (p == 0) return 1;     long long ret = fe(x, p / 2);     ret = dmod(ret * ret, m);     if (p & 1) ret = dmod(ret * x, m);     return ret;   }   int n;   long long li[N + 5];   set<long long> ada;   long long get_count(long long x) {     long long ret = 0;     for (int i = 1; i <= n; i++) {       long long cur = (li[i] + x) % m;       if (ada.find(cur) != ada.end()) ret++;     }     return ret;   }   bool proc() {     if (2 * n < m) return 0;     set<long long> tmp;     long long cur = 0;     for (int i = 1; i <= n; i++) {       while (cur != li[i]) tmp.insert(cur++);       cur++;     }     while (cur != m) tmp.insert(cur++);     int id = 0;     for (auto x : tmp) {       id++;       li[id] = x;     }     n = id;     return 1;   }   int main() {     scanf( %d%d , &m, &n);     for (int i = 1; i <= n; i++) scanf( %lld , &li[i]);     if (n == 1) {       printf( %lld 0 n , li[1]);       return 0;     } else if (m == 2 || n == m) {       printf( 0 1 n );       return 0;     } else if (n == m - 1) {       sort(li + 1, li + n + 1);       for (int i = 1; i <= n; i++) {         if (li[i] != (i - 1)) {           printf( %d 1 n , i);           return 0;         }       }       printf( 0 1 n );       return 0;     }     sort(li + 1, li + n + 1);     bool tukar = proc();     for (int i = 1; i <= n; i++) ada.insert(li[i]);     long long dif = li[2] - li[1];     long long cnt = get_count(dif);     long long inv = fe(n - cnt, m - 2);     dif = dmod(dif * inv, m);     deque<long long> dq;     dq.push_front(li[1]);     while (1) {       long long now = dq.front();       now = dmod(now - dif + m, m);       if (ada.find(now) != ada.end())         dq.push_front(now);       else         break;     }     while (1) {       long long now = dq.back();       now = dmod(now + dif, m);       if (ada.find(now) != ada.end())         dq.push_back(now);       else         break;     }     if (dq.size() != n) {       printf( -1 n );       return 0;     }     if (tukar) {       printf( %lld %lld n , dmod(dq.back() + dif, m), dif);     } else {       printf( %lld %lld n , dq.front(), dif);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long dp[300300];   int a[300300], h[300300], d[300300];   vector<int> ans;   inline void calc(int i) {     int mn = min(a[i], a[i + 1]);     if (!mn) return;     ans.push_back(i);     a[i] -= mn, a[i + 1] -= mn;   }   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , a + i);     for (int i = 1; i <= 2; i++) dp[i] = a[i], d[i] = 1;     for (int i = 3; i <= n; i++) {       if (dp[i - 2] + a[i] < dp[i - 3] + max(a[i], a[i - 1]))         dp[i] = dp[i - 2] + a[i], d[i] = 1;       else         dp[i] = dp[i - 3] + max(a[i], a[i - 1]), d[i] = 2;     }     for (int i = n - (dp[n] >= dp[n - 1]); i > 0; i -= d[i] + 1) {       h[i] = h[i - d[i] + 1] = 1;     }     for (int i = 1; i <= n; i++)       if (h[i]) {         if (h[i + 1]) calc(i);         calc(i - 1), calc(i);       }     printf( %d n , ans.size());     for (int x : ans) printf( %d n , x);   }
#include <bits/stdc++.h>   using namespace std;   vector<string> a;   long long i, j, k, sumA = 0, sumB = 0, min_sumA = 8, min_sumB = 8;   string t;   int main() {     for (i = 0; i < 8; i++) {       cin >> t;       a.push_back(t);     }     for (i = 0; i < 8; i++)       for (j = 0; j < 8; j++) {         sumA = sumB = 0;         if (a[i][j] ==  W ) {           for (k = i - 1; k >= 0; k--)             if (a[k][j] !=  B )               ++sumA;             else {               sumA = min_sumA;               break;             }           sumB = min_sumB;         } else if (a[i][j] ==  B ) {           for (k = i + 1; k < 8; k++)             if (a[k][j] !=  W )               ++sumB;             else {               sumB = min_sumB;               break;             }           sumA = min_sumA;         } else {           sumA = min_sumA;           sumB = min_sumB;         }         if (sumA < min_sumA) min_sumA = sumA;         if (sumB < min_sumB) min_sumB = sumB;       }     if (min_sumA <= min_sumB)       printf( A );     else       printf( B );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool good(int x, int y, int n) { return x >= 0 && y >= 0 && x < n && y < n; }   int main() {     cin.tie(0);     cin.sync_with_stdio(0);     int x;     cin >> x;     for (int i = 1; i <= 200; i += 2) {       int n = i;       int o = 1;       int t = (n / 2) * 2;       int f = (n / 2) * (n / 2);       int O = 1;       int T = t;       int F = f;       if ((n / 2) % 2 == 0) {         t = T / 2;         f = F / 2;         int X = x;         if (X % 2) X--;         while (f) {           if (X - 4 >= 0) X -= 4;           f--;         }         while (t) {           if (X - 2 >= 0) X -= 2;           t--;         }         if (X == 0) {           cout << n;           return 0;         }       } else {         int X = x;         o = 0;         t = ((n / 2) / 2 + 1) * 2;         f = ((n / 2) * (n / 2)) / 2;         while (f) {           if (X - 4 >= 0) X -= 4;           f--;         }         while (t) {           if (X - 2 >= 0) X -= 2;           t--;         }         if (X == 0) {           cout << n;           return 0;         }         X = x;         o = 1;         t = ((n / 2) / 2) * 2;         f = (((n / 2) * (n / 2)) / 2) + 1;         if (X % 2) X--;         while (f) {           if (X - 4 >= 0) X -= 4;           f--;         }         while (t) {           if (X - 2 >= 0) X -= 2;           t--;         }         if (X == 0) {           cout << n;           return 0;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int Maxn = 3e5 + 10;   const int lim = 1000;   int prime[Maxn], M[Maxn], H[Maxn], cnt;   bool vis[Maxn];   struct node {     int v, c, l;   } a[Maxn];   int cmp(node A, node B) { return A.l < B.l; }   int n, k;   int main() {     int cnt = 0;     vis[0] = vis[1] = 1;     for (int i = 2; i <= 3e5; i++) {       if (!vis[i]) prime[++cnt] = i;       for (int j = 1; j <= cnt && i * prime[j] <= 3e5; j++) {         vis[i * prime[j]] = 1;         if (i % prime[j] == 0) break;       }     }     scanf( %d %d , &n, &k);     for (int i = 1; i <= n; i++) scanf( %d %d %d , &a[i].v, &a[i].c, &a[i].l);     sort(a + 1, a + n + 1, cmp);     for (int i = 1; i <= n; i++) M[a[i].l] = i;     int ans = 0, sum, top;     for (int i = 1; i <= n; i++) {       if (!M[i]) continue;       for (int h = 0; h < lim; h++) {         random_shuffle(a + 1, a + M[i] + 1);         top = 0, sum = 0;         for (int j = 1; j <= M[i]; j++) {           bool _ = 1;           for (int q = 0; q < top; q++)             if (!vis[a[j].c + a[H[q]].c]) {               _ = 0;               break;             }           if (_) {             H[top++] = j;             sum += a[j].v;           }         }         if (sum >= k) return 0 * printf( %d n , i);       }     }     puts( -1 );   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100000 + 10;   struct TreeNode {     int L, R;     pair<double, double> val;   } tree[maxn << 2];   int a[maxn], b[maxn], n, q;   void pushUp(int root) {     tree[root].val.first =         tree[root << 1].val.first * tree[root << 1 | 1].val.first;     tree[root].val.second =         tree[root << 1].val.second +         tree[root << 1].val.first * tree[root << 1 | 1].val.second;   }   void build(int L, int R, int root) {     tree[root].L = L;     tree[root].R = R;     if (L == R) {       return;     }     int mid = (L + R) >> 1;     build(L, mid, root << 1);     build(mid + 1, R, root << 1 | 1);   }   void update(int pos, pair<double, double> val, int root) {     int L = tree[root].L, R = tree[root].R;     if (L == R) {       tree[root].val = val;       return;     }     int mid = (L + R) >> 1;     if (pos <= mid) {       update(pos, val, root << 1);     } else {       update(pos, val, root << 1 | 1);     }     pushUp(root);   }   pair<double, double> query(int ql, int qr, int root) {     int L = tree[root].L, R = tree[root].R;     if (L >= ql && R <= qr) return tree[root].val;     int mid = (L + R) >> 1;     pair<double, double> a = make_pair(1.0, 0.0), b = make_pair(1.0, 0.0), c;     if (ql <= mid) {       a = query(ql, qr, root << 1);     }     if (qr > mid) {       b = query(ql, qr, root << 1 | 1);     }     c.first = a.first * b.first;     c.second = a.second + a.first * b.second;     return c;   }   int main() {     cin >> n >> q;     build(1, n, 1);     for (int i = 1; i <= n; i++) {       double x, y;       cin >> x >> y;       double p = x / y;       update(i, make_pair((1 - p) / p, (1 - p) / p), 1);     }     while (q--) {       int type;       cin >> type;       if (type == 1) {         int i, x, y;         scanf( %d%d%d , &i, &x, &y);         double p = double(x) / y;         update(i, make_pair((1.0 - p) / p, (1.0 - p) / p), 1);       } else {         int l, r;         scanf( %d%d , &l, &r);         pair<double, double> t = query(l, r, 1);         double p = t.second;         if (p < 1e20)           printf( %.6lf n , 1.0 / (1 + p));         else           cout <<  0.0000000  << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, a, b, minn = 1000;     long long res = 0;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d%d , &a, &b);       minn = min(minn, b);       res += minn * a;     }     printf( %d , res);     return 0;   }