malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include<bits/stdc++.h>   using namespace std;   using ll = long long;   const ll nax = 1e5 + 69;   int n;   vector<ll>possible;   void fun(ll *a,int l,int r,ll *pref){    if(l>r || l<0 || r>n)     return;    possible.push_back(pref[r+1]-pref[l]);    if(a[r]==a[l])     return;    int mid = (a[l] + a[r])/2;    int ind = lower_bound(a,a+n,mid+1)-a;    fun(a,l,ind-1,pref);    fun(a,ind,r,pref);   }   int main(){       ios_base::sync_with_stdio(false);       cin.tie(NULL);       int t;       cin>>t;       while(t--)       {         int q;           cin>>n>>q;           ll a[n];           ll pref[n+1];           pref[0] = 0;           for (int i = 0; i < n; ++i)            cin>>a[i];           sort(a,a+n);           for (int i = 0; i < n; ++i)            pref[i+1] = pref[i] + a[i];           fun(a,0,n-1,pref);           sort(possible.begin(),possible.end());           //for (auto i : possible)           // cout<<i<<   ;           //cout<<endl;           while(q--){            ll s;            cin>>s;            auto it = lower_bound(possible.begin(),possible.end(),s);            if(it!=possible.end() && *it==s)             cout<< Yes n ;            else             cout<< No n ;           }           possible.clear();       }           return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 101010 * 2;   vector<int> vec[maxn];   vector<int> mp[maxn];   bool vis[maxn];   int arr[maxn];   int dfs(int x) {     vis[x] = true;     int ans = vec[x].size();     int siz = mp[x].size();     for (int i = 0; i < siz; i++) {       int y = mp[x][i];       if (vis[y]) continue;       ans = max(ans, dfs(y));     }     return ans;   }   int main() {     int n, q;     scanf( %d%d , &n, &q);     for (int i = 1; i <= n; i++) {       scanf( %d , &arr[i]);       vec[arr[i]].push_back(i);     }     int ans = 0, las = 0, pos = 0;     int maxv = 0;     for (int i = 1; i <= n; i++) {       if (las != arr[i] && las) {         if (vec[arr[i]][0] < pos || maxv > i)           mp[arr[i]].push_back(las), mp[las].push_back(arr[i]);       }       las = arr[i], pos = i;       int siz = vec[arr[i]].size();       maxv = max(maxv, vec[arr[i]][siz - 1]);     }     for (int i = 1; i <= n; i++) {       if (vis[i]) continue;       ans += dfs(i);     }     printf( %d n , n - ans);   }
#include <bits/stdc++.h>   using namespace std;   long long int power(long long int a, long long int n) {     if (n == 1) {       return (a);     }     if (n == 0) {       return 1;     }     long long int c = power(a, n / 2);     if (n % 2 == 0) {       return (c * c);     } else {       return c * c * a;     }   }   long long int func(int n, long long int k) {     long long int x = power(2, n - 1);     if (n == 1) return 1;     if (k == x) {       return n;     }     if (k < x) {       return func(n - 1, k);     } else {       return func(n - 1, k - x);     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n;     long long int k;     cin >> n >> k;     cout << func(n, k) << endl;   }
#include <bits/stdc++.h>   int main() {     int n, m, p, q, a, b;     scanf( %d %d %d %d , &n, &m, &p, &q);     scanf( %d %d , &a, &b);     int u = q - m, v = p - n;     if (u < 0) u = -u;     if (v < 0) v = -v;     if ((u) % b == 0 && (v) % a == 0) {       int c = u / b - v / a;       if (c < 0) c = -c;       if (c % 2 == 0)         printf( YES n );       else         printf( NO n );     } else       printf( NO n );   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1000000007;   const int INF = int(1e9);   const int MAX = 100007;   int dp[MAX][3], n;   string s;   int main() {     ios_base::sync_with_stdio(false);     cin >> n >> s;     dp[0][1] = dp[0][0] = dp[0][2] = 1;     for (int i = 1; i < s.size(); i++) {       dp[i][0] = dp[i - 1][0] + (s[i] != s[i - 1]);       dp[i][1] = max(dp[i - 1][0] + (s[i] == s[i - 1]),                      dp[i - 1][1] + (s[i] != s[i - 1]));       dp[i][2] = max(dp[i - 1][1] + (s[i] == s[i - 1]),                      dp[i - 1][2] + (s[i] != s[i - 1]));     }     cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));     return 0;   }
#include <bits/stdc++.h>   int cal(int x) {     int sum = 0;     for (int i = 1; i < x; i++) {       sum = sum + i;     }     return sum;   };   char x[101][101];   using namespace std;   int main() {     int n, c1 = 0, c2 = 0, total1 = 0, total2 = 0;     cin >> n;     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         cin >> x[i][j];         if (x[i][j] ==  C ) c1++;       }       total1 = total1 + cal(c1);       c1 = 0;     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         if (x[j][i] ==  C ) c2++;       }       total2 = total2 + cal(c2);       c2 = 0;     }     cout << total1 + total2;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void action() {     string s;     cin >> s;     reverse(s.begin(), s.end());     long long c = 0, f = 0, j;     for (long long i = 0; i < s.length(); i++) {       if (s[i] ==  1 ) {         f++;       }       if (i % 2 == 0) c++;     }     if (f > 1)       cout << c;     else {       if ((s.length()) % 2 == 0)         cout << c;       else         cout << c - 1;     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     action();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main(int argc, char** argv) {     int n, k;     std::cin >> n >> k;     int s[n + 1];     for (int i = 1; i < n + 1; ++i) {       std::cin >> s[i];     }     if (k >= n)       std::cout << s[n];     else {       int max = s[n];       for (int i = 1; i <= (n - k); ++i) {         int temp = s[i] + s[2 * (n - k) + 1 - i];         if (max < temp) {           max = temp;         }       }       std::cout << max;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1e9 + 7;   const long long inf = 1e18;   const long long N = 2e2 + 5;   long long n;   long long a[N];   void solve(long long id) {     cin >> n;     for (long long i = 0; i < n; i++) {       cin >> a[i];     }     long long odd = 0, even = 0;     long long oddind = 0, evenind = 0;     for (long long i = 0; i < n; i++) {       if (i % 2 != a[i] % 2) {         if (i % 2) {           oddind++;           even++;         } else {           evenind++;           odd++;         }       }     }     if (oddind == odd) {       cout << odd << endl;     } else       cout <<  -1  << endl;   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     long long t = 1;     cin >> t;     for (long long i = 1; i <= t; i++) solve(i);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     for (int tt = 0; tt < int(t); tt++) {       int n;       cin >> n;       map<int, int> c;       for (int i = 0; i < int(n); i++) {         int pi;         cin >> pi;         c[-pi]++;       }       vector<int> pp;       for (auto p : c) pp.push_back(p.second);       bool ok = false;       int g = pp[0];       int i = 1;       int s = 0;       while (s <= g && i < pp.size()) s += pp[i++];       if (g < s) {         int b = 0;         while (b <= g && i < pp.size()) b += pp[i++];         while (i < pp.size() && g + s + b + pp[i] <= n / 2) b += pp[i++];         if (g < b && g + s + b <= n / 2) {           ok = true;           cout << g <<     << s <<     << b << endl;         }       }       if (!ok) cout << 0 <<     << 0 <<     << 0 << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n;     cin >> n;     for (int i = 0; i < n / 4; i++) {       cout <<  bbaa ;     }     if (n % 4 == 1) {       cout <<  b ;     }     if (n % 4 == 2) {       cout <<  bb ;     }     if (n % 4 == 3) {       cout <<  bba ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, kol = 0, sum = 0, a;     cin >> n >> m;     for (int i = 0; i < n; i++) {       cin >> a;       if (sum + a > m) {         kol++;         sum = a;       } else         sum += a;     }     cout << kol + 1;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 100;   vector<int> v[maxn];   pair<long long, long long> a[maxn];   long long q[maxn], siz[maxn];   bool c[maxn];   long long n, m, k;   set<pair<long long, long long> > s;   map<pair<long long, long long>, bool> mark;   int main() {     ios_base::sync_with_stdio(false);     cin >> n >> m >> k;     for (long long y = 0; y < m; y++) {       cin >> a[y].first >> a[y].second;       v[a[y].first].push_back(a[y].second), v[a[y].second].push_back(a[y].first);       siz[a[y].second]++, siz[a[y].first]++;     }     for (long long y = 1; y <= n; y++)       s.insert(pair<long long, long long>(siz[y], y));     for (long long y = m - 1; y >= 0; y--) {       if (y != m - 1 && !mark[a[y + 1]]) {         mark[pair<long long, long long>(a[y + 1].second, a[y + 1].first)] =             mark[pair<long long, long long>(a[y + 1].first, a[y + 1].second)] = 1;         long long i = a[y + 1].second;         siz[i]--;         if (c[i] == 0) {           pair<long long, long long> x =               pair<long long, long long>(siz[i] + 1, i);           s.erase(x);           x.first--;           s.insert(x);         }         i = a[y + 1].first;         siz[i]--;         if (c[i] == 0) {           pair<long long, long long> x =               pair<long long, long long>(siz[i] + 1, i);           s.erase(x);           x.first--;           s.insert(x);         }       }       while (s.size() != 0) {         pair<long long, long long> x = *s.begin();         if (x.first >= k) break;         s.erase(x);         c[x.second] = 1;         for (long long ii = 0; ii < v[x.second].size(); ii++) {           long long i = v[x.second][ii];           if (!mark[pair<long long, long long>(x.second, i)]) {             mark[pair<long long, long long>(x.second, i)] =                 mark[pair<long long, long long>(i, x.second)] = 1;             siz[i]--;             siz[x.second]--;             if (!c[i]) {               pair<long long, long long> z =                   pair<long long, long long>(siz[i] + 1, i);               s.erase(z);               z.first--;               s.insert(z);             }           }         }       }       q[y] = s.size();     }     for (long long y = 0; y < m; y++) cout << q[y] << endl;   }
#include <bits/stdc++.h>   using namespace std;   int dep[100005], present[100005];   int main() {     int n, p;     scanf( %d , &n);     for (int i = 2; i <= n; ++i) {       scanf( %d , &p);       present[dep[i] = dep[p] + 1] ^= 1;     }     printf( %d n , accumulate(present, present + n + 1, 1));   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e6 + 10;   int cnt[maxn];   int check(int k) {     if (k == 0) return 1;     long long d = 1, ans = maxn;     while (d < maxn) d <<= 1;     while (d >>= 1)       if (ans - d >= 0)         if ((ans - d) * (ans - d - 1) >= 2 * k) ans -= d;     if (ans * (ans - 1) != 2 * k) return -1;     return ans;   }   int main() {     int a, b, c, d;     cin >> a >> b >> c >> d;     int aa = check(a), dd = check(d);     if (aa == -1 || dd == -1) return cout <<  Impossible  << endl, 0;     bool safe = false;     if (aa == 1 || dd == 1) {       if (b + c == 0) safe = true;     }     if (!safe && (b + c) != aa * dd) return cout <<  Impossible  << endl, 0;     if (safe) {       if (aa == 1) aa = 0;       if (dd == 1) dd = 0;     }     if (aa == 0) {       if (dd == 0) dd = 1;       for (int i = 0; i < dd; ++i) cout << 1;       return 0;     }     if (dd == 0) {       if (aa == 0) aa = 1;       for (int i = 0; i < aa; ++i) cout << 0;       return 0;     }     int f = dd - (b + aa - 1) / aa;     for (int i = 0; i < f; ++i) cout << 1;     int m = b % aa;     for (int i = 0; i < aa; ++i) {       if (m && i == m) cout << 1;       cout << 0;     }     f = b / aa;     for (int i = 0; i < f; ++i) cout << 1;     return 0;   }
#include  bits/stdc++.h    using namespace std;   #define int  long long   #define yes  YES n    #define no  NO n    const int M = 1000000007;      signed main(){       ios_base::sync_with_stdio(0);cin.tie(0);       int T;       cin >> T;       //T = 1;       while(T--){               int n, k;               cin >> n >> k;               int r;               cout << 0 << endl;               cin >> r;               if(r!=1){                   for(int i = 1;i <= n-1;i++){                       cout << (i^(i-1)) << endl;                       cin >> r;                       if(r==1)                           break;                   }               }       }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     int n;     cin >> n;     int arr[n];     for (int i = (int)(0); i <= (int)(n - 1); i++) {       cin >> arr[i];     }     int hash1[100005] = {0};     for (int i = (int)(0); i <= (int)(n / 2 - 1); i++) {       if (arr[i] - i > 0) hash1[arr[i] - i]++;     }     for (int i = (int)(n / 2); i <= (int)(n - 1); i++) {       if (arr[i] - (n - i - 1) > 0) hash1[arr[i] - (n - i - 1)]++;     }     int cnt = 0, val = 0;     for (int i = (int)(1); i <= (int)(100000); i++) {       if (cnt < hash1[i]) {         cnt = hash1[i];         val = i;       }     }     cout << n - cnt <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f;   const int MaxN = 3e5 + 5;   map<int, int> mp;   struct node {     int x, y;   } arr[MaxN], brr[MaxN];   struct qnode {     int x, y;     bool operator>(const qnode &p) const { return p.y > y; }   } st;   bool cmp(node b, node c) {     if (b.x == c.x) return b.y < c.y;     return b.x < c.x;   }   int main() {     int n, m, u, v, pp;     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) scanf( %d , &pp), mp[pp] = i;     int x = -1, y = inf;     for (int i = 0; i < m; i++) {       scanf( %d%d , &u, &v);       arr[i].x = min(mp[u], mp[v]);       arr[i].y = max(mp[u], mp[v]);     }     sort(arr, arr + m, cmp);     priority_queue<qnode, vector<qnode>, greater<qnode> > pq;     for (int i = 0; i < m; i++) {       if (pq.empty()) {         st.x = arr[i].x, st.y = arr[i].y;         pq.push(st);         continue;       }       while (!pq.empty() && arr[i].y <= pq.top().y) {         pq.pop();       }       st.x = arr[i].x, st.y = arr[i].y;       pq.push(st);     }     int num = 0;     while (!pq.empty()) {       st = pq.top();       pq.pop();       brr[num].x = st.x, brr[num].y = st.y, num++;     }     long long p = (long long)(brr[num - 1].x) * (n - brr[num - 1].y + 1);     for (int i = num - 1; i >= 1; i--)       p += (long long)(brr[i - 1].x - brr[i].x) * (n - brr[i - 1].y + 1);     long long ans = (long long)n + (long long)n * (n - 1) / 2;     printf( %I64d n , ans - p);   }
#include <bits/stdc++.h>   using namespace std;   template <typename T1, typename T2>   inline void chkmin(T1 &x, T2 y) {     if (x > y) x = y;   }   template <typename T1, typename T2>   inline void chkmax(T1 &x, T2 y) {     if (x < y) x = y;   }   inline int readChar();   template <class T = int>   inline T readInt();   template <class T>   inline void writeInt(T x, char end = 0);   inline void writeChar(int x);   inline void writeWord(const char *s);   static const int buf_size = 4096;   inline int getChar() {     static char buf[buf_size];     static int len = 0, pos = 0;     if (pos == len) {       pos = 0, len = fread(buf, 1, buf_size, stdin);     }     if (pos == len) {       return -1;     }     return buf[pos++];   }   inline int readChar() {     int c = getChar();     while (c <= 32) {       c = getChar();     }     return c;   }   template <class T>   inline T readInt() {     int s = 1, c = readChar();     T x = 0;     if (c ==  - ) s = -1, c = getChar();     while ( 0  <= c && c <=  9 ) x = x * 10 + c -  0 , c = getChar();     return s == 1 ? x : -x;   }   static int write_pos = 0;   static char write_buf[buf_size];   inline void writeChar(int x) {     if (write_pos == buf_size)       fwrite(write_buf, 1, buf_size, stdout), write_pos = 0;     write_buf[write_pos++] = x;   }   template <class T>   inline void writeInt(T x, char end) {     if (x < 0) writeChar( - ), x = -x;     char s[24];     int n = 0;     while (x || !n) s[n++] =  0  + x % 10, x /= 10;     while (n--) writeChar(s[n]);     if (end) writeChar(end);   }   inline void writeWord(const char *s) {     while (*s) writeChar(*s++);   }   struct Flusher {     ~Flusher() {       if (write_pos) fwrite(write_buf, 1, write_pos, stdout), write_pos = 0;     }   } flusher;   using namespace std;   const int MAXN = 100228;   int n, m;   int a[MAXN], ans[MAXN], lp[MAXN];   vector<pair<int, int> > vq[MAXN];   int main() {     n = readInt(), m = readInt();     for (int i = 0; i < n; ++i) {       lp[i] = -1;     }     for (int i = 0; i < m; ++i) {       int l = readInt(), r = readInt();       l--, r--;       lp[r] = l;     }     int q = readInt();     for (int i = 0; i < q; ++i) {       int x = readInt(), y = readInt();       x--, y--;       vq[y].push_back({x, i});     }     for (int i = 0; i < n; ++i) {       a[i] = i;     }     for (int i = 0; i < n; ++i) {       int x = lp[i];       for (int j = 0; j <= x; ++j) {         a[j] = a[j] >= x ? i : a[j];       }       for (auto p : vq[i]) {         ans[p.second] = a[p.first];       }     }     for (int i = 0; i < q; ++i) {       writeInt(ans[i] + 1,   n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 1e6 + 1;   const int MOD = 1e9 + 7;   struct node {     int n4, n7, n47, n74;   };   bool tab[MAX], lazy[4 * MAX];   int n, q;   node seg[4 * MAX];   void build(int v = 1, int l = 0, int r = n - 1) {     if (l == r) {       seg[v].n7 = tab[l];       seg[v].n4 = !tab[l];       seg[v].n47 = seg[v].n74 = 1;       return;     }     int mid = (l + r) / 2;     build(2 * v, l, mid);     build(2 * v + 1, mid + 1, r);     seg[v].n7 = seg[2 * v].n7 + seg[2 * v + 1].n7;     seg[v].n4 = seg[2 * v].n4 + seg[2 * v + 1].n4;     seg[v].n47 = max(max(seg[2 * v].n4 + seg[2 * v + 1].n47,                          seg[2 * v].n7 + seg[2 * v + 1].n7),                      seg[2 * v].n47 + seg[2 * v + 1].n7);     seg[v].n74 = max(max(seg[2 * v].n74 + seg[2 * v + 1].n4,                          seg[2 * v].n7 + seg[2 * v + 1].n7),                      seg[2 * v].n7 + seg[2 * v + 1].n74);   }   void up(int v, int l, int r, int a, int b) {     if (lazy[v]) {       swap(seg[v].n4, seg[v].n7);       swap(seg[v].n47, seg[v].n74);       if (l != r) {         lazy[2 * v + 1] = !lazy[2 * v + 1];         lazy[2 * v] = !lazy[2 * v];       }       lazy[v] = 0;     }     if (l > b || r < a) return;     if (l >= a && r <= b) {       swap(seg[v].n4, seg[v].n7);       swap(seg[v].n47, seg[v].n74);       if (l != r) {         lazy[2 * v + 1] = !lazy[2 * v + 1];         lazy[2 * v] = !lazy[2 * v];       }       return;     }     int mid = (l + r) / 2;     up(2 * v, l, mid, a, b);     up(2 * v + 1, mid + 1, r, a, b);     seg[v].n7 = seg[2 * v].n7 + seg[2 * v + 1].n7;     seg[v].n4 = seg[2 * v].n4 + seg[2 * v + 1].n4;     seg[v].n47 = max(max(seg[2 * v].n4 + seg[2 * v + 1].n47,                          seg[2 * v].n7 + seg[2 * v + 1].n7),                      seg[2 * v].n47 + seg[2 * v + 1].n7);     seg[v].n74 = max(max(seg[2 * v].n74 + seg[2 * v + 1].n4,                          seg[2 * v].n7 + seg[2 * v + 1].n7),                      seg[2 * v].n7 + seg[2 * v + 1].n74);   }   int main() {     cin.tie(0);     ios_base::sync_with_stdio(0);     cin >> n >> q;     for (int i = 0; i < n; ++i) {       char x;       cin >> x;       tab[i] = ((x -  0 ) & 1);     }     build();     while (q--) {       string s;       cin >> s;       if (s[0] ==  c )         cout << seg[1].n47 <<   n ;       else {         int a, b;         cin >> a >> b;         up(1, 0, n - 1, a - 1, b - 1);       }     }   }
#include <bits/stdc++.h>   using namespace std;   int dirx[8] = {1, 0, -1, 0, 1, -1, -1, 1};   int diry[8] = {0, 1, 0, -1, 1, 1, -1, -1};   string str1, str2;   int main() {     int n, m;     cin >> n >> m;     cin >> str1 >> str2;     if (str1[0] ==  >  && str2[0] ==  v  || str1[0] ==  <  && str2[0] ==  ^ )       cout <<  NO ;     else if (str1[0] ==  >  && str2[m - 1] ==  ^  ||              str1[0] ==  <  && str2[m - 1] ==  v )       cout <<  NO ;     else if (str1[n - 1] ==  >  && str2[0] ==  ^  ||              str1[n - 1] ==  <  && str2[0] ==  V )       cout <<  NO ;     else if (str1[n - 1] ==  >  && str2[m - 1] ==  v  ||              str1[n - 1] ==  <  && str2[m - 1] ==  ^ )       cout <<  NO ;     else       cout <<  YES ;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int n, m;     cin >> n >> m;     int arr[n], brr[m];     for (int i = 0; i < n; i++) {       cin >> arr[i];     }     for (int i = 0; i < m; i++) {       cin >> brr[i];     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (arr[i] == brr[j]) {           cout <<  YES  <<   n ;           cout << 1 <<     << arr[i] <<   n ;           return;         }       }     }     cout <<  NO  <<   n ;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     ;     int t = 1;     cin >> t;     while (t--) solve();   }
#include <bits/stdc++.h>   using namespace std;   void i1d(vector<long long> &v) {     for (auto &i : v) cin >> i;   }   void p1d(vector<long long> &v) {     for (auto i : v) cout << i <<    ;     cout << endl;   }   long long t;   void solve() {     cin >> t;     while (t--) {       long long n;       cin >> n;       string s;       cin >> s;       set<long long> o, z;       map<long long, long long> ans;       for (long long i = 0; i <= n - 1; i++) {         if (s[i] ==  0 )           z.insert(i);         else           o.insert(i);       }       long long ctr = 0;       long long ptr1 = 0, ptr2 = 0;       for (long long i = 0; i <= n - 1; i++) {         if (s[i] ==  0 ) {           auto it = o.upper_bound(i);           if (ans.count(i) == 0) ans[i] = ++ctr;           if (it != o.end()) {             ans[*it] = ans[i];             o.erase(it);           }         } else {           auto it = z.upper_bound(i);           if (ans.count(i) == 0) ans[i] = ++ctr;           if (it != z.end()) {             ans[*it] = ans[i];             z.erase(it);           }         }       }       cout << ctr <<   n ;       for (long long i = 0; i <= n - 1; i++) {         cout << ans[i] <<    ;       }       cout <<   n ;     }   }   int main() {     ios::sync_with_stdio(false);     solve();   }
#include <bits/stdc++.h>   using namespace std;   using nagai = long long;   using ll = long long;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int n;     cin >> n;     int c = 0;     int t = 1;     while (t <= n) {       n -= t, ++c, t *= 2;     }     if (n) ++c;     cout << c <<   n ;     return 0;   }