malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   int main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     int n;     cin >> n;     string s;     cin >> s;     vector<long long int> col;     int zero = 0, one = 0;     col.push_back(0);     for (int i = 1; i < s.size(); i++) {       if (s[i] >= s[zero]) {         col.push_back(0);         zero = i;       } else {         if (s[i] < s[one] && one != 0) {           cout <<  NO ;           return 0;         } else {           col.push_back(1);           one = i;         }       }     }     cout <<  YES  <<   n ;     for (auto i : col) cout << i;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int x, y;     cin >> x >> y;     if (y == 0) {       cout <<  No  << endl;       return 0;     }     y = y - 1;     if (y >= 1) {       x = x - y;       if (x >= 0 && x % 2 == 0) {         cout <<  Yes  << endl;       } else {         cout <<  No  << endl;       }     } else {       if (x == 0) {         cout <<  Yes  << endl;       } else         cout <<  No  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bitset<1000001> L, R;   vector<int> H1, H2, V1, V2, res;   multiset<int> AA, BB;   int A[1000], B[1000];   bool solve(int *A, int s, int e, int S) {     int m = (s + e) >> 1;     if (s == e || S == 0) {       if (S) res.push_back(A[m]);       return true;     }     for (int i = 0; i <= S; i++) L[i] = R[i] = 0;     L[0] = R[0] = 1;     for (int i = s; i <= m; i++) L |= L << A[i];     for (int i = e; i > m; i--) R |= R << A[i];     for (int i = 0; i <= S; i++)       if (L[i] && R[S - i]) {         solve(A, s, m, i);         solve(A, m + 1, e, S - i);         return true;       }     return false;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ((void)0);     ((void)0);     ((void)0);     int T, N, M;     for (cin >> T; T--;) {       int H = 0, V = 0, x = 0, y = 0;       cin >> N;       AA.clear();       BB.clear();       for (int i = 0; i < N; i++) {         cin >> A[i];         H += A[i];         AA.insert(A[i]);       }       cin >> M;       for (int i = 0; i < M; i++) {         cin >> B[i];         V += B[i];         BB.insert(B[i]);       }       if ((H & 1) || (V & 1) || N != M || N == 1 || M == 1) {         cout <<  No n ;         continue;       }       sort(A, A + N);       sort(B, B + M);       res.clear();       if (!solve(A, 0, N - 1, H / 2)) {         cout <<  No n ;         continue;       }       H1.clear();       H2.clear();       for (auto v : res) {         H1.push_back(v);         AA.erase(AA.find(v));       }       for (auto v : AA) H2.push_back(v);       res.clear();       if (!solve(B, 0, M - 1, V / 2)) {         cout <<  No n ;         continue;       }       V1.clear();       V2.clear();       for (auto v : res) {         V1.push_back(v);         BB.erase(BB.find(v));       }       for (auto v : BB) V2.push_back(v);       if (V1.size() > V2.size()) swap(V1, V2);       if (H1.size() < H2.size()) swap(H1, H2);       reverse(V1.begin(), V1.end());       reverse(V2.begin(), V2.end());       cout <<  Yes n ;       for (auto &v : V1) v *= -1;       for (auto &h : H2) H1.push_back(-h);       for (auto v : V2) V1.push_back(v);       for (int i = 0; i < N; i++) {         y += V1[i];         cout << x <<     << y <<   n ;         x += H1[i];         cout << x <<     << y <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, x;     long long k, count = 0;     char c;     cin >> n >> x;     for (int i = 1; i <= n; i++) {       cin >> c >> k;       if (c ==  + ) {         x += k;       } else {         if (x >= k) {           x -= k;         } else {           count++;         }       }     }     cout << x <<     << count;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long int temp, i, j, k, T;   int main() {     int n, a, b;     cin >> n >> a >> b;     int h[2007];     for (i = 0; i < n; i++) cin >> h[i];     sort(h, h + n);     int val = h[b - 1];     if (h[b] == val)       cout <<  0  << endl;     else       cout << h[b] - val << endl;     return 0;   }
#include <bits/stdc++.h>   void unionInit(int d[], int s) {     int i;     for (i = 0; i < s; i++) d[i] = i;   }   int unionGet(int d[], int n) {     int t = n, k;     while (d[t] != t) t = d[t];     while (d[n] != n) k = d[n], d[n] = t, n = k;     return n;   }   int unionConnect(int d[], int a, int b) {     a = unionGet(d, a);     b = unionGet(d, b);     if (a == b) return 0;     d[a] = b;     return 1;   }   int main() {     int i, j, k, l, m, n;     int ind[110000];     int res;     while (scanf( %d%d , &n, &m) == 2) {       unionInit(ind, n);       res = 1;       while (m--) {         scanf( %d%d , &i, &j);         i--;         j--;         if (unionConnect(ind, i, j) == 0) res = (res * 2) % 1000000009;         printf( %d n , (res + 1000000009 - 1) % 1000000009);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int arr[n];     for (int i = 0; i < n; i++) {       cin >> arr[i];     }     sort(arr, arr + n);     int ans = n;     if (arr[0] == 0) {       ans--;     }     for (int i = 1; i < n; i++) {       if (arr[i] == 0) {         ans--;       } else if (arr[i] == arr[i - 1]) {         ans--;       }     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long int t, n;   int main() {     cin >> n >> t;     long long int k = 0;     long long int a, b;     long long int res1 = 1;     long long int res;     cin >> a >> b;     long long int m = (t - a) / b;     if (a >= t)       res = a;     else if (m * b + a == t)       res = t;     else       res = (m + 1) * b + a;     for (int i = 1; i < n; i++) {       cin >> a >> b;       m = (t - a) / b;       if (a >= t) {         if (a < res) {           res = a;           res1 = i + 1;         }       } else if (m * b + a == t) {         res = t;         res1 = i + 1;       } else if ((m + 1) * b + a < res) {         res = (m + 1) * b + a;         res1 = i + 1;       }     }     cout << res1;   }
#include <bits/stdc++.h>   #pragma GCC optimize(2)   using namespace std;   const int man = 2e5 + 10;   const long long mod = 1e9 + 7;   struct edge {     int v;     int w;     int next;   } e[man << 1];   int head[man];   int cnt;   void init(int n) {     memset(head, 0, sizeof(int) * (n + 5));     cnt = 0;   }   void add(int u, int v, int w) {     e[++cnt].next = head[u];     e[cnt].v = v;     e[cnt].w = w;     head[u] = cnt;   }   int vis[man];   int dfs(int u, int fa) {     int num = 0;     int cnt = 0;     for (int i = head[u]; i; i = e[i].next) {       if (e[i].v == fa) continue;       ++cnt;       int tp = dfs(e[i].v, u);       num += tp;       vis[i] = tp;     }     if (!cnt) num++;     return num;   }   struct node {     long long w;     int cnt, va;     bool operator<(const node &a) const {       return 1ll * (va / 2 + va % 2) * cnt < 1ll * (a.va / 2 + a.va % 2) * a.cnt;     }   };   signed main() {     int t;     scanf( %d , &t);     while (t--) {       int n;       long long s = 0;       long long sum = 0;       scanf( %d%lld , &n, &s);       for (int i = 1; i < n; ++i) {         int u, v, w;         scanf( %d%d%d , &u, &v, &w);         add(u, v, w);         add(v, u, w);       }       dfs(1, 1);       priority_queue<node> q;       for (int i = 1; i <= cnt; ++i) {         if (vis[i] == 0) continue;         sum += 1ll * e[i].w * vis[i];         q.push(node{1ll * e[i].w * vis[i], vis[i], e[i].w});       }       if (sum <= s) {         cout << 0 <<   n ;       } else {         int cnt = 0;         while (q.size()) {           node tp = q.top();           q.pop();           ++cnt;           int tpva = tp.va / 2 + tp.va % 2;           sum -= 1ll * tpva * tp.cnt;           tp.va -= tpva;           tp.w = 1ll * tp.cnt * tp.va;           if (tp.va) q.push(tp);           if (sum <= s) break;         }         cout << cnt <<   n ;       }       memset(vis, 0, sizeof(int) * (cnt + 5));       init(n);     }     return 0;   }
#include <queue>   #include <cstdio>   #include <algorithm>   const int Maxn=200;   const int Maxl=40;   const int Mod=998244353;   int n,m;   namespace Trie{    struct Trie_Node{     int ch[26];     bool pos;    }node[Maxl+5];    int id_tot;    void insert(char *s,int len){     int root=0;     for(int i=1;i<=len;i++){      if(node[root].ch[s[i]- a ]==0){       node[root].ch[s[i]- a ]=++id_tot;      }      root=node[root].ch[s[i]- a ];     }     node[root].pos=1;    }   }   struct Node{    int id,x,y;    Node(int _id=0,int _x=0,int _y=0){     id=_id,x=_x,y=_y;    }   };   std::queue<Node> q;   int id[Maxl+5][Maxl+5],id_tot;   int get_id(int x,int y){    if(x>y){     std::swap(x,y);    }    if(id[x][y]==0){     id[x][y]=++id_tot;     q.push(Node(id[x][y],x,y));    }    return id[x][y];   }   struct Matrix{    int a[Maxn+5][Maxn+5];    void init(){     for(int i=1;i<=id_tot;i++){      for(int j=1;j<=id_tot;j++){       a[i][j]=0;      }     }    }    friend Matrix operator *(Matrix a,Matrix b){     Matrix ans;     ans.init();     for(int i=1;i<=id_tot;i++){      for(int k=1;k<=id_tot;k++){       for(int j=1;j<=id_tot;j++){        ans.a[i][j]=(ans.a[i][j]+1ll*a.a[i][k]*b.a[k][j])%Mod;       }      }     }     return ans;    }   }g;   int main(){    scanf( %d%d ,&n,&m);    for(int i=1;i<=n;i++){     static char s[Maxl+5];     scanf( %s ,s+1);     int len=0;     while(s[++len]!=  0 );     len--;     Trie::insert(s,len);    }    get_id(0,0);    while(!q.empty()){     Node u=q.front();     q.pop();     for(int i=0;i<26;i++){      int a=Trie::node[u.x].ch[i],b=Trie::node[u.y].ch[i];      if(a==0||b==0){       continue;      }      g.a[u.id][get_id(a,b)]++;      if(Trie::node[a].pos){       g.a[u.id][get_id(0,b)]++;      }      if(Trie::node[b].pos){       g.a[u.id][get_id(a,0)]++;      }      if(Trie::node[a].pos&&Trie::node[b].pos){       g.a[u.id][get_id(0,0)]++;      }     }    }    Matrix ans;    ans.init();    for(int i=1;i<=id_tot;i++){     ans.a[i][i]=1;    }    while(m){     if(m&1){      ans=ans*g;     }     g=g*g;     m>>=1;    }    printf( %d n ,ans.a[1][1]);    return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k, m, x, y, ans;   bool b;   int main() {     scanf( %d%d , &n, &k);     ans = n * 2 - k - 1;     for (int i = 1; i <= k; i++) {       scanf( %d , &m);       b = 0;       for (int j = 1; j <= m; j++) {         scanf( %d , &x);         if (j == 1 && x == 1) b = 1;         if ((b) && j > 1 && x > y + 1) {           ans -= (j - 2) * 2;           b = 0;         }         if ((b) && j == m) ans -= (m - 1) * 2;         y = x;       }     }     printf( %d , ans);   }
#include <bits/stdc++.h>   using namespace std;   const int N = -1;   const int INF = 1.01e9;   const int MOD = 1e9 + 7;   long long rev(long long a, long long m) {     if (a == 0) return 0;     return ((1 - rev(m % a, a) * m) / a + m) % m;   }   int main() {     int n, k;     scanf( %d%d , &n, &k);     vector<long long> fact(n + 1);     fact[0] = 1;     for (int i = 1; i <= n; i++) {       fact[i] = (fact[i - 1] * i) % MOD;     }     vector<long long> rfact(n + 1);     rfact[n] = rev(fact[n], MOD);     assert(fact[n] * rfact[n] % MOD == 1);     for (int i = n - 1; i >= 0; i--) {       rfact[i] = (rfact[i + 1] * (i + 1)) % MOD;     }     auto getC = [&](int nn, int kk) {       assert(0 <= kk && kk <= nn);       return fact[nn] * rfact[kk] % MOD * rfact[nn - kk] % MOD;     };     vector<long long> f(n + 1);     vector<long long> g(n + 1);     vector<long long> prefG(n + 1);     f[1] = 1;     g[1] = 1;     prefG[1] = 1;     for (int i = 2; i <= n; i++) {       long long tmp = prefG[i - 1];       if (i - k - 1 >= 1) {         tmp = (tmp - prefG[i - k - 1] + MOD) % MOD;       }       tmp = (tmp * fact[i - 2]) % MOD;       f[i] = tmp;       g[i] = f[i] * rfact[i - 1] % MOD;       prefG[i] = (prefG[i - 1] + g[i]) % MOD;     }     long long answer = 0;     for (int i = 1; i <= n; i++) {       answer = (answer + getC(n - 1, i - 1) * f[i] % MOD * fact[n - i]) % MOD;     }     cout << (fact[n] - answer + MOD) % MOD << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int paths[5001][5001];   int ct[5001], top[5001], freq[5001];   int main() {     for (int i = 2; i <= 5000; i++) {       for (int j = 2; j <= 5000; j++) {         paths[i][j] = paths[i - 1][j];       }       int tmp = i;       for (int j = 2; j <= sqrt(tmp); j++) {         while (tmp > 0 && tmp % j == 0) {           tmp /= j;           paths[i][j]++;         }       }       if (tmp > 1) paths[i][tmp]++;     }     ios_base::sync_with_stdio(0);     cin.tie(0);     int n;     cin >> n;     for (int i = 0; i < n; i++) {       int k;       cin >> k;       ct[k]++;     }     long long sol = 0;     fill(top, top + 5001, 1);     for (int i = 1; i <= 5000; i++) {       if (!ct[i]) continue;       for (int j = 1; j <= 5000; j++) {         sol += 1LL * paths[i][j] * ct[i];         if (paths[i][j]) top[i] = j;       }     }     while (true) {       memset(freq, 0, sizeof freq);       for (int i = 1; i <= 5000; i++) {         if (!ct[i]) continue;         freq[top[i]] += ct[i];       }       int most = max_element(freq, freq + 5001) - freq;       if (freq[most] * 2 <= n || most == 1) break;       sol -= freq[most];       sol += n - freq[most];       for (int i = 1; i <= 5000; i++) {         if (top[i] != most) {           top[i] = 1;         }         if (top[i] == 1) continue;         paths[i][top[i]]--;         while (top[i] > 1 && paths[i][top[i]] == 0) {           top[i]--;         }       }     }     cout << sol <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   using namespace std;   int main() {     long long int k, b, n, t;     while (cin >> k >> b >> n >> t) {       long long int s = 1;       long long int cas = 0;       while (s <= t && cas < n) {         s = s * k + b;         cas++;       }       if (cas == n && s <= t)         cout << 0 << endl;       else         cout << n - cas + 1 << endl;     }     return 0;   }
#include <bits/stdc++.h>   const int maxn = 100005;   int nbs[maxn], ev[maxn * 2], next[maxn * 2], color[maxn], d[maxn], ans[maxn],       size[2], view[maxn], n, m, k;   void addedge(int x, int y) {     next[++k] = nbs[x];     ev[k] = y;     nbs[x] = k;   }   void init() {     scanf( %d%d , &n, &m);     for (int i = 0; i < m; ++i) {       int x, y;       scanf( %d%d , &x, &y);       addedge(x, y);       addedge(y, x);       ++d[x];       ++d[y];     }   }   void dfs(int x, int col) {     color[x] = col;     ++size[col];     for (int i = nbs[x]; i; i = next[i]) {       if (color[ev[i]] == -1) dfs(ev[i], col ^ 1);     }   }   void output(int x) {     int y = 0;     for (int i = 1; i <= n; ++i) {       if (!ans[i] && color[i] == 0) {         ans[i] = x;         ++y;         if (y % 3 == 0) ++x;       }     }     for (int i = 1; i <= n; ++i) {       if (!ans[i] && color[i] == 1) {         ans[i] = x;         ++y;         if (y % 3 == 0) ++x;       }     }     printf( YES n );     for (int i = 1; i <= n; ++i) printf( %d  , ans[i]);     printf(  n );   }   void solve(int x, int y = 1) {     memset(view, 0, sizeof(view));     ans[x] = y;     for (int i = nbs[x]; i; i = next[i]) view[ev[i]] = 1;     int k = 0;     for (int i = 1; i <= n && k < 2; ++i) {       if (!ans[i] && color[i] != color[x] && !view[i]) {         ans[i] = y;         ++k;       }     }   }   void work() {     memset(color, -1, sizeof(color));     for (int i = 1; i <= n; ++i) {       if (color[i] == -1) dfs(i, 0);     }     if (size[0] % 3 == 0)       output(1);     else {       int col = size[0] % 3 - 1, find = 0;       for (int i = 1; i <= n && !find; ++i) {         if (color[i] == col && d[i] + 2 <= size[col ^ 1]) {           solve(i);           find = 1;         }       }       if (find)         output(find + 1);       else {         col ^= 1;         int t = 0;         for (int i = 1; i <= n && find < 2; ++i) {           if (color[i] == col && d[i] + 2 <= size[col ^ 1]) {             solve(i, find + 1);             ++find;           }         }         if (find == 2)           output(find + 1);         else           printf( NO n );       }     }   }   int main() {     init();     work();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<int> s(n), r(n);     for (int i = 0; i < n; i++) {       cin >> s[i] >> r[i];     }     vector<tuple<int, int, int>> T(n);     for (int i = 0; i < n; i++) {       T[i] = make_tuple(s[i], r[i], i);     }     sort(T.begin(), T.end(), greater<tuple<int, int, int>>());     vector<int> id(n);     for (int i = 0; i < n; i++) {       s[i] = get<0>(T[i]);       r[i] = get<1>(T[i]);       id[i] = get<2>(T[i]);     }     int mx = -1, ms = -1;     vector<int> s2, r2, id2;     vector<vector<int>> p;     int n2 = 0;     for (int i = 0; i < n; i++) {       if (r[i] > mx) {         mx = r[i];         ms = s[i];         s2.push_back(s[i]);         r2.push_back(r[i]);         id2.push_back(id[i]);         p.push_back(vector<int>(0));         n2++;       } else if (r[i] == mx && s[i] == ms) {         p.back().push_back(id[i]);       }     }     stack<int> st;     st.push(0);     if (n2 > 1) {       st.push(1);     }     for (int i = 2; i < n2; i++) {       while (st.size() >= 2) {         int b = st.top();         st.pop();         int a = st.top();         st.pop();         long long A =             (long long)s2[i] * r2[a] * (r2[b] - r2[i]) * (s2[b] - s2[a]);         long long B =             (long long)s2[a] * r2[i] * (r2[a] - r2[b]) * (s2[i] - s2[b]);         if (A <= B) {           st.push(a);           st.push(b);           break;         } else {           st.push(a);         }       }       st.push(i);     }     vector<int> ans;     while (!st.empty()) {       int x = st.top();       st.pop();       ans.push_back(id2[x]);       for (int y : p[x]) {         ans.push_back(y);       }     }     sort(ans.begin(), ans.end());     int cnt = ans.size();     for (int i = 0; i < cnt; i++) {       cout << ans[i] + 1;       if (i < cnt - 1) {         cout <<    ;       }     }     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t, i, j;     char c =  W ;     cin >> t;     for (i = 0; i < t; i++) {       for (j = 0; j < t; j++) {         cout << c;         if (c ==  B )           c =  W ;         else           c =  B ;       }       if (t % 2 == 0) {         if (c ==  B )           c =  W ;         else           c =  B ;       }       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1000 * 1000 * 1000 + 7;   inline long long mod(long long n) {     if (n < 0) {       return (n % MOD + MOD) % MOD;     } else {       return n % MOD;     }   }   long long fp(long long a, long long p) {     long long ans = 1, cur = a;     for (long long i = 0; (1ll << i) <= p; ++i) {       if ((p >> i) & 1) ans = mod(ans * cur);       cur = mod(cur * cur);     }     return ans;   }   long long dv(long long a, long long b) { return mod(a * fp(b, MOD - 2)); }   const long long N = 103;   long long m[N][N], ans[N][N], t[N][N];   void add(long long a[N][N], long long b[N][N]) {     for (long long i = 0; i < N; ++i) {       for (long long j = 0; j < N; ++j) {         t[i][j] = 0;       }     }     for (long long i = 0; i < N; ++i) {       for (long long j = 0; j < N; ++j) {         for (long long k = 0; k < N; ++k) {           t[i][j] = mod(t[i][j] + a[i][k] * b[k][j]);         }       }     }     for (long long i = 0; i < N; ++i) {       for (long long j = 0; j < N; ++j) {         a[i][j] = t[i][j];       }     }   }   void pw(long long p) {     for (long long i = 0; i < N; ++i) ans[i][i] = 1;     for (long long i = 0; (1ll << i) <= p; ++i) {       if ((p >> i) & 1) add(ans, m);       add(m, m);     }   }   bool a[N];   long long cnt[2];   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     long long n, k;     cin >> n >> k;     for (long long i = 0; i < n; ++i) {       cin >> a[i];       ++cnt[a[i]];     }     long long l = cnt[0];     long long r = n - l;     long long op = n * (n - 1) / 2;     for (long long l1 = 0; l1 <= cnt[0] && l1 <= cnt[1]; ++l1) {       long long l0 = l - l1;       long long r0 = cnt[0] - l0;       long long r1 = cnt[1] - l1;       m[l1][l1] = op;       if (l1) {         m[l1][l1 - 1] = mod(l1 * r0);         m[l1][l1] = mod(m[l1][l1] - m[l1][l1 - 1]);       }       m[l1][l1 + 1] = mod(l0 * r1);       m[l1][l1] = mod(m[l1][l1] - m[l1][l1 + 1]);     }     pw(k);     long long sum = 0;     for (long long i = 0; i < l; ++i) sum += a[i];     cout << dv(ans[sum][0], fp(op, k)) <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1000000007;   const long double EPS = 1e11;   const long long INFL = 1e16;   const int INF = 1e9 + 7;   mt19937 rnd((unsigned)chrono::steady_clock::now().time_since_epoch().count());   int highdig(long long x) {     int ans = 0;     while (x > 0LL) {       x /= 2LL;       ++ans;     }     return ans;   }   long long umen(long long x, vector<long long>& ea, vector<long long>& eb,                  vector<char>& ec) {     long long cx = x;     long long highdigx = 1;     while (highdigx * 2LL <= x) {       highdigx *= 2LL;     }     while (cx % highdigx != 0LL) {       ea.push_back(cx);       eb.push_back(cx);       ec.push_back( + );       cx *= 2LL;     }     ea.push_back(x);     ea.push_back(x);     eb.push_back(cx);     eb.push_back(cx);     ec.push_back( + );     ec.push_back( ^ );     long long y2 = cx + x;     long long y3 = (cx ^ x);     ea.push_back(y2);     eb.push_back(y3);     ec.push_back( ^ );     cx = (y2 ^ y3);     while (highdig(cx) > highdig(x)) {       long long ccx = x;       while (highdig(ccx) < highdig(cx)) {         ea.push_back(ccx);         eb.push_back(ccx);         ec.push_back( + );         ccx *= 2LL;       }       ea.push_back(cx);       eb.push_back(ccx);       ec.push_back( ^ );       cx ^= ccx;     }     while (highdig(cx) < highdig(x)) {       ea.push_back(cx);       eb.push_back(cx);       ec.push_back( + );       cx *= 2LL;     }     ea.push_back(x);     eb.push_back(cx);     ec.push_back( ^ );     while ((x ^ cx) % 2 == 0) {       cx = cx;     }     return (x ^ cx);   }   long long trie(long long x, vector<long long>& ea, vector<long long>& eb,                  vector<char>& ec) {     ea.push_back(x);     eb.push_back(x);     ec.push_back( + );     long long y1 = x * 2LL;     ea.push_back(x);     eb.push_back(y1);     ec.push_back( + );     long long y2 = x + y1;     ea.push_back(y1);     eb.push_back(y1);     ec.push_back( + );     ea.push_back(y2);     eb.push_back(y1 * 2LL);     ec.push_back( ^ );     long long y3 = (y2 ^ (2 * y1));     ea.push_back(y2);     eb.push_back(y3);     ec.push_back( + );     long long y4 = y2 + y3;     ea.push_back(2 * y1);     eb.push_back(y4);     ec.push_back( ^ );     for (long long cd = 2LL; x > 1LL; cd *= 2LL) {       ea.push_back(x);       eb.push_back(cd);       ec.push_back( ^ );       ea.push_back(cd);       eb.push_back(cd);       ec.push_back( + );       x ^= cd;     }     return 1LL;   }   void solve() {     long long x;     cin >> x;     vector<long long> ea, eb;     vector<char> ec;     while (x > 1LL) {       if ((x & (x + 1LL)) > 0LL) {         x = umen(x, ea, eb, ec);       } else {         x = trie(x, ea, eb, ec);       }     }     cout << ea.size() <<   n ;     for (int i = 0; i < ea.size(); ++i) {       cout << ea[i] <<     << ec[i] <<     << eb[i] <<   n ;     }   }   int main() {     int t = 1;     for (int i = 0; i < t; ++i) {       solve();     }     return 0;   }