malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   string s[8] = { vaporeon ,  jolteon ,  flareon ,  espeon ,                   umbreon ,   leafeon ,  glaceon ,  sylveon };   int f[8] = {0};   int main() {     string x;     int n, k;     scanf( %d , &n);     cin >> x;     for (int i = 0; i < 8; i++) {       if (s[i].size() != n) {         f[i] = -1;       } else {         f[i] = 1;         for (int j = 0; j < n; j++) {           if (s[i][j] == x[j]) {             f[i]++;           } else if (s[i][j] != x[j] && x[j] !=  . ) {             f[i] = -1;             break;           }         }       }     }     for (int i = 0; i < 8; i++) {       if (f[i] > -1) {         k = i;       }     }     cout << s[k];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int next_samebit(int mask) {     int lowbit = mask & -mask;     int slack = lowbit + mask;     return slack | (mask ^ slack) / lowbit / 4;   }   int n, a[16], ans[4][4], at, row[4], col[4], zig[3], tag[2];   const int mt[] = {1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1};   const int mr[] = {0, 0, 0, 0, 1, 2, 3, 2, 1, 1, 1, 3, 2, 2, 3, 3};   const int mc[] = {0, 1, 2, 3, 0, 0, 0, 1, 2, 1, 3, 1, 2, 3, 2, 3};   const int mv[] = {1, 0, 0, 2, 0, 0, 2, 2, 2, 1, 0, 0, 1, 0, 0, 1};   const int fr[] = {0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1};   const int fc[] = {0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1};   const int fv[] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1};   bool dfs(int i) {     if (i == 16) return true;     int r = mr[i], c = mc[i], v = mv[i];     for (int s = tag[mt[i]]; s; s &= s - 1) {       int x = __builtin_ctz(s);       ans[r][c] = a[x];       tag[mt[i]] ^= 1 << x, row[r] += a[x], col[c] += a[x], zig[v] += a[x];       if ((!fr[i] || row[r] == at) && (!fc[i] || col[c] == at) &&           (!fv[i] || zig[v] == at) && dfs(i + 1))         return true;       tag[mt[i]] ^= 1 << x, row[r] -= a[x], col[c] -= a[x], zig[v] -= a[x];     }     return false;   }   int main() {     scanf( %d , &n);     int m = n * n, all = 0, sum = 0;     for (int i = 0; i < m; all += a[i++]) scanf( %d , a + i);     if (n == 1) {       sum = a[0];     } else if (n == 2) {       sort(a, a + m);       do {         sum = a[0] + a[1];         if (sum == a[3] + a[4] && sum == a[0] + a[3] && sum == a[1] + a[4] &&             sum == a[0] + a[4] && sum == a[1] + a[3])           break;       } while (next_permutation(a, a + m));     } else if (n == 3) {       sort(a, a + m);       do {         sum = a[0] + a[1] + a[2];         if (sum == a[3] + a[4] + a[5] && sum == a[6] + a[7] + a[8] &&             sum == a[0] + a[3] + a[6] && sum == a[1] + a[4] + a[7] &&             sum == a[2] + a[5] + a[8] && sum == a[0] + a[4] + a[8] &&             sum == a[2] + a[4] + a[6])           break;       } while (next_permutation(a, a + m));     } else if (n == 4) {       int mask = (1 << m) - 1;       for (int s = 255; s <= mask; s = next_samebit(s)) {         for (int i = sum = 0; i < m; i++)           if (s & 1 << i) sum += a[i];         if ((all * 2 + sum) % 10) continue;         at = (all * 2 + sum) / 10;         tag[0] = mask ^ s;         tag[1] = s;         if (dfs(0)) break;       }       for (int i = 0; i < 4; i++)         for (int j = 0; j < 4; j++) a[i * n + j] = ans[i][j];       sum = a[0] + a[1] + a[2] + a[3];     }     printf( %d n , sum);     for (int i = 0; i < n; i++) {       for (int j = 0; j < n - 1; j++) printf( %d  , a[i * n + j]);       printf( %d n , a[i * n + n - 1]);     }   }
#include <bits/stdc++.h>   using namespace std;   const double PI = acos(-1);   const double eps = 1e-9;   const int inf = 2000000000;   const long long infLL = 9000000000000000000;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     int n;     cin >> n;     string second;     cin >> second;     int c = 0, d = 0;     for (auto u : second) {       if (u ==  n )         c++;       else if (u ==  z )         d++;     }     while (c--) cout << 1 <<    ;     while (d--) cout << 0 <<    ;     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     long long int t = 1;     while (t--) {       long long int n, k;       cin >> n >> k;       long long int ans = -1;       for (long long int i = 1;; i++) {         long long int p = n + ((-1) * (i)*k);         if (p < i) break;         long long int c = 0;         while (p > 0) {           if (p % 2 == 1) c++;           p /= 2;         }         if (c <= i) {           ans = i;           break;         }       }       cout << ans << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int s1, s11, s12;     int s2 = 0;     s1 = s11 = s12 = 0;     string s, c;     s = c =   ;     for (int i = 0; i < n; i++) {       int a, b;       cin >> a >> b;       if (i == 0) {         s1 = a;         s2 = 0;         s =  A ;       } else {         if (abs(s1 + a - s2) < abs(s2 + b - s1)) {           s1 += a;           s +=  A ;         } else {           s2 += b;           s +=  G ;         }       }       if (i == 0) {         s11 = 0;         s12 = b;         c =  G ;       } else {         if (abs(s11 + a - s12) < abs(s12 + b - s11)) {           s11 += a;           c +=  A ;         } else {           s12 += b;           c +=  G ;         }       }     }     if (abs(s1 - s2) <= 500) {       cout << s;       return 0;     }     if (abs(s11 - s12) <= 500) {       cout << c;       return 0;     }     cout << -1;     return 0;   }
#include <bits/stdc++.h>   #pragma gcc optimize(O3)   using namespace std;   long long INF = static_cast<long long>(2e18);   long long inf = static_cast<long long>(1e9 + 7);   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   vector<vector<set<long long> > > dp;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     long long n, k;     cin >> n >> k;     vector<long long> vals(n);     dp.resize(k, vector<set<long long> >(n));     for (auto& it : vals) cin >> it;     for (long long i = n - 2; i >= 0; --i) vals[i] += vals[i + 1];     for (long long i = n - 1; i >= 0; --i) dp[0][i].insert(vals[i]);     if (k == 1) {       cout << vals[0];       return 0;     }     long long res = 0;     for (long long i = 1; i < k; i++) {       for (long long j = n - 1 - i; j >= k - i - 1; --j) {         for (long long q = j + 1; q < n - i + 1; ++q) {           for (auto& it : dp[i - 1][q]) {             if (i == (k - 1) && (!j)) {               res = max(res, ((vals[j] - vals[q]) & it));             } else               dp[i][j].insert((vals[j] - vals[q]) & it);           }         }       }     }     cout << res;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double dp[2010][2010][2][2];   int a[2010];   pair<int, int> le[2010], ri[2010];   int ll[2010][2], rr[2010][2];   int h;   double p, q;   double go(int l, int r, int Li, int Ri) {     if (l > r) return 0;     if (dp[l][r][Li][Ri] > -1) {       return dp[l][r][Li][Ri];     }     int L = ll[l][Li], R = rr[r][Ri];     double res = 0;     int d;     if (L < le[l].second) {       d = h;     } else {       d = a[l] - L;     }     res += 0.5 * p * (d + go(l + 1, r, 0, Ri));     if (R > ri[r].second) {       d = h;     } else {       d = R - a[r];     }     res += 0.5 * q * (d + go(l, r - 1, Li, 1));     if (ri[l].second > R) {       d = R - a[l];     } else {       d = ri[l].second - a[l];     }     res += 0.5 * q * (d + go(ri[l].first + 1, r, 1, Ri));     if (le[r].second < L) {       d = a[r] - L;     } else {       d = a[r] - le[r].second;     }     res += 0.5 * p * (d + go(l, le[r].first - 1, Li, 0));     return dp[l][r][Li][Ri] = res;   }   int main() {     int n;     scanf( %d%d%lf , &n, &h, &p);     q = 1 - p;     for (int i = 0; i < n; i++) {       scanf( %d , &a[i]);     }     sort(a, a + n);     for (int i = 0; i < n; i++) {       le[i] = make_pair(0, a[0] - h);       ri[i] = make_pair(i, a[i] + h);     }     for (int i = n - 2; i >= 0; i--) {       if (a[i] + h > a[i + 1]) {         ri[i] = ri[i + 1];       } else {         ri[i] = make_pair(i, a[i] + h);       }     }     for (int i = 1; i < n; i++) {       if (a[i] - h < a[i - 1]) {         le[i] = le[i - 1];       } else {         le[i] = make_pair(i, a[i] - h);       }     }     ll[0][0] = ll[0][1] = -1001001001;     for (int i = 1; i < n; i++) {       ll[i][0] = a[i - 1];       ll[i][1] = ri[i - 1].second;     }     rr[n - 1][0] = rr[n - 1][1] = 1001001001;     for (int i = n - 2; i >= 0; i--) {       rr[i][1] = a[i + 1];       rr[i][0] = le[i + 1].second;     }     for (int i = 0; i < 2010; i++) {       for (int j = 0; j < 2010; j++) {         for (int k = 0; k < 2; k++) {           for (int l = 0; l < 2; l++) {             dp[i][j][k][l] = -1;           }         }       }     }     printf( %.12f n , go(0, n - 1, 0, 1));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> vis;   vector<pair<long long, long long>> v;   void dfs(long long x, long long y) {     pair<long long, long long> p = v[x];     vis[x] = 1;     if (x == y) return;     for (long long i = 0; i < v.size(); i++) {       if (vis[i]) continue;       if (p.first > v[i].first && p.first < v[i].second) {         dfs(i, y);       } else if (p.second > v[i].first && p.second < v[i].second) {         dfs(i, y);       }     }   }   signed main() {     ios::sync_with_stdio(0);     long long n, m, b, c;     while (cin >> n) {       v.clear();       long long mp[105][105];       for (long long i = 0; i < n; i++) {         cin >> m >> b >> c;         if (m == 2) {           vis.assign(100, 0);           dfs(b - 1, c - 1);           if (vis[c - 1]) {             cout <<  YES n ;           } else {             cout <<  NO n ;           }         }         if (m == 1) {           v.push_back(make_pair(b, c));         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1000000 + 10;   const int mod = 1e9 + 7;   int n, k, a[maxn], f[maxn], g[maxn];   int fast_pow(int a, int b) {     int ret = 1;     for (; b; b >>= 1, a = 1ll * a * a % mod)       if (b & 1) ret = 1ll * ret * a % mod;     return ret;   }   int main() {     scanf( %d%d , &n, &k);     for (int i = 1; i <= min(k + 2, n); i++)       a[i] = (a[i - 1] + fast_pow(i, k)) % mod;     if (n <= k + 2) {       printf( %d n , a[n]);       return 0;     }     int now, ans = 0;     now = f[0] = g[0] = 1;     for (int i = 1; i <= k + 2; i++) {       now = 1ll * now * (n - i) % mod;       f[i] = 1ll * f[i - 1] * i % mod;       g[i] = 1ll * -g[i - 1] * i % mod;     }     for (int i = 1; i <= k + 2; i++)       ans = (ans + 1ll * a[i] * now % mod * fast_pow(n - i, mod - 2) % mod *                        fast_pow(1ll * f[i - 1] * g[k + 2 - i] % mod, mod - 2) %                        mod) %             mod;     ans = (ans + mod) % mod;     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long bigmod(long long a, long long p) {     long long ret = 1;     while (p > 0) {       if ((p & 1)) ret = (ret * a) % 998244353LL;       p >>= 1;       a = (a * a) % 998244353LL;     }     return ret;   }   long long modinverse(long long a) { return bigmod(a, 998244353LL - 2); }   long long n, fre[300009], eng[300009], mat[300009];   vector<int> graph[300009];   void dfs(int u, int par) {     fre[u] = eng[u] = mat[u] = 0;     long long mul = 1, mul2 = 1;     for (int i = 0; i < graph[u].size(); i++) {       int v = graph[u][i];       if (v == par) continue;       dfs(v, u);       mul *= (fre[v] + eng[v]);       mul2 *= (fre[v] + 2 * eng[v]);       mul %= 998244353LL;       mul2 %= 998244353LL;     }     fre[u] = mul;     mat[u] = mul2;     for (int i = 0; i < graph[u].size(); i++) {       int v = graph[u][i];       if (v == par) continue;       eng[u] += (modinverse((fre[v] + 2 * eng[v]) % 998244353LL) * mat[v]) %                 998244353LL;     }     eng[u] %= 998244353LL;     eng[u] *= mul2;     eng[u] %= 998244353LL;   }   int main() {     scanf( %lld , &n);     int u, v;     for (int i = 1; i < n; i++) {       scanf( %d %d , &u, &v);       graph[u].push_back(v);       graph[v].push_back(u);     }     dfs(1, -1);     long long ans = (fre[1] + eng[1]) % 998244353LL;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> m >> n;     char a[n][m];     int i, j, c;     for (i = 0; i < n; i++) {       for (j = 0; j < m; j++) {         cin >> a[i][j];       }     }     char b[m][n];     for (i = 0; i < m; i++) {       for (j = 0; j < n; j++) {         b[i][j] = a[j][i];       }     }     for (i = 0; i < m; i++) {       c = 2;       while (c--) {         for (j = 0; j < n; j++) {           cout << b[i][j] << b[i][j];         }         cout << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     int cnt = 0, cur = 0;     do {       cur++;     } while (cur * 5 < n);     cnt = cur;     cur = 0;     do {       cur++;     } while (cur * 4 < n);     cnt = max(cnt, cur);     for (int i = 0; i < cnt; i++) cout << 5;     cout << 1;     cout << endl;     for (int i = 0; i < cnt; i++) cout << 4;     cout << 9;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100000 + 5, inf = 1e9 + 7;   int n, m, x, y, l, r, f[N];   struct tt {     int l, r;   } a[100];   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) {       scanf( %d%d , &x, &y);       l = max(1, x - y), r = min(m, x + y);       a[i].l = l, a[i].r = r;     }     for (int i = 1; i <= m; i++) {       f[i] = i;       for (int j = 1; j <= n; j++) {         if (a[j].l <= i && i <= a[j].r)           f[i] = min(f[i], f[i - 1]);         else if (a[j].r < i)           f[i] = min(f[i], i - a[j].r + f[max(0, a[j].l - i + a[j].r - 1)]);       }     }     printf( %d n , f[m]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = 1e18;   const int N = 300005;   vector<pair<int, int>> g[N];   int pre[N], vis[N], sz[N];   long long d[N];   void dfs1(int u, int fa) {     pre[u] = fa;     for (auto [v, w] : g[u]) {       if (v != fa) {         d[v] = d[u] + w;         dfs1(v, u);       }     }   }   long long dfs2(int u) {     long long ret = 0;     sz[u] = 1;     for (auto [v, w] : g[u]) {       if (!vis[v]) {         vis[v] = true;         ret = max(ret, dfs2(v) + w);         sz[u] += sz[v];       }     }     return ret;   }   int main(int argc, char *argv[]) {     std::ios_base::sync_with_stdio(false);     int n, m;     cin >> n >> m;     for (int i = 0; i < n - 1; i++) {       int u, v, w;       cin >> u >> v >> w;       g[u].emplace_back(v, w);       g[v].emplace_back(u, w);     }     dfs1(1, 0);     vector<int> path;     for (int i = n; i; i = pre[i]) path.push_back(i), vis[i] = 1;     reverse(path.begin(), path.end());     long long mx = -inf, now = dfs2(path[0]), now2 = -inf;     for (int i = 1; i < path.size(); i++) {       long long x = dfs2(path[i]);       if (sz[path[i]] > 2) x = inf;       if (now == 0 && x == 0) {         if (i > 1) {           mx = max(mx, now2 + x - (d[path[i]] - d[path[i - 1]]));         }       } else {         mx = max(mx, now + x - (d[path[i]] - d[path[i - 1]]));       }       now = now - (d[path[i]] - d[path[i - 1]]);       now2 = now;       now = max(now, x);     }     while (m--) {       long long x;       cin >> x;       if (x + mx >= 0)         cout << d[n] << endl;       else         cout << d[n] + x + mx << endl;     }     return 0;   }
//doing a 800 difficulty question using dynammic programming   #include<bits/stdc++.h>   #define ll long long   using namespace std;   int main(){       int t;       cin>>t;       while(t--){           ll n,m,k;           cin>>n>>m>>k;           ll dp[n][m];           for(ll i=0;i<n;i++){               for(ll j=0;j<m;j++){                   if(i==0){                       dp[i][j]=j;                   }                   if(i!=0){                       dp[i][j]=dp[i-1][j]+(j+1);                   }}}                   if(dp[n-1][m-1]==k){                       cout<< YES <<  n ;                   }                   else{                       cout<< NO <<  n ;                   }           }}
#include <bits/stdc++.h>   using namespace std;   int n, m;   vector<int> c;   vector<bool> used;   vector<vector<int> > e;   vector<vector<int> > ices;   int colors = 1;   int cur = 1;   int used_colors[1000000];   void dfs(int v) {     if (used[v]) return;     used[v] = 1;     if (ices[v].size() > colors) {       colors = ices[v].size();     }     cur++;     for (int j = 0; j < ices[v].size(); j++) {       int t = ices[v][j];       if (c[t]) {         used_colors[c[t]] = cur;       }     }     int cur_unused = 1;     for (int j = 0; j < ices[v].size(); j++) {       int t = ices[v][j];       if (!c[t]) {         while (used_colors[cur_unused] == cur) cur_unused++;         c[t] = cur_unused++;       }     }     for (int i = 0; i < e[v].size(); i++) {       dfs(e[v][i]);     }   }   int main() {     for (int i = 0; i < 1e6; i++) {       used_colors[i] = 0;     }     ios_base::sync_with_stdio(0);     cin >> n >> m;     c.resize(m + 1);     e.resize(n);     used.assign(n, 0);     ices.resize(n);     int cnt;     for (int i = 0; i < n; i++) {       cin >> cnt;       if (cnt == 0) continue;       ices[i].resize(cnt);       for (int j = 0; j < cnt; j++) {         cin >> ices[i][j];       }     }     for (int i = 0; i < n - 1; i++) {       int v, u;       cin >> v >> u;       v--, u--;       e[v].push_back(u);       e[u].push_back(v);     }     dfs(0);     cout << colors <<   n ;     for (int i = 0; i < m; i++) {       cout << max(1, c[i + 1]) <<    ;     }     cout <<   n ;   }
#include <bits/stdc++.h>   namespace my_std {   using namespace std;   inline int read() {     char c = getchar();     int ans = 0, f = 1;     while (c >  9  || c <  0 ) {       f ^= (c ==  - );       c = getchar();     }     for (; c <=  9  && c >=  0 ; c = getchar())       ans = (ans << 1) + (ans << 3) + (c ^ 48);     return f ? ans : -ans;   }   const int mod = 1e9 + 7, N = 5010;   inline void inc(int &x, const int &y) {     x += y;     if (x >= mod) x -= mod;   }   inline int ksm(int x, long long y) {     int res = 1;     for (; y; y >>= 1, x = 1ll * x * x % mod)       if (y & 1) res = 1ll * res * x % mod;     return res;   }   inline int gcd(int x, int y) {     if (x > y) swap(y, x);     return y ? gcd(y, x % y) : x;   }   }  // namespace my_std   using namespace my_std;   vector<int> e[N << 1];   int n, m, d, lv[N], ans[N], wt[N << 1], vis[N << 1];   struct People_CF1139E {     int pot, cl, lf;   } st[N];   inline bool find(int u) {     register int v;     for (register int i = (0); i <= (int(e[u].size()) - 1); ++i) {       v = e[u][i];       if (vis[v]) continue;       vis[v] = 1;       if (wt[v] == -1 || find(wt[v])) {         wt[v] = u;         return 1;       }     }     return 0;   }   int main() {     n = read(), m = read();     for (register int i = (1); i <= (n); ++i) st[i].pot = read();     for (register int i = (1); i <= (n); ++i) st[i].cl = read();     d = read();     for (register int i = (1); i <= (d); ++i) lv[i] = read(), st[lv[i]].lf = 1;     for (register int i = (1); i <= (n); ++i) {       if (!st[i].lf && st[i].pot <= m) {         e[st[i].pot].push_back(st[i].cl + m);         e[st[i].cl + m].push_back(st[i].pot);       }     }     memset(wt, -1, sizeof(wt));     for (register int i = (d); i >= (1); --i) {       for (register int j = (ans[i + 1]); j <= (m); ++j) {         memset(vis, 0, sizeof(vis));         if (!find(j)) {           ans[i] = j;           break;         }       }       if (st[lv[i]].pot > m) continue;       e[st[lv[i]].pot].push_back(st[lv[i]].cl + m);       e[st[lv[i]].cl + m].push_back(st[lv[i]].pot);     }     for (register int i = (1); i <= (d); ++i) printf( %d n , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct query {     int l, r, id, rng;     bool operator<(const query &tmp) const {       return rng != tmp.rng ? rng < tmp.rng : r < tmp.r;     }   } Q[100100];   int n, q, a[100100], b[100100], c[100100], cnt[100100], ans[100100];   int D;   vector<int> v;   void add(int x) { c[cnt[x]++]--, c[cnt[x]]++; }   void del(int x) { c[cnt[x]--]--, c[cnt[x]]++; }   int calc() {     int rlt = 0;     for (int i = 1; i <= D; i++) b[i] = c[i];     priority_queue<int> pq;     for (int i = 0; i < v.size(); i++)       if (cnt[v[i]] > D) pq.push(-cnt[v[i]]);     for (int i = 1, j = 2; i <= D; i++) {       rlt += b[i] / 2 * (2 * i);       if (i * 2 <= D)         b[i * 2] += b[i] / 2;       else {         for (int k = 1; k <= b[i] / 2; k++) pq.push(-i * 2);       }       if (b[i] & 1) {         if (j <= i) j = i + 1;         while (j <= D && !b[j]) j++;         if (j > D) {           pq.push(-i);           break;         }         rlt += i + j;         b[j]--;         if (i + j <= D)           b[i + j]++;         else           pq.push(-(i + j));       }     }     while (!pq.empty()) {       int x = pq.top();       pq.pop();       if (pq.empty()) break;       int y = pq.top();       pq.pop();       rlt -= x + y;       pq.push(x + y);     }     return rlt;   }   int main() {     scanf( %d , &n);     D = 2 * sqrt(n);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]), cnt[a[i]]++;     for (int i = 1; i <= 100000; i++) {       if (cnt[i] > D) v.push_back(i);       cnt[i] = 0;     }     scanf( %d , &q);     for (int i = 1; i <= q; i++)       scanf( %d %d , &Q[i].l, &Q[i].r), Q[i].id = i, Q[i].rng = Q[i].l / D;     sort(Q + 1, Q + q + 1);     int l = 1, r = 0;     for (int i = 1; i <= q; i++) {       while (r < Q[i].r) add(a[++r]);       while (l < Q[i].l) del(a[l++]);       while (r > Q[i].r) del(a[r--]);       while (l > Q[i].l) add(a[--l]);       ans[Q[i].id] = calc();     }     for (int i = 1; i <= q; i++) printf( %d n , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct Graph {     struct Edge {       int u, v;       int cost;       Edge(int _u, int _v, int _cost) : u(_u), v(_v), cost(_cost) {}     };     int n, m;     bool is_digraph;     vector<vector<int>> g;     vector<Edge> e;     Graph(int _n) : n(_n), m(0) {       assert(n >= 1);       g.resize(n);       set_di(false);     }     Graph(int _n, int _m, bool _di = false) : n(_n) {       assert(n >= 1);       g.resize(n);       e.reserve(_m);       m = 0;       set_di(_di);       input(_m);     }     void set_di(bool _di) {       pos = vector<int>(n, 0);       deg = vector<int>(n, 0);       is_digraph = _di;     }     vector<int> deg;     inline void add(int u, int v, int cost = 1) {       assert(0 <= u && u < n);       assert(0 <= v && v < n);       if (is_digraph) {         g[u].emplace_back(m);       } else {         deg[u]++;         deg[v]++;         g[u].emplace_back(m);         g[v].emplace_back(m);       }       e.emplace_back(u, v, cost);       m++;     }     void input(int _m) {       int u, v;       for (int i = 0; i < _m; i++) {         cin >> u >> v;         u--;         v--;         add(u, v);       }     }     vector<int> pos;     void dfs(int u) {       for (; pos[u] < g[u].size(); pos[u]++) {         int i = g[u][pos[u]];         int v = e[i].u ^ e[i].v ^ u;         dfs(v);       }     }     int k;     void dele() {       int need_del = m - (n + m + 1) / 2;       if (need_del > 0) {         int cnt = 0;         random_shuffle(e.begin(), e.end());         vector<int> d = deg;         for (auto& x : e) {           if (cnt < need_del && d[x.u] - 1 >= (deg[x.u] + 1) / 2 &&               d[x.v] - 1 >= (deg[x.v] + 1) / 2) {             d[x.u]--;             d[x.v]--;             x.cost = 0;             cnt++;           }         }         assert(cnt == need_del);         k = (n + m + 1) / 2;       } else {         k = m;       }     }     void pri() {       cout << k <<   n ;       for (auto& x : e) {         if (x.cost) cout << x.u + 1 <<     << x.v + 1 <<   n ;       }     }   };   void solve() {     int n, m;     cin >> n >> m;     Graph g(n, m);     g.dele();     g.pri();   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     solve();     cout << endl;   }