malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const long long int INF = 1e18;   const int N = 3e5 + 7;   const int MOD = 1e9 + 7;   constexpr int mul(int a, int b) { return 1LL * a * b % MOD; }   template <typename... T>   constexpr int mul(int a, int b, T... t) {     return mul(mul(a, b), t...);   }   inline int read() {     char ch = getchar();     int x = 0, f = 1;     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while ( 0  <= ch && ch <=  9 ) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     return x * f;   }   inline long long int readl() {     char ch = getchar();     long long int x = 0, f = 1;     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while ( 0  <= ch && ch <=  9 ) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     return x * f;   }   long long int a[N], b[N];   long long int dp[N][3];   int main() {     int T = read();     while (T--) {       int n = read();       for (int i = 1; i <= n; i++) {         a[i] = readl();         b[i] = readl();       }       for (int i = 1; i <= n; i++) {         for (int j = 0; j < 3; j++) {           dp[i][j] = INF;         }       }       dp[1][0] = 0;       dp[1][1] = b[1];       dp[1][2] = b[1] * 2;       for (int i = 2; i <= n; i++) {         for (int j = 0; j < 3; j++) {           for (int k = 0; k < 3; k++) {             if (a[i] + j == a[i - 1] + k) {               continue;             }             dp[i][j] = min(dp[i][j], dp[i - 1][k] + b[i] * j);           }         }       }       cout << min(dp[n][0], min(dp[n][1], dp[n][2])) << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, *a, s, t, d1 = 0, d2 = 0;     cin >> n;     a = new int[n];     for (int i = 0; i < n; i++) cin >> a[i];     cin >> s >> t;     if (s < t) {       int tmp = t;       t = s;       s = tmp;     }     for (int i = t - 1; i < s - 1; i++) d1 += a[i];     for (int i = s - 1; i < n; i++) d2 += a[i];     for (int i = 0; i < t - 1; i++) d2 += a[i];     if (d1 > d2)       cout << d2;     else       cout << d1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> prefix_function(const string &s) {     int n = (int)s.size();     vector<int> p(n);     p[0] = 0;     for (int i = 1; i < n; i++) {       p[i] = p[i - 1];       while (p[i] > 0 && s[p[i]] != s[i]) p[i] = p[p[i] - 1];       if (s[p[i]] == s[i]) p[i]++;     }     return p;   }   vector<int> Z_function(string s) {     int n = (int)s.size();     vector<int> Z(n);     int l = 0, r = 0;     for (int i = 1; i < n; i++) {       if (i <= r) Z[i] = min(Z[i - l], r - i + 1);       while (i + Z[i] < n && s[i + Z[i]] == s[Z[i]]) Z[i]++;       if (i + Z[i] >= r) {         l = i;         r = i + Z[i] - 1;       }     }     return Z;   }   int main() {     string a;     getline(cin, a);     string b;     getline(cin, b);     int n = (int)a.size();     if (n != (int)b.size()) {       cout <<  -1 -1  << endl;       return 0;     }     vector<int> Z = Z_function(b + char(10) + a);     reverse(a.begin(), a.end());     vector<int> pi = prefix_function(a + char(10) + b);     reverse(a.begin(), a.end());     int i = 0;     int x = -1;     int y = -1;     while (i < n - 1) {       if (a[i] != b[n - i - 1]) break;       if (i + Z[n + 1 + i + 1] + pi[2 * n - i - 1] + 1 >= n) {         x = i;         y = n - pi[2 * n - i - 1];       };       i++;     }     cout << x <<     << y << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int A = 1000001;   int x, p, k;   bool b[A];   vector<int> v[A];   int calc(int x) {     int ret = 0;     int n = v[p].size();     for (int i = 1; i < (1 << n); i++) {       int pro = 1;       for (int j = 0; j < n; j++) {         if ((1 << j) & i) pro *= v[p][j];       }       ret += x / pro * (__builtin_popcount(i) % 2 ? 1 : -1);     }     return x - ret;   }   int main() {     for (int i = 2; i < A; i++) b[i] = 1;     for (int i = 2; i < A; i++) {       if (b[i] == 0) continue;       v[i].push_back(i);       for (int j = i + i; j < A; j += i) {         v[j].push_back(i);         b[j] = 0;       }     }     int T;     scanf( %d , &T);     while (T--) {       scanf( %d %d %d , &x, &p, &k);       int c = calc(x);       int l = 1, r = 1e9;       while (l <= r) {         int mid = (l + r) / 2;         if (calc(mid) - c >= k)           r = mid - 1;         else           l = mid + 1;       }       printf( %d n , r + 1);     }   }
#include <bits/stdc++.h>   using namespace std;   const int MXN = 1000100;   const long long inf = 1e15;   const int mod = 1000000007;   char s[MXN];   int was[2 * MXN];   int main() {     scanf( %s , s);     int n = strlen(s);     if (s[n - 1] ==  L ) {       for (int i = 0; i < (n); i++) {         if (s[i] ==  R )           s[i] =  L ;         else           s[i] =  R ;       }     }     for (int i = 0; i < (n); i++) {       if (s[i] ==  R )         s[i] = 1;       else         s[i] = -1;     }     int cur = 0;     int mn = 0, mx = 0, cmx = 0, tmx = 0;     for (int i = 0; i < (n); i++) {       was[cur + n] = 1;       cur += s[i];       tmx = max(tmx, cur);       if (cur < mn) {         mn = cur;         mx = -1e9;         cmx = 0;       }       if (cur > mx) {         mx = cur;         cmx = 1;       } else if (cur == mx) {         cmx++;       }     }     if (!was[cur + n]) {       printf( 1 n );       return 0;     }     if (cur == mx && cmx == 1) {       if (cur - mn > tmx) {         printf( %d n , cur - mn - tmx);         return 0;       }     }     printf( 0 );   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1000 * 1000 * 1000 + 7;   const int INF = 1000 * 1000 * 1000;   const long long LINF = (long long)INF * INF;   struct Query {     int l, r, ind, k;   };   int n, m;   int c[100100];   vector<int> adj[100100];   int cnt[100100], bnd[100100];   int ans[100100];   vector<int> st;   int sttime[100100];   int fntime[100100];   Query qr[100100];   void dfs(int v, int par) {     st.push_back(v);     sttime[v] = st.size() - 1;     for (int u : adj[v]) {       if (u == par) {         continue;       }       dfs(u, v);     }     fntime[v] = st.size() - 1;   }   bool mos_cmp(Query &a, Query &b) {     if (a.l / 400 == b.l / 400) {       return (a.l / 400 % 2 ? a.r > b.r : a.r < b.r);     }     return a.l / 400 < b.l / 400;   }   void mos_add(int i) {     cnt[c[i]]++;     bnd[cnt[c[i]]]++;   }   void mos_rem(int i) {     bnd[cnt[c[i]]]--;     cnt[c[i]]--;   }   int main(void) {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     cin >> n >> m;     for (int i = (1); i < (n + 1); i++) {       cin >> c[i];     }     for (int i = (0); i < (n - 1); i++) {       int ai, bi;       cin >> ai >> bi;       adj[ai].push_back(bi);       adj[bi].push_back(ai);     }     dfs(1, -1);     for (int i = (0); i < (m); i++) {       int vi, ki;       cin >> vi >> ki;       qr[i].l = sttime[vi];       qr[i].r = fntime[vi];       qr[i].k = ki;       qr[i].ind = i;     }     sort(qr, qr + m, mos_cmp);     int l = 0, r = -1;     for (int i = (0); i < (m); i++) {       while (l > qr[i].l) {         l--;         mos_add(st[l]);       }       while (r < qr[i].r) {         r++;         mos_add(st[r]);       }       while (l < qr[i].l) {         mos_rem(st[l]);         l++;       }       while (r > qr[i].r) {         mos_rem(st[r]);         r--;       }       ans[qr[i].ind] = bnd[qr[i].k];     }     for (int i = (0); i < (m); i++) {       cout << ans[i] <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long st = 1, mod = 998244353;     int n;     cin >> n;     vector<long long> ans(n + 1);     ans[n] = 10;     ans[n - 1] = 20;     for (int i = n - 2; i >= 1; i--) {       ans[i] = ans[i + 1] + 9;     }     for (int i = n - 1; i >= 1; i--) {       ans[i] = ((ans[i] * 9) % mod * st) % mod;       st = (10 * st) % mod;     }     for (int i = 1; i <= n; i++) cout << ans[i] <<    ;     cout << endl;   }   int main() {     ios_base::sync_with_stdio(false);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long read() {     long long s = 0, w = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) w = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) s = s * 10 + ch -  0 , ch = getchar();     return s * w;   }   const long long p = 998244353;   long long qp(long long x, long long y) {     long long res = 1;     for (long long t = x; y; y >>= 1, t = t * t % p)       if (y & 1) res = res * t % p;     return res;   }   struct node {     long long u, v, w;   } a[1000003];   vector<node> v[1000003];   long long f[1000003], g[1000003];   long long c[1000003];   signed main() {     long long n = read(), m = read(), k = read() + 1;     for (long long i = 1; i <= m; ++i) {       long long X = read();       a[i].u = read();       a[i].v = read();       a[i].w = read();       v[X].push_back(a[i]);     }     long long ans = 1e18;     memset(f, -1, sizeof(f)), memset(g, -1, sizeof(g));     memset(c, -1, sizeof(c));     long long S = 0, C = 0;     for (long long i = 1; i <= 1000000; ++i) {       for (node j : v[i])         if (j.v == 0) {           if (c[j.u] == -1) {             S += j.w, ++C, c[j.u] = j.w;           } else if (c[j.u] > j.w) {             S -= c[j.u] - j.w, c[j.u] = j.w;           }         }       if (C == n) f[i] = S;     }     S = 0, C = 0;     memset(c, -1, sizeof(c));     for (long long i = 1000000; i >= 1; --i) {       for (node j : v[i])         if (j.u == 0) {           if (c[j.v] == -1) {             S += j.w, ++C, c[j.v] = j.w;           } else if (c[j.v] > j.w) {             S -= c[j.v] - j.w, c[j.v] = j.w;           }         }       if (C == n) g[i] = S;     }     for (long long i = 1; i + k <= 1000000; ++i)       if (f[i] > -1 && g[i + k] > -1) {         ans = min(ans, f[i] + g[i + k]);       }     if (ans > 1e17)       puts( -1 );     else       printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void sc() {}   template <typename T, typename... Args>   void sc(T& a, Args&... args) {     cin >> a, sc(args...);   }   template <typename T>   void pr(T a) {     cout << a;   }   template <typename T, typename... Args>   void pr(T a, Args... args) {     cout << a <<    , pr(args...);   }   template <typename T>   void prl(T a) {     cout << a <<   n ;   }   template <typename T, typename... Args>   void prl(T a, Args... args) {     cout << a <<    , prl(args...);   }   template <typename T>   int sz(const T& a) {     return (int)a.size();   }   int dp[81][200003];   struct comp {     bool operator()(const pair<int, int>& lhs, const pair<int, int>& rhs) const {       return lhs.first + lhs.second <= rhs.first + rhs.second;     }   };   int main() {     cin.tie(NULL);     ios_base::sync_with_stdio(false);     int n, m;     sc(n, m);     pair<int, int> aten[n + 1];     aten[0] = {0, 0};     for (__typeof(2 * (m + 1)) i = (1) - ((1) > (2 * (m + 1)));          i != (2 * (m + 1)) - ((1) > (2 * (m + 1)));          i += 1 - 2 * ((1) > (2 * (m + 1))))       dp[0][i] = m + 1;     for (__typeof(n + 1) i = (1) - ((1) > (n + 1));          i != (n + 1) - ((1) > (n + 1)); i += 1 - 2 * ((1) > (n + 1))) {       sc(aten[i].first, aten[i].second);     }     sort(aten + 1, aten + n + 1, comp());     for (__typeof(n + 1) i = (1) - ((1) > (n + 1));          i != (n + 1) - ((1) > (n + 1)); i += 1 - 2 * ((1) > (n + 1))) {       dp[i][2 * (m + 1)] = m + 1;       for (__typeof(1) j = (2 * (m + 1)) - ((2 * (m + 1)) > (1));            j != (1) - ((2 * (m + 1)) > (1)); j += 1 - 2 * ((2 * (m + 1)) > (1))) {         int addneeded = 0;         if (j >= aten[i].first) {           addneeded = max(0, j - aten[i].first - aten[i].second);         } else           addneeded = max(0, aten[i].first - aten[i].second - j);         dp[i][j] = min(             dp[i][j + 1],             min(dp[i - 1][j],                 addneeded + (aten[i].first - aten[i].second - addneeded - 1 >= 0                                  ? dp[i - 1][aten[i].first - aten[i].second -                                              addneeded - 1]                                  : 0)));       }     }     prl(dp[n][m]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int x, y, z = 0, k, t = 0, e, g;     vector<int> zero;     vector<int> po;     vector<int> ne;     cin >> x;     g = x;     while (x--) {       cin >> y;       if (y < 0) {         ne.push_back(y);         k *= y;       }       if (y > 0) {         po.push_back(y);       }       if (y == 0) {         zero.push_back(y);       }       if (y < 0 || y == 0) t++;     }     if (t == g) {       for (int i = 0; i < 2; i++) {         e = ne.back();         po.push_back(e);         ne.pop_back();       }     }     k = ne.size();     if (k % 2 == 0) {       e = ne.back();       zero.push_back(e);       ne.pop_back();     }     cout << ne.size() <<    ;     for (int i = 0; i < ne.size(); i++) cout << ne[i] <<    ;     cout << endl;     cout << po.size() <<    ;     for (int i = 0; i < po.size(); i++) cout << po[i] <<    ;     cout << endl;     cout << zero.size() <<    ;     for (int i = 0; i < zero.size(); i++) cout << zero[i] <<    ;     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int oo = 1e9 + 9;   const long long inf = 1e18 + 18;   const int max6 = 1e6 + 6;   const int modx = 1e9 + 123;   const int mody = 997;   const int base = 137;   int a[max6], dd[max6], cnt[max6];   int main() {     int t;     cin >> t;     while (t--) {       int n, k;       cin >> n >> k;       for (int i = 0; i <= 2 * k; ++i) dd[i] = cnt[i] = 0;       for (int i = 1; i <= n; ++i) cin >> a[i];       int m = n / 2;       for (int i = 1; i <= m; ++i) {         int gmax = max(a[i], a[n - i + 1]) + k;         int gmin = min(a[i], a[n - i + 1]) + 1;         dd[gmin]++;         dd[gmax + 1]--;         cnt[a[i] + a[n - i + 1]]++;       }       int res = oo;       dd[1] += dd[0];       for (int i = 2; i <= 2 * k; ++i) {         dd[i] += dd[i - 1];         res = min(res, n - dd[i] - cnt[i]);       }       cout << res <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const double PI = acos(-1.0);   const int N = 3e5 + 5, K = 30;   int tam[N] = {1}, g[N][K], _g[N][K];   vector<int> v;   int res[N];   pair<int, int> merge(int a, int b) {     if (!a) return pair<int, int>(b, 0);     if (!b) return pair<int, int>(a, 0);     int r = 0;     v.push_back(a);     for (int i = 0; i < K; i++) {       if (g[a][i] and g[b][i]) {         r++;         pair<int, int> p = merge(g[a][i], g[b][i]);         g[a][i] = p.first;         r += p.second;       } else if (g[b][i]) {         g[a][i] = g[b][i];       }     }     return pair<int, int>(a, r);   }   void go(int at, int d) {     int r = 0;     for (int i = 0; i < K; i++) {       int next = g[at][i];       if (next) {         r++;         go(next, d + 1);         tam[at] += tam[next];       }     }     v.clear();     v.push_back(at);     int u = 0;     for (int i = 0; i < K; i++) {       int next = g[at][i];       pair<int, int> p = merge(u, next);       u = p.first;       r += p.second;     }     for (int i = 0; i < (int)v.size(); i++)       for (int j = 0; j < K; j++) g[v[i]][j] = _g[v[i]][j];     res[d] += r;   }   int main(void) {     ios_base::sync_with_stdio(false);     int n;     cin >> n;     for (int i = 1; i < n; i++) {       int a, b;       char c;       cin >> a >> b >> c;       g[a][c -  a ] = b;       _g[a][c -  a ] = b;     }     go(1, 1);     int ans = 0;     for (int i = 0; i < N; i++)       if (res[i] > res[ans]) ans = i;     cout << n - res[ans] << endl;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, k;     cin >> n >> k;     vector<long long> a(n);     for (size_t i = 0; i < n; i++) {       cin >> a[i];     }     long long ans = a[n - 1] - a[0];     multiset<long long> s;     for (long long i = 1; i < n; i++) {       s.insert(a[i - 1] - a[i]);     }     for (auto i : s) {       if (k == 1) {         cout << ans;         return 0;       } else {         k--;         ans += i;       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const long long LNF = 0x3f3f3f3f3f3f3f3f;   const int MOD = 1000000007;   const double EPS = 1e-8;   const long double EUL = 2.71828182845904523536;   const long double PII = 3.14159265358979323846;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, m, d;     while (cin >> n >> m >> d) {       int coffee[n];       int ans[n];       set<pair<int, int> > timeline;       for (int i = 0; i < n; i++) {         cin >> coffee[i];         timeline.insert({coffee[i], i});       }       int day = 0;       while (!timeline.empty()) {         day++;         int x = timeline.begin()->second;         ans[x] = day;         timeline.erase(timeline.begin());         while (1) {           auto it = timeline.lower_bound({coffee[x] + d + 1, -1});           if (it == timeline.end()) break;           x = it->second;           ans[x] = day;           timeline.erase(it);         }       }       cout << day << endl;       for (int i = 0; i < n; i++) cout << ans[i] <<    ;       cout << endl;     }     cerr <<  Time :   << 1000 * (long double)clock() / (long double)CLOCKS_PER_SEC          <<  ms n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f;   struct Rec {     pair<int, int> interval[4];   } recs[100005];   bool check(set<pair<pair<int, int>, int>> st[]) {     int n = st[0].size();     if (n == 1) return true;     set<pair<pair<int, int>, int>>::iterator iter[4];     for (int i = 0; i < 4; i++) iter[i] = st[i].begin();     vector<int> mxr(4, -inf);     for (int i = 0; i < n - 1; i++) {       for (int j = 0; j < 4; j++) {         mxr[j] = max(mxr[j], iter[j]->first.second);         iter[j]++;         if (iter[j]->first.first >= mxr[j]) {           set<pair<pair<int, int>, int>> mini[4];           vector<int> indexs;           for (auto it = st[j].begin(); it != iter[j]; it++) {             int index = it->second;             indexs.push_back(index);           }           for (auto index : indexs) {             for (int z = 0; z < 4; z++) {               mini[z].insert(make_pair(recs[index].interval[z], index));               st[z].erase(make_pair(recs[index].interval[z], index));             }           }           if (check(mini) && check(st)) return true;           return false;         }       }     }     return false;   }   int main() {     ios::sync_with_stdio(false);     int n;     cin >> n;     for (int i = 0; i < n; i++) {       int a, b, c, d;       cin >> a >> b >> c >> d;       recs[i].interval[0] = make_pair(a, c);       recs[i].interval[1] = make_pair(b, d);       recs[i].interval[2] = make_pair(-c, -a);       recs[i].interval[3] = make_pair(-d, -b);     }     set<pair<pair<int, int>, int>> st[4];     for (int i = 0; i < 4; i++) {       for (int j = 0; j < n; j++) st[i].insert(make_pair(recs[j].interval[i], j));     }     puts(check(st) ?  YES  :  NO );     return 0;   }
#include <bits/stdc++.h>   #pragma optimize( O3 )   using namespace std;   const long long MOD = 998244353;   const long long INF = 1e8 + 7;   const int base = 2e5 + 1;   const long long MAX = 3 * 1e5 + 1;   const double EPS = 1e-9;   const double PI = acos(-1.);   const int MAXN = 5 * 1e5 + 47;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   vector<vector<int> > g(MAXN), tb(MAXN);   vector<int> res;   int t[MAXN], was[MAXN];   int get(int v) {     was[v] = 1;     set<int> s;     for (auto u : g[v]) {       if (was[u]) s.insert(t[u]);     }     for (int i = (1); i < (MAXN); ++i) {       if (!s.count(i)) return i;     }   }   int main() {     int n, m;     cin >> n >> m;     for (int i = (0); i < (m); ++i) {       int v, u;       scanf( %d %d , &v, &u);       v--;       u--;       g[v].push_back(u);       g[u].push_back(v);     }     for (int i = (0); i < (n); ++i) {       scanf( %d , &t[i]);       tb[t[i]].push_back(i);     }     for (int i = (1); i < (n + 1); ++i) {       for (auto v : tb[i]) {         if (get(v) != i) {           cout << -1;           return 0;         }         res.push_back(v + 1);       }     }     for (auto v : res) printf( %d  , v);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 1e5 + 10;   int n, k;   struct st {     int v, p;   };   bool cmp(st a, st b) { return a.v < b.v; }   st a[MAX];   void solve() {     sort(a + 1, a + n + 1, cmp);     int t = 0;     for (int i = 2; i <= n; ++i) {       if (a[i].p == a[i - 1].p + 1) {         while (1) {           if (a[i].p != a[i - 1].p + 1)             break;           else {             ++i;           }         }         --i;       } else {         ++t;       }     }     if (t + 1 <= k)       cout <<  YES n ;     else       cout <<  NO n ;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0), cout.tie(0);     int T;     cin >> T;     while (T--) {       cin >> n >> k;       for (int i = 1; i <= n; ++i) {         cin >> a[i].v;         a[i].p = i;       }       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 50010;   int n;   char s[maxn];   int main() {     while (scanf( %s , s) != EOF) {       n = strlen(s);       int len = 1;       while (len <= n / 2) {         int cnt = 0, start = len;         for (int i = len; i < n; i++) {           if (cnt == len) break;           if (s[i] != s[i - len]) {             start = i + 1;             cnt = 0;           } else             cnt++;         }         if (cnt == len) {           for (int i = start + len; i < n; i++) s[i - len] = s[i];           n -= len;           s[n] =   0 ;         } else           len++;       }       printf( %s n , s);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long arr[200000];   int main() {     int n, cnt = 0, cntz = 0;     scanf( %d , &n);     for (int i = 0; i < n; ++i) {       scanf( %lld , &arr[i]);       if (arr[i] < 0)         cnt++;       else if (arr[i] == 0)         cntz++;     }     if (cnt % 2 == 0 && cntz == 0)       for (int i = 0; i < n - 1; ++i) printf( 1 %d %d n , i + 1, i + 2);     else if (cnt % 2 == 1 && cntz == 0) {       long long mx = (-1e9) - 1, mxi = -1;       for (int i = 0; i < n; ++i)         if (arr[i] < 0 && mx < arr[i]) {           mx = arr[i];           mxi = i;         }       printf( 2 %lld n , mxi + 1);       vector<int> ans;       for (int i = 0; i < n; ++i)         if (i != mxi) ans.push_back(i);       for (int i = 1; i < ans.size(); ++i)         printf( 1 %d %d n , ans[i - 1] + 1, ans[i] + 1);     } else if (cnt % 2 == 0 && cntz >= 1) {       vector<int> idx;       for (int i = 0; i < n; ++i)         if (arr[i] == 0) idx.push_back(i);       for (int i = 1; i < idx.size(); ++i)         printf( 1 %d %d n , idx[i - 1] + 1, idx[i] + 1);       if (idx.size() >= 1 && cntz != n) printf( 2 %d n , idx.back() + 1);       vector<int> ans;       for (int i = 0; i < n; ++i)         if (arr[i] != 0) ans.push_back(i);       for (int i = 1; i < ans.size(); ++i)         printf( 1 %d %d n , ans[i - 1] + 1, ans[i] + 1);     } else if (cnt % 2 == 1 && cntz >= 1) {       long long mx = (-1e9) - 1, mxi = -1;       vector<int> idx;       for (int i = 0; i < n; ++i) {         if (arr[i] == 0) idx.push_back(i);         if (arr[i] < 0 && mx < arr[i]) {           mx = arr[i];           mxi = i;         }       }       idx.push_back(mxi);       sort(idx.begin(), idx.end());       for (int i = 1; i < idx.size(); ++i)         printf( 1 %d %d n , idx[i - 1] + 1, idx[i] + 1);       if (idx.size() != n) printf( 2 %d n , idx.back() + 1);       vector<int> ans;       for (int i = 0; i < n; ++i)         if (i != mxi && arr[i] != 0) ans.push_back(i);       for (int i = 1; i < ans.size(); ++i)         printf( 1 %d %d n , ans[i - 1] + 1, ans[i] + 1);     } else {       for (int i = 0; i < n - 1; ++i) printf( 1 %d %d n , i + 1, i + 2);     }     return 0;   }