malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   bool fl, vis[200005];   int en, d[200005], head[200005];   struct edge {     int u, v, w, nxt;   } e[200005 * 4], e0[200005];   void dfs(int);   void adde(int, int, int);   int calc(int x) {     int ans = 0;     while (x) {       ans ^= x & 1;       x >>= 1;     }     return ans;   }   int main() {     int i, k, t, n, m, u, v, w;     scanf( %d , &t);     while (t--) {       scanf( %d %d , &n, &m);       fl = 0;       en = 0;       memset(vis, 0, n + 1);       memset(head, 0, 4 * (n + 1));       for (i = 1; i < n; ++i) {         scanf( %d %d %d , &u, &v, &w);         e0[i].u = u;         e0[i].v = v;         e0[i].w = w;         if (w != -1) {           k = calc(w);           adde(u, v, k);           adde(v, u, k);         }       }       for (i = 1; i <= m; ++i) {         scanf( %d %d %d , &u, &v, &w);         adde(u, v, w);         adde(v, u, w);       }       for (i = 1; i <= n; ++i)         if (!vis[i]) {           d[i] = 0;           dfs(i);         }       if (fl) {         puts( NO );         continue;       }       for (i = 1; i < n; ++i)         if (e0[i].w == -1) {           u = e0[i].u;           v = e0[i].v;           if (d[u] == d[v])             e0[i].w = 0;           else             e0[i].w = 1;         }       puts( YES );       for (i = 1; i < n; ++i) printf( %d %d %d n , e0[i].u, e0[i].v, e0[i].w);     }     return 0;   }   void dfs(int u) {     int i, v;     vis[u] = 1;     for (i = head[u]; i; i = e[i].nxt)       if (!vis[v = e[i].v]) {         d[v] = (d[u] ^ e[i].w);         dfs(v);       } else         fl |= d[v] != (d[u] ^ e[i].w);   }   void adde(int u, int v, int w) {     e[++en].v = v;     e[en].w = w;     e[en].nxt = head[u];     head[u] = en;   }
#include <bits/stdc++.h>   using namespace std;   struct edge {     int v, u;     long long w;     edge() {}     edge(int a, int b, long long c) : v(a), u(b), w(c) {}     bool operator<(edge e) const { return w < e.w; }   };   const int N = 100 * 1000 + 10;   vector<int> graph[N];   vector<long long> wei[N];   edge e[N * 2];   int n, m, par[N], cnt, upd[N];   bool is[N];   long long d[N];   int root(int v) {     if (v == par[v]) return v;     return par[v] = root(par[v]);   }   bool merge(int v, int u) {     v = root(v);     u = root(u);     if (v == u) return false;     par[v] = u;     return true;   }   long long mst() {     sort(e, e + cnt);     long long ans = 0;     for (int i = 0; i <= n - 1; i++) par[i] = i;     for (int i = 0; i <= cnt - 1; i++)       if (merge(e[i].v, e[i].u)) ans += e[i].w;     return ans;   }   void dijk() {     set<pair<long long, int> > st;     for (int i = 0; i <= n - 1; i++) {       d[i] = (1000LL * 1000 * 1000 * 1000 * 1000 * 1000);       if (is[i]) {         d[i] = 0;         upd[i] = i;       }       st.insert(pair<long long, int>(0, i));     }     while (!st.empty()) {       int ind = st.begin()->second;       st.erase(st.begin());       for (int i = 0; i <= ((int)(graph[ind]).size()) - 1; i++) {         int u = graph[ind][i];         long long w = wei[ind][i] + d[ind];         if (d[u] > w) {           st.erase(pair<long long, int>(d[u], u));           d[u] = w;           upd[u] = upd[ind];           st.insert(pair<long long, int>(d[u], u));         }       }     }     for (int i = 0; i <= n - 1; i++)       for (int j = 0; j <= ((int)(graph[i]).size()) - 1; j++) {         int u = graph[i][j];         e[cnt++] = edge(upd[i], upd[u], wei[i][j] + d[i] + d[u]);       }   }   int main() {     ios::sync_with_stdio(false);     cin >> n >> m;     for (int i = 0; i <= m - 1; i++) {       int a, b;       long long c;       cin >> a >> b >> c;       a--;       b--;       graph[a].push_back(b);       graph[b].push_back(a);       wei[a].push_back(c);       wei[b].push_back(c);     }     int k;     cin >> k;     for (int i = 0; i <= k - 1; i++) {       int x;       cin >> x;       x--;       is[x] = true;     }     dijk();     cout << mst() + d[0] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long t;     cin >> t;     while (t--) {       long long n, k;       cin >> n >> k;       vector<long long> p;       vector<long long> pre;       for (long long i = 0; i < n; i++) {         p.push_back(i + 1);       }       long long sum = 0;       for (long long i = 0; i < n; i++) {         sum += p[i];         pre.push_back(sum);       }       long long ind = lower_bound(pre.begin(), pre.end(), k) - pre.begin();       long long x = p[ind];       long long y = n - x - 1;       long long bb;       bb = y + (pre[ind] - k) + 1;       vector<char> ans;       for (long long i = 0; i < n; i++) {         if (i == y || i == bb)           ans.push_back( b );         else           ans.push_back( a );       }       for (int i = 0; i < n; i++) {         cout << ans[i];       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MAXN = 100005;   const int D = 1005;   struct data {     int ind;     long long Sum;     data(int _ind, long long _Sum) {       ind = _ind;       Sum = _Sum;     }   };   bool compare(data A, data B) {     if (A.Sum < B.Sum) return true;     if (A.Sum == B.Sum && A.ind < B.ind) return true;     return false;   }   long long f(long long a, long long b, long long c) {     return (((a - b) * (a - b)) + (c * c));   }   long long a[MAXN], S[MAXN];   vector<data> Q;   int main() {     int N;     cin >> N;     S[0] = 0;     for (int i = 1; i <= N; i++) {       cin >> a[i];       S[i] = S[i - 1] + a[i];       data r(i, S[i]);       Q.push_back(r);     }     long long ans = MAXN * MAXN;     for (long long i = 2; i <= N; i++) {       for (long long j = i; j <= i + D && j <= N; j++) {         long long res = f(S[i - 1], S[j], j - i + 1);         ans = min(ans, res);       }     }     sort(Q.begin(), Q.end(), compare);     for (int i = 0; i < Q.size(); i++) {       for (int j = i + 1; j < Q.size() && j < i + D; j++) {         ans = min(ans, f(Q[i].Sum, Q[j].Sum, abs(Q[i].ind - Q[j].ind)));       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   const int inf = INT_MAX;   const int MAX = 1e3 + 8;   const long long MOD = 1e9 + 7;   const int TOT_PRIMES = 1e6 + 9;   const int MAX_A = 71;   const int LN = 20;   using namespace std;   int main() {     int n, k;     cin >> n >> k;     int a[32];     memset(a, 0, sizeof(a));     for (int i = 0; i < n; i++) {       int res = 0;       for (int j = 0; j < k; j++) {         int x;         cin >> x;         res = x + res * 2;       }       a[res] = 1;     }     int f = 0;     for (int i = 0; i < (1 << k); i++) {       for (int j = 0; j < (1 << k); j++) {         if ((!(i & j)) && a[i] && a[j]) f = 1;       }     }     if (f)       cout <<  YES ;     else       cout <<  NO ;   }
#include <bits/stdc++.h>   using namespace std;   int main(void) {     string s;     cin >> s;     vector<set<int>> v(26);     for (int i = 0, l = s.size(); i < l; i++) {       v[s[i] -  a ].insert(i);     }     int q;     cin >> q;     int t;     while (q--) {       cin >> t;       if (t == 1) {         int pos;         char c;         cin >> pos >> c;         pos--;         v[s[pos] -  a ].erase(pos);         s[pos] = c;         v[c -  a ].insert(pos);       } else if (t == 2) {         int l, r, cnt = 0;         cin >> l >> r;         l--;         for (int i = 0; i < 26; i++) {           auto itr = v[i].lower_bound(l);           if (itr != v[i].end() && *itr < r) {             cnt++;           }         }         cout << cnt << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     for (int i = 0; i < t; i++) {       long long n, k;       cin >> n >> k;       long long ans = 0;       while (n != 0) {         if (n % k == 0) {           n /= k;           ans++;         } else {           ans += n % k;           n -= n % k;         }       }       cout << ans << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1005;   int N, K;   long long L[MAXN], R[MAXN];   double dp[MAXN][MAXN];   double calc(long long l, long long r) {     long long ret = 0, cur = 1;     for (; cur <= r; cur *= 10) {       if (cur == 1e18) {         ret++;         break;       }       if (cur * 10 <= l) continue;       if (cur <= l && cur * 10 > l) {         int a = l / cur;         if (a == 1) {           if (cur * 10 <= r)             ret += cur * 2 - l;           else {             int b = r / cur;             if (b == 1)               ret += r - l + 1;             else               ret += cur * 2 - l;           }         }       } else if (cur * 10 > r) {         int b = r / cur;         if (b == 1)           ret += r - cur + 1;         else           ret += cur;       } else         ret += cur;     }     return double(ret) / (r - l + 1);   }   int main() {     if (fopen( input.txt ,  r )) freopen( input.txt ,  r , stdin);     cin >> N;     for (int i = 0; i < N; i++) cin >> L[i] >> R[i];     cin >> K;     K = ceil(K / 100. * N);     dp[0][0] = 1;     for (int i = 0; i < N; i++) {       double p = calc(L[i], R[i]);       for (int j = 0; j < N; j++) {         dp[i + 1][j + 1] += dp[i][j] * p;         dp[i + 1][j] += dp[i][j] * (1 - p);       }     }     double ans = 0;     for (int k = K; k <= N; k++) ans += dp[N][k];     cout << fixed << setprecision(10) << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int b[100];   int main() {     int n;     cin >> n;     int a[n];     for (int i = 0; i < n; i++) {       cin >> a[i];       b[a[i]]++;     }     int f = 0, h = -1;     for (int i = 1; i <= 100; i++) {       if (b[i] == 1) {         f++;       } else if (b[i] > 2) {         h = i;       }     }     if (f % 2 == 0) {       cout <<  YES n ;       int r = f / 2;       for (int i = 0; i < n; i++) {         if (b[a[i]] == 1) {           if (r > 0) {             cout <<  A ;             r--;           } else {             cout <<  B ;           }         } else {           cout <<  A ;         }       }     } else {       if (h == -1) {         return cout <<  NO , 0;       }       int y = 0;       cout <<  YES n ;       int r = f / 2;       for (int i = 0; i < n; i++) {         if ((a[i] != h) || (a[i] == h && y != 0)) {           if (b[a[i]] == 1) {             if (r > 0) {               cout <<  A ;               r--;             } else {               cout <<  B ;             }           } else {             cout <<  B ;           }         } else {           cout <<  A ;           y++;         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       if (n % 4 != 0) {         cout <<  NO n ;         continue;       }       cout <<  YES n ;       for (int i = 2; i <= n; i += 2) cout << i <<    ;       for (int i = 1; i < n - 1; i += 2) cout << i <<    ;       cout << (n - 1) + (n / 2) << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   vector<T> uniq(vector<T> v) {     sort(v.begin(), v.end());     v.erase(unique(v.begin(), v.end()), v.end());     return v;   }   template <typename T>   struct RMQ {     using F = function<T(const T &, const T &)>;     int n;     vector<T> t;     F f;     RMQ(int n, F f, T df = 0) : n(n), f(f), t(vector<T>(n << 1, df)) {}     void modify(int p, T v) {       for (t[p += n] = v; p > 1; p >>= 1) t[p >> 1] = f(t[p], t[p ^ 1]);     }     T query(int l, int r, T res = 0) {       for (l += n, r += n + 1; l < r; l >>= 1, r >>= 1) {         if (l & 1) res = f(res, t[l++]);         if (r & 1) res = f(res, t[--r]);       }       return res;     }   };   int32_t main() {     ios_base ::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     vector<int> l(n + 1, 0), r(n + 1, 0);     vector<int> a(n);     for (int &x : a) cin >> x;     vector<int> b;     for (int i = 0; i < n; i++) {       b.push_back(a[i] - i);       b.push_back(a[i] - i + 1);     }     b = uniq(b);     int ptr = 0;     map<int, int> mp;     for (int x : b) mp[x] = ++ptr;     RMQ<int> ST(b.size() + 10, [&](int p, int q) { return max(p, q); });     for (int i = 0; i < n; i++) {       l[i] = 1 + ST.query(1, mp[a[i] - i]);       ST.modify(mp[a[i] - i], l[i]);     }     ST = RMQ<int>(b.size() + 10, [&](int p, int q) { return max(p, q); });     for (int i = n - 1; i >= 0; i--) {       r[i] = 1 + ST.query(mp[a[i] - i], b.size() + 9);       if (i + 1 < n) {         int x = 1 + ST.query(mp[a[i + 1] - (i + 1) + 1], b.size() + 9);         ST.modify(mp[a[i + 1] - (i + 1) + 1], x);       }     }     int ans = 0;     for (int i = 0; i < n; i++) ans = max(ans, l[i] + r[i] - 1);     cout << n - 1 - min(n - 1, ans) << endl;   }
#include <bits/stdc++.h>   using namespace std;   inline long long read() {     long long x = 0, f = 1;     char c = getchar();     for (; !isdigit(c); c = getchar())       if (c ==  - ) f = -1;     for (; isdigit(c); c = getchar()) x = x * 10 + c -  0 ;     return x * f;   }   const long long MAXN = 100010;   const long long INF = 1e9;   const long long Mod = 1e9 + 7;   long long N;   set<pair<long long, long long> > S;   long long P;   long long last = 0;   long long h[9][MAXN + 1];   long long inv[MAXN + 1];   long long top;   long long f[MAXN + 1];   long long g[9];   pair<long long, long long> sta[MAXN + 1];   const long long inv2 = (Mod + 1) / 2;   inline void Add(long long x, long long fn) {     if (top && fn == sta[top].second)       S.erase(sta[top]), sta[top].first = x, S.insert(sta[top]);     else       sta[++top] = make_pair(x, fn), S.insert(sta[top]);   }   inline long long Qf(long long x) {     return (*S.upper_bound(make_pair(x - 1, 3))).second;   }   inline long long OPR(long long i) {     long long l = 1, r = i + 1, d = (r - l) / 3;     long long a = Qf(d), b = Qf((r - d) - l), fx = 0;     fx = 0;     while (fx == a || fx == b) ++fx;     return fx;   }   long long ifac[MAXN + 1];   int main() {     N = read();     P = read();     long long now = 2;     f[1] = f[2] = 0;     Add(2, 0);     for (long long i = 3;; i++) {       long long l = 1, r = i + 1, d = (r - l) / 3;       long long a = f[d], b = f[(r - d) - l];       f[i] = 0;       while (f[i] == a || f[i] == b) ++f[i];       if (f[i] != f[i - 1]) {         last = i, Add(i - 1, f[i - 1]);         if (i > 1000) {           now = i - 1;           break;         }       }     }     long long lena = 1, lenb = 1;     for (; now <= P;) {       ++now;       while (sta[lena].first * 3 < now) ++lena;       while ((sta[lenb].first * 3) / 2 < now) ++lenb;       now = max(min((sta[lenb].first * 3 / 2) - 3, sta[lena].first * 3 - 3), now);       for (long long j = 1; j <= 10; j++) Add(now, OPR(now)), ++now;     }     --P;     for (long long i = 1; i <= top; i++) {       long long len = min(sta[i].first, P) - min(sta[i - 1].first, P);       (g[sta[i].second] += len * (P + 1) % Mod -                            (min(sta[i].first, P) + min(sta[i - 1].first, P) + 1) *                                len % Mod * inv2 % Mod +                            Mod) %= Mod;     }     inv[1] = 1;     ifac[0] = 1;     for (long long i = 2; i <= N; i++)       inv[i] = (Mod - (Mod / i) * inv[Mod % i] % Mod) % Mod;     for (long long i = 1; i <= N; i++) ifac[i] = ifac[i - 1] * inv[i] % Mod;     for (long long i = 0; i < 3; i++) {       long long ans = 1;       for (long long j = 0; j <= N; j++) {         if ((!(j & 1)) || (!i))           for (long long k = N - j; k >= 0; k--)             (h[i][k + j] +=              (i ? h[i - 1][k] : (!k ? 1 : 0)) * ans % Mod * ifac[j] % Mod) %= Mod;         ans = ans * g[i] % Mod;       }     }     long long fac = 1, pw = 1, sum = (g[0] + g[1] + g[2]) % Mod;     for (long long i = 1; i <= N; i++) fac = fac * i % Mod, pw = pw * sum % Mod;     printf( %lld n , (pw - h[2][N] * fac % Mod + Mod) % Mod);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, m;   long long x, y, z;   vector<pair<long long, long long> > v[200005];   long long dp[300];   bool used[2000005];   long long len[100005];   void dfs(long long x) {     used[x] = true;     for (long long i = 0; i < v[x].size(); ++i) {       long long to = v[x][i].first;       if (used[to]) {         long long l = len[x] ^ len[to] ^ v[x][i].second;         for (long long j = 32; j >= 0; --j)           if ((!dp[j] || dp[j] > l) && l & (1 << j)) {             dp[j] = l;           } else             l = min(l, l ^ dp[j]);       } else {         len[to] = len[x] ^ v[x][i].second;         dfs(to);       }     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> m;     for (long long i = 1; i <= m; ++i) {       cin >> x >> y >> z;       v[x].push_back(make_pair(y, z));       v[y].push_back(make_pair(x, z));     }     dfs(1);     long long ans = len[n];     for (long long i = 32; i >= 0; --i) ans = min(ans, ans ^ dp[i]);     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     string s;     cin >> s;     char m =  b ;     int ans = 0;     int k = 0, bm = 0, rm = 0;     while (k < n) {       if (s[k] == m) {         if (m ==  b )           m =  r ;         else           m =  b ;         k++;       } else {         if (s[k] ==  b )           bm++;         else           rm++;         if (m ==  b )           m =  r ;         else           m =  b ;         k++;       }     }     int ans1 = min(bm, rm) + abs(rm - bm);     m =  r ;     k = 0, bm = 0, rm = 0;     while (k < n) {       if (s[k] == m) {         if (m ==  b )           m =  r ;         else           m =  b ;         k++;       } else {         if (s[k] ==  b )           bm++;         else           rm++;         if (m ==  b )           m =  r ;         else           m =  b ;         k++;       }     }     int ans2 = min(bm, rm) + abs(rm - bm);     cout << min(ans1, ans2) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char A[5010], B[5010];   int N, M;   int f[5010][5010];   int main() {     scanf( %d%d , &N, &M);     scanf( %s , A + 1);     scanf( %s , B + 1);     int ans = 0;     for (int i = 1; i <= N; i++) {       for (int j = 1; j <= M; j++) {         f[i][j] = max(f[i - 1][j] - 1, f[i][j - 1] - 1);         if (A[i] == B[j]) {           f[i][j] = max(f[i][j], f[i - 1][j - 1] + 2);           f[i][j] = max(f[i][j], 2);         }         ans = max(ans, f[i][j]);       }     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> t;   void upd(int v, int x) {     for (int i = v; i < t.size(); i |= (i + 1)) {       t[i] += x;     }   }   int get(int v) {     int sum = 0;     for (int i = v; i >= 0; i = (i & (i + 1)) - 1) {       sum += t[i];     }     return sum;   }   int low_b(int s) {     int k = 0;     for (int i = 20; i > -1; i--) {       if (k + (1 << i) - 1 >= t.size()) {         continue;       }       if (t[k + (1 << i) - 1] < s) {         s -= t[k + (1 << i) - 1];         k += (1 << i);       }     }     return k;   }   const int k = 600;   bool cmp(const vector<int>& a, const vector<int>& b) {     if (a[0] / k == b[0] / k) return a[1] / k > b[1] / k;     return a[0] / k < b[0] / k;   }   int main() {     int n;     cin >> n;     vector<int> a(n);     for (int i = 0; i < n; ++i) {       cin >> a[i];     }     vector<vector<int>> pos(n);     for (int i = 0; i < n; ++i) {       pos[i].push_back(-1);       pos[i].push_back(n);     }     for (int i = 0; i < n; ++i) {       pos[a[i] - 1].push_back(i);     }     for (int i = 0; i < n; ++i) {       sort(pos[i].begin(), pos[i].end());     }     vector<vector<int>> queries;     for (int i = 0; i < n; ++i) {       for (int j = 0; j < pos[i].size() - 1; ++j) {         int l = pos[i][j] + 1;         int r = pos[i][j + 1] - 1;         if (l <= r) queries.push_back({l, r, i + 1});       }     }     queries.push_back({0, n - 1, n + 1});     sort(queries.begin(), queries.end(), cmp);     t.resize(n + 2);     for (int i = 0; i < n + 2; ++i) {       upd(i, 1);     }     vector<int> cnt(n + 1);     int L = 0, R = -1;     for (int i = 0; i < queries.size(); ++i) {       int l = queries[i][0];       int r = queries[i][1];       while (L > l) {         L--;         cnt[a[L] - 1]++;         if (cnt[a[L] - 1] == 1) {           upd(a[L] - 1, -1);         }       }       while (L < l) {         cnt[a[L] - 1]--;         if (cnt[a[L] - 1] == 0) {           upd(a[L] - 1, 1);         }         L++;       }       while (R > r) {         cnt[a[R] - 1]--;         if (cnt[a[R] - 1] == 0) {           upd(a[R] - 1, 1);         }         R--;       }       while (R < r) {         R++;         cnt[a[R] - 1]++;         if (cnt[a[R] - 1] == 1) {           upd(a[R] - 1, -1);         }       }       queries[i].push_back(low_b(1) + 1);     }     vector<bool> ok(n + 2, false);     for (auto elem : queries) {       if (elem[2] == elem[3]) {         ok[elem[2] - 1] = 1;       }     }     int answe = 0;     for (; answe <= n + 1; ++answe) {       if (!ok[answe]) break;     }     cout << answe + 1;   }
#include<bits/stdc++.h>   using namespace std;      int main(){       int t;       cin>>t;              while(t--){           int n;           cin>>n;                      int A[n],B[n];           vector<int>pos,neg;           for(int i=0;i<n;++i){               cin>>A[i];           }                      int z=0;           int m=0;           for(int i=0;i<n;++i){               cin>>B[i];               z+=(B[i]-A[i]);               if(B[i]>A[i]){                   m+=(B[i]-A[i]);                   neg.push_back(i);               }               if(B[i]<A[i]){                   pos.push_back(i);               }           }                      if(z==0){                               cout<<m<<  n ;               int i1=0,i2=0;               for(int i=0;i<m;++i){                   cout<<(pos[i1]+1)<<   <<(neg[i2]+1)<<  n ;                   A[pos[i1]]--;                   A[neg[i2]]++;                                      if(A[pos[i1]]==B[pos[i1]])i1++;                   if(A[neg[i2]]==B[neg[i2]])i2++;               }           }           else{               cout<< -1 n ;           }                  }   }
#include <bits/stdc++.h>   using namespace std;   int arr[3];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int t;     cin >> t;     for (int i = 0; i < t; ++i) {       int x;       cin >> x;       arr[i % 3] += x;     }     int count = 0;     for (int i = 0; i < 3; i++) {       count = max(count, arr[i]);     }     if (arr[0] == count) {       cout <<  chest             <<   n ;     }     if (arr[1] == count) {       cout <<  biceps             <<   n ;     }     if (arr[2] == count) {       cout <<  back             <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int arr[n + 1];     for (int i = 1; i <= n; i++) cin >> arr[i];     int x;     cin >> x;     int w, l;     while (x--) {       cin >> w >> l;       if (w == 1) {         arr[2] += arr[1] - l;         arr[1] = 0;         continue;       }       if (w == n) {         arr[n - 1] += l - 1;         arr[n] = 0;         continue;       }       arr[w - 1] += l - 1;       arr[w + 1] += arr[w] - l;       arr[w] = 0;     }     for (int i = 1; i <= n; i++) {       cout << arr[i] << endl;     }     return 0;   }