malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   long long memo[100005][205];   std::pair<long long, int> pre[100005];   int n;   struct q4 {     int s, t, d, pin;     long long w;     bool operator<(const q4& wx) const {       return ((w > wx.w) || ((w == wx.w) && (d > wx.d)));     }   };   std::vector<q4> Q[100005];   std::multiset<q4> X;   long long BALLIA(int z, int m) {     if (m < 0)       return 100000000000000001;     else if (z > n)       return 0;     if (memo[z][m] != -1) return memo[z][m];     long long ans = 100000000000000001;     if (pre[z] != std::make_pair(0LL, 0))       ans = std::min(pre[z].first + BALLIA(pre[z].second + 1, m),                      BALLIA(z + 1, m - 1));     else       ans = BALLIA(z + 1, m);     memo[z][m] = ans;     return ans;   }   int main(void) {     std::ios_base::sync_with_stdio(false);     std::cin.tie(NULL);     std::cout.tie(NULL);     memset(memo, -1, sizeof(memo));     int m, k;     std::cin >> n >> m >> k;     for (int i = 1; i <= n; i++) pre[i] = std::make_pair(0LL, 0);     for (int i = 1; i <= k; i++) {       int s, t, d;       long long w;       std::cin >> s >> t >> d >> w;       Q[s].push_back({s, t, d, 1, w});       Q[t + 1].push_back({s, t, d, -1, w});     }     for (int i = 1; i <= n; i++) {       for (auto u : Q[i]) {         if (u.pin == 1)           X.insert(u);         else           X.erase(X.find({u.s, u.t, u.d, 1, u.w}));       }       if (!X.empty())         pre[i] = std::make_pair((*X.begin()).w, (*X.begin()).d);       else         pre[i] = std::make_pair(0LL, 0);     }     long long ans = BALLIA(1, m);     std::cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7;   const int MAX = 2e5 + 5;   long long dis[MAX];   int a[MAX], ans[MAX];   int pos[MAX];   vector<pair<int, int> > adj[MAX];   void dfs(int x, int idx, long long d) {     pos[idx] = x;     dis[idx] = d;     int len = lower_bound(dis, dis + idx + 1, d - a[x]) - dis - 1;     ans[pos[len]]--;     ans[x]++;     for (int i = 0; i < ((int)(adj[x]).size()); i += 1) {       dfs(adj[x][i].first, idx + 1, d + adj[x][i].second);       ans[x] += ans[adj[x][i].first];     }   }   int main(int argc, char* argv[]) {     if (argc == 2 or argc == 3) freopen(argv[1],  r , stdin);     if (argc == 3) freopen(argv[2],  w , stdout);     ios::sync_with_stdio(false);     int n, p, w;     cin >> n;     for (int i = 1; i < n + 1; i += 1) {       cin >> a[i];     }     for (int i = 2; i < n + 1; i += 1) {       cin >> p >> w;       adj[p].push_back(make_pair(i, w));     }     dis[0] = -1;     dfs(1, 1, 0);     for (int i = 1; i < n + 1; i += 1)       if (i == 1)         cout << ans[i] - 1;       else         cout <<     << ans[i] - 1;     cout << endl;     return 0;   }
#include <bits/stdc++.h>   static const int MAXN = 2e5 + 10;   int n, m;   std::pair<int, int> p[MAXN];   int x_idx[MAXN], x[MAXN];   int a_i, l_i;   inline int solve_query(int u, int len) {     while (true) {       int last_len = len;       int p = std::upper_bound(x, x + n, x[u] + len) - x - 1;       len -= (x[p] - x[u]);       int q = std::lower_bound(x, x + n, x[p] - len) - x;       len -= (x[p] - x[q]);       if (p == q)         return q;       else if (u == q)         len %= (last_len - len);       u = q;     }   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 0; i < n; ++i) {       scanf( %d , &p[i].first);       p[i].second = i + 1;     }     std::sort(p, p + n);     for (int i = 0; i < n; ++i) {       x[i] = p[i].first;       x_idx[p[i].second] = i;     }     for (int i = 0; i < m; ++i) {       scanf( %d%d , &a_i, &l_i);       printf( %d n , p[solve_query(x_idx[a_i], l_i)].second);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[100010];   int main() {     long long n;     cin >> n;     long long tmp = n;     for (int i = 2; (long long)i * i <= tmp; i++) {       if (tmp % i == 0) {         a[++a[0]] = i;         while (tmp % i == 0) {           tmp /= i;         }       }     }     if (tmp != 1) {       a[++a[0]] = tmp;     }     if (a[0] == 1) {       cout << a[1] << endl;     } else {       puts( 1 );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     long long l;     cin >> n >> l;     long long *lanterns = new long long[n];     for (long long i = 0; i < n; i++) cin >> lanterns[i];     double maxDistance = 0;     sort(lanterns, lanterns + n);     for (long long i = 0; i < n - 1; i++)       if (lanterns[i + 1] - lanterns[i] > maxDistance)         maxDistance = lanterns[i + 1] - lanterns[i];     if (maxDistance < lanterns[0] * 2) maxDistance = lanterns[0] * 2;     if (maxDistance < (l - lanterns[n - 1]) * 2)       maxDistance = (l - lanterns[n - 1]) * 2;     cout << fixed;     cout << maxDistance / 2;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int n;     cin >> n;     set<int> ms;     for (int i = 0; i < n; ++i) {       int x;       cin >> x;       if (x) ms.insert(x);     }     cout << ms.size() <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double pi = acos(-1);   void Open() {}   long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }   void PrintNumber(int n, int len) {     if (!len) return;     cout << (n & 1);   }   void PrintAllSubset(int n) {     for (int i = 0; i < (1 << n); i++) {       PrintNumber(i, n);       cout <<   n ;     }   }   void trr() {}   int main() {     std::ios_base::sync_with_stdio(0);     cin.tie(NULL);     long long n, m;     cin >> n >> m;     map<pair<int, int>, int> mpp;     map<int, int> mp;     int x, y;     vector<pair<int, int>> a(m);     for (int i = 0; i < m; i++) {       cin >> x >> y;       a[i] = {x, y};       mpp[{x, y}]++;       mpp[{y, x}]++;       mp[x]++;       mp[y]++;     }     long long h = 0;     while (true) {       int c = 0;       vector<int> r;       for (int i = 0; i < a.size(); i++) {         if (mp[a[i].first] == 0 || mp[a[i].second] == 0) continue;         if (mp[a[i].first] == 1 || mp[a[i].second] == 1) {           c++;           r.push_back(i);         }       }       for (int i = 0; i < r.size(); i++) {         mp[a[r[i]].first]--;         mp[a[r[i]].second]--;       }       if (c > 0)         h++;       else         break;     }     cout << h;   }
#include <bits/stdc++.h>   using namespace std;   bool visited[100005];   vector<long long> mp[100005];   long long res = 0;   long long ans = 0;   const long long U = 1e8 + 7;   void dfs(long long second) {     visited[second] = true;     ans++;     for (int i = 0; i < mp[second].size(); i++) {       res++;       if (visited[mp[second][i]] == false) {         dfs(mp[second][i]);       }     }   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     long long n, m;     cin >> n >> m;     memset(visited, false, sizeof visited);     for (int i = 0; i < m; i++) {       long long a, b;       cin >> a >> b;       mp[a].push_back(b);       mp[b].push_back(a);     }     long long x = 0;     for (int i = 0; i < n; i++) {       if (visited[i] == false) {         res = 0;         ans = 0;         dfs(i);         res = res / 2;         if (res == ans - 1) x++;       }     }     cout << x - 1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int m[100005], v[100005], selected[100005];   vector<pair<pair<int, int>, int> > V;   int k, n, h;   bool check(long double time) {     long double pos = 1.0;     int id = 0;     for (int i = 0; i < n; i++) {       if (V[i].first.second * 1.0 * time >= pos * h) {         selected[id++] = V[i].second;         pos += 1.0;       }     }     return (id >= k);   }   int main() {     V.clear();     cin >> n >> k >> h;     for (int i = 0; i < n; ++i) cin >> m[i];     for (int i = 0; i < n; ++i) cin >> v[i];     for (int i = 0; i < n; ++i) V.push_back(make_pair(make_pair(m[i], v[i]), i));     sort((V).begin(), (V).end());     long double l = 0, r = 1000000009, mid;     for (int i = 0; i < 200; i++) {       mid = (l + r) * 0.5;       if (check(mid))         r = mid;       else         l = mid;     }     check(r);     for (int i = 0; i < k; ++i) {       if (i != 0) cout <<    ;       cout << selected[i] + 1;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 5;   struct dsu {     int forests = 0, parent[N], groupsize[N];     void add(int x) {       parent[x] = x;       groupsize[x] = 1;       forests++;     }     int findset(int node) {       if (parent[node] == node) return node;       return parent[node] = findset(parent[node]);     }     bool issameset(int x, int y) { return findset(x) == findset(y); }     void link(int i, int j) {       int x = findset(i), y = findset(j);       if (x == y) return;       if (groupsize[x] < groupsize[y]) swap(x, y);       groupsize[x] += groupsize[y];       parent[y] = x;       forests--;     }   };   map<long long, int> mp;   map<int, vector<pair<int, int>>> e;   int main() {     ios::sync_with_stdio(0), ios_base::sync_with_stdio(0), cin.tie(0),         cout.tie(0);     ;     int n, m;     cin >> n >> m;     dsu mst;     for (int i = 1; i <= n; ++i) mst.add(i);     for (int i = 1; i <= m; ++i) {       int x, y, c;       cin >> x >> y >> c;       e[c].push_back({x, y});     }     long long sum = 0, mx = 0;     for (auto u : e) {       int add = 0;       for (auto uu : u.second) {         if (!mst.issameset(uu.first, uu.second)) {           add++;         }       }       for (auto uu : u.second) {         if (!mst.issameset(uu.first, uu.second)) {           add--;           mst.link(uu.first, uu.second);         }       }       sum += add;     }     cout << sum <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string a, b;     long long team1 = 0, team2 = 0;     cin >> a;     cin >> b;     for (int i = 0; i <= a.size(); i++) {       if ((a[i] ==  [  && b[i] ==  ( ) || (a[i] ==  8  && b[i] ==  [ ) ||           (a[i] ==  (  && b[i] ==  8 )) {         team1++;       } else if ((b[i] ==  [  && a[i] ==  ( ) || (b[i] ==  8  && a[i] ==  [ ) ||                  (b[i] ==  (  && a[i] ==  8 )) {         team2++;       }     }     if (team1 > team2) {       cout <<  TEAM 1 WINS ;     } else if (team1 < team2) {       cout <<  TEAM 2 WINS ;     } else {       cout <<  TIE ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int q;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> q;     while (q--) {       bool ch = false;       string s;       cin >> s;       if (s.size() == 1) {         if (s[0] ==  ? )           cout <<  a ;         else           cout << s;       } else {         if (s[0] ==  ? ) {           if (s[1] ==  a  || s[1] ==  b )             s[0] =  c ;           else             s[0] =  a ;         }         for (int i = 1; i < s.size(); i++) {           if (s[i] ==  ? ) {             bool a = 0, b = 0, c = 0;             if (s[i - 1] ==  a  || s[i + 1] ==  a ) a = 1;             if (s[i - 1] ==  b  || s[i + 1] ==  b ) b = 1;             if (s[i - 1] ==  c  || s[i + 1] ==  c ) c = 1;             if (!a) s[i] =  a ;             if (!b) s[i] =  b ;             if (!c) s[i] =  c ;           }         }         if (s[s.size() - 1] ==  ? ) {           if (s[s.size() - 2] ==  a  || s[s.size() - 2] ==  b )             s[s.size() - 1] =  c ;           else             s[s.size() - 1] =  a ;         }         for (int i = 0; i < s.size() - 1; i++)           if (s[i] == s[i + 1]) ch = 1;         if (!ch)           cout << s;         else           cout << -1;       }       cout <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int a[300];   int main() {     int n, k, cnt = 0;     cin >> n >> k;     for (int i = 0; i < 2 * n + 1; i++) cin >> a[i];     for (int i = 1; (i <= 2 * n - 1) && (cnt != k); i += 2) {       if (a[i] - 1 > a[i - 1] && a[i] - 1 > a[i + 1]) {         a[i]--;         cnt++;       }     }     for (int i = 0; i < 2 * n + 1; i++) cout << a[i] <<    ;     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   const int N = 1E5;   int main() {     ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);     string s;     cin >> s;     int len = s.size();     int ans = 0;     for (int i = 0; i < len; i++) {       int l = 0, r = 0;       for (int j = i; j < len; j++) {         if (s[j] ==  ( ) {           l++, r++;         } else if (s[j] ==  ) ) {           l--, r--;         } else {           l--, r++;         }         if (r < 0) break;         if (l < 0) {           l += 2;         }         if (l == 0) {           ans++;         }       }     }     cout << ans << endl;   }
/*   Author: Sanskar Agarwal   Nick: sanskaragarwal   Birla Institute Of Technology, Mesra   */   #include <bits/stdc++.h>   using namespace std;   #define ll long long int   #define endl   n    #define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);   #define F(i,a,b) for(ll i = (ll)(a); i <= (ll)(b); i++)   #define RF(i,a,b) for(ll i = (ll)(a); i >= (ll)(b); i--)   #define INF 100009   #define mod 1000000007   #define pb(x) push_back(x)   #define mp(x,y) make_pair(x,y)   #define ff first   #define ss second   #define test while(t--)solve();      void solve()   {    int n;    cin >> n;    int pos[32];    int arr[n];    memset(pos, 0, sizeof(pos));    int xo = 0;    int pre[n];    for (int i = 0; i < n; ++i)    {     cin >> arr[i];     xo ^= arr[i];     pre[i] = xo;    }    bool flag = !xo;    for (int i = 0; i < n; ++i)    {     for (int j = i + 1; j < n; ++j)     {      int sp1 = pre[i];      int sp2 = pre[j] ^ pre[i];      int sp3 = pre[n - 1] ^ pre[j];      flag |= (sp1 == sp2 && sp2 == sp3);     }    }    if (flag)     cout <<  YES  << endl;    else     cout <<  NO  << endl;   }      int main()   {   #ifndef ONLINE_JUDGE    freopen( input.txt ,  r , stdin);    freopen( output.txt ,  w , stdout);   #endif    fast    int t;    // t = 1;    cin >> t;    test;   #ifndef ONLINE_JUDGE    cout <<   nTime Elapsed :   << 1.0 * clock() / CLOCKS_PER_SEC <<   s n ;   #endif    return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 55;   int type;   const long long int mod = 1e9 + 7;   long long C[N][N];   void matrix_mul(long long A[N][N], long long B[N][N]) {     for (int i = 0; i < type; i++) {       for (int j = 0; j < type; j++) {         C[i][j] = 0;         for (int k = 0; k < type; k++) {           C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % mod;         }       }     }     for (int i = 0; i < type; i++) {       for (int j = 0; j < type; j++) {         A[i][j] = C[i][j];       }     }   }   void pow(long long A[N][N], long long m) {     long long res[N][N];     memset(res, 0, sizeof(res));     for (int i = 0; i < type; i++) res[i][i] = 1;     while (m) {       if (m & 1) matrix_mul(res, A);       matrix_mul(A, A);       m >>= 1;     }     for (int i = 0; i < type; i++) {       for (int j = 0; j < type; j++) {         A[i][j] = res[i][j];       }     }   }   int main() {     ios::sync_with_stdio(false);     long long n, m, k;     cin >> n >> m >> k;     type = m;     long long M[N][N];     for (int i = 0; i < m; i++)       for (int j = 0; j < m; j++) M[i][j] = 1;     while (k--) {       string str;       cin >> str;       char x1 = str[0];       int x1n;       char x2 = str[1];       int x2n;       if (x1 >=  a  && x1 <=  z )         x1n = x1 -  a ;       else if (x1 >=  A  && x1 <=  Z )         x1n = x1 -  A  + 26;       if (x2 >=  a  && x2 <=  z )         x2n = x2 -  a ;       else if (x2 >=  A  && x2 <=  Z )         x2n = x2 -  A  + 26;       M[x1n][x2n] = 0;     }     pow(M, n - 1);     long long sum = 0;     for (int i = 0; i < m; i++)       for (int j = 0; j < m; j++) sum = (sum + M[i][j]) % mod;     cout << sum << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class t>   inline void rd(t &s) {     s = 0;     register char c = getchar();     while (!isdigit(c)) c = getchar();     while (isdigit(c)) s = (s << 3) + (s << 1) + (c ^ 48), c = getchar();     return;   }   int ans[5050];   signed main(void) {     register int n, x1, x2, x3, x;     scanf( %d , &n);     printf( ? 1 2 n );     fflush(stdout);     scanf( %d , &x1);     printf( ? 2 3 n );     fflush(stdout);     scanf( %d , &x2);     printf( ? 1 3 n );     fflush(stdout);     scanf( %d , &x3);     ans[2] = (x1 + x2 - x3) / 2;     ans[1] = x1 - ans[2];     ans[3] = x2 - ans[2];     for (int i = 4; i <= n; ++i) {       printf( ? %d %d n , i - 1, i);       fflush(stdout);       scanf( %d , &x);       ans[i] = x - ans[i - 1];     }     printf( !  );     for (int i = 1; i <= n; ++i) printf( %d  , ans[i]);     printf(  n );     fflush(stdout);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int ZIMAX = 3005;   int n, v;   int cnt[ZIMAX];   int main() {     cin >> n >> v;     for (int i = 1; i <= n; ++i) {       int ai, bi;       cin >> ai >> bi;       cnt[ai] += bi;     }     int ans = 0;     int before = 0;     for (int i = 0; i < ZIMAX; ++i) {       int azi = before;       int ramase = v - azi;       if (ramase < 0) {         ans += v;         before = cnt[i];       } else {         azi += (cnt[i] <= ramase ? cnt[i] : ramase);         ans += azi;         before = max(0, cnt[i] - ramase);       }     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k, a[50];     scanf( %d , &n);     scanf( %d , &k);     for (int i = 0; i < n; i++) scanf( %d , &a[i]);     sort(a, a + n);     if (k > n) {       cout << -1 << endl;       return 0;     }     if (n == k) {       cout << 0 <<     << 0 << endl;       return 0;     }     if (a[n - k - 1] < a[n - k])       cout << a[n - k - 1] + 1 <<     << a[n - k - 1] + 1 << endl;     else       cout << -1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e6 + 10, mod = 1e9 + 7;   inline int ad(int x, int y) {     int ans = x + y;     if (ans > mod) ans -= mod;     return ans;   }   inline int mu(int x, int y) { return 1LL * x * y % mod; }   inline int wop(int x, int y) {     int ret = 1;     while (y) {       if (y & 1) ret = mu(ret, x);       y >>= 1;       x = mu(x, x);     }     return ret;   }   int fact[maxn], inv[maxn], lst[maxn], pr[maxn], cnt[maxn];   int num[maxn][20];   int pw[maxn], pww[maxn];   inline void prep() {     int n = maxn - 5;     fact[0] = 1;     for (int i = 1; i < n; i++) fact[i] = mu(fact[i - 1], i);     for (int i = 0; i < n; i++) inv[i] = wop(fact[i], mod - 2);     pr[0] = pr[1] = 1;     for (int i = 2; i < 300005; i++) {       if (pr[i] == 0) {         lst[i] = i;         for (int j = i * 2; j < 300005; j += i) lst[j] = i, pr[j] = 1;       }     }     for (int i = 1; i < n; i++) pw[i] = ad(mu(pw[i - 1], 2), 1);     pww[0] = 1;     for (int i = 1; i < n; i++) pww[i] = ad(pww[i - 1], pww[i - 1]);   }   inline int C(int r, int n) {     if (r < 0 || r > n) return 0;     return mu(mu(fact[n], inv[n - r]), inv[r]);   }   inline int cal(int x, int y) {     if (x < 0 || y < 1) return 0;     if (x == 0) return pw[y];     int ans = 0;     for (int i = 1; i <= y; i++)       ans = ad(ans, mu(pw[i], C(x - 1, x - 1 + y - i)));     return ans;   }   inline int f(int x, int y) {     if (y <= x) return cal(x, y);     int oth = cal(y, x);     int eq = 0;     for (int i = 0; i <= min(x, y); i++) eq = ad(eq, mu(C(i, x), C(i, y)));     oth = ad(oth, eq);     return ad(pww[x + y], mod - oth);   }   inline int ff(int x, int y) { return f(x + 1, y - 1); }   int ps[20], answer[20];   int solve(vector<int> a, bool rev) {     int n = a.size();     for (int i = 1; i <= n; i++) ps[i] = ps[i - 1] + a[i - 1];     int ans = 0;     for (int j = 1; j < n; j++) {       int tmp;       if (rev) tmp = f(ps[j] - 1, ps[n] - ps[j]);       if (!rev) tmp = ff(ps[j] - 1, ps[n] - ps[j]);       answer[j] = tmp;     }     for (int i = 0; i < n; i++) {       int sum = 0;       for (int j = i + 1; j < n; j++) sum = ad(sum, answer[j]);       ans = ad(ans, mu(sum, a[i]));     }     return ans;   }   int main() {     prep();     int n;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       int x;       scanf( %d , &x);       cnt[x]++;     }     for (int i = 1; i <= 1e6; i++) {       if (cnt[i] == 0) continue;       int cur = i;       while (cur != 1) {         int p = lst[cur], tav = 0;         while (cur % p == 0) cur /= p, tav++;         num[p][tav] += cnt[i];       }     }     int ans = 0;     for (int i = 2; i <= 300000; i++) {       if (pr[i]) continue;       vector<int> a;       int sum = 0;       for (int j = 1; j < 20; j++) sum += num[i][j];       if (sum == 0) continue;       a.push_back(n - sum);       for (int j = 1; j < 20; j++) a.push_back(num[i][j]);       ans = ad(ans, solve(a, 0));       reverse(a.begin(), a.end());       ans = ad(ans, solve(a, 1));     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> e[200005], E[200005], v;   int vis[200005];   inline void dfs(int u) {     if (vis[u]) return;     vis[u] = 1;     v.push_back(u);     int x = E[u][0], y = E[u][1];     if (e[x][0] == e[u][0] || e[x][0] == e[u][1] || e[x][1] == e[u][1] ||         e[x][1] == e[u][0])       dfs(x);     dfs(y);   }   int main(int argc, char** argv) {     int n;     cin >> n;     for (int i = 1; i <= n; i++) {       int x, y;       cin >> x >> y;       e[i].push_back(y);       e[i].push_back(x);       E[x].push_back(i);       E[y].push_back(i);     }     dfs(1);     for (int i = v.size() - 1; i >= 0; i--) cout << v[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int n;     cin >> n;     string s1;     cin >> s1;     vector<pair<char, int> > v;     long long int sz = s1.size();     long long int j = 0;     while (j < sz) {       char ch = s1[j];       if (v.empty() || v.back().first != ch)         v.push_back({ch, 1});       else         v.back().second++;       j++;     }     long long int ans;     if (v.front().second > 1) {       ans = v.front().second - 1;     } else       ans = 1;     string s2 =   ;     s2 += v.front().first;     long long int f = 0;     for (long long int i = 1; i < v.size(); i++) {       if (f) {         s2 += v[i].first;         f = 0;       } else {         if (v[i].second == 1) {           s2 += v[i].first;           f = 1;         } else {           s2 += v[i].first;           s2 += v[i].first;         }       }     }     long long int sz2 = s2.size();     if (sz2 == 0 || sz2 % 2 == 0) {       cout << n - sz2 << endl;       cout << s2 << endl;     } else {       cout << n - sz2 + 1 << endl;       s2[sz2 - 1] =   0 ;       long long int j = 0;       while (j < sz2 - 1) {         cout << s2[j];         j++;       }     }     return 0;   }