malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int n, m, ans[1010], foo[1010];   int t, l, r;   pair<pair<int, int>, int> ranges[1010];   int main() {     memset(foo, -1, sizeof(foo));     scanf( %d%d , &n, &m);     for (int i = 0; i < m; ++i) {       scanf( %d%d%d , &t, &l, &r);       ranges[i] = make_pair(pair<int, int>(l, r), t);       if (t == 1) {         for (int j = l; j < r; ++j) foo[j] = 0;       }     }     bool can = true;     ans[1] = 10000000;     for (int i = 0; i < m && can; ++i) {       if (ranges[i].second == 1) {         for (int j = ranges[i].first.first; j < ranges[i].first.second && can;              ++j) {           if (foo[j] != 0) can = false;         }       } else {         int cnt = 0;         for (int j = ranges[i].first.first; j < ranges[i].first.second && can;              ++j) {           if (foo[j] < 0) {             cnt++;             break;           }         }         if (cnt == 0) can = false;       }     }     if (!can) {       puts( NO );     } else {       puts( YES );       printf( %d , ans[1]);       for (int i = 2; i <= n; ++i) {         ans[i] = ans[i - 1] + foo[i - 1];         printf(  %d , ans[i]);       }       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char s[110000];   char res[110000];   int main() {     scanf( %s , s);     int resLen = 0;     int last = 0;     int index = 0;     for (int i = 0; i < 110000; i++) res[i] = 0;     for (char c =  z ; c >=  a ; c--)       for (int i = index; s[i]; i++)         if (s[i] == c) {           res[resLen] = c;           resLen++;           index = i + 1;         }     printf( %s n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a[110][110];     int n, i, j;     long long s = 0;     cin >> n;     if (n == 1) {       cin >> i;       cout << i;       return 0;     }     for (i = 0; i < n; ++i)       for (j = 0; j < n; ++j) {         cin >> a[i][j];         if (i == j) s += a[i][j];         if (i + j == n - 1) s += a[i][j];         if (i == (n - 1) / 2 || j == (n - 1) / 2) s += a[i][j];       }     cout << s - 2 * a[(n - 1) / 2][(n - 1) / 2];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, k;     cin >> n >> k;     vector<pair<long double, long double>> v;     for (long long int i = 0; i < n; i++) {       long double x, y;       cin >> x >> y;       v.push_back(make_pair(x, y));     }     long double sum = 0;     for (long long int i = 1; i < v.size(); i++) {       long double x1 = v[i - 1].first, y1 = v[i - 1].second, x2 = v[i].first,                   y2 = v[i].second;       long double dis = sqrt(((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1)));       sum = sum + dis;     }     long double ans = ((1.0 / 50.0) * sum) * k;     printf( %0.9Lf n , ans);   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx )   using namespace std;   const int MAXN = 1e3 + 3;   int n;   bool dp[MAXN][10];   string s;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> s;     n = (int)s.length();     string kek =  heidi ;     memset(dp, 0, sizeof(dp));     for (auto i = 0; i != n; i++) {       for (auto j = 0; j != 5; j++) {         if (s[i] != kek[j]) continue;         if (j > 0) {           bool good = false;           for (auto k = 0; k != i; k++)             if (dp[k][j - 1]) {               good = true;               break;             }           if (!good) continue;         }         dp[i][j] = true;       }     }     for (auto i = 0; i != n; i++)       if (dp[i][4]) {         cout <<  YES ;         return 0;       }     cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long get() {     long long x = 0;     char s = getchar();     while (s <  0  || s >  9 ) s = getchar();     while (s >=  0  && s <=  9 )       x = (x << 3) + (x << 1) + (s ^ 48), s = getchar();     return x;   }   long long Max(const long long x, const long long y) {     if (x > y) return x;     return y;   }   long long pow2(const long long x) { return x * x; }   const long long M = 3e5 + 5, INF = 2e18;   long long n, a, d[M], c[M], f[M];   struct node {     long long d, mxf, mxans;     node() {}     node(const long long D, const long long MXF, const long long MXANS) {       d = D, mxf = MXF, mxans = MXANS;     }   };   stack<node> s;   signed main() {     n = get(), a = get();     for (long long i = 1; i <= n; ++i)       d[i] = get(), c[i] = c[i - 1] + get(), f[i] = a * i - c[i];     long long ans = Max(0, a - (c[n] - c[n - 1]));     s.push(node(0, f[n], f[n]));     long long mxf_pre;     for (long long l = n - 1; l; --l) {       mxf_pre = -INF;       while (!s.empty() && s.top().d <= d[l + 1] - d[l]) {         mxf_pre = Max(mxf_pre, s.top().mxf);         s.pop();       }       if (mxf_pre != -INF && !s.empty())         s.push(node(d[l + 1] - d[l], mxf_pre,                     Max(mxf_pre - pow2(d[l + 1] - d[l]), s.top().mxans)));       else         s.push(node(d[l + 1] - d[l], mxf_pre,                     Max(mxf_pre - pow2(d[l + 1] - d[l]), -INF)));       if (!s.empty())         s.push(node(0, f[l], Max(f[l], s.top().mxans)));       else         s.push(node(0, f[l], Max(f[l], -INF)));       if (!s.empty())         ans = Max(ans, s.top().mxans - f[l - 1]);       else         ans = Max(ans, -INF);     }     printf( %lld , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 3e5 + 100;   long long n, x, y;   int a[maxn];   vector<long long> v[maxn];   int vis[maxn];   int flag;   void dfs(int u) {     int i, j;     vis[u] = 1;     if (u == y) {       flag = 1;       return;     }     for (i = 0; i < v[u].size(); i++) {       int k = v[u][i];       if (vis[k]) continue;       vis[k] = 1;       if (k == y) {         flag = 1;         return;       }       dfs(k);       if (!flag)         vis[k] = 0;       else         return;     }   }   long long cnt = 0;   void dfs2(int u) {     int i, j;     for (i = 0; i < v[u].size(); i++) {       int k = v[u][i];       if (vis[k]) {         continue;       }       vis[k] = 1;       cnt++;       dfs2(k);     }   }   int main() {     int i, j;     cin >> n >> x >> y;     for (i = 1; i <= n - 1; i++) {       int l, r;       cin >> l >> r;       v[l].push_back(r);       v[r].push_back(l);     }     if (n == 1) {       cout << 0 << endl;       return 0;     }     if (n == 2) {       cout << 1 << endl;       return 0;     }     dfs(x);     long long ans = n * (n - 1);     cnt = 0;     dfs2(x);     cnt++;     long long x1 = cnt;     cnt = 0;     dfs2(y);     cnt++;     long long y1 = cnt;     cout << ans - x1 * y1 << endl;     return 0;   }
#include <bits/stdc++.h>   const int N = 100002;   int n, k, l[N], r[N];   char s[N];   bool check1() {     if (n == k || l[n] == 1 || r[1] == n || l[n - k] == 1 || r[k + 1] == n)       return 1;     for (int i = 2; i <= n - k; i++)       if (s[i - 1] == s[i + k] && l[i - 1] == 1 && r[i + k] == n) return 1;     return 0;   }   bool check2() {     if ((k << 1) < n) return 0;     for (int i = 2; i <= n - k; i++)       if (l[i - 1] != 1 || r[i + k] != n) return 0;     return 1;   }   int main() {     scanf( %d %d %s , &n, &k, s + 1);     l[1] = 1;     r[n] = n;     for (int i = 2; i <= n; i++) l[i] = s[i] == s[i - 1] ? l[i - 1] : i;     for (int i = n - 1; i >= 1; i--) r[i] = s[i] == s[i + 1] ? r[i + 1] : i;     if (check1()) return !printf( tokitsukaze n );     if (check2()) return !printf( quailty n );     printf( once again n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 35050;   const int inf = 1e9;   int t[2 * N], lz[N], n, h, k;   int dp[55][N], val[N];   pair<int, int> up[N];   int pv[N];   inline void carrot() {     for (int i = int(0); i < int(n + 1); ++i) pv[i] = n;     for (int i = int(n - 1); i >= int(0); i--) {       up[i].first = i + 1;       up[i].second = pv[val[i]];       pv[val[i]] = i + 1;     }   }   inline void clear_trees() {     memset(t, 0, sizeof(t));     memset(lz, 0, sizeof(lz));   }   inline void build_trees(int row) {     for (int i = int(0); i < int(n); ++i) t[i + n] = dp[row][i];     for (int i = int(n - 1); i >= int(1); i--)       t[i] = max(t[i << 1], t[i << 1 | 1]);   }   inline void apply(int p, int val) {     t[p] += val;     if (p < n) lz[p] += val;   }   inline void build(int p) {     while (p > 1) p >>= 1, t[p] = max(t[p << 1], t[p << 1 | 1]) + lz[p];   }   inline void modify(int lo, int ro) {     lo += n, ro += n;     for (int l = lo, r = ro; l < r; l >>= 1, r >>= 1) {       if (l & 1) apply(l++, 1);       if (r & 1) apply(--r, 1);     }     build(lo);     build(ro);   }   inline void push(int p) {     for (int s = int(h); s >= int(1); s--) {       int i = p >> s;       if (lz[i] != 0) {         apply(i << 1, lz[i]);         apply(i << 1 | 1, lz[i]);         lz[i] = 0;       }     }   }   inline int query(int l, int r) {     push(l + n);     push(r + n - 1);     int res = -inf;     for (l += n, r += n; l < r; l >>= 1, r >>= 1) {       if (l & 1) res = max(res, t[l++]);       if (r & 1) res = max(res, t[--r]);     }     return res;   }   inline int solve() {     memset(dp, 0, sizeof(dp));     carrot();     set<int> s;     for (int i = int(n - 1); i >= int(0); i--) {       s.insert(val[i]);       dp[1][i] = int(s.size());     }     for (int num = int(2); num < int(k + 1); ++num) {       clear_trees();       build_trees(num - 1);       for (int i = int(n - num); i >= int(0); i--) {         modify(up[i].first, up[i].second);         dp[num][i] = query(i + 1, n);       }     }     return dp[k][0];   }   inline void input_random() {     n = (rand() % 10) + 1;     k = (rand() % n) + 1;     for (int i = int(0); i < int(n); ++i) val[i] = (rand() % n) + 1;   }   int dp2[15][15];   inline int brute() {     memset(dp2, 0, sizeof(dp2));     for (int i = int(0); i < int(n); ++i) dp2[1][i] = dp[1][i];     for (int num = int(2); num < int(k + 1); ++num) {       for (int i = int(n - num); i >= int(0); i--) {         set<int> s;         s.insert(val[i]);         for (int j = int(i + 1); j < int(n); ++j) {           if (dp[num - 1][j] == 0) continue;           dp2[num][i] = max(dp2[num][i], dp2[num - 1][j] + int(s.size()));           s.insert(val[j]);         }       }     }     for (int num = int(1); num < int(k + 1); ++num) {       for (int i = int(0); i < int(n); ++i) cout << dp[num][i] <<    ;       cout << endl;     }     return dp2[k][0];   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n >> k;     for (int i = int(0); i < int(n); ++i) cin >> val[i];     h = sizeof(int) * 8 - __builtin_clz(n);     int ans = solve();     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 300005;   int n;   int ans = 300005, pos = 1;   long long tnow, wnow;   struct node {     long long t, w;   } a[N];   priority_queue<long long, vector<long long>, greater<long long> > q;   bool cmp(node a, node b) { return a.t > b.t; }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %lld%lld , &a[i].t, &a[i].w);     tnow = a[1].t;     wnow = a[1].w;     a[1].t = 0;     sort(a + 1, a + 1 + n, cmp);     while (1) {       while (pos <= n && a[pos].t > tnow) {         q.push(a[pos].w - a[pos].t + 1);         pos++;       }       ans = min(ans, (int)q.size() + 1);       if (!q.size() || tnow < q.top()) break;       tnow -= q.top();       q.pop();     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:102400000,102400000 )   using namespace std;   const int inf = 2e9;   int ans[208][208];   int n, m;   namespace MaxFlow {   struct Edge {     int to, capacity, revid;     Edge() : to(-1), capacity(0), revid(-1){};     Edge(int t, int c, int r) : to(t), capacity(c), revid(r) {}   };   int depth[34010];   size_t curr[34010];   vector<Edge> g[34010];   void buildEdge(int src, int dst, int cap) {     g[src].push_back(Edge(dst, cap, int(g[dst].size())));     g[dst].push_back(Edge(src, 0, int(g[src].size()) - 1));   }   void bfs(int src) {     for (int i = 0; i <= 24000; i++) depth[i] = inf;     queue<int> q;     q.push(src);     depth[src] = 0;     while (!q.empty()) {       int p = q.front();       q.pop();       for (size_t i = 0; i < g[p].size(); i++) {         if (g[p][i].capacity == 0 || depth[g[p][i].to] <= depth[p] + 1) continue;         q.push(g[p][i].to);         depth[g[p][i].to] = depth[p] + 1;       }     }   }   int dfs(int x, int dst, int cmin) {     if (x == dst) return cmin;     for (size_t& i = curr[x]; i < g[x].size(); i++) {       Edge& e = g[x][i];       if (e.capacity == 0 || depth[e.to] <= depth[x]) continue;       int d = dfs(e.to, dst, min(cmin, e.capacity));       if (d > 0) {         e.capacity -= d;         int ac = x, ak = e.to;         if (ac > n) ans[ak][ac - n] -= d;         if (ak > n) ans[ac][ak - n] += d;         g[e.to][e.revid].capacity += d;         return d;       }     }     return 0;   }   int solve(int src, int dst) {     int res = 0;     while (true) {       bfs(src);       if (depth[dst] == inf) return res;       memset(curr, 0, sizeof curr);       int d = dfs(src, dst, inf);       while (d > 0) {         res += d;         d = dfs(src, dst, inf);       }     }   }   }  // namespace MaxFlow   int pep[108];   int pur[108];   int tot;   int main() {     cin >> n >> m;     for (int i = 1; i <= n; i++) {       cin >> pep[i];       MaxFlow::buildEdge(i, n + i, inf);       MaxFlow::buildEdge(0, i, pep[i]);       tot += pep[i];     }     int sum = 0;     for (int i = 1; i <= n; i++) {       cin >> pur[i];       sum += pur[i];       MaxFlow::buildEdge(i + n, 205, pur[i]);     }     while (m--) {       int a, b;       cin >> a >> b;       MaxFlow::buildEdge(a, b + n, inf);       MaxFlow::buildEdge(b, a + n, inf);     }     if (MaxFlow::solve(0, 205) != tot or tot != sum) {       cout <<  NO ;       return 0;     }     puts( YES );     cout <<   ;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         printf( %d  , ans[i][j]);       }       puts(  );     }   }
#include <bits/stdc++.h>   using namespace std;   struct s {     long long x;     long long y;   };   vector
 v;   bool cmp(s a, s b) {     if (a.x == b.x) return a.y < b.y;     return a.x > b.x;   }   int main() {     long long a, b, c, d, e, i, j, k, xx, yy;     s aa, bb;     scanf( %lld %lld , &a, &b);     for (i = 0; i < a; i++) {       scanf( %lld %lld , &aa.x, &aa.y);       v.push_back(aa);     }     sort(v.begin(), v.end(), cmp);     xx = v[b - 1].x;     yy = v[b - 1].y;     long long count = 0;     for (i = 0; i < a; i++) {       if (xx == v[i].x && yy == v[i].y) {         count++;       }     }     cout << count << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int c1, c2, c3, c4, n, m;   const int maxn = 1050;   int a[maxn], b[maxn];   int p, q, r, s;   int x, y;   int main() {     cin >> c1 >> c2 >> c3 >> c4;     cin >> n >> m;     for (int i = 0; i < n; i++) {       cin >> a[i];       x += min(c1 * a[i], c2);     }     for (int i = 0; i < m; i++) {       cin >> b[i];       y += min(c1 * b[i], c2);     }     cout << min(min(x, c3) + min(y, c3), c4) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   set<pair<int, int> > s;   int t[200000];   int n, k, q;   int main() {     cin >> n >> k >> q;     for (int i = 1; i <= n; ++i) scanf( %d , t + i);     for (int i = 0; i < q; ++i) {       int type, id;       pair<int, int> p;       scanf( %d %d , &type, &id);       p = make_pair(t[id], id);       if (type == 1) {         s.insert(p);         if (s.size() > k) s.erase(s.begin());       } else if (type == 2) {         if (s.count(p))           printf( YES n );         else           printf( NO n );       } else {         assert(0);       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int dd = (int)1e5 + 7;   int A[dd], k[dd], j[dd], G[dd];   int main() {     int n, m;     scanf( %d %d , &n, &m);     for (int i = 0; i < n; ++i) {       int l, r;       scanf( %d %d , &l, &r);       G[l - 1]++, G[r]--;     }     int F = 0;     for (int i = 0; i < m; ++i) A[i] = (F += G[i]);     vector<int> Y;     for (int i = 0; i < m; ++i) {       auto I = upper_bound(Y.begin(), Y.end(), A[i]);       k[i] = I - Y.begin() + 1;       if (I == Y.end())         Y.push_back(A[i]);       else         *I = A[i];     }     Y = vector<int>(0);     for (int i = m - 1; i >= 0; --i) {       auto I = upper_bound(Y.begin(), Y.end(), A[i]);       j[i] = I - Y.begin() + 1;       if (I == Y.end())         Y.push_back(A[i]);       else         *I = A[i];     }     int ans = 0;     for (int i = 0; i < m; ++i) ans = max(ans, k[i] + j[i] - 1);     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5, M = 1e9 + 7;   int n, a[N];   long long bigmod(long long b, long long p) {     long long t = 1;     for (; p; b = (b * b) % M, p >>= 1)       if (p & 1) t = (t * b) % M;     return t;   }   long long go(int now) {     vector<int> div;     for (int i = 1; i * i <= now; i++) {       if (now % i == 0) {         div.push_back(i);         if (i * i != now) div.push_back(now / i);       }     }     div.push_back(N);     sort(div.begin(), div.end());     long long last = 1, cur = 1;     for (int i = 0; i < div.size() - 1; i++) {       int x = lower_bound(a, a + n, div[i]) - a;       int y = lower_bound(a, a + n, div[i + 1]) - a;       long long tmp = bigmod(i + 1, y - x);       cur *= tmp;       cur %= M;     }     int sz = div.size() - 2;     div[sz] = N;     for (int i = 0; i < div.size() - 2; i++) {       int x = lower_bound(a, a + n, div[i]) - a;       int y = lower_bound(a, a + n, div[i + 1]) - a;       long long tmp = bigmod(i + 1, y - x);       last *= tmp;       last %= M;     }     return (cur - last + M) % M;   }   int main() {     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i];     sort(a, a + n);     long long ans = 1;     for (int i = 1; i < N; i++) {       ans += go(i);       ans %= M;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   const int MX = 1e5 + 23;   const long long MOD = 998244353;   int read() {     char k = getchar();     int x = 0;     while (k <  0  || k >  9 ) k = getchar();     while (k >=  0  && k <=  9 ) x = x * 10 + k -  0 , k = getchar();     return x;   }   struct node {     int l, r;     int sum, mx;     node *lch, *rch;   } * root;   void pushup(node *x) {     x->sum = x->lch->sum + x->rch->sum;     x->mx = std::max(x->lch->mx + x->rch->sum, x->rch->mx);   }   node *build(int l, int r) {     node *x = new node;     x->l = l, x->r = r;     if (l == r) {       x->sum = x->mx = 0;       x->lch = x->rch = nullptr;     } else {       int mid = (l + r) >> 1;       x->lch = build(l, mid);       x->rch = build(mid + 1, r);       pushup(x);     }     return x;   }   void add(node *x, int p, int v) {     if (x->l == x->r) {       x->sum += v;       x->mx += v;       return;     }     if (p <= x->lch->r)       add(x->lch, p, v);     else       add(x->rch, p, v);     pushup(x);   }   int query(node *x, int ex) {     if (x->l == x->r) return x->l;     if (x->rch->mx + ex >= 1) return query(x->rch, ex);     return query(x->lch, ex + x->rch->sum);   }   int m, w[MX];   int main() {     root = build(1, 100000 + 233);     m = read();     for (int i = 1, type, x, v; i <= m; ++i) {       x = read(), type = read();       if (type == 0) {         add(root, x, -1);       } else {         v = read();         w[x] = v;         add(root, x, 1);       }       if (root->mx <= 0) {         puts( -1 );       } else {         printf( %d n , w[query(root, 0)]);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   long long x, y;   vector<pair<pair<long long, long long>, int> > p;   long long dx, dy;   bool dot(long long x, long long y) {     long long x1 = x - p[0].first.first;     long long x2 = x - p[1].first.first;     long long y1 = y - p[0].first.second;     long long y2 = y - p[1].first.second;     return x1 * y2 - y1 * x2;     return true;   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %I64d%I64d , &x, &y);       p.push_back(make_pair(make_pair(x, y), i + 1));     }     sort(p.begin(), p.end());     dx = p[0].first.first - p[1].first.first;     dy = p[0].first.second - p[1].first.second;     for (int i = 2; i < n; i++) {       if (dot(p[i].first.first, p[i].first.second)) {         printf( %d %d %d n , p[0].second, p[1].second, p[i].second);         return 0;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   string a[55];   long long f[(1LL << (21))];   double fac[55];   int main() {     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i];     int l = a[0].size();     fac[0] = 1;     for (int i = 1; i <= l; i++) fac[i] = fac[i - 1] * i;     for (int i = 0; i < n; i++) {       for (int j = i + 1; j < n; j++) {         int s = 0;         for (int k = 0; k < l; k++)           if (a[i][k] == a[j][k]) s |= (1LL << (k));         f[s] |= (1LL << (i)) | (1LL << (j));       }     }     double res = 0;     for (int s = (1LL << (l)) - 1; s >= 0; s--) {       for (int k = 0; k < l; k++)         if (s >> k & 1) f[s ^ (1LL << (k))] |= f[s];     }     for (int s = 0; s < (1LL << (l)); s++) {       int nturn = __builtin_popcount(s);       for (int k = 0; k < l; k++)         if (s >> k & 1) {           int nreveal = 0;           long long x = f[s] ^ f[s ^ (1LL << (k))];           while (x) {             x -= x & (-x);             nreveal++;           }           res += (fac[nturn - 1] / fac[l] * fac[l - nturn]) * nturn * nreveal / n;         }     }     printf( %.15lf , res);   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   const int N = 2 * 1e5 + 10;   ll res;   ll a[N];   void solve() {     ll t, x, y, ex, ey, neast = 0, nnorth = 0, nsouth = 0, nwest = 0;     map<char, int> mp;     cin >> t >> x >> y >> ex >> ey;     ll k = ex - x;     ll l = ey - y;     string s;     cin >> s;     if (k > 0) {       neast = k;     } else {       nwest = abs(k);     }     if (l > 0) {       nnorth = l;     } else {       nsouth = abs(l);     }     for (int i = 0; i < s.size(); i++) {       if (s[i] ==  N  and nnorth > 0) {         nnorth--;       }       if (s[i] ==  E  and neast > 0) {         neast--;       }       if (s[i] ==  S  and nsouth > 0) {         nsouth--;       }       if (s[i] ==  W  and nwest > 0) {         nwest--;       }       if (nnorth == 0 and nsouth == 0 and neast == 0 and nwest == 0) {         cout << i + 1;         return;       }     }     cout << -1;   }   int main(int argc, char const *argv[]) {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     ll t = 1;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   const int MN = 1000 * 100 + 100;   int arr[MN], n, s_l, s_r;   int main() {     cin >> n;     for (int i = 0; i < n; i++) {       cin >> arr[i];       s_r += arr[i];     }     s_r -= arr[0];     s_l = arr[0];     int cnt = 0;     for (int i = 1; i < n; i++) {       if (s_l == s_r) cnt++;       s_r -= arr[i];       s_l += arr[i];     }     cout << cnt;     return 0;   }