malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   void solve() {     int n, m;     cin >> n;     cout << (((1ll << (n / 2)) - 1) * 2) <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     int t = 1;     cin >> t;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   long long ara[505][505];   bool row_check(long long val) {     for (int i = 0; i < n; i++) {       long long tmp = 0;       for (int j = 0; j < n; j++) {         tmp += ara[i][j];       }       if (tmp != val) return false;     }     return true;   }   bool col_check(long long val) {     for (int i = 0; i < n; i++) {       long long tmp = 0;       for (int j = 0; j < n; j++) {         tmp += ara[j][i];       }       if (tmp != val) return false;     }     return true;   }   bool diagonal_check(long long val) {     long long tmp = 0;     for (int i = 0; i < n; i++) tmp += ara[i][i];     if (tmp != val) return false;     tmp = 0;     for (int i = 0; i < n; i++) {       tmp += ara[i][n - 1 - i];     }     return (tmp == val);   }   bool check() {     long long row = 0;     for (int i = 0; i < n; i++) row += ara[i][0];     return row_check(row) & col_check(row) & diagonal_check(row);   }   int main() {     ios_base::sync_with_stdio(false);     while (cin >> n) {       int r, c;       for (int i = 0; i < n; i++) {         for (int j = 0; j < n; j++) {           cin >> ara[i][j];           if (ara[i][j] == 0) {             r = i;             c = j;           }         }       }       if (n > 1) {         long long sum = 0;         int x = 0;         if (r == 0) x++;         for (int i = 0; i < n; i++) sum += ara[x][i];         for (int i = 0; i < n; i++) sum -= ara[r][i];         if (sum > 0) {           ara[r][c] = sum;           if (check()) {             cout << ara[r][c] << endl;           } else {             printf( -1 n );           }         } else {           printf( -1 n );         }       } else         printf( 1 n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int T, n, i, j, l, m, x, y, z, a, b, c, d, flag, count;     cin >> a >> b >> c >> d;     long long int sum1, sum2;     sum1 = std::max((3 * a / 10), (a - ((a / 250) * c)));     sum2 = std::max((3 * b / 10), (b - ((b / 250) * d)));     if (sum1 > sum2)       cout <<  Misha  << endl;     else if (sum1 < sum2)       cout <<  Vasya  << endl;     else       cout <<  Tie  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     string name;     int id;     int taxi, pizza, girl;   } arr[105];   int cmp1(node a, node b) {     if (a.taxi == b.taxi) return a.id < b.id;     return a.taxi > b.taxi;   }   int cmp2(node a, node b) {     if (a.pizza == b.pizza) return a.id < b.id;     return a.pizza > b.pizza;   }   int cmp3(node a, node b) {     if (a.girl == b.girl) return a.id < b.id;     return a.girl > b.girl;   }   int main() {     int n;     cin >> n;     for (int i = 0; i < n; i++) {       int m;       cin >> m >> arr[i].name;       arr[i].id = i;       for (int j = 0; j < m; j++) {         int a, b, c;         scanf( %d-%d-%d , &a, &b, &c);         if (a % 10 == a / 10 && a == b && b == c)           arr[i].taxi++;         else if (a / 10 > a % 10 && a % 10 > b / 10 && b / 10 > b % 10 &&                  b % 10 > c / 10 && c / 10 > c % 10)           arr[i].pizza++;         else           arr[i].girl++;       }     }     sort(arr, arr + n, cmp1);     printf( If you want to call a taxi, you should call:  );     int first = 1;     for (int i = 0; i < n; i++) {       if (arr[i].taxi != arr[0].taxi) break;       if (!first) cout <<  ,  ;       cout << arr[i].name;       first = 0;     }     cout <<  .  << endl;     sort(arr, arr + n, cmp2);     printf( If you want to order a pizza, you should call:  );     first = 1;     for (int i = 0; i < n; i++) {       if (arr[i].pizza != arr[0].pizza) break;       if (!first) cout <<  ,  ;       cout << arr[i].name;       first = 0;     }     cout <<  .  << endl;     sort(arr, arr + n, cmp3);     printf(          If you want to go to a cafe with a wonderful girl, you should call:  );     first = 1;     for (int i = 0; i < n; i++) {       if (arr[i].girl != arr[0].girl) break;       if (!first) cout <<  ,  ;       cout << arr[i].name;       first = 0;     }     cout <<  .  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1e9 + 5;   const int MOD = 1e9 + 7;   void solve() {     int n, m;     cin >> n >> m;     vector<int> a(n), b(m + 1), la(m + 1);     for (int i = 0; i < n; ++i) cin >> a[i];     for (int i = 1; i < m + 1; ++i) cin >> b[i];     int mid = 0, l = 0, r = n - 1, ans = -1;     while (l <= r) {       mid = (l + r) / 2;       for (int i = 0; i < m + 1; ++i) la[i] = -1;       for (int i = 0; i < mid + 1; ++i) {         if (a[i] != 0) la[a[i]] = i;       }       int p = 0, ctr = 0;       for (int i = 0; i < mid + 1; ++i) {         if (la[a[i]] != i)           ctr++;         else if (ctr >= b[a[i]]) {           ctr -= b[a[i]];           p++;         } else           break;       }       if (p == m) {         ans = mid + 1;         r = mid - 1;       } else {         l = mid + 1;       }     }     cout << ans;   }   int main() {     int t = 1;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     t = 1;     while (t--) {       stack<int> st;       int n, x, ans = 0;       scanf( %d , &n);       for (int i = 0; i < n; ++i) {         scanf( %d , &x);         while (!st.empty()) {           ans = max(ans, st.top() ^ x);           if (st.top() > x) break;           st.pop();         }         st.push(x);       }       printf( %d n , ans);     }   }
#include <bits/stdc++.h>   unsigned bactery_count(unsigned num) {     unsigned res = 0;     while (num > 0) {       (num & true) ? ++res, --num : num >>= 1;     }     return res;   }   int main() {     unsigned num;     std::cin >> num;     std::cout << bactery_count(num) << std::endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int N;     while (cin >> N) {       int Store[31][31], i, j, SumR, SumC, Count = 0;       vector<int> Row, Col;       memset(Store, false, sizeof(Store));       for (i = 0; i < N; i++)         for (j = 0; j < N; j++) cin >> Store[i][j];       for (i = 0; i < N; i++) {         SumR = 0;         SumC = 0;         for (j = 0; j < N; j++) {           SumR += Store[i][j];           SumC += Store[j][i];         }         Row.push_back(SumR);         Col.push_back(SumC);       }       for (i = 0; i < N; i++) {         for (j = 0; j < N; j++) {           if (Row[i] < Col[j]) Count++;         }       }       cout << Count << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int lim = 400100;   int dx[] = {0, 0, 1, -1};   int dy[] = {1, -1, 0, 0};   const long long mod = 1000000007;   long long a, b;   int main() {     cin >> a >> b;     long long ans;     ans = (b * (b - 1)) / 2;     ans %= mod;     ans *= (((b * (((a * (a + 1)) / 2) % mod)) % mod) + a) % mod;     ans %= mod;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long int n, m;     cin >> n >> m;     if (n == 1) {       cout <<  0  << endl;       return;     }     if (n == 2) {       cout << m << endl;       return;     }     if (n > 2) {       cout << 2 * m << endl;       return;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long int t;     cin >> t;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n = 0;     cin >> n;     vector<int> ans;     int k = 0;     if (n == 1) {       cout << 1 << endl << 1;       return 0;     }     for (int i = 1; i <= n; i++) {       ans.push_back(i);       if (n - i >= 0)         n -= i;       else         break;     }     if (n == 0) {       cout << ans.size() << endl;       for (int i = 0; i < ans.size(); i++) cout << ans[i] <<    ;     } else {       cout << ans.size() << endl;       sort(ans.begin(), ans.end());       for (int i = 0; i < ans.size() - 1; i++) cout << ans[i] <<    ;       cout << ans[ans.size() - 1] + n;       return 0;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 6;   string lcp(string txt, string pat) {     string S = pat +  $  + txt;     vector<int> Arr(S.size(), 0);     int j = 0;     for (int i = 1; i < S.size(); i++) {       while (j > 0 && S[j] != S[i]) j = Arr[j - 1];       if (S[j] == S[i]) j++;       Arr[i] = j;     }     int MX = 0;     for (int i = 0; i < S.size(); i++) MX = max(MX, Arr[i]);     if (MX == pat.size()) return txt;     return txt + pat.substr(Arr[S.size() - 1]);   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     string s[3];     cin >> s[0] >> s[1] >> s[2];     sort(s, s + 3);     int Res = 1e9 + 7;     do {       string s1 = lcp(lcp(s[0], s[1]), s[2]);       string s2 = lcp(s[0], lcp(s[1], s[2]));       int a = s1.size(), b = s2.size();       Res = min(Res, min(a, b));     } while (next_permutation(s, s + 3));     cout << Res <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int qmin(int a, int b) { return (a < b) ? a : b; }   int qmax(int a, int b) { return (a > b) ? a : b; }   int n, m, k;   int x[555], y[555];   int xl[555], xr[555], yl[555], yr[555];   set<int> stx, sty;   map<int, int> mpx;   int xpos[1010];   vector<int> l[1010], r[1010];   multiset<pair<int, int> > y_seg_l;   bool check(int now) {     for (int i = 0; i < 1001; i++) l[i].clear(), r[i].clear();     for (int i = 0; i < k; i++)       xl[i] = qmax(x[i] - now, 1), xr[i] = qmin(x[i] + now, n),       yl[i] = qmax(y[i] - now, 1), yr[i] = qmin(y[i] + now, m);     stx.clear(), sty.clear();     for (int i = 0; i < k; i++) stx.insert(xl[i]), stx.insert(xr[i] + 1);     stx.insert(1), stx.insert(n + 1);     int cnt = 0;     for (set<int>::iterator it = stx.begin(); it != stx.end(); it++, cnt++)       mpx[*it] = cnt, xpos[cnt] = *it;     for (int i = 0; i < k; i++)       l[mpx[xl[i]]].push_back(i), r[mpx[xr[i] + 1]].push_back(i);     y_seg_l.clear();     int xxl = n + 1, xxr = 0, yyl = m + 1, yyr = 0;     y_seg_l.insert(make_pair(0, 0));     y_seg_l.insert(make_pair(m + 1, m + 1));     for (int i = 0; i < cnt - 1; i++) {       for (int j = 0; j < (int)r[i].size(); j++) {         multiset<pair<int, int> >::iterator it =             y_seg_l.lower_bound(make_pair(yl[r[i][j]], yr[r[i][j]]));         y_seg_l.erase(it);       }       for (int j = 0; j < (int)l[i].size(); j++)         y_seg_l.insert(make_pair(yl[l[i][j]], yr[l[i][j]]));       int nr = 0;       int nyl = m + 1, nyr = 0;       for (set<pair<int, int> >::iterator it = y_seg_l.begin();            it != y_seg_l.end(); it++) {         if (it->first > nr + 1)           nyl = qmin(nyl, nr + 1), nyr = qmax(nyr, it->first - 1);         nr = qmax(nr, it->second);       }       if (nyr > 0) {         xxl = qmin(xxl, xpos[i]);         xxr = qmax(xxr, xpos[i + 1] - 1);       }       yyl = qmin(yyl, nyl);       yyr = qmax(yyr, nyr);     }     if (xxr == 0) return 1;     return ((xxr - xxl + 1) <= (now + now + 1)) &&            ((yyr - yyl + 1) <= (now + now + 1));   }   int main() {     ios::sync_with_stdio(false);     cin >> n >> m >> k;     for (int i = 0; i < k; i++) cin >> x[i] >> y[i];     int lb = 0, ub = 1e9;     while (lb <= ub) {       int mid = (lb + ub) >> 1;       if (check(mid))         ub = mid - 1;       else         lb = mid + 1;     }     cout << lb << endl;     return 0;   }
#include <bits/stdc++.h>   namespace LYD {   inline int read() {     int x = 0, data = 1;     char ch = getchar();     while ((ch >  9  || ch <  0 ) && ch !=  - ) ch = getchar();     if (ch ==  - ) {       ch = getchar();       data = -1;     }     while (ch >=  0  && ch <=  9 ) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     return x * data;   }   }  // namespace LYD   int st[105], ans[105];   using namespace LYD;   namespace solve {}   using namespace solve;   int main() {     int n = read(), k = read(), tot = 0;     for (int i = 1; i <= n; ++i) {       int x = read();       if (st[x] == 0) {         ++tot;         st[x] = i;       }     }     if (tot < k) {       printf( NO );       return 0;     }     int num = 0, ans_num = 0;     printf( YES n );     for (int i = 1; i <= k; ++i) {       while (st[num] == 0) ++num;       ++ans_num;       ans[ans_num] = st[num];       ++num;     }     std ::sort(ans + 1, ans + ans_num + 1);     for (int i = 1; i < ans_num; ++i) printf( %d  , ans[i]);     printf( %d , ans[ans_num]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> rs_needed[1000000 + 5];   int arr[1000000 + 5];   int main() {     int i, j, k, n, idx = 0, rs, lst_pos, cminus = 0, cplus = 0;     long long int dv = 0, mn;     scanf( %d , &n);     for (i = 1; i <= n; i++) {       scanf( %d , &arr[i]);       dv += abs(arr[i] - i);     }     mn = dv;     for (i = 1; i <= n; i++) {       if (arr[i] > i) {         rs_needed[arr[i] - i].push_back(arr[i]);         cminus++;       } else {         rs_needed[n - i + arr[i]].push_back(arr[i]);         cplus++;       }     }     lst_pos = n;     for (rs = 0; rs < n; rs++) {       if (dv < mn) mn = dv, idx = rs;       for (auto x : rs_needed[rs]) {         cminus--;         cplus++;       }       dv -= n - arr[lst_pos];       dv += arr[lst_pos];       lst_pos--;       cplus--;       cminus++;       dv = dv + cplus - cminus;     }     printf( %lld %d n , mn, idx);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   struct Item {     int c;     int x;     Item() : c(), x() {}     Item(int _c, int _x) : c(_c), x(_x) {}   };   const long long INF = (long long)1e16;   const int N = 505;   int n, m, k;   vector<Item> a[N][N];   vector<Item> b[N][N];   long long s[N][N];   long long dp[N][N];   int DX[] = {0, 1, 1, 0};   int DY[] = {0, -1, 0, 1};   int main() {     scanf( %d%d%d , &n, &m, &k);     while (k--) {       int x, y, d, t, c;       scanf( %d%d%d%d%d , &x, &y, &d, &t, &c);       vector<pair<int, int> > cur;       for (int i = 0; i < 4; i++) {         int xx = x + d * DX[i], yy = y + d * DY[i];         int tt = xx + yy;         if (tt < t || (tt - t) % 4 != i) continue;         cur.push_back(make_pair(xx, yy));       }       if ((int)cur.size() > 2) throw;       for (int i = 0; i < (int)cur.size(); i++) {         s[cur[i].first][cur[i].second] += c;         if (i == 1) {           if (cur[0].first == cur[1].first)             a[cur[1].first][cur[1].second].push_back(Item(c, cur[0].second));           else if (cur[0].second == cur[1].second)             b[cur[1].first][cur[1].second].push_back(Item(c, cur[0].first));         }       }     }     for (int x = 0; x < n; x++)       for (int y = 0; y < m; y++) dp[x][y] = INF;     dp[0][0] = 0;     for (int x = 0; x < n; x++)       for (int y = 0; y < m; y++) {         long long w;         w = dp[x][y];         for (int xx = x + 1; xx < n; xx++) {           for (Item I : b[xx][y]) {             if (I.x >= x) w -= I.c;           }           w += s[xx][y];           dp[xx][y] = min(dp[xx][y], w);         }         w = dp[x][y];         for (int yy = y + 1; yy < m; yy++) {           for (Item I : a[x][yy]) {             if (I.x >= y) w -= I.c;           }           w += s[x][yy];           dp[x][yy] = min(dp[x][yy], w);         }       }     printf( %lld n , dp[n - 1][m - 1]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, ans = 0, fac[1000010], inv[1000010], sq[1000010], sl[1000010],          sr[1000010];   char s[1000010];   template <class T>   void read(T &x) {     char ch;     bool ok;     for (ok = 0, ch = getchar(); !isdigit(ch); ch = getchar())       if (ch ==  - ) ok = 1;     for (x = 0; isdigit(ch); x = x * 10 + ch -  0 , ch = getchar())       ;     if (ok) x = -x;   }   int c(int x, int y) {     if (x < y || y < 0) return 0;     return 1ll * fac[x] * inv[y] % 998244353 * inv[x - y] % 998244353;   }   int main() {     scanf( %s , s + 1);     n = strlen(s + 1);     inv[0] = inv[1] = fac[0] = fac[1] = 1;     for (int i = 2; i <= n; ++i)       inv[i] = 1ll * (998244353 - 998244353 / i) * inv[998244353 % i] % 998244353;     for (int i = 2; i <= n; ++i) {       inv[i] = 1ll * inv[i - 1] * inv[i] % 998244353;       fac[i] = 1ll * fac[i - 1] * i % 998244353;     }     for (int i = 1; i <= n; ++i) sq[i] = sq[i - 1] + (s[i] ==  ? );     for (int i = 1; i <= n; ++i) sl[i] = sl[i - 1] + (s[i] ==  ( );     for (int i = n; i >= 1; --i) sr[i] = sr[i + 1] + (s[i] ==  ) );     for (int i = 1; i <= n; ++i)       ans =           (ans +            1ll * sl[i] * c(sq[n], sq[n] - sq[i] + sr[i + 1] - sl[i]) % 998244353 +            1ll * sq[i] * c(sq[n] - 1, sq[n] - sq[i] + sr[i + 1] - sl[i] - 1)) %           998244353;     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 200000;   long long mem[MAXN + 1][2];   int visited[MAXN + 1][2];   int b[MAXN + 1][2];   int a[MAXN + 1];   int n;   int input() {     int i;     scanf( %d , &n);     for (i = 2; i <= n; i++) scanf( %d , &a[i]);     return 0;   }   int search(int x, int k) {     int i, tx;     if (visited[x][k] == 1) {       mem[x][k] = -1;       return 0;     }     if (visited[x][k] == 2) {       return 0;     }     if (x == 1 && k == 1) {       b[x][k] = 1;       mem[x][k] = 0;       return 0;     }     mem[x][k] += a[x];     visited[x][k] = 1;     tx = x;     if (k)       tx -= a[x];     else       tx += a[x];     if (tx >= 1 && tx <= n) {       search(tx, k ^ 1);       if (mem[tx][k ^ 1] != -1) {         mem[x][k] += mem[tx][k ^ 1];         b[x][k] = b[tx][k ^ 1];       } else         mem[x][k] = -1;     }     visited[x][k] = 2;     return 0;   }   int solve() {     int i;     memset(mem, 0, sizeof(mem));     memset(b, 0, sizeof(b));     memset(visited, 0, sizeof(visited));     visited[1][0] = 1;     for (i = 2; i <= n; i++) {       if (!visited[i][1]) search(i, 1);     }     for (i = 1; i < n; i++) {       a[1] = i;       a[0] = 0;       if (mem[i + 1][1] == -1)         printf( -1 n );       else         printf( %I64d n , mem[i + 1][1] + i + a[b[i + 1][1]]);     }     return 0;   }   int main() {     input();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1 << 30;   vector<int> w, cn, c, d, p;   vector<bool> used;   int find(int x) { return (p[x] == x ? x : p[x] = find(p[x])); }   void un(int x, int y) {     x = find(x);     y = find(y);     if (rand() & 1)       p[x] = y;     else       p[y] = x;   }   int main() {     int n, m;     scanf( %d %d , &n, &m);     used.resize(n, false);     cn.resize(n + 1, 0);     p.resize(n);     for (int i = 0; i < n; ++i) p[i] = i;     int a, b, comp = n;     for (int i = 0; i < m; ++i) {       scanf( %d%d , &a, &b);       a--;       b--;       if (find(a) != find(b)) un(a, b), comp--;     }     for (int i = 0; i < n; ++i) cn[find(p[i])]++;     for (int i = 0; i < n; ++i)       if (cn[i] > 0) c.push_back(cn[i]);     cn.assign(n + 1, 0);     for (int i = 0; i < c.size(); ++i) ++cn[c[i]];     c.clear();     for (int i = 0; i < cn.size(); ++i)       if (cn[i] > 0) {         int st = 1;         while (cn[i] >= st) {           c.push_back(st);           w.push_back(st * i);           cn[i] -= st;           st *= 2;         }         if (cn[i] > 0) {           c.push_back(cn[i]);           w.push_back(cn[i] * i);         }       }     int N = c.size();     d.resize(n + 1, INF);     d[0] = 0;     for (int i = 1; i <= N; ++i)       for (int j = n; j >= w[i - 1]; --j)         if (d[j - w[i - 1]] + c[i - 1] < d[j]) d[j] = d[j - w[i - 1]] + c[i - 1];     int ans = INF, tmp;     for (int i = 4; i <= n; ++i) {       if (ans <= d[i]) continue;       tmp = i;       bool good = true;       while (tmp > 0 && good) {         if (!(tmp % 10 == 4 || tmp % 10 == 7)) good = false;         tmp /= 10;       }       if (good) ans = d[i];     }     printf( %d , (ans < INF ? ans - 1 : -1));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, d, i, j, m, l, t, sz = 1, a;   long long cnt(long long p) {     long long res = 1;     for (i = 0; i < p; i++) res *= 2;     return res;   }   int main() {     cin >> t;     for (int k = 0; k < t; k++) {       long long h1 = 0, h0 = 0;       cin >> n;       for (i = 0; i < n; i++) {         cin >> a;         if (a == 1) h1++;         if (a == 0) h0++;       }       cout << h1 * cnt(h0) <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int getint() {     unsigned int c;     int x = 0;     while (((c = getchar()) -  0 ) >= 10) {       if (c ==  - ) return -getint();       if (!~c) exit(0);     }     do {       x = (x << 3) + (x << 1) + (c -  0 );     } while (((c = getchar()) -  0 ) < 10);     return x;   }   const int L = 222;   const int G = 222;   int nTour, needWin, initCap;   double winProb[200];   int award[200];   double cache[L][L + G + 1][L];   double solve(int pos, int cap, int won) {     double& res = cache[pos][cap][won];     if (res > -1) return res;     if (pos == nTour) {       if (won >= needWin) {         if (cap >= G) {           return res = 1;         } else {           return res = 0;         }       } else {         return res = 0;       }     }     if (award[pos] == -1) {       res = winProb[pos] * solve(pos + 1, cap - 1, won + 1);     } else {       res = winProb[pos] * solve(pos + 1, min(L + G, cap + award[pos]), won + 1);     }     res += (1 - winProb[pos]) * solve(pos + 1, cap, won);     return res;   }   int main() {     int i, j, k, tcc, tc = 1 << 28;     for (tcc = 0; tcc < tc; tcc++) {       nTour = getint();       needWin = getint();       initCap = getint();       for (i = 0; i < nTour; i++) {         winProb[i] = getint() / 100.0;       }       for (i = 0; i < nTour; i++) {         award[i] = getint();       }       for (i = 0; i < L; i++)         for (j = 0; j < L + G + 1; j++)           for (k = 0; k < L; k++) cache[i][j][k] = -1e40;       double res = solve(0, initCap + G, 0);       printf( %.10lf n , res);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, a, b;     cin >> n >> a >> b;     int position[21] = {0};     for (int i = 0; i < n; i++) cin >> position[i];     int head = 0, tail = n - 1, cost = 0;     while (head <= tail) {       if (position[head] != 2 && position[tail] != 2 &&           (position[head] != position[tail])) {         cost = -1;         break;       }       if (position[head] == 2 && position[tail] == 2 && head != tail) {         if (a > b)           cost += 2 * b;         else           cost += 2 * a;       } else if (position[head] == 2 && position[tail] == 2 && head == tail) {         if (a > b)           cost += b;         else           cost += a;       } else if (position[head] == 2 || position[tail] == 2) {         if (position[head] == 2 && position[tail] == 0)           cost += a;         else if (position[head] == 2 && position[tail] == 1)           cost += b;         else if (position[tail] == 2 && position[head] == 0)           cost += a;         else if (position[tail] == 2 && position[head] == 1)           cost += b;       }       head++;       tail--;     }     cout << cost;     return 0;   }