malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     long long t;     cin >> t;     while (t--) {       long long kkkk = 1;       unsigned long long n, i, k, a, j, cont = 0, cont1 = 0, cont2 = 0, x;       cin >> n >> k;       vector<int> vec;       for (i = 0; i < n; i++) {         cin >> a;         vec.push_back(a);         if (vec[i] % 2 != 0) {           cont += 1;         }       }       for (j = cont; j >= k; j = j - 2) {         if (j == k) {           cont1 += 1;           break;         }       }       if (cont1 > 0) {         cout <<  YES  << endl;       } else {         cout <<  NO  << endl;         continue;       }       if (cont >= k) {         for (i = 0;; i++) {           if (kkkk == k) break;           if (vec[i] % 2 != 0) {             cont2 += 1;             cout << i + 1 <<    ;             x++;             kkkk++;           }         }         cout << n << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int dr[] = {0, -1, 0, 1, -1, 1, 1, -1};   const int dc[] = {1, 0, -1, 0, 1, 1, -1, -1};   const double eps = 1e-9;   template <class T>   void print(const vector<T> &v) {     ostringstream os;     for (int i = 0; i < (int)v.size(); ++i) {       if (i) os <<    ;       os << v[i];     }     cout << os.str() << endl;   }   template <class T>   int sz(const T &c) {     return (int)c.size();   }   template <class T>   void srt(T &c) {     sort(c.begin(), c.end());   }   template <class T>   void checkmin(T &a, T b) {     if (b < a) a = b;   }   template <class T>   void checkmax(T &a, T b) {     if (b > a) a = b;   }   template <class T>   T sqr(T x) {     return x * x;   }   template <class T, class U>   T cast(U x) {     ostringstream os;     os << x;     T res;     istringstream is(os.str());     is >> res;     return res;   }   template <class T>   vector<T> split(string s, string x =    ) {     vector<T> res;     for (int i = 0; i < s.size(); i++) {       string a;       while (i < (int)s.size() && x.find(s[i]) == string::npos) a += s[i++];       if (!a.empty()) res.push_back(cast<T>(a));     }     return res;   }   template <class T>   bool inside(T r, T c, T R, T C) {     return r >= 0 && r < R && c >= 0 && c < C;   }   struct segment {     int left, right, len;     segment(int a, int b) : left(a), right(b), len(b - a) {}   };   bool operator<(const segment &a, const segment &b) {     if (a.len != b.len) return a.len > b.len;     return a.left > b.left;   }   map<int, int> t;   int n;   void add(int i, int value) {     for (; i < n; i |= i + 1) t[i] += value;   }   int sum(int i) {     int res = 0;     for (; i >= 0; i -= -~i & ~i)       if (t.count(i)) res += t[i];     return res;   }   int sum(int a, int b) { return sum(b) - sum(a - 1); }   int main(int argc, char *argv[]) {     int m;     scanf( %d%d , &n, &m);     set<segment> q;     q.insert(segment(1, n));     set<int> points;     points.insert(0);     points.insert(n + 1);     map<int, int> pos;     while (m--) {       int x;       scanf( %d , &x);       if (x == 0) {         int a, b;         scanf( %d%d , &a, &b);         printf( %d n , sum(a - 1, b - 1));       } else {         if (pos[x] == 0) {           segment s = *q.begin();           q.erase(s);           int mid = (s.left + s.right + 1) / 2;           pos[x] = mid;           points.insert(mid);           add(mid - 1, 1);           if (s.left <= mid - 1) q.insert(segment(s.left, mid - 1));           if (mid + 1 <= s.right) q.insert(segment(mid + 1, s.right));         } else {           int mid = pos[x];           set<int>::iterator it = points.find(mid);           int pre = *--it;           int nxt = *++ ++it;           if (pre + 1 <= mid - 1) q.erase(segment(pre + 1, mid - 1));           if (mid + 1 <= nxt - 1) q.erase(segment(mid + 1, nxt - 1));           if (pre + 1 <= nxt - 1) q.insert(segment(pre + 1, nxt - 1));           points.erase(mid);           add(mid - 1, -1);           pos[x] = 0;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string v[12] = { x^y^z ,  x^z^y ,  (x^y)^z ,  (x^z)^y ,                    y^x^z ,  y^z^x ,  (y^x)^z ,  (y^z)^x ,                    z^x^y ,  z^y^x ,  (z^x)^y ,  (z^y)^x };   pair<long double, long double> sol[12];   const long double EPS = 1e-12;   long double cmp(pair<long double, long double> a,                   pair<long double, long double> b) {     long double res1, res2;     res1 = a.second * log(a.first);     res2 = b.second * log(b.first);     if (abs(res1 - res2) < EPS) return 0;     return res1 - res2;   }   int main() {     int i, pos;     long double x, y, z;     cin >> x >> y >> z;     sol[0] = {x, pow(y, z)};     sol[1] = {x, pow(z, y)};     sol[2] = {x, y * z};     sol[3] = {x, z * y};     sol[4] = {y, pow(x, z)};     sol[5] = {y, pow(z, x)};     sol[6] = {y, x * z};     sol[6] = {y, z * x};     sol[8] = {z, pow(x, y)};     sol[9] = {z, pow(y, x)};     sol[10] = {z, x * y};     sol[11] = {z, y * x};     pos = 0;     for (i = 1; i < 12; ++i) {       if (cmp(sol[pos], sol[i]) < 0) pos = i;     }     cout << v[pos];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   inline long long read() {     long long 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 << 1) + (x << 3) + c -  0 ;       c = getchar();     }     return x * f;   }   int n, m, fac[1000100], ifac[1000100], ans;   int qpow(int a, int b) {     int ans = 1;     while (b) {       if (b & 1) ans = 1LL * ans * a % mod;       a = 1LL * a * a % mod;       b >>= 1;     }     return ans;   }   void init(int n) {     fac[0] = 1;     for (int i = 1; i <= n; ++i) {       fac[i] = 1LL * fac[i - 1] * i % mod;     }     ifac[n] = qpow(fac[n], mod - 2);     for (int i = n - 1; i >= 0; --i) {       ifac[i] = 1LL * ifac[i + 1] * (i + 1) % mod;     }   }   inline int C(int n, int m) {     if (n < m) return 0;     return 1LL * fac[n] * ifac[m] % mod * ifac[n - m] % mod;   }   int main() {     n = read(), m = read();     read(), read();     init(max(n, m));     ans = 1LL * fac[n - 2] * C(m - 1, n - 2) % mod;     for (int i = 1; i < n - 1; ++i) {       ans = (ans + 1LL * C(m - 1, i - 1) * qpow(m, n - i - 1) % mod *                        C(n - 2, i - 1) % mod * fac[i - 1] % mod * (i + 1) % mod *                        qpow(n, n - i - 2)) %             mod;     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 10;   int gi() {     int x = 0, o = 1;     char ch = getchar();     while (!isdigit(ch) && ch !=  - ) ch = getchar();     if (ch ==  - ) o = -1, ch = getchar();     while (isdigit(ch)) x = x * 10 + ch -  0 , ch = getchar();     return x * o;   }   int n, m, a[N], mx[N], mn[N];   map<pair<int, int>, int> f;   map<int, int> lst;   vector<pair<int, int> > key;   set<pair<int, int> > ban;   void work(int *mx) {     f.clear();     lst.clear();     key.clear();     ban.clear();     for (int i = 1; i <= n; i++) key.push_back(make_pair(0, i));     for (int i = 1; i <= m; i++)       if (a[i] > 1) {         key.push_back(make_pair(i, a[i] - 1));         ban.insert(make_pair(i, a[i]));       }     for (int i = 1; i <= m + 1; i++) {       key.push_back(make_pair(i, n));       ban.insert(make_pair(i, n + 1));     }     sort(key.begin(), key.end());     reverse(key.begin(), key.end());     for (auto t : key) {       if (ban.find(make_pair(t.first, t.second + 1)) != ban.end())         lst[t.first - t.second - 1] = t.first;       if (ban.find(make_pair(t.first, t.second)) != ban.end()) continue;       if (lst.count(t.first - t.second)) {         int x = lst[t.first - t.second], y = x - t.first + t.second;         if (ban.find(make_pair(x, y - 1)) != ban.end())           f[t] = f[make_pair(x, y - 2)];         else           f[t] = f[make_pair(x, y - 1)];       } else         f[t] = t.second + m + 1 - t.first;     }     for (int i = 1; i <= n; i++) mx[i] = f[make_pair(0, i)];   }   int main() {     cin >> n >> m;     for (int i = 1; i <= m; i++) a[i] = gi();     if (n == 1) return cout << 0, 0;     work(mx);     for (int i = 1; i <= m; i++) a[i] = n - a[i] + 1;     work(mn);     reverse(mn + 1, mn + n + 1);     for (int i = 1; i <= n; i++) mn[i] = n - mn[i] + 1;     long long ans = 0;     for (int i = 1; i <= n; i++) ans += mx[i] - mn[i] + 1;     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool checkbit(int mask, int bit) { return mask & (1 << bit); }   int setbit(int mask, int bit) { return mask | (1 << bit); }   int clearbit(int mask, int bit) { return mask & ~(1 << bit); }   int togglebit(int mask, int bit) { return mask ^ (1 << bit); }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n;     int l, r, PR, PL;     cin >> n >> l >> r >> PL >> PR;     int ans = INT_MAX;     int a[n + 1];     int PrefixSum[n + 1];     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     PrefixSum[0] = 0;     for (int i = 1; i <= n; i++) PrefixSum[i] = PrefixSum[i - 1] + a[i];     for (int i = 0; i <= n; i++) {       int usedL = i;       int usedR = n - i;       int now = PrefixSum[i] * l + (PrefixSum[n] - PrefixSum[i]) * r;       if (i > n - i) {         now += (2 * i - n - 1) * PL;       }       if (i < n - i) {         now += (n - 2 * i - 1) * PR;       }       ans = min(ans, now);     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int N = 0;     string s;     cin >> N >> s;     map<char, int> number = {{ 0 , 0}, { 1 , 1}, { 2 , 2}, { 3 , 3}, { 4 , 4},                              { 5 , 5}, { 6 , 6}, { 7 , 7}, { 8 , 8}, { 9 , 9}};     int curr_prefix = 0;     for (int i = 0; i < N; i++) {       curr_prefix += number[s[i]];       int curr = 0;       bool flag = false;       for (int j = i + 1; j < N; j++) {         curr += number[s[j]];         if (curr == curr_prefix) {           curr = 0;           flag = true;         }       }       if (curr == 0 && flag) {         cout <<  YES ;         return 0;       }     }     cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n, x;     cin >> n;     long ans = 0;     vector<int> divisiors, dp(1e6 + 1);     dp[0] = 1;     for (int i = 0; i < n; i++) {       cin >> x;       divisiors.clear();       for (int j = 1; j * j <= x; j++) {         if (x % j == 0) {           divisiors.push_back(j);           if (j != x / j) divisiors.push_back(x / j);         }       }       sort(divisiors.begin(), divisiors.end());       reverse(divisiors.begin(), divisiors.end());       for (int z = 0; z < divisiors.size(); z++) {         dp[divisiors[z]] += dp[divisiors[z] - 1];         dp[divisiors[z]] %= (int)1e9 + 7;       }     }     for (int i = 1; i <= 1e6; i++) {       ans += dp[i];       ans %= (int)1e9 + 7;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e5 + 10;   int N, arr[MAXN], tid[MAXN], a[MAXN], b[MAXN];   int main() {     scanf( %d , &N);     for (int i = (0), iend = (N); i < iend; ++i) scanf( %d , &arr[i]);     iota(tid, tid + N, 0);     sort(tid, tid + N,          [](const int& x, const int& y) { return arr[x] < arr[y]; });     int cur = 0;     for (int _i = ((N + 2) / 3), _iend = (N); _i < _iend; ++_i) {       int i = tid[_i];       if (cur & 1)         a[i] = cur >> 1, b[i] = arr[i] - a[i];       else         b[i] = cur >> 1, a[i] = arr[i] - b[i];       cur++;     }     for (int i = (0), iend = ((N + 2) / 3); i < iend; ++i)       b[tid[i]] = arr[tid[i]];     puts( YES );     for (int i = (0), iend = (N); i < iend; ++i) printf( %d  , a[i]);     puts(  );     for (int i = (0), iend = (N); i < iend; ++i) printf( %d  , b[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a, b, k;   int main() {     cin >> a >> b >> k;     a %= b;     bool ok = false;     int i;     for (i = 0; i < 1000000; i++) {       a *= 10;       int x = a / b;       a %= b;       if (x == k) {         ok = true;         break;       }     }     if (ok)       cout << i + 1 << endl;     else       cout << -1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double pi = 3.14159265;   using namespace std;   int a[200000];   int main() {     int n, x, y;     scanf( %d , &n);     scanf( %d , &x);     scanf( %d , &y);     fill(a, a + 200000, 2e9);     int count0 = -1;     for (int i = 0; i < n; i++) {       scanf( %d , &a[i + x]);       ;     }     for (int i = 0; i < n; i++) {       for (int j = 1; j <= x; j++) {         if (a[i + x] > a[i + j]) {           goto l;         }       }       for (int j = 1; j <= y; j++) {         if (a[i + x] > a[i + x + j]) {           goto l;         }       }       printf( %d , i + 1);       printf(  n );       break;     l:       0;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long l[2], r[2], k;     cin >> l[0] >> r[0] >> l[1] >> r[1] >> k;     long long max_ow = min(r[0], r[1]);     long long min_ow = max(l[0], l[1]);     long long ans = max_ow - min_ow;     if (max_ow >= k && min_ow <= k) {       ans--;     }     if (ans < 0) {       cout <<  0  << endl;       return 0;     }     cout << ans + 1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   const int N = 2e5;   int dep[N], fa[N], cnt[N], ans;   int main() {     ios ::sync_with_stdio(0);     cin >> n;     ans = 1;     for (int i = 2; i <= n; ++i) {       cin >> fa[i];       dep[i] = dep[fa[i]] + 1;       cnt[dep[i]] ^= 1;     }     for (int i = 1; i <= n; ++i) ans += cnt[i];     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1E3 + 5, M = 11;   int n, d;   long long dp[N][M][N], inv[M] = {1}, ans, mo;   inline void upd(long long &x, long long y) {     x += y;     if (x >= mo) x -= mo;   }   long long Pow(long long a, int b = mo - 2) {     long long res = 1;     for (; b; b >>= 1, a = a * a % mo)       if (b & 1) res = res * a % mo;     return res;   }   long long C(int n, int m) {     long long res = inv[m];     for (int i = n - m + 1; i <= n; ++i) res = res * i % mo;     return res;   }   long long f(int i, int j, int k) {     if (dp[i][j][k] != -1) return dp[i][j][k];     if (i == 1) return dp[i][j][k] = !j || j == d - 1;     if (i > j * k + 1) return 0;     long long res = f(i, j, k - 1);     for (int t = 1; t * k < i && t <= j; ++t)       upd(res,           f(i - t * k, j - t, k - 1) * C(f(k, d - 1, k - 1) + t - 1, t) % mo);     return dp[i][j][k] = res;   }   int main() {     scanf( %d%d%lld , &n, &d, &mo);     if (n == 1) return 0 * printf( 1 n );     if ((n - 2) % (d - 1)) return 0 * printf( 0 n );     memset(dp, -1, sizeof dp);     for (long long i = 1, j = 1; i <= d; ++i) {       j = j * i % mo;       inv[i] = Pow(j);     }     ans = f(n, d, n >> 1);     if (n & 1)       ;     else       ans -= C(f(n / 2, d - 1, n / 2 - 1), 2);     printf( %lld n , (ans % mo + mo) % mo);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long t;   long long a[200005];   int main() {     ios_base::sync_with_stdio(false);     cin >> t;     while (t--) {       long long n;       cin >> n;       for (int i = 1; i <= n; i++) {         cin >> a[i];         if (a[i] >= 0)           a[i] %= n;         else {           long long x = abs(a[i] / n);           a[i] = a[i] + n * (x + 5);           a[i] %= n;         }       }       vector<long long> v;       map<long long, long long> m;       for (int i = 1; i <= n; i++) {         v.push_back(((i - 1) + a[i]) % n);         m[((i - 1) + a[i]) % n]++;       }       bool flag = false;       for (auto x : v) {         if (m[x] > 1) {           flag = 1;         }       }       if (!flag)         cout <<  yes ;       else         cout <<  no ;       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1000010;   int P[N];   string T[N];   vector<int> G[N], depth[N + 1];   int DP[N][4];   int V[N];   int D[N];   int dfs(int c) {     D[c] = D[P[c]] + 1;     depth[D[c]].push_back(c);     if (T[c][0] ==  I ) return V[c];     if (T[c][0] ==  N ) return V[c] = !dfs(G[c][0]);     if (T[c][0] ==  A ) return V[c] = dfs(G[c][0]) & dfs(G[c][1]);     if (T[c][0] ==  O ) return V[c] = dfs(G[c][0]) | dfs(G[c][1]);     if (T[c][0] ==  X ) return V[c] = dfs(G[c][0]) ^ dfs(G[c][1]);   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n, x, y;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> T[i];       if (T[i][0] ==  I )         cin >> V[i];       else if (T[i][0] ==  N ) {         cin >> x;         G[i].push_back(x);         P[x] = i;       } else {         cin >> x >> y;         G[i].push_back(x);         G[i].push_back(y);         P[x] = P[y] = i;       }     }     dfs(1);     DP[1][0] = 0;     DP[1][1] = 1;     for (int i = 0; i <= N; i++)       for (auto& c : depth[i]) {         if (c == 1) continue;         int p = P[c];         DP[c][V[c]] = DP[p][V[p]];         int o = !V[c];         if (T[p][0] ==  N ) DP[c][o] = DP[p][!o];         if (T[p][0] ==  A ) {           int s = V[G[p][0]] + V[G[p][1]] - V[c] + o;           DP[c][o] = DP[p][(s == 2 ? 1 : 0)];         }         if (T[p][0] ==  O ) {           int s = V[G[p][0]] + V[G[p][1]] - V[c] + o;           DP[c][o] = DP[p][(s > 0 ? 1 : 0)];         }         if (T[p][0] ==  X ) {           int s = V[G[p][0]] + V[G[p][1]] - V[c] + o;           DP[c][o] = DP[p][(s == 1 ? 1 : 0)];         }       }     for (int i = 1; i <= n; i++)       if (T[i][0] ==  I ) cout << DP[i][!V[i]];   }
#include <bits/stdc++.h>   using namespace std;   long long i, j, k, s, l, m, n, t, a, c, b, d, e[11][11];   string p, q, r, f;   int main() {     cin >> n >> a >> m >> b;     a = abs(b - a);     s = 0;     for (i = 1; i <= m; i++) {       b = abs(a - i);       c = a + i;       t = 0;       if (n >= c) {         t = 2 * (c - b);       }       if (n >= b && n < c) t = 1 + (n - b) * 2;       if (b == 0) t--;       if (t == 0) k++;       s += t;     }     swap(n, m);     for (i = 1; i <= m; i++) {       b = abs(a - i);       c = a + i;       t = 0;       if (n >= c) {         t = 2 * (c - b);       }       if (n >= b && n < c) t = 1 + (n - b) * 2;       if (b == 0) t--;       if (t == 0) k++;       s += t;     }     if (s == 0)       cout << 1 + k;     else       cout << s / 2 + 2 + k;     return 0;   }
#include <bits/stdc++.h>   time_t st = clock();   using namespace std;   template <class stl>   void DBGSTL(stl a) {     cout <<   tDEBUG: n t ;     for (typeof(a.begin()) i = a.begin(); i != a.end(); i++) {       cerr << *i <<    ;     }     cerr <<   n ;     return;   }   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 / gcd(a, b) * b; }   double mathround(double x) {     int intx = (int)x;     if (x < intx + 0.5) return intx;     return intx + 1;   }   int main() {     int n;     int p[100];     vector<int> ans;     cin >> n;     for (int i = 0; i < n; i++) cin >> p[i];     getchar();     int cnt = 0;     int loss = 0;     for (int i = 0; i < n; i++) {       if (p[i] < 0) loss++;       if (loss == 3) {         loss = 1;         ans.push_back(cnt);         cnt = 0;       }       cnt++;     }     if (cnt > 0) ans.push_back(cnt);     cout << (int)(ans).size() << endl;     for (int i = 0; i < (int)(ans).size(); i++) cout << ans[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, a[1000005], ans, p = 1;   int main() {     scanf( %I64d , &n);     for (int i = 1; i <= n; i++) scanf( %I64d , a + i);     for (int i = n - 1; i > 0; p = (p << 1) % 998244353, i--)       ans = (ans + (n + 2 - i) * p % 998244353 * a[i] % 998244353) % 998244353;     printf( %I64d n , (ans + a[n]) % 998244353);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s, s2, t1, t2;   int main() {     long long n, l, r, i, j;     cin >> s;     n = s.length();     char mx =  a ;     for (i = n - 1; i >= 0; i--) {       if (s[i] - mx >= 0) {         mx = s[i];         l = i;       }     }     s2 += mx;     r = l;     for (i = mx -  a ; i >= 0; i--) {       char aa =  a  + i;       l = r;       for (j = l + 1; j < n; j++) {         if (s[j] == aa) {           s2 += s[j];           r = j;         }       }     }     cout << s2 << endl;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   void OUT(T x, int n) {     for (int i = 0; i < n; ++i) cout << x[i] <<    ;     cout << endl;   }   template <class T>   void OUT(T x, int n, int m) {     for (int i = 1; i <= n; ++i) OUT(x[i], m);     cout << endl;   }   template <class T>   void checkmod(T& a, T m) {     a = (a % m + m) % m;   }   inline long long mod(long long x, long long y) {     return x - floor(1.0 * x / y + 1e-8) * y;   }   const int maxn = 50005, INF = 0x7fffffff;   int n, m;   int p[105];   char name[105][35];   int c[105], Count = 0;   char s[35];   bool comp(int a, int b) { return a > b; }   int main() {     int i, j, k, t, T, x, y, sum, index;     scanf( %d%d , &n, &m);     for (i = 0; i < n; i++) scanf( %d , p + i);     sort(p, p + n);     for (i = 1; i <= m; i++) {       scanf( %s , s);       for (j = 0; j < Count; j++) {         if (strcmp(s, name[j]) == 0) {           c[j]++;           break;         }       }       if (j == Count) c[Count]++, strcpy(name[Count++], s);     }     sort(c, c + Count, comp);     int minp = 0, maxp = 0;     for (i = 0; i < Count; i++) {       minp += p[i] * c[i];     }     for (i = 0; i < Count; i++) {       maxp += p[n - i - 1] * c[i];     }     printf( %d %d n , minp, maxp);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool binary(vector<int> v, int key) {     int lo = 0, hi = v.size() - 1;     while (lo <= hi) {       int mid = (lo + hi) / 2;       if (v[mid] == key)         return true;       else if (v[mid] < key)         lo = mid + 1;       else         hi = mid - 1;     }     return false;   }   int main() {     int n, ans = 0, l = 0, r = 0, u = 0, d = 0;     cin >> n;     vector<pair<int, int>> v;     for (int i = 0; i < n; i++) {       int t1, t2;       cin >> t1 >> t2;       v.push_back(make_pair(t1, t2));     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         if (v[j].first == v[i].first && v[j].second < v[i].second) d++;         if (v[j].first == v[i].first && v[j].second > v[i].second) u++;         if (v[j].first < v[i].first && v[j].second == v[i].second) l++;         if (v[j].first > v[i].first && v[j].second == v[i].second) r++;       }       if (d && r && l && u) ans++;       d = 0, r = 0, l = 0, u = 0;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using i64 = int_fast64_t;   using seika = string;   template <class kizuna>   using akari = vector<kizuna>;   template <class yuzuki>   using yukari = akari<akari<yuzuki>>;   template <class tsurumaki>   using maki = akari<yukari<tsurumaki>>;   template <class kotonoha>   using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;   template <class kotonoha>   using aoi = priority_queue<kotonoha>;   inline void print() { cout << endl; }   template <typename First, typename... Rest>   void print(const First &first, const Rest &...rest) {     cout << first <<    ;     print(rest...);   }   void solve() {     int n;     cin >> n;     akari<int> as(n);     for (int i = 0; i < n; i++) {       cin >> as[i];       as[i] &= 1;     }     stack<int> st;     int now = -1, cur = 0;     as.push_back(-1);     for (int a : as) {       if (a == now) {         cur++;       } else {         if (cur & 1) {           if (!st.empty() && st.top() == now) {             st.pop();           } else if (now != -1) {             st.push(now);           }         }         now = a;         cur = 1;       }     }     if (st.size() < 2) {       cout <<  YES  << endl;     } else {       cout <<  NO  << endl;     }   }   int main() {     solve();     return 0;   }