malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;      using ll = long long int;   typedef vector<ll> vi;   typedef vector<vi> vvi;   typedef pair<ll,ll> ii;   typedef vector<ii> vii;   typedef vector<vii> vvii;   #define F first   #define S second      ll min(ll x, ll y){       return ((x < y) ? x : y);   }      ll max(ll x, ll y){       return ((x > y) ? x : y);   }   const ll INF = 1e18;      double findavg (ll x, ll itr){       ll sum = 0;       for (ll i = 0; itr > i; i++){           ll mvs = 0;           ll cur = 0;           while (x > cur){               ll rd = rand()%2;               if (rd){                   cur++;               }else cur = 0;               mvs++;           }           cout << mvs << endl;           sum += mvs;       }       double ans = (double)sum/(double)itr;       cout <<  x:   << x <<     <<  itr:   << itr << endl;       cout << ans << endl;       return ans;   }      int main(){       ll t; cin >> t;       while (t--){           ll k; cin >> k;           if (k%2 == 1){               cout <<  -1 n ;               continue;           }           vi v;           for (ll i = 1; 63 > i; i++){               ll bm = 1;               bm <<= i;               if (k & bm){                   v.push_back(1);                   for (ll j = 0; i > j+1; j++){                       if (j) v.push_back(0);                       else v.push_back(1);                   }               }              }           cout << v.size() << endl;           for (auto i: v) cout << i <<    ;           cout << endl;       }      }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, a, b, c;     cin >> n >> a >> b >> c;     long long x = n % 4;     long long y = 4 - x;     if (n % 4 == 0)       cout << 0 <<   n ;     else {       if (y == 1) {         cout << min(min(a, b + c), 3 * c) <<   n ;       } else if (y == 2) {         cout << min(min(2 * a, 2 * c), b) <<   n ;       } else if (y == 3) {         cout << min(min(c, 3 * a), b + a) <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   long long mod = 1000000007;   long long fin(long long a, long long b) {     long long ans = 1;     a %= mod;     while (b) {       if (b % 2 == 1) {         ans = (ans * a) % mod;       }       a = (a * a) % mod;       b = b / 2;     }     return ans;   }   int main() {     long long x, k;     cin >> x >> k;     if (x == 0)       cout <<  0 n ;     else {       x %= mod;       cout << (((2 * x - 1) * fin(2, k) + mod) % mod + 1 + mod) % mod <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main(){    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);       //freopen( input.txt , r ,stdin);       //freopen( output.txt , w ,stdout);    int T;    cin>>T;    for(int t=0;t<T;t++){     int n,k;     cin>>n>>k;     if(n==1&&k==1){cout<<0<<endl;continue;}     if(k<=3){      if(k==2){       int m=n-1;       cout<<m<<endl;       cout<<1<<   ;       for(int i=3;i<=n;i++)        cout<<i<<   ;       cout<<endl;     }else{      if(k==1){       cout<<n-1<<endl;       for(int i=2;i<=n;i++)         cout<<i<<   ;        cout<<endl;      }      else{       cout<<n-2<<endl;       cout<<1<<   ;       for(int i=4;i<=n;i++)         cout<<i<<   ;        cout<<endl;             }     }     }else{      if(k%2==0){       int m=n-k/2;       cout<<m<<endl;       for(int i=k/2;i<=n;i++)        if(i!=k)cout<<i<<   ;       cout<<endl;      }else{       int m=n-k/2-1;       cout<<m<<endl;       for(int i=k/2+1;i<=n;i++)        if(i!=k)cout<<i<<   ;       cout<<endl;      }     }    }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, A;   long long b[200005];   long long beki[200005];   long long pow(long long a, long long n) {     if (n == 0) return 1;     if (n % 2) {       return ((a % 998244353) * (pow(a, n - 1) % 998244353)) % 998244353;     } else {       return pow((a * a) % 998244353, n / 2) % 998244353;     }   }   int main(void) {     cin >> n >> m >> A;     for (int i = 1; i <= m; i++) cin >> b[i];     long long inv2 = pow(2, 998244353 - 2);     long long ans = 1;     for (int i = 1; i <= m; i++) {       long long l = b[i] - b[i - 1];       long long tmp = (pow(A, 2 * l) + 998244353 - pow(A, l)) % 998244353;       tmp *= inv2, tmp %= 998244353;       tmp += pow(A, l), tmp %= 998244353;       ans *= tmp, ans %= 998244353;     }     ans *= pow(A, n - 2 * b[m]), ans %= 998244353;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void init_code() {}   long long int c[207];   bool adj[207][207];   long long int n;   void dfs(long long int u, long long int cu) {     if (~c[u]) {       if (c[u] ^ cu) {         cout <<  NO               <<   n ;         exit(0);       }       return;     }     c[u] = cu;     for (long long int v = 0; v < n; v++)       if (adj[u][v]) dfs(v, cu ^ 1);   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     init_code();     cin >> n;     string str;     cin >> str;     for (long long int i = 0; i < n; i++) {       for (long long int j = i + 1; j < n; j++) {         if (str[j] < str[i]) adj[i][j] = adj[j][i] = 1;       }     }     memset(c, -1, sizeof(c));     for (long long int i = 0; i < n; i++) {       if (c[i] < 0) dfs(i, 0);     }     cout <<  YES           <<   n ;     for (long long int i = 0; i < n; i++) cout << c[i];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename A>   using VE = vector<A>;   template <typename A>   using USET = unordered_set<A>;   template <typename A>   using HEAP = priority_queue<A>;   template <typename A, typename B>   using PA = pair<A, B>;   template <typename A, typename B>   using UMAP = unordered_map<A, B>;   template <typename A>   using RHEAP = priority_queue<A, vector<A>, greater<A> >;   template <typename A>   A MAX(const A &a) {     return a;   }   template <typename A>   A MIN(const A &a) {     return a;   }   template <typename A>   A MAX(const A *a, const A *b) {     return *max_element(a, b);   }   template <typename A>   A MIN(const A *a, const A *b) {     return *min_element(a, b);   }   template <typename A, typename... B>   A MAX(const A &a, const B &...b) {     return max(a, MAX(b...));   }   template <typename A, typename... B>   A MIN(const A &a, const B &...b) {     return min(a, MIN(b...));   }   template <typename A, typename B = typename std::iterator_traits<A>::value_type>   B MAX(A a, A b) {     return *max_element(a, b);   }   template <typename A, typename B = typename std::iterator_traits<A>::value_type>   B MIN(A a, A b) {     return *min_element(a, b);   }   mt19937 rng(       (unsigned int)chrono::steady_clock::now().time_since_epoch().count());   const int N = 100010, M = 1010;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cout << fixed << setprecision(10);     int T;     cin >> T;     while (T--) {       int n;       cin >> n;       int idx = 0;       map<int, int> mp;       vector<int> a(n);       for (auto &u : a) {         cin >> u;         if (!mp.count(u)) mp[u] = ++idx;         u = mp[u];       }       int p = -1;       for (int i = 0; i < n; i++)         if (a[i] == a[(i + 1) % n]) {           p = i;           break;         }       vector<int> c(n);       if (p == -1) {         for (int i = 0, j = 1; i + 1 < n; i += 2) {           c[i] = j;           j = 3 - j;           c[i + 1] = j;           j = 3 - j;         }         if (c.back() == 0) {           if (c[n - 2] != c[0])             c.back() = 3;           else             c.back() = 3 - c[0];         }       } else {         rotate(a.begin(), a.begin() + p + 1, a.end());         c[0] = 1;         for (int i = 1; i < n; i++)           if (a[i] != a[i - 1])             c[i] = 3 - c[i - 1];           else             c[i] = 1;       }       cout << MAX(c.begin(), c.end()) <<   n ;       int j;       if (p == -1)         j = 0;       else         j = n - p - 1;       for (int i = 0; i < n; i++, j++) cout << c[j % n] <<    ;       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[27], c[27], d[27];   int main() {     int count, i, n, max, co, t, index, k;     char str[1010], ch, b[1010];     ch = getchar();     while (ch !=   n ) {       a[ch -  a  + 1]++;       ch = getchar();     }     count = 0;     for (i = 1; i <= 26; i++)       if (a[i] != 0) count++;     scanf( %d , &n);     if (n < count)       printf( -1 n );     else if (n == count) {       max = 0;       for (i = 1; i <= 26; i++)         if (a[i] > max) max = a[i];       printf( %d n , max);       for (i = 1; i <= 26; i++)         if (a[i] != 0) printf( %c , i +  a  - 1);       printf(  n );     } else {       t = 0;       for (i = 1; i <= 26; i++) {         if (a[i] != 0) b[t++] = i +  a  - 1;         c[i] = 1;       }       copy(a, a + 27, d);       for (k = n - count; k > 0; k--) {         max = 0;         index = 0;         for (i = 1; i <= 26; i++)           if (d[i] > max) {             max = d[i];             index = i;           }         c[index]++;         b[t++] = index +  a  - 1;         if (a[index] % c[index] != 0)           d[index] = a[index] / c[index] + 1;         else           d[index] = a[index] / c[index];       }       max = 0;       for (i = 1; i <= 26; i++) {         if (d[i] > max) max = d[i];       }       printf( %d n , max);       b[t] = 0;       puts(b);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     set<int> s;     int n;     cin >> n;     for (int i = 0; i < n; i++) {       int x;       cin >> x;       s.insert(x);     }     set<int>::iterator it, it1, it2;     it = s.begin();     it1 = it;     it1++;     it2 = s.end();     it2--;     if (s.size() == 1)       cout << 0 << endl;     else if (s.size() == 2) {       int e = *it1 - (*it);       if (e % 2 == 0) e /= 2;       cout << e;     } else if (s.size() == 3) {       int a = (*it);       int b = (*it1);       int c = (*it2);       if (b - a == c - b)         cout << b - a << endl;       else         cout << -1 << endl;     } else       cout << -1 << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2000010;   int n, ans, q[N], x[N], y[N];   struct node {     int a, b, m, id;   };   vector<node> a[N];   bool cmp(node x, node y) { return x.a < y.a; }   void Work() {     scanf( %d , &n);     for (int i = 1, x, y, z; i <= n; i++) {       scanf( %d%d%d , &x, &y, &z);       a[x + y - z].push_back((node){x, y, z, i});       q[i] = x + y - z;     }     ans = 0;     for (int i = 1; i <= n; i++)       if (a[q[i]].size()) {         sort(a[q[i]].begin(), a[q[i]].end(), cmp);         for (int j = 0, px = -1e9; j < (int)a[q[i]].size(); j++) {           node b = a[q[i]][j];           if (b.b < q[i] - px) px = min(b.a, q[i]), ans++;           x[b.id] = b.a - px;           y[b.id] = b.m - x[b.id];         }         a[q[i]].clear();       }     cout << ans <<   n ;     for (int i = 1; i <= n; i++) cout << x[i] <<     << y[i] <<   n ;   }   int main() {     int T = 1;     scanf( %d , &T);     while (T--) Work();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int d8x[8] = {1, -1, 0, 0, 1, 1, -1, -1};   int d8y[8] = {0, 0, 1, -1, 1, -1, 1, -1};   const int M = 1e9 + 7;   const int N = 1e3, Nx = 500;   int a[N + 1], c[N + 1];   bool isPrime[N + 1];   void sieve(int x) {     for (int i = 0; i <= x; i++) isPrime[i] = true;     isPrime[0] = false;     isPrime[1] = false;     for (int i = 2; i * i <= x; i++) {       if (isPrime[i]) {         for (int j = i * i; j <= x; j += i) isPrime[j] = false;       }     }   }   template <class type>   type gcd(type a, type b) {     if (b == 0) return a;     return gcd(b, a % b);   }   template <class type>   type MODEXPO(type a, type b, int mod) {     if (b == 0)       return 1;     else if (b % 2 == 0)       return MODEXPO((a * a) % mod, b / 2, mod);     else       return (a * MODEXPO((a * a) % mod, (b - 1) / 2, mod)) % mod;   }   void fast() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);   }   int main() {     fast();     int n;     cin >> n;     int ans = 1;     for (int i = 0; i <= n - 1; i++) cin >> a[i], a[i]--;     for (int i = 0; i <= n - 1; i++) {       memset(c, 0, sizeof c);       int l = 0, x = i;       while (!c[x]) c[x] = 1, l++, x = a[x];       if (x != i) {         ans = -1;         break;       }       if (l % 2 == 0) l /= 2;       ans *= l / gcd(l, ans);     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int n;     cin >> n;     vector<pair<int, int> > v(n);     for (int i = 0; i < n; i++) cin >> v[i].first;     bool is0 = false, is1 = false;     for (int i = 0; i < n; i++) {       cin >> v[i].second;       if (v[i].second)         is1 = true;       else         is0 = true;     }     if (is0 && is1) {       cout <<  Yes n ;       return;     }     for (int i = 1; i < n; i++)       if (v[i - 1] > v[i]) {         cout <<  No n ;         return;       }     cout <<  Yes n ;   }   int main() {     ios::sync_with_stdio(false);     int t;     cin >> t;     while (t--) solve();   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   int mat[1000010];   int row(int r) {     int s = r * m, e = s + m;     bool eq = false, dif = false;     for (int i = s, idx = 0; i < e; i++, idx++) {       if (mat[i] == -1) continue;       int a = mat[i] / 2;       int b = idx & 1;       if (a == b) eq = true;       if (a != b) dif = true;     }     if (eq && dif) return 0;     if (eq || dif) return 1;     return 2;   }   int col(int c) {     int s = c, e = n * m + c;     bool eq = false, dif = false;     for (int i = s, idx = 0; i < e; i += m, idx++) {       if (mat[i] == -1) continue;       int a = min(mat[i], 3 - mat[i]);       int b = idx & 1;       if (a == b) eq = true;       if (a != b) dif = true;     }     if (eq && dif) return 0;     if (eq || dif) return 1;     return 2;   }   int main() {     while (cin >> n >> m) {       char ch;       for (int i = 0; i < n * m; i++) {         cin >> ch;         if (ch ==  . )           mat[i] = -1;         else           mat[i] = (int)(ch -  1 );       }       int res = 1;       for (int i = 0; i < n; i++) {         res *= row(i);         if (res >= 1000003) res -= 1000003;       }       for (int i = 0; i < m; i++) {         res *= col(i);         if (res >= 1000003) res -= 1000003;       }       cout << res % 1000003 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100;   int n, x, t;   long long ans, s[N];   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i) {       scanf( %d , &x);       t = 0;       while (x) {         t += x % 2;         x /= 2;       }       ++s[t];     }     for (int i = 1; i <= N; ++i) ans += s[i] * (s[i] - 1) / 2;     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   int n, i, j;   vector<string> koutsompolio;   int main() {     cin >> n;     string lol;     bool r, f;     for (i = 0; i <= n; i++) {       getline(cin, lol);       koutsompolio.push_back(lol);     }     for (i = 1; i <= n; i++) {       r = false;       f = false;       if ((koutsompolio[i][0] ==  m ) && (koutsompolio[i][1] ==  i ) &&           ((koutsompolio[i][2] ==  a )) && (koutsompolio[i][3] ==  o ) &&           (koutsompolio[i][4] ==  . )) {         r = true;       }       if ((koutsompolio[i][koutsompolio[i].size() - 1] ==  . ) &&           (koutsompolio[i][koutsompolio[i].size() - 2] ==  a ) &&           ((koutsompolio[i][koutsompolio[i].size() - 3] ==  l )) &&           (koutsompolio[i][koutsompolio[i].size() - 4] ==  a ) &&           (koutsompolio[i][koutsompolio[i].size() - 5] ==  l )) {         f = true;       }       if ((f == false) && (r == true)) {         cout <<  Rainbow s n ;       } else if ((f == true) && (r == false)) {         cout <<  Freda s n ;       } else {         cout <<  OMG>.< I don t know! n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int x{};     cin >> x;     if (x % 3 == 0 || x % 7 == 0) {       cout <<  YES  << endl;       return;     }     int ms{x / 3};     int ml{x / 7};     for (int i{0}; i <= ms; ++i) {       for (int j{0}; j <= ml; ++j) {         int chunks{3 * i + 7 * j};         if (chunks == x) {           cout <<  YES  << endl;           return;         }       }     }     cout <<  NO  << endl;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     int t{};     cin >> t;     while (t > 0) {       solve();       t--;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long k;     cin >> k;     long long cnt = 0;     for (double a = 2 + 2. / 3; a < (2 * k) / sqrt(3); a += 2) {       double b =           1e-8 + (-a + sqrt((16 * k * k) / 3. - (3 * a * a))) / 2. - 2. / 3;       if (b > 0) cnt += ((int)b + 2) / 2;     }     cout << 1 + 6 * cnt << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int cmpint(const void *a, const void *b) {     if (((int *)a)[0] == ((int *)b)[0]) return ((int *)a)[1] - ((int *)b)[1];     return ((int *)a)[0] - ((int *)b)[0];   }   int prim[500005] = {0};   bool isprim[5000005] = {0};   int prim_len;   void count_prim() {     int i, j, l;     prim[0] = 2;     prim_len = 1;     for (i = 3; i < 5000000; i += 2)       if (isprim[i] == 0) {         prim[prim_len] = i;         prim_len++;         l = i * 2;         if (i < 10000)           for (j = i * i; j < 5000000; j += l) isprim[j] = 1;       }   }   int a[100005];   int main() {     int i, j, n, m, k, l, o, p;     scanf( %d , &n);     count_prim();     m = 0;     for (i = (0); i < (prim_len); i++) {       k = prim[i];       l = 0;       while (k > 0) {         l = l * 10 + k % 10;         k /= 10;       }       if (l != prim[i] && isprim[l] == 0 && l % 2 == 1) {         m++;         a[m] = prim[i];       }       if (m > n) break;     }     printf( %d n , a[n]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     vector<long> A;     long N, L, R, M, T, Sum, Min = 2147483647;     cin >> N;     A.resize(N);     for (long i = 0; i < N; ++i) cin >> A[i];     for (long M = 1; M <= 100; ++M) {       Sum = 0;       for (long i = 0; i < N; ++i)         Sum += min(min(abs(A[i] - M + 1), abs(A[i] - M - 1)), abs(A[i] - M));       if (Sum < Min) {         Min = Sum;         T = M;       }     }     cout << T <<     << Min;     return 0;   }
#include <bits/stdc++.h>   const int mod = 1e6 + 3;   int add(int a, int b) { return (a += b) >= mod ? a -= mod : a; }   int sub(int a, int b) { return add(a, mod - b); }   int mul(int a, int b) { return int(1LL * a * b % mod); }   int pow(int a, int64_t n) {     int res = 1;     while (n > 0) {       if (n & 1) {         res = mul(res, a);       }       a = mul(a, a);       n >>= 1;     }     return res;   }   int inv(int a) { return pow(a, mod - 2); }   int main() {     const int n = 11;     std::vector<int> f(n + 1);     for (int i = 1; i <= n; ++i) {       std::cout <<  ?   << i << std::endl;       std::cin >> f[i];       if (f[i] == 0) {         std::cout <<  !   << i << std::endl;         return 0;       }     }     std::vector<std::vector<int> > a(1 + n, std::vector<int>(1 + n));     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= n; ++j) {         a[i][j] = pow(i, j - 1);       }     }     for (int j = 1, i = 1; j <= n; ++j) {       bool was = false;       for (int k = i; k <= n; ++k) {         if (a[k][j] != 0) {           was = true;           std::swap(a[i], a[k]);           std::swap(f[i], f[k]);           break;         }       }       if (!was) {         continue;       }       for (int k = i + 1; k <= n; ++k) {         int coeff = mul(sub(0, inv(a[k][j])), a[i][j]);         for (int t = j; t <= n; ++t) {           a[k][t] = add(mul(coeff, a[k][t]), a[i][t]);         }         assert(a[k][j] == 0);         f[k] = add(f[i], mul(coeff, f[k]));       }       i++;     }     std::vector<int> x(1 + n);     for (int i = n; i >= 1; --i) {       assert(a[i][i] != 0);       int res = f[i];       for (int j = i + 1; j <= n; ++j) {         res = sub(res, mul(a[i][j], x[j]));       }       x[i] = mul(res, inv(a[i][i]));     }     for (int i = 0; i < mod; ++i) {       int p = 1, s = 0;       for (int j = 1; j <= n; ++j) {         s = add(s, mul(x[j], p));         p = mul(p, i);       }       if (s == 0) {         std::cout <<  ?   << i << std::endl;         int v;         std::cin >> v;         assert(v == 0);         std::cout <<  !   << i << std::endl;         return 0;       }     }     std::cout <<  !   << -1 << std::endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = 2 * acos(0.0);   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());   const string DIGITS =  0123456789 ;   const string ALPH =  abcdefghijklmnopqrstuvwxyz ;   template <class T0, class T1>   inline ostream &operator<<(ostream &out, pair<T0, T1> &a) {     return out <<  {  << a.first <<  ,   << a.second <<  } ;   }   template <class T0, class T1, class T2>   inline ostream &operator<<(ostream &out, tuple<T0, T1, T2> &a) {     return out <<  {  << get<0>(a) <<  ,   << get<1>(a) <<  ,   << get<2>(a)                <<  } ;   }   template <class T0, class T1, class T2, class T3>   inline ostream &operator<<(ostream &out, tuple<T0, T1, T2, T3> &a) {     return out <<  {  << get<0>(a) <<  ,   << get<1>(a) <<  ,   << get<2>(a)                <<  ,   << get<3>(a) <<  } ;   }   template <class T>   inline ostream &operator<<(ostream &out, vector<T> &a) {     out <<  [ ;     for (long long i = 0; i < (long long)(a.size()); ++i)       out << a[i] << vector<string>{ ,  ,  ]   }[i + 1 == a.size()];     return out;   }   void smain();   signed main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cout << setprecision(10) << fixed;     smain();     return 0;   }   void smain() {     long long t;     cin >> t;     while (t--) {       long long n, k;       string s;       cin >> n >> k >> s;       vector<long long> p(2);       map<long long, long long> mp;       for (long long i = 0; i < s.size(); i++) {         p[s[i] -  0 ]++;         long long u = p[0] - p[1];         mp[u]++;       }       long long v = p[0] - p[1];       if (v == 0) {         if (mp[k] != 0) {           cout << -1 <<   n ;         } else {           cout << mp[k] <<   n ;         }         continue;       }       long long sum = 0;       for (auto h : mp) {         if ((k - h.first) % abs(v) == 0 && (k - h.first) / v >= 0) {           sum += h.second;         }       }       if (k == 0) sum++;       cout << sum <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int n, ans, dp[105], a[105];   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     if (n % 2 == 0 || n == 1) {       printf( -1 );       return 0;     }     for (int i = n; i >= 2; i--) {       ans += max(a[i], a[i - 1]);       a[(i - 1) / 2] -= min(a[(i - 1) / 2], max(a[i], a[i - 1]));       i--;     }     printf( %d , ans + a[1]);   }