malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int n, k, tot, len[(int)(3e3 + 4)];   pair<int, int> bound[(int)(3e3 + 4)];   string s;   vector<int> poz, ans[3000004];   void fail();   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     cin >> n >> k;     cin >> s;     for (int i = s.size() - 1; i >= 0; --i)       if (s[i] ==  R ) {         len[poz.size()] = (s.size() - poz.size()) - i - 1;         tot += len[poz.size()];         poz.push_back(i);       }     if (k > tot) fail();     int p = 0;     while (p < poz.size() && !len[p]) ++p;     bound[p] = {1, len[p]};     tot -= len[p];     for (int i = p + 1; i < poz.size(); ++i) {       int l, r, dist, ramas;       dist = dist = poz[i - 1] - poz[i] - 1;       l = max(1, bound[i - 1].first + 1 - dist);       tot -= len[i];       if (k - tot - len[i] + 1 >= l)         bound[i] = {k - tot - len[i] + 1, k - tot};       else if (l + len[i] - 1 <= k)         bound[i] = {l, l + len[i] - 1};       else         fail();     }     for (int i = 0; i < poz.size(); ++i) {       int p = poz[i];       while (bound[i].first <= bound[i].second) {         ans[bound[i].first].push_back(p + 1);         ++p;         ++bound[i].first;       }     }     for (int i = 1; i < k + 1; ++i) {       printf( %d  , ans[i].size());       for (auto it : ans[i]) printf( %d  , it);       printf(  n );     }     return 0;   }   void fail() {     cout << -1;     exit(0);   }
#include <bits/stdc++.h>   using namespace std;   int SquareRoot(int n) {     int l = 1, r = n + 1;     while (l < r) {       int mid = (l + r) / 2;       if (n / mid < mid) {         r = mid;       } else {         l = mid + 1;       }     }     --l;     if (l * l == n) {       return l;     }     return -1;   }   int GCD(int a, int b) {     while (b > 0) {       int t = a % b;       a = b;       b = t;     }     return a;   }   int main() {     int a = 0, b = 0;     scanf( %d%d , &a, &b);     int a2 = a * a;     int b2 = b * b;     bool found = false;     for (int i = a - 1; i > 0; --i) {       int j = SquareRoot(a2 - i * i);       if (j < 0) {         continue;       }       int gcd = GCD(i, j);       int i_norm = i / gcd;       int j_norm = j / gcd;       int squ = i_norm * i_norm + j_norm * j_norm;       if (b2 % squ != 0) {         continue;       }       int mul = SquareRoot(b2 / squ);       if (mul < 0) {         continue;       }       found = true;       int i2 = i_norm * mul;       int j2 = j_norm * mul;       if (i2 == j) {         continue;       }       printf( YES n );       printf( 0 0 n );       printf( %d %d n , i, j);       printf( %d %d n , -j2, i2);       break;     }     if (!found) {       printf( NO n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   const int inf = 0x3f3f3f3f;   const ll INF = 0x3f3f3f3f3f3f3f3fLL;   const int MAXN = 1e6 + 5;   int arr[MAXN], n;   ll fun(ll x) {     if (x == 1) return INF;     ll sum = 0, y = 0;     for (int i = 0; i < n; i++) {       y += arr[i];       y %= x;       sum += min(y, x - y);     }     return sum;   }   int main() {     std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);     ll sum = 0, ans = INF;     cin >> n;     for (int i = 0; i < n; i++) cin >> arr[i], sum += arr[i];     if (sum < 2) {       cout << -1 <<   n ;       return 0;     }     for (ll i = 2; i * i <= sum; i++) {       if (sum % i == 0) ans = min(ans, fun(i));       while (sum % i == 0) sum /= i;     }     ans = min(ans, fun(sum));     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   #pragma warning(disable : 4996)   using namespace std;   using LL = int64_t;   using pii = pair<int, int>;   const double PI = 2 * asin(1);   int g_n;   string g_s;   vector<int> vi_in;   vector<LL> vll_sum;   void pretreat() {}   void input() {     vi_in.clear(), vi_in.resize(g_n + 1);     vll_sum.clear(), vll_sum.resize(g_n + 1);     for (int i = 1, t; i <= g_n; ++i) {       scanf(  %d , &vi_in[i]);     }     cin >> g_s;     g_s =     + g_s;   }   void solve() {     LL mx = 0, sum = 0;     for (int i = 1; i <= g_n; ++i) {       if (g_s[i] ==  B ) {         vll_sum[i] = vll_sum[i - 1] + vi_in[i];         mx = max(mx, vll_sum[i]);       } else {         vll_sum[i] = vll_sum[i - 1];       }     }     sum = 0;     for (int i = 1; i <= g_n; ++i) {       if (g_s[i] ==  A ) {         sum += vi_in[i];         mx = max(mx, sum + (vll_sum[g_n] - vll_sum[i]));       }     }     sum = 0;     for (int i = g_n; i > 0; --i) {       if (g_s[i] ==  A ) {         sum += vi_in[i];         mx = max(mx, sum + vll_sum[i]);       }     }     cout << mx << endl;   }   int main() {     pretreat();     int t;     while (cin >> g_n) {       input();       solve();     }     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:102400000,102400000 )   using namespace std;   template <class T, class U>   inline void Max(T &a, U b) {     if (a < b) a = b;   }   template <class T, class U>   inline void Min(T &a, U b) {     if (a > b) a = b;   }   inline void add(int &a, int b) {     a += b;     while (a >= 1000003) a -= 1000003;   }   int pow(int a, int b) {     int ans = 1;     while (b) {       if (b & 1) ans = ans * (long long)a % 1000003;       a = (long long)a * a % 1000003;       b >>= 1;     }     return ans;   }   int f[700005], inv[700005], M;   int main() {     int T = 100, j, k, i, ca = 0, m, n;     scanf( %d%d , &n, &m);     M = n + m;     f[0] = 1;     for (int i = 1; i < M; i++) f[i] = f[i - 1] * (long long)i % 1000003;     inv[M - 1] = pow(f[M - 1], 1000003 - 2);     for (int i = M - 1 - 1; i >= 0; i--)       inv[i] = inv[i + 1] * (long long)(i + 1) % 1000003;     long long ans = 0;     for (int i = 1; i < n + 1; i++) {       ans += 1LL * f[i + m - 1] * inv[i] % 1000003;     }     ans %= 1000003;     printf( %d n , ans * inv[m - 1] % 1000003);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> v;   int main() {     long long n, res = 0, i;     cin >> n;     long long ans = (n * (n + 1)) / 2;     if (ans % 2 == 0)       cout << 0 << endl;     else       cout << 1 << endl;     ans = ans / 2;     for (i = n; i >= 1; i--) {       res += i;       if (res > ans) break;       v.push_back(i);     }     res -= i;     if (res < ans) v.push_back(ans - res);     int sz = v.size();     cout << sz <<    ;     for (int i = 0; i < sz; i++) cout << v[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 3e5 + 5;   int a[maxn];   int n;   int vis[maxn];   vector<int> ans;   int main() {     memset(vis, 0, sizeof(vis));     ans.clear();     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);     }     int cnt = 0;     int ma = 0;     for (int i = 1; i <= n; i++) {       int l, r;       for (l = i - 1; l >= 1; l--) {         if (a[l] % a[i] != 0) break;       }       for (r = i + 1; r <= n; r++) {         if (a[r] % a[i] != 0) break;       }       l++, r--;       if (r - l == ma)         ans.push_back(l);       else if (r - l > ma) {         ans.clear();         ma = r - l;         ans.push_back(l);       }       i = r;     }     sort(ans.begin(), ans.end());     cout << ans.size() <<     << ma << endl;     for (int i = 0; i < ans.size(); i++) {       cout << ans[i];       if (i != ans.size() - 1) cout <<    ;     }     cout <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int n, s, x, v, t, y, i, nr1, nr2, v1[100004], v2[100004], c[1000004],       d[1000004];   long long st, dr, m, Min, Min1, x1, x2, a[100004], b[100004];   double nr;   bool ok;   int main() {     scanf( %d %d , &n, &s);     for (i = 1; i <= n; i++) {       scanf( %d %d %d , &x, &v, &t);       if (t == 1) {         a[++nr1] = (1LL) * x * 5000000;         v1[nr1] = v;       } else {         b[++nr2] = (1LL) * 1000000 * 5000000 - (1LL) * x * 5000000;         v2[nr2] = v;       }     }     st = 1;     dr = (1LL) * 1000000 * 5000000;     for (i = 1; i <= 1000000; i++) c[i] = 0;     while (st <= dr) {       m = (1LL) * ((0LL) + st + dr) / 2;       ok = false;       for (i = 1; i <= nr1; i++) {         x1 = (0LL) + a[i] - (1LL) * v1[i] * m;         if (x1 > 0) {           x2 = (1LL) * x1 / s;           if (((1LL) * x1 % s) != 0) x2 = (1LL) + x2;           x2 = (0LL) + m - x2;           if (x2 >= 0) {             x1 = (0LL) + a[i] + (1LL) * x2 * (s - v1[i]);             if (((1LL) * a[i] % 5000000) == 0)               c[(1LL) * a[i] / 5000000]++;             else               c[(1LL) * a[i] / 5000000 + 1]++;             if (((1LL) * x1 / 5000000) <= 1000000) c[(1LL) * x1 / 5000000 + 1]--;           }         } else           c[1]++;       }       for (i = 1; i <= nr2 && ok == false; i++) {         x1 = (0LL) + b[i] - (1LL) * v2[i] * m;         if (x1 > 0) {           x2 = (1LL) * x1 / s;           if (((1LL) * x1 % s) != 0) x2 = (1LL) + x2;           x2 = (0LL) + m - x2;           if (x2 >= 0) {             x1 = (0LL) + ((1LL) * 5000000 * 1000000 - b[i]) -                  (1LL) * x2 * (s - v2[i]);             d[(1LL) * ((1LL) * 5000000 * 1000000 - b[i]) / 5000000 + 1]--;             if ((((1LL) * x1 % 5000000) == 0) && (x1 > 0))               d[(1LL) * x1 / 5000000]++;             else if ((((1LL) * x1 % 5000000) != 0) && (x1 > 0))               d[(1LL) * x1 / 5000000 + 1]++;             else               d[1]++;           }         } else           d[1]++;       }       if (ok == false) {         x = 0;         y = 0;         for (i = 1; i <= 1000000; i++) {           x += c[i];           y += d[i];           if (x > 0 && y > 0) ok = true;           c[i] = 0;           d[i] = 0;         }       }       if (ok == false)         st = (0LL) + m + 1;       else         dr = (0LL) + m - 1;     }     nr = (1.0) * st / 5000000;     printf( %.10f , nr);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long n;     cin >> n;     long long x, a, b, i, f = 1, pa, push_back;     vector<pair<long long, long long> > v(n);     vector<long long> ch;     cin >> x;     cin >> a >> b;     pa = a, push_back = b;     if (a + b == 7) f = 0;     for (i = 1; i < n; i++) {       cin >> a >> b;       if (f == 1) {         if (a + b != 7) {           if (a == pa || a == 7 - pa || a == push_back || a == 7 - push_back) {             if (b == pa || b == 7 - pa || b == push_back || b == 7 - push_back) {               f = 1;             } else               f = 0;           } else             f = 0;         } else           f = 0;       }       pa = a, push_back = b;     }     if (f == 1) {       cout <<  YES  << endl;     } else {       cout <<  NO  << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     ;     int n, m;     cin >> n >> m;     int dem = 0;     if (m % n != 0) {       cout << -1;       return 0;     }     int sum = m / n;     while (sum % 2 == 0) {       sum /= 2;       dem++;     }     while (sum % 3 == 0) {       sum /= 3;       dem++;     }     if (sum == 1)       cout << dem;     else       cout << -1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void dfs(long long a, vector<long long>& d, vector<vector<long long>>& adj,            vector<long long>& vis, long long dist) {     d[a] = dist;     vis[a]++;     for (auto b : adj[a]) {       if (!vis[b]) {         dfs(b, d, adj, vis, dist + 1);       }     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long t;     cin >> t;     while (t--) {       long long n, a, b, da, db;       cin >> n >> a >> b >> da >> db;       vector<vector<long long>> adj(n + 1);       for (long long i = 0; i < n - 1; i++) {         long long u, v;         cin >> u >> v;         adj[u].push_back(v);         adj[v].push_back(u);       }       if (da * 2 >= db) {         cout <<  Alice n ;         continue;       }       vector<long long> d(n + 1);       vector<long long> vis(n + 1);       dfs(b, d, adj, vis, 0);       if (d[a] <= da) {         cout <<  Alice n ;         continue;       }       long long mx = 0;       for (long long i = 1; i < n + 1; i++) {         mx = max(mx, d[i]);       }       vector<long long> d2(n + 1);       vector<long long> vis2(n + 1);       for (long long i = 1; i < n + 1; i++) {         if (d[i] == mx) {           dfs(i, d2, adj, vis2, 0);           break;         }       }       long long mx2 = 0;       for (long long i = 1; i < n + 1; i++) {         mx2 = max(mx2, d2[i]);       }       long long di = mx2;       if (di > 2 * da)         cout <<  Bob n ;       else         cout <<  Alice n ;     }     return 0;   }
#include <bits/stdc++.h>   int dx[] = {0, 0, 1, -1};   int dy[] = {1, -1, 0, 0};   using namespace std;   vector<long long int> v, v2, v3;   vector<long long int>::iterator it1, it2;   int ar[200];   int main() {     long long int tcase = 1;     while (tcase--) {       long long int n, k, a, ans = 0;       scanf( %lld %lld , &n, &k);       for (int i = 0; i < n; i++) {         scanf( %lld , &a);         ar[a % k]++;       }       ans += ar[0] / 2;       ar[0] = 0;       for (int i = 1; i <= (k / 2) + 1; i++) {         if (ar[i]) {           if (ar[k - i] && i != (k - i)) {             ans += min(ar[i], ar[k - i]);             ar[i] = ar[k - i] = 0;           } else if (ar[k - i] && (i == k - i)) {             ans += ar[i] / 2;             ar[i] = 0;           }         }       }       printf( %lld n , 2 * ans);     }   }
#include <bits/stdc++.h>   template <typename T>   inline void read(T& x) {     T res = 0, flag = 1;     char ch;     ch = getchar();     while (!isdigit(ch)) {       if (ch ==  - ) flag = -1;       ch = getchar();     }     while (isdigit(ch)) {       res = res * 10 + ch - 48;       ch = getchar();     }     x = res * flag;   }   const int N = 100000 + 1;   int n, k, x;   bool vis[N], pre[N], suf[N];   int main() {     read(n), read(k);     long long ans = n * 3 - 2;     for (int i = 1; i <= k; ++i) {       read(x);       if (!vis[x]) --ans;       vis[x] = 1;       if (vis[x - 1] && !pre[x]) --ans, pre[x] = 1;       if (vis[x + 1] && !suf[x]) --ans, suf[x] = 1;     }     printf( %lld n , ans);   }
#include <bits/stdc++.h>   using namespace std;   bool check(long long y) {     for (long long x = 2; x * x <= y; x++) {       if (y % x == 0) return 0;     }     return 1;   }   int main() {     std::cin.tie(0);     std::ios::sync_with_stdio(false);     long long n, x, y;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> y >> x;       if (y - x == 1 && check(x + y)) {         cout <<  Yes  << endl;       } else {         cout <<  No  << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   int f[1200000], g[30][30], h[30][30], o[30], p[30], q[30][30];   char c[30][30];   int i, j, k, l, m, n, t, u, v;   int main() {     scanf( %d%d , &n, &m);     for (i = 1; i <= n; i++) scanf( %s , c[i] + 1);     for (i = 1; i <= n; i++)       for (j = 1; j <= m; j++) c[i][j] = c[i][j] - 96;     memset(o, 12, sizeof(o));     for (i = 1; i <= n; i++)       for (j = 1; j <= m; j++) {         scanf( %d , &g[i][j]);         if (g[i][j] < o[i]) o[i] = g[i][j];       }     for (i = 1; i <= m; i++)       for (j = 1; j <= 26; j++) {         for (k = 1, l = 0, u = 0, v = 0; k <= n; k++)           if (c[k][i] == j) {             l = l | (1 << (k - 1));             u = u + g[k][i];             if ((!v) || (g[v][i] < g[k][i])) v = k;           }         h[i][j] = l, q[i][j] = u - g[v][i];       }     for (i = 1; i <= n; i++) p[i] = 1 << (i - 1);     t = (1 << n) - 1;     memset(f, 12, sizeof(f));     f[0] = 0;     for (i = 1; i <= m; i++) {       for (k = 1; k <= 26; k++)         if (h[i][k]) {           for (j = t; j > 0; j--)             if (((j | h[i][k]) == j) && (f[j] > f[j - h[i][k]] + q[i][k]))               f[j] = f[j - h[i][k]] + q[i][k];           for (j = t; j > 0; j--)             if (((j | h[i][k]) != j) && (f[j]))               for (l = t ^ j; l != 0; l = l - (l & (-l)))                 if (f[j] > f[j + (l & (-l))]) f[j] = f[j + (l & (-l))];         }     }     for (k = 1; k <= 20; k++)       for (j = t; j > 0; j--)         if ((j & p[k]) && (f[j] > f[j - p[k]] + o[k])) f[j] = f[j - p[k]] + o[k];     printf( %d , f[(1 << n) - 1]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   int a[N], b[N], seg[4 * N], lazy[4 * N], n, diff[N];   void update(int sq, int eq, int val, int id = 1, int s = 1, int e = n) {     if (lazy[id] != 0) {       seg[id] = lazy[id];       if (s != e) lazy[id * 2] = lazy[id * 2 + 1] = lazy[id];       lazy[id] = 0;     }     if (s > eq || e < sq) return;     if (s >= sq && e <= eq) {       seg[id] = val;       if (s != e) lazy[id * 2] = lazy[id * 2 + 1] = val;       return;     }     int mid = (s + e) / 2;     update(sq, eq, val, id * 2, s, mid);     update(sq, eq, val, id * 2 + 1, mid + 1, e);   }   int query(int idx, int id = 1, int s = 1, int e = n) {     if (lazy[id] != 0) {       seg[id] = lazy[id];       if (s != e) lazy[id * 2] = lazy[id * 2 + 1] = lazy[id];       lazy[id] = 0;     }     if (s == e) return seg[id];     int mid = (s + e) / 2;     if (idx <= mid)       return query(idx, id * 2, s, mid);     else       return query(idx, id * 2 + 1, mid + 1, e);   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int m;     cin >> n >> m;     for (int i = 1; i <= n; i++) cin >> a[i];     for (int i = 1; i <= n; i++) cin >> b[i];     for (int i = 1; i <= m; i++) {       int t;       cin >> t;       if (t == 2) {         int x;         cin >> x;         int cur = query(x);         if (cur == 0)           cout << b[x] <<   n ;         else           cout << a[x + diff[cur]] <<   n ;       } else {         int x, y, k;         cin >> x >> y >> k;         diff[i] = x - y;         update(y, y + k - 1, i);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5;   int c[4][11][11][maxn + 5];   char s[maxn + 50];   char t[15];   int n;   int getnum(char c) {     if (c ==  A ) return 0;     if (c ==  T ) return 1;     if (c ==  G ) return 2;     if (c ==  C ) return 3;   }   int lowbit(int x) { return x & (-x); }   void add(int *c, int k, int x) {     for (int i = k; i <= n; i += lowbit(i)) {       c[i] += x;     }   }   int query(int *c, int k) {     int ans = 0;     for (int i = k; i; i -= lowbit(i)) ans += c[i];     return ans;   }   int main() {     scanf( %s , s + 1);     n = strlen(s + 1);     for (int ch = 0; ch < 4; ++ch)       for (int i = 1; i <= 10; ++i)         for (int j = 1; j <= i; ++j)           for (int k = j; k <= n; k += i)             if (getnum(s[k]) == ch) {               add(c[ch][i][j], (k - j) / i + 1, 1);             }     int q;     scanf( %d , &q);     while (q--) {       int op, x, l, r;       char ch;       scanf( %d , &op);       if (op == 1) {         scanf( %d %c , &x, &ch);         int id = getnum(s[x]);         for (int i = 1; i <= 10; ++i) {           int j = x % i;           if (j == 0) j = i;           add(c[id][i][j], (x - j) / i + 1, -1);         }         s[x] = ch;         id = getnum(s[x]);         for (int i = 1; i <= 10; ++i) {           int j = x % i;           if (j == 0) j = i;           add(c[id][i][j], (x - j) / i + 1, 1);         }       }       if (op == 2) {         scanf( %d%d%s , &l, &r, t + 1);         int len = strlen(t + 1);         int ans = 0;         for (int k = 1; k <= len && k <= r - l + 1; ++k) {           int id = getnum(t[k]);           int i = len;           int j = (l + k - 1) % i;           if (j == 0) j = i;           ans += query(c[id][i][j], (r - j) / i + 1) -                  query(c[id][i][j], (l + k - 1 - j) / i);         }         printf( %d n , ans);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct laptop {     long long p, b, ind;     laptop() {}     laptop(long long a, long long b, long long c) : p(a), b(b), ind(c) {}     bool operator<(const laptop& o) const {       return ((long double)o.b * p > (long double)b * o.p);     }   };   int n, k;   vector<laptop> laptops;   bool check(long long q) {     priority_queue<laptop> pq;     for (auto& x : laptops) {       pq.push(x);     }     laptop here(0, 1, 1);     for (int i = 0; i < k; ++i) {       laptop u = pq.top();       pq.pop();       here.p = i;       if (here < u) {         return false;       }       u.p += q;       pq.push(u);     }     return true;   }   long long bs() {     const long long THIGH = 2000000000001LL;     long long lo = 0, hi = THIGH;     while (lo < hi) {       long long m = (lo + hi) / 2;       if (check(m)) {         hi = m;       } else {         lo = m + 1;       }     }     if (lo == THIGH) return -1;     return lo;   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0);     cin >> n >> k;     laptops.resize(n);     for (int i = 0; i < n; ++i) {       cin >> laptops[i].p;       laptops[i].ind = i;     }     for (int i = 0; i < n; ++i) {       cin >> laptops[i].b;     }     cout << bs() << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long m, n, a, b, c, ans, ar[1000001], k, paths[200010], visit[200010],       ans1, dp[400010], t, er[200110];   bool boo;   bool compare(long long a, long long b) {     if (a >= b) return 1;     return 0;   }   int main() {     string s;     std::ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> m;     for (long long i = 0; i < n; i++) {       cin >> a;       er[i] = a;       a %= m;       ar[a]++;     }     for (long long i = 0; i < m; i++) {       if (ar[i] >= 2) {         cout << 0;         return 0;       }     }     ans = 1;     sort(er, er + n);     for (long long i = n - 1; i >= 0; i--) {       for (long long j = 0; j < i; j++) {         ans *= (er[i] - er[j]) % m;         ans %= m;       }     }     cout << ans % m;   }
#include <bits/stdc++.h>   using namespace std;   int a[100005];   int themax(int b[], int k) {     int sum = b[0];     for (int z = 1; z < k; z++) {       sum += (b[z] + 1);     }     return sum;   }   int main() {     int n, x, max = 0, min = 0;     cin >> n >> x;     for (int i = 0; i < n; i++) {       cin >> a[i];     }     max = themax(a, n);     if (x == max)       cout <<  YES  << endl;     else       cout <<  NO  << endl;   }