malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 300010;   pair<int, int> c[MAXN];   int n, x[2];   bool check(int pos, int fst, int snd) {     int a = c[pos].first;     int k = (x[fst] + a - 1) / a;     if (pos + k >= n) {       return false;     }     int val = c[pos + k].first;     int dk = (x[snd] + val - 1) / val;     if (pos + k + dk > n) {       return false;     }     if (fst == 0) {       printf( Yes n );       printf( %d %d n , k, dk);       for (int i = 0; i < k; ++i) {         printf( %d  , c[pos + i].second + 1);       }       printf(  n );       for (int i = 0; i < dk; ++i) {         printf( %d  , c[pos + k + i].second + 1);       }       printf(  n );     } else {       printf( Yes n );       printf( %d %d n , dk, k);       for (int i = 0; i < dk; ++i) {         printf( %d  , c[pos + k + i].second + 1);       }       printf(  n );       for (int i = 0; i < k; ++i) {         printf( %d  , c[pos + i].second + 1);       }       printf(  n );     }     return true;   }   int main() {     scanf( %d%d%d , &n, &x[0], &x[1]);     for (int i = 0; i < n; ++i) {       scanf( %d , &c[i].first);       c[i].second = i;     }     sort(c, c + n);     for (int i = 0; i < n; ++i) {       if (check(i, 0, 1) || check(i, 1, 0)) {         return 0;       }     }     printf( No n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s;   int n, m, ans = 0;   int main() {     cin >> n >> m;     while (n--) {       cin >> s;     }     int flag = 0;     for (int i = 0; i < s.size(); ++i) {       if (s[i] ==  B ) {         flag = 1;       } else if (flag) {         flag = 0;         ans++;       }     }     cout << ans + flag <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long x2, y2;   long long euler(long long a, long long b) {     if (b == 0) {       x2 = 1;       y2 = 0;       return a;     } else {       long long res = euler(b, a % b);       long long temp = x2;       x2 = y2;       y2 = temp - (a / b) * y2;       return res;     }   }   int main() {     int T;     long long x, y, m, n, vx, vy;     long long k1, k2;     long long res, res1, res2, xx, yy;     cin >> n >> m >> x >> y >> vx >> vy;     if (!vx) {       if ((!x) || (x == n)) {         cout << x <<     << (vy > 0 ? m : 0) << endl;       } else         cout <<  -1  << endl;       return 0;     }     if (!vy) {       if ((!y) || (y == m)) {         cout << (vx > 0 ? n : 0) <<     << y << endl;       } else         cout <<  -1  << endl;       return 0;     }     k1 = (vx == 1 ? ((n - x) % n) : (x % n));     k2 = (vy == 1 ? ((m - y) % m) : (y % m));     long long g = euler(n, m);     if (abs(k1 - k2) % g) {       cout <<  -1  << endl;       return 0;     }     long long lcm = m * n / g;     res1 = (k2 * x2) % m;     res1 = res1 * (n / g);     res2 = (k1 * y2) % n;     res2 = res2 * (m / g);     res = (res1 + res2) % lcm;     res = (res + lcm) % lcm;     xx = x + res * vx;     yy = y + res * vy;     cout << ((xx % (2 * n)) + 2 * n) % (2 * n) <<              << ((yy % (2 * m)) + 2 * m) % (2 * m) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7;   const int MAX = 1e5 + 5;   int n, s, h, m;   vector<pair<int, int> > a;   int main(int argc, char const *argv[]) {     ios_base::sync_with_stdio(false);     cin >> n >> s;     for (int i = 0; i < n; i++) {       cin >> h >> m;       a.push_back(make_pair(h, m));     }     bool done = false;     if (a[0].first * 60 + a[0].second >= s + 1)       cout <<  0 0 ;     else {       for (int i = 0; i < n - 1; i++) {         int gap =             (a[i + 1].first - a[i].first) * 60 + (a[i + 1].second - a[i].second);         if (gap >= 2 * (s + 1)) {           done = true;           if (a[i].second + s + 1 >= 60) {             int mins = s + 1 - (60 - a[i].second);             if (mins == 60)               cout << a[i].first + 2 <<   0 ;             else               cout << a[i].first + 1 <<     << mins;           } else             cout << a[i].first <<     << a[i].second + s + 1;           break;         }       }       if (!done) {         if (a[n - 1].second + s + 1 >= 60) {           int mins = s + 1 - (60 - a[n - 1].second);           if (mins == 60)             cout << a[n - 1].first + 2 <<   0 ;           else             cout << a[n - 1].first + 1 <<     << mins;         } else           cout << a[n - 1].first <<     << a[n - 1].second + s + 1;       }     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC target( avx2 )   #pragma GCC optimization( O3 )   #pragma GCC optimization( unroll-loops )   using namespace std;   template <class T>   using vec = std::vector<T>;   bool __hack = std::ios::sync_with_stdio(false);   auto __hack1 = cin.tie(nullptr);   struct Input {     Input(istream &in) : in(&in) {}     template <class T>     T next() const {       T x;       *in >> x;       return x;     }     int ni() const { return next<int>(); }     istream *in;   };   Input in(cin);   class Output {    private:     ostream *out;     template <typename T>     void printSingle(const T &value) {       *out << value;     }       public:     Output(ostream &out) : out(&out) {}     inline void print() {}     template <typename T, typename... Ts>     inline void print(const T &f, const Ts &...args) {       printSingle(f);       if (sizeof...(args) != 0) {         *out <<    ;         print(args...);       }     }     template <typename... Ts>     inline void println(const Ts &...args) {       print(args...);       *out <<   n ;     }     template <typename... Ts>     inline void operator()(const Ts &...args) {       println(args...);     }     template <typename T>     ostream &operator<<(const T &x) {       *out << x;       return *out;     }   };   Output out(cout);   namespace template_util {   constexpr int bytecount(uint64_t x) { return x ? 1 + bytecount(x >> 8) : 0; }   template <int N>   struct bytetype {};   template <uint64_t N>   struct minimal_uint : bytetype<bytecount(N)> {};   }  // namespace template_util   void solveOne() {     auto n = in.ni();     auto m = in.ni();     vec<pair<int, int>> edges(m);     for (int i = 0; i < (m); ++i) {       auto x = in.ni() - 1;       auto y = in.ni() - 1;       if (x > y) swap(x, y);       edges[i] = {x, y};     }     vec<int> used(3 * n, 0);     vec<int> takenEdges;     for (int i = 0; i < (m); ++i) {       if (!used[edges[i].first] && !used[edges[i].second]) {         takenEdges.push_back(i);         used[edges[i].first] = true;         used[edges[i].second] = true;       }       if (takenEdges.size() == n) {         out( Matching );         for (const auto &e : takenEdges) {           out << e + 1 <<    ;         }         out();         return;       }     }     out( IndSet );     int cnt = 0;     for (int i = 0; i < (3 * n); ++i) {       if (!used[i]) {         out << i + 1 <<    ;         ++cnt;       }       if (cnt == n) break;     }     out();   }   void solve(istream &inStream, ostream &outStream) {     in = Input(inStream);     out = Output(outStream);     auto tests = in.ni();     while (tests--) {       solveOne();     }   }   int main() {     solve(cin, cout);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long mod = 1e9 + 7;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n, m, x;     cin >> n >> m >> x;     x--;     if (n > m) {       cout << 0 << endl;       return 0;     }     vector<vector<long long>> dp(n + 1, vector<long long>(n + 1, 0));     dp[0][0] = 1;     for (int i = 0; i < m; i++) {       vector<vector<long long>> ndp(n + 1, vector<long long>(n + 1, 0));       for (int j = 0; j <= n; j++)         for (int k = 0; j + k <= n; k++) {           if (i != x) (ndp[j][k] += dp[j][k]) %= mod;           if (j + k + 1 <= n) (ndp[j + 1][k] += dp[j][k]) %= mod;           if (i != x && j) (ndp[j - 1][k + 1] += dp[j][k]) %= mod;           if (j + k + 1 <= n) (ndp[j][k + 1] += dp[j][k]) %= mod;         }       swap(dp, ndp);     }     long long ans = dp[0][n];     for (int i = 1; i <= n; i++) (ans *= i) %= mod;     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, k;   int s;   struct DSU {     int p[505];     void init() {       for (int i = 1; i <= n; i++) p[i] = i;     }     int find(int x) { return p[x] == x ? x : p[x] = find(p[x]); }     int count() {       int count = 0;       for (int i = 1; i <= n; i++)         if (p[i] == i) count++;       return count;     }     void link(int a, int b) { p[find(a)] = find(b); }   } L[10050], R[10050];   DSU hebing(DSU L, DSU R) {     DSU a = L;     for (int i = 1; i <= n; i++) a.link(i, R.find(i));     return a;   }   int l[10050], r[10050];   int main() {     cin >> n >> m;     L[0].init();     for (int i = 1; i <= m; i++) {       cin >> l[i];       cin >> r[i];       L[i] = L[i - 1];       L[i].link(l[i], r[i]);     }     R[m + 1].init();     for (int i = m; i >= 1; i--) {       R[i] = R[i + 1];       R[i].link(l[i], r[i]);     }     cin >> k;     while (k--) {       int x1, y1;       cin >> x1 >> y1;       DSU h = hebing(L[x1 - 1], R[y1 + 1]);       cout << h.count() << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     map<int, int, greater<int>> input;     map<int, int, greater<int>> output;     map<int, int, greater<int>> input_reverse;     map<int, int, greater<int>> output_reverse;     int N;     scanf( %d , &N);     ;     int i = N;     int index = 1;     while (i--) {       int x;       scanf( %d , &x);       input[index] = x;       input_reverse[x] = index++;     }     index = 1;     while (N--) {       int x;       scanf( %d , &x);       output[index] = x;       output_reverse[x] = index++;     }     map<int, int, greater<int>>::iterator it1;     int val = 0;     int count_val = 0;     it1 = input.begin();     while (!input.empty()) {       int x = (*it1).second;       if (x != (*(output.begin())).second) {         val = val + count_val + 1;         count_val = 0;       } else {         count_val++;       }       it1++;       input.erase((*(input_reverse.find(x))).second);       output.erase((*(output_reverse.find(x))).second);     }     printf( %d n , val);   }
#include <bits/stdc++.h>   namespace FastIO {   bool IOerror = 0;   inline char nc() {     static char buf[100000], *p1 = buf + 100000, *pend = buf + 100000;     if (p1 == pend) {       p1 = buf;       pend = buf + fread(buf, 1, 100000, stdin);       if (pend == p1) {         IOerror = 1;         return -1;       }     }     return *p1++;   }   inline bool blank(char ch) {     return ch ==     || ch ==   n  || ch ==   r  || ch ==   t ;   }   template <class T>   inline bool read(T &x) {     bool sign = 0;     char ch = nc();     x = 0;     for (; blank(ch); ch = nc())       ;     if (IOerror) return false;     if (ch ==  - ) sign = 1, ch = nc();     for (; ch >=  0  && ch <=  9 ; ch = nc()) x = x * 10 + ch -  0 ;     if (sign) x = -x;     return true;   }   template <class T, class... U>   bool read(T &h, U &...t) {     return read(h) && read(t...);   }   };  // namespace FastIO   using namespace std;   using namespace FastIO;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   const int INF = 0x3f3f3f3f;   const int N = 1e5 + 10;   struct node {     int l, r, sum;     bitset<1010> f;   } tree[N * 15];   int root[N], cnt;   int n, m, q;   bitset<1010> base;   void ins(int &x, int pre, int l, int r, int i, int j, int op) {     x = ++cnt;     tree[x] = tree[pre];     if (l == r) {       if (op == 1) tree[x].f.set(j);       if (op == 2) tree[x].f.reset(j);       if (op == 3) tree[x].f ^= base;       tree[x].sum = tree[x].f.count();       return;     }     int mid = (l + r) / 2;     if (i <= mid)       ins(tree[x].l, tree[pre].l, l, mid, i, j, op);     else       ins(tree[x].r, tree[pre].r, mid + 1, r, i, j, op);     tree[x].sum = tree[tree[x].l].sum + tree[tree[x].r].sum;     return;   }   signed main() {     read(n, m, q);     for (int i = 1; i <= m; i++) base.set(i);     for (int i = 1; i <= q; i++) {       int op, x, y;       read(op);       if (op <= 2) {         read(x, y);         ins(root[i], root[i - 1], 1, n, x, y, op);       }       if (op == 3) {         read(x);         ins(root[i], root[i - 1], 1, n, x, 0, op);       }       if (op == 4) {         read(x);         root[i] = root[x];       }       printf( %d n , tree[root[i]].sum);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long L[100005];   long long P[100005][40];   long long T[100005];   vector<long long> graph[100005];   long long mx = 0, hh;   void dfs(long long src, long long par) {     if (src == -1)       L[par] = 0;     else       L[par] = L[src] + 1;     if (mx < L[par]) {       hh = par;       mx = max(mx, L[par]);     }     T[par] = src;     long long len = graph[par].size();     for (long long i = 0; i < (long long)graph[par].size(); i++) {       long long v = graph[par][i];       if (v != src) {         dfs(par, v);       }     }   }   void dfs1(long long src, long long par) {     if (src == -1)       L[par] = 0;     else       L[par] = L[src] + 1;     if (mx < L[par]) {       hh = par;       mx = max(mx, L[par]);     }     long long len = graph[par].size();     for (long long i = 0; i < (long long)graph[par].size(); i++) {       long long v = graph[par][i];       if (v != src) {         dfs1(par, v);       }     }   }   int main() {     long long i, j, n, m, t, a, b, c, d, e, f, x, y;     scanf( %lld , &t);     for (long long cz = 0; cz < t; cz++) {       scanf( %lld%lld%lld%lld%lld , &n, &a, &b, &c, &d);       for (i = 0; i < n - 1; i++) {         scanf( %lld%lld , &x, &y);         graph[x].push_back(y);         graph[y].push_back(x);       }       mx = 0;       dfs(-1, a);       long long cc, dd;       cc = L[b];       for (i = 0; i <= n; i++) {         L[i] = 0;       }       mx = 0;       dfs1(-1, hh);       if (c * 2 >= min(d, mx) || cc <= c) {         printf( Alice n );       } else         printf( Bob n );       for (i = 0; i <= n; i++) {         graph[i].clear();         L[i] = 0;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int const N = 200001;   int main() {     long long n, k, d;     scanf( %lld%lld%lld , &n, &k, &d);     if (d < k) return puts( NO ), 0;     long long dv = d / k;     if (dv + 1 > n || (dv + (d % k == 0 ? 0 : 2)) > n) return puts( NO ), 0;     vector<long long> an;     puts( YES );     if (d % k == 0) {       for (int j = 0; j < k; ++j) {         if (j & 1)           printf( 1  );         else           printf( %lld  , 1ll + dv);       }       return 0;     }     long long lst = 1;     for (int j = 0; j < (d % k); ++j) {       if (j & 1)         printf( 1  ), lst = 1ll;       else         printf( %lld  , 2ll + dv), lst = 2ll + dv;     }     for (int j = 0; j < k - (d % k); ++j) {       if (j & 1)         printf( %lld  , lst);       else         printf( %lld  , lst - dv >= 1 ? lst - dv : lst + dv);     }   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, p;   int q[100010];   long long f[106][100010], D[100010], sum[100010], A[100010], g[100010];   int main() {     scanf( %lld %lld %lld , &n, &m, &p);     for (int i = 2; i <= n; i++) scanf( %lld , &D[i]), D[i] += D[i - 1];     long long H, T;     for (int i = 1; i <= m; i++) {       scanf( %lld %lld , &H, &T);       A[i] = T - D[H];     }     sort(A + 1, A + 1 + m);     for (int i = 1; i <= m; i++) sum[i] = A[i] + sum[i - 1];     memset(f, 0x3f, sizeof(f));     f[0][0] = 0;     for (int i = 1; i <= p; i++) {       int l = 1, r = 1;       q[1] = 0;       for (int j = 1; j <= m; j++) g[j] = f[i - 1][j] + sum[j];       for (int j = 1; j <= m; j++) {         while (l < r && (g[q[l + 1]] - g[q[l]]) <= A[j] * (q[l + 1] - q[l])) l++;         f[i][j] = min(f[i - 1][j], g[q[l]] + A[j] * (j - q[l]) - sum[j]);         if (g[j] >= 0x3f3f3f3f3f3f3f3fll) continue;         while (l < r && (g[j] - g[q[r]]) * (q[r] - q[r - 1]) <=                             (g[q[r]] - g[q[r - 1]]) * (j - q[r]))           r--;         q[++r] = j;       }     }     cout << f[p][m] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int s, x;     cin >> s >> x;     long long int i, c = 1, f = 0;     long long int a = (s - x) / 2;     if ((s - x) % 2 != 0)       cout << 0;     else {       for (i = 0; i < 64; i++) {         long long int x1 = ((x >> i) & 1);         long long int a1 = ((a >> i) & 1);         if (x1 == 0 && a1 == 1) f = 1;         if (x1 == 1 && a1 == 0) c = c * 2;         if (x1 == 1 && a1 == 1) {           f = 1;           c = 0;         }       }       if (f == 1)         cout << c;       else         cout << (c - 2);     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int i, t, n, m, a[105], ans[105] = {0};     cin >> n >> m;     for (__typeof(0) i = 0; i <= m - 1; i++) cin >> a[i];     for (__typeof(0) i = 0; i <= m - 1; i++) {       int tem = a[i];       for (int j = tem; j <= n; j++) {         if (ans[j] == 0) ans[j] = a[i];       }     }     for (__typeof(1) i = 1; i <= n; i++) cout << ans[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MX = 100000 + 10;   long long n, arr[MX];   struct node {     long long bit_[3];     node() { memset(bit_, 0, sizeof(bit_)); }   };   vector<node> tree;   void add(long long inode, long long ptr, long long num) {     if (ptr < 0) return;     long long q = (num >> ptr) & 1;     if (tree[inode].bit_[q] == 0) {       tree.push_back(node());       tree[inode].bit_[q] = (int)tree.size() - 1;     }     add(tree[inode].bit_[q], ptr - 1, num);   }   long long find_fit(long long x) {     int ptr = 45;     long long nd = 0;     long long sol = 0;     while (ptr >= 0) {       sol *= 2;       long long q = !((x >> ptr) & 1);       if (q == 1) {         if (tree[nd].bit_[1] != 0) {           nd = tree[nd].bit_[1];           sol++;         } else           nd = tree[nd].bit_[0];       } else {         if (tree[nd].bit_[0] != 0)           nd = tree[nd].bit_[0];         else {           nd = tree[nd].bit_[1];           sol++;         }       }       ptr--;     }     return sol;   }   int main() {     tree.push_back(node());     cin >> n;     long long q = 0;     add(0, 45, 0);     for (int i = 0; i < n; i++) {       cin >> arr[i];       q ^= arr[i];       add(0, 45, q);     }     q = 0;     long long ans = 0;     for (int i = n - 1; i >= 0; i--) {       q ^= arr[i];       long long p = find_fit(q);       ans = max(ans, p ^ q);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     long long y, z;     long long x;     int choice;   };   node g[2000001];   int cmp(node head, node a) {     if (head.y != a.y) return head.y < a.y;     if (head.z != a.z) return head.z < a.z;     return head.x > a.x;   }   struct info {     int choice;     long long x;   } f[2000001];   int m, n;   int has = 0;   struct self {     int x, y, z;   } s[33];   long long ans;   int choicex, choicey;   int ipow(int i, int k) {     if (k == 0) return 1;     return i * ipow(i, k - 1);   }   int bs(long long y, long long z) {     int l = 1, r = has, mid, ret = 0;     while (l <= r) {       mid = (l + r) >> 1;       if (g[mid].y > y || (g[mid].y == y && g[mid].z >= z)) {         ret = mid;         r = mid - 1;       } else         l = mid + 1;     }     if (g[ret].y == y && g[ret].z == z)       return ret;     else       return 0;   }   void rep(int i, int u) {     if (i == 1) {       int t = u % 3;       if (t == 0) printf( LM n );       if (t == 1) printf( LW n );       if (t == 2) printf( MW n );       return;     }     rep(i - 1, u / 3);     int t = u % 3;     if (t == 0) printf( LM n );     if (t == 1) printf( LW n );     if (t == 2) printf( MW n );   }   void p(int i, int u) {     while (i <= m) {       int t = u % 3;       u /= 3;       i++;       if (t == 0) printf( LM n );       if (t == 1) printf( LW n );       if (t == 2) printf( MW n );     }   }   void print(int l, int r) {     rep(n, l);     p(n + 1, r);   }   int main() {     ans = -1e14;     scanf( %d , &m);     for (int i = 1; i <= m; i++) scanf( %d%d%d , &s[i].x, &s[i].y, &s[i].z);     if (m % 2 == 0)       n = m / 2;     else       n = m / 2 + 1;     for (int i = 0; i < ipow(3, n); i++) {       int v = i;       long long x = 0, y = 0, z = 0;       for (int j = n; j >= 1; j--) {         int k = v % 3, li = j;         long long a = x, b = y;         if (k == 0) {           x += s[li].x;           y += s[li].y;         }         if (k == 1) {           x += s[li].x;           z += s[li].z;         }         if (k == 2) {           y += s[li].y;           z += s[li].z;         }         v /= 3;       }       y -= x;       z -= x;       has++;       g[has].x = x;       g[has].y = y;       g[has].z = z;       g[has].choice = i;     }     sort(g + 1, g + has + 1, cmp);     for (int i = 0; i < ipow(3, m - n); i++) {       int v = i;       long long x = 0, y = 0, z = 0;       for (int j = n + 1; j <= m; j++) {         int k = v % 3, li = j;         if (k == 0) {           x += s[li].x;           y += s[li].y;         }         if (k == 1) {           x += s[li].x;           z += s[li].z;         }         if (k == 2) {           y += s[li].y;           z += s[li].z;         }         v /= 3;       }       y -= x;       z -= x;       int pos = bs(-y, -z);       if (pos != 0)         if (g[pos].x + x > ans) {           ans = g[pos].x + x;           choicex = g[pos].choice;           choicey = i;         }     }     if (ans != -1e14)       print(choicex, choicey);     else       printf( Impossible n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int test;     cin >> test;     while (test--) {       int n, m;       cin >> n >> m;       string S;       cin >> S;       vector<int> P(m);       vector<int> cnt(n);       for (int i = 0; i < m; i++) {         cin >> P[i];         cnt[0]++;         cnt[P[i]]--;       }       vector<int> res(26);       for (int i = 0; i < n; i++) res[S[i] -  a ]++;       res[S[0] -  a ] += cnt[0];       for (int i = 1; i < n; i++) {         cnt[i] += cnt[i - 1];         res[S[i] -  a ] += cnt[i];       }       for (int i = 0; i < 26; i++) cout << res[i] <<     << flush;       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100005;   struct node {     long long x, s[8];     int id;   } a[N];   int n, p, t;   long long f[N][(1 << 8) + 5];   bool cmp(node a, node b) { return a.x > b.x; }   int main() {     scanf( %d%d%d , &n, &p, &t);     for (int i = 1; i <= n; i++) {       scanf( %lld , &a[i].x);       a[i].id = i;     }     for (int i = 1; i <= n; i++)       for (int j = 1; j <= p; j++) scanf( %lld , &a[i].s[j]);     sort(a + 1, a + n + 1, cmp);     memset(f, -1, sizeof(f));     f[0][0] = 0;     for (int i = 1; i <= n; i++) {       for (int j = 0; j < (1 << p); j++) {         f[i][j] = f[i - 1][j];         int sum = 0;         for (int k = 0; k < p; k++)           if (j & (1 << k)) sum++;         int tmp = i - 1 - sum;         if (tmp < t && f[i - 1][j] != -1) f[i][j] += a[i].x;         for (int k = 0; k < p; k++) {           if (((j & (1 << k))) && f[i - 1][j ^ (1 << k)] != -1)             f[i][j] = max(f[i][j], f[i - 1][j ^ (1 << k)] + a[i].s[k + 1]);         }       }     }     printf( %lld , f[n][(1 << p) - 1]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const long long LINF = 0x3f3f3f3f3f3f3f3fLL;   long long N, L, v1, v2, k;   long long d;   pair<double, double> get_it(double mid) {     double end = mid * v2;     double pass = mid;     for (int i = 1; i < d; i++) {       double add = (end - pass * v1) / (v2 + v1);       end = (pass + add) * v1 + mid * v2;       pass += add + mid;     }     return {pass, end};   }   bool check(double mid) { return (get_it(mid).second >= L); }   void test_case() {     cin >> N >> L >> v1 >> v2 >> k;     d = (N + k - 1) / k;     double l = 0, r = INF;     for (int i = 0; i < 100; i++) {       double m = l + (r - l) / 2;       if (check(m))         r = m;       else         l = m;     }     cout << fixed << setprecision(10);     cout << get_it(l).first <<   n ;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int tt = 1;     while (tt--) {       test_case();     }     return 0;   }