malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int a[7];   int b[7];   int main() {     string s;     int k;     cin >> s >> k;     int kol = 0;     for (int i = 0; i < s.length(); i++) {       if (s[i] ==  0 ) {         kol++;       }     }     if (kol < k) {       cout << s.length() - 1;     } else {       kol = 0;       int res = 0;       for (int i = s.length() - 1; i >= 0; i--) {         if (s[i] ==  0 ) {           kol++;         } else {           res++;         }         if (kol == k) {           cout << res;           return 0;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char s1[5010], s2[5010], str[5010];   int num[30];   int len1, len2;   int dfs(int k, int m) {     if (!s1[k]) return m;     for (int i = 0; i < 26; i++)       if (num[i] && (m || (i >= s2[k] -  a ))) {         str[k] = i +  a ;         num[i]--;         if (dfs(k + 1, m || (i > s2[k] -  a ))) return 1;         num[i]++;       }     return 0;   }   int main() {     while (EOF != scanf( %s %s , s1, s2)) {       memset(num, 0, sizeof(num));       len1 = strlen(s1), len2 = strlen(s2);       for (int i = 0; i < len1; i++) num[s1[i] -  a ]++;       if (!dfs(0, 0))         printf( -1 n );       else {         printf( %s n , str);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct Rectangle {     int x1;     int x2;     int y1;     int y2;     Rectangle() {}     Rectangle(int a, int b, int c, int d) {       x1 = a;       y1 = b;       x2 = c;       y2 = d;       if (x1 > x2) {         swap(x1, x2);       }       if (y1 > y2) {         swap(y1, y2);       }     }     bool operator<(Rectangle r) const {       if (x1 != r.x1) {         return x1 < r.x1;       } else if (x2 != r.x2) {         return x2 < r.x2;       } else if (y1 != r.y1) {         return y1 < r.y1;       } else {         return y2 < r.y2;       }     }   };   int Area(Rectangle r) { return (r.x2 - r.x1) * (r.y2 - r.y1); }   set<Rectangle> rec;   set<Rectangle> lines;   int main() {     int W, H, N;     scanf( %d , &W);     ;     scanf( %d , &H);     ;     scanf( %d , &N);     ;     rec.insert(Rectangle(0, 0, W, H));     for (int(n) = 0; n < (int)N; n++) {       int a, b, c, d;       scanf( %d , &a);       ;       scanf( %d , &b);       ;       scanf( %d , &c);       ;       scanf( %d , &d);       ;       lines.insert(Rectangle(a, b, c, d));     }     for (int(n) = 0; n < (int)N; n++) {       for (__typeof(rec).begin() t = rec.begin(); t != rec.end(); t++) {         Rectangle r = *t;         for (__typeof(lines).begin() it = lines.begin(); it != lines.end();              it++) {           if (it->x1 == it->x2) {             if (r.x1 < it->x1 && it->x2 < r.x2 && r.y1 == it->y1 &&                 r.y2 == it->y2) {               lines.erase(lines.find(*it));               rec.erase(*t);               rec.insert(Rectangle(r.x1, r.y1, it->x2, r.y2));               rec.insert(Rectangle(it->x2, r.y1, r.x2, r.y2));               goto end;             }           } else if (it->y1 == it->y2) {             if (r.y1 < it->y1 && it->y2 < r.y2 && r.x1 == it->x1 &&                 r.x2 == it->x2) {               lines.erase(lines.find(*it));               rec.erase(*t);               rec.insert(Rectangle(r.x1, r.y1, r.x2, it->y1));               rec.insert(Rectangle(r.x1, it->y1, r.x2, r.y2));               goto end;             }           }         }       }     end:       int sol = 42;     }     vector<int> res;     for (__typeof(rec).begin() it = rec.begin(); it != rec.end(); it++) {       res.push_back(Area(*it));     }     sort(res.begin(), res.end());     for (__typeof(res).begin() it = res.begin(); it != res.end(); it++) {       printf(  %d , *it);     }     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 1e3 + 10;   long long q, x, v, u, w, ans;   map<long long, long long> len;   int main() {     cin >> q;     for (int i = 1; i <= q; i++) {       cin >> x >> v >> u;       if (x == 1) {         cin >> w;         while (v != u) {           if (v > u) {             len[v] += w;             v = v / 2;           } else {             len[u] += w;             u = u / 2;           }         }       } else {         ans = 0;         while (v != u) {           if (v > u) {             ans += len[v];             v = v / 2;           } else {             ans += len[u];             u = u / 2;           }         }         cout << ans <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1000000000000000000ll;   long long x[6], y[6];   int main() {     ios_base::sync_with_stdio(0);     int n;     cin >> n;     for (int i = 0; i < n; i++) cin >> x[i] >> y[i];     if (n == 1) {       cout << -1 << endl;       return 0;     }     if (n == 2) {       if (x[0] == x[1] || y[0] == y[1]) {         cout << -1 << endl;         return 0;       }       long long s = (abs(x[0] - x[1]) * abs(y[0] - y[1]));       cout << s << endl;       return 0;     }     long long X = 0, Y = 0;     for (int i = 1; i < n; i++) {       X = max(X, abs(x[0] - x[i]));       Y = max(Y, abs(y[0] - y[i]));     }     cout << X * Y << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const long long LINF = 0x3f3f3f3f3f3f3f3f;   const int MOD = (int)1e9 + 7;   const int N = (int)3e5 + 7;   char read_char() {     char c;     for (;;) {       c = getchar();       if (c >=  A  && c <=  Z ) return c;     }   }   long long powmod(long long a, long long b) {     long long res = 1;     a %= MOD;     for (; b; b >>= 1) {       if (b & 1) res = res * a % MOD;       a = a * a % MOD;     }     return res;   }   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   long long add(long long a, long long b) {     a = ((a + b) % MOD + MOD) % MOD;     return a;   }   long long mul(long long a, long long b) { return a * b % MOD; }   int n, p, cnt[N], tmp[N];   pair<int, int> a[N];   void Init() {     memset(cnt, 0, sizeof(cnt));     for (int i = (0); i < (n); ++i) {       int u, v;       scanf( %d%d , &u, &v);       if (u > v) swap(u, v);       a[i].first = u, a[i].second = v;       cnt[u]++;       cnt[v]++;     }     for (int i = (1); i < (n + 1); ++i) tmp[i] = cnt[i];     sort(tmp + 1, tmp + n + 1);     sort(a, a + n);   }   int Solve() {     long long ans = 0;     for (int i = n, j = 1; j < i; i--) {       while (tmp[j] + tmp[i] < p && j < i) j++;       ans += i - j;     }     for (int i = 0, j; i < n; i = j) {       j = i + 1;       while (j < n && a[i] == a[j]) j++;       int u = a[i].first, v = a[i].second;       if (cnt[u] + cnt[v] >= p && cnt[u] + cnt[v] - (j - i) < p) {         ans--;       }     }     return !printf( %lld n , ans);   }   int main() {     while (~scanf( %d%d , &n, &p)) {       Init();       Solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<long long, long long> s;   long long n, b[500005], c[500005];   int main() {     cin >> n;     for (int i = 0; i < n; i++) {       long long x;       cin >> x;       s[x]++;     }     long long m, mx1 = 0, mx2 = 0, index = 1;     cin >> m;     for (int i = 0; i < m; i++) {       cin >> b[i];     }     for (int i = 0; i < m; i++) {       cin >> c[i];     }     for (int i = 0; i < m; i++) {       if (s[b[i]] > mx1) {         mx1 = s[b[i]];         index = i + 1;       }     }     for (int i = 0; i < m; i++) {       if (s[b[i]] == mx1) {         if (s[c[i]] > mx2) {           index = i + 1;           mx2 = s[c[i]];         }       }     }     cout << index << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX_N = 1010;   const double EPS = 0.0000001;   struct Point {     int x, y;     Point() {}     Point(int a, int b) : x(a), y(b) {}   };   int n;   long long k;   Point centers[MAX_N];   int radii[MAX_N];   double GetDist(int x1, int y1, int x2, int y2) {     return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));   }   void AddEvents(vector<pair<double, int> > &events, double ang1, double ang2) {     for (int i = 0; i < 3; ++i) {       events.push_back(make_pair(ang1 + i * 2 * M_PI + EPS, 1));       events.push_back(make_pair(ang2 + i * 2 * M_PI - EPS, -1));     }   }   int main() {     cin >> n >> k;     for (int i = 1; i <= n; ++i) {       int x, y;       cin >> x >> y >> radii[i];       centers[i] = Point(x, y);     }     int best = 0;     for (int i = 1; i <= n; ++i) {       vector<pair<double, int> > events;       int cnt = 0;       for (int j = 1; j <= n; ++j) {         if (i != j) {           double ang =               atan2(centers[j].y - centers[i].y, centers[j].x - centers[i].x);           double d =               GetDist(centers[i].x, centers[i].y, centers[j].x, centers[j].y);           double u1 = asin((radii[i] - radii[j]) / d);           double u2 = asin((radii[i] + radii[j]) / d);           AddEvents(events, ang + u1 - M_PI / 2, ang + u2 - M_PI / 2);           AddEvents(events, ang - u2 + M_PI / 2, ang - u1 + M_PI / 2);         }       }       sort(events.begin(), events.end());       for (size_t j = 0; j < events.size(); ++j) {         cnt += events[j].second;         if (cnt < 0) {           cnt = 0;         }         best = max(best, cnt);       }     }     long long sol = k * (k + 1) / 2 + (k + 1) * best + (n - best);     cout << sol << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long calc(const long long &x, const long long &pow, const long long &pp) {     long long res = 1, tmp = (x % pp);     long long cur = pow;     while (cur > 0) {       if (cur % 2 == 0) {         tmp = (tmp * tmp) % pp;         cur = cur / 2;       } else {         res = (res * tmp) % pp;         cur = cur - 1;       }     }     return res;   }   int obr() {     long long k, l, r, p;     cin >> k >> l >> r >> p;     long long ans;     if (p == 2) {       cout << (1 - (k % 2)) << endl;       return 0;     }     if (k == 1)       ans = 2 % p;     else {       long long st_l = calc(2, l, p - 1), st_r = calc(2, r + 1, p - 1);       long long rev_2 = (p + 1) / 2;       long long ch = (calc(k, st_r, p) + p - 1) % p;       long long zn = (calc(k, st_l, p) + p - 1) % p;       if (k % p == 0) zn = ch = p - 1;       if (zn == 0) {         ch = calc(2, r - l + 1, p);       } else {         zn = calc(zn, p - 2, p);         ch = (ch * zn) % p;       }       if (k % 2) {         long long to_div = calc(rev_2, r - l, p);         ch = (ch * to_div) % p;       }       ans = ch;     }     cout << ans << endl;     return 0;   }   int main() {     ios_base::sync_with_stdio(false);     int t;     cin >> t;     for (int i = 1; i <= t; ++i) obr();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   int x[500010], y[500010];   bitset<2010 * 2> A[2010];   void Work() {     for (int i = 1; i <= n; i++) {       int t = i;       for (int j = i + 1; j <= n; j++)         if (A[j][i]) t = j;       swap(A[i], A[t]);       for (int j = 1; j <= n; j++)         if (A[j][i] && j != i) A[j] ^= A[i];     }     for (int i = 1; i <= m; i++)       if (A[y[i]][x[i] + n])         puts( NO );       else         puts( YES );   }   void Init() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; i++) {       scanf( %d%d , &x[i], &y[i]);       A[x[i]][y[i]] = 1;     }     for (int i = 1; i <= n; i++) A[i][i + n] = 1;   }   int main() {     Init();     Work();     return 0;   }
#include <bits/stdc++.h>   const int MAXN = 60;   int n, P, A[MAXN];   const int mod = 1000000007;   void reduce(int& x) { x += x >> 31 & mod; }   int mul(int a, int b) { return (long long)a * b % mod; }   int pow(int a, int b, int res = 1) {     for (; b; b >>= 1, a = mul(a, a))       if (b & 1) res = mul(res, a);     return res;   }   int dp[MAXN][MAXN][MAXN];   int main() {     std::ios_base::sync_with_stdio(false), std::cin.tie(0);     std::cin >> n >> P;     for (int i = 1; i <= n; ++i) std::cin >> A[i];     dp[0][0][0] = 1;     for (int i = 1; i <= n; ++i)       for (int j = 0; j <= i; ++j)         for (int k = 0; k <= i; ++k)           if (dp[i - 1][j][k]) {             if (A[i] == 0 || A[i] == -1) {               int t = pow(2, i - 1 - (!!k), dp[i - 1][j][k]);               reduce(dp[i][j + 1][k] += t - mod);               if (k) reduce(dp[i][j][k] += t - mod);             }             if (A[i] == 1 || A[i] == -1) {               int t = pow(2, i - 1 - (!!j), dp[i - 1][j][k]);               reduce(dp[i][j][k + 1] += t - mod);               if (j) reduce(dp[i][j][k] += t - mod);             }           }     int ans = 0;     for (int i = 0; i <= n; ++i)       for (int j = 0; j <= n; ++j)         if ((i + j & 1) == P) reduce(ans += dp[n][i][j] - mod);     std::cout << ans << std::endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     char s[200001], t1[200001];     long long n, x, y, t, con = 0;     cin >> n >> x >> y;     getchar();     gets(s);     t = n - x;     for (long long i = t; s[i] !=   0 ; i++) {       if (i == n - 1 - y && s[i] !=  1 ) con++;       if (i != n - 1 - y && s[i] !=  0 ) con++;     }     cout << con << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int k, r;     cin >> k >> r;     int n = 1;     while (true) {       if ((k * n - r) % 10 == 0 || (k * n) % 10 == 0) {         cout << n <<   n ;         return 0;       }       n++;     }   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   using namespace std;   template <class c>   struct rge {     c b, e;   };   template <class c>   rge<c> range(c h, c n) {     return {h, n};   }   template <class c>   auto dud(c* r) -> decltype(cerr << *r);   template <class c>   char dud(...);   struct muu {     template <class c>     muu& operator<<(const c&) {       return *this;     }     muu& operator()() { return *this; }   };   const int N = 1e5 + 7;   long long tab[N];   int n;   long long inf = 1e18;   void fail() {     printf( No n );     exit(0);   }   int main() {     scanf( %d , &n);     for (int i = 2; i <= n; i += 2) scanf( %lld , tab + i);     long long sum = 0;     for (int i = 2; i <= n; i += 2) {       long long nsum = inf;       for (int d = 1; d * d <= tab[i]; ++d) {         if (tab[i] % d == 0) {           long long a = (tab[i] / d) - d;           long long b = (tab[i] / d) + d;           if (a % 2 == 0 && b % 2 == 0) {             if (a * a > 4 * sum) {               nsum = min(nsum, (b * b) / 4);             }           }         }       }       (muu() << __FUNCTION__ <<  #  << 67 <<  :  ) << i <<     << nsum;       if (nsum == inf) fail();       tab[i - 1] = nsum - sum - tab[i];       sum = nsum;     }     printf( Yes n );     for (int i = 1; i <= n; ++i) printf( %lld  , tab[i]);     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3e5 + 50;   vector<int> e[N];   int dp[N], res, deg[N];   void dfs(int u, int pre) {     dp[u] = deg[u];     for (int v : e[u]) {       if (v == pre) continue;       dfs(v, u);       res = max(res, dp[u] + dp[v]);       dp[u] = max(dp[u], dp[v] + deg[u] - 2 + 1);     }   }   int main() {     int t;     scanf( %d , &t);     while (t--) {       int n;       scanf( %d , &n);       for (int i = 1; i <= n; i++) e[i].clear(), deg[i] = 0;       for (int i = 0; i < n - 1; i++) {         int u, v;         scanf( %d%d , &u, &v);         e[u].push_back(v);         e[v].push_back(u);         deg[u]++;         deg[v]++;       }       res = 0;       dfs(1, 0);       printf( %d n , res);     }   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   const int maxN = (int)1e6 + 10;   vector<int> g[maxN];   int p[maxN];   int a[maxN];   long long s = 0;   long long tr[maxN];   set<long long> all;   void dfs(int v) {     tr[v] = a[v];     for (int to : g[v]) {       dfs(to);       tr[v] += tr[to];     }     if (s % tr[v] == 0) {       all.insert(tr[v]);     }   }   int val[maxN];   const int mod = (int)1e9 + 7;   int sum(int a, int b) {     int s = a + b;     if (s >= mod) s -= mod;     return s;   }   set<long long> ok;   long long id[maxN];   long long sm[maxN];   map<long long, int> f;   int dp[maxN];   int main() {     ios_base::sync_with_stdio(false);     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i];       s += a[i];     }     for (int i = 1; i < n; i++) {       cin >> p[i];       g[p[i]].push_back(i + 1);     }     dfs(1);     int sz = 1;     int oth = 1;     for (long long t : all) {       memset(sm, 0, sizeof sm);       bool can = true;       for (int i = n; i >= 1; i--) {         if (sm[i] + a[i] > t) {           can = false;           break;         }         if (sm[i] + a[i] == t) {           continue;         }         if (i == 1) {           can = false;           break;         }         sm[p[i - 1]] += (sm[i] + a[i]);       }       if (can) {         f[t] = oth;         oth++;         ok.insert(t);       }     }     for (long long x : ok) {       int id = f[x];       dp[id] = 1;       for (long long y : ok) {         if (y >= x) continue;         if (x % y == 0) dp[id] = sum(dp[id], dp[f[y]]);       }     }     cout << dp[f[s]];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const long long LINF = 0x3f3f3f3f3f3f3f3f;   const int MOD = (int)1e9 + 7;   const int N = (int)2e5 + 7;   int tree[N << 1];   void update(int x, int n) {     x += n;     if (tree[x]) return;     while (x) {       tree[x]++;       x >>= 1;     }   }   int query(int l, int r, int n) {     int re = 0;     l += n, r += n;     while (l <= r) {       if (l & 1) re += tree[l++];       if (~r & 1) re += tree[r--];       l >>= 1, r >>= 1;     }     return re;   }   pair<int, int> p[N];   vector<int> x;   int l[N];   int main() {     int n;     scanf( %d , &n);     for (int i = (0); i < (n); ++i) {       scanf( %d%d , &p[i].first, &p[i].second);       x.push_back(p[i].first);     }     sort((x).begin(), (x).end());     sort(p, p + n);     for (int i = (0); i < (n); ++i) {       p[i].first = lower_bound((x).begin(), (x).end(), p[i].first) - x.begin();       swap(p[i].first, p[i].second);     }     sort(p, p + n);     long long ans = 0;     for (int i = n - 1, j; i >= 0; i = j) {       for (j = i; j >= 0 && p[i].first == p[j].first; j--)         ;       int z = 0;       for (int k = (j + 1); k < (i + 1); ++k) {         l[k] = query(z, p[k].second - 1, n);         update(p[k].second, n);         z = p[k].second + 1;       }       for (int k = (j + 1); k < (i + 1); ++k) {         ans += (long long)(l[k] + 1) * (query(p[k].second + 1, n, n) + 1);       }     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long exp(long long x, long long y) {     x %= 1000000007;     long long res = 1;     while (y) {       if (y & 1) res = res * x % 1000000007;       x = x * x % 1000000007;       y >>= 1;     }     return res;   }   long long fact(long long n) {     long long res = 1;     for (long long i = 2; i <= n; ++i) (res *= i) %= 1000000007;     return res;   }   bool isprime(long long n) {     for (long long i = 2; i * i <= n; ++i)       if (n % i == 0) return 0;     return 1;   }   int main() {     int n, m;     cin >> n >> m;     const long long inf = 1e17;     vector<long long> sum(n), pre(n), s(n);     vector<long long> t(n);     for (int i = 0; i < n; ++i) {       int x;       cin >> x;       long long val = -inf;       long long mx = -inf;       vector<long long> v1, v2;       for (int j = 0; j < x; ++j) {         long long k;         cin >> k;         val = max(k, val + k);         mx = max(mx, val);         v1.push_back(k);         v2.push_back(k);       }       t[i] = mx;       for (int j = 1; j < x; ++j) v1[j] += v1[j - 1];       for (int j = x - 2; j >= 0; --j) v2[j] += v2[j + 1];       sum[i] = v1[x - 1];       pre[i] = *max_element(v1.begin(), v1.end());       s[i] = *max_element(v2.begin(), v2.end());     }     long long to = -inf;     vector<int> v(m + 1);     for (int i = 1; i <= m; ++i) {       cin >> v[i];       to = max(to, t[v[i] - 1]);     }     long long dp[m + 1][3];     memset(dp, 0, sizeof(dp));     for (int i = 1; i <= m; ++i) {       dp[i][0] = s[v[i] - 1];       dp[i][1] = max(dp[i - 1][0] + sum[v[i] - 1], dp[i - 1][1] + sum[v[i] - 1]);       dp[i][2] = max(dp[i - 1][0] + pre[v[i] - 1], dp[i - 1][1] + pre[v[i] - 1]);     }     long long ans = -inf;     for (int i = 1; i <= m; ++i) ans = max(ans, dp[i][2]);     cout << max(ans, to);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = -1;   struct disk {     long long L;     double p;     disk(long long L = 0, double p = 0.) : L(L), p(p) {}   };   bool operator<(disk a, disk b) {     return (a.L * a.p * (1 - b.p)) > (b.L * b.p * (1 - a.p));   }   int n;   vector<disk> P;   int main() {     while (cin >> n) {       P.resize(n);       for (int i = (0); i < (int)(n); i++)         scanf( %lld %lf , &P[i].L, &P[i].p), P[i].p /= 100;       sort(P.begin(), P.end());       double ans = 0., E = 0.;       for (int i = ((int)n) - 1; i >= 0; i--) {         disk D = P[i];         ans += D.L * (1 + E * D.p);         E = D.p * E + (1 - D.p) * (E + 1);       }       printf( %.6f n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long i, n, now, ans, hh, m, p = 1000000009;   int main() {     scanf( %lld , &n);     if (n == 2) {       puts( 10 );       return 0;     }     m = n / 2;     now = 4;     hh = 1;     for (i = 3; i <= m; i++) {       now = now * 2 % p;       hh = hh * (now - 3) % p;       ans = (ans + hh) % p;     }     ans = ans * 4 + 6;     ans %= p;     ans = ans * ans % p;     ans++;     ans = ans * 2 % p;     printf( %lld , ans);   }
#include <bits/stdc++.h>   using namespace std;   int m(int x, int md) { return (((x) % md) + md) % md; }   void solve() {     int n;     cin >> n;     vector<int> a(n);     for (int i = 0; i < n; i++) cin >> a[i];     set<int> st;     for (int r = 0; r < n; r++) {       st.insert(m(r + a[r], n));     }     if (st.size() == n)       cout <<  YES n ;     else       cout <<  NO n ;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int T;     cin >> T;     for (int testcase = 1; testcase <= T; testcase++) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct event {     int pos, type, p;     event(int pos = 0, int type = -1, int p = 0) : pos(pos), type(type), p(p) {}     bool operator<(const event &e) const {       if (pos == e.pos) return type < e.type;       return pos < e.pos;     }   };   const int maxE = 5e5 + 10;   event E[maxE];   int cnt[111];   double fpow(double a, int n) {     double r = 1;     for (; n; n = n >> 1) {       if (n & 1) r *= a;       a = a * a;     }     return r;   }   int main() {     memset((cnt), (0), sizeof(cnt));     int n, m, x, h, l, r, sz = 0, b, z;     scanf( %d%d , &n, &m);     for (int _n(n), i(0); i < _n; i++) {       scanf( %d%d%d%d , &x, &h, &l, &r);       l = 100 - l;       r = 100 - r;       E[sz++] = event(x - h, 0, l);       E[sz++] = event(x, 0, -1 - l);       E[sz++] = event(x + 1, 0, r);       E[sz++] = event(x + h + 1, 0, -1 - r);     }     for (int _n(m), i(0); i < _n; i++) {       scanf( %d%d , &b, &z);       E[sz++] = event(b, z);     }     sort(E, E + sz);     double expectation = 0, pro = 0;     for (int _n(sz), i(0); i < _n; i++) {       if (E[i].type == 0) {         if (E[i].p >= 0) {           cnt[E[i].p]++;         } else           cnt[-E[i].p - 1]--;       } else {         pro = 1;         for (int _n(101), i(0); i < _n; i++) pro *= fpow(0.01 * i, cnt[i]);         expectation += pro * E[i].type;       }     }     printf( %.7f n , expectation);     return 0;   }