malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     ll n, m;     cin >> n >> m;     std::vector<int> a(n + 2);     n = n + 2;     a[0] = 0;     a[n - 1] = m;     for (int i = 1; i <= n; i++) cin >> a[i];     ll v[n][2];     v[n - 1][0] = 0;     v[n - 1][1] = 0;     for (int i = n - 2; i >= 0; i--) {       v[i][0] = v[i + 1][1];       v[i][1] = (a[i + 1] - a[i]) + v[i + 1][0];     }     ll ans = v[0][1];     ll cur = 0;     for (int i = 0; i < n - 1; i++) {       int f;       if (i % 2 == 0)         f = 1;       else         f = 0;       if (f == 1) {         if (a[i + 1] - a[i] > 1) {           ans = max(ans, cur + a[i + 1] - 1 - a[i] + v[i + 1][1]);         }         cur += a[i + 1] - a[i];       } else {         if (a[i + 1] - a[i] > 1) {           ans = max(ans, cur + a[i + 1] - (a[i] + 1) + v[i + 1][0]);         }       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long t[3000000];   long long t1[3000000];   long long dp[10 * 10 + 5][10 + 5];   vector<long long> v;   long long n, m, k, l, r, nb, q, p;   map<long long, int> mapp;   void debug(long long* tab, int len) {     cout <<  debug ::::  n ;     for (int i = 0; i < len; i++) cout << tab[i] <<    ;     cout <<   n ;   }   int main() {     ios_base::sync_with_stdio(0);     cin >> nb;     while (nb--) {       cin >> n;       for (int i = 0; i < 4 * n; i++) cin >> t[i];       sort(t, t + 4 * n);       bool test = true;       for (int i = 0; i < 2 * n; i++) {         if (t[2 * i + 1] != t[2 * i]) test = false;       }       for (int i = 0; i < 2 * n; i++) t1[i] = t[2 * i];       long long k = t1[0] * t1[2 * n - 1];       for (int i = 0; i < n; i++) {         if (t1[i] * t1[2 * n - 1 - i] != k) test = false;       }       if (test)         cout <<  YES ;       else         cout <<  NO ;       if (nb) cout <<   n ;     }   }
#include <bits/stdc++.h>   #pragma warning(disable : 4996)   template <typename T>   T min(T x, T y) {     return x < y ? x : y;   }   template <typename T>   T max(T x, T y) {     return x > y ? x : y;   };   const int INF = 2000000005;   const long long mod = 1000000007;   const long long MAXN = 1000005;   const double eps = 1e-6;   int sgn(double x) { return x < -eps ? -1 : x > eps; }   double SQ(double x) { return x * x; }   struct point {     double x;     double y;     point(double X = 0, double Y = 0) { x = X, y = Y; }     point operator-(point t) { return {x - t.x, y - t.y}; }     double operator*(point t) { return x * t.y - y * t.x; }     double operator%(point t) { return x * t.x + y * t.y; }     double norm() { return sqrt(SQ(x) + SQ(y)); }   };   struct polygon {     int n;     std::vector<point> V;     double S;     void read() {       double x, y;       V.clear();       scanf( %d , &n);       for (int i = 0; i < n; i++) {         scanf( %lf %lf , &x, &y);         V.push_back({x, y});       }       S = 0;       for (int i = 0; i < n - 1; i++) S += V[i] * V[i + 1];       S += V[n - 1] * V[0];       S = 0.5 * fabs(S);     }     bool in(point p) {       int cnt = 0;       for (int i = 0; i < n; i++) {         int j = (i + 1) % n;         point u = V[i], v = V[j];         if (sgn(p.y - u.y) == 0 || sgn(p.y - v.y) == 0)           return in({p.x, p.y + 3 * eps});         if (sgn(u.y - v.y) <= 0) std::swap(u, v);         if (sgn(p.y - u.y) > 0 || sgn(p.y - v.y) <= 0) continue;         cnt += sgn((v - p) * (u - p)) > 0;       }       return cnt & 1;     }     double dis(point a, point b, point p) {       point ab = b - a, pa = a - p, pb = b - p;       if ((ab % pb) * (ab % pa) < 0) return fabs(pa * ab) / ab.norm();       return min(pa.norm(), pb.norm());     }     double dis(double x, double y) {       double t = 1e15;       for (int i = 0; i < n; i++) {         int j = (i + 1) % n;         point u = V[i], v = V[j];         t = min(t, dis(u, v, {x, y}));       }       return t;     }     bool judge(double x, double y, double r) {       if (dis(x, y) < r + eps) return true;       return in({x, y});     }   };   double W, H;   int N, Q;   polygon P[MAXN];   int main() {     scanf( %lf %lf %d , &W, &H, &N);     for (int i = 1; i <= N; i++) P[i].read();     double x, y, r;     scanf( %d , &Q);     while (Q--) {       scanf( %lf %lf %lf , &x, &y, &r);       std::vector<int> q;       double t = 0;       for (int i = 1; i <= N; i++)         if (P[i].judge(x, y, r)) q.push_back(i - 1), t += P[i].S;       printf( %lf %d  , t, q.size());       for (int i = 0; i < q.size(); i++) printf( %d  , q[i]);       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ld = long double;   using D = double;   using uint = unsigned int;   const int maxn = 1005;   int n;   int a[maxn];   int cnt[maxn];   int have[maxn];   int was[maxn];   int ct = 0;   inline bool canset(int x) {     int wh = lower_bound(a, a + n, x) - a;     if (wh >= n || a[wh] != x) return false;     if (was[wh] == ct) {       if (!have[wh]) return false;       have[wh]--;       return true;     } else {       have[wh] = cnt[wh] - 1;       was[wh] = ct;       return true;     }   }   inline int getcnt(int x) {     int wh = lower_bound(a, a + n, x) - a;     return have[wh];   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) scanf( %d , &a[i]);     sort(a, a + n);     int last = 0;     cnt[0] = 1;     for (int i = 1; i < n; i++) {       if (a[i] == a[i - 1])         cnt[last]++;       else {         last++;         a[last] = a[i];         cnt[last] = 1;       }     }     n = last + 1;     int answer = 2;     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         ct++;         int f = a[i];         int s = a[j];         canset(f);         if (!canset(s)) continue;         int curans = 2;         while (true) {           if (!canset(f + s)) break;           curans++;           int t = f + s;           f = s;           s = t;           if (f == 0 && s == 0) {             curans += getcnt(0);             break;           }         }         answer = max(answer, curans);       }     }     cout << answer << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s[1005];   long long a[1005];   long long ans;   long long b[1005][5];   long long ma;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n, m;     cin >> n >> m;     for (long long i = 1; i <= n; i++) {       cin >> s[i];     }     for (long long i = 0; i < m; i++) {       cin >> a[i];     }     for (long long i = 0; i < m; i++) {       ma = 0;       for (long long j = 1; j <= n; j++) {         b[i][s[j][i] -  A ]++;       }       for (long long j = 0; j < 5; j++) {         ma = max(ma, b[i][j]);       }       ans += ma * a[i];     }     cout << ans;   }
#include <bits/stdc++.h>   int Q;   int A;   int Ans[33];   int main() {     Ans[2] = 1;     Ans[3] = 1;     Ans[4] = 5;     Ans[5] = 1;     Ans[6] = 21;     Ans[7] = 1;     Ans[8] = 85;     Ans[9] = 73;     Ans[10] = 341;     Ans[11] = 89;     Ans[12] = 1365;     Ans[13] = 1;     Ans[14] = 5461;     Ans[15] = 4681;     Ans[16] = 21845;     Ans[17] = 1;     Ans[18] = 87381;     Ans[19] = 1;     Ans[20] = 349525;     Ans[21] = 299593;     Ans[22] = 1398101;     Ans[23] = 178481;     Ans[24] = 5592405;     Ans[25] = 1082401;     scanf( %d , &Q);     for (int i = 1; i <= Q; ++i) {       scanf( %d , &A);       for (int j = 2; j <= 25; ++j) {         if (A == (1 << j) - 1) {           printf( %d n , Ans[j]);           A = 0;           break;         }       }       if (A > 0) {         for (int j = 2; j <= 25; ++j) {           if (A < (1 << j) - 1) {             printf( %d n , (1 << j) - 1);             break;           }         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     unsigned long long sum{};     int cur{1};     for (int i{}; i < m; i++) {       int x;       cin >> x;       if (cur < x) {         sum += x - cur;         cur = x;       } else if (cur > x) {         sum += n - cur + x;         cur = x;       } else         continue;     }     cout << sum;   }
#include <bits/stdc++.h>   using namespace std;   int n;   long long ab[11], y[11];   long long val(string abv) {     long long res = 0;     for (int i = 0; i < (int)abv.size(); i++)       res = 10 * res + ((long long)(abv[i] -  0 ));     return res;   }   int main() {     cin.sync_with_stdio(false);     long long p10 = 10;     long long nb = 1989;     for (int i = 0; i < (int)10; i++) {       ab[i] = nb % p10;       y[i] = nb;       nb += p10;       p10 *= ((long long)10);     }     cin >> n;     while (n--) {       char c;       string abv;       for (int i = 0; i < (int)4; i++) cin >> c;       cin >> abv;       long long k = val(abv);       int l = abv.size() - 1;       if (ab[l] <= k)         printf( %I64d n , y[l] + k - ab[l]);       else         printf( %I64d n , y[l + 1] - (ab[l] - k));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1e9 + 7;   const int N = 100010;   int a[N];   vector<int> f[N];   void go() {     long long n;     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 2; i < N; i++) {       for (int j = i; j < N; j += i) f[j].push_back(i);     }     int freq[N] = {0};     for (int i = 0; i < n; i++) {       int m = 0;       for (auto x : f[a[i]]) {         m = max(m, freq[x] + 1);       }       freq[a[i]] = m;       for (auto x : f[a[i]]) {         freq[x] = m;       }     }     int ans = 1;     for (int i = 0; i < n; i++) {       ans = max(freq[a[i]], ans);     }     cout << ans;   }   int main() {     ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);     int t = 1;     cout << fixed << setprecision(9);     while (t--) {       go();     }   }
#include <bits/stdc++.h>   using namespace std;   int l1, r1, l2, r2, ans;   int min(int a, int b) { return a < b ? a : b; }   int max(int a, int b) { return a > b ? a : b; }   int check(int a) {     if (a > ans) ans = a;     return a;   }   int solve(int l1, int r1, int l2, int r2, int k) {     if (l1 == l2 && r1 == r2) {       if (r1 - l1 + 1 > ans) ans = r1 - l1 + 1;       return r1 - l1 + 1;     }     if (r1 - l1 + 1 <= ans || r2 - l2 + 1 <= ans) return 0;     if (k == 0) return 0;     int mid = (1 << k);     if (r1 < mid && r2 < mid) return check(solve(l1, r1, l2, r2, k - 1));     if (l1 > mid && l2 > mid)       return check(solve(l1 - mid, r1 - mid, l2 - mid, r2 - mid, k - 1));     if (r1 < mid && l2 > mid)       return check(solve(l1, r1, l2 - mid, r2 - mid, k - 1));     if (r2 < mid && l1 > mid)       return check(solve(l1 - mid, r1 - mid, l2, r2, k - 1));     if (l1 <= mid && r1 >= mid) {       if (r2 < mid)         return check(max(solve(l1, mid - 1, l2, r2, k - 1),                          solve(1, r1 - mid, l2, r2, k - 1)));       if (l2 > mid)         return check(max(solve(l1, mid - 1, l2 - mid, r2 - mid, k - 1),                          solve(1, r1 - mid, l2 - mid, r2 - mid, k - 1)));       int ret = min(r1, r2) - max(l1, l2) + 1;       ret = max(ret, solve(l1, mid - 1, 1, r2 - mid, k - 1));       ret = max(ret, solve(1, r1 - mid, l2, mid - 1, k - 1));       return check(ret);     }     if (l2 <= mid && r2 >= mid) {       if (r1 < mid)         return check(max(solve(l1, r1, l2, mid - 1, k - 1),                          solve(l1, r1, 1, r2 - mid, k - 1)));       if (l1 > mid)         return check(max(solve(l1 - mid, r1 - mid, l2, mid - 1, k - 1),                          solve(l1 - mid, r1 - mid, 1, r2 - mid, k - 1)));       int ret = min(r1, r2) - max(l1, l2) + 1;       ret = max(ret, solve(l1, mid - 1, 1, r2 - mid, k - 1));       ret = max(ret, solve(1, r1 - mid, l2, mid - 1, k - 1));       return check(ret);     }   }   int main() {     cin >> l1 >> r1 >> l2 >> r2;     cout << solve(l1, r1, l2, r2, 29) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     char temp[11];     int n, m, k;     cin >> n >> m >> k;     int a[10][100], b[10][100], c[10][100];     for (int i = 0; i < n; i++) {       cin >> temp;       for (int j = 0; j < m; j++) cin >> a[i][j] >> b[i][j] >> c[i][j];     }     int maxi = 0;     for (int i = 0; i < n; i++)       for (int j = 0; j < n; j++) {         if (i == j) continue;         vector<pair<int, int> > diff(m);         for (int t = 0; t < m; t++) diff[t] = make_pair(b[j][t] - a[i][t], t);         sort(diff.rbegin(), diff.rend());         int kc = k, cur = 0;         for (int t = 0; kc > 0 && t < m && diff[t].first > 0; t++) {           cur += min(kc, c[i][diff[t].second]) * diff[t].first;           kc -= min(kc, c[i][diff[t].second]);         }         maxi = max(maxi, cur);       }     cout << maxi << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f;   const int maxn = 100010;   int x0[maxn], x1[maxn], d[maxn], c[maxn];   int main() {     int n, m, y0, y1;     cin >> n >> m >> y0 >> y1;     for (int i = 0; i < n; ++i) {       cin >> x0[i];     }     memset(d, -1, sizeof(d));     for (int i = 0; i < m; ++i) {       cin >> x1[i];     }     int p = 0, k = 0, last = -1;     for (int i = 0; i < n; ++i) {       while (p < m && abs(x0[i] - x1[p]) > abs(x0[i] - x1[p + 1])) ++p;       if (last < p || abs(x0[i - 1] - x1[p]) == abs(x0[i] - x1[p]))         ++k, last = p;       else if (p < m && abs(x0[i] - x1[p]) == abs(x0[i] - x1[p + 1]))         ++k, last = ++p;       else         last = p;     }     cout << n - k << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve();   void precalc();   clock_t start;   bool doing = true;   int main() {     int t = 1;     cout.sync_with_stdio(0);     cin.tie(0);     precalc();     cout.precision(10);     cout << fixed;     start = clock();     int testNum = 1;     while (t--) {       solve();     }     return 0;   }   void precalc() {}   int binpow(int q, int w, int mod) {     if (!w) return 1;     if (w & 1) return q * binpow(q, w - 1, mod) % mod;     return binpow(q * q % mod, w / 2, mod);   }   int mod = 1000000007;   int gcd(int q, int w) {     while (w) {       q %= w;       swap(q, w);     }     return q;   }   int n, m;   string s[1005];   void solve() {     cin >> n >> m;     for (int i = 0; i < n; ++i) {       cin >> s[i];     }     vector<char> good(n - 1, false);     int ans = 0;     for (int i = 0; i < m; ++i) {       bool need = false;       for (int j = 0; j + 1 < n; ++j) {         if (good[j]) {           continue;         }         if (s[j][i] > s[j + 1][i]) {           need = true;         }       }       if (need) {         ++ans;       } else {         for (int j = 0; j + 1 < n; ++j) {           if (s[j][i] < s[j + 1][i]) {             good[j] = true;           }         }       }     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     double x = 0, ans = 0, p[100005] = {0};     int n;     cin >> n;     for (int i = 1; i <= n; i++) cin >> p[i];     for (int i = 1; i <= n; i++) {       x = x * p[i] + p[i];       ans += 2 * x;       ans -= p[i];     }     cout << fixed << setprecision(10);     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string char_to_str(char c) {     string tem(1, c);     return tem;   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     ;     long long n, k;     cin >> n >> k;     string s;     cin >> s;     string ans = s;     for (long long i = 0; i < n; ++i) {       long long d1 =  z  - s[i];       long long d2 = s[i] -  a ;       if (k >= d1 && k >= d2) {         if (d1 > d2) {           ans[i] =  z ;           k -= d1;         } else {           ans[i] =  a ;           k -= d2;         }       } else {         if (s[i] + k <=  z ) {           ans[i] = s[i] + k;           k = 0;         } else {           ans[i] = s[i] - k;           k = 0;         }       }     }     if (k != 0) {       cout <<  -1 ;     } else {       cout << ans;     }   }
#include <bits/stdc++.h>   using namespace std;   int dx[8] = {0, 0, 1, -1, -1, -1, 1, 1};   int dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};   char s[111][111];   int main() {     int n, m;     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) scanf( %s , s[i] + 1);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) {         if (s[i][j] >=  1  && s[i][j] <=  8 ) {           int cnt = 0;           for (int k = 0; k < 8; k++) {             int tx = i + dx[k];             int ty = j + dy[k];             if (tx >= 1 && tx <= n && ty >= 1 && ty <= m && s[tx][ty] ==  * )               cnt++;           }           if (cnt != s[i][j] -  0 ) return 0 * printf( NO n );         } else if (s[i][j] ==  . ) {           for (int k = 0; k < 8; k++) {             int tx = i + dx[k];             int ty = j + dy[k];             if (tx >= 1 && tx <= n && ty >= 1 && ty <= m && s[tx][ty] ==  * )               return 0 * printf( NO n );           }         }       }     puts( YES );   }
#include <bits/stdc++.h>   using namespace std;   int dp[105][105][205][2];   string s1;   int main() {     int n;     int ans = 0;     memset(dp, 0, sizeof(dp));     cin >> s1;     cin >> n;     dp[0][0][100][0] = 1;     for (int i = 1; i <= s1.size(); i++) {       for (int j = 0; j <= 100; j++) {         for (int k = 0; k <= 200; k++) {           if (dp[i - 1][j][k][0] == 1) {             if (s1[i - 1] ==  F ) {               for (int z = 0; z <= 50; z = z + 2) {                 if (j + z > n) break;                 dp[i][j + z][k + 1][0] = 1;               }               for (int z = 0; z <= 50; z = z + 2) {                 if (j + z + 1 > n) break;                 dp[i][j + 1 + z][k][1] = 1;               }             }             if (s1[i - 1] ==  T ) {               for (int z = 0; z <= 50; z = z + 2) {                 if (j + z > n) break;                 dp[i][j + z][k][1] = 1;               }               for (int z = 0; z <= 50; z = z + 2) {                 if (j + z + 1 > n) break;                 dp[i][j + 1 + z][k + 1][0] = 1;               }             }           }           if (dp[i - 1][j][k][1] == 1) {             if (s1[i - 1] ==  F ) {               dp[i][j][k - 1][1] = 1;               dp[i][j + 1][k][0] = 1;             }             if (s1[i - 1] ==  T ) {               dp[i][j][k][0] = 1;               dp[i][j + 1][k - 1][1] = 1;             }           }         }       }     }     for (int i = 0; i <= 201; i++) {       if (dp[s1.size()][n][i][0] == 1) ans = max(ans, abs(i - 100));       if (dp[s1.size()][n][i][1] == 1) ans = max(ans, abs(i - 100));     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 1e5 + 5;   long long n, u, v, w, res = 0, par[N];   vector<pair<long long, long long> > a[N];   long long root(long long x) {     if (par[x] < 0) return x;     return (par[x] = root(par[x]));   }   void Merge(long long u, long long v) {     long long a = root(u), b = root(v);     if (a == b) return;     if (par[a] > par[b]) swap(a, b);     par[a] += par[b], par[b] = a;   }   bool check(long long n) {     while (n > 0) {       long long a = n % 10;       if (a != 4 && a != 7) return false;       n /= 10;     }     return true;   }   void in() {     cin >> n;     for (long long i = 1; i <= n; i++) par[i] = -1;     for (long long i = 1; i <= n - 1; i++) {       cin >> u >> v >> w;       if (!check(w)) Merge(u, v);       a[u].push_back({v, w}), a[v].push_back({u, w});     }   }   void process() {     for (long long i = 1; i <= n; i++) {       if (par[i] < 0) {         long long tmp = -par[i];         res += (tmp * (n - tmp - 1) * (n - tmp));       }     }     cout << res;   }   int main() {     if (fopen( trau.inp ,  r ))       freopen( trau.inp ,  r , stdin), freopen( trau.out ,  w , stdout);     in();     process();   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int t;     cin >> t;     while (t--) {       long long int n;       cin >> n;       long long int i, j, s = 0, p = 0, u = 0;       for (i = 1; i <= n / 2; i++) {         s = s + i * i;       }       cout << s * 8 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long M1 = 998244353;   long long M2 = 1000000007;   long long fact[100005];   long long prime[169] = {       2,   3,   5,   7,   11,  13,  17,  19,  23,  29,  31,  37,  41,  43,  47,       53,  59,  61,  67,  71,  73,  79,  83,  89,  97,  101, 103, 107, 109, 113,       127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197,       199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281,       283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379,       383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463,       467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571,       577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659,       661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761,       769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863,       877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977,       983, 991, 997, 1009};   long long gcd(long long a, long long b) {     while (a != 0 && b != 0) {       if (a > b)         a %= b;       else         b %= a;     }     return max(a, b);   }   long long power(long long a, long long b, long long m) {     long long ans = 1;     while (b) {       if (b & 1) ans = (ans * a) % m;       b /= 2;       a = (a * a) % m;     }     return ans;   }   long long modInverse(long long a, long long m) {     long long g = gcd(a, m);     if (g == 1) return power(a, m - 2, m);   }   long long ncr(long long n, long long r, long long m) {     if (r == 0) return 1;     return (fact[n] * modInverse(fact[r], m) % m * modInverse(fact[n - r], m) %             m) %            m;   }   void boost() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);   }   int main() {     boost();     long long n, i, j, add = 0, t1, t2, m;     cin >> n;     long long a[n + 1], x = n + 1;     for (i = 1; i < n + 1; i++) cin >> a[i];     vector<pair<long long, pair<long long, long long>>> vec;     for (i = n; i >= 1; i--) {       m = (a[i] + add) % x;       if (m == i)         continue;       else if (m < i) {         t1 = i - m;         add += t1;         vec.push_back({1, {i, t1}});       } else {         t1 = x - m + i;         add += t1;         vec.push_back({1, {i, t1}});       }     }     vec.push_back({2, {n, x}});     long long ans = vec.size();     cout << ans << endl;     for (i = 0; i < ans; i++)       cout << vec[i].first <<     << vec[i].second.first <<                << vec[i].second.second << endl;   }
#include <bits/stdc++.h>   using namespace std;   constexpr int inf32 = 0x3f3f3f3f;   constexpr long long inf64 = 0x3f3f3f3f3f3f3f3f;   int main() {     ios::sync_with_stdio(false);     cin.tie(0), cout.tie(0);     int n, m;     cin >> n >> m;     vector<long long> a(n);     for (int u = 0; u < (n); ++u) cin >> a[u];     vector<vector<int> > adj(n);     for (int i = 0; i < (m); ++i) {       int u, v;       cin >> u >> v, --u, --v;       adj[u].push_back(v);     }     int k = 1;     vector<int> g(n, 0), vis(n, 0);     function<void(int)> dfs = [&](int u) {       if (vis[u]) return;       vis[u] = true;       for (const int &v : adj[u]) dfs(v);       vector<int> use(k, 0);       for (const int &v : adj[u]) use[g[v]] = true;       while (g[u] < k && use[g[u]]) ++g[u];       if (g[u] >= k) ++k;     };     for (int u = 0; u < (n); ++u) dfs(u);     vector<long long> f(k, 0);     for (int u = 0; u < (n); ++u) f[g[u]] ^= a[u];     int mx = -1;     for (int i = 0; i < (k); ++i)       if (f[i]) mx = i;     if (!~mx) return !(cout <<  LOSE n );     cout <<  WIN n ;     for (int u = 0; u < (n); ++u)       if (g[u] == mx && (a[u] ^ f[mx]) < a[u]) {         a[u] ^= f[mx], f[mx] = 0;         for (const int &v : adj[u]) a[v] ^= f[g[v]], f[g[v]] = 0;         break;       }     for (int u = 0; u < (n); ++u) cout << a[u] <<    ;     cout <<   n ;     return 0;   }