malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int sim(vector<int> s, int p, int x) {     s.insert(s.begin() + p, x);     int l = p, r = p;     int acum = 0;     int ans = 0;     for (;;) {       while (l >= 0 && s[l] == x) l--;       while (r <= (int)s.size() - 1 && s[r] == x) r++;       int dis = r - l - 1;       if (dis - acum >= 3) {         ans += dis - acum;         acum += dis - acum;       } else         break;       if (l == -1 || r == (int)s.size()) break;       if (s[l] == s[r]) x = s[l];     }     return ans - 1;   }   int main() {     int n, k, x;     cin >> n >> k >> x;     vector<int> ns(n);     for (int i = 0; i < n; i++) cin >> ns[i];     int ans = 0;     for (int i = 0; i <= n; i++) {       ans = max(ans, sim(ns, i, x));     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string str;     getline(cin, str);     char c = 0;     int n = str.length();     for (int i = n - 1; i >= 0; i--) {       if ((str[i] >= 65 && str[i] <= 90) || (str[i] >= 97 && str[i] <= 122)) {         c = str[i];         break;       }     }     if (c ==  a  || c ==  e  || c ==  i  || c ==  o  || c ==  u  || c ==  y  ||         c ==  A  || c ==  E  || c ==  I  || c ==  O  || c ==  U  || c ==  Y )       cout <<  YES ;     else       cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int M[3][3];     for (int i = 0; i < 3; i++) {       for (int j = 0; j < 3; j++) {         cin >> M[i][j];       }     }     for (int i = 0; i < 3; i++) {       int c = 0;       for (int j = 0; j < 3; j++) {         c = (i > 0 ? M[i - 1][j] : 0);         c += (j > 0 ? M[i][j - 1] : 0);         c += M[i][j];         c += (j < 2 ? M[i][j + 1] : 0);         c += (i < 2 ? M[i + 1][j] : 0);         if (!(c % 2))           cout << 1;         else           cout << 0;       }       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.setf(ios::fixed);     cout.precision(20);     int m;     cin >> m;     string s;     cin >> s;     int n = s.size();     vector<int> cnt(26);     vector<int> have(n);     for (int c = 0; c < 26; ++c) {       for (int i = 0; i < n; ++i) {         if (s[i] -  a  == c) {           have[i] = 1;           ++cnt[c];         }       }       bool fl = 1;       int lst = -1;       for (int i = 0; i < n; ++i) {         if (have[i]) {           fl &= (i - lst - 1 < m);           lst = i;         }       }       fl &= (n - lst - 1 < m);       if (!fl) {         continue;       } else {         int lst = -1;         int nxt = 0;         for (int i = 0; i < n; ++i) {           nxt = max(nxt, i + 1);           while (nxt < n && !have[nxt]) ++nxt;           if (have[i] && s[i] -  a  == c && nxt - lst - 1 < m) {             --cnt[c];           } else if (have[i])             lst = i;         }         for (int i = 0; i < 26; ++i) {           for (int j = 0; j < cnt[i]; ++j) {             cout << char( a  + i);           }         }         return 0;       }     }   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   T abs(T x) {     if (x < 0)       return -x;     else       return x;   }   int main() {     double A, B, C, D;     scanf( %lf%lf , &A, &B);     scanf( %lf%lf , &C, &D);     if (A * D > B * C) {       swap(A, B);       swap(D, C);     }     double l = 0, r = 1e9;     for (int T = 0; T < 200; ++T) {       double mid = (l + r) / 2.0;       bool flag = false;       double a = A - mid;       for (int i = 0; i < 2; ++i) {         double b = B - mid;         for (int j = 0; j < 2; ++j) {           double c = C - mid;           for (int u = 0; u < 2; ++u) {             double d = D - mid;             for (int v = 0; v < 2; ++v) {               if (a * d > b * c) {                 flag = true;               }               d += mid;               d += mid;             }             c += mid;             c += mid;           }           b += mid;           b += mid;         }         a += mid;         a += mid;       }       if (flag)         r = mid;       else         l = mid;     }     printf( %.12f n , l);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k;   const int maxn = 300000 + 500;   const int maxk = 5005;   const int INF = 2e9 + 100;   int a[maxn];   int d[maxk][maxk];   int main() {     scanf( %d %d , &n, &k);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);     }     int large = n % k;     int small = k - large;     int seg = n / k;     sort(a + 1, a + n + 1);     for (int i = 0; i <= k; i++)       for (int j = 0; j <= k; j++) d[i][j] = INF;     d[0][0] = 0;     for (int i = 0; i <= large; i++) {       for (int j = 0; j <= small; j++) {         int nxt = i * (seg + 1) + j * seg + 1;         if (i < large) {           int add = a[nxt + seg] - a[nxt];           d[i + 1][j] = min(d[i + 1][j], d[i][j] + add);         }         if (j < small) {           int add = a[nxt + seg - 1] - a[nxt];           d[i][j + 1] = min(d[i][j + 1], d[i][j] + add);         }       }     }     cout << d[large][small] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 5005;   int n, k, x, arr[N];   long long tree[2][17000];   void build(int pos, int l, int r, int dim) {     if (l == r) {       if (l <= k)         tree[dim][pos] = arr[l];       else         tree[dim][pos] = -1e18;       return;     }     int mid = (l + r) >> 1;     build(pos << 1, l, mid, dim);     build(pos << 1 | 1, mid + 1, r, dim);     tree[dim][pos] = max(tree[dim][pos << 1], tree[dim][pos << 1 | 1]);   }   void update(int pos, int l, int r, int x, long long v, int dim) {     if (l == r) {       tree[dim][pos] = v;       return;     }     int mid = (l + r) >> 1;     if (mid >= x)       update(pos << 1, l, mid, x, v, dim);     else       update(pos << 1 | 1, mid + 1, r, x, v, dim);     tree[dim][pos] = max(tree[dim][pos << 1], tree[dim][pos << 1 | 1]);   }   long long get(int pos, int l, int r, int qLow, int qHigh, int dim) {     if (l >= qLow && r <= qHigh) return tree[dim][pos];     int mid = (l + r) >> 1;     long long a = -1, b = -1;     if (mid >= qLow) a = get(pos << 1, l, mid, qLow, qHigh, dim);     if (mid + 1 <= qHigh) b = get(pos << 1 | 1, mid + 1, r, qLow, qHigh, dim);     return max(a, b);   }   int main() {     scanf( %d%d%d , &n, &k, &x);     for (int i = 1; i <= n; i++) scanf( %d , &arr[i]);     for (int i = 1; i <= k; i++) tree[0][i] = arr[i];     for (int i = k + 1; i <= n; i++) tree[0][i] = -1e18;     int p = 1;     for (int z = 2; z <= x; z++) {       deque<int> q;       for (int i = max(0, z - k); i < z; i++) {         while (!q.empty() && tree[!p][i] >= tree[!p][q.back()]) q.pop_back();         q.push_back(i);       }       for (int i = z; i <= n; i++) {         while (!q.empty() && q.front() < i - k) q.pop_front();         long long zorbe7 = tree[!p][q.front()];         while (!q.empty() && tree[!p][i] >= tree[!p][q.back()]) q.pop_back();         q.push_back(i);         long long ans = arr[i] + (zorbe7 < 0 ? -1e18 : zorbe7);         tree[p][i] = ans;       }       p = !p;     }     long long zorbe7 = -1e18;     for (int i = n - k + 1; i <= n; i++) zorbe7 = max(zorbe7, tree[!p][i]);     printf( %lld , zorbe7 > 0 ? zorbe7 : -1);     return 0;   }
#include <bits/stdc++.h>   char a[1001][1001];   int n, m;   int findG(int r) {     int i;     for (i = 0; i < m; i = i + 1)       if (a[r][i] ==  G ) return i;   }   int findS(int r) {     int i;     for (i = 0; i < m; i = i + 1)       if (a[r][i] ==  S ) return i;   }   int main() {     scanf( %d%d , &n, &m);     int N = n;     while (N--) {       scanf( %s , &a[N]);     }     int f[1001] = {0};     for (int l = 0; l < n; l++) {       int dif = findS(l) - findG(l);       if (dif < 0) {         printf( -1 );         return 0;       } else         f[dif] = 1;     }     int s = 0;     for (int d = 0; d < m; d++) s = s + f[d];     printf( %d , s);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double dpsm[200001][26] = {0};   double dpfm[200001][26] = {0};   double ans = 0;   int main() {     int n;     cin >> n;     string s, f;     cin >> s >> f;     dpsm[0][s[0] -  A ] = 1;     dpfm[0][f[0] -  A ] = 1;     for (int i = 0; i < 26; ++i) {       char c =  A  + i;       for (int j = 1; j < s.size(); ++j) {         if (s[j] == c) {           dpsm[j][i] = (dpsm[j - 1][i] + j + 1);         } else {           dpsm[j][i] = dpsm[j - 1][i];         }         if (f[j] == c) {           dpfm[j][i] = dpfm[j - 1][i] + j + 1;         } else {           dpfm[j][i] = dpfm[j - 1][i];         }       }     }     double r = (1.0 * (n) * (n + 1) * (2 * n + 1)) / 6.0;     for (int j = 0; j < s.size(); ++j) {       ans += 1.0 * (s.size() - j) * dpfm[j][s[j] -  A ] / r;     }     for (int j = 0; j < f.size(); ++j) {       if (f[j] == s[j]) {         ans += 1.0 * (s.size() - j) * (dpsm[j][f[j] -  A ] - j - 1) / r;       } else {         ans += 1.0 * (s.size() - j) * dpsm[j][f[j] -  A ] / r;       }     }     printf( %.9f n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string a, b;   int rs, p;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> a >> b;     if (a.size() != b.size()) return cout <<  NO , 0;     for (int i = 0; i < a.size(); i++)       if (a[i] != b[i]) rs++, p = i;     if (rs != 2) return cout <<  NO , 0;     for (int i = 0; i < a.size(); i++)       if (a[i] != b[i] && a[i] == b[p] && a[p] == b[i])         return cout <<  YES , 0;       else if (a[i] != b[i])         return cout <<  NO , 0;   }
#include <bits/stdc++.h>   using namespace std;   bool cmp(const pair<int, int> &p1, const pair<int, int> &p2) {     if (p1.first == p2.first) {       return p1.second < p2.second;     }     return p1.first > p2.first;   }   int main() {     int n, m, e, x, y;     cin >> n >> m;     std::vector<pair<int, int> > E;     for (int i = 0; i < n; ++i) {       cin >> e;       E.push_back(make_pair(e, i));     }     sort(E.begin(), E.end(), cmp);     int inv[n];     for (int i = 0; i < n; ++i) {       inv[E[i].second] = i;     }     bool isThere[n];     for (int i = 0; i < n; ++i) isThere[i] = false;     std::vector<vector<int> > adj(n);     for (int i = 0; i < m; ++i) {       cin >> x >> y;       adj[x - 1].push_back(y - 1);       adj[y - 1].push_back(x - 1);     }     long long int sum = 0;     for (int i = 0; i < n; ++i) {       int ind = E[i].second;       for (int j = 0; j < adj[ind].size(); ++j) {         if (isThere[adj[ind][j]]) continue;         sum += E[inv[adj[ind][j]]].first;       }       isThere[ind] = true;     }     cout << sum;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool Prime(int a) {     if (a == 1) return true;     for (int i = 2; i * i <= a; i++)       if (a % i == 0) return false;     return true;   }   int main() {     int t;     cin >> t;     while (t--) {       string s;       cin >> s;       int count = 0;       for (int i = 0; i < s.length(); i++)         if (s[i] ==  N ) count++;       count == 1 ? cout <<  NO  : cout <<  YES ;       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int MAXL = 40000;   pair<int, int> p[MAXL];   int Init() {     for (int i = 0; i * i < MAXL; i++) {       for (int j = i; j * j + i * i < MAXL; j++) {         int now = i * i + j * j;         p[now].first = i;         p[now].second = j;       }     }     return 0;   }   inline bool cmp(pair<int, int> a, pair<int, int> b) {     return a.first * a.first + a.second * a.second >            b.first * b.first + b.second * b.second;   }   inline bool cmp2(pair<int, int> a, pair<int, int> b) {     return atan2(a.second, a.first) < atan2(b.second, b.first) - (1e-8);   }   int L(int a, int b) { return a * a + b * b; }   int n;   int Solve() {     vector<pair<int, int> > e;     int sum = 0;     scanf( %d , &n);     for (int i = 0; i < MAXL && e.size() <= n; i++) {       if (p[i].first == 0 && p[i].second == 0) continue;       sum ^= p[i].first ^ p[i].second;       e.push_back(p[i]);     }     reverse(e.begin(), e.end());     for (vector<pair<int, int> >::iterator it = e.begin(); it != e.end(); it++) {       if (((sum ^ it->first ^ it->second) & 1) == 0) {         e.erase(it);         break;       }     }     sort(e.begin(), e.end(), cmp);     int ix = 0, iy = 0;     for (vector<pair<int, int> >::iterator it = e.begin(); it != e.end(); it++) {       int fx = 1, fy = 1;       int xx = it->first, yy = it->second;       if (ix > 0) fx = -1;       if (iy > 0) fy = -1;       if (L(fx * xx + ix, fy * yy + iy) < L(fx * yy + ix, fy * xx + iy))         *it = make_pair(fx * xx, fy * yy);       else         *it = make_pair(fx * yy, fy * xx);       ix = it->first + ix;       iy = it->second + iy;     }     sort(e.begin(), e.end(), cmp2);     puts( YES );     for (vector<pair<int, int> >::iterator it = e.begin(); it != e.end(); it++) {       printf( %d %d n , ix, iy);       ix += it->first;       iy += it->second;     }     return 0;   }   int main() {     Init();     Solve();     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:134217728 )   using namespace std;   template <class T>   T abs(T x) {     return x > 0 ? x : -x;   }   int n;   int m;   int dx[4] = {0, 1, 0, -1};   int dy[4] = {1, 0, -1, 0};   string s[5001];   vector<int> t[5001];   string ss[5001];   vector<pair<int, int> > root[4][5001];   vector<pair<int, int> > next239[4][5001];   int good(int x, int y) { return x >= 0 && y >= 0 && x < n && y < m; }   int ans[10000];   pair<int, int> get_root(int t, pair<int, int> o) {     if (root[t][o.first][o.second] == o) return o;     return root[t][o.first][o.second] = get_root(t, root[t][o.first][o.second]);   }   void merge(int t, pair<int, int> a, pair<int, int> b) {     a = get_root(t, a);     root[t][a.first][a.second] = get_root(t, b);   }   int main() {     cin >> n >> m;     for (int i = 0; i < (n); i++) cin >> s[i];     for (int i = 0; i < (n); i++)       for (int j = 0; j < (m); j++)         if (s[i][j] !=  . ) {           int c = s[i][j];           if (c ==  U ) t[i].push_back(3);           if (c ==  D ) t[i].push_back(1);           if (c ==  L ) t[i].push_back(2);           if (c ==  R ) t[i].push_back(0);         } else           t[i].push_back(-1);     for (int o = 0; o < (4); o++) {       for (int i = 0; i < (n); i++)         for (int j = 0; j < (m); j++) {           int cx = i + dx[o];           int cy = j + dy[o];           while (good(cx, cy) && s[cx][cy] ==  . ) {             cx += dx[o];             cy += dy[o];           }           if (good(cx, cy))             next239[o][i].push_back(make_pair(cx, cy));           else             next239[o][i].push_back(make_pair(n, m));         }     }     for (int o = 0; o < (4); o++)       for (int i = 0; i < (n + 1); i++) root[o][i].resize(m + 1);     for (int x = 0; x < (n); x++)       for (int y = 0; y < (m); y++)         if (s[x][y] !=  . ) {           for (int i = 0; i < (n + 1); i++)             for (int j = 0; j < (m + 1); j++)               for (int o = 0; o < (4); o++) root[o][i][j] = make_pair(i, j);           int cx = x, cy = y;           int col = 1;           while (good(cx, cy)) {             pair<int, int> tmp = get_root(t[cx][cy], next239[t[cx][cy]][cx][cy]);             if (!good(tmp.first, tmp.second)) break;             for (int o = 0; o < (4); o++) {               merge(o, make_pair(cx, cy), next239[o][cx][cy]);             }             cx = tmp.first;             cy = tmp.second;             col++;           }           ans[col]++;         }     int o = n * m;     while (ans[o] == 0) o--;     cout << o <<     << ans[o] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long n, m, ans = 0;     cin >> n;     long long boy[n];     for (long long i = 0; i < n; i++) cin >> boy[i];     cin >> m;     long long girl[m];     for (long long i = 0; i < m; i++) cin >> girl[i];     sort(boy, boy + n);     sort(girl, girl + m);     for (long long i = 0; i < n; i++) {       for (long long j = 0; j < m; j++) {         if (abs(boy[i] - girl[j]) <= 1) {           ans++;           girl[j] = 200;           break;         }       }     }     cout << ans <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int getidx(const vector<int>& ar, int x) {     return lower_bound(ar.begin(), ar.end(), x) - ar.begin();   }   inline long long GCD(long long a, long long b) {     long long n;     if (a < b) swap(a, b);     while (b != 0) {       n = a % b;       a = b;       b = n;     }     return a;   }   inline long long LCM(long long a, long long b) {     if (a == 0 || b == 0) return GCD(a, b);     return a / GCD(a, b) * b;   }   inline long long CEIL(long long n, long long d) {     return n / d + (long long)(n % d != 0);   }   inline long long ROUND(long long n, long long d) {     return n / d + (long long)((n % d) * 2 >= d);   }   inline long long POW(long long a, long long n) {     if (n < 0) return 0;     long long ret = 1;     while (n) {       if (n % 2) ret *= a;       a = a * a;       n /= 2;     }     return ret;   }   void debug_out() { cerr << endl; }   template <typename Head, typename... Tail>   void debug_out(Head H, Tail... T) {     cerr <<     << H;     debug_out(T...);   }   template <class T>   ostream& operator<<(ostream& os, vector<T> v) {     os <<  [ ;     int cnt = 0;     for (auto vv : v) {       os << vv;       if (++cnt < v.size()) os <<  , ;     }     return os <<  ] ;   }   template <class T>   ostream& operator<<(ostream& os, set<T> v) {     os <<  [ ;     int cnt = 0;     for (auto vv : v) {       os << vv;       if (++cnt < v.size()) os <<  , ;     }     return os <<  ] ;   }   template <class L, class R>   ostream& operator<<(ostream& os, pair<L, R> p) {     return os <<  (  << p.first <<  ,  << p.second <<  ) ;   }   const int INF = 0x3fffffff, MOD = 1e9 + 7;   int n;   map<int, int> dp;   set<int> non0;   void input() { cin >> n; }   int solve() {     dp[-INF] = 1, dp[INF] = 0;     non0.insert(-INF);     while (n--) {       int x;       string qur;       cin >> qur >> x;       if (qur ==  ADD ) {         auto it = dp.lower_bound(x);         --it;         dp[x] = it->second;         non0.insert(x);       } else {         auto hi = dp.find(x);         auto lo = prev(hi);         lo->second = (lo->second + hi->second) % MOD;         non0.insert(lo->first);         non0.erase(hi->first);         dp.erase(hi);         for (auto it = non0.begin(); it != non0.end();) {           if (*it == lo->first)             ++it;           else             dp[*it] = 0, it = non0.erase(it);         }       }     }     int ans = 0;     for (auto p : dp) {       ans = (ans + p.second) % MOD;     }     cout << ans <<   n ;     return 0;   }   void execute() { input(), solve(); }   int main(void) {     cin.tie(0);     ios_base::sync_with_stdio(false);     execute();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   int n, col[N], maxx, cnt[N], p[N], eid, Son, mx[N], sz[N];   long long sum, ans[N];   struct edge {     int v, nxt;   } e[N << 1];   inline void addedge(int u, int v) { e[++eid] = (edge){v, p[u]}, p[u] = eid; }   inline void dfs0(int u, int fa) {     sz[u] = 1;     for (int i = p[u]; i; i = e[i].nxt)       if (e[i].v != fa) {         int v = e[i].v;         dfs0(v, u), sz[u] += sz[v];         if (sz[v] > sz[mx[u]]) mx[u] = v;       }   }   inline void add(int u, int fa, int d) {     cnt[col[u]] += d;     if (cnt[col[u]] > maxx)       maxx = cnt[col[u]], sum = col[u];     else if (cnt[col[u]] == maxx)       sum += col[u];     for (int i = p[u]; i; i = e[i].nxt)       if (e[i].v != fa && e[i].v != Son) add(e[i].v, u, d);   }   inline void dfs(int u, int fa, int d) {     for (int i = p[u]; i; i = e[i].nxt)       if (e[i].v != fa && e[i].v != mx[u]) dfs(e[i].v, u, 0);     if (mx[u]) dfs(mx[u], u, 1), Son = mx[u];     add(u, fa, 1), Son = 0, ans[u] = sum;     if (!d) add(u, fa, -1), sum = maxx = 0;   }   int main() {     scanf( %d , &n);     for (int i = (1); i <= (n); i++) scanf( %d , &col[i]);     for (int i = (1); i <= (n - 1); i++) {       int u, v;       scanf( %d%d , &u, &v);       addedge(u, v), addedge(v, u);     }     dfs0(1, 0), dfs(1, 0, 0);     for (int i = (1); i <= (n); i++) printf( %lld  , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = acos(-1);   int main() {     double d, h, v, e;     while (scanf( %lf%lf%lf%lf , &d, &h, &v, &e) != EOF) {       double t = v / (PI * (d / 2) * (d / 2));       if (t > e) {         printf( YES n );         double ti = h / (t - e);         printf( %lf n , ti);       } else         printf( NO n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, p, w, d;   int main() {     cin >> n >> p >> w >> d;     for (long long i = 0; i < w; i++) {       if ((p - i * d) % w == 0) {         long long x = (p - i * d) / w;         if (x >= 0 && x + i <= n) {           printf( %lld %lld %lld n , x, i, n - x - i);           return 0;         }       }     }     cout <<  -1  << endl;     return 0;   }
#include <bits/stdc++.h>   const int N = 3e5;   int t, n, m, h[N], val[N];   std::set<int> adj[N], jda[N], res;   std::map<int, std::set<int>> map;   void reset() {     for (int i = 1; i <= n; ++i) {       adj[i].clear();       jda[i].clear();       h[i] = 0;       val[i] = 0;     }     map.clear();     res.clear();   }   void dfs(int u) {     if (h[u]) return;     for (int v : adj[u]) {       dfs(v);       h[u] = std::max(h[u], h[v]);     }     map[-++h[u]].insert(u);   }   void turn_off(int u) {     val[u] = n;     for (int v : adj[u]) --val[v];   }   void turn_on(int u) {     --val[u];     for (int v : adj[u])       if (!++val[v]) turn_off(v);   }   int greedy(int u) {     if (!val[u]) {       for (int v : jda[u]) assert(val[v] > 0);       --val[u];       for (int v : adj[u])         if (!val[v])           turn_on(v);         else if (~val[v])           val[v] = n;     }     return val[u];   }   void solve() {     scanf( %d%d , &n, &m);     reset();     for (int i = 0; i < m; ++i) {       int u, v;       scanf( %d%d , &u, &v);       adj[u].insert(v);       jda[v].insert(u);     }     for (int i = 1; i <= n; ++i) dfs(i);     for (auto pset : map)       for (int x : pset.second)         if (greedy(x) > 0) res.insert(x);     printf( %u n , res.size());     for (int x : res) printf( %d  , x);     printf(  n );   }   int main() {     scanf( %d , &t);     for (int i = 0; i < t; ++i) solve();   }
#include <bits/stdc++.h>   using namespace std;   struct el {     long long hp, dmg, i;   };   bool comp(el a, el b) { return (a.hp - a.dmg) > (b.hp - b.dmg); }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     long long n, a, b, i = 0;     cin >> n >> a >> b;     el sol[n];     for (i = (0); i < (n); i++) {       cin >> sol[i].hp >> sol[i].dmg;       sol[i].i = i;     }     sort(sol, sol + n, comp);     long long sum = 0;     for (i = (0); i < (n); i++) {       if (i < b)         sum += max(sol[i].hp, sol[i].dmg);       else         sum += sol[i].dmg;     }     if (b == 0) {       cout << sum <<   n ;       return 0;     }     long long x = (1LL << a);     long long res = sum;     for (i = (0); i < (n); i++) {       long long temp = res;       if (i < b) {         temp -= max(sol[i].hp, sol[i].dmg);         temp += (sol[i].hp) * x;         sum = max(sum, temp);       } else {         temp -= sol[i].dmg;         temp += sol[i].hp * x;         temp -= max(sol[b - 1].hp, sol[b - 1].dmg);         temp += sol[b - 1].dmg;         sum = max(sum, temp);       }     }     cout << sum <<   n ;     return 0;   }