malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int mn = 2005;   vector<int> g[mn], G[mn];   int dfn[mn], low[mn], times;   int stk[mn], top, bel[mn], cnt, siz[mn], fa[mn];   int rt, maxs;   bool ins[mn], vis[mn][mn], flg[mn], chn[mn], tmp[mn], leav[mn];   void dfs1(int s, int f) {     dfn[s] = low[s] = ++times, stk[++top] = s, ins[s] = 1;     int m = g[s].size();     for (int i = 0; i < m; i++) {       int t = g[s][i];       if (t == f) continue;       if (!dfn[t])         dfs1(t, s), low[s] = min(low[s], low[t]);       else if (ins[s])         low[s] = min(low[s], dfn[t]);       if (low[t] > dfn[s]) {         ++cnt;         while (stk[top] != t)           ins[stk[top]] = 0, bel[stk[top--]] = cnt, ++siz[cnt];         bel[t] = cnt, ins[t] = 0, --top, ++siz[cnt];       }     }   }   void dfs2(int s, int d) {     if (d > maxs) rt = s, maxs = d;     int m = G[s].size();     flg[s] = 1;     for (int i = 0; i < m; i++) {       int t = G[s][i];       if (!flg[t]) dfs2(t, d + 1);     }   }   void dfs3(int s, int f, int d) {     int m = G[s].size();     fa[s] = f;     bool flg = 0;     for (int i = 0; i < m; i++) {       int t = G[s][i];       if (t != f) dfs3(t, s, d + 1), flg = 1;     }     leav[s] = flg ^ 1;     if (!flg && d > maxs) {       memset(tmp, 0, sizeof tmp), maxs = d;       while (s) tmp[s] = 1, s = fa[s];     }   }   int main() {     int n, m, a, b, blk = 0, ans = 0;     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; i++)       scanf( %d%d , &a, &b), g[a].push_back(b), g[b].push_back(a);     for (int i = 1; i <= n; i++)       if (!dfn[i]) {         dfs1(i, 0), ++blk, ++cnt;         while (top) bel[stk[top]] = cnt, ins[stk[top]] = 0, --top, ++siz[cnt];       }     for (int i = 1; i <= n; i++) {       int siz = g[i].size();       for (int j = 0; j < siz; j++) {         int t = g[i][j];         if (bel[i] != bel[t] && !vis[bel[i]][bel[t]])           vis[bel[i]][bel[t]] = vis[bel[t]][bel[i]] = 1,           G[bel[i]].push_back(bel[t]), G[bel[t]].push_back(bel[i]);       }     }     for (int i = 1; i <= cnt; i++) {       ans += siz[i] - 1;       if (!flg[i]) {         maxs = 0, dfs2(i, 1), maxs = 0, dfs3(rt, 0, 1);         for (int i = 1; i <= cnt; i++) chn[i] |= tmp[i];       }     }     for (int i = 1; i <= cnt; i++) {       int s = i, d = 0;       if (leav[s]) continue;       while (!chn[s]) chn[s] = 1, s = fa[s], ++d;       ans += d;     }     printf( %d n , ans + blk - 1);   }
#include <bits/stdc++.h>   using namespace std;   const int N = 101;   int a[N];   int n;   int main() {     int i, t;     cin >> n;     for (i = 0; i < n; i++) cin >> a[i];     sort(a, a + n);     t = a[0];     a[0] = a[n - 1];     a[n - 1] = t;     for (i = 0; i < n; i++) cout << a[i] <<    ;     cout << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC_OPTIMAZE( ofast )   using namespace std;   signed main() {     long long n;     cin >> n;     vector<long long> arr(n);     for (long long i = 0; i < n; i++) {       cin >> arr[i];       arr[i]--;     }     long long cnt = 0, pos = 0;     while (pos < n) {       cnt++;       long long mx = pos;       while (pos < n && pos <= mx) {         mx = max(mx, arr[pos]);         pos++;       }     }     cout << cnt << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     int n;     cin >> n;     vector<vector<int> > T(n);     for (int i = 0; i < n - 1; ++i) {       int a, b;       cin >> a >> b;       --a;       --b;       T[a].push_back(b);       T[b].push_back(a);     }     vector<bool> odw(n, false);     stack<int> S;     vector<double> odl(n);     odw[0] = true;     S.push(0);     odl[0] = 1;     double odp = 0.0;     while (!S.empty()) {       int akt = S.top();       S.pop();       odp += 1.0 / odl[akt];       for (int i = 0; i < T[akt].size(); ++i) {         if (!odw[T[akt][i]]) {           odw[T[akt][i]] = true;           S.push(T[akt][i]);           odl[T[akt][i]] = odl[akt] + 1;         }       }     }     cout.precision(10);     cout << odp;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) {     a = abs(a), b = abs(b);     if (a < b) swap(a, b);     return b ? gcd(b, a % b) : a;   }   long long lcm(long long a, long long b) { return a * b / gcd(a, b); }   long long fast_pow(long long x, long long exp, long long mod) {     long long ret = 1;     while (exp) {       if (exp & 1) ret = (ret * x) % mod;       x = (x * x) % mod;       exp >>= 1;     }     return ret;   }   const int dx[] = {0, 0, -1, 1};   const int dy[] = {-1, 1, 0, 0};   const int inf = (int)1e9 + 5;   vector<vector<int> > adj;   vector<int> v;   priority_queue<int> q;   map<int, int> mp;   set<int> st;   long long x, y, z;   int32_t main(void) {     ios_base::sync_with_stdio(false), cin.tie(nullptr);     cin >> x >> y >> z;     if (x > y) swap(x, y);     cout << (x + y) / z <<    ;     x %= z;     y %= z;     if (x + y >= z)       cout << min(x - ((x + y) - z), y - ((x + y) - z));     else       cout << 0;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n;     cin >> n;     long long a[n], b[n];     long long i;     for (i = 0; i < n; i++) {       cin >> a[i];       b[i] = a[i];     }     sort(a, a + n);     long long count = 0;     for (i = 0; i < n; i++) {       if (a[i] != b[i]) {         count++;       }     }     if (count == 2 || count == 0) {       cout <<  YES  << endl;     } else {       cout <<  NO  << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   struct Arc {     int f, s, prev;   } arr[400005];   Arc nbr[400005];   Arc br[400005];   int beg[400005];   int kol = 0;   void add_arc(int f, int s) {     arr[kol].f = f;     arr[kol].s = s;     arr[kol].prev = beg[f];     beg[f] = kol++;     arr[kol].f = s;     arr[kol].s = f;     arr[kol].prev = beg[s];     beg[s] = kol++;   }   int pos[1 << 19];   int lev[1 << 19];   int llv[1 << 19];   int tin[1 << 19];   int tout[1 << 19];   int base[1 << 19];   int t = 0, ff = 0, q = 0;   void DFS(int v, int p = -1) {     tout[v] = tin[v] = ++t;     for (int i = beg[v]; i != -1; i = arr[i].prev) {       if (arr[i].s != p) {         if (!tin[arr[i].s]) {           DFS(arr[i].s, v);           if (tout[arr[i].s] <= tin[v]) {             tout[v] = min(tout[v], tout[arr[i].s]);             nbr[ff++] = arr[i];           } else {             br[q++] = arr[i];           }         } else {           tout[v] = min(tout[v], tout[arr[i].s]);         }       }     }   }   void DFS2(int v, int lv = 0, int p = -1) {     tin[v] = t;     llv[v] = lv;     lev[t] = lv;     pos[t++] = v;     for (int i = beg[v]; i != -1; i = arr[i].prev) {       if (arr[i].s != p) {         DFS2(arr[i].s, lv + 1, v);         lev[t] = lv;         pos[t++] = v;       }     }   }   int get_base(int v) {     if (base[v] == v) {       return v;     } else {       return base[v] = get_base(base[v]);     }   }   void merge_base(int a, int b) {     if (rand() & 1) {       base[get_base(a)] = get_base(b);     } else {       base[get_base(b)] = get_base(a);     }   }   void build_tree() {     for (int i = (1 << 18) - 1; i; --i) {       if (lev[i + i] < lev[i + i + 1]) {         lev[i] = lev[i + i];         pos[i] = pos[i + i];       } else {         lev[i] = lev[i + i + 1];         pos[i] = pos[i + i + 1];       }     }   }   int get_min(int l, int r) {     l = tin[l];     r = tin[r];     if (l > r) {       swap(l, r);     }     ++r;     int best = lev[l], bv = pos[l];     while (r - l > 1) {       if (!(l & 1)) {         if (lev[l + 1] < best) {           best = lev[l + 1];           bv = pos[l + 1];         }       }       if (r & 1) {         if (lev[r - 1] < best) {           best = lev[r - 1];           bv = pos[r - 1];         }       }       l >>= 1;       r >>= 1;     }     return bv;   }   int main() {     memset(beg, -1, sizeof beg);     int n, m, k;     scanf( %d%d , &n, &m);     for (int i = 0; i < m; ++i) {       int f, s;       scanf( %d%d , &f, &s);       --f;       --s;       add_arc(f, s);     }     DFS(0);     for (int i = 0; i < n; ++i) {       base[i] = i;     }     for (int i = 0; i < ff; ++i) {       merge_base(nbr[i].s, nbr[i].f);     }     memset(beg, -1, sizeof beg);     memset(tin, -1, sizeof tin);     for (int i = 0; i < q; ++i) {       add_arc(get_base(br[i].f), get_base(br[i].s));     }     t = 1 << 18;     DFS2(get_base(0));     build_tree();     scanf( %d , &k);     for (int i = 0; i < k; ++i) {       int f, s;       scanf( %d%d , &f, &s);       --f;       --s;       f = get_base(f);       s = get_base(s);       int ret = llv[f] + llv[s] - 2 * llv[get_min(f, s)];       printf( %d n , ret);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using namespace std;   map<long long, long long> f;   int main() {     int q;     scanf( %d , &q);     while (q--) {       long long u, v;       int t, w;       scanf( %d %lld %lld , &t, &u, &v);       if (t == 1) {         scanf( %d , &w);         while (u != v) {           if (u < v) swap(u, v);           f[u] += w;           u >>= 1;         };       } else {         long long ans = 0;         while (u != v) {           if (u < v) swap(u, v);           ans += f[u];           u >>= 1;         };         cout << ans << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 4e5 + 7;   int n, a[N], cnt[N], lim = 0, mx = 0, fa[N];   long long ans = 0;   inline int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }   inline void merge(int u, int v, long long w) {     if (cnt[u] && cnt[v]) {       u = find(u), v = find(v);       if (u != v) {         ans += 1ll * w * (cnt[v] + cnt[u] - 1);         fa[u] = v;         cnt[v] = 1;       }     }   }   int main() {     scanf( %d , &n);     cnt[0] = 1;     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       cnt[a[i]]++;       mx = max(mx, a[i]);       ans -= a[i];     }     lim = 1 << 32 - __builtin_clz(mx);     for (int i = 0; i <= lim - 1; i++) fa[i] = i;     for (int i = lim - 1; ~i; i--) {       for (int j = i; j; j = (j - 1) & i) {         if (cnt[j] && cnt[i ^ j]) merge(j, i ^ j, i);       }       merge(i, 0, i);     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct vac {     int l, r, cost, duration;     vac() : cost(-1) {}     vac(int l, int r, int cost) : l(l), r(r), cost(cost), duration(r - l + 1) {}   };   vector<vector<vac> > lifes(200001, vector<vac>(0)),       deaths(200001, vector<vac>(0));   vector<vac> cheapest(200001);   int min1(int x, int y) {     if (x == -1) return y;     if (y == -1) return x;     return min(x, y);   }   int main() {     int n, x;     cin >> n >> x;     int minAns = -1;     for (int i = 0; i < n; i++) {       int l, r, cost;       cin >> l >> r >> cost;       lifes[l].push_back(vac(l, r, cost));       deaths[r].push_back(vac(l, r, cost));     }     for (int i = 0; i < lifes.size(); i++) {       for (int j = 0; j < lifes[i].size(); j++) {         int d = lifes[i][j].duration;         if (d > x) continue;         if (cheapest[x - d].cost != -1)           minAns = min1(minAns, cheapest[x - d].cost + lifes[i][j].cost);       }       for (int j = 0; j < deaths[i].size(); j++) {         int d = deaths[i][j].duration;         cheapest[d].cost = min1(cheapest[d].cost, deaths[i][j].cost);       }     }     cout << minAns << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int N, i, j, p = 0, q = 0, ans = 0;     cin >> N;     for (i = 0; i < N; i++) {       cin >> j;       if (q < j)         p++;       else         p = 1;       q = j;       ans = max(ans, p);     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 10, InfI = INT_MAX, Mod = 998244353;   const long long InfL = LONG_LONG_MAX;   int n, m, sqn;   vector<int> adj[N];   vector<int> ind;   bool vis[N] = {}, indpen[N] = {};   int ent[N], par[N], back_edge[N], back_min[N];   int dfstimer = 0, idma = 1;   void dfs(int x) {     vis[x] = 1;     ent[x] = dfstimer++;     int back_edg = 0, back_mi = x;     bool pen = 1;     for (int v : adj[x]) {       if (!vis[v]) {         par[v] = x;         dfs(v);       } else if (ent[v] < ent[x]) {         back_edg++;         back_mi = (ent[v] < ent[back_mi]) ? v : back_mi;       }       if (indpen[v]) pen = 0;     }     back_edge[x] = back_edg;     back_min[x] = back_mi;     idma = (back_edg > back_edge[idma]) ? x : idma;     if (back_edg < sqn - 1 && pen) {       ind.push_back(x);       indpen[x] = 1;     }   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> m;     sqn = ceil(sqrt(1.0 * n));     for (int i = 1; i <= m; i++) {       int a, b;       cin >> a >> b;       adj[a].push_back(b);       adj[b].push_back(a);     }     back_edge[1] = 0;     dfs(1);     if (back_edge[idma] >= sqn - 1) {       cout << 2 << endl;       vector<int> path;       int j = idma;       path.push_back(j);       while (j != back_min[idma]) {         j = par[j];         path.push_back(j);       }       cout << path.size() << endl;       for (int i : path) cout << i <<    ;       return 0;     }     cout << 1 << endl;     for (int i = 0; i < sqn; i++) cout << ind[i] <<    ;   }
#include <bits/stdc++.h>   const double eps = 1e-9;   const int int_inf = 2000000000;   const long long i64_inf = 1000000000000000000LL;   const double pi = acos(-1.0);   using namespace std;   int wa[1000010];   int wb[1000010];   int a[1000100];   int b[1000100];   int la, lb;   int res = 0;   int main() {     memset(wa, -1, sizeof(wa));     memset(wb, -1, sizeof(wb));     cin >> la >> lb;     for (int i = 0; i < (int)la; i++) scanf( %d , &a[i]), wa[a[i]] = i;     for (int i = 0; i < (int)lb; i++) scanf( %d , &b[i]), wb[b[i]] = i;     int first = wb[a[0]], last = first, len = 1;     if (first != -1) {       for (int i = 1; i < (int)la; i++) {         if (wb[a[i]] == -1) break;         if (first <= last)           if (wb[a[i]] > last || wb[a[i]] < first) {             last = wb[a[i]];             len++;             continue;           } else             break;         if (wb[a[i]] > last && wb[a[i]] < first) {           last = wb[a[i]];           len++;           continue;         } else           break;       }     } else       len = 0;     res = max(res, len);     for (int i = 1; i < (int)la; i++) {       if (len == 0) {         if (wb[a[i]] == -1) continue;         first = last = wb[a[i]];         len = 1;       } else {         len--;         first = wb[a[i]];         if (first == -1) {           len = 0;           continue;         }       }       int j = (i + len) % la;       while (j != i) {         if (wb[a[j]] == -1) break;         if (first <= last)           if (wb[a[j]] > last || wb[a[j]] < first) {             last = wb[a[j]];             len++;             j = (j + 1) % la;             continue;           } else             break;         if (wb[a[j]] > last && wb[a[j]] < first) {           last = wb[a[j]];           len++;           j = (j + 1) % la;           continue;         } else           break;       }       res = max(res, len);     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n, m;     string s;     cin >> n >> m;     int a[n][m];     int r[m];     memset(r, 0, sizeof r);     for (int i = 0; i < n; i++) {       cin >> s;       for (int j = 0; j < m; j++) {         a[i][j] = s[j] -  0 ;         if (a[i][j]) {           r[j]++;         }       }     }     for (int i = 0; i < n; i++) {       bool u = false;       for (int j = 0; j < m && !u; j++) {         if (a[i][j] && r[j] == 1) u = true;       }       if (!u) {         cout <<  YES n ;         return 0;       }     }     cout <<  NO n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e5 + 100;   int arr[MAXN];   int n, x, t;   long long ans;   int main() {     cin >> n;     for (int i = 0; i < n; i++) {       cin >> x;       if (t <= 1)         arr[++t] = x;       else {         while (t > 1 && arr[t] <= arr[t - 1] && arr[t] <= x) {           ans += min(arr[t - 1], x);           t--;         }         arr[++t] = x;       }     }     sort(arr + 1, arr + t + 1, greater<int>());     for (int i = 3; i <= t; i++) ans += arr[i];     return cout << ans << endl, 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int gi() {     char c = getchar();     while (c <  0  || c >  9 ) c = getchar();     int sum = 0;     while ( 0  <= c && c <=  9 ) sum = sum * 10 + c - 48, c = getchar();     return sum;   }   const int maxn = 100005;   int n, a[maxn], cnt[maxn], p[maxn][3], val[maxn];   priority_queue<pair<int, int>> que;   int main() {     n = gi();     for (int i = 1; i <= n; ++i) a[i] = gi();     sort(a + 1, a + n + 1);     for (int i = 1, m = 0, lst = -1; i <= n; ++i)       if (a[i] == lst)         ++cnt[m];       else         lst = a[i], ++m, val[m] = a[i], ++cnt[m];     for (int i = 1; i <= n; ++i)       if (cnt[i]) que.push(make_pair(cnt[i], val[i]));     pair<int, int> x, y, z;     int ans = 0;     while (que.size() >= 3) {       x = que.top();       que.pop();       y = que.top();       que.pop();       z = que.top();       que.pop();       ++ans;       p[ans][0] = x.second;       p[ans][1] = y.second;       p[ans][2] = z.second;       sort(p[ans], p[ans] + 3, greater<int>());       if (x.first > 1) --x.first, que.push(x);       if (y.first > 1) --y.first, que.push(y);       if (z.first > 1) --z.first, que.push(z);     }     printf( %d n , ans);     for (int i = 1; i <= ans; ++i)       printf( %d %d %d n , p[i][0], p[i][1], p[i][2]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<vector<int> > g;   vector<int> a, q;   vector<char> cl;   vector<int> p;   map<int, pair<int, int> > y;   map<int, pair<int, int> >::iterator it;   int cycle_st, cycle_end;   long long i, j, n, m, e, k, ot, x, i1, i2, i3, i4, l, r;   bool dfs(int v) {     cl[v] = 1;     for (size_t i = 0; i < g[v].size(); ++i) {       int to = g[v][i];       if (cl[to] == 0 && p[v] != to) {         p[to] = v;         y[v].first = to;         y[to].second = y[v].second + 1;         if (dfs(to)) return true;       } else if (cl[to] == 1 && p[v] != to &&                  y[v].second - y[to].second + 1 >= k + 1) {         cycle_end = v;         cycle_st = to;         cout << y[v].second - y[to].second + 1 << endl;         while (y[to].first != v) {           cout << to <<    ;           to = y[to].first;         }         cout << to <<     << v <<    ;         exit(0);         return true;       }     }     cl[v] = 2;     return false;   }   int main() {     vector<vector<int> > w;     vector<int> d;     cin >> n >> m >> k;     for (i = 0; i < n + 2; i++) {       g.push_back(a);       p.push_back(-1);       cl.push_back(0);     }     for (i = 0; i < m; i++) {       cin >> l >> r;       g[l].push_back(r);       g[r].push_back(l);     }     for (int i = 0; i < n; ++i) {       y[i].second = 1;       if (dfs(i)) break;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t, i, j, count = 0;     cin >> t;     int a[t], b[t];     for (i = 0; i < t; i++) cin >> a[i] >> b[i];     for (int i = 0; i < t; i++) {       int e = 0, f = 0, c = 0, d = 0;       for (j = 0; j < t; j++) {         if (a[i] < a[j] && b[i] == b[j]) e = 1;         if (a[i] > a[j] && b[i] == b[j]) f = 1;         if (a[i] == a[j] && b[i] > b[j]) c = 1;         if (a[i] == a[j] && b[i] < b[j]) d = 1;       }       if (e + f + c + d == 4) count++;     }     cout << count <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   T gcd(T a, T b) {     if (a == 0) return b;     return gcd(b % a, a);   }   template <typename T>   T pow(T a, T b, long long m) {     T ans = 1;     while (b > 0) {       if (b % 2 == 1) ans = ((ans % m) * (a % m)) % m;       b /= 2;       a = ((a % m) * (a % m)) % m;     }     return ans % m;   }   double fac[55];   double c[55][55];   void factorial() {     fac[0] = 1.00;     for (int i = 1; i <= 50; i++) {       fac[i] = fac[i - 1] * (double)i;     }   }   int n, m;   int a[55];   double pw(double base, int exp) {     double ans = 1.00;     for (int i = 0; i < exp; i++) ans *= base;     return ans;   }   double dp[55][55][55];   bool vis[55][55][55];   double solve(int id, int cnt, int maxSoFar) {     if (id == (m)) {       if (cnt == 0)         return maxSoFar;       else         return 0.00;     }     if (vis[id][cnt][maxSoFar]) return dp[id][cnt][maxSoFar];     vis[id][cnt][maxSoFar] = 1;     double ans = 0.00;     for (int i = 0; i <= cnt; i++) {       ans += c[cnt][i] *              solve(id + 1, cnt - i, max((a[id] + i - 1) / a[id], maxSoFar));     }     return dp[id][cnt][maxSoFar] = ans;   }   int main() {     cin >> n >> m;     factorial();     for (int i = 0; i < m; i++) cin >> a[i];     for (int i = 0; i <= 50; i++) {       c[i][0] = 1.00;       c[i][i] = 1.00;     }     for (int i = 2; i <= 50; i++) {       for (int j = 1; j < i; j++) {         c[i][j] = c[i - 1][j] + c[i - 1][j - 1];       }     }     double ans = solve(0, n, 0);     ans /= pw(m, n);     cout << fixed << setprecision(12) << ans;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int W = 0, B = 0, i, h = 64;     char z;     for (i = 0; i < h; i++) {       cin >> z;       if (z ==  Q ) W += 9;       if (z ==  q ) B += 9;       if (z ==  R ) W += 5;       if (z ==  r ) B += 5;       if (z ==  B ) W += 3;       if (z ==  b ) B += 3;       if (z ==  N ) W += 3;       if (z ==  n ) B += 3;       if (z ==  P ) W += 1;       if (z ==  p ) B += 1;     }     if (W > B) cout <<  White ;     if (B > W) cout <<  Black ;     if (B == W) cout <<  Draw ;   }
#include <bits/stdc++.h>   int n, m, f, c[150005], p, a, b;   long long A;   struct odp {     long long L, M, R, S;     odp() {}     odp(long long L, long long M, long long R, long long S)         : L(L), M(M), R(R), S(S) {}   } t[150005 * 4];   void init(int n, int l, int r) {     if (l == r)       t[n].L = t[n].R = t[n].M = ((t[n].S = c[l]) > (0) ? (t[n].S = c[l]) : (0));     else {       int L = n * 2, R = L + 1, c = l + r >> 1;       init(L, l, c);       init(R, c + 1, r);       t[n].S = t[L].S + t[R].S;       t[n].L = ((t[L].L) > (t[L].S + t[R].L) ? (t[L].L) : (t[L].S + t[R].L));       t[n].R = ((t[R].R) > (t[L].R + t[R].S) ? (t[R].R) : (t[L].R + t[R].S));       t[n].M =           ((t[L].M) >                    (((t[R].M) > (t[L].R + t[R].L) ? (t[R].M) : (t[L].R + t[R].L)))                ? (t[L].M)                : (((t[R].M) > (t[L].R + t[R].L) ? (t[R].M) : (t[L].R + t[R].L))));     }   }   odp q(int n, int l, int r) {     if (l >= a && r <= b) return odp(t[n].L, t[n].M, t[n].R, t[n].S);     int c = l + r >> 1;     if (c >= b) return q(n * 2, l, c);     if (c < a) return q(n * 2 + 1, c + 1, r);     odp L = q(n * 2, l, c), R = q(n * 2 + 1, c + 1, r);     return odp(((L.L) > (L.S + R.L) ? (L.L) : (L.S + R.L)),                ((L.M) > (((R.M) > (L.R + R.L) ? (R.M) : (L.R + R.L)))                     ? (L.M)                     : (((R.M) > (L.R + R.L) ? (R.M) : (L.R + R.L)))),                ((R.R) > (L.R + R.S) ? (R.R) : (L.R + R.S)), L.S + R.S);   }   int main() {     scanf( %d %d %d , &n, &m, &f);     for (int i = 1; i <= n; i++)       scanf( %d , &c[i]), c[i - 1] = (c[i] - c[i - 1]) * 50;     for (int i = 1; i < n; i++) scanf( %d , &p), c[i] -= p * f;     init(1, 1, n - 1);     while (m--) {       scanf( %d %d , &a, &b);       b--;       A += q(1, 1, n - 1).M;     }     printf( %.8lf n , A * 0.01);   }