malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long tot, n, q, u, v, z, a, b, c, p, k;   long long dep[200005], f[200005][25], fa[200005], va[200005];   struct edge {     long long from, head, nxt, val, go;   } e[200005 * 4];   long long find(long long x) {     long long o = x;     while (x != fa[x]) x = fa[x] = fa[fa[x]];     while (o != x) {       long long j = fa[o];       fa[o] = x;       o = j;     }     return x;   }   void add(long long u, long long v, long long z) {     e[++tot].nxt = e[u].head;     e[u].head = tot;     e[tot].from = u;     e[tot].go = v;     e[tot].val = z;   }   void deal_first(long long u, long long father) {     dep[u] = dep[father] + 1;     for (int i = 0; i <= 19; i++) f[u][i + 1] = f[f[u][i]][i];     for (long long i = e[u].head; i; i = e[i].nxt) {       long long v = e[i].go, w = e[i].val;       if (v == father) continue;       if (w == 1) fa[v] = find(u);       va[v] = w;       f[v][0] = u;       deal_first(v, u);     }   }   long long lca(long long u, long long v) {     if (dep[u] < dep[v]) swap(u, v);     for (long long i = 17; i >= 0; i--) {       if (dep[f[u][i]] >= dep[v]) u = f[u][i];       if (u == v) return u;     }     for (long long i = 17; i >= 0; i--) {       if (f[u][i] != f[v][i]) {         u = f[u][i];         v = f[v][i];       }     }     return f[u][0];   }   int main() {     scanf( %lld%lld , &n, &q);     for (int i = 1; i < n; i++) {       scanf( %lld%lld%lld , &u, &v, &z);       add(u, v, z);       add(v, u, z);     }     for (int i = 1; i <= n; i++) fa[i] = i;     deal_first(1, 0);     while (q--) {       scanf( %lld , &k);       if (k == 1) {         scanf( %lld%lld%lld , &a, &b, &c);         long long finish = lca(a, b);         while (dep[a] > dep[finish] && c) {           c = c / va[a];           a = find(f[a][0]);         }         while (dep[b] > dep[finish] && c) {           c = c / va[b];           b = find(f[b][0]);         }         printf( %lld n , c);       } else {         scanf( %lld%lld , &p, &c);         long long u = e[p << 1].from, v = e[p << 1].go;         if (f[u][0] == v)           z = u;         else           z = v;         va[z] = c;         if (va[z] == 1) fa[z] = find(f[z][0]);       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k, p, c = 0;     cin >> n >> k;     vector<int> v;     map<int, int> m;     for (int i = 1; i <= n; i++) {       cin >> p;       v.push_back(p);       m[p]++;     }     if (m[k] == 0) v.push_back(k), c++, n++;     sort(v.begin(), v.end());     while (1) {       int x = (n + 1) / 2;       if (v[x - 1] == k) {         cout << c;         return 0;       } else if (v[x - 1] < k) {         v.push_back(100000);         n++;         c++;       } else         v.push_back(1), n++, c++;       sort(v.begin(), v.end());     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 300010;   int n, l[N], t[N];   long long r, dv, res, tcur;   vector<long long> ans;   void solve(int l, int t) {     if (2 * l <= t) {       tcur += 2 * l;       return;     }     long long x = t - l;     long long tmp = (1ll * l - x + r - 1) / r;     res += tmp;     dv = x + tmp * r - l;     tcur += 2 * x;     long long t1 = tcur;     while (ans.size() < 1e5 + 10 && tmp) {       ans.push_back(t1);       tmp--;       t1 += r;     }     tcur += l - x;   }   int main() {     cin >> n >> r;     for (int i = 1; i <= n; i++) cin >> l[i];     for (int i = 1; i <= n; i++) cin >> t[i];     res = 0;     dv = 0;     tcur = 0;     for (int i = 1; i <= n; i++) {       if (l[i] > t[i]) {         res = -1;         break;       }       if (l[i] <= dv) {         dv -= l[i];         tcur += l[i];         continue;       }       l[i] -= dv;       t[i] -= dv;       tcur += dv;       dv = 0;       solve(l[i], t[i]);     }     cout << res << endl;     if (res != -1 && ans.size() <= 1e5) {       assert(res == ans.size());       for (int i = 0; i < ans.size(); i++) cout << ans[i] <<    ;       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 228;   const int big = 2e9;   const int md = 1e9 + 7;   struct node {     int l, r, s;   };   int n, m, a[N], pr[N], root[N], k, tex, jj;   node t[N * 40];   bool ok;   void build(int v, int l, int r) {     if (l == r) return;     t[v].l = ++k;     t[v].r = ++k;     int d = (l + r) >> 1;     build(t[v].l, l, d);     build(t[v].r, d + 1, r);   }   void update(int v, int l, int r, int ps, int vl) {     if (l == r) {       t[++k].s = vl;       return;     }     int d = (l + r) >> 1;     if (ps <= d) {       update(t[v].l, l, d, ps, vl);       t[++k].l = k - 1;       t[k].r = t[v].r;     } else {       update(t[v].r, d + 1, r, ps, vl);       t[++k].r = k - 1;       t[k].l = t[v].l;     }     t[k].s = t[t[k].l].s + t[t[k].r].s;   }   void mod(int v, int l, int r, int ps, int vl) {     if (l == r) {       t[v].s = vl;       return;     }     int d = (l + r) >> 1;     if (ps <= d)       mod(t[v].l, l, d, ps, vl);     else       mod(t[v].r, d + 1, r, ps, vl);     t[v].s = t[t[v].l].s + t[t[v].r].s;   }   int go(int v, int l, int r) {     if (l == r) return l;     int d = (l + r) >> 1;     if (t[t[v].l].s >= tex)       return go(t[v].l, l, d);     else {       tex -= t[t[v].l].s;       return go(t[v].r, d + 1, r);     }   }   void nx(int v, int tl, int tr, int l, int r) {     if (l > r || ok) return;     if (tl == l && tr == r) {       if (tex <= t[v].s) {         ok = 1;         jj = go(v, l, r);       } else         tex -= t[v].s;       return;     }     int d = (tl + tr) >> 1;     nx(t[v].l, tl, d, l, min(r, d));     nx(t[v].r, d + 1, tr, max(l, d + 1), r);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     k = 1;     root[n + 1] = 1;     build(1, 1, n);     for (int i = n; i >= 1; i--) {       update(root[i + 1], 1, n, i, 1);       if (pr[a[i]] != 0) update(k, 1, n, pr[a[i]], 0);       root[i] = k;       pr[a[i]] = i;     }     for (int i = 1; i <= n; i++) {       int j = 1, ans = 0;       ok = 1;       while (j <= n && ok) {         ans++;         tex = i + 1;         ok = 0;         nx(root[j], 1, n, j, n);         j = jj;       }       cout << ans <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int test;     cin >> test;     while (test--) {       int n;       cin >> n;       for (int i = 2 * n, j = 0; j < n; i += 2, ++j) {         cout << i <<    ;       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 5e5 + 10;   int le[MAXN], ri[MAXN];   int a[MAXN];   struct num {     int val, pos;   };   num data[MAXN];   bool cmp(num a, num b) { return a.val < b.val; }   int main() {     int n;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i];       data[i].val = a[i];       data[i].pos = i;       le[i] = i - 1;       ri[i] = i + 1;     }     sort(data, data + n, cmp);     long long ans = 0;     int low = 0;     int hi = n - 1;     for (int i = 0; i < n - 2; i++) {       int pos = data[i].pos;       if (low == pos) {         ans += a[pos];         low = ri[pos];       } else if (hi == pos) {         ans += a[pos];         hi = le[pos];       } else {         ans += min(a[le[pos]], a[ri[pos]]);         ri[le[pos]] = ri[pos];         le[ri[pos]] = le[pos];       }     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int SZ = 1000010;   const long long INF = 1e18 + 10;   const int mod = 1e9 + 7;   const long double eps = 1e-12;   long long read() {     long long n = 0;     char a = getchar();     bool flag = 0;     while (a >  9  || a <  0 ) {       if (a ==  - ) flag = 1;       a = getchar();     }     while (a <=  9  && a >=  0 ) {       n = n * 10 + a -  0 , a = getchar();     }     if (flag) n = -n;     return n;   }   int a[SZ], s[SZ], b[SZ];   int main() {     int n = read(), m = read(), sum = 0;     for (int i = 1; i <= m; i++) a[i] = read(), b[i] = (sum += a[i]) % n;     printf( %d n , (sum + n - 1) / n);     b[m] = n;     sort(b + 1, b + 1 + m);     for (int i = 1; i <= m; i++) s[i] = b[i] - b[i - 1];     for (int i = 1; i <= m; i++) printf( %d  , s[i]);     puts(  );     int k = 1;     for (int i = 1, j = 1; i <= m; i++)       while (a[i] > 0) {         a[i] -= s[j];         printf( %d  , i);         if (k % m == 0) puts(  );         k++;         j++, j = (j - 1) % m + 1;       }     while ((k - 1) % m) k++, printf( 1  );   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = (int)1e9 + 7;   const int INF = (int)1e9;   const long long LINF = (long long)1e18;   const long double PI = acos((long double)-1);   const long double EPS = 1e-9;   inline long long gcd(long long a, long long b) {     long long r;     while (b) {       r = a % b;       a = b;       b = r;     }     return a;   }   inline long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }   inline long long fpow(long long n, long long k, int p = MOD) {     long long r = 1;     for (; k; k >>= 1) {       if (k & 1) r = r * n % p;       n = n * n % p;     }     return r;   }   template <class T>   inline int chkmin(T& a, const T& val) {     return a > val ? a = val, 1 : 0;   }   template <class T>   inline int chkmax(T& a, const T& val) {     return a < val ? a = val, 1 : 0;   }   inline long long isqrt(long long k) {     long long r = sqrt(k) + 1;     while (r * r > k) r--;     return r;   }   inline long long icbrt(long long k) {     long long r = cbrt(k) + 1;     while (r * r * r > k) r--;     return r;   }   inline void addmod(int& a, int val, int p = MOD) {     if ((a = (a + val)) >= p) a -= p;   }   inline void submod(int& a, int val, int p = MOD) {     if ((a = (a - val)) < 0) a += p;   }   inline int mult(int a, int b, int p = MOD) { return (long long)a * b % p; }   inline int inv(int a, int p = MOD) { return fpow(a, p - 2, p); }   const int maxn = 100010;   const int magic = 320;   int fac[maxn];   int rfac[maxn];   int f[maxn];   int p25[maxn];   int binomial(int a, int b) {     if (!a || a == b) {       return 1;     }     return mult(fac[b], mult(rfac[a], rfac[b - a]));   }   void solve() {     fac[0] = 1;     for (int i = (1); i < (maxn); i++) fac[i] = mult(fac[i - 1], i);     for (int i = (0); i < (maxn); i++) rfac[i] = inv(fac[i]);     p25[0] = 1;     for (int i = (1); i < (maxn); i++) p25[i] = mult(p25[i - 1], 25);     int m, k;     cin >> m;     string s;     cin >> s;     if ((k = int((s).size())) > magic) memset(f, -1, sizeof(f));     while (m--) {       int op;       cin >> op;       if (op == 1) {         string s;         cin >> s;         if ((k = int((s).size())) > magic) memset(f, -1, sizeof(f));       } else {         int n;         cin >> n;         if (n < k) {           cout << 0 <<   n ;           continue;         }         if (k > magic && ~f[n]) {           cout << f[n] <<   n ;           continue;         }         int res = fpow(26, n);         for (int i = (0); i < (k); i++) {           submod(res, mult(binomial(i, n), p25[n - i]));         }         if (k > magic) f[n] = res;         cout << res <<   n ;       }     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     solve();     return 0;   }
#include <bits/stdc++.h>   const int MXN = 100010;   bool alive[MXN * 5];   int L[MXN], R[MXN], T[MXN];   struct heap_t {     int idx;     heap_t(int nidx) : idx(nidx) {}     bool operator<(const heap_t& cmp) const { return T[idx] > T[cmp.idx]; }   };   struct ele_t {     int idx, val;     bool operator<(const ele_t& cmp) const { return val < cmp.val; }   } ele[MXN * 2], ele2[MXN * 5];   int ans[MXN];   int main() {     int n, m;     scanf( %d %d , &m, &n);     for (int i = 1; i <= n; i++) {       scanf( %d %d %d , &L[i], &R[i], &T[i]);       ele[i].idx = i, ele[i].val = L[i];       ele[i + n].idx = i, ele[i + n].val = R[i];     }     int cele2 = m;     for (int i = 1; i <= m; i++) {       ele2[i].idx = i;       scanf( %d , &ele2[i].val);     }     int lstPos = -1;     std::priority_queue<heap_t> heap;     std::sort(ele + 1, ele + n * 2 + 1);     for (int i = 1; i <= n * 2; i++) {       while (!heap.empty() && !alive[heap.top().idx]) heap.pop();       if (!heap.empty()) {         ++cele2;         ele2[cele2].idx = cele2;         ele2[cele2 + 1].idx = cele2;         ele2[cele2].val = T[heap.top().idx] - lstPos;         ele2[cele2 + 1].val = T[heap.top().idx] - ele[i].val;         ++cele2;       }       lstPos = ele[i].val;       alive[ele[i].idx] = !alive[ele[i].idx];       if (alive[ele[i].idx]) heap.push(ele[i].idx);     }     int sum = 0, cnt = 0;     std::sort(ele2 + 1, ele2 + cele2 + 1);     for (int i = 1; i <= cele2; i++) {       sum += cnt * (ele2[i].val - lstPos);       lstPos = ele2[i].val;       if (ele2[i].idx <= m)         ans[ele2[i].idx] = sum;       else {         alive[ele2[i].idx] = !alive[ele2[i].idx];         cnt += (alive[ele2[i].idx]) ? 1 : -1;       }     }     for (int i = 1; i <= m; i++) printf( %d%c , ans[i], i == m ?   n  :    );   }
#include <bits/stdc++.h>   const long long INF = (long long)1e18 + 18;   const long long maxn = (long long)1e6 + 6;   using namespace std;   long long n;   signed main() {     cin >> n;     long long a[n], c[n], b[maxn];     for (long long i = 0; i < n; i++) {       cin >> a[i];     }     for (long long i = 0; i < n; i++) {       long long inp;       cin >> inp;       b[inp] = i + 1;     }     for (long long i = 0; i < n; i++) {       c[i] = b[a[i]];     }     long long fine = 0, maxx = c[0];     for (long long i = 0; i < n; i++) {       if (c[i] < maxx) {         fine++;       }       maxx = max(maxx, c[i]);     }     cout << fine;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   const int N = 10010;   int f[2][N], g[2][N], a[N], ans[N], b[N], pr[N];   inline int qpow(long long a, int b, const int p) {     int ret = 1;     a %= p;     while (b) {       ret = ret * 1ll * (b & 1 ? a : 1) % p;       a = a * a % p, b >>= 1;     }     return ret;   }   int main() {     auto _add = [&](int &x, int y) {       x += y;       if (x >= mod) x -= mod;     };     int n;     scanf( %d , &n);     a[1] = 1;     b[1] = 1;     const int inv_2 = mod - mod / 2;     for (int i = 2; i <= n; i++) scanf( %d , &a[i]), b[i] = a[i];     for (int i = 2; i <= n; i++) b[i] = b[i - 1] * 1ll * b[i] % mod;     for (int i = n; i >= 2; i--) pr[i] = (pr[i + 1] + b[i]) % mod;     for (int i = 1; i <= n; i++) {       f[i & 1][0] = g[i & 1][0] = 1;       for (int j = 1; j <= n * 2 - 2; j++) {         f[i & 1][j] = f[i & 1][j - 1] * 1ll * a[i + j] % mod;         g[i & 1][j] = 0;         if (j >= 2)           _add(g[i & 1][j], f[i & 1][j - 2] * 1ll * (a[i] - 1 + mod) % mod);         _add(g[i & 1][j], g[(i - 1) & 1][j - 1]);         _add(ans[j], g[i & 1][j] * 1ll * b[i] % mod);       }     }     for (int i = 1; i <= 2 * n - 2; i++) {       if (i <= n - 1) {         ans[i] =             ((ans[i] - pr[1 + i] + mod) % mod * 1ll * inv_2 % mod + pr[1 + i]) %             mod;       } else         ans[i] = ans[i] * 1ll * inv_2 % mod;     }     for (int i = 1; i <= 2 * n - 2; i++)       printf( %d%c , ans[i], i == 2 * n - 2 ?   n  :    );     return 0;   }
#include <bits/stdc++.h>   const int INF = 1e9 + 1;   const int MOD = 1e9 + 7;   const int N = 1e6 + 1;   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     int n, m;     cin >> n >> m;     if (m == 1) {       cout <<  100003 100003  << endl;       cout <<  1 2 100003  << endl;       return 0;     }     cout <<  100003 100003  << endl;     for (int i = 1; i < n - 1; i++) {       cout << i <<     << i + 1 <<   1  << endl;       m--;     }     cout << n - 1 <<     << n <<     << 100003 - n + 2 << endl;     m--;     long long int z = 1000000000;     for (int i = 1; i < n && m > 0; i++) {       for (int j = i + 2; j <= n && m > 0; j++) {         cout << i <<     << j <<     << z << endl;         m--;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double memo[2002][2002];   double p;   int main() {     int n, t;     cin >> n >> p >> t;     double ans = 0;     memo[0][0] = 1.0;     for (int per = 1; per <= n; per++)       for (int s = 1; s <= t; s++)         memo[per][s] = memo[per - 1][s - 1] * p + memo[per][s - 1] * (1.0 - p);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= t; j++) ans += memo[i][j];     printf( %lf , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, val;     int arr[3] = {0}, count = 0;     cin >> n;     for (int i = 0; i < n; ++i) {       cin >> val;       arr[val]++;     }     if (arr[2] <= arr[1]) {       count += arr[2];       arr[1] -= arr[2];       count += (arr[1] / 3);     } else {       count += arr[1];     }     cout << count;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   int main() {     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       set<int> se;       for (int i = 0; i < n; i++) {         int va;         cin >> va;         se.insert(va & 1);       }       if (se.size() == 1) {         cout <<  YES n ;       } else {         cout <<  NO n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100010, mod = 998244353;   inline long long read() {     char ch = getchar();     long long x = 0, f = 0;     while (ch <  0  || ch >  9 ) f |= ch ==  - , ch = getchar();     while (ch >=  0  && ch <=  9 ) x = x * 10 + ch -  0 , ch = getchar();     return f ? -x : x;   }   int n, m, dfn[maxn], low[maxn], stk[maxn], tp, cnt, id[maxn], deg[maxn], scnt,       el, head[maxn], to[maxn], nxt[maxn], ans, q[maxn], h = 1, r;   bool ins[maxn];   vector<int> vec[maxn];   inline int ask(int u, int v) {     printf( ? %d %d n , u, v);     fflush(stdout);     return read();   }   inline void add(int u, int v) {     to[++el] = v;     nxt[el] = head[u];     head[u] = el;   }   void dfs(int u) {     dfn[u] = low[u] = ++cnt;     stk[++tp] = u;     ins[u] = true;     for (int i = head[u]; i; i = nxt[i]) {       int v = to[i];       if (!dfn[v])         dfs(v), low[u] = min(low[u], low[v]);       else if (ins[v])         low[u] = min(low[u], dfn[v]);     }     if (low[u] == dfn[u]) {       scnt++;       do {         int v = stk[tp];         ins[v] = false;         id[v] = scnt;         vec[scnt].push_back(v);       } while (stk[tp--] != u);     }   }   int main() {     n = read();     m = read();     for (int i = (1); i <= (m); i++) {       int u = read(), v = read();       add(u, v);     }     for (int i = (1); i <= (n); i++)       if (!dfn[i]) dfs(i);     for (int u = (1); u <= (n); u++)       for (int i = head[u]; i; i = nxt[i])         if (id[u] != id[to[i]]) deg[id[to[i]]]++;     for (int i = (1); i <= (scnt); i++)       if (!deg[i]) q[++r] = i;     ans = vec[q[h]].back();     while (h != r) {       int &at = q[h + 1];       int u = vec[at].back();       if (!ask(ans, u)) swap(u, ans), swap(q[h], q[h + 1]);       for (int i = head[u]; i; i = nxt[i])         if (id[u] != id[to[i]] && !--deg[id[to[i]]]) q[++r] = id[to[i]];       vec[at].pop_back();       if (vec[at].empty()) swap(q[h], q[h + 1]), h++;     }     printf( ! %d n , ans);     fflush(stdout);   }
#include<bits/stdc++.h>   using namespace std;   const int N=1e5+5;   int tot;   int head[N],to[N*2],next1[N*2];   void lian(int x,int y)   {       to[++tot]=y;       next1[tot]=head[x];       head[x]=tot;   }   int d[N],k;   struct qw{       int a,b,c,d;   }e[N];   struct er{       int a,b;   }jie[N];   void dfs(int x,int fa)   {       jie[x].a=x,jie[x].b=0;       for(int i=head[x];i;i=next1[i])       {           int v=to[i];           if(v==fa) continue;           d[x]++;           dfs(v,x);       }       if(d[x]==0) return;       int v1=-1;       for(int i=head[x];i;i=next1[i])       {           int v=to[i];           if(v==fa) continue;           if(jie[v].b==0)           {               if(v1==-1) jie[x].a=jie[v].a;               else if(jie[x].b==0) jie[x].b=jie[v].a;               else e[++k]=(qw){v,x,v,jie[x].a},jie[x].a=jie[v].a;               v1=0;                          }       }       if(v1==-1)       {           for(int i=head[x];i;i=next1[i])           {               int v=to[i];               if(v==fa) continue;               v1=v;               e[++k]=(qw){v,x,x,jie[v].a};               jie[x].a=jie[v].b;               break;           }       }       for(int i=head[x];i;i=next1[i])       {           int v=to[i];           if(v==fa||jie[v].b==0||v==v1) continue;           if(jie[v].a&&jie[v].b) e[++k]=(qw){v,x,jie[v].a,jie[x].a},jie[x].a=jie[v].b;           else e[++k]=(qw){v,x,jie[x].a,v},jie[x].a=jie[v].a;       }   }   int main()   {       int T;       cin>>T;       while(T--)       {           int n;           cin>>n;           int x,y;           for(int i=1;i<=n-1;i++)           {               scanf( %d %d ,&x,&y);               lian(x,y),lian(y,x);           }           k=0;           dfs(1,0);           printf( %d n ,k);           for(int i=1;i<=k;i++)           printf( %d %d %d %d n ,e[i].a,e[i].b,e[i].c,e[i].d);           tot=0;           for(int i=1;i<=n;i++) head[i]=d[i]=0;       }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, k, a[100100];   int main() {     scanf( %lld %lld , &n, &k);     int temp = 0, t = 0;     vector<int> v;     for (int i = 1; i <= n; i++) {       long long x;       scanf( %lld , &x);       if (temp + (i - n) * x * 1ll * (i - t - 1) < k) {         v.push_back(i);         t++;       } else         temp = temp + x * 1ll * (i - t - 1);     }     for (int i = 0; i < v.size(); i++) printf( %d n , v[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int a[1001];     int b[1001] = {0};     for (int i = 0; i < n; i++) {       cin >> a[i];       b[a[i]] = 1;     }     sort(a, a + n);     int ans = 0;     int sum = a[n - 1] - a[0] + 1;     cout << sum - n << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   using namespace std;   const long double eps = 1e-7;   const int inf = 1000000010;   const long long INF = 10000000000000010LL;   const int mod = 1000000007;   const int MAXN = 100010;   int n, m, k, u, v, x, y, t, a, b, ans;   string A[5];   string s;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> s;     for (int i = 0; i < 5; i++) {       cin >> A[i];       if (A[i][0] == s[0] || A[i][1] == s[1]) return cout <<  YES  <<   n , 0;     }     return cout <<  NO  <<   n , 0;     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:16777216 )   using namespace std;   int n, a, b, c, ans = 0;   int main() {     cin >> n >> a >> b >> c;     for (int i = 0; i <= a; i += 2)       for (int j = 0; j < (int)(b + 1); j++) {         int k = n - (i * 0.5 + j);         if (k < 0) break;         if (!k) {           ans++;           continue;         }         if (k % 2 == 0) {           int l = k / 2;           if (l <= c) ans++;         }       }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 10;   const int M = 1e6 + 10;   const long long INF = 0x3f3f3f3f3f3f3f;   const int inf = 0x3f3f3f;   const double esp = 1e-6;   long long read() {     long long x = 0;     long long k = 1;     char c = getchar();     while (c <  0  || c >  9 ) {       if (c ==  - ) k = -1;       c = getchar();     }     while (c >=  0  && c <=  9 ) {       x = x * 10 + (c -  0 );       c = getchar();     }     return x * k;   }   int n;   int a[N];   int main() {     int t;     cin >> t;     while (t--) {       int a, b;       cin >> a >> b;       if (a == 1) {         if (b <= 1) {           cout <<  YES  << endl;         } else           cout <<  NO  << endl;       } else if (a == 2) {         if (b <= 3) {           cout <<  YES  << endl;         } else           cout <<  NO  << endl;       } else if (a == 3) {         if (b <= 3) {           cout <<  YES  << endl;         } else           cout <<  NO  << endl;       } else         cout <<  YES  << endl;     }   }