malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   using pii = pair<int, int>;   using ll = long long;   using llu = long long unsigned;   using ld = long double;   const ld EPS = 1e-9;   inline int cmp(ld first, ld second = 0, ld tol = EPS) {     return (first <= second + tol) ? (first + tol < second) ? -1 : 0 : 1;   }   const int MOD = 1;   inline int mod(ll first, int m = MOD) { return (int)(((first % m) + m) % m); }   const int N = 2e5 + 10;   int n, m;   ll first[N], chg[N], one[N];   int main() {     scanf( %d %d , &n, &m);     for (int i = 0; i < m; i++) scanf( %lld , &first[i]);     ll base = 0;     for (int i = 1; i < m; i += 2) {       base += abs(first[i] - first[i - 1]);       if (i < m - 1) base += abs(first[i] - first[i + 1]);     }     for (int i = 0; i < m; i++) {       if (i < m - 1) {         if (first[i + 1] > first[i]) {           chg[first[i]]--;           one[first[i]] += first[i] - 1;         }         if (first[i + 1] < first[i]) {           chg[first[i]]++;           ll dBef = abs(first[i] - (first[i + 1] + 1));           ll dNow = abs(1 - (first[i + 1] + 1));           one[first[i]] += (dNow - dBef);         }       }       if (i) {         if (first[i - 1] > first[i]) {           chg[first[i]]--;           one[first[i]] += first[i] - 1;         }         if (first[i - 1] < first[i]) {           chg[first[i]]++;           ll dBef = abs(first[i] - (first[i - 1] + 1));           ll dNow = abs(1 - (first[i - 1] + 1));           one[first[i]] += (dNow - dBef);         }       }     }     for (int i = 1; i <= n; i++) {       printf( %lld  , base);       base -= one[i];       base += chg[i] + one[i + 1];     }     putchar(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXV = 600, MAXE = 70000, inf = 1000000000;   int N, Count;   int G[MAXV], Queue[MAXV], Dist[MAXV], Pre[MAXV], Last[MAXV];   int Data[MAXE], Weight[MAXE], Cost[MAXE], Next[MAXE];   bool Flag[MAXV];   int Calc(int X) {     if (!X) return 0;     return Calc(X / 2) + X % 2;   }   void Add(int Number, int V1, int V2, int W, int C) {     Data[Number] = V2;     Weight[Number] = W;     Cost[Number] = C;     Next[Number] = G[V1];     G[V1] = Number;   }   void Connect(int V1, int V2, int W, int C) {     Add(Count++, V1, V2, W, C);     Add(Count++, V2, V1, 0, -C);   }   int SPFA(int S, int T) {     for (int i = 0; i <= T; i++) Dist[i] = inf;     Dist[S] = 0;     memset(Flag, 0, sizeof(Flag));     Queue[0] = S;     int F = 0, R = 1;     while (F != R) {       int V = Queue[F++];       if (F == MAXV) F = 0;       int P = G[V];       Flag[V] = false;       while (P != -1) {         int U = Data[P];         if (Weight[P] && Dist[V] + Cost[P] < Dist[U]) {           Dist[U] = Dist[V] + Cost[P];           Pre[U] = P;           if (!Flag[U]) Flag[Queue[R++] = U] = true;           if (R == MAXV) R = 0;         }         P = Next[P];       }     }     if (Dist[T] == inf) return -1;     int V = T;     while (V != S) {       Weight[Pre[V]]--;       Weight[Pre[V] ^ 1]++;       int U = Data[Pre[V] ^ 1];       if (U <= N && V > N) Last[V - N - 1] = U;       V = U;     }     return Dist[T];   }   int main() {     int M;     cin >> N >> M;     int A[250];     for (int i = 0; i < N; i++) cin >> A[i];     int S = N * 2 + 1, T = N * 2 + 2;     Count = 0;     for (int i = 0; i <= T; i++) G[i] = -1;     for (int i = 0; i < N; i++) Connect(S, i, 1, 0);     Connect(S, N, M, 0);     for (int i = 0; i < N; i++)       for (int j = i + 1; j < N; j++)         if (A[i] == A[j])           Connect(i, N + j + 1, 1, 0);         else           Connect(i, N + j + 1, 1, Calc(A[j]));     for (int i = 0; i < N; i++) Connect(N, N + i + 1, 1, Calc(A[i]));     for (int i = 1; i <= N; i++) Connect(N + i, T, 1, 0);     int Ans = 0, Tmp;     while (Tmp = SPFA(S, T), Tmp != -1) Ans += Tmp;     int Total = N;     for (int i = 0; i < N; i++)       if (Last[i] == N || A[Last[i]] != A[i]) Total++;     cout << Total <<     << Ans << endl;     int Number = 0, Var[250];     for (int i = 0; i < N; i++)       if (Last[i] == N) {         Var[i] = Number++;         printf( %c=%d nprint(%c) n , Var[i] + 97, A[i], Var[i] + 97);       } else if (A[i] == A[Last[i]]) {         Var[i] = Var[Last[i]];         printf( print(%c) n , Var[i] + 97);       } else {         Var[i] = Var[Last[i]];         printf( %c=%d nprint(%c) n , Var[i] + 97, A[i], Var[i] + 97);       }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     if (n == 0) {       cout <<  O-|-OOOO  << endl;       return 0;     }     while (n != 0) {       int k = n % 10;       if (k >= 5) {         cout <<  -O| ;         k -= 5;       } else         cout <<  O-| ;       int i = 0;       for (; i < k; i++) cout <<  O ;       cout <<  - ;       i++;       for (; i < 5; i++) cout <<  O ;       cout << endl;       n /= 10;     }   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 1e9 + 7;   int main() {     ios_base::sync_with_stdio(false);     cin.tie();     int n;     cin >> n;     int x;     cin >> x;     int a[n];     int pp[100005] = {0};     for (int i = 0; i < n; i++) {       cin >> a[i];       pp[a[i]]++;     }     long long c = 0;     for (int i = 0; i < n; i++) {       if (((a[i] ^ x) < 100005) && pp[a[i] ^ x]) {         c += pp[a[i] ^ x];       }     }     if (x == 0)       cout << (c - n) / 2 <<   n ;     else       cout << c / 2 <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t;     cin >> t;     int a[t + 10];     for (int i = 0; i < t; i++) {       long int b, p, f, c, h, c1 = 0, c2 = 0;       cin >> b >> p >> f;       cin >> h >> c;       b = b / 2;       if (b == 0) {         cout << 0 << endl;         continue;       }       if (h > c) {         if (b >= p) {           c1 += (p * h);           b -= p;           if (f >= b) {             c1 += b * c;           } else {             c1 += f * c;           }         } else {           c1 += b * h;         }       } else {         if (b >= f) {           b -= f;           c1 += c * f;           if (b > p) {             c1 += p * h;           } else {             c1 += b * h;           }         } else {           c1 += b * c;         }       }       cout << c1 << endl;       c1 = 0;     }   }
#include <bits/stdc++.h>   using namespace std;   int b[600][600], n, m, q, row[600];   int main() {     ios::sync_with_stdio(false);     scanf( %d%d%d , &n, &m, &q);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) {         int x;         scanf( %d , &x);         b[i][j] = x;       }     int ans = 0;     for (int i = 1; i <= n; i++) {       int len = 0;       int maxlen = 0;       for (int j = 1; j <= m; j++) {         if (b[i][j])           len++;         else           len = 0;         maxlen = max(len, maxlen);       }       row[i] = maxlen;     }     while (q--) {       int i, j;       scanf( %d%d , &i, &j);       b[i][j] ^= 1;       int len = 0;       int maxlen = 0;       for (j = 1; j <= m; j++) {         if (b[i][j])           len++;         else           len = 0;         maxlen = max(len, maxlen);       }       row[i] = maxlen;       int ans = 0;       for (int ii = 1; ii <= n; ii++) {         ans = max(ans, row[ii]);       }       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100500;   int a[maxn];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n;     long long k;     cin >> n >> k;     long long sm = 0;     priority_queue<pair<int, int> > pq;     for (int i = 0; i < n; ++i) {       cin >> a[i];       sm += a[i];       pq.push({-a[i], i});     }     if (sm < k) return cout << -1 <<   n , 0;     if (sm == k) return 0;     long long it = 0, lft = n;     while (true) {       assert(!pq.empty());       auto u = pq.top();       u.first += it;       lft = (int)pq.size();       if (lft * -1LL * u.first > k) break;       pq.pop();       while (pq.top().first + it == u.first) pq.pop();       k -= lft * -1LL * u.first;       it += u.first * -1LL;     }     for (int i = 0; i < n; ++i) a[i] = 0;     it += k / lft;     k %= lft;     while (!pq.empty()) {       a[pq.top().second] = (pq.top().first + it) * -1LL;       pq.pop();     }     queue<int> q;     for (int i = 0; i < n; ++i)       if (a[i]) q.push(i);     while (k--) {       auto u = q.front();       q.pop();       a[u]--;       if (a[u]) q.push(u);     }     while (!q.empty()) {       cout << q.front() + 1 <<    ;       q.pop();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double tt, anstt;   long long ansp, answ, tod[2000000], x1, x2, t1, t2, t0, ps;   int main() {     cin >> t1 >> t2 >> x1 >> x2 >> t0;     if (t1 == t2 && t1 == t0)       cout << x1 <<     << x2 << endl;     else {       tod[0] = x2;       ps = 0;       for (int i = 1; i <= x1; i++) {         long fl = 0;         while ((i * t1 + ps * t2) < (i + ps) * t0) {           ++ps;           fl = 1;           if (ps > x2) break;         }         tod[i] = ps;       }       anstt = 10000000;       for (int i = 0; i <= x1; i++) {         if (tod[i] <= x2) {           tt = i * t1 + tod[i] * t2;           tt = tt * 1.0 / (i + tod[i]);           anstt = min(anstt, tt);         }       }       anstt += 1e-8;       answ = -1;       for (int i = 0; i <= x1; i++) {         if (tod[i] <= x2) {           tt = i * t1 + tod[i] * t2;           tt = tt * 1.0 / (i + tod[i]);           if (tt < anstt) {             if (answ < i + tod[i]) {               answ = i + tod[i];               ansp = i;             }           }         }       }       cout << ansp <<     << tod[ansp] << endl;     }     cin.get();     cin.get();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }   long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }   long long power(long long x, long long y, long long p) {     long long res = 1;     x = x % p;     while (y > 0) {       if (y & 1) res = ((res % p) * (x % p)) % p;       y = y >> 1;       x = ((x % p) * (x % p)) % p;     }     return res % p;   }   long long raichu(long long x, long long y) {     long long res = 1;     while (y > 0) {       if (y & 1) res = ((res) * (x));       y = y >> 1;       x = ((x) * (x));     }     return res;   }   bool isprime(long long n) {     if (n < 2)       return false;     else if (n == 2)       return true;     else if (n % 2 == 0)       return false;     else {       long long z = sqrt(n);       for (int i = 0; i < z - 1; i++)         if (n % (i + 2) == 0) return false;       return true;     }   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int tests = 1, Tests;     Tests = tests;     while (tests--) {       int n, l, r, x;       cin >> n >> l >> r >> x;       vector<int> c(n);       for (int i = 0; i < n; i++) cin >> c[i];       vector<int> tmp;       sort(c.begin(), c.end());       int ans = 0;       for (int i = 0; i < (1 << n); i++) {         tmp.clear();         int sum = 0;         for (int j = 0; j < n; j++) {           if ((i >> j) & 1) {             tmp.push_back(c[j]);             sum += c[j];           }         }         if ((int)tmp.size() >= 2 && sum >= l && sum <= r &&             tmp[(int)tmp.size() - 1] - tmp[0] >= x) {           ans++;         }       }       cout << ans;     }     return 0;   }
#include<bits/stdc++.h>   #define int long long   using namespace std;   const int N=1e5+5;   #define pb push_back   int n,m,t;   int i,j,k;   int a[N];   int b[N],c[N];   vector<int> ans;   vector<int>v[N];   int vis[N];       signed main()   {       int t;       cin>>t;       while(t--){        int n;     cin>>n;     int m=(n-1);     int f=sqrt(2*m+1);    // cout<<f<<endl;     if(f<3) cout<<0<<endl;     else cout<<(f-1)/2<<endl;    }       return 0;   }
#include <bits/stdc++.h>   const int MAXA = 5005;   const int MAXN = 2016;   int array[MAXN]{};   long long diffr[MAXA]{};   long long suffx[MAXA]{};   long double total;   long long Ans = 0;   int N;   int main() {     scanf( %d , &N);     for (int i = 0; i < N; ++i) scanf( %d , &array[i]);     total = N * (N - 1) >> 1;     std::sort(array, array + N);     for (int i = 0; i < N; ++i)       for (int j = i + 1; j < N; ++j) ++diffr[array[j] - array[i]];     for (int i = 5000; i >= 0; --i) suffx[i] = suffx[i + 1] + diffr[i];     for (int i = 1; i <= 5000; ++i)       for (int j = 1; i + j <= 5000; ++j)         Ans += diffr[i] * diffr[j] * suffx[i + j + 1];     std::cout << std::setprecision(9) << Ans / total / total / total <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     const long long MOD = 1000000009;     int n, m;     cin >> n >> m;     long long ret = 1;     long long x = 1;     for (int i = 0; i < (int)(m); i++) x = x * 2 % MOD;     x = (x - 1 + MOD) % MOD;     for (int i = 0; i < (int)(n); i++) {       ret = ret * x % MOD;       if (--x < 0) x = 0;     }     cout << ret << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using pii = pair<long long, long long>;   const long long INF = 2e18;   template <class A, class B>   ostream &operator<<(ostream &os, const pair<A, B> &p) {     os <<  (  << p.first <<  ,   << p.second <<  ) ;     return os;   }   template <class A>   ostream &operator<<(ostream &os, const vector<A> &v) {     os <<  { ;     for (long long i = 0; i < (long long)v.size(); i++)       if (i == 0)         os << v[i];       else         os <<  ,   << v[i];     os <<  } ;     return os;   }   void dprint(string s) { cout <<   n ; }   template <class T, class... U>   void dprint(string s, T t, U... u) {     long long w = s.find( , );     cout <<  [  << s.substr(0, w) <<  :   << t <<  ]  ;     dprint(s.substr(w + 2, (long long)s.size() - w - 1), u...);   }   const long long N = 1e6 + 5;   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     string s;     cin >> s;     vector<pair<char, long long>> v;     for (long long i = 0; i < (long long)(s).size();) {       char c = s[i];       long long cnt = 0;       while (s[i] == c and i < (long long)(s).size()) cnt++, i++;       v.push_back({c, cnt});     }     if ((long long)(v).size() % 2) {       bool ok = 1;       for (long long i = 0; i < (long long)(v).size() / 2; i++) {         if (v[i].first == v[(long long)(v).size() - 1 - i].first and             v[i].second + v[(long long)(v).size() - 1 - i].second >= 3)           ;         else           ok = 0;       }       if (v[(long long)(v).size() / 2].second == 1) ok = 0;       if (ok)         cout << v[(long long)(v).size() / 2].second + 1;       else         cout << 0;     } else {       cout << 0;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 5;   vector<int> v[maxn];   int vos[maxn];   int ans;   void dfs(int now, int pre) {     if (vos[now]) {       ans = 0;       return;     }     vos[now] = 1;     for (int i = 0; i < v[now].size(); i++) {       if (v[now][i] != pre) {         dfs(v[now][i], now);       }     }   }   int main() {     int n, m;     scanf( %d%d , &n, &m);     int a, b;     for (int i = 0; i < m; i++) {       scanf( %d%d , &a, &b);       v[a].push_back(b);       v[b].push_back(a);     }     memset(vos, 0, sizeof(vos));     int sum = 0;     for (int i = 1; i <= n; i++) {       if (vos[i]) continue;       ans = 1;       dfs(i, 0);       sum += ans;     }     printf( %d n , sum);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1000000007LL;   int n, k;   string s;   long long A[30];   long long ans, aux;   int last[30];   int main() {     cin >> n >> k >> s;     memset(last, -1, sizeof(last));     int m = s.length();     ans = 1LL;     for (int i = 0; i < m; i++) {       aux = ans;       ans = (2 * ans + MOD - A[s[i] -  a ]) % MOD;       A[s[i] -  a ] = aux;       last[s[i] -  a ] = i;     }     for (int j = 0; j < n; j++) {       int mini = (1 << 30);       int let;       for (int i = 0; i < k; i++) {         if (last[i] < mini) {           mini = last[i];           let = i;         }       }       aux = ans;       ans = (2 * ans + MOD - A[let]) % MOD;       A[let] = aux;       last[let] = m + j;     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   char x[1500001];   int k, i, starti, fini;   bool start, finish, found[500001];   int main() {     while (cin.getline(x, 1500001)) {       k++;       found[k] = false;       int a = strlen(x);       for (i = 0; i < a; i++) {         if (x[i] !=     && x[i] !=  #  && !found[k]) break;         if (x[i] ==  # ) {           found[k] = true;           break;         }       }       if (found[k]) {         if (!found[k - 1] && k != 1) cout <<   n ;         cout << x <<   n ;       } else {         int p = strlen(x);         for (i = 0; i < p; i++) {           if (x[i] ==    ) {             continue;           } else             cout << x[i];         }       }     }     if (!found[k]) cout <<   n ;   }
#include <bits/stdc++.h>   const int inf = 0xfffffff;   const long long INF = 1ll << 61;   using namespace std;   int num[1000000 + 5];   int b[1000000 + 5];   int c[1000000 + 5];   int n;   int ans;   void init() {     memset(num, 0, sizeof(num));     memset(b, 0, sizeof(b));     memset(c, 0, sizeof(c));     ans = 0;   }   bool input() {     while (scanf( %d , &n) == 1) {       return false;     }     return true;   }   void cal() {     n++;     for (int i = 2; i <= n; i++) {       scanf( %d , &num[i]);       b[i] = 1;       c[i] = 0;       int j = i;       if (ans < b[j]) ans = b[j];       while (num[j] != 1) {         if (ans < b[j]) ans = b[j];         if (ans < b[num[j]]) ans = b[num[j]];         if (b[num[j]] < b[j]) {           b[num[j]] = b[j];           c[num[j]] = 1;         } else if (c[num[j]] == 1 && b[num[j]] == b[j]) {           b[num[j]] = b[j] + 1;           c[num[j]] = 0;         } else if (c[num[j]] == 0 && b[num[j]] == b[j]) {           c[num[j]] = 1;           break;         } else           break;         if (ans < b[num[j]]) ans = b[num[j]];         j = num[j];       }       printf( %d%c , ans, i == 1 ?   n  :    );     }   }   void output() {}   int main() {     while (true) {       init();       if (input()) return 0;       cal();       output();     }   }
#include <bits/stdc++.h>   using namespace std;   const double PI = acos(-1);   const int N = 100000 + 5;   long long q;   long long tree[4000005], lazy[4000005];   long long ti[1000005], di[1000005];   void lazify(long long s, long long e, long long i) {     if (lazy[i]) {       tree[i] += lazy[i];       if (s != e) {         lazy[2 * i] += lazy[i];         lazy[2 * i + 1] += lazy[i];       }       lazy[i] = 0;     }   }   void upd(long long l, long long r, long long s, long long e, long long i,            long long x) {     lazify(s, e, i);     if (s > r || e < l) return;     if (s >= l && e <= r) {       lazy[i] += x;       lazify(s, e, i);       return;     }     long long mid = (s + e) >> 1;     upd(l, r, s, mid, 2 * i, x);     upd(l, r, mid + 1, e, 2 * i + 1, x);     tree[i] = min(tree[2 * i], tree[2 * i + 1]);   }   long long pquery(long long l, long long r, long long s, long long e,                    long long i) {     if (s > r || e < l) return 1e18;     lazify(s, e, i);     if (s >= l && e <= r) return tree[i];     long long mid = (s + e) >> 1;     return min(pquery(l, r, s, mid, 2 * i), pquery(l, r, mid + 1, e, 2 * i + 1));   }   void build(long long l, long long r, long long i) {     if (l == r) {       tree[i] = -l;       return;     }     long long mid = (l + r) >> 1;     build(l, mid, 2 * i);     build(mid + 1, r, 2 * i + 1);     tree[i] = min(tree[2 * i], tree[2 * i + 1]);   }   long long get(long long t) {     long long x = pquery(t, t, 1, 1000000, 1);     long long y = pquery(1, t - 1, 1, 1000000, 1);     y = min(y, 0ll);     return x - y + 1;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     build(1, 1000000, 1);     cin >> q;     for (int i = 1; i <= q; i++) {       char c;       long long in;       cin >> c;       if (c ==  + ) {         cin >> ti[i] >> di[i];         upd(ti[i], 1000000, 1, 1000000, 1, di[i]);       } else if (c ==  - ) {         cin >> in;         upd(ti[in], 1000000, 1, 1000000, 1, -di[in]);       } else if (c ==  ? ) {         cin >> in;         cout << get(in) << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   bitset<4096> f[100020];   int a[13][100005], b[100005][13], now;   bool cmp(int x, int y) {     return a[x][now] == a[y][now] ? x > y : a[x][now] > a[y][now];   }   int main() {     int n, q, k, cnt, op, x, y;     scanf( %d%d%d , &n, &k, &q);     cnt = k;     for (int i = 1; i <= k; i++)       for (int j = 1; j <= n; j++) scanf( %d , &a[i][j]), b[j][i] = i;     for (int i = 1; i <= n; i++) now = i, sort(b[i] + 1, b[i] + k + 1, cmp);     for (int i = 1; i <= k; i++)       for (int j = 0; j < (1 << k); j++)         if (j & (1 << (i - 1))) f[i][j] = 1;     while (q--) {       scanf( %d%d%d , &op, &x, &y);       if (op == 1)         cnt++, f[cnt] = f[x] | f[y];       else if (op == 2)         cnt++, f[cnt] = f[x] & f[y];       else         for (int i = 1, t = 0; i <= k; i++) {           t |= (1 << (b[y][i] - 1));           if (f[x][t]) {             printf( %d n , a[b[y][i]][y]);             break;           }         }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1E6 + 5, INF = 1E9 + 7;   int m, n, ans = INF;   mt19937 mt(133769420);   int ask(int u, int v) {     cout <<  ?   << u <<     << v << endl;     int ret;     cin >> ret;     return ret;   }   int rand(int l, int r) {     uniform_int_distribution<int> uni(l, r);     return uni(mt);   }   void solve(int u, int d, int l, int r) {     if (u > d) {       return;     }     int m = rand(u, d);     pair<int, int> mi = {INF, 0};     for (int i = l; i <= r; i++) {       mi = min(mi, {ask(m, i), i});     }     ans = min(ans, mi.first);     solve(u, m - 1, l, mi.second);     solve(m + 1, d, mi.second, r);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cin >> m >> n;     solve(1, m, 1, n);     cout <<  !   << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     int x = 0, f = 1;     char c = getchar();     while (c <  0  || c >  9 ) {       if (c ==  - ) f = -1;       c = getchar();     }     while (c >=  0  && c <=  9 ) {       x = (x << 3) + (x << 1) + c -  0 ;       c = getchar();     }     return x * f;   }   int w, h, n, l, r;   char opt[3];   set<int> a, b;   multiset<int> f, g;   int main() {     w = read(), h = read(), n = read();     a.insert(0), b.insert(0);     a.insert(w), b.insert(h);     f.insert(w), g.insert(h);     for (int i = 1; i <= n; i++) {       scanf( %s , opt + 1);       int x = read();       if (opt[1] ==  V ) {         r = (*a.lower_bound(x));         l = (*(--a.lower_bound(x)));         f.erase(f.find(r - l));         f.insert(r - x), f.insert(x - l);         a.insert(x);       } else {         r = (*b.lower_bound(x));         l = (*(--b.lower_bound(x)));         g.erase(g.find(r - l));         g.insert(r - x), g.insert(x - l);         b.insert(x);       }       printf( %I64d n , 1LL * (*(--f.end())) * (*(--g.end())));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double table[2][1005];   int main() {     int N, K;     cin >> N >> K;     for (int t = 1; t <= N; t++) {       for (int l = 1; l < 1000; l++) {         double good = ((l + table[(t - 1) & 1][l + 1]) +                        l * ((l + 1) / 2.0 + table[(t - 1) & 1][l])) /                       (l + 1);         table[t & 1][l] = (good + (K - 1.0) * table[(t - 1) & 1][l]) / K;       }       double good = (1000 + 2) / 2.0 + table[(t - 1) & 1][1000];       table[t & 1][1000] = (good + (K - 1.0) * table[(t - 1) & 1][1000]) / K;     }     printf( %.12f n , K * table[N & 1][1]);   }