malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int n, ans = 1e9;   pair<int, int> p[1005];   void solve(int height) {     int width = 0, remain = n / 2;     vector<int> priority;     for (int i = 1; i <= n; i++)       if (p[i].second > height)         if (p[i].first > height)           return;         else if (remain) {           remain--;           width += p[i].second;         } else           return;       else if (p[i].first > height)         width += p[i].first;       else if (p[i].first > p[i].second) {         width += p[i].second;         priority.push_back(p[i].first - p[i].second);       } else         width += p[i].first;     sort(priority.rbegin(), priority.rend());     for (int i = remain; i < priority.size(); i++) width += priority[i];     ans = min(ans, width * height);   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d %d , &p[i].first, &p[i].second);     for (int i = 1; i <= 1000; i++) solve(i);     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int x, num;   } s[100009];   int mark[100009];   int cmp(node a, node b) { return a.x < b.x; }   int main() {     int n, m;     while (scanf( %d %d , &n, &m) == 2) {       int l, h;       scanf( %d %d , &l, &h);       for (int i = 0; i < n; i++) {         int a, b;         scanf( %d %d , &a, &b);         s[i].x = a * l + b * h;         s[i].num = i + 1;       }       sort(s, s + n, cmp);       int ans = 0;       int k = 0;       for (int i = 0; i < n; i++) {         m -= s[i].x;         if (m < 0) break;         ans++;         mark[k++] = s[i].num;       }       printf( %d n , ans);       for (int i = 0; i < ans; i++) {         if (i == 0)           printf( %d , mark[i]);         else           printf(  %d , mark[i]);       }       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 2000 * 100 + 1000;   vector<long long> adj[N];   long long a[N], h[N], t[N];   bool mark[N];   long long f(long long p) {     mark[p] = true;     long long ans = h[p] * a[p];     t[p] = a[p];     for (auto q : adj[p])       if (mark[q] == false) {         h[q] = h[p] + 1;         ans += f(q);         t[p] += t[q];       }     return ans;   }   long long ans = 0, sum = 0;   void calc(long long val, long long p) {     mark[p] = true;     ans = max(ans, val);     for (auto q : adj[p])       if (mark[q] == false) {         long long k = sum - 2 * t[q];         calc(val + k, q);       }   }   int32_t main() {     ios::sync_with_stdio(false);     long long n;     cin >> n;     for (long long i = 0; i < n; i++) {       cin >> a[i];       sum += a[i];     }     for (long long i = 0; i < n - 1; i++) {       long long u, v;       cin >> u >> v;       u--;       v--;       adj[u].push_back(v);       adj[v].push_back(u);     }     long long val = f(0);     for (long long i = 0; i < N; i++) mark[i] = false;     calc(val, 0);     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     cin >> s;     for (int i = 0; i < s.size(); i++) {       if (s[i] ==  1 ) continue;       if (s[i] ==  4  && s[i - 1] ==  1 ) continue;       if (s[i] ==  4  && i > 1 && s[i - 1] ==  4  && s[i - 2] ==  1 ) continue;       return cout <<  NO , 0;     }     cout <<  YES ;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 5010;   int n, m, s;   vector<int> e[N];   int low[N], dfn[N], idx;   bool vis[N];   stack<int> st;   bool in_stack[N];   int color[N], color_tot;   int indeg[N];   int ans;   void AddEdge(int u, int v) { e[u].push_back(v); }   void Dfs(int u) {     low[u] = dfn[u] = ++idx;     in_stack[u] = true;     st.push(u);     for (int v : e[u]) {       if (!dfn[v]) {         Dfs(v);         low[u] = min(low[u], low[v]);       } else if (in_stack[v]) {         low[u] = min(low[u], dfn[v]);       }     }     if (low[u] == dfn[u]) {       ++color_tot;       int v;       do {         v = st.top();         st.pop();         in_stack[v] = false;         color[v] = color_tot;       } while (v != u);     }   }   void Tarjan() {     for (int i = 1; i <= n; ++i)       if (!color[i]) Dfs(i);   }   int main() {     scanf( %d%d%d , &n, &m, &s);     for (int i = 1; i <= m; ++i) {       int u, v;       scanf( %d%d , &u, &v);       AddEdge(u, v);     }     Tarjan();     for (int i = 1; i <= n; ++i)       ;     for (int i = 1; i <= n; ++i)       for (int j : e[i])         if (color[i] != color[j]) ++indeg[color[j]];     for (int i = 1; i <= color_tot; ++i)       ;     for (int i = 1; i <= color_tot; ++i)       if (indeg[i] == 0) ++ans;     if (indeg[color[s]] == 0) --ans;     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct Edge {     int v;     char c;   } edge[220];   vector<Edge> ans;   vector<int> Chain[10];   int N;   bool flag[110];   void dfs(int x) {     for (int i = 0; i < Chain[x].size(); i++) {       int v = edge[Chain[x][i]].v, id = Chain[x][i] >> 1;       if (!flag[id]) {         flag[id] = 1;         dfs(v);         ans.push_back((Edge){id, edge[Chain[x][i]].c});       }     }   }   void print() {     for (int i = N - 1; i >= 0; i--) printf( %d %c n , ans[i].v + 1, ans[i].c);   }   int main() {     scanf( %d , &N);     for (int i = 0; i < N; i++) {       int a, b;       scanf( %d%d , &a, &b);       edge[2 * i] = (Edge){b,  + };       Chain[a].push_back(2 * i);       edge[2 * i + 1] = (Edge){a,  - };       Chain[b].push_back(2 * i + 1);     }     int u = edge[0].v, sum = 0;     for (int i = 0; i <= 6; i++)       if (1 & Chain[i].size()) u = i, sum++;     if (sum == 0 || sum == 2) {       dfs(u);       if (ans.size() == N)         print();       else         printf( No solution );     } else       printf( No solution );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   bool umin(T& a, T b) {     if (a > b) {       a = b;       return 1;     }     return 0;   }   template <class T>   bool umax(T& a, T b) {     if (a < b) {       a = b;       return 1;     }     return 0;   }   const int N = 1e3 + 9;   double dp[N][N], prob[N];   bool vis[N][N];   long long sum[22], pw[22];   double rec(int x, int y) {     umax(y, 0);     if (!x) {       if (!y) return 1.0;       return 0.0;     }     double& ret = dp[x][y];     if (vis[x][y]) return ret;     vis[x][y] = 1;     return ret = rec(x - 1, y - 1) * prob[x] + rec(x - 1, y) * (1 - prob[x]);   }   long long f(long long x) {     if (!x) return 0;     vector<int> v;     while (x >= 1) {       v.push_back(x % 10);       x /= 10;     }     reverse(v.begin(), v.end());     if (v[0] > 1) return sum[v.size()];     long long res = sum[v.size() - 1];     for (int i = 1; i < int(v.size()); i++) {       if (v[i] == 0) continue;       res += (v[i]) * 1LL * pw[v.size() - i - 1];     }     return res + 1;   }   int main() {     pw[0] = 1;     for (int i = 1; i <= 18; i++) {       pw[i] = pw[i - 1] * 10;       sum[i] = sum[i - 1] + pw[i - 1];     }     int n, k;     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       long long x, y;       scanf( %lld%lld , &x, &y);       long long res = f(y) - f(x - 1);       prob[i] = double(res) / double(y - x + 1);     }     scanf( %d , &k);     printf( %.12lf n , rec(n, (k * n + 99) / 100));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long spf[3000001];   long long fac[3000001];   void sieve() {     spf[1] = 1;     for (long long i = 2; i < 3000001; i++) spf[i] = i;     for (long long i = 4; i < 3000001; i += 2) spf[i] = 2;     for (long long i = 3; i * i < 3000001; i++) {       if (spf[i] == i) {         for (long long j = i * i; j < 3000001; j += i)           if (spf[j] == j) spf[j] = i;       }     }   }   map<long long, long long> getfactor(long long a) {     map<long long, long long> m;     while (a > 1) {       m[spf[a]]++;       a /= spf[a];     }     return m;   }   long long power(long long x, long long y, long long p) {     long long res = 1;     x = x % p;     while (y > 0) {       if (y & 1) res = (res * x) % p;       y = y >> 1;       x = (x * x) % p;     }     return res;   }   long long gcd(long long a, long long b) {     if (a == 0) return b;     return gcd(b % a, a);   }   long long inverse(long long a, long long p) { return power(a, p - 2, p); }   long long ncr(long long n, long long r, long long p) {     if (r > n) return 0;     if (r == 0) return 1;     return (fac[n] * inverse(fac[r], p) % p * inverse(fac[n - r], p) % p) % p;   }   void solve() {     long long n, k;     cin >> n >> k;     map<long long, long long> m;     for (long long i = 1; i <= n; i++) {       long long l, r;       cin >> l >> r;       m[l]++;       m[r + 1]--;     }     long long pre = 0;     for (auto it : m) {       pre += m[it.first];       m[it.first] = pre;     }     long long prev = -1e18, val = 0;     long long ans = 0;     for (auto it : m) {       if (prev == -1e18) {         prev = it.first;         val = it.second;       } else {         ans = (ans +                (ncr(val, k, 1000000007) * (it.first - prev) % 1000000007) %                    1000000007 +                1000000007) %               1000000007;         prev = it.first;         val = it.second;       }     }     cout << ans <<   n ;   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long test = 1;     fac[0] = 1;     for (long long i = 1; i <= 300000; i++)       fac[i] = (fac[i - 1] * i) % 1000000007;     while (test--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   long long int pow_mod(long long int a, long long int b) {     long long int res = 1;     while (b != 0) {       if (b & 1) {         res = (res * a) % 1000000007;       }       a = (a * a) % 1000000007;       b /= 2;     }     return res;   }   long long int inv(long long int x) { return pow_mod(x, 1000000007 - 2); }   void solve() {     long long int n;     cin >> n;     long long int x = 2 * n - 1;     long long int y = n;     long long int res1 = 1;     for (long long int i = 0; i < y; i++) res1 = (res1 * (x - i)) % 1000000007;     long long int res2 = 1;     for (long long int i = 1; i <= y; i++) res2 = (res2 * i) % 1000000007;     long long int ans = (res1 * inv(res2)) % 1000000007;     ans *= 2;     ans %= 1000000007;     ans -= n;     ans += 1000000007;     ans %= 1000000007;     cout << ans << endl;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long int t;     t = 1;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const unsigned long long INF = ~0ll;   unsigned long long prime[16] = {2,  3,  5,  7,  11, 13, 17, 19,                                   23, 29, 31, 37, 41, 43, 47, 53};   int n;   unsigned long long ans;   void dfs(int deepth, unsigned long long v, unsigned long long num) {     if (num > n || deepth > 15) return;     if (num == n && v < ans) {       ans = v;       return;     }     for (unsigned long long i = 1; i <= 63; i++) {       if (ans / prime[deepth] < v) break;       dfs(deepth + 1, v *= prime[deepth], num * (i + 1));     }   }   int main() {     while (cin >> n) {       ans = INF;       dfs(0, 1, 1);       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       long long n, a, b;       cin >> n >> a >> b;       if (2 * a < b) {         long long ans = n * a;         cout << ans << endl;       } else {         long long cou = n % 2;         long long ans = (n / 2) * b;         if (cou == 1) {           ans += a;         }         cout << ans << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const long long p = 1000000007LL;   long long power(long long x, long long n) {     long long ret = 1LL;     while (n > 0LL) {       if (n & 1LL) ret = ret * x % p;       x = x * x % p;       n >>= 1LL;     }     return ret;   }   long long n, m;   long long dp;   int main() {     cin >> n >> m;     dp = 1;     for (long long i = 1LL; i <= n; i++)       dp = (dp * (m * 2LL - 1LL) + power(m, i - 1LL)) % p;     cout << dp << endl;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int n, t;     cin >> n >> t;     for (int i = 1; i <= n; i++) {       int val;       cin >> val;       t -= (86400 - val);       if (t <= 0) {         cout << i <<   n ;         return;       }     }   }   int main() {     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void desperate_optimization(int precision) {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cout.setf(ios::fixed);     cout.setf(ios::showpoint);     cout.precision(precision);   }   const int N = 2e5;   long long arrA[N + 5], arrB[N + 5];   long long posA[N + 5], posB[N + 5];   long long res[N + 5];   long long bit[N + 5];   int n;   int query(int x) {     int tot = 0;     for (; x; x -= (x & -x)) tot += bit[x];     return tot;   }   void update(int x) {     for (; x <= n; x += (x & -x)) bit[x]++;   }   void hora(int tc) {     cin >> n;     for (int i = 0; i < n; i++) cin >> arrA[i];     for (int i = 0; i < n; i++) cin >> arrB[i];     for (int i = 0; i < n; i++) {       int val = query(arrA[i] + 1);       posA[i] = arrA[i] - val;       update(arrA[i] + 1);     }     memset(bit, 0, sizeof bit);     for (int i = 0; i < n; i++) {       int val = query(arrB[i] + 1);       posB[i] = arrB[i] - val;       update(arrB[i] + 1);     }     long long cur = 0;     long long sisa = 0;     for (int i = n - 1; i >= 0; i--) {       res[i] = posA[i] + posB[i] + sisa;       sisa = res[i] / (cur + 1);       res[i] %= (cur + 1);       cur += 1;     }     memset(bit, 0, sizeof bit);     for (int i = 0; i < n; i++) {       int lo = 0;       int hi = n;       int ans = -1;       while (lo <= hi) {         int mid = (lo + hi) / 2;         if (mid - query(mid + 1) >= res[i]) {           ans = mid;           hi = mid - 1;         } else           lo = mid + 1;       }       update(ans + 1);       cout << ans <<    ;     }   }   int main() {     desperate_optimization(10);     int ntc = 1;     for (int tc = 1; tc <= ntc; tc++) hora(tc);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long maxm = -1e18;   long long minm = 1e18;   long long mod = 1e9 + 7;   long long mod1 = 1e9 + 9;   const long double Pi = 3.141592653;   long long int fact(long long int n) {     if (n == 0) {       return 1;     } else if (n == 1) {       return 1;     }     long long int res = 1;     for (long long int i = 2; i <= n; i++) res = res * i;     return res;   }   long long int nCr(long long int n, long long int r) {     return fact(n) / (fact(r) * fact(n - r));   }   bool isint(double n) {     long long int j = n;     double w = n - j;     if (w > 0) {       return false;     }     return true;   }   long long int count3(long long int x) {     long long int ret = 0;     while (x % 3 == 0) {       ret++;       x /= 3;     }     return ret;   }   long long int sqr(long long int a) { return a * a; }   int32_t main() {     ios_base::sync_with_stdio(false), cin.tie(NULL);     long long t = 1;     cin >> t;     while (t--) {       long long int n;       cin >> n;       long long int ans = 1;       if (n == 1) {         cout << 1 <<   n ;         continue;       }       for (long long int i = 1; i <= 2 * n - 1; i++) {         ans = (ans * i);         ans = (ans) % mod;       }       ans = (ans * n) % mod;       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int M = 4e3 + 44;   const int F = 4000;   int n;   int s[M];   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &s[i]);     printf( %d n , n + 1);     int tmp, tmp1, tmp2, sum = 0;     for (int i = n; i >= 1; i--) {       tmp = (F + i - ((sum + s[i]) % F)) % F;       sum += tmp;       printf( %d %d %d n , 1, i, tmp);     }     printf( %d %d %d n , 2, n, F);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   static const int maxn = 2e5 + 5;   struct Node {     bool ok;     int val;     int pos, rpos;     Node(bool ok = 0, int val = 0, int pos = 0, int rpos = 0)         : ok(ok), val(val), pos(pos), rpos(rpos) {}     bool operator<(const Node &other) const {       if (ok and other.ok) {         if (val == other.val) return pos > other.pos;         return val < other.val;       }       return ok > other.ok;     }   };   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     int n;     cin >> n;     vector<int> arr(n + 2);     for (int i = 1; i <= n; i++) cin >> arr[i];     vector<int> rgt(n + 1);     rgt[n] = -1;     for (int i = n - 1; i >= 1; i--) rgt[i] = i + 1;     multiset<Node> ms;     arr[n + 1] = 1e9 + 9;     for (int i = 1; i <= n; i++) {       bool ok = arr[i] > arr[i + 1];       ms.insert(Node(ok, arr[i], i, i + 1));     }     int min_time = 0;     map<int, int> mp;     while (ms.size()) {       int cnt = 0;       mp.clear();       while (ms.size()) {         auto it = *ms.begin();         if (it.ok == false) break;         ++cnt;         ms.erase(it);         rgt[it.pos] = rgt[it.rpos];         mp[rgt[it.rpos]] = it.pos;       }       if (cnt == 0) break;       ++min_time;       for (auto it : mp) {         if (it.first == -1) continue;         int pos = it.second;         int rpos = it.first;         bool ok = arr[pos] > arr[rpos];         ms.insert(Node(ok, arr[pos], pos, rpos));       }     }     cout << min_time <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   long long rdtsc() {     long long tmp;     asm( rdtsc  :  =A (tmp));     return tmp;   }   inline int myrand() { return abs((rand() << 15) ^ rand()); }   inline int rnd(int x) { return myrand() % x; }   const int INF = (int)1e9 + 1;   const long double EPS = 1e-9;   void precalc() {}   const int maxn = (int)1e5 + 10;   int a[2 * maxn];   int n, w;   bool read() {     if (scanf( %d%d , &n, &w) < 2) {       return 0;     }     for (int i = 0; i < 2 * n; ++i) {       scanf( %d , &a[i]);     }     return 1;   }   void solve() {     sort(a, a + 2 * n);     printf( %.18f n ,            min((double)w, min((double)a[n] / 2, (double)a[0]) * 3 * n));   }   int main() {     srand(rdtsc());     precalc();     while (1) {       if (!read()) {         break;       }       solve();     }     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:100000000,100000000 )   using namespace std;   const long long inf = 1e9 + 7;   const long long mod = 1e9 + 7;   const double eps = 1e-9;   const double PI = 2 * acos(0.0);   const double E = 2.71828;   int main(void) {     long long n;     cin >> n;     double ans = 0, e = 0;     for (int i = 0; i < n; i++) {       double temp;       cin >> temp;       ans += temp * (2.0 * e + 1);       e = temp * (e + 1);     }     cout << setprecision(8) << fixed << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string norm(string s) {     string res = s;     for (int i = 0; i < 2; i++) {       for (int j = 0; j < 4; j++) {         for (int k = 0; k < 4; k++) {           res = min(s, res);           swap(s[0], s[1]);           swap(s[1], s[2]);           swap(s[2], s[3]);         }         swap(s[0], s[4]);         swap(s[4], s[2]);         swap(s[2], s[5]);       }       swap(s[0], s[1]);       swap(s[1], s[2]);       swap(s[2], s[3]);     }     return res;   }   int main() {     set<string> myS;     string S;     cin >> S;     sort(S.begin(), S.end());     do {       myS.insert(norm(S));     } while (next_permutation(S.begin(), S.end()));     cout << myS.size() << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       vector<int> a(n + 1);       for (int i = 1; i <= n; i++) cin >> a[i];       vector<vector<int> > dp(201);       for (int i = 1; i <= n; i++) {         dp[a[i]].push_back(i);       }       int maximum = 0;       for (int i = 1; i <= n; i++) {         int p = a[i];         int l = lower_bound(dp[p].begin(), dp[p].end(), i) - begin(dp[p]);         int r = dp[p].size() - l - 1;         if (l >= r) continue;         int lval = dp[p][l];         int rval = dp[p][r];         int maxi = 0;         for (int j = 1; j <= 200; j++) {           if (j == p) {             maxi = max(maxi, r - l - 1);             continue;           }           int xx = upper_bound(dp[j].begin(), dp[j].end(), rval) - dp[j].begin();           int yy = upper_bound(dp[j].begin(), dp[j].end(), lval) - dp[j].begin();           maxi = max(maxi, xx - yy);         }         maximum = max(maximum, maxi + (2 * (l + 1)));       }       cout << max(1, maximum) << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   int s, t, ds, dt;   struct edge {     int u, v;   } E[400005];   vector<int> vecr[200005];   int pre[200005];   int find(int x) {     if (x != pre[x]) pre[x] = find(pre[x]);     return pre[x];   }   void Union(int x, int y) { pre[find(x)] = find(y); }   int cpts[200005];   int tot;   int conts[200005];   int contt[200005];   map<int, int> to;   vector<int> dhas;   vector<int> ans;   void output(int pos) {     int siz = vecr[pos].size();     for (int i = 0; i < siz; i++) {       int u = E[vecr[pos][i]].u;       int v = E[vecr[pos][i]].v;       if (find(u) == find(v))         continue;       else {         Union(u, v);         ans.push_back(vecr[pos][i]);       }     }   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) pre[i] = i;     for (int i = 0; i < m; i++) scanf( %d%d , &E[i].u, &E[i].v);     scanf( %d%d%d%d , &s, &t, &ds, &dt);     for (int i = 0; i < m; i++) {       if (E[i].u == s || E[i].u == t || E[i].v == s || E[i].v == t)         continue;       else if (find(E[i].u) != find(E[i].v)) {         Union(E[i].u, E[i].v);       }     }     for (int i = 1; i <= n; i++)       if (i != s && i != t) cpts[tot++] = find(i);     sort(cpts, cpts + tot);     tot = unique(cpts, cpts + tot) - cpts;     cpts[tot++] = s;     cpts[tot++] = t;     for (int i = 0; i < tot; i++) to[cpts[i]] = i;     memset(conts, -1, sizeof(conts));     memset(contt, -1, sizeof(contt));     for (int i = 0; i < m; i++) {       if (E[i].u == s) conts[to[find(E[i].v)]] = i;       if (E[i].v == s) conts[to[find(E[i].u)]] = i;       if (E[i].u == t) contt[to[find(E[i].v)]] = i;       if (E[i].v == t) contt[to[find(E[i].u)]] = i;       if (find(E[i].u) == find(E[i].v)) vecr[to[find(E[i].u)]].push_back(i);     }     for (int i = 1; i <= n; i++) pre[i] = i;     for (int i = 0; i < tot - 2; i++) {       output(i);       if (conts[i] >= 0 && contt[i] >= 0)         dhas.push_back(i);       else if (conts[i] >= 0) {         ans.push_back(conts[i]);         ds--;       } else if (contt[i] >= 0) {         ans.push_back(contt[i]);         dt--;       }     }     if (dhas.size() == 0) {       ds--;       dt--;       ans.push_back(conts[tot - 1]);       if (ds < 0 || dt < 0)         printf( No n );       else {         printf( Yes n );         for (int i = 0; i < ans.size(); i++) {           printf( %d %d n , E[ans[i]].u, E[ans[i]].v);         }       }     } else {       for (int i = 0; i < dhas.size(); i++) {         if (i == 0) {           ans.push_back(conts[dhas[i]]);           ans.push_back(contt[dhas[i]]);           ds--;           dt--;         } else {           if (ds < dt) {             ans.push_back(contt[dhas[i]]);             dt--;           } else {             ans.push_back(conts[dhas[i]]);             ds--;           }         }       }       if (ds < 0 || dt < 0)         printf( No n );       else {         printf( Yes n );         for (int i = 0; i < ans.size(); i++) {           printf( %d %d n , E[ans[i]].u, E[ans[i]].v);         }       }     }     return 0;   }