malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   inline long long read() {     long long x = 0, f = 0;     char ch = getchar();     while (!isdigit(ch)) f |= (ch ==  - ), ch = getchar();     while (isdigit(ch)) x = x * 10 + ch -  0 , ch = getchar();     return f ? -x : x;   }   inline void write(long long x) {     if (x < 0) x = -x, putchar( - );     if (x >= 10) write(x / 10);     putchar(x % 10 +  0 );   }   long long n, a[200005], tot[200005], tong[105], mx, mxat, now;   signed main() {     n = read();     for (register long long i = 1; i <= n; i++) {       a[i] = read();       now = a[i];       while (now && now % 2 == 0) {         tot[i]++;         now /= 2;       }       tong[tot[i]]++;       if (tong[tot[i]] > mx) mx = tong[tot[i]], mxat = tot[i];     }     write(n - mx);     puts(  );     for (register long long i = 1; i <= n; i++)       if (tot[i] != mxat) write(a[i]), putchar(   );     return 0;   }
#include <bits/stdc++.h>   int main() {     int loop, cnt = 1, max = 1;     scanf( %d , &loop);     int arr[loop];     for (int i = 0; i < loop; i++) scanf( %d , &arr[i]);     for (int i = 1; i < loop; i++) {       if (arr[i - 1] >= arr[i]) {         cnt = 1;       }       if (arr[i - 1] < arr[i]) {         cnt++;       }       if (max < cnt) max = cnt;     }     printf( %d , max);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   multiset<int> ms;   const int MAXN = 1000000;   int pos[MAXN], a[MAXN], b[MAXN], st[MAXN];   int n, i, j, k, ans;   int main() {     scanf( %d , &n);     for (i = 1; i <= n; ++i) {       scanf( %d , &a[i]);       pos[a[i]] = i;     }     for (j = 1; j <= n; ++j) {       scanf( %d , &b[j]);       int diff = j - pos[b[j]];       st[j] = diff;       ms.insert(diff);     }     for (i = 0; i < n; ++i) {       ans = n;       multiset<int>::iterator it = ms.lower_bound(i);       if (it != ms.end()) ans = min(ans, abs(*(it)-i));       if (it != ms.begin()) ans = min(ans, abs(*(--it) - i));       cout << ans << endl;       ms.erase(ms.find(st[i + 1]));       int num = b[i + 1];       ms.insert((i + n + 1) - pos[num]);     }   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC optimize( unroll-loops )   using namespace std;   const long long N = 1000 + 5, L = 12, inf = LLONG_MAX;   long long n, m, k;   long long a[N][N], par[N * N], sz[N * N], res[N][N], hh, cnt;   bool mark[N][N], vis[N][N];   long long mp[N * N];   vector<pair<long long, long long> > vec, all;   set<long long> s;   long long H[] = {0, 0, -1, 1};   long long G[] = {1, -1, 0, 0};   inline void er(long long x) {     mp[x]--;     if (mp[x] == 0) {       s.erase(-x);     }     return;   }   inline void ad(long long x) {     mp[x]++;     if (mp[x] == 1) {       s.insert(-x);     }     return;   }   long long find(long long a) {     if (par[a] == a) return a;     return par[a] = find(par[a]);   }   inline void _union(long long a, long long b) {     a = find(a);     b = find(b);     if (a == b) return;     if (sz[a] < sz[b]) swap(a, b);     er(sz[a]);     er(sz[b]);     par[b] = a;     sz[a] += sz[b];     ad(sz[a]);     return;   }   void dfs(long long x, long long y) {     vis[x][y] = 1;     all.push_back({x, y});     for (long long k = 0; k < 4; k++) {       long long i = x + H[k], j = y + G[k];       if (i >= 0 && j >= 0 && i < n && j < m) {         if (!vis[i][j] && a[i][j] >= hh) {           dfs(i, j);         }       }     }     return;   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(nullptr);     cout.tie(nullptr);     ;     cin >> n >> m >> k;     for (long long i = 0; i < n * m; i++) par[i] = i, sz[i] = 1;     s.insert(-1);     mp[1] = n * m;     for (long long i = 0; i < n; i++)       for (long long j = 0; j < m; j++) {         cin >> a[i][j];         vec.push_back({a[i][j], i * m + j});       }     sort(vec.begin(), vec.end(), greater<pair<long long, long long> >());     long long ans = -1, xx = -1, yy = -1;     for (auto p : vec) {       long long x = p.second / m, y = p.second % m, h = p.first;       mark[x][y] = 1;       for (long long k = 0; k < 4; k++) {         long long i = x + H[k], j = y + G[k];         if (i >= 0 && j >= 0 && i < n && j < m && mark[i][j]) {           _union(i * m + j, p.second);         }       }       if (k % h == 0) {         long long mx = sz[find(p.second)];         if (mx >= k / h) {           ans = mx;           hh = h;           xx = x;           yy = y;           break;         }       }     }     if (ans == -1) return cout <<  NO n , 0;     dfs(xx, yy);     cout <<  YES n ;     long long sum = 0;     for (auto p : all) {       res[p.first][p.second] = hh;       sum += hh;       if (sum == k) break;     }     for (long long i = 0; i < n; i++) {       for (long long j = 0; j < m; j++) cout << res[i][j] <<    ;       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, m;   long long dp[1501][1501];   long long a[1510][1501];   long long func(long long here, long long here1) {     if (here1 > m) return -999999999999999;     if (here1 < 1) return -999999999999999;     if (here == n + 1) return 0;     long long &ret = dp[here][here1];     if (ret != -1) return ret;     ret = -999999999999999;     if (here % 2) {       ret = max(ret, func(here, here1 + 1));       ret = max(ret, func(here + 1, here1 - 1) + a[here][here1]);     } else {       ret = max(ret, func(here, here1 - 1));       ret = max(ret, func(here + 1, here1 + 1) + a[here][here1]);     }     return ret;   }   int main() {     memset(dp, -1, sizeof(dp));     scanf( %lld %lld , &n, &m);     for (int i = 1; i <= n; i++) {       for (int y = 1; y <= m; y++) {         scanf( %lld , &a[i][y]);         a[i][y] += a[i][y - 1];       }     }     printf( %lld n , func(1, 1));   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, i, j, k, mod, dp[605][605], rd[605], xs[605][605], ans = 1;   vector<long long> ts, bi[605], nrd, ncd;   long long gcd(long long x, long long y) {     if (y == 0) return x;     return gcd(y, x % y);   }   long long lcm(long long x, long long y) { return x / gcd(x, y) * y; }   void dfs(int x) {     int i;     rd[x] = -1;     ts.push_back(x);     for (i = 0; i < bi[x].size(); i++) {       rd[bi[x][i]]--;       if (!rd[bi[x][i]]) {         dfs(bi[x][i]);       }     }   }   int main() {     ios_base::sync_with_stdio(0);     cin >> n >> m >> mod;     for (i = 1; i <= m; i++) {       int x, y;       cin >> x >> y;       bi[x].push_back(y);       rd[y]++;     }     for (i = 1; i <= n; i++) {       if (rd[i] == 0) nrd.push_back(i);       if (bi[i].size() == 0) ncd.push_back(i);     }     for (i = 0; i < nrd.size(); i++) {       dfs(nrd[i]);       dp[nrd[i]][nrd[i]] = 1;     }     for (i = 0; i < ts.size(); i++) {       for (j = 0; j < ts.size(); j++) {         for (k = 0; k < bi[ts[j]].size(); k++) {           dp[ts[i]][bi[ts[j]][k]] += dp[ts[i]][ts[j]];           dp[ts[i]][bi[ts[j]][k]] %= mod;         }       }     }     for (i = 0; i < nrd.size(); i++) {       for (j = 0; j < ncd.size(); j++) {         xs[i][j] = dp[nrd[i]][ncd[j]];       }     }     long long cnt = 0;     for (i = 0; i < ncd.size(); i++) {       for (j = i + 1; j < nrd.size(); j++) {         while (xs[j][i]) {           long long t = -xs[i][i] / xs[j][i];           for (k = i; k < nrd.size(); k++) {             xs[i][k] += t * xs[j][k];             xs[i][k] %= mod;             xs[i][k] += mod;             xs[i][k] %= mod;           }           for (k = i; k < nrd.size(); k++) {             swap(xs[i][k], xs[j][k]);           }           cnt++;         }       }     }     if (cnt & 1) ans = mod - 1;     for (i = 0; i < nrd.size(); i++) {       ans *= xs[i][i];       ans %= mod;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   signed main() {     string s;     cin >> s;     char zero =  0 ;     s =  00  + s;     long long n = (long long)s.size();     for (long long i = 0; i < n - 2; i++) {       long long temp = 100 * (s[i] - zero);       for (long long j = i + 1; j < n - 1; j++) {         temp += (10 * (s[j] - zero));         for (long long k = j + 1; k < n; k++) {           temp += (s[k] - zero);           if (temp % 8 == 0) {             cout <<  YES  <<   n ;             cout << temp <<   n ;             return 0;           }           temp -= (s[k] - zero);         }         temp -= (10 * (s[j] - zero));       }     }     cout <<  NO  <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int Q;     cin >> Q;     while (Q--) {       long long n, a, b, ans;       cin >> n >> a >> b;       double x = b / 2.0;       if (x > a) {         ans = a * n;         cout << ans << endl;       } else {         if (n % 2 == 0) {           ans = n / 2 * b;           cout << ans << endl;         } else {           ans = (n - 1) / 2 * b + a;           cout << ans << endl;         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   long long n, k, x, a, b, i, j, m[1000005], f[1000005];   multiset<long long> s;   pair<long long, long long> d[1000005];   vector<long long> v;   int main() {     ios::sync_with_stdio(0);     cin >> n >> k >> x;     while (i < n) {       cin >> m[i];       i++;     }     i = 0;     while (i < k) {       cin >> d[i].first;       d[i].second = i + 1;       i++;     }     i = 0;     sort(m, m + n);     sort(d, d + k);     s.insert(1000000001);     while (i < n) {       if (x * m[i] + x < i + 1)         return cout << -1, 0;       else         f[i] = x * m[i] + x - i - 1, s.insert(f[i]);       i++;     }     i = 0;     while (i < n + 1) {       while (j < k && a < *s.begin()) {         if (x * d[j].first + x >= i + a + 1) a++, v.push_back(d[j].second);         j++;       }       s.erase(s.lower_bound(f[i]));       i++;     }     i = 0;     cout << a << endl;     while (i < a) {       cout << v[i] <<    ;       i++;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int i, count = 0;     string str;     cin >> str;     int len = str.size();     for (i = 0; i < len; i++) {       if (str[i] ==  W  && str[i + 1] ==  U  && str[i + 2] ==  B ) {         i += 2;         if (count > 0) cout <<    ;       } else {         cout << str[i];         count = 1;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = 2e9;   int32_t main() {     cin.tie(0)->sync_with_stdio(0);     long long n, m;     string s, t;     cin >> n >> m >> s >> t;     vector<long long> pi(m, 0), nxt(m, 0);     for (long long i = 1; i < m; i++) {       {         t[i] = char( 0  + (t[i] -  0 ) ^ 1);         long long j = pi[i - 1];         while (j > 0 and t[i] != t[j]) {           j = pi[j - 1];         }         if (t[i] == t[j]) j++;         nxt[i] = j;         t[i] = char( 0  + (t[i] -  0 ) ^ 1);       }       {         long long j = pi[i - 1];         while (j > 0 and t[i] != t[j]) {           j = pi[j - 1];         }         if (t[i] == t[j]) j++;         pi[i] = j;       }     }     s =  #  + s;     long long dp[n + 1][m][n - m + 2];     fill(**dp, **dp + sizeof dp / sizeof(long long), inf);     dp[0][0][0] = 0;     for (long long i = 0; i < n; i++) {       for (long long j = 0; j < m; j++) {         for (long long k = 0; k < n - m + 2; k++) {           if (dp[i][j][k] == inf) continue;           if (j == m - 1) {             dp[i + 1][pi.back()][k + 1] = min(dp[i + 1][pi.back()][k + 1],                                               dp[i][j][k] + (s[i + 1] != t[j]));           } else {             dp[i + 1][j + 1][k] =                 min(dp[i + 1][j + 1][k], dp[i][j][k] + (s[i + 1] != t[j]));           }           dp[i + 1][nxt[j]][k] =               min(dp[i + 1][nxt[j]][k], dp[i][j][k] + (s[i + 1] == t[j]));         }       }     }     for (long long i = 0; i < n - m + 2; i++) {       long long mn = inf;       for (long long j = 0; j < m; j++) {         mn = min(mn, dp[n][j][i]);       }       if (mn == inf) mn = -1;       cout << mn <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       vector<pair<int, pair<int, int>>> v;       for (int i = 0; i < n; i++) {         int a, b;         cin >> a >> b;         v.push_back(make_pair(a, make_pair(b, i)));       }       sort(v.begin(), v.end());       int g[100001]{}, r = v[0].second.first;       g[v[0].second.second] = 1;       for (int i = 1; i < n; i++) {         if (v[i].first > r) break;         g[v[i].second.second] = 1;         r = max(r, v[i].second.first);       }       bool ans = true;       for (int i = 0; i < n && ans; i++) ans &= g[i];       if (ans) {         cout << -1 <<   n ;         continue;       }       for (int i = 0; i < n; i++) cout << g[i] + 1 <<    ;       cout <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   char A[300];   int cnt[5];   char data[5] =  ACGT ;   int main() {     int n;     scanf( %d , &n);     scanf( %s , A);     for (int i = 0; A[i]; i++) {       if (A[i] ==  A )         cnt[0]++;       else if (A[i] ==  C )         cnt[1]++;       else if (A[i] ==  G )         cnt[2]++;       else if (A[i] ==  T )         cnt[3]++;       else         cnt[4]++;     }     int big = 0, dif = 0;     ;     for (int i = 0; i < 4; i++) big = max(big, cnt[i]);     for (int i = 0; i < 4; i++) {       cnt[i] = big - cnt[i];       dif += cnt[i];     }     if (dif > cnt[4]) {       printf( === );       return 0;     }     if ((cnt[4] - dif) % 4 != 0) {       printf( === );       return 0;     }     int flag = 0;     for (int i = 0; A[i]; i++) {       if (A[i] ==  ? ) {         flag = 0;         for (int j = 0; j < 4; j++) {           if (cnt[j] > 0) {             A[i] = data[j];             cnt[j]--;             flag = 1;             break;           }         }         if (flag == 0) {           for (int j = 0; j < 4; j++) cnt[j]++;           i--;         }       }     }     printf( %s , A);   }
#include <bits/stdc++.h>   using namespace std;   int a[2];   string ans[2] = { Vladik ,  Valera };   int main() {     cin >> a[0] >> a[1];     int turn = 0;     int sub = 1;     while (true) {       if (a[turn] - sub >= 0) {         a[turn] -= sub;       } else {         break;       }       sub++;       turn = 1 - turn;     }     cout << ans[turn] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, loc[250] = {}, isi[250] = {}, idx = 0;   int kosong() {     for (int i = 0, _n = (n); i < _n; i++)       if (isi[i] == -1) return i;     return -111;   }   int main() {     memset(isi, -1, sizeof isi);     scanf( %d %d , &n, &m);     for (int i = 0, _n = (m); i < _n; i++) {       int a;       scanf( %d , &a);       for (int j = 0, _n = (a); j < _n; j++) {         int x;         scanf( %d , &x);         x--;         isi[x] = idx;         loc[idx] = x;         idx++;       }     }     vector<pair<int, int> > ans;     for (int i = 0, _n = (idx); i < _n; i++)       if (isi[i] != i) {         if (isi[i] == -1) {           ans.push_back(make_pair(loc[i], i));           isi[loc[i]] = -1;           loc[i] = i;           isi[i] = i;         } else {           int k = kosong();           ans.push_back(make_pair(i, k));           isi[k] = isi[i];           loc[isi[i]] = k;           isi[i] = -1;           i--;         }       }     printf( %d n , ans.size());     for (int i = 0, _n = (ans.size()); i < _n; i++)       printf( %d %d n , ans[i].first + 1, ans[i].second + 1);     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   using namespace std;   template <class T>   void dbg(const char* xn, T x) {     if (0) cout << xn <<  :   << x <<   n ;   }   template <class T, class... TA>   void dbg(const char* xn, T x, TA... t) {     while (*xn !=  , )       if (0) cout << *xn++;     if (0) cout <<  :   << x <<  , ;     dbg(xn + 1, t...);   }   template <class T>   inline bool upd_max(T& x, T y) {     return y > x ? x = y, true : false;   }   template <class T>   inline bool upd_min(T& x, T y) {     return y < x ? x = y, true : false;   }   const int N = 1000007;   long long n, m1 = 0, m0 = 0, n1 = 0, n0 = 0;   string A, B;   void solve() {     cin >> n;     cin >> A;     A =  #  + A;     cin >> B;     B =  #  + B;     for (long long i = 1; i <= (n); ++i) {       if (A[i] ==  1 )         ++n1;       else if (A[i] ==  0 )         ++n0;       if (A[i] ==  1  && B[i] ==  0 ) ++m1;       if (A[i] ==  0  && B[i] ==  0 ) ++m0;     }     cout << m1 * n0 + m0 * n1 - m1 * m0;   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout << fixed << setprecision(10);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int sz = 5005;   long long int x[sz];   long long int a[sz];   long long int b[sz];   long long int c[sz];   long long int d[sz];   int n, s, e;   const long long int Max = 1e16;   long long int dp[sz][sz];   long long int jumpl(int i) { return x[i] + c[i]; }   long long int jumpr(int i) { return -x[i] + d[i]; }   long long int landfr(int i) { return -x[i] + b[i]; }   long long int landfl(int i) { return x[i] + a[i]; }   long long int calc(int ch, int pl, int pr) {     if (pl < 0 || pr < 0) {       return Max;     }     if (dp[ch][pl] != 0) {       return dp[ch][pl];     }     if (ch == 0) {       if (s == 0) {         return calc(ch + 1, pl, pr + 1) + jumpr(ch);       } else if (e == 0) {         return calc(ch + 1, pl + 1, pr) + landfr(ch);       }       return calc(ch + 1, pl + 1, pr + 1) + landfr(ch) + jumpr(ch);     }     if (ch == n - 1) {       if (s == n - 1 && (pl == 1 && pr == 0)) {         return jumpl(ch);       } else if (e == n - 1 && (pl == 0 && pr == 1)) {         return landfl(ch);       } else if (pl == pr && pl == 1) {         return landfl(ch) + jumpl(ch);       } else {         return Max;       }     } else if (pl == 0 && pr == 0) {       return Max;     }     long long int m;     if (ch == s) {       m = min(calc(ch + 1, pl - 1, pr) + jumpl(ch),               calc(ch + 1, pl, pr + 1) + jumpr(ch));       dp[ch][pl] = m;       return m;     }     if (ch == e) {       m = min(calc(ch + 1, pl, pr - 1) + landfl(ch),               calc(ch + 1, pl + 1, pr) + landfr(ch));       dp[ch][pl] = m;       return m;     }     m = calc(ch + 1, pl + 1, pr + 1) + jumpr(ch) + landfr(ch);     m = min(m, calc(ch + 1, pl - 1, pr - 1) + jumpl(ch) + landfl(ch));     if (pr > 0) {       m = min(m, calc(ch + 1, pl, pr) + jumpr(ch) + landfl(ch));     }     if (pl > 0) {       m = min(m, calc(ch + 1, pl, pr) + jumpl(ch) + landfr(ch));     }     dp[ch][pl] = m;     return m;   }   int main() {     ios::sync_with_stdio(false);     cin >> n >> s >> e;     --s, --e;     for (int i = 0; i < n; ++i) {       cin >> x[i];     }     for (int i = 0; i < n; ++i) {       cin >> a[i];     }     for (int i = 0; i < n; ++i) {       cin >> b[i];     }     for (int i = 0; i < n; ++i) {       cin >> c[i];     }     for (int i = 0; i < n; ++i) {       cin >> d[i];     }     cout << calc(0, 0, 0) << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 200005;   int x[maxn], n, m;   int main() {     int ans = 0, use = 0;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> m;       x[m] = 0;     }     for (int i = 1; i <= n; i++) {       cin >> m;       x[m] = i;     }     for (int i = 1; x[i] <= n && i <= n && x[i + 1] == x[i] + 1; i++) use = i + 1;     if (use && x[use] == n) {       m = 0;       for (int i = use + 1; i <= n; i++) m = max(m, x[i] - (i - use - 1));       if (!m) {         cout << n - use <<   n ;         return 0;       }     }     if (x[1] && x[1] < n) {       for (int i = 2; i <= n; i++) x[i] = max(0, x[i] - x[1]);       ans += x[1];       x[1] = 0;     }     if (x[1] == n) {       m = 0;       for (int i = 2; i <= n; i++) m = max(m, x[i] - (i - 2));       if (m) {         cout << ans + 2 * n <<   n ;         return 0;       } else {         cout << ans + n - 1 <<   n ;         return 0;       }     }     m = 0;     for (int i = 2; i <= n; i++) m = max(m, x[i] - (i - 1));     cout << ans + m + n <<   n ;     return 0;   }
#include <bits/stdc++.h>   const long long int mod = 1000000007;   using namespace std;   void toh_chaliye_shuru_karte_hain() {}   void code_samapti_ki_ghoshna() {}   long long int power(long long int a, long long int b, long long int modi) {     a %= modi;     long long int res = 1;     while (b) {       if (b % 2) {         res = (res * a) % modi;       }       b /= 2;       a = (a * a) % modi;     }     return res;   }   int main() {     toh_chaliye_shuru_karte_hain();     ios::sync_with_stdio(0);     cin.tie(0);     int n, x1, y1, x2, y2;     cin >> n >> x1 >> y1 >> x2 >> y2;     if (x1 == 0 && x2 == 0 || x1 == n && x2 == n) {       cout << abs(y1 - y2) <<   n ;     } else if (y1 == 0 && y2 == 0 || y1 == n && y2 == n) {       cout << abs(x1 - x2) <<   n ;     } else {       int ans = 0;       ans += min(n - y1 + n - y2, y1 + y2);       ans += min(n - x1 + n - x2, x1 + x2);       cout << ans <<   n ;     }     code_samapti_ki_ghoshna();     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:268435456 )   using namespace std;   const string IN_NAME =  input.txt ;   const string OUT_NAME =  output.txt ;   template <class T>   T abs(T &x) {     return ((x) >= 0) ? (x) : (-(x));   }   template <class T>   T sqr(T &x) {     return (x) * (x);   }   template <class T>   T min(T &a, T &b) {     return ((a) < (b)) ? (a) : (b);   }   template <class T>   T max(T &a, T &b) {     return ((a) > (b)) ? (a) : (b);   }   int n, m;   struct tree {     int x, h, pL, pR;     tree() {}     bool operator<(const tree &t) const { return x < t.x; }   };   struct mush {     int x, z;     mush() {}     bool operator<(const mush &t) const { return x < t.x; }   };   tree a[100010];   mush b[100010], tmpb[100010];   int binSearch(int x) {     if (x < b[0].x) return -1;     if (x > b[m - 1].x) return -m - 1;     int left = 0, right = m - 1;     while (right - left > 1) {       int mid = (left + right) >> 1;       if (b[mid].x == x) return mid;       if (b[mid].x < x)         left = mid + 1;       else         right = mid - 1;     }     for (int i = max(0, left - 4); i < min(m - 1, right + 3); i++) {       if (b[i].x < x && x < b[i + 1].x) return -(i + 1) - 1;     }     return right;   }   double d[100010];   double db[100010];   int dk;   void multQuery(int left, int right, double p) {     if (left > right) return;     int L = left / dk + 1;     int R = right / dk - 1;     if (L > R) {       for (int i = left; i <= right; i++) d[i] *= p;     } else {       for (int i = left; i < L * dk; i++) d[i] *= p;       for (int j = L; j <= R; j++) db[j] *= p;       for (int i = (R + 1) * dk; i <= right; i++) d[i] *= p;     }   }   double getQuery(int index) { return d[index] * db[index / dk]; }   int main() {     scanf( %d%d , &n, &m);     for (int i = 0; i < n; i++)       scanf( %d%d%d%d , &a[i].x, &a[i].h, &a[i].pL, &a[i].pR);     for (int i = 0; i < m; i++) scanf( %d%d , &tmpb[i].x, &tmpb[i].z);     sort(a, a + n);     sort(tmpb, tmpb + m);     int newM = 0;     for (int i = 0; i < m; i++) {       if (i == 0 || tmpb[i - 1].x < tmpb[i].x) {         b[newM].x = tmpb[i].x;         b[newM].z = tmpb[i].z;         newM++;       } else {         b[newM - 1].z += tmpb[i].z;       }     }     m = newM;     for (int i = 0; i < n; i++) a[i].x *= 2;     for (int i = 0; i < n; i++) a[i].h *= 2;     for (int i = 0; i < m; i++) b[i].x *= 2;     dk = (int)sqrt(m + 1e-9);     for (int i = 0; i < m + 5; i++) {       d[i] = db[i] = 1;     }     for (int i = 0; i < n; i++) {       int leftIndex = binSearch(a[i].x - a[i].h - 1);       int rightIndex = binSearch(a[i].x + a[i].h + 1);       int thisLeftIndex = binSearch(a[i].x - 1);       int thisRightIndex = binSearch(a[i].x + 1);       leftIndex = ~leftIndex;       rightIndex = ~rightIndex;       thisLeftIndex = ~thisLeftIndex;       thisRightIndex = ~thisRightIndex;       multQuery(leftIndex, thisLeftIndex - 1, 1.0 - a[i].pL / 100.0);       multQuery(thisRightIndex, rightIndex - 1, 1.0 - a[i].pR / 100.0);     }     double result = 0;     for (int i = 0; i < m; i++) {       result += getQuery(i) * b[i].z;     }     printf( %.12f , result);   }