malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     vector<vector<pair<int, string> > > rg(m, vector<pair<int, string> >(1));     for (int i = 0; i < n; i++) {       string sn;       int r, s;       cin >> sn;       scanf( %d %d , &r, &s);       rg[r - 1].push_back(make_pair(s, sn));     }     for (int i = 0; i < m; i++) {       rg[i][0] = make_pair(-10,  xD );       sort(rg[i].begin(), rg[i].end());       reverse(rg[i].begin(), rg[i].end());       cout << (rg[i][1].first == rg[i][2].first                    ?  ?                     : string(rg[i][0].second +     + rg[i][1].second))            << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1000000007;   long long POW(long long a, long long b, long long MMM = MOD) {     long long ret = 1;     for (; b; b >>= 1, a = (a * a) % MMM)       if (b & 1) ret = (ret * a) % MMM;     return ret;   }   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   long long lcm(long long a, long long b) {     if (a == 0 || b == 0) return a + b;     return a * (b / gcd(a, b));   }   int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};   int ddx[] = {0, 0, 1, 1, 1, -1, -1, -1}, ddy[] = {1, -1, 1, 0, -1, 1, 0, -1};   vector<int> v[2];   vector<pair<int, int> > ans;   int main() {     v[0].push_back(0);     v[1].push_back(0);     int n;     scanf( %d , &n);     for (int(i) = (1); (i) <= (n); (i) += (1)) {       int x;       scanf( %d , &x);       v[x - 1].push_back(i);     }     for (int(t) = (1); (t) <= (n); (t) += (1)) {       int cnt[2] = {0};       int now = 0, last = -1;       while (1) {         int p1 = upper_bound(v[0].begin(), v[0].end(), now) - v[0].begin() - 1;         int p2 = upper_bound(v[1].begin(), v[1].end(), now) - v[1].begin() - 1;         if (p1 + t >= v[0].size() && p2 + t >= v[1].size()) break;         int t1 = 987654321, t2 = 987654321;         if (p1 + t < v[0].size()) t1 = v[0][p1 + t];         if (p2 + t < v[1].size()) t2 = v[1][p2 + t];         if (t1 < t2) {           cnt[0]++;           last = 0;           now = t1;         } else {           cnt[1]++;           last = 1;           now = t2;         }       }       if (now == n) {         if (cnt[0] > cnt[1] && last == 0) ans.push_back(make_pair(cnt[0], t));         if (cnt[0] < cnt[1] && last == 1) ans.push_back(make_pair(cnt[1], t));       }     }     sort(ans.begin(), ans.end());     printf( %d n , ans.size());     for (auto a : ans) printf( %d %d n , a.first, a.second);   }
#include <bits/stdc++.h>   using namespace std;   int options[] = {2, 7, 2, 3, 3, 4, 2, 5, 1, 2};   int main(void) {     string s;     cin >> s;     int total = 1;     for (int i = 0; i < 2; ++i) {       total *= options[s[i] -  0 ];     }     cout << total << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[512];   int main() {     int n, t;     scanf( %d , &t);     while (t--) {       scanf( %d , &n);       for (int i = 1; i <= n; i++) scanf( %d , &a[i]);       vector<int> ans;       for (int i = 1; i <= n; i++) {         for (int j = 1; j < n - 1; j++) {           if (a[j] > a[j + 1]) {             swap(a[j], a[j + 2]);             swap(a[j], a[j + 1]);             ans.emplace_back(j);             ans.emplace_back(j);           } else if (a[j + 1] > a[j + 2]) {             swap(a[j], a[j + 1]);             swap(a[j], a[j + 2]);             ans.emplace_back(j);           }         }       }       int i;       for (i = 2; i <= n; i++)         if (a[i] < a[i - 1]) break;       if (i <= n)         printf( -1 n );       else {         printf( %d n , ans.size());         for (int x : ans) printf( %d  , x);         ;         printf(  n );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long dx[] = {-1, -1, -1, 0, 0, 1, 1, 1};   long long dy[] = {-1, 0, 1, -1, 1, -1, 0, 1};   const long double pi = 3.141592653589;   const long long mod = 1000000007;   const long long maxn = 1e5 + 5;   template <typename T>   void printv(const vector<T>& v) {     for (auto i : v) cout << i <<    ;     cout <<   n ;   }   template <typename T>   void printv(const vector<pair<T, T>>& v) {     for (auto p : v) cout <<  (  << p.first <<  ,  << p.second <<  ), ;     cout <<   n ;   }   int main() {     ios_base::sync_with_stdio(false), cin.tie(nullptr);     long long n;     string s;     cin >> n >> s;     long long open = 0, closed = 0;     for (auto i : s) {       if (i ==  ( )         open++;       else         closed++;     }     if ((n & 1) || (open != closed))       cout << -1 <<   n ;     else {       long long ans = 0;       long long ck = 0;       for (auto i : s) {         if (i ==  ( )           ck++;         else {           ck--;           if (ck < 0) {             ans += 2;           }         }       }       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100010;   int n;   struct Data {     int s, id;     bool operator<(const Data &a) const { return s < a.s; }   } da[N];   int a[N], b[N];   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) {       int s;       scanf( %d , &s);       da[i] = Data{s, i};     }     sort(da, da + n);     for (int i = 0; i < (n + 2) / 3; i++) {       a[da[i].id] = i;       b[da[i].id] = da[i].s - i;     }     int x = (n + 2) / 3;     for (int i = x; i < min(x + x, n); i++) {       a[da[i].id] = 0;       b[da[i].id] = da[i].s;     }     for (int i = x + x; i < n; i++) {       a[da[i].id] = da[i].s - (n - i - 1);       b[da[i].id] = n - i - 1;     }     puts( YES );     for (int i = 0; i < n; i++) {       printf( %d%c , a[i],    n [i == n - 1]);     }     for (int i = 0; i < n; i++) {       printf( %d%c , b[i],    n [i == n - 1]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     cin >> s;     vector<pair<long long, long long> > arr;     long long n = s.length();     for (int i = 0; i < n; i++) {       for (int j = 1; i + (2 * j) < n; j++) {         if (s[i] == s[i + j] && s[i] == s[i + (2 * j)]) {           arr.push_back(make_pair(i + (2 * j), i));           break;         }       }     }     sort(arr.begin(), arr.end());     long long cnt = 0;     for (int i = 0, j = 0; i < n; i++) {       while (j < arr.size() && arr[j].second < i) j++;       if (j == arr.size()) break;       cnt += (n - arr[j].first);     }     cout << cnt << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main(int argc, const char* argv[]) {     int n, maxf;     cin >> n;     int h[n];     for (int i = 0; i < n; i++) cin >> h[i];     maxf = h[n - 1];     h[n - 1] = 0;     for (int i = n - 2; i >= 0; i--) {       if (h[i] > maxf) {         maxf = h[i];         h[i] = 0;       } else         h[i] = maxf - h[i] + 1;     }     for (int i = 0; i < n; i++) cout << h[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 10, mod = 998244353;   int n, m, x, y;   vector<int> e[2][N];   inline void adde(int x, int y, int o) { e[o][x].push_back(y); }   inline int read() {     char ch = getchar();     int x = 0, f = 1;     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = (x << 1) + (x << 3) -  0  + ch;       ch = getchar();     }     return x * f;   }   void write(int x) {     if (x < 0) {       putchar( - );       x = -x;     }     if (x > 9) write(x / 10);     putchar(x % 10 +  0 );     return;   }   int dis[19][N];   bool vis[19][N];   queue<pair<int, int> > q;   int spfa() {     memset(dis, 63, sizeof(dis));     q.push(pair<int, int>(0, 1));     dis[0][1] = 0;     while (!q.empty()) {       int u = q.front().second, k = q.front().first;       q.pop();       vis[k][u] = 0;       for (int v : e[k & 1][u]) {         if (dis[k][v] > dis[k][u] + 1) {           dis[k][v] = dis[k][u] + 1;           if (!vis[k][v]) vis[k][v] = 1, q.push(pair<int, int>(k, v));         }       }       if (k < 18) {         if (dis[k + 1][u] > dis[k][u] + (1 << k)) {           dis[k + 1][u] = dis[k][u] + (1 << k);           if (!vis[k + 1][u]) vis[k + 1][u] = 1, q.push(pair<int, int>(k + 1, u));         }       }     }     int res = 1e9 + 7;     for (int i = 0; i <= 18; ++i) res = min(res, dis[i][n]);     return res;   }   queue<int> Q, tmp;   int diss[N];   inline int qbit(int x) {     int res = 1, t = 2;     for (; x; x >>= 1)       x & 1 ? (res = 1ll * res * t % mod) : 1, t = 1ll * t * t % mod;     return res;   }   int main() {     n = read(), m = read();     for (int i = 1; i <= m; ++i) {       x = read(), y = read();       adde(x, y, 0), adde(y, x, 1);     }     int ans = spfa();     if (ans < 1e9) return write(ans), 0;     memset(diss, 63, sizeof(diss));     diss[1] = 0, Q.push(1), tmp.push(1);     for (int k = 0;; ++k) {       while (!Q.empty()) {         int u = Q.front();         Q.pop();         if (u == n) return write((qbit(k) - 1 + diss[u]) % mod), 0;         for (int v : e[k & 1][u])           if (diss[v] > diss[u] + 1)             diss[v] = diss[u] + 1, Q.push(v), tmp.push(v);       }       while (!tmp.empty()) Q.push(tmp.front()), tmp.pop();     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long t;     cin >> t;     while (t--) {       int n, m;       cin >> n >> m;       vector<string> v(n);       for (int i = 0; i < n; i++) cin >> v[i];       int c = 0;       string ans =  -1 , temp;       for (int i = 0; i < m; i++) {         temp = v[0];         for (char j =  a ; j <=  z ; j++) {           temp[i] = j;           for (int k = 0; k < n; k++) {             c = 0;             for (int l = 0; l < m; l++)               if (v[k][l] != temp[l]) c++;             if (c > 1) break;           }           if (c <= 1) {             ans = temp;             break;           }         }         if (ans !=  -1 ) break;       }       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-6;   const double INF = DBL_MAX;   bool iszero(const double a) { return fabs(a) <= eps; }   double sqr(const double a) { return a * a; }   int sgn(const double a) {     if (a < -eps) return -1;     return (a > eps);   }   int cmp(const double a, const double b) { return sgn(a - b); }   int inint() {     int t;     scanf( %d , &t);     return t;   }   const int N = 4010;   const long long p = 1e9 + 7;   struct ll {     long long l;     ll(long long a = 0) : l(a % p) {}     ll operator+(ll a) { return (l + a.l) % p; }     ll operator+=(ll a) {       l = (l + a.l) % p;       return *this;     }     ll operator+(long long a) { return ll((l + a) % p); }     ll operator+=(long long a) {       l = (l + a) % p;       return *this;     }     ll operator*(ll a) { return ll((l * a.l) % p); }     ll operator*(long long a) { return ll((l * a) % p); }     ll operator=(long long a) {       l = a % p;       return *this;     }     ll operator=(ll a) {       l = a.l % p;       return *this;     }     long long operator*() { return l; }   };   ll C[N][N];   void init() {     for (int i = 0; i < N; i++) C[i][0] = 1;     for (int i = 1; i < N; i++)       for (int j = 1; j <= i; j++) C[i][j] = C[i - 1][j - 1] + C[i - 1][j];   }   ll a[N][N], bell[N], cnt[N];   void init2() {     a[0][0] = bell[0] = 1;     a[1][1] = bell[1] = 1;     for (int i = 2; i < N; i++) {       a[i][1] = a[i - 1][i - 1];       for (int j = 2; j <= i; j++) a[i][j] = a[i][j - 1] + a[i - 1][j - 1];       bell[i] = a[i][i];     }   }   void solve() {     int n = inint();     ll ans;     for (int i = 0; i < n; i++) ans += bell[i] * C[n][i];     cout << (*ans) << endl;   }   int main() {     init();     init2();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s;   int g, t, n;   int main() {     cin >> n >> n;     cin >> s;     int l = s.size();     for (int i = 0; i < l; i++) {       if (s[i] ==  T )         t = i;       else if (s[i] ==  G )         g = i;     }     if (g < t) swap(g, t);     int i;     if ((g - t) % n != 0) {       cout <<  NO ;       return 0;     }     for (i = t; i <= g; i += n) {       if (s[i] ==  # ) {         cout <<  NO ;         return 0;       }     }     cout <<  YES ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> me;   long long sum(long long x) { return (x * (x + 1)) / 2; }   int main() {     int k;     string s;     cin >> k >> s;     for (int i = 0; i < s.size(); i++) {       if (s[i] ==  1 ) {         me.push_back(i);       }     }     long long ans = 0, cnt = 0, idx = -1;     if (k == 0) {       for (int i = 0; i < s.size(); i++) {         if (s[i] ==  1 ) {           ans += sum(cnt);           cnt = 0;         } else {           cnt++;         }       }       ans += sum(cnt);     } else {       long long fst = -1;       for (int i = 0; i < me.size(); i++) {         long long idx = me[i];         cnt = 0;         if ((i + k - 1) == me.size() - 1) {           ans += ((idx - fst) * (s.size() - me[i + k - 1]));         } else if (i + k - 1 < me.size() - 1) {           ans += ((idx - fst) * (me[i + k] - me[i + k - 1]));         }         fst = me[i];       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void test_case() {     const int N = 55;     int n, x, y, m = 0;     cin >> n;     int arr[N][N] = {0};     map<int, pair<int, int>> pos;     deque<int> ci, sally;     vector<pair<pair<int, int>, pair<int, int>>> ans;     for (int k = 0; k < n; ++k) {       cin >> x;       ci.push_back(x);     }     int k = 0;     for (auto z : ci) {       for (int j = 0; j < z; ++j) {         cin >> arr[k][j];         sally.push_back(arr[k][j]);         pos[arr[k][j]] = {k, j};       }       k++;     }     sort(sally.begin(), sally.end());     for (int i = 0; i < n; ++i) {       for (int j = 0; j < ci.front(); ++j) {         if (pos[sally.front()].first == i && pos[sally.front()].second == j)           sally.pop_front();         else {           m++;           ans.push_back(               {{pos[sally.front()].first, pos[sally.front()].second}, {i, j}});           pos[arr[i][j]] = {pos[sally.front()].first, pos[sally.front()].second};           arr[pos[sally.front()].first][pos[sally.front()].second] = arr[i][j];           sally.pop_front();         }       }       ci.pop_front();     }     cout << m << endl;     for (auto x : ans) {       cout << x.first.first + 1 <<     << x.first.second + 1 <<                << x.second.first + 1 <<     << x.second.second + 1 << endl;     }   }   int main() {     ios_base::sync_with_stdio(false);     int t = 1;     while (t--) {       test_case();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char str[210], in[10];   int cnt[10], r[10];   int main() {     scanf( %s %s , in, str);     int l = strlen(in);     for (int i = 0; i < l; i++) {       if (in[i] ==  9 )         cnt[6]++;       else if (in[i] ==  5 )         cnt[2]++;       else         cnt[in[i] -  0 ]++;     }     l = strlen(str);     for (int i = 0; i < l; i++) {       if (str[i] ==  9 )         r[6]++;       else if (str[i] ==  5 )         r[2]++;       else         r[str[i] -  0 ]++;     }     int ans = 0x7fffffff;     for (int i = 0; i <= 9; i++) {       if (cnt[i] == 0) continue;       ans = min(ans, r[i] / cnt[i]);     }     cout << ans << endl;   }
#include<bits/stdc++.h>   #include<iostream>   #include<string>   #include<cmath>   #include<cstdio>   #include<cctype>   #include<cstring>   #include<iomanip>   #include<cstdlib>   #include<ctime>   #include<set>   #include<map>   #include<utility>   #include<queue>   #include<vector>   #include<stack>   #include<sstream>   #include<algorithm>   #define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)   #define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)   #define rep(i,n)for(int i=0,_n=n;i<n;i++)   #define ll long long   #define pii pair<int,int>   #define vi vector<int>   #define vpii vector<pii>   #define p_q priority_queue   #define m_p make_pair   #define pb push_back   #define ld long double   #define F first   #define S second   #define ull unsigned long long   #define mod 1000000007   #define md 998244353   #define x1 XZVJDFADSPFOE   #define y1 GASDIJSLDAEJF   #define x2 DFDAJKVOHKWIW   #define y2 PSFSAODSXVNMQ   #define LLINF 0x3f3f3f3f3f3f3f3fLL   #define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)   using namespace std;   inline void read(int &x)   {    short negative=1;       x=0;       char c=getchar();       while(c< 0  || c> 9 )       {     if(c== - )      negative=-1;     c=getchar();    }       while(c>= 0  && c<= 9 )           x=(x<<3)+(x<<1)+(c^48),c=getchar();       x*=negative;   }   ll qpow(ll n,ll k){    ll ans=1;    while(k){     if(k%2){      ans*=n;      ans%=mod;     }     n*=n;     n%=mod;     k/=2;    }    return ans;   }   string iots(int n)   {    string s=  ;    while(n)    {     int now=n%10;     s+=now+ 0 ;     n/=10;    }    reverse(s.begin(),s.end());    return s;   }   int stoi(string s)   {    int n=0;    rep(i,s.size())    {     n*=10;     n+=s[i]- 0 ;    }    return n;   }   int n;   int p[100100];   int pr[100100];   int suf[100100];   //pr[i]->i山峰左边能到的最远的地方 suf[i]右边    int main()   {    ios::sync_with_stdio(0);    cin>>n;    rep(i,n)cin>>p[i];     pr[0]=0;    forn(i,1,n-1)    {     if(p[i]>p[i-1])     {      pr[i]=pr[i-1];      }      else      {      pr[i]=i;     }    }    suf[n-1]=n-1;    fore(i,n-2,0)    {     if(p[i]>p[i+1])     {      suf[i]=suf[i+1];     }     else     {      suf[i]=i;     }    }    int mx=0;    rep(i,n)    {     if(pr[i]==i||suf[i]==i)continue;     if(i-pr[i]==suf[i]-i)     {      mx=max(mx,i-pr[i]);     }    }    int ans=0;    rep(i,n)    {     if(pr[i]==i||suf[i]==i)continue;     if(i-pr[i]==suf[i]-i&&i-pr[i]==mx)     {      ans++;     }    }    int cnt=0;    rep(i,n)    {     if(i-pr[i]==mx)cnt++;     if(suf[i]-i==mx)cnt++;     }     if(mx==0||mx%2==1||cnt>=3)    {     cout<<0<<endl;     return 0;    }    if(ans==1) cout<<1<<endl;    else cout<<0<<endl;    return 0;   }   //特判判全   //循环边界   //精度足够   //注意初值
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) {     while (a) b %= a, swap(a, b);     return b;   }   char x[1000005], y[1000005];   int aux[1000005][26];   int main() {     long long n, m;     cin >> n >> m;     scanf( %s %s , x, y);     int lenx = strlen(x), leny = strlen(y);     long long mdc = gcd(lenx, leny);     long long mmc = lenx / mdc * leny;     long long diff = mmc;     for (int i = (0); i < (leny); ++i) ++aux[i % mdc][y[i] -  a ];     for (int i = (0); i < (lenx); ++i) diff -= aux[i % mdc][x[i] -  a ];     cout << diff * (n * lenx / mmc) << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:1000000000 )   #pragma GCC optimize( Ofast,no-stack-protector )   using namespace std;   const int maxn = (int)3e5 + 10, mod = 998244353;   int add(int x, int y) {     x += y;     if (x >= mod) {       x -= mod;     }     return x;   }   int sub(int x, int y) {     x -= y;     if (x < 0) {       x += mod;     }     return x;   }   int mul(int x, int y) { return (long long)x * y % mod; }   int my_pow(int x, int y) {     int ans = 1;     for (; y; y >>= 1, x = mul(x, x)) {       if (y & 1) {         ans = mul(ans, x);       }     }     return ans;   }   pair<int, int> dp[maxn];   int v[maxn];   int res[maxn];   int main() {     int m;     cin >> m;     int n = 0;     int ps = 0;     for (int i = 0; i < m; i++) {       scanf( %d , &v[i]);       n += v[i];       if (v[i] > v[ps]) {         ps = i;       }     }     dp[1] = make_pair(1, 0);     dp[0] = make_pair(1, 0);     int rn = my_pow(n, mod - 2);     int rm = my_pow(m - 1, mod - 2);     for (int i = 1; i < n; i++) {       int p1 = mul(i, rn);       int p2 = sub(1, p1);       int p3 = mul(p2, rm);       int p4 = mul(p2, mul(m - 2, rm));       pair<int, int> cur = make_pair(0, sub(0, mul(i, rn)));       cur.first = add(cur.first, add(sub(0, mul(dp[i - 1].first, p1)),                                      mul(dp[i].first, sub(1, p4))));       cur.second = add(cur.second, add(sub(0, mul(dp[i - 1].second, p1)),                                        mul(dp[i].second, sub(1, p4))));       cur.first = mul(cur.first, my_pow(p3, mod - 2));       cur.second = mul(cur.second, my_pow(p3, mod - 2));       dp[i + 1] = cur;     }     pair<int, int> cur = dp[n];     cur.first += mul(m - 1, dp[0].first);     cur.second += mul(m - 1, dp[0].second);     int x = mul(sub(0, cur.second), my_pow(cur.first, mod - 2));     for (int i = 0; i <= n; i++) {       res[i] = add(mul(dp[i].first, x), dp[i].second);     }     int tot = 0;     for (int i = 0; i < m; i++) {       tot = add(tot, res[v[i]]);     }     cout << tot << endl;   }
#include <bits/stdc++.h>   using namespace std;   void init() {}   const int N = 1e6 + 34;   const int INF = 1e9 + 34;   vector<int> ans[2];   vector<int> es[N];   int n, m, v1, v2;   int c[N];   void dfs(int v, int q) {     if (c[v] && c[v] != q + 1) {       cout <<  -1 ;       exit(0);     }     if (c[v]) return;     c[v] = q + 1;     ans[q].push_back(v + 1);     for (int w : es[v]) {       dfs(w, 1 - q);     }   }   int main() {     init();     cin >> n >> m;     for (int i = 0; i < m; i++) {       cin >> v1 >> v2;       v1--;       v2--;       es[v1].push_back(v2);       es[v2].push_back(v1);     }     for (int i = 0; i < n; i++)       if (!c[i]) dfs(i, 0);     for (int i = 0; i < 2; i++) {       cout << ans[i].size() <<   n ;       for (int w : ans[i]) cout << w <<    ;       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int t = 1;     while (t--) {       int n;       cin >> n;       long long int a[n + 1];       int o = 0, idx, z = 0;       long long int maxo = -1000000007;       vector<int> v, v0;       for (long long int i = 1; i < n + 1; i++) {         cin >> a[i];         if (a[i] < 0) {           o++;           if (maxo < a[i]) {             maxo = a[i];             idx = i;           }         }         if (a[i] != 0)           v.push_back(i);         else           v0.push_back(i);       }       if (o % 2 == 1) {         v.erase(find(v.begin(), v.end(), idx));         v0.push_back(idx);         sort(v0.begin(), v0.end());       }       bool ch = 0;       if (v.size() > 0) {         for (long long int i = 0; i < v.size() - 1; i++) {           ch = 1;           cout <<  1   << v[i] <<     << v[i + 1] <<   n ;         }         if (v0.size() > 0) {           for (long long int i = 0; i < v0.size() - 1; i++) {             cout <<  1   << v0[i] <<     << v0[i + 1] <<   n ;           }           cout <<  2   << v0[v0.size() - 1] <<   n ;         }       } else {         if (idx == n) {           cout <<  2   << idx <<   n ;           for (long long int i = 1; i < v0.size() - 1; i++)             cout <<  1   << v0[i] <<     << v0[i + 1] <<   n ;         } else {           for (long long int i = 0; i < v0.size() - 1; i++)             cout <<  1   << v0[i] <<     << v0[i + 1] <<   n ;         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     string a =   , b =   , s1, s2;     cin >> s1 >> s2;     if (s1[0] ==  X )       a += s1[1];     else if (s1[1] ==  X )       a += s1[0];     else       a += s1;     if (s2[1] ==  X )       a += s2[0];     else if (s2[0] ==  X )       a += s2[1];     else {       a += s2[1];       a += s2[0];     }     cin >> s1 >> s2;     if (s1[0] ==  X )       b += s1[1];     else if (s1[1] ==  X )       b += s1[0];     else       b += s1;     if (s2[1] ==  X )       b += s2[0];     else if (s2[0] ==  X )       b += s2[1];     else {       b += s2[1];       b += s2[0];     }     if ((a[0] == b[0] && a[2] == b[2]) || (a[1] == b[0] && a[0] == b[2]) ||         (a[2] == b[0] && a[1] == b[2]))       cout <<  YES ;     else       cout <<  NO ;     return 0;   }