malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N = 200 + 10;   int main() {     int n, arr[N];     char f;     char ch[N];     scanf( %d , &n);     cin >> ch;     n = 2 * n;     for (int i = 0; i < n; i++) arr[i] = ch[i] -  0 ;     sort(arr, arr + n / 2);     sort(arr + n / 2, arr + n);     bool a = false, b = false;     for (int i = 0; i < n / 2; i++) {       if (arr[i] >= arr[n / 2 + i]) a = true;       if (arr[i] <= arr[n / 2 + i]) b = true;     }     if (a && b)       cout <<  NO ;     else       cout <<  YES ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     long long int i, j, a, b, ans;     for (i = 1; i <= t; i++) {       cin >> a >> b;       ans = 0;       while ((a + b + ans * (ans + 1) / 2) % 2 != 0 ||              (a + b + ans * (ans + 1) / 2) < 2 * max(a, b)) {         ans++;       }       cout << ans << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   struct point {     long long x, a;   } p[100];   int n;   long long key[100][100];   long long k[100];   long long s[3], ans;   long long v;   void getb(long long ab, long long b, int cur) {     if (ab < b * b) return;     if (cur > n + 1) return;     if (cur == n + 1) {       long long a = ab / b;       long long c = v / ab;       long long tmp = a * c + ab + b * c;       if (tmp < ans) {         ans = tmp;         s[0] = a, s[1] = b, s[2] = c;       }       return;     }     int t = p[cur].a - k[cur];     for (int i = t; i >= 0; i--) {       getb(ab, b * key[cur][i], cur + 1);     }   }   void dfs(long long c, int cur) {     if (v / c < c * c || cur > n + 1) return;     if (cur == n + 1) {       long long ab = v / c;       if (ab + 2 * sqrt(1.0 * v * c) <= ans) {         getb(ab, 1, 1);       }       return;     }     for (int i = p[cur].a; i >= 0; i--) {       k[cur] = i;       dfs(c * key[cur][i], cur + 1);     }   }   int main() {     int cas;     long long suma, sumb;     scanf( %d , &cas);     while (cas--) {       scanf( %d , &n);       v = 1;       for (int i = 1; i <= n; i++) {         cin >> p[i].x >> p[i].a;         long long t = 1;         key[i][0] = 1;         for (int j = 1; j <= p[i].a; j++) {           t *= p[i].x;           key[i][j] = t;         }         v *= t;       }       ans = 2 * v + 1;       s[0] = v, s[1] = s[2] = 1;       dfs(1, 1);       ans *= 2;       cout << ans <<     << s[0] <<     << s[1] <<     << s[2] << endl;     }     return 0;   }
#include <bits/stdc++.h>   #include <stdio.h>   using namespace std;      #define all(v) v.begin(), v.end()   #define eb emplace_back   #define ll long long      const int N = 2e5 + 5;      const int inf = 1e9 + 7;      ll t[4 * N];   ll z[4 * N];   ll a[N];   bool modify[4 * N];      void push(int tl, int tr, int v) {       if (modify[v]) {           t[v] += z[v];           if (tl != tr) {               modify[v + v + 1] = modify[v + v + 2] = 1;               z[v + v + 1] += z[v];               z[v + v + 2] += z[v];           }           modify[v] = 0;           z[v] = 0;       }   }      void build(int tl, int tr, int v) {       if (tl == tr) {           t[v] = a[tl];       } else {           int tm = (tl + tr) >> 1;           build(tl, tm, v + v + 1);           build(tm + 1, tr, v + v + 2);           t[v] = min(t[v + v + 1], t[v + v + 2]);       }   }      ll query(int ql, int qr, int tl, int tr, int v) {       if (ql > tr || qr < tl) {           return inf;       }       push(tl, tr, v);       if (ql <= tl && tr <= qr) {           return t[v];       }       int tm = (tl + tr) >> 1;       return min(                  query(ql, qr, tl, tm, v + v + 1),                  query(ql, qr, tm + 1, tr, v + v + 2));   }      void update(int ql, int qr, int val, int tl, int tr, int v) {       push(tl, tr, v);       if (ql > tr || qr < tl) {           return;       }       if (ql <= tl && tr <= qr) {           z[v] += val;           modify[v] = 1;           push(tl, tr, v);       } else {           int tm = (tl + tr) >> 1;           update(ql, qr, val, tl, tm, v + v + 1);           update(ql, qr, val, tm + 1, tr, v + v + 2);           t[v] = min(t[v + v + 1], t[v + v + 2]);       }   }      void solve() {       int n;       cin >> n;       int answer = 0;       vector<pair<int, int>> neg;       for(int i = 0; i < n; i += 1) {           int x;           cin >> x;           if (x < 0) {               neg.emplace_back(x, i);           }           if (i)               a[i] = a[i - 1];           if (x >= 0) {               a[i] += x;               answer += 1;           }       }       build(0, n - 1, 0);       sort(all(neg));       reverse(all(neg));      //    for(int i = 0; i < n; i += 1) {   //        cout << query(i, i, 0, n - 1, 0) <<    ;   //    }   //    cout << endl;       for(auto [val, id] : neg) {           update(id, n - 1, val, 0, n - 1, 0);           if (query(0, n - 1, 0, n - 1, 0) >= 0) {               answer += 1;   //            cout <<  id =   << id << endl;   //            for(int i = 0; i < n; i += 1) {   //                cout << query(i, i, 0, n - 1, 0) <<    ;   //            }   //            cout << endl;           } else {               update(id, n - 1, -val, 0, n - 1, 0);           }       }       cout << answer << endl;   }      int main() {       ios_base::sync_with_stdio(false);       cin.tie(0);       cout.tie(0);   //    freopen( taskA.in ,  r , stdin);   //    freopen( taskA.out ,  w , stdout);       int t = 1;   //    cin >> t;       while(t--) {           solve();       }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   int cnt[300007];   int main() {     int n, k;     scanf( %d%d , &n, &k);     string s;     cin >> s;     int check = 100;     for (int i = (0); i <= ((int)s.size() - 1); ++i) ++cnt[s[i] -  a ];     for (int i = ( a ); i <= ( z ); ++i) {       if (k >= cnt[i -  a ])         k -= cnt[i -  a ];       else {         cnt[i -  a ] -= k;         check = i -  a ;         break;       }     }     string str =   ;     for (int i = (0); i <= ((int)s.size() - 1); ++i) {       if (s[i] -  a  < check) continue;       if (s[i] -  a  == check) {         if (k) {           --k;           continue;         }       }       str += s[i];     }     cout << str << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string num;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> num;     for (int i = 0; i < num.length(); i++) {       cout << num[i];     }     for (int i = num.length() - 1; i >= 0; i--) {       cout << num[i];     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double pi = acos(-1.0);   const double eps = 1e-7;   const long long MOD = 1000000007LL;   const int INF = 0x3f3f3f3f;   const int _NAN = -0x3f3f3f3f;   const double EULC = 0.5772156649015328;   const int NIL = -1;   template <typename T>   void read(T &x) {     x = 0;     char ch = getchar();     long long f = 1;     while (!isdigit(ch)) {       if (ch ==  - ) f *= -1;       ch = getchar();     }     while (isdigit(ch)) {       x = x * 10 + ch - 48;       ch = getchar();     }     x *= f;   }   const int maxn = 1e7 + 10;   bool isprime[maxn] = {1, 1};   int prime[maxn], kase;   vector<long long> ve;   long long ls[12] = {0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024};   int ans;   void primeMaker() {     for (int i = 2; i < maxn; ++i) {       if (!isprime[i]) prime[kase++] = i;       for (int j = 0; j < kase && prime[j] * i < maxn; ++j) {         isprime[i * prime[j]] = true;         if (!(i % prime[j])) break;       }     }   }   int solve(long long &n) {     long long t2 = n;     int __max = -1;     for (int i = 0; i < kase && prime[i] <= t2; ++i) {       if (!(t2 % prime[i])) {         int cnt = 0;         while (!(t2 % prime[i])) {           ++cnt;           t2 /= prime[i];         }         if (__max != -1 && __max != cnt) ++ans;         __max = max(__max, cnt);         ve.push_back(prime[i]);       }     }     if (ans) ans = 1;     if (__max == -1) __max = 1;     for (int i = 0; i < 10; ++i) {       if (__max == ls[i]) break;       if (__max > ls[i] && __max < ls[i + 1]) {         __max = ls[i + 1];         if (ans != 1) ++ans;         break;       }     }     n = 1;     if (!ve.empty()) {       for (auto num : ve) n *= num;     }     return __max;   }   int main(void) {     primeMaker();     long long n;     while (~scanf( %lld , &n)) {       ans = 0;       if (!isprime[n]) {         printf( %lld %d n , n, 0);         continue;       }       int res = solve(n);       ans += log2l(res) + eps;       printf( %lld %d n , n, ans);       ve.clear();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> g[100005];   int par[18][100005];   int depth[100005];   void dfs(int u, int p = 0, int d = 0) {     par[0][u] = p;     depth[u] = d;     for (int i = 0; i < g[u].size(); i++) {       int v = g[u][i];       if (v == p) continue;       dfs(v, u, d + 1);     }   }   int LCA(int a, int b) {     if (depth[a] < depth[b]) swap(a, b);     int diff = depth[a] - depth[b];     for (int i = 17; i >= 0; i--)       if ((diff >> i) & 1) a = par[i][a];     if (a == b) return a;     for (int i = 17; i >= 0; i--) {       if (par[i][a] != par[i][b]) a = par[i][a], b = par[i][b];     }     return par[0][a];   }   int dist(int a, int b) {     int lca = LCA(a, b);     return depth[a] + depth[b] - 2 * depth[lca];   }   int main() {     int n, q, p;     scanf( %d%d , &n, &q);     for (int i = 2; i <= n; i++)       scanf( %d , &p), g[i].push_back(p), g[p].push_back(i);     dfs(1);     for (int j = 1; j <= 17; j++)       for (int i = 1; i <= n; i++)         if (par[j - 1][i] != 0) par[j][i] = par[j - 1][par[j - 1][i]];     while (q--) {       int a[3];       scanf( %d%d%d , &a[0], &a[1], &a[2]);       int ans = -1;       for (int i = 0; i < 3; i++) {         for (int j = 0; j < 3; j++) {           for (int k = 0; k < 3; k++) {             if (i == j || i == k || j == k) continue;             int s = a[i], t = a[j], f = a[k];             ans = max(ans, (dist(s, f) + dist(t, f) - dist(s, t) + 1) / 2);           }         }       }       printf( %d n , ans + 1);     }   }
#include <bits/stdc++.h>   using namespace std;   bool is_integer(long double k) { return std::floor(k) == k; }   int main() {     long long i, j = 0;     string s;     cin >> s;     if (s.length() == 1 && s[0] ==  0 ) {       cout << 0;       return 0;     }     int c = 0;     for (i = (s.length() - 1); i >= 0; i--) {       if (s[i] ==  1 ) {         c++;       }     }     if (c == 1) {       cout << floor(s.length() / 2.0);     } else {       cout << ceil(s.length() / 2.0);     }   }
#include <bits/stdc++.h>   using namespace std;   using tint = tuple<int, int, int>;   const int maxn = 200004;   int N, M;   tint a[maxn];   struct dsu {     dsu() { iota(p, p + maxn, 0); }     int p[maxn], add[maxn];     int root(int k) { return p[k] != k ? p[k] = root(p[k]) : k; }     bool connect(int x, int y) {       x = root(x);       y = root(y);       if (x == y) return false;       p[y] = x;       add[x] |= add[y];       return true;     }   } d;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> N >> M;     for (int i = 0; i < M; i++) {       int x, y, w;       cin >> x >> y >> w;       a[i] = tint(x, y, w);     }     sort(a, a + M, [](tint x, tint y) { return get<2>(x) > get<2>(y); });     int ans = 0;     for (int i = 0; i < M; i++) {       int x, y, w;       tie(x, y, w) = a[i];       if (d.root(x) != d.root(y) and not(d.add[d.root(x)] and d.add[d.root(y)])) {         ans += w;         d.connect(x, y);       } else if (!d.add[d.root(x)]) {         ans += w;         d.add[d.root(x)] = true;       }     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 3e6 + 7;   const int mod = 1e9 + 7;   long long int dp[maxn] = {0};   int main() {     int t;     cin >> t;     dp[1] = 0;     dp[2] = 0;     dp[3] = 1;     for (int i = 4; i < maxn; i++) {       dp[i] = 2 * dp[i - 2] + dp[i - 1];       if (i % 3 == 0) dp[i]++;       dp[i] %= mod;     }     while (t--) {       int n;       cin >> n;       cout << (dp[n] * 4 + mod) % mod << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 200010;   const int MOD = 1e9 + 7;   int read() {     int x = 0, ch;     while (isspace(ch = getchar()))       ;     do x = x * 10 + ch -  0 ;     while (isdigit(ch = getchar()));     return x;   }   int n;   map<int, int> idx, idy;   int nid;   namespace G {   int head[MAXN], nxt[MAXN], to[MAXN], m;   void init() { memset(head, -1, sizeof head); }   void adde(int u, int v) {     to[m] = v, nxt[m] = head[u], head[u] = m++;     to[m] = u, nxt[m] = head[v], head[v] = m++;   }   }  // namespace G   int fpow(int a, int b) {     int c = 1;     while (b) {       if (b & 1) c = int(1LL * c * a % MOD);       a = int(1LL * a * a % MOD);       b >>= 1;     }     return c;   }   int vis[MAXN];   queue<int> q;   int solve(int s) {     using namespace G;     int e = 0, o = 0;     vis[s] = 1, q.push(s);     while (!q.empty()) {       int u = q.front();       q.pop();       ++o;       for (int i = head[u]; ~i; i = nxt[i], ++e)         if (!vis[to[i]]) vis[to[i]] = 1, q.push(to[i]);     }     e >>= 1;     return e == o - 1 ? (fpow(2, o) - 1 + MOD) % MOD : fpow(2, o);   }   int main() {     n = read();     G::init();     for (int i = 0; i < n; ++i) {       int x = read(), y = read();       if (!idx[x]) idx[x] = ++nid;       if (!idy[y]) idy[y] = ++nid;       G::adde(idx[x], idy[y]);     }     int ans = 1;     for (int i = 1; i <= nid; ++i)       if (!vis[i]) ans = int(1LL * ans * solve(i) % MOD);     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = ~0u >> 2;   const int N = 500010;   int Max[N << 2];   struct node {     int x, y, z;   } in[N];   int tot, n;   int num[N];   int max(int a, int b) { return a > b ? a : b; }   void pushup(int rt) { Max[rt] = max(Max[rt << 1], Max[rt << 1 | 1]); }   void build(int l, int r, int rt) {     Max[rt] = 0;     if (l == r) return;     int m = (l + r) >> 1;     build(l, m, rt << 1);     build(m + 1, r, rt << 1 | 1);   }   void update(int p, int val, int l, int r, int rt) {     if (l == r) {       if (val > Max[rt]) Max[rt] = val;       return;     }     int m = (l + r) >> 1;     if (p <= m)       update(p, val, l, m, rt << 1);     else       update(p, val, m + 1, r, rt << 1 | 1);     pushup(rt);   }   int query(int L, int R, int l, int r, int rt) {     if (L <= l && r <= R) return Max[rt];     int m = (l + r) >> 1;     int ret = 0;     if (L <= m) ret = max(ret, query(L, R, l, m, rt << 1));     if (R > m) ret = max(ret, query(L, R, m + 1, r, rt << 1 | 1));     return ret;   }   void init() {     sort(num + 1, num + n + 1);     tot = unique(num + 1, num + n + 1) - num - 1;     build(1, tot, 1);     for (int i = 1; i <= n; i++)       in[i].x = lower_bound(num + 1, num + 1 + tot, in[i].x) - num;   }   inline int cmp(node a, node b) { return a.y > b.y; }   int main() {     int i, j, k;     scanf( %d , &n);     for (i = 1; i <= n; i++) {       scanf( %d , &in[i].x);       num[i] = in[i].x;     }     for (i = 1; i <= n; i++) scanf( %d , &in[i].y);     for (i = 1; i <= n; i++) scanf( %d , &in[i].z);     init();     sort(in + 1, in + n + 1, cmp);     int ans = 0;     for (i = 1; i <= n; i = j) {       for (j = i; j <= n && in[j].y == in[i].y; j++) {         int z;         z = query(in[j].x + 1, tot, 1, tot, 1);         if (z > in[j].z) ans++;       }       for (; i <= j - 1; i++) {         update(in[i].x, in[i].z, 1, tot, 1);       }     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a[] = {0,   1,  1, 1, 2,  1, 2,  1, 5,  2, 2,  1, 5,  1, 2, 1,                14,  1,  5, 1, 5,  2, 2,  1, 15, 2, 2,  5, 4,  1, 4, 1,                51,  1,  2, 1, 14, 1, 2,  2, 14, 1, 6,  1, 4,  2, 2, 1,                52,  2,  5, 1, 5,  1, 15, 2, 13, 2, 2,  1, 13, 1, 2, 4,                267, 1,  4, 1, 5,  1, 4,  1, 50, 1, 2,  3, 4,  1, 6, 1,                52,  15, 2, 1, 15, 1, 2,  1, 12, 1, 10, 1, 4,  2},         n;     cin >> n;     cout << a[n];   }
#include <bits/stdc++.h>   namespace chtholly {   char buf[1 << 23], *p1 = buf, *p2 = buf;   inline int read() {     int x = 0, f = 1;     char c = getchar();     for (; !isdigit(c); c = getchar()) f ^= c ==  - ;     for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^  0 );     return f ? x : -x;   }   template <typename mitsuha>   inline bool read(mitsuha &x) {     x = 0;     int f = 1;     char c = getchar();     for (; !isdigit(c) && ~c; c = getchar()) f ^= c ==  - ;     if (!~c) return 0;     for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^  0 );     return x = f ? x : -x, 1;   }   template <typename mitsuha>   inline int write(mitsuha x) {     if (!x) return 0 & putchar(48);     if (x < 0) putchar( - ), x = -x;     int bit[20], i, p = 0;     for (; x; x /= 10) bit[++p] = x % 10;     for (i = p; i; --i) putchar(bit[i] + 48);     return 0;   }   inline char fuhao() {     char c = getchar();     for (; isspace(c); c = getchar())       ;     return c;   }   }  // namespace chtholly   using namespace chtholly;   using namespace std;   const int yuzu = 1e5;   typedef long long fuko[yuzu | 10];   fuko a, b, c, d;   int n, k;   typedef long long karen[yuzu << 2 | 13];   struct segtree {     karen val;     void build(int rt = 1, int l = 1, int r = n) {       if (l == r)         val[rt] = read() % k;       else {         int mid = l + r >> 1;         build(rt << 1, l, mid), build(rt << 1 | 1, mid + 1, r);         val[rt] = val[rt << 1] * val[rt << 1 | 1] % k;       }     }     long long query(int ql, int qr, int rt = 1, int l = 1, int r = n) {       if (ql > r || qr < l) return 1;       if (ql <= l && qr >= r) return val[rt];       int mid = l + r >> 1;       return query(ql, qr, rt << 1, l, mid) *              query(ql, qr, rt << 1 | 1, mid + 1, r) % k;     }   } my;   int main() {     read(n), read(k), my.build();     int i, l = 1, r = 1;     long long llx = 0;     for (; r <= n; llx += n - r + 1, ++l, r = max(l, r))       for (; r <= n && my.query(l, r); ++r)         ;     write(llx);   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1e17;   const long long maxn = 2e5 + 700;   const int mod = 1e9 + 7;   template <typename T>   inline void read(T &a) {     char c = getchar();     T x = 0, f = 1;     while (!isdigit(c)) {       if (c ==  - ) f = -1;       c = getchar();     }     while (isdigit(c)) {       x = (x << 1) + (x << 3) + c -  0 ;       c = getchar();     }     a = f * x;   }   long long n, m, p;   char s[maxn];   int a[maxn], b[maxn];   int digit(long long x, int *d) {     int ans = 0;     while (x) {       d[++ans] = x % 10;       x /= 10;     }     return ans;   }   int path[maxn];   int check(int pos, int lbound, int rbound) {     if (!pos) return 1;     if (!lbound && !rbound) return 1;     int l = lbound ? a[pos] : 0;     int r = rbound ? b[pos] : 9;     for (int i = l; i <= r; i++) {       if (path[i] > 0) {         path[i]--;         if (check(pos - 1, lbound && i == l, rbound && i == r)) {           path[i]++;           return 1;         }         path[i]++;       }     }     return 0;   }   int pos, res = 0;   void dfs(int u, int w) {     if (u == 9) {       path[u] = w;       if (check(pos, 1, 1)) res++;       return;     }     for (int i = 0; i <= w; i++) {       path[u] = i;       dfs(u + 1, w - i);     }   }   int main() {     read(n);     read(m);     digit(n, a);     pos = digit(m, b);     dfs(0, pos);     printf( %d n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int q[3001], t, n;   int main() {     scanf( %d , &n);     for (int i = 2; i <= n; i++) {       if (q[i - 1] == 2) t++;       if (q[i] > 0) continue;       for (int j = i; j <= n; j += i) q[j]++;     }     if (q[n] == 2) t++;     printf( %d n , t);   }
#include <bits/stdc++.h>   using namespace std;   long long n, x;   vector<string> ans;   long long dec(string s) {     long long ret = 0;     for (long long i = 0; i < s.size(); i++) {       ret = ret * 10 + s[i] - 48;     }     return ret;   }   void add(long long v) {     long long rs = 0;     if (ans.size() == 0) {       string tmp =   ;       while (v > 9) {         tmp =  9  + tmp;         v -= 9;       }       tmp = to_string(v) + tmp;       ans.push_back(tmp);     } else {       string p_s = ans[ans.size() - 1], req = p_s;       long long cnt = 0;       for (long long i = 0; i < req.size(); i++) {         cnt += req[i] - 48;       }       if (cnt < v) {         long long df = v - cnt;         for (long long i = req.size() - 1; i >= 0; i--) {           if (req[i] <  9  && df) {             long long dy =  9  - req[i];             req[i] += min(df, dy);             df -= min(df, dy);             if (!df) {               ans.push_back(req);               return;             }           }         }         while (df >= 9) {           req =  9  + req;           df -= 9;         }         if (v) req = to_string(df) + req;         ans.push_back(req);       } else {         string p_s = ans[ans.size() - 1];         long long idx = -1, sm = 0, tmp_sm = 0;         for (long long i = 0; i < p_s.size(); i++) {           tmp_sm += p_s[i] - 48;           if (v > tmp_sm && p_s[i] <  9 ) {             idx = i;             sm = tmp_sm;           } else if (v < sm)             break;         }         if (idx == -1) {           string p_s =  1 ;           long long sz = ans[ans.size() - 1].size();           for (long long i = 0; i < sz; i++) p_s = p_s +  0 ;           v -= 1;           long long idx = p_s.size() - 1;           while (idx > 0 && v > 0) {             char c = (char)min((long long) 9 , v + 48);             p_s[idx] = c;             idx--, v -= 9;           }           ans.push_back(p_s);         } else {           sm = v - sm - 1;           p_s[idx] += 1;           for (long long j = idx + 1; j < p_s.size(); j++) {             p_s[j] =  0 ;           }           for (long long i = p_s.size() - 1; i > idx; i--) {             if (sm > 0) {               long long dx =  9  - p_s[i];               p_s[i] += min(sm, dx);               sm -= min(sm, dx);             } else               break;           }           ans.push_back(p_s);         }       }     }   }   int main() {     cin >> n;     for (long long i = 0; i < n; i++) {       cin >> x;       add(x);     }     for (long long i = 0; i < ans.size(); i++) cout << ans[i] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int N;     scanf( %d , &N);     if (N == 1) {       puts( 1 );       return 0;     }     int s = 0;     for (int i = 0; i < N; ++i) {       int t;       scanf( %d , &t);       s += t;     }     printf( %d n , s % N == 0 ? N : N - 1);   }
#include <bits/stdc++.h>   using namespace std;   const double PI = acos(-1.0);   #pragma GCC diagnostic ignored  -Wsign-compare    int main() {     int n, ind = 0;     scanf( %d , &n);     vector<long long> vals(n);     vector<long long> pref(n);     for (int i = 0; i < n; i++) {       scanf( %d , &vals[i]);     }     42;     partial_sum(vals.begin(), vals.end(), pref.begin());     vals.insert(vals.begin(), 0);     pref.insert(pref.begin(), 0);     vector<double> hull(n);     vector<pair<int, int> > inds(n);     for (int i = 1; i <= n; i++) {       double cur = vals[i];       pair<int, int> use = make_pair(i, i);       while (ind > 0 and hull[ind - 1] > cur) {         ind--;         cur = ((double)pref[i] - pref[inds[ind].first - 1]) /               ((double)i - inds[ind].first + (double)1.000000);         use = make_pair(inds[ind].first, i);       }       hull[ind] = cur;       inds[ind] = use;       ind++;     }     42;     for (int i = 0; i < ind; i++) {       for (int j = inds[i].first; j <= inds[i].second; j++) {         printf( %.10f n , hull[i]);       }     }     return 0;   }