malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, c, d, sum, mod1, mod, mod2;     cin >> a >> b >> c;     sum = (a + b);     if ((a >= b || a <= b) && (c <= sum)) {       if (c == a) {         cout <<  YES  << endl;       } else if (c == sum) {         cout <<  YES  << endl;       } else {         cout <<  NO  << endl;       }     } else if (c > sum) {       mod = sum % b;       sum = sum + 1;       mod1 = sum % b;       mod2 = c % b;       if (mod2 == mod1 || mod2 == mod) {         cout <<  YES  << endl;       } else {         cout <<  NO  << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k, m;   int arr[1005][105][2], arr1[1005], arr2[1005];   long long dp(int i, int s, int hg) {     if (s == 0 && hg) return ((i != n) ? ((9 * 1LL * arr2[n - i - 1]) % m) : 1);     if (i == n) return 0;     if (arr[i][s][hg] != -1) return arr[i][s][hg];     arr[i][s][hg] = 0;     for (int j = 0; j <= 9; j++) {       arr[i][s][hg] +=           dp(i + 1, (s + (j * 1LL * arr1[i]) % k) % k, (hg || (j != 0)));       arr[i][s][hg] %= m;     }     return arr[i][s][hg];   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     memset(arr, -1, sizeof(arr));     cin >> n >> k >> m;     arr1[0] = arr2[0] = 1;     for (int i = 1; i <= 1000; i++) arr1[i] = (arr1[i - 1] * 1LL * 10) % k;     for (int i = 1; i <= 1000; i++) arr2[i] = (arr2[i - 1] * 1LL * 10) % m;     cout << dp(0, 0, 0) <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1E5 + 5;   const int BASE1 = 1E9 + 7;   const int BASE2 = 999999993;   int n, k;   bool mark[MAXN];   int a[MAXN], nTurn;   int main() {     ios_base::sync_with_stdio(0);     cin >> n >> k;     for (int i = 0; i <= n; ++i) {       string s;       cin >> s;       if (s[0] ==  ? )         mark[i] = 1, ++nTurn;       else {         stringstream ss;         ss << s;         ss >> a[i];       }     }     if (k == 0) {       if (!mark[0]) {         if (a[0] == 0) {           cout <<  Yes ;         } else {           cout <<  No ;         }         return 0;       } else {         if (nTurn % 2 == n % 2) {           cout <<  Yes ;         } else {           cout <<  No ;         }         return 0;       }     } else {       if (nTurn == 0) {         long long res1 = 0, res2 = 0, cur1 = 1, cur2 = 1;         for (int i = 0; i <= n; ++i) {           res1 = (res1 + a[i] * cur1 % BASE1 + BASE1) % BASE1;           res2 = (res2 + a[i] * cur2 % BASE2 + BASE2) % BASE2;           cur1 = cur1 * k % BASE1;           cur2 = cur2 * k % BASE2;         }         if (res1 == 0 && res2 == 0) {           cout <<  Yes ;         } else           cout <<  No ;       } else {         if (n % 2 == 0) {           cout <<  No ;         } else {           cout <<  Yes ;         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int M = 5005;   int a[M], n, dp[M], ans, mx, s[M], t[M], cnt;   bool vis[M];   struct no {     int l, r, x;   } p[M];   bool cmp(no a, no b) { return a.r != b.r ? a.r < b.r : a.l < b.l; }   int main() {     ios::sync_with_stdio(false);     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i];       if (!p[a[i]].l) p[a[i]].l = i;       p[a[i]].r = i;       if (s[a[i]] == 0) s[a[i]] = i;       t[a[i]] = i;       mx = max(mx, a[i]);     }     for (int i = 1; i <= n; i++) {       int l = i, r = t[a[i]];       memset(vis, 0, sizeof(vis));       bool flag = 0;       int res = 0;       for (int j = l; j <= r; j++) {         if (vis[a[j]]) continue;         if (s[a[j]] < l) {           flag = 1;           break;         }         r = max(r, t[a[j]]);         res ^= a[j];         vis[a[j]] = 1;       }       if (flag) continue;       p[++cnt] = (no){l, r, res};     }     sort(p + 1, p + cnt + 1, cmp);     for (int i = 1; i <= cnt; i++) {       for (int j = 1; j < i; j++) {         if (p[j].r < p[i].l) {           dp[i] = max(dp[i], dp[j]);         }       }       dp[i] += p[i].x;       ans = max(ans, dp[i]);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     vector<long long> a;     a.push_back(0);     a.push_back(1);     map<long long, long long> m;     int k, l = 0;     m[0] = 1;     m[1] = 1;     while (1) {       k = l;       l = a.size();       for (int i = k; i < l; i++) {         long long z = a[i] * 10 + 0;         long long y = a[i] * 10 + 1;         if (m[z] == 0) {           a.push_back(z);           m[z]++;         }         if (m[y] == 0) {           a.push_back(y);           m[y]++;         }       }       if (a[a.size() - 1] > 1e9) break;     }     long long n;     cin >> n;     vector<long long>::iterator it;     it = upper_bound(a.begin(), a.end(), n);     cout << it - a.begin() - 1 << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int N = (int)1e6 + 9;   set<pair<int, int> > len, pos;   int n, m;   void add_seg(int L, int R) {     if (L > R) return;     int sz = R - L + 1;     pos.insert(make_pair(L, sz));     if (L != 1 && R != n) sz = (sz + 1) / 2;     len.insert(make_pair(sz, L));   }   void rem_seg(int L, int R) {     if (L > R) return;     int sz = R - L + 1;     pos.erase(make_pair(L, sz));     if (L != 1 && R != n) sz = (sz + 1) / 2;     len.erase(make_pair(sz, L));   }   int loc[N];   void add(int x) {     auto it = len.end();     --it;     int opt = it->first;     it = len.lower_bound(make_pair(opt, -1));     auto segt = pos.lower_bound(make_pair(it->second, -1));     int L = segt->first;     int R = L + (segt->second) - 1;     rem_seg(L, R);     int M = (L + R) / 2;     if (L == 1)       M = 1;     else if (R == n)       M = R;     cout << M <<   n ;     loc[x] = M;     add_seg(L, M - 1);     add_seg(M + 1, R);   }   void rem(int x) {     int pp = loc[x];     loc[x] = 0;     int L = pp, R = pp;     auto v2 = pos.lower_bound(make_pair(pp + 1, -1));     if (v2 != pos.end() && v2->first == pp + 1) {       R = (v2->first) + (v2->second) - 1;       rem_seg(v2->first, (v2->first) + (v2->second) - 1);     }     v2 = pos.lower_bound(make_pair(pp + 1, -1));     if (v2 != pos.begin()) {       --v2;       if ((v2->first) + (v2->second) - 1 == pp - 1) {         L = v2->first;         rem_seg(v2->first, pp - 1);       }     }     add_seg(L, R);   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     cin >> n >> m;     add_seg(1, n);     int typ;     int id;     for (int i = 0; i < m; i++) {       cin >> typ >> id;       if (typ == 1)         add(id);       else         rem(id);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int inf = -1e9;   struct node {     int low;     int high;     pair<int, int> val;     node() : val(make_pair(inf, 0)) {}     node(int _l, int _h) : low(_l), high(_h), val(make_pair(inf, 0)) {}     node(int _l, int _h, pair<int, int> _v) : low(_l), high(_h), val(_v) {}   };   int N = 1 << 19;   vector<node> seg(2 * N);   void initSeg(vector<pair<int, int>> vals) {     int len = vals.size();     for (int i = 0; i < len; ++i) {       seg[N + i].val = vals[i];       seg[N + i].low = i;       seg[N + i].high = i + 1;     }     for (int i = len; i < N; ++i) {       seg[N + i].low = i;       seg[N + i].high = i + 1;     }     for (int i = N - 1; i > 0; --i) {       seg[i].val = max(seg[2 * i].val, seg[2 * i + 1].val);       seg[i].low = seg[2 * i].low;       seg[i].high = seg[2 * i + 1].high;     }   }   pair<int, int> querySeg(int index, int low, int high) {     if (low <= seg[index].low && seg[index].high <= high) return seg[index].val;     if (seg[index].high <= low || high <= seg[index].low)       return make_pair(inf, 0);     return max(querySeg(2 * index, low, high),                querySeg(2 * index + 1, low, high));   }   pair<int, int> updateSeg(int index, int low, int high, pair<int, int> val) {     if (low <= seg[index].low && seg[index].high <= high) {       seg[index].val = val;       return val;     }     if (seg[index].high <= low || high <= seg[index].low) return seg[index].val;     pair<int, int> left = updateSeg(2 * index, low, high, val);     pair<int, int> right = updateSeg(2 * index + 1, low, high, val);     seg[index].val = max(left, right);     return seg[index].val;   }   vector<int> seq;   vector<int> a;   vector<pair<int, int>> b;   vector<bool> toVisit;   int n;   void dfs(int index) {     toVisit[index] = false;     updateSeg(1, index, index + 1, make_pair(inf, 0));     if (b[index].first < n && toVisit[b[index].first]) dfs(b[index].first);     while (true) {       pair<int, int> p = querySeg(1, 0, a[index]);       if (p.first > index)         dfs(p.second);       else         break;     }     seq.push_back(index);   }   int main() {     int Test = 1;     for (int test = 1; test <= Test; ++test) {       cin >> n;       a.clear();       b.clear();       seq.clear();       toVisit.clear();       for (int i = 0; i < n; ++i) {         int in;         cin >> in;         if (in == -1) in = n + 1;         a.push_back(in - 1);       }       for (int i = 0; i < n; ++i) {         b.push_back(make_pair(n, i));         toVisit.push_back(true);       }       for (int i = 0; i < n; ++i) {         if (a[i] == n) continue;         b[a[i]].first = i;       }       initSeg(b);       for (int i = 0; i < n; ++i) {         if (toVisit[i]) dfs(i);       }       int ans[n];       for (int i = 0; i < n; ++i) {         ans[seq[i]] = i + 1;       }       for (int i = 0; i < n; ++i) {         cout << ans[i] <<    ;       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int t[n];     for (int i = 0; i < n; i++) cin >> t[i];     int left_cnt, left_time, right_cnt, right_time;     int left_idx = 0, right_idx = n - 1;     left_time = left_cnt = right_time = right_cnt = 0;     while (left_idx <= right_idx) {       left_time += t[left_idx];       left_cnt++;       while (right_idx > left_idx && right_time < left_time) {         right_time += t[right_idx--];         right_cnt++;       }       left_idx++;     }     cout << left_cnt <<     << right_cnt << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, k;   int arr[51][51] = {0}, visit[51][51] = {0};   vector<pair<int, pair<int, int> > > v;   int dfs(int a, int b, int count);   void make_land(int i, int j);   int main() {     int i, j, sum = 0;     char ch;     cin >> n >> m >> k;     for (i = 0; i < n; i++) {       for (j = 0; j < m; j++) {         cin >> ch;         if (ch ==  * ) arr[i][j]++;       }     }     for (i = 0; i < n; i++) {       for (j = 0; j < m; j++) {         if (!visit[i][j] && !arr[i][j]) {           int value = dfs(i, j, 0);           if (value != -1) v.push_back(make_pair(value, make_pair(i, j)));         }       }     }     sort(v.begin(), v.end());     int check = v.size();     vector<pair<int, pair<int, int> > >::iterator it = v.begin();     for (i = 0; i < v.size() - k; i++) {       sum += it->first;       int a = (it->second).first;       int b = (it->second).second;       make_land(a, b);       it++;     }     cout << sum << endl;     for (i = 0; i < n; i++) {       for (j = 0; j < m; j++) {         if (arr[i][j] == 1)           cout <<  * ;         else           cout <<  . ;       }       cout << endl;     }   }   int dfs(int i, int j, int count) {     visit[i][j] = 1;     if (count != -1) count++;     if (i == n - 1 || j == m - 1 || i == 0 || j == 0) count = -1;     if (i <= n - 1 && j - 1 >= 0 && !visit[i][j - 1] && !arr[i][j - 1])       count = dfs(i, j - 1, count);     if (i - 1 >= 0 && j <= m - 1 && !visit[i - 1][j] && !arr[i - 1][j])       count = dfs(i - 1, j, count);     if (i <= n - 1 && j + 1 <= m - 1 && !visit[i][j + 1] && !arr[i][j + 1])       count = dfs(i, j + 1, count);     if (i + 1 <= n - 1 && j <= m - 1 && !visit[i + 1][j] && !arr[i + 1][j])       count = dfs(i + 1, j, count);     return count;   }   void make_land(int i, int j) {     arr[i][j] = 1;     if (i <= n - 1 && j - 1 >= 0 && !arr[i][j - 1]) {       make_land(i, j - 1);     }     if (i - 1 >= 0 && j <= m - 1 && !arr[i - 1][j]) {       make_land(i - 1, j);     }     if (i <= n - 1 && j + 1 <= m - 1 && !arr[i][j + 1]) {       make_land(i, j + 1);     }     if (i + 1 <= n - 1 && j <= m - 1 && !arr[i + 1][j]) {       make_land(i + 1, j);     }   }
#include <bits/stdc++.h>   const int maxed = 200000 + 10;   struct Node {     int x, y;   };   std::vector<Node> ve[maxed];   std::vector<Node>::iterator it;   std::map<long long, int> id;   std::map<std::pair<int, int>, int> ma;   int n, id_cnt;   int gcd_(int a, int b);   int main() {     scanf( %d , &n);     int a, b, c, sum = 0;     while (n--) {       scanf( %d%d%d , &a, &b, &c);       if (a == 1) {         sum += 1;         long long w = 1LL * b * b + 1LL * c * c;         if (!id.count(w)) id[w] = (++id_cnt);         int wa = id[w];         ve[wa].push_back((Node){b, c});         int len = ve[wa].size();         for (int i = 0; i < len; ++i) {           int x = ve[wa][i].x + b;           int y = ve[wa][i].y + c;           int z = gcd_(x, y);           if (b == ve[wa][i].x && c == ve[wa][i].y)             ma[std::pair<int, int>(x / z, y / z)] += 1;           else             ma[std::pair<int, int>(x / z, y / z)] += 2;         }       } else if (a == 2) {         sum -= 1;         long long w = 1LL * b * b + 1LL * c * c;         int wa = id[w], len = ve[wa].size();         for (int i = 0; i < len; ++i) {           int x = ve[wa][i].x + b;           int y = ve[wa][i].y + c;           int z = gcd_(x, y);           if (ve[wa][i].x == b && ve[wa][i].y == c)             ma[std::pair<int, int>(x / z, y / z)] -= 1;           else             ma[std::pair<int, int>(x / z, y / z)] -= 2;         }         for (it = ve[wa].begin(); it != ve[wa].end(); ++it)           if (it->x == b && it->y == c) {             ve[wa].erase(it);             break;           }       } else {         int z = gcd_(b, c), wa = 0;         if (ma.count(std::pair<int, int>(b / z, c / z)))           wa = ma[std::pair<int, int>(b / z, c / z)];         printf( %d n , sum - wa);       }     }     return 0;   }   int gcd_(int a, int b) {     if (!b) return a;     return gcd_(b, a % b);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, k;     cin >> n >> k;     if (k == 1) {       if (n > 1)         cout << n;       else         cout <<  -1 ;       return 0;     }     int i;     vector<int> res;     for (i = 2; i * i <= n; i++) {       while (n % i == 0 && k != 1) {         n /= i;         res.push_back(i);         k--;       }       if (k == 1 && n != 1) {         res.push_back(n);         for (i = 0; i < res.size(); i++) {           cout << res[i] <<    ;         }         return 0;       }     }     cout <<  -1 ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, a, b, k;   int dp[5010][5010];   int main() {     scanf( %d %d %d %d , &n, &a, &b, &k);     dp[0][a] = 1;     for (int i = 1; i <= k; ++i) {       for (int j = 1; j <= n; ++j) {         dp[i - 1][j] += dp[i - 1][j - 1];         dp[i - 1][j] %= (1000000007);       }       for (int j = 1; j <= n; ++j) {         if (j == b)           dp[i][j] = 0;         else {           int l, r;           if (j < b)             l = 0, r = (b + j + 1) / 2 - 1;           else             l = (b + j) / 2, r = n;           dp[i][j] = dp[i - 1][min(n, r)] - dp[i - 1][max(0, l)];           dp[i][j] %= (1000000007);           if (dp[i][j] < 0) dp[i][j] += (1000000007);           if (r >= j && l < j) dp[i][j] -= dp[i - 1][j] - dp[i - 1][j - 1];           dp[i][j] %= (1000000007);           if (dp[i][j] < 0) dp[i][j] += (1000000007);         }       }     }     int ans = 0;     for (int i = 1; i <= n; ++i) ans = (ans + dp[k][i]) % (1000000007);     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T, typename U>   inline void smin(T &a, const U &b) {     if (a > b) a = b;   }   template <typename T, typename U>   inline void smax(T &a, const U &b) {     if (a < b) a = b;   }   template <class T>   inline void gn(T &first) {     char c, sg = 0;     while (c = getchar(), (c >  9  || c <  0 ) && c !=  - )       ;     for ((c ==  -  ? sg = 1, c = getchar() : 0), first = 0; c >=  0  && c <=  9 ;          c = getchar())       first = (first << 1) + (first << 3) + c -  0 ;     if (sg) first = -first;   }   template <class T1, class T2>   inline void gn(T1 &x1, T2 &x2) {     gn(x1), gn(x2);   }   template <class T1, class T2, class T3>   inline void gn(T1 &x1, T2 &x2, T3 &x3) {     gn(x1, x2), gn(x3);   }   template <class T>   inline void print(T first) {     if (first < 0) {       putchar( - );       return print(-first);     }     if (first < 10) {       putchar( 0  + first);       return;     }     print(first / 10);     putchar(first % 10 +  0 );   }   template <class T>   inline void println(T first) {     print(first);     putchar(  n );   }   template <class T>   inline void printsp(T first) {     print(first);     putchar(   );   }   template <class T1, class T2>   inline void print(T1 x1, T2 x2) {     printsp(x1), println(x2);   }   template <class T1, class T2, class T3>   inline void print(T1 x1, T2 x2, T3 x3) {     printsp(x1), printsp(x2), println(x3);   }   int power(int a, int b, int m, int ans = 1) {     for (; b; b >>= 1, a = (long long)a * a % m)       if (b & 1) ans = (long long)ans * a % m;     return ans;   }   int a[3010], arr[3010], n, nn;   long long dp[3010][3010];   int main() {     gn(n);     for (int i = 1; i <= n; i++) {       gn(a[i]);       a[i] -= i;       arr[i] = a[i];     }     sort(arr + 1, arr + n + 1);     nn = unique(arr + 1, arr + n + 1) - arr - 1;     for (int i = 1; i <= n; i++) {       dp[i][0] = 0x3f3f3f3f3f3f3f3fLL;       for (int j = 1; j <= nn; j++) {         dp[i][j] = abs(a[i] - arr[j]);         dp[i][j] += dp[i - 1][j];         smin(dp[i][j], dp[i][j - 1]);       }     }     print(dp[n][nn]);   }
#include <bits/stdc++.h>   #pragma comment(linker,  /stack:200000000 )   #pragma GCC optimize( Ofast )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native )   using namespace std;   const int block_size = 320;   const long long mod = 1e9 + 7;   const long long inf = 1e9 + 7;   const long double eps = 1e-9;   const double PI = atan(1) * 4;   template <typename T>   inline int sign(const T &a) {     if (a < 0) return -1;     if (a > 0) return 1;     return 0;   }   template <typename T, typename S>   inline bool upmin(T &a, const S &b) {     return a > b ? a = b, 1 : 0;   }   template <typename T, typename S>   inline bool upmax(T &a, const S &b) {     return a < b ? a = b, 1 : 0;   }   template <typename T>   inline void in(T &x) {     x = 0;     T f = 1;     char ch = getchar();     while (!isdigit(ch)) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (isdigit(ch)) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     x *= f;   }   long long twop(int x) { return 1LL << x; }   template <typename A, typename B>   inline void in(A &x, B &y) {     in(x);     in(y);   }   template <typename A, typename B, typename C>   inline void in(A &x, B &y, C &z) {     in(x);     in(y);     in(z);   }   template <typename A, typename B, typename C, typename D>   inline void in(A &x, B &y, C &z, D &d) {     in(x);     in(y);     in(z);     in(d);   }   namespace SOLVE {   long long n;   long long a[100000];   long long dp[2];   long long pre[20000][2];   long long getSum(long long l, long long r, long long v) {     return pre[r][v] - pre[l - 1][v];   }   void main() {     in(n);     n++;     for (long long i = 1; i < n; i++) {       in(a[i]);       a[i]--;       pre[i][a[i]] = 1;     }     for (long long i = 1; i < n; i++) {       for (long long j = 0; j < 2; j++) pre[i][j] += pre[i - 1][j];     }     memset(dp, 0xcf, sizeof(dp));     for (long long i = 1; i < n; i++) {       if (a[i] == 0) {         dp[0]++;       } else {         dp[1]++;         upmax(dp[1], dp[0] + 1);       }     }     long long ans = max(dp[0], dp[1]);     for (long long i = 1; i < n; i++) {       memset(dp, 0, sizeof(dp));       for (long long j = i; j < n; j++) {         if (a[j] == 1) {           dp[1]++;         } else {           dp[0]++;           upmax(dp[0], dp[1] + 1);         }         upmax(ans,               getSum(1, i - 1, 0) + getSum(j + 1, n - 1, 1) + max(dp[0], dp[1]));       }     }     cout << ans << endl;   }   }  // namespace SOLVE   int main() {     SOLVE::main();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, i, x, q, w[110000];   long long ans;   int f(int x) { return x * (x / 2) + x % 2; }   bool cmp(int x, int y) { return x > y; }   int main() {     scanf( %d%d , &n, &m);     for (i = 0; i < m; i++) scanf( %d%d , &q, w + i);     sort(w, w + m, cmp);     while (f(x + 1) <= n) x++;     x = min(x, m);     for (i = 0; i < x; i++) ans += w[i];     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class L, class R>   ostream& operator<<(ostream& os, pair<L, R> P) {     return os <<  (  << P.first <<  ,  << P.second <<  ) ;   }   template <class T>   ostream& operator<<(ostream& os, vector<T> V) {     os <<  [  ;     for (auto v : V) os << v <<    ;     return os <<  ] ;   }   template <class T>   ostream& operator<<(ostream& os, set<T> second) {     os <<  {  ;     for (auto s : second) os << s <<    ;     return os <<  } ;   }   template <class T>   ostream& operator<<(ostream& os, multiset<T> second) {     os <<  {  ;     for (auto s : second) os << s <<    ;     return os <<  } ;   }   template <class L, class R>   ostream& operator<<(ostream& os, map<L, R> M) {     os <<  {  ;     for (auto m : M) os <<  (  << m.first <<  :  << m.second <<  )  ;     return os <<  } ;   }   template <typename Arg1>   void __f(const char* name, Arg1&& arg1) {     cout << name <<   :   << arg1 <<   n ;   }   template <typename Arg1, typename... Args>   void __f(const char* names, Arg1&& arg1, Args&&... args) {     const char* comma = strchr(names + 1,  , );     cout.write(names, comma - names) <<   :   << arg1 <<   | ;     __f(comma + 1, args...);   }   void solve() {     int n;     cin >> n;     vector<long long> a(n);     for (int i = 0; i < n; ++i) {       cin >> a[i];       if (i) a[i] += a[i - 1];     }     long long sm = a[n - 1];     if (sm == 1) {       cout <<  -1 n ;       return;     }     vector<long long> divs;     for (long long d = 2; d * d <= sm; ++d) {       if (sm % d) continue;       divs.push_back(d);       while (sm % d == 0) {         sm /= d;       }     }     if (sm != 1) divs.push_back(sm);     long long ans = LLONG_MAX;     for (long long d : divs) {       long long ta = 0;       for (int i = 0; i < n - 1; ++i) {         ta += min(a[i] % d, d - a[i] % d);       }       ans = min(ans, ta);     }     cout << ans <<   n ;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int T = 1, tc = 1;     while (T--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     double l, x, v1, v2, k;     cin >> l >> x >> v1 >> v2 >> k;     double n = ceil(l / k);     double t2, t1;     t2 = x / (v2 * (n * ((v1 + v2) / (v2 - v1)) - (n - 1)));     t1 = t2 * (v1 + v2) / (v2 - v1);     double odp = t1 * n + t2 * (n - 1);     cout << setprecision(8) << odp;   }
#include <bits/stdc++.h>   char c =  G ;   void incrementa();   int main() {     int n;     scanf( %d , &n);     n = n - 7;     printf( ROYGBIV );     for (int i = 0; i < n; i++) incrementa();     return 0;   }   void incrementa() {     printf( %c , c);     switch (c) {       case  G :         c =  B ;         break;       case  B :         c =  I ;         break;       case  I :         c =  V ;         break;       case  V :         c =  G ;         break;     }   }