malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const long long int mod = 1000000007;   int main() {     ios::sync_with_stdio(0);     int n;     cin >> n;     long long int a[10000], sum[10000], all[10000], m[10000];     memset(all, 0, sizeof(all));     for (int i = 2; i < pow(2, n + 1); i++) {       cin >> a[i];     }     m[1] = sum[1] = 0;     for (int i = 2; i < pow(2, n + 1); i++) {       m[i] = sum[i] = sum[i / 2] + a[i];     }     long long int fin[10000];     fin[1] = sum[(int)pow(2, n)];     for (int i = pow(2, n); i < pow(2, n + 1); i++) {       fin[1] = max(fin[1], sum[i]);     }     for (int i = pow(2, n) - 1; i >= 1; i--) {       m[i] = max(m[2 * i], m[2 * i + 1]);     }     long long int ans = 0;     for (int i = 1; i < pow(2, n); i++) {       all[2 * i] = all[2 * i + 1] = all[i];       if (m[2 * i] + all[i] < fin[1]) {         ans += (fin[1] - all[i] - m[2 * i]);         all[2 * i] = all[i] + fin[1] - all[i] - m[2 * i];       }       if (m[2 * i + 1] + all[i] < fin[1]) {         ans += (fin[1] - all[i] - m[2 * i + 1]);         all[2 * i + 1] = all[i] + fin[1] - all[i] - m[2 * i + 1];       }       cerr <<  i             <<  :   << i <<   |              <<  ans             <<  :   << ans << endl;       ;     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   char grid[512][512];   bool used[512][512];   int n, m;   struct op {     char type;     int x, y;     op() {}     op(char c, int a, int b) {       type = c;       x = a;       y = b;     }   };   vector<op> res;   int dx[4] = {0, -1, 0, 1};   int dy[4] = {1, 0, -1, 0};   void go(int x, int y, int level) {     if (x < 1 || x > n || y > m || y < 1) return;     if (used[x][y]) return;     used[x][y] = 1;     for (int i = 0; i < 4; i++) {       go(x + dx[i], y + dy[i], level + 1);     }     if (level) {       res.push_back(op( D , x, y));       res.push_back(op( R , x, y));     }   }   int main() {     cin >> n >> m;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) cin >> grid[i][j];     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) {         if (grid[i][j] ==  . )           res.push_back(op( B , i, j));         else           used[i][j] = 1;       }     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) {         if (!used[i][j]) {           go(i, j, 0);         }       }     int k = res.size();     cout << k << endl;     for (int i = 0; i < k; i++) {       cout << res[i].type <<     << res[i].x <<     << res[i].y << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, a[1005];   int main() {     scanf( %I64d , &n);     for (int i = 1; i <= n; i++) scanf( %I64d , &a[i]);     sort(a + 1, a + n + 1);     long long ans = 0;     for (int i = 2; i <= n; i++) ans += a[i] - a[i - 1] - 1;     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int a[n];     bool f = false;     for (int x = 0; x < n; x++) {       cin >> a[x];       if (a[x] == 1) f = true;     }     if (f) {       cout << -1;     } else       cout << 1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxN = 50 + 10;   long long dp[maxN];   int used[maxN];   int main() {     int n;     long long l;     cin >> n >> l;     dp[0] = 1;     dp[1] = 1;     for (int i = 2; i < maxN; i++) dp[i] = dp[i - 1] + dp[i - 2];     l--;     for (int i = 0; i < n; i++) {       int k = n - i;       if (dp[k - 1] > l)         cout << i + 1 <<    ;       else {         l -= dp[k - 1];         cout << i + 2 <<     << i + 1 <<    ;         i++;       }     }   }
#include <bits/stdc++.h>   using namespace std;   void Emsawy() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);   }   const double PI = acos(-1.0);   const double eps = 1e-10;   const long long mod = 1e9 + 7, oo = 1e9;   int dx[]{1, -1, 0, 0, 1, -1, 1, -1};   int dy[]{0, 0, 1, -1, 1, -1, -1, 1};   vector<vector<pair<int, int> > > adj;   int n, m, k, t;   const int N = 4001;   int L[N], R[N];   long dp[89][2002][89 * 2 + 10];   long go(int l, int r, int k) {     long &ret = dp[k][l][n - r - l + 89];     if (ret != -oo) return ret;     if (l <= (n - r)) {       ret = -oo;       if (r - l > k) ret = max(ret, go(l + k, r, k) - L[l] + L[l + k]);       if (r - l > k + 1)         ret = max(ret, go(l + k + 1, r, k + 1) - L[l] + L[l + k + 1]);       return (ret == -oo ? ret = 0 : ret);     }     ret = oo;     if (r - l > k) ret = min(ret, go(l, r - k, k) - (-R[r] + R[r - k]));     if (r - l > k + 1)       ret = min(ret, go(l, r - k - 1, k + 1) - (-R[r] + R[r - k - 1]));     return (ret == oo ? ret = 0 : ret);   }   int main() {     Emsawy();     while (cin >> n) {       for (int i = 1; i <= n; i++) {         cin >> L[i];         R[i] = L[i];         L[i] += L[i - 1];       }       for (int i = n - 1; i >= 1; i--) R[i] += R[i + 1];       for (int i = 0; i < 89; i++) {         for (int j = 0; j < 2002; j++) {           for (int g = 0; g < 89 * 2 + 10; g++) {             dp[i][j][g] = -oo;           }         }       }       n += 1;       cout << go(0, n, 1) << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int nod, edge;   int a[401][401];   int dist[401];   int vis[401];   int bfs(int node) {     queue<int> q;     q.push(node);     vis[node] = 1;     while (q.size()) {       int cur = q.front();       q.pop();       if (cur == nod) return dist[cur];       for (int i = nod; i >= 1; i--) {         if (!vis[i] and (a[cur][i] + a[i][cur])) {           dist[i] += dist[cur] + 1, q.push(i);           vis[i] = 1;         }       }     }     return 0;   }   int bfs1(int node) {     memset(dist, 0, sizeof dist);     memset(vis, 0, sizeof vis);     queue<int> q;     q.push(node);     vis[node] = 1;     while (q.size()) {       int cur = q.front();       q.pop();       if (cur == nod) return dist[cur];       for (int i = nod; i >= 1; i--) {         if (!vis[i] and !(a[cur][i] + a[i][cur])) {           dist[i] += dist[cur] + 1, q.push(i);           vis[i] = 1;         }       }     }     return 0;   }   int main() {     cin >> nod >> edge;     int x, y;     while (edge--) {       cin >> x >> y;       a[x][y] = 1;       a[y][x] = 1;     }     int ans = bfs(1);     int ans2 = bfs1(1);     if (ans != 0 and ans2 != 0)       cout << max(ans, ans2);     else       cout << -1;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int f = 0;     int a[502] = {0,   1,   3,   6,   10,  15,  21,  28,  36,  45,  55,                   66,  78,  91,  105, 120, 136, 153, 171, 190, 210, 231,                   253, 276, 300, 325, 351, 378, 406, 435, 465, 496};     for (int i = 0; i < 32; i++) {       if (a[i] == n) {         cout <<  YES ;         f = 1;       }     }     if (f == 0) cout <<  NO ;   }
#include <bits/stdc++.h>   using namespace std;   struct point {     int x, y;     int det(point p) { return x * p.y - y * p.x; }   };   point a[10], b[10];   int GetCross(point p1, point p2, point p) {     return (p2.x - p1.x) * (p.y - p1.y) - (p.x - p1.x) * (p2.y - p1.y);   }   bool check(point p) {     return GetCross(b[1], b[2], p) * GetCross(b[3], b[4], p) >= 0 &&            GetCross(b[2], b[3], p) * GetCross(b[4], b[1], p) >= 0;   }   int main() {     for (int i = 1; i <= 4; i++) {       scanf( %d%d , &a[i].x, &a[i].y);     }     for (int i = 1; i <= 4; i++) {       scanf( %d%d , &b[i].x, &b[i].y);     }     int mix = min(min(min(a[1].x, a[2].x), a[3].x), a[4].x);     int mxx = max(max(max(a[1].x, a[2].x), a[3].x), a[4].x);     int miy = min(min(min(a[1].y, a[2].y), a[3].y), a[4].y);     int mxy = max(max(max(a[1].y, a[2].y), a[3].y), a[4].y);     for (int i = mix; i <= mxx; i++) {       for (int j = miy; j <= mxy; j++) {         point pi;         pi.x = i;         pi.y = j;         if (check(pi)) {           printf( YES n );           return 0;         }       }     }     printf( NO n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100005;   const int sqrtn = 505;   int l = 1, r, sum, cant;   int n, m, p, s[maxn], w[maxn], cnt[maxn], last[maxn], pre[maxn], nxt[maxn],       qwq[maxn][sqrtn], num[maxn];   vector<int> v;   struct node {     int l, r, id;   } a[maxn];   inline bool cmp(node a, node b) {     return a.l / p == b.l / p ? ((a.l / p) & 1 ? a.r < b.r : a.r > b.r)                               : a.l < b.l;   }   inline void add(int x) {     cnt[w[x]]++;     sum += cnt[w[x]] == 1;   }   inline void add_right(int x) {     add(x);     if (cnt[w[x]] != 1 && pre[x]) {       qwq[w[x]][pre[x]]++;       if (qwq[w[x]][pre[x]] == 1) {         num[w[x]]++;         if (num[w[x]] == 2) {           cant++;         }       }     }   }   void add_left(int x) {     add(x);     if (cnt[w[x]] != 1 && nxt[x]) {       qwq[w[x]][nxt[x]]++;       if (qwq[w[x]][nxt[x]] == 1) {         num[w[x]]++;         if (num[w[x]] == 2) {           cant++;         }       }     }   }   inline void del(int x) {     cnt[w[x]]--;     sum -= cnt[w[x]] == 0;   }   inline void del_right(int x) {     del(x);     if (qwq[w[x]][pre[x]] && pre[x]) {       qwq[w[x]][pre[x]]--;       if (qwq[w[x]][pre[x]] == 0) {         num[w[x]]--;         if (num[w[x]] == 1) {           cant--;         }       }     }   }   inline void del_left(int x) {     del(x);     if (qwq[w[x]][nxt[x]] && nxt[x]) {       qwq[w[x]][nxt[x]]--;       if (qwq[w[x]][nxt[x]] == 0) {         num[w[x]]--;         if (num[w[x]] == 1) {           cant--;         }       }     }   }   signed main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> w[i];       if (last[w[i]]) {         pre[i] = i - last[w[i]];         nxt[last[w[i]]] = i - last[w[i]];         v.push_back(pre[i]);         v.push_back(nxt[last[w[i]]]);       }       last[w[i]] = i;     }     sort(v.begin(), v.end());     v.erase(unique(v.begin(), v.end()), v.end());     for (int i = 1; i <= n; i++) {     }     p = sqrt(n);     cin >> m;     for (int i = 1; i <= m; i++) {       cin >> a[i].l >> a[i].r;       a[i].id = i;     }     sort(a + 1, a + m + 1, cmp);     for (int i = 1; i <= m; i++) {       while (l > a[i].l) {         add_left(--l);       }       while (r < a[i].r) {         add_right(++r);       }       while (l < a[i].l) {         del_left(l++);       }       while (r > a[i].r) {         del_right(r--);       }       s[a[i].id] = sum + (cant == sum);     }     for (int i = 1; i <= m; i++) {       cout << s[i] <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   bool isprime(int n) {     for (int i = 2; i < n; i++) {       if (n % i == 0) {         return false;       }     }     return true;   }   int main() {     int n;     cin >> n;     string s;     cin >> s;     int diff = 1;     int i = 0;     while (i < n) {       cout << s[i];       i = i + diff;       diff++;     }   }
#include <bits/stdc++.h>   using namespace std;   vector<pair<char, pair<int, int> > > closest(10,                                                make_pair( * , make_pair(0, 0)));   int n, X, Y;   int check_dir(int x, int y) {     if (x == X && y > Y) return 1;     if (x == X && y < Y) return 5;     if (Y == y && x > X) return 3;     if (Y == y && x < X) return 7;     if (X < x && (x - X) == (y - Y)) return 2;     if (X > x && (x - X) == (y - Y)) return 6;     if (y > Y && (X - x) == (y - Y)) return 4;     if (y < Y && (X - x) == (y - Y)) return 8;     return 0;   }   int dist(int x, int y, int xx, int yy) { return max(abs(xx - x), abs(yy - y)); }   void get_closest(char z, int x, int y, int dir) {     if (closest[dir].first ==  *  ||         dist(X, Y, x, y) <             dist(X, Y, closest[dir].second.first, closest[dir].second.second)) {       closest[dir].first = z;       closest[dir].second = make_pair(x, y);     }   }   int main() {     scanf( %d%d%d , &n, &X, &Y);     for (int i = 0; i < n; ++i) {       char z;       int x, y;       cin >> z >> x >> y;       int dir = check_dir(x, y);       if (dir) {         get_closest(z, x, y, dir);       }     }     bool flag = false;     for (int i = 1; i <= 7; i += 2) {       if (closest[i].first ==  R  || closest[i].first ==  Q ) flag = true;     }     for (int i = 2; i <= 8; i += 2) {       if (closest[i].first ==  B  || closest[i].first ==  Q ) flag = true;     }     if (flag)       printf( YES );     else       printf( NO );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void c_p_c() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);   }   bool isPrime(long long n) {     if (n <= 1) return false;     if (n <= 3) return true;     if (n % 2 == 0 || n % 3 == 0) return false;     for (long long i = 5; i * i <= n; i += 6) {       if (n % i == 0 || n % (i + 2) == 0) return false;     }     return true;   }   vector<long long> Sieve(long long n) {     bool prime[n + 1];     memset(prime, true, sizeof(prime));     for (long long i = 2; i * i <= n; i++) {       if (prime[i]) {         for (long long j = i * i; j <= n; j += i) {           prime[j] = false;         }       }     }     vector<long long> primes;     for (long long i = 2; i <= n; i++) {       if (prime[i]) primes.push_back(i);     }     return primes;   }   map<long long, long long> primeFactors(long long n) {     map<long long, long long> factors;     while (n % 2 == 0) {       n /= 2;       factors[2]++;     }     for (long long i = 3; i <= sqrt(n); i += 2) {       while (n % i == 0) {         factors[i]++;         n /= i;       }     }     if (n > 2) factors[n]++;     return factors;   }   int32_t main() {     c_p_c();     long long t;     cin >> t;     while (t--) {       long long n;       cin >> n;       vector<long long> arr(n + 1, 0);       long long num;       for (long long i = 0; i < n; i++) {         cin >> num;         arr[num]++;       }       sort(arr.begin(), arr.end(), greater<long long>());       long long ans = arr[0], prev = arr[0];       for (long long i = 1; i <= n; i++) {         if (prev == 0) break;         if (arr[i] >= prev) {           ans += prev - 1;           prev--;         } else {           ans += arr[i];           prev = arr[i];         }       }       cout << ans <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e4 + 5;   int n, a[N], m, k;   long long ans;   int main() {     scanf( %d%d%d , &n, &m, &k);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     if (n % 2 == 0) {       puts( 0 );       return 0;     }     int mn = N * 100;     for (int i = 1; i <= n; i += 2) mn = min(mn, a[i]);     long long ans = min((long long)mn, 1ll * (m / ((n + 1) / 2)) * k);     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string ITS(long long x) {     string s =   ;     while (x > 0) {       s += (char)(x % 10 +  0 );       x /= 10;     }     string t =   ;     for (int i = s.size() - 1; i > -1; i--) t += s[i];     return t;   }   long long inf = 1e9;   long long mod = 1e9 + 7;   const long long M = 2e3;   int main() {     std::ios::sync_with_stdio(false);     long long n, m;     cin >> n >> m;     double a = n * pow(1.000000011, m);     cout << fixed << setprecision(15) << a;   }
#include <bits/stdc++.h>   using namespace std;   long long n = 0, m = 0, q = 0;   long long ans = 0;   vector<vector<int>> G = vector<std::vector<int>>(100001);   vector<long long> f(112345), fa(100001), dep(100001), val(100001), sz(100001),       s(100001);   long long F(long long x) { return x == f[x] ? x : (f[x] = F(f[x])); }   void dfs(long long u, long long ff) {     sz[u] = 1;     dep[u] = dep[ff] + 1;     fa[u] = ff;     for (int i = 0; i < G[u].size(); ++i) {       long long v = G[u][i];       if (v == ff) {         continue;       }       dfs(v, u);       sz[u] += sz[v];       val[u] += sz[v] * sz[v];     }     val[u] += (n - sz[u]) * (n - sz[u]);     ans -= val[u];   }   void merge(int x, int y) {     ans -= s[x] * (s[x] - 1) * (s[x] - 2);     ans -= s[y] * (s[y] - 1) * (s[y] - 2);     ans -= s[x] * (s[x] - 1) * (n - s[x]) * 2;     ans -= s[y] * (s[y] - 1) * (n - s[y]) * 2;     ans -= (n - s[x]) * (n - s[x]) * s[x];     ans -= (n - s[y]) * (n - s[y]) * s[y];     ans += val[x] * s[x];     ans += val[y] * s[y];     val[x] += val[y] - sz[y] * sz[y] - (n - sz[y]) * (n - sz[y]);     s[x] += s[y];     f[y] = x;     ans += s[x] * (s[x] - 1) * (s[x] - 2);     ans += s[x] * (s[x] - 1) * (n - s[x]) * 2;     ans += (n - s[x]) * (n - s[x]) * s[x];     ans -= val[x] * s[x];   }   int main() {     cin >> n;     for (int i = 1; i <= n; ++i) {       G[i] = std::vector<int>();       s[i] = 1;       f[i] = i;     }     for (int i = 0; i < n - 1; ++i) {       int u, v;       cin >> u >> v;       G[u].push_back(v);       G[v].push_back(u);     }     ans = 1LL * n * (n - 1) * (n - 1);     dfs(1, 0);     cout << ans << endl;     cin >> q;     while (q-- > 0) {       int u, v;       cin >> u >> v;       u = F(u);       v = F(v);       while (u != v) {         if (dep[u] < dep[v]) {           int o = v;           v = u;           u = o;         }         merge(F(fa[u]), u);         u = F(u);       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   bool uin(T &a, T b) {     return a > b ? (a = b, true) : false;   }   template <class T>   bool uax(T &a, T b) {     return a < b ? (a = b, true) : false;   }   const long long maxn = 1000001, mod = 1e9 + 7;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     long double a[n], b[n];     for (long long i = 0; i < (long long)(n); ++i) cin >> a[i];     for (long long i = 0; i < (long long)(n); ++i) cin >> b[i];     int ex = 0;     map<long double, int> freq;     for (long long i = 0; i < (long long)(n); ++i) {       if (a[i] == 0 && b[i] == 0) ex++;       if (a[i] == 0) continue;       freq[b[i] / a[i]]++;     }     int ans = 0;     for (auto it : freq) {       ans = max(ans, it.second);     }     cout << ans + ex <<   n ;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   using namespace std;   const int N = 3e5 + 5, M = 1e8 + 5, OO = 1000000;   int T, n, m;   int u, v;   int deg[N];   int main() {     scanf( %d , &n);     for (int i = 1; i < n; ++i) {       scanf( %d %d , &u, &v);       ++deg[u], ++deg[v];     }     for (int i = 1; i <= n; ++i) {       if (deg[i] == 2) {         printf( NO n );         return 0;       }     }     printf( YES n );   }
#include <bits/stdc++.h>   #pragma GCC target( sse )   const int maxn = 2e5 + 5;   struct IO {     char c;     inline char gc() {       static char buf[maxn], *p1 = buf, *p2 = buf;       return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, maxn, stdin), p1 == p2)                  ? EOF                  : *p1++;     }     template <typename T>     inline IO &operator>>(T &_) {       _ = 0;       bool f = 1;       c = gc();       while (c <  0  || c >  9 ) {         if (c ==  - ) f = 0;         c = gc();       }       while (c >=  0  && c <=  9 ) {         _ = _ * 10 + c - 48;         c = gc();       }       if (!f) _ = -_;       return *this;     }     char buf[maxn];     int p = 0;     ~IO() { fwrite(buf, 1, p, stdout); }     inline void pc(const char &c) {       buf[p++] = c;       if (p == maxn) fwrite(buf, 1, maxn, stdout), p = 0;     }     template <typename T>     inline IO &operator<<(T x) {       if (!x) {         pc(48);         pc(  n );         return *this;       }       static int wt[41], len;       len = 0;       if (x < 0) {         pc( - );         x = -x;       }       for (; x; x /= 10) {         wt[++len] = x % 10;       }       while (len) {         pc(wt[len--] + 48);       }       pc(  n );       return *this;     }     inline IO &operator>>(char s[]) {       c = gc();       int len = -1;       while (c ==     || c ==   n  || c ==   r ) c = gc();       while (c !=     && c !=   n  && c !=   r  && c !=   0  && c != EOF) {         s[++len] = c;         c = gc();       }       s[++len] =   0 ;       return *this;     }   } io;   int n, m, q;   char s1[maxn], s2[maxn];   unsigned long long b1[64][(maxn >> 6) + 64], b2[64][(maxn >> 6) + 64];   void build() {     for (int i = 0; i < 64; i++) {       for (int j = i; j < n; j += 64) {         for (int k = 0; k < 64; k++)           b1[i][j >> 6] += (1ll << k) * (s1[j + k] - 48);       }     }     for (int i = 0; i < 64; i++) {       for (int j = i; j < m; j += 64) {         for (int k = 0; k < 64; k++)           b2[i][j >> 6] += (1ll << k) * (s2[j + k] - 48);       }     }   }   int main() {     io >> s1 >> s2;     n = strlen(s1), m = strlen(s2);     build();     io >> q;     while (q--) {       int p1, p2, len;       io >> p1 >> p2 >> len;       int now = 0, a1 = 0, a2 = 0, a3 = 0, a4 = 0, a5 = 0, a6 = 0, a7 = 0, a8 = 0;       unsigned long long *f1 = b1[p1 & 63] + (p1 >> 6),                          *f2 = b2[p2 & 63] + (p2 >> 6);       for (; now + 511 < len; now += 512, f1 += 8, f2 += 8) {         a1 += __builtin_popcountll(f1[0] ^ f2[0]);         a2 += __builtin_popcountll(f1[1] ^ f2[1]);         a3 += __builtin_popcountll(f1[2] ^ f2[2]);         a4 += __builtin_popcountll(f1[3] ^ f2[3]);         a5 += __builtin_popcountll(f1[4] ^ f2[4]);         a6 += __builtin_popcountll(f1[5] ^ f2[5]);         a7 += __builtin_popcountll(f1[6] ^ f2[6]);         a8 += __builtin_popcountll(f1[7] ^ f2[7]);       }       for (; now < len; now++) a1 += (s1[p1 + now] - 48) ^ (s2[p2 + now] - 48);       io << a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long int t;     cin >> t;     while (t--) {       long long int n, i, j, k, sum = 0, ev = 0, ze = 0;       string s;       cin >> s;       n = s.length();       for (i = 0; i < n; i++) {         sum = sum + s[i] -  0 ;         if ((s[i] -  0 ) % 2 == 0) ev++;         if (s[i] -  0  == 0) ze++;       }       if (ze == 0)         cout <<  cyan  << endl;       else {         if (ev < 2)           cout <<  cyan  << endl;         else {           if (sum % 3 == 0)             cout <<  red  << endl;           else             cout <<  cyan  << endl;         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, ans;     cin >> n;     long long a[n];     for (int i = 0; i < n; i++) {       cin >> a[i];     }     ans = a[0];     for (int i = 1; i < n; i++) {       a[i] += ans;       if (a[i] - ans > 0) {         ans = a[i];       }     }     for (int i = 0; i < n; i++) {       cout << a[i] <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   int MOD = 1000000007;   int tree[20000][2];   int main() {     ios::sync_with_stdio(0);     int n, a, b, k;     cin >> n >> a >> b >> k;     for (int i = 1; i <= n; i++) {       if (i != b) tree[i][0]++;     }     int h = 1;     for (int j = 1; j <= k; j++) {       for (int i = 2; i <= n; i++) {         tree[i][1 - h] += tree[i - 1][1 - h];         tree[i][1 - h] %= MOD;       }       for (int i = 1; i <= n; i++) {         if (i == b) continue;         int lim = abs(i - b);         lim--;         tree[i][h] =             tree[min(n, i + lim)][1 - h] - tree[max(1, i - lim) - 1][1 - h];         tree[i][h] += MOD;         tree[i][h] %= MOD;         tree[i][h] -= (tree[i][1 - h] - tree[i - 1][1 - h] + MOD) % MOD;         tree[i][h] += MOD;         tree[i][h] %= MOD;       }       h ^= 1;     }     for (int i = 2; i <= n; i++) {       tree[i][1 - h] += tree[i - 1][1 - h];       tree[i][1 - h] %= MOD;     }     cout << (tree[a][1 - h] - tree[a - 1][1 - h] + MOD) % MOD << endl;     return 0;   }