malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const double PI = 2 * acos(0.0);   const double eps = 1e-9;   double toRad(int angle) { return PI * angle / 180.0; }   int a, w, h;   double angle;   complex<double> intersect(complex<double> p1, complex<double> p2,                             complex<double> p3, complex<double> p4) {     complex<double> ret;     double u = (p4.real() - p3.real()) * (p1.imag() - p3.imag()) -                (p4.imag() - p3.imag()) * (p1.real() - p3.real());     u /= (p4.imag() - p3.imag()) * (p2.real() - p1.real()) -          (p4.real() - p3.real()) * (p2.imag() - p1.imag());     return complex<double>(p1.real() + u * (p2.real() - p1.real()),                            p1.imag() + u * (p2.imag() - p1.imag()));   }   complex<double> rotate(complex<double> p, double angle) {     return complex<double>(p.real() * cos(angle) - p.imag() * sin(angle),                            p.real() * sin(angle) + p.imag() * cos(angle));   }   double dist(complex<double> a, complex<double> b) {     return (hypot((a - b).real(), (a - b).imag()));   }   int main() {     cin >> w >> h >> a;     long double ans = 0;     if (a > 90) a = 180 - a;     if (a == 0)       ans = 1.0 * w * h;     else if (a == 90)       ans = min(w, h) * min(w, h);     else {       angle = toRad(a);       if (w < h) swap(w, h);       complex<double> A(-0.5 * w, 0.5 * h);       complex<double> B(0.5 * w, 0.5 * h);       complex<double> C(0.5 * w, -0.5 * h);       complex<double> D(-0.5 * w, -0.5 * h);       complex<double> E = rotate(A, angle), F = rotate(B, angle),                       G = rotate(C, angle), H = rotate(D, angle);       complex<double> N = intersect(A, B, E, F);       complex<double> M = intersect(A, D, E, F);       complex<double> O = intersect(A, B, F, G);       complex<double> P = intersect(B, C, F, G);       ans = 1.0 * w * h;       if (G.imag() < B.imag()) {         long double area = dist(A, M) * dist(A, N) + dist(B, O) * dist(B, P);         ans -= area;       } else {         N = intersect(A, B, H, G);         M = intersect(C, D, H, G);         complex<double> K(N.real(), M.imag());         ans -= 2.0 * h * dist(C, K);         ans -= dist(K, M) * dist(N, K);       }     }     cout << fixed << setprecision(10) << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     ;     long long int t;     cin >> t;     while (t--) {       long long int n;       cin >> n;       float a = 1;       float b = (float)360 / ((2 * n));       b /= 2;       b = (3.14159265358979323846264338327950288419716939937510582 / 180) * b;       float ans = 1 / tan(b);       cout << fixed << setprecision(15) << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename A, typename B, typename C>   struct triple {     A X;     B Y;     C Z;     triple(A a = 0, B b = 0, C c = 0) : X(a), Y(b), Z(c) {}   };   template <typename A, typename B, typename C>   triple<A, B, C> make_triple(A a = 0, B b = 0, C c = 0) {     return triple<A, B, C>(a, b, c);   }   template <typename A, typename B, typename C>   bool operator<(const triple<A, B, C>& a, const triple<A, B, C>& b) {     if (a.X != b.X) return a.X < b.X;     if (a.Y != b.Y) return a.Y < b.Y;     return a.Z < b.Z;   }   template <typename T, typename SS>   ostream& operator<<(ostream& ofs, const pair<T, SS>& p) {     ofs <<  (   << p.first <<   ,   << p.second <<   ) ;     return ofs;   }   template <typename T>   void print(T a) {     for (auto i : a) cout << i <<    ;     cout <<   n ;   }   template <typename T>   T max(T a, T b, T c) {     return max(a, max(b, c));   }   template <typename T>   T min(T a, T b, T c) {     return min(a, min(b, c));   }   struct custom_hash {     static uint64_t splitmix64(uint64_t x) {       x += 0x9e3779b97f4a7c15;       x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;       x = (x ^ (x >> 27)) * 0x94d049bb133111eb;       return x ^ (x >> 31);     }     size_t operator()(uint64_t x) const {       static const uint64_t FIXED_RANDOM =           chrono::steady_clock::now().time_since_epoch().count();       return splitmix64(x + FIXED_RANDOM);     }   };   signed main() {     srand(time(NULL));     cin.tie(0);     cout.tie(0);     ios_base::sync_with_stdio(false);     long long n;     cin >> n;     vector<long long> a(n);     for (long long i = 0; i < (n); i++) cin >> a[i];     long long ans = 0;     auto solve = [&](long long v) {       vector<long long> b(a);       long long pw = 1 << v;       for (long long i = 0; i < (n); i++) b[i] %= (pw * 2);       sort(b.begin(), b.end());       long long c = 0;       auto count = [&](long long l, long long r) -> long long {         return lower_bound(b.begin(), b.end(), r) -                lower_bound(b.begin(), b.end(), l);       };       for (long long i = 0; i < (n); i++)         c += (count(pw - b[i], pw * 2 - b[i]) +               count(pw * 3 - b[i], pw * 4 - b[i]));       for (long long i = 0; i < (n); i++)         if ((2 * b[i]) & pw) c--;       c >>= 1;       return c & 1;     };     for (long long i = 0; i < (25); i++)       if (solve(i)) ans += 1LL << i;     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   long long int gcd(long long int a, long long int b) {     if (b != 0)       return gcd(b, a % b);     else       return a;   }   long long int power(long long int a, long long int b) {     if (b == 0) return 1;     if (b == 1) return a;     if (b % 2 == 0) {       long long int t = power(a, b / 2);       return t * t;     } else {       long long int t = power(a, b / 2);       return a * t * t;     }   }   long long int powin(long long int a, long long int b) {     if (b == 0)       return 1;     else if (b == 1)       return a;     else if (b % 2 == 0) {       long long int t = powin(a, b / 2);       return (t * t) % 1000000007;     } else {       long long int t = powin(a, b / 2);       return (((t * t) % 1000000007) * a) % 1000000007;     }   }   long long int n, k;   long long int dp[509][10 * 509];   long long int h[20];   void solve() {     for (long long int i = 1; i < n + 1; i++) {       for (long long int j = 1; j < k * n + 1; j++) {         for (long long int p = 1; p < k + 1; p++) {           if (j >= p) dp[i][j] = max(dp[i][j], dp[i - 1][j - p] + h[p]);         }       }     }   }   long long int fr[100000 + 10];   long long int f[100000 + 10];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> n >> k;     memset(dp, 0, sizeof dp);     memset(fr, 0, sizeof fr);     memset(f, 0, sizeof f);     for (long long int i = 0; i < n * k; i++) {       long long int t;       cin >> t;       fr[t]++;     }     for (long long int i = 0; i < n; i++) {       int p;       cin >> p;       f[p]++;     }     h[0] = 0;     for (long long int i = 1; i < k + 1; i++) {       cin >> h[i];       dp[1][i] = h[i];     }     solve();     long long int ans = 0;     for (long long int i = 1; i < 100000 + 1; i++) {       if (f[i] > 0) {         long long int temp = 0;         for (long long int j = 1; j < f[i] + 1; j++) {           temp = max(dp[j][fr[i]], temp);         }         ans += temp;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct ln {     long long m, k;     ln(long long mm, long long kk) {       m = mm;       k = kk;     }   };   deque<ln> cvt;   long long dp[100010][2];   long long sw[100010];   long long wt[100010];   long long hilldist[100010];   long long cs(long long x, int ci) { return x * cvt[ci].m + cvt[ci].k; }   bool ex(long long m, long long k) {     long long m1 = cvt[cvt.size() - 2].m;     long long k1 = cvt[cvt.size() - 2].k;     long long m2 = cvt[cvt.size() - 1].m;     long long k2 = cvt[cvt.size() - 1].k;     return (k1 - k2) * (m - m1) >= (k1 - k) * (m2 - m1);   }   int main() {     int n, m, p;     int d, h, t;     scanf( %d%d%d , &n, &m, &p);     for (int i = 2; i <= n; i++) {       scanf( %d , &d);       hilldist[i] = hilldist[i - 1] + d;     }     for (int i = 1; i <= m; i++) {       scanf( %d%d , &h, &t);       wt[i] = t - hilldist[h];     }     sort(wt + 1, wt + m + 1);     for (int i = 1; i <= m; i++) sw[i] = sw[i - 1] + wt[i];     int nx = 1, nw = 0;     for (int i = 1; i <= m; i++) {       dp[i][0] = wt[i] * i - sw[i];     }     int k1;     for (int k = 2; k <= p; k++) {       cvt.clear();       k1 = k - 1;       cvt.push_back(ln(-k1, sw[k1] + dp[k1][nw]));       for (int i = 0; i <= m; i++) dp[i][nx] = 0;       for (int i = k; i <= m; i++) {         while (cvt.size() > 1 && cs(wt[i], 0) >= cs(wt[i], 1)) cvt.pop_front();         dp[i][nx] = cs(wt[i], 0) + wt[i] * (i)-sw[i];         while (cvt.size() > 1 && ex(-i, sw[i] + dp[i][nw])) cvt.pop_back();         cvt.push_back(ln(-i, sw[i] + dp[i][nw]));       }       swap(nx, nw);     }     cout << dp[m][nw];   }
#include <bits/stdc++.h>   using namespace std;   int x[100];   int a[10010000];   int main() {     int a, b, n;     scanf( %d%d%d , &a, &b, &n);     if (b >= n - 1)       puts( 2 );     else {       int f = 0;       for (int i = 1; i < n && i <= a; i++) {         int x = (long long)i * 1000000000 % n;         if (x > 0 && x <= n - b - 1) {           f = 1;           printf( 1 %09d n , i);           break;         }       }       if (!f) puts( 2 );     }   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-6;   const int mod = 1e9 + 7;   const int maxn = 2e6 + 100;   const int maxm = 2e6 + 100;   const int inf = 0x3f3f3f3f;   const double pi = acos(-1.0);   int t;   pair<long long, long long> a[maxn];   long long s;   int n;   int vis[maxn];   bool cmp2(pair<long long, long long> a, pair<long long, long long> b) {     return a.second < b.second;   }   vector<long long> mm, rr, lll;   int ck(long long x) {     int L = 0, R = 0, M = 0;     lll.clear();     rr.clear();     mm.clear();     for (int i = 1; i <= n; i++) {       if (a[i].first <= x && a[i].second >= x) {         mm.push_back(a[i].first);         M++;         continue;       }       if (a[i].first > x) {         R++;         rr.push_back(a[i].first);       }       if (a[i].second < x) {         L++;         lll.push_back(a[i].first);       }     }     if (L > n / 2) return false;     long long res = 0;     sort(mm.begin(), mm.end());     if (L < n / 2) {       int to = M;       for (int i = 0; i < to; i++) {         lll.push_back(mm[i]);         L++;         M--;         if (L == n / 2) break;       }     }     if (R < n / 2 + 1) {       if (R + M != n / 2 + 1) return false;       res += 1ll * M * x;     }     for (int i = 0; i < (int)lll.size(); i++) {       res += lll[i];     }     for (int i = 0; i < (int)rr.size(); i++) {       res += max(rr[i], x);     }     return res <= s;   }   int main() {     scanf( %d , &t);     while (t--) {       long long mx = 0;       scanf( %d %lld , &n, &s);       for (int i = 1; i <= n; i++) {         scanf( %lld %lld , &a[i].first, &a[i].second);         mx = max(mx, a[i].second);       }       long long ans = 0;       sort(a + 1, a + 1 + n);       long long l = a[n / 2 + 1].first;       sort(a + 1, a + 1 + n, cmp2);       long long r = a[n / 2 + 1].second;       while (l <= r) {         long long mid = l + r >> 1;         if (ck(mid)) {           l = mid + 1;           ans = mid;         } else           r = mid - 1;       }       printf( %lld n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int max(long long int a, long long int b) {     if (a > b)       return a;     else       return b;   }   void solve() {     int n;     cin >> n;     vector<int> a(2 * n);     for (int i = 0; i < 2 * n; i++) {       cin >> a[i];     }     int din = 0;     for (int i = 0; i < 2 * n; i++) {       if (a[i] == 1)         din += 1;       else         din -= 1;     }     if (din == 0) {       cout << 0 << endl;       return;     }     map<int, int> m;     int dr = 0;     m[0] = n - 1;     for (int i = n; i < 2 * n; i++) {       if (a[i] == 1)         dr += 1;       else         dr -= 1;       if (!m.count(dr)) {         m[dr] = i;       }     }     int ans = 1e9 + 7;     int dl = 0;     if (m.count(din)) {       ans = min(ans, m[din] - n + 1);     }     for (int i = n - 1; i >= 0; i--) {       if (a[i] == 1)         dl += 1;       else         dl -= 1;       int q = din - dl;       if (m.count(q)) {         ans = min(ans, m[q] - i + 1);       }     }     cout << ans << endl;   }   int main() {     int t;     cin >> t;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   const long double PI = acos(-1.0);   const double EPS = 1E-6;   const int INF = 2 * (1e+9) + 1;   const int MAXN = 3 * 100000001;   const int MOD = (1e+9) + 7;   int n, m;   map<int, int> m1, m2;   map<int, int> u, cnt;   int main() {     cin >> n;     for (int i = 0; i < (n); ++i) {       int t1, t2;       cin >> t1 >> t2;       m1[t1] = t2;       m2[t2] = t1;       cnt[t1]++;       cnt[t2]++;     }     int cur = 0;     vector<int> ans(n);     int inx = 1;     while (inx < n) {       cur = m1[cur];       ans[inx] = cur;       u[cur] = 1;       inx += 2;       if (!cur) break;     }     cur = 0, inx = n - 2;     while (inx >= 0) {       cur = m2[cur];       if (!cur) break;       ans[inx] = cur;       u[cur] = 1;       inx -= 2;     }     if (n % 2 == 0) {       for (map<int, int>::iterator it = m1.begin(); it != m1.end(); it++) {         if (!u[it->first] && it->first) {           ans[0] = it->first;         }       }     } else {       for (map<int, int>::iterator it = m1.begin(); it != m1.end(); it++) {         if (cnt[it->first] == 1 && (!u[it->first])) {           ans[0] = it->first;           cur = ans[0], inx = 2;           while (inx < n) {             cur = m1[cur];             ans[inx] = cur;             u[cur] = 1;             inx += 2;             if (!cur) break;           }           break;         }       }     }     for (int i = 0; i < ((int)(ans).size()); ++i) {       cout << ans[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 1e9 + 7;   vector<vector<pair<string, int>>> adl;   vector<int> dist(2000, inf);   map<pair<string, int>, int> nums;   map<string, pair<int, int>> mins;   void bfs(string& poly, int version) {     vector<string> order;     order.push_back(poly);     mins[poly] = {0, version};     dist[1] = 0;     for (int i = 0; i < order.size(); i++) {       int u = nums[{order[i], mins[order[i]].second}];       for (auto j : adl[u]) {         int v = nums[j], ver = j.second;         string& s = j.first;         if (dist[v] > dist[u] + 1) {           dist[v] = dist[u] + 1;           order.push_back(s);           if (mins.find(s) == mins.end()) mins[s] = {dist[v], ver};           if (dist[v] < mins[s].first) {             mins[s] = {dist[v], ver};           } else if (dist[v] == mins[s].first) {             mins[s].second = max(mins[s].second, ver);           }         }       }     }   }   int main() {     int n;     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n;     adl.resize(2 * n);     int m = 1, v = -1;     string poly;     for (int i = 0; i < n; i++) {       int num, ind, vers;       string s, s1;       cin >> s >> num;       if (i == 0) {         poly = s;         v = num;       }       if (nums[{s, num}] == 0) {         nums[{s, num}] = m;         m++;       }       ind = nums[{s, num}];       int k;       cin >> k;       for (int j = 0; j < k; j++) {         cin >> s1 >> vers;         if (s == s1) continue;         adl[ind].push_back({s1, vers});       }     }     bfs(poly, v);     cout << (int)mins.size() - 1 <<   n ;     for (auto p : mins)       if (p.first != poly) cout << p.first <<     << p.second.second <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   using nagai = long long;   const int N = 100;   int matr[N][N];   const int K = 12;   int de[N][K];   const int oo = 0x3f3f3f3f;   mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int n, k;     cin >> n >> k;     for (int i = 0; i < n; ++i)       for (int j = 0; j < n; ++j) cin >> matr[i][j];     int ans = oo;     for (int i = 0; i < 30000; ++i) {       memset(de, 0x3f, sizeof de);       vector<int> col(n);       for (int i = 0; i < n; ++i) col[i] = rnd() % 2;       de[0][0] = 0;       for (int l = 0; l < k; ++l)         for (int a = 0; a < n; ++a)           for (int b = 0; b < n; ++b)             if (col[a] != col[b])               de[b][l + 1] = min(de[b][l + 1], de[a][l] + matr[a][b]);       ans = min(ans, de[0][k]);     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   const int mod = 1000000007, maxn = 200005, maxk = 105;   int n, m;   int a[maxn], fac[maxn], nfac[maxn], inv[maxn], sum[maxn][maxk];   inline int C(int a, int b) {     return 1ll * fac[a] * nfac[b] % mod * nfac[a - b] % mod;   }   int main() {     fac[0] = fac[1] = nfac[0] = nfac[1] = inv[1] = 1;     for (int i = 2; i <= 200000; i++)       fac[i] = 1ll * fac[i - 1] * i % mod,       inv[i] = mod - 1ll * (mod / i) * inv[mod % i] % mod,       nfac[i] = 1ll * nfac[i - 1] * inv[i] % mod;     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     for (int i = 1; i <= m; i++) {       int l, r, k;       scanf( %d%d%d , &l, &r, &k);       for (int j = 0; j <= k; j++) {         sum[l][j] = (sum[l][j] + C(k, k - j)) % mod;         sum[r + 1][j] = (sum[r + 1][j] - C(k + r - l + 1, k - j) + mod) % mod;       }     }     for (int i = 1; i <= n; i++)       for (int j = 100; j >= 0; j--)         sum[i][j] = (sum[i][j] + (sum[i - 1][j + 1] + sum[i - 1][j]) % mod) % mod;     for (int i = 1; i <= n; i++)       printf( %d%c , (a[i] + sum[i][0]) % mod, i == n ?   n  :    );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 500010;   long long n, sx, sy, x, y, res[6];   int main() {     scanf( %lld , &n);     scanf( %lld%lld , &sx, &sy);     for (int i = 0; i < n; i++) {       scanf( %lld%lld , &x, &y);       if (x < sx) res[1]++;       if (y < sy) res[2]++;       if (x > sx) res[3]++;       if (y > sy) res[4]++;     }     long long mx = 0;     for (int i = 1; i <= 4; i++) mx = max(mx, res[i]);     for (int i = 1; i <= 4; i++) {       if (mx == res[i]) {         long long a, b;         if (i == 1) {           a = sx - 1, b = sy;         } else if (i == 2) {           a = sx, b = sy - 1;         } else if (i == 3) {           a = sx + 1, b = sy;         } else           a = sx, b = sy + 1;         printf( %lld n , mx);         printf( %lld %lld , a, b);         return 0;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int const N = 1e5 + 2;   int n, m;   void solve() {     string n, m;     cin >> n >> m;     sort((n).begin(), (n).end());     if (n[0] ==  0  && n.size() > 1) swap(n[0], n[1]);     if (n == m)       cout <<  OK  << endl;     else       cout <<  WRONG_ANSWER  << endl;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     solve();   }
#include <bits/stdc++.h>   using namespace std;   map<int, long long> ans, re, now;   int n, h[200005], tot, mp[200005], siz[200005], mz[200005], rem[200005], cnt;   bool vis[200005];   struct DX {     int v, p;   } dx[400005];   int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }   void add(int u, int v) {     dx[tot].p = h[u];     dx[tot].v = v;     h[u] = tot++;   }   void dfs_G(int u, int fx) {     siz[u] = 1;     rem[++cnt] = u;     mz[u] = 0;     for (int i = h[u]; ~i; i = dx[i].p) {       int v = dx[i].v;       if (v == fx || vis[v]) continue;       dfs_G(v, u);       siz[u] += siz[v];       mz[u] = max(mz[u], siz[v]);     }   }   int fd_G(int u) {     cnt = 0;     dfs_G(u, u);     for (int i = 1; i <= cnt; i++)       if (mz[rem[i]] <= siz[u] / 2 && siz[u] - siz[rem[i]] <= siz[u] / 2)         return rem[i];   }   void dfs(int u, int fx, int gc) {     re[gc = gcd(gc, mp[u])]++;     for (int i = h[u]; ~i; i = dx[i].p) {       int v = dx[i].v;       if (v == fx || vis[v]) continue;       dfs(v, u, gc);     }   }   void sol(int u) {     u = fd_G(u);     vis[u] = 1;     now[mp[u]] = 1;     ans[mp[u]] += 1;     for (int i = h[u]; ~i; i = dx[i].p) {       int v = dx[i].v;       if (vis[v]) continue;       dfs(v, 0, mp[u]);       for (map<int, long long>::iterator it = now.begin(); it != now.end(); it++)         for (map<int, long long>::iterator ti = re.begin(); ti != re.end(); ti++)           ans[gcd(it->first, ti->first)] += it->second * ti->second;       for (map<int, long long>::iterator ti = re.begin(); ti != re.end(); ti++)         now[ti->first] += ti->second;       re.clear();     }     now.clear();     for (int i = h[u]; ~i; i = dx[i].p) {       int v = dx[i].v;       if (vis[v]) continue;       sol(v);     }   }   int main() {     memset(h, -1, sizeof(h));     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &mp[i]);     int a, b;     for (int i = 1; i < n; i++) {       scanf( %d%d , &a, &b);       add(a, b);       add(b, a);     }     sol(1);     for (map<int, long long>::iterator it = ans.begin(); it != ans.end(); it++)       printf( %d %lld n , it->first, it->second);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int m;     cin >> m;     for (int i = 1; i <= m; i++) {       if ((i * (i + 1)) / 2 == m) {         cout <<  YES  << endl;         return 0;       }       if ((i * (i + 1)) / 2 > m) {         cout <<  NO  << endl;         return 0;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 150000 + 50;   int n, m, h, vec[MAXN], sec[MAXN], ans, need[4 * MAXN], ex[4 * MAXN];   void plant(int v, int b, int e) {     need[v] = e - b;     if (e - b == 1) return;     int mid = (b + e) / 2;     plant(v << 1, b, mid);     plant(v << 1 ^ 1, mid, e);   }   void water(int v, int b, int e, int x, int val) {     if (x == e) return;     if (e - b == 1) {       need[v] -= val;       ex[v] = max(0, -need[v]);       return;     }     int mid = (b + e) / 2;     if (x < mid)       water(v << 1, b, mid, x, val);     else       water(v << 1 ^ 1, mid, e, x, val);     need[v] = max(0, need[v << 1]) + max(0, need[v << 1 ^ 1] - ex[v << 1]);     ex[v] = ex[v << 1 ^ 1] + max(0, ex[v << 1] - max(0, need[v << 1 ^ 1]));   }   int main() {     scanf( %d %d %d , &n, &m, &h);     for (int i = 0; i < m; i++) scanf( %d , &sec[i]);     sort(sec, sec + m);     plant(1, 0, m);     for (int i = 0; i < n; i++) {       if (i >= m)         water(1, 0, m, lower_bound(sec, sec + m, h - vec[i - m]) - sec, -1);       scanf( %d , &vec[i]);       water(1, 0, m, lower_bound(sec, sec + m, h - vec[i]) - sec, 1);       ans += bool(need[1] == 0);     }     printf( %d n , ans);     return 0;   }