malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const inline int __GET_INT() {     int ret;     scanf( %d , &ret);     return ret;   }   const int maxn = 2002;   int n, m;   char grid[maxn][maxn];   int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1};   int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1};   int cntStar(int r, int c) {     return (grid[r][c] ==  * ) + (grid[r + 1][c] ==  * ) +            (grid[r][c + 1] ==  * ) + (grid[r + 1][c + 1] ==  * );   }   void dfs(int r, int c) {     if (r < 0 || c < 0 || (r + 1) >= n || (c + 1) >= m) {       return;     }     if (cntStar(r, c) != 1) {       return;     }     grid[r][c] = grid[r + 1][c] = grid[r][c + 1] = grid[r + 1][c + 1] =  . ;     for (int i = 0; i < 2; ++i)       for (int j = 0; j < 2; ++j) {         for (int k = 0; k < 8; ++k) {           dfs(r + i + dx[k], c + j + dy[k]);         }       }   }   int main() {     n = __GET_INT();     m = __GET_INT();     for (int i = 0; i < n; ++i) {       scanf( %s , grid[i]);     }     for (int i = 0; (i + 1) < n; ++i)       for (int j = 0; (j + 1) < m; ++j) {         dfs(i, j);       }     for (int i = 0; i < n; ++i) {       for (int j = 0; j < m; ++j) printf( %c , grid[i][j]);       puts(  );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[200005];   int b[200005];   int n, k, Q;   long long ans;   int l, r;   int main() {     scanf( %d , &Q);     while (Q--) {       scanf( %d%d , &n, &k);       for (int i = 1; i <= n; i++) scanf( %lld , &a[i]);       for (int i = 1; i <= k; i++) scanf( %d , &b[i]);       sort(a + 1, a + 1 + n);       sort(b + 1, b + 1 + k);       int l, r;       ans = 0;       l = 1;       r = n;       for (int i = 1; i <= k; i++) {         if (b[i] == 1)           ans += a[r] + a[r];         else           break;         r--;       }       for (int i = k; i >= 1; i--) {         if (b[i] == 1) break;         ans += a[l] + a[r];         r--;         l += b[i] - 1;       }       printf( %lld n , ans);     }   }
#include <bits/stdc++.h>   using namespace std;   long long max(long long a, long long b) {     if (a > b) return a;     return b;   }   long long min(long long a, long long b) {     if (a < b) return a;     return b;   }   const int MOD = 1e9 + 7, N = 102, L = 3005, INF = INT_MAX;   pair<long long, long long> a[N];   long long dp[L][N][2];   int main() {     int n, l;     cin >> n >> l;     for (int i = 0; i < n; i++) {       cin >> a[i].first >> a[i].second;     }     for (int i = 1; i <= l; i++) {       for (int j = 0; j < n; j++) {         if (a[j].first == i)           dp[i][j][0] = 1;         else if (a[j].first < i) {           for (int c = 0; c < n; c++) {             if (c == j) continue;             if (a[c].second == a[j].first)               dp[i][j][0] += dp[i - a[j].first][c][0];             if (a[c].first == a[j].first && a[c].first != a[c].second)               dp[i][j][0] += dp[i - a[j].first][c][1];             dp[i][j][0] %= MOD;           }         }         if (a[j].second == i)           dp[i][j][1] = 1;         else if (a[j].second < i) {           for (int c = 0; c < n; c++) {             if (c == j) continue;             if (a[c].second == a[j].second)               dp[i][j][1] += dp[i - a[j].second][c][0];             if (a[c].first == a[j].second && a[c].first != a[c].second)               dp[i][j][1] += dp[i - a[j].second][c][1];             dp[i][j][1] %= MOD;           }         }       }     }     long long ans = 0;     for (int i = 0; i < n; i++) {       ans += dp[l][i][0];       if (a[i].first != a[i].second) ans += dp[l][i][1];       ans %= MOD;     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int M = 11, N = 2e5 + 5;   int n, k;   int a[N];   map<int, int> rem[M];   long long solve() {     long long ans = 0;     for (int i = 0; i < n; ++i) {       unsigned long long f = 10;       int ln = ((int)(to_string(a[i])).size());       for (int l = 1; l < M; ++l) {         int r = (k - (int)((f * a[i]) % k)) % k;         ans += rem[l][r];         if (l == ln && r == a[i] % k) ans--;         f *= 10;       }     }     return ans;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(nullptr);     cout.tie(nullptr);     cin >> n >> k;     for (int i = 0; i < n; ++i) {       cin >> a[i];       int l = ((int)(to_string(a[i])).size());       rem[l][a[i] % k]++;     }     cout << solve() <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 5e5 + 5;   int main() {     long long v, w1, w2, v1, v2;     cin >> v >> w1 >> w2 >> v1 >> v2;     long long x = max(v1, v2);     if (x * x >= v) {       if (v1 < v2) swap(v1, v2), swap(w1, w2);       long long ans = 0;       for (int i = 0; i <= v / v1; i++) {         ans = max(ans, i * w1 + (v - i * v1) / v2 * w2);       }       cout << ans << endl;     } else {       if (1.0 * w1 / v1 > 1.0 * w2 / v2) {         swap(v1, v2), swap(w1, w2);       }       long long ans = 0;       for (int i = 0; i < v2; i++) {         ans = max(ans, i * w1 + (v - i * v1) / v2 * w2);       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   const int mod = 1000000007;   const int inf = 1000000009;   const long long INF = 1000000000000000009;   const long long big = 1000000000000000;   const long double eps = 0.000000000000000000001;   using namespace std;   const int M = 100000;   int W[M + 5], U[M + 5], cnt[M + 5];   vector<int> D[M + 5], S;   long long int funkcja(int x) {     long long int wynik = 0;     for (auto v : D[x]) wynik += cnt[v] * U[v];     return wynik;   }   void aktualizuj(int x, int c) {     for (auto v : D[x]) cnt[v] += c;   }   int main() {     ios::sync_with_stdio(false);     cin.tie();     cout.tie();     int n;     cin >> n;     for (int i = 1; i <= M; i++) {       for (int j = i; j <= M; j += i) D[j].push_back(i);       if (i == 1)         U[i] = 1;       else if ((i / D[i][1]) % D[i][1] == 0)         U[i] = 0;       else         U[i] = -U[i / D[i][1]];     }     long long int wynik = 0;     for (int i = 1; i <= n; i++) {       int a;       cin >> a;       wynik = max(wynik, (long long int)a);       for (auto v : D[a]) W[v] = 1;     }     for (int j = M; j >= 1; j--) {       if (!W[j]) continue;       while (funkcja(j)) {         wynik = max(wynik, (long long int)j * S.back());         aktualizuj(S.back(), -1);         S.pop_back();       }       aktualizuj(j, 1);       S.push_back(j);     }     cout << wynik;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, arr[500010], temp, j, i, ans;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n;     for (long long i = 0; i < n; i++) {       cin >> arr[i];     };     sort(arr, arr + n);     i = 0, j = n / 2;     ans = n;     while (i < n / 2) {       while (j < n) {         if (arr[i] * 2 <= arr[j]) {           ans--;           j++;           break;         } else           j++;       }       i++;     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int l[210000], r[210000];   vector<pair<int, int> > v;   int n, m, k;   int mp[1000];   int lbit[1000];   int dp[210000][300];   int msk[210000];   int main() {     for (int i = 0; i < 210000; i++)       for (int j = 0; j < 300; j++) dp[i][j] = -0x3f3f3f3f;     dp[0][0] = 0;     for (int i = 0; i < (1 << 9); i++) {       int cnt = 0;       for (int j = 0; j < 8; j++)         if (i & (1 << j)) {           mp[i]++;         } else if (lbit[i] == 0) {           lbit[i] = (1 << j);         }     }     cin >> n >> m >> k;     for (int i = 1; i <= n; i++) {       scanf( %d%d , &l[i], &r[i]);       v.push_back({l[i] - 1, i});       v.push_back({r[i], -i});     }     sort(v.begin(), v.end());     int tim = 0;     int posmsk = 0;     int ans = 0;     int lst = 0;     for (auto p : v) {       tim++;       if (p.second < 0) {         for (int j = 0; j < (1 << 8); j++)           if (j & msk[-p.second])             dp[tim][j ^ msk[-p.second]] =                 max(dp[tim][j ^ msk[-p.second]],                     dp[tim - 1][j] + max(0, p.first - lst) * (mp[j] & 1));           else {             dp[tim][j] =                 max(dp[tim][j], dp[tim - 1][j] + (p.first - lst) * (mp[j] & 1));           }         posmsk ^= msk[-p.second];       } else {         msk[p.second] = lbit[posmsk];         posmsk ^= msk[p.second];         for (int j = 0; j < (1 << 8); j++)           if ((j & msk[p.second]) == 0) {             dp[tim][j ^ msk[p.second]] =                 max(dp[tim][j ^ msk[p.second]],                     dp[tim - 1][j] + (max(0, p.first - lst)) * (mp[j] & 1));             dp[tim][j] =                 max(dp[tim][j], dp[tim - 1][j] + (p.first - lst) * (mp[j] & 1));           }       }       lst = p.first;     }     cout << dp[2 * n][0];     return ~~(0 ^ 0 ^ 0);   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 998244353;   const int N = 3005;   int n, c, a[N], dp[N][N], g[N][N], freq[N], mul[N], imul[N], pw[N], cnt[N];   int dp2[2][N][1 << 12];   int inverse(int n) {     if (n == 1) return 1;     return inverse(mod % n) * 1LL * (mod - mod / n) % mod;   }   inline void add(int &x, int y) {     x += y;     if (x >= mod) x -= mod;   }   void solve1() {     for (int i = 1; i <= n; i++) {       a[i]--;     }     memset(dp2, 0, sizeof(dp2));     int flg = 0;     dp2[0][0][0] = 1;     for (int i = 1; i <= n; i++) {       for (int p = 0; p * c <= i; p++) {         for (int mask = 0; mask < (1 << c); mask++) {           dp2[flg ^ 1][p][mask] = 0;         }       }       for (int p = 0; p * c <= i; p++) {         for (int mask = 0; mask + 1 < (1 << c); mask++) {           int nmask = mask | (1 << a[i]);           if (nmask + 1 == (1 << c)) {             add(dp2[flg ^ 1][p + 1][0], dp2[flg][p][mask]);           } else {             add(dp2[flg ^ 1][p][nmask], dp2[flg][p][mask]);           }           add(dp2[flg ^ 1][p][mask], dp2[flg][p][mask]);         }       }       flg ^= 1;     }     memset(cnt, 0, sizeof(cnt));     for (int p = 0; p <= n; p++) {       for (int mask = 0; mask + 1 < (1 << c); mask++) {         add(cnt[p], dp2[flg][p][mask]);       }     }     add(cnt[0], mod - 1);     for (int i = 0; i <= n; i++) {       cout << cnt[i] <<    ;     }     cout <<   n ;   }   void solve2() {     mul[0] = 0;     pw[0] = 1;     for (int i = 1; i <= n; i++) {       mul[i] = mul[i - 1] + mul[i - 1] + 1;       if (mul[i] >= mod) mul[i] -= mod;       imul[i] = inverse(mul[i]);       pw[i] = mul[i] + 1;     }     memset(g, 0, sizeof(g));     for (int i = 1; i <= n; i++) {       int cnt = 0;       long long prd = 1;       memset(freq, 0, sizeof(freq));       for (int j = i; j <= n; j++) {         if (freq[a[j]] == 0) {           cnt++;         } else {           (prd *= imul[freq[a[j]]]) %= mod;         }         freq[a[j]]++;         (prd *= mul[freq[a[j]]]) %= mod;         if (cnt == c) {           g[i][j] = prd * imul[freq[a[j]]] % mod;         }       }     }     memset(dp, 0, sizeof(dp));     for (int i = 1; i <= n; i++) {       dp[i][1] = g[1][i];       for (int j = 1; j <= i; j++) {         for (int p = 2; p * c <= i; p++) {           dp[i][p] += dp[j - 1][p - 1] * 1LL * g[j][i] % mod;           if (dp[i][p] >= mod) dp[i][p] -= mod;         }       }     }     memset(cnt, 0, sizeof(cnt));     for (int i = 1; i <= n; i++) {       for (int p = 1; p * c <= i; p++) {         cnt[p] += dp[i][p] * 1LL * pw[n - i] % mod;         if (cnt[p] >= mod) cnt[p] -= mod;       }     }     cnt[0] = mul[n] + mod - cnt[1];     if (cnt[0] >= mod) cnt[0] -= mod;     for (int p = 1; p <= n; p++) {       cnt[p] += mod - cnt[p + 1];       if (cnt[p] >= mod) cnt[p] -= mod;     }     for (int i = 0; i <= n; i++) {       cout << cnt[i] <<    ;     }     cout <<   n ;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> n >> c;     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     if (c <= 10) {       solve1();     } else {       solve2();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int ans[101000], mark[101000];   char s[101000];   int n, top, now, n_;   int main() {     do s[++n_] = getchar();     while (s[n_] !=  = );     scanf( %d , &n);     mark[1] = 0;     top = 1;     for (int i = 3; i < n_; i += 4) mark[++top] = (s[i] ==  - );     now = 0;     for (int i = 1; i <= top; i++) ans[i] = 1;     for (int i = 1; i <= top; i++)       if (mark[i])         now--;       else         now++;     while (now != n) {       if (now < n) {         int q = 0;         for (int i = 1; i <= top; i++)           if (!mark[i] && ans[i] < n) {             q = i;             break;           }         if (!q) {           printf( Impossible );           return 0;         }         int inc = min(n - ans[q], n - now);         ans[q] += inc;         now += inc;       } else {         int q = 0;         for (int i = 1; i <= top; i++)           if (mark[i] && ans[i] < n) {             q = i;             break;           }         if (!q) {           printf( Impossible );           return 0;         }         int inc = min(n - ans[q], now - n);         ans[q] += inc;         now -= inc;       }     }     printf( Possible n );     printf( %d , ans[1]);     for (int i = 2; i <= top; i++) {       putchar(   );       if (mark[i])         putchar( - );       else         putchar( + );       putchar(   );       printf( %d , ans[i]);     }     printf(  = %d , n);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   const int maxn = 4e5 + 5;   long long a[maxn], f[maxn], d[maxn];   int q[maxn];   int main() {     int n, i, j, l, r;     long long c;     scanf( %d%lld , &n, &c);     for (i = 1; i < (n << 1); i++) {       scanf( %lld , &a[i]);       a[i] += a[i - 1];     }     l = r = 1;     j = q[1] = 0;     for (i = 1; i <= n; i++) {       while (j < i && a[(i << 1) - 1] - a[j << 1] > c) j++;       while (l <= r && q[l] < j) l++;       if (j) f[i] = f[j - 1] + c;       if (l <= r) f[i] = max(f[i], d[q[l]] + a[(i << 1) - 1]);       d[i] = f[i] - a[i << 1];       while (l <= r && d[i] > d[q[r]]) r--;       q[++r] = i;     }     printf( %lld n , f[n]);     return 0;   }
#include <bits/stdc++.h>   template <typename T>   std::istream& operator>>(std::istream& input, std::vector<T>& v) {     for (T& a : v) input >> a;     return input;   }   void answer(bool v) {     constexpr const char* s[2] = { NO ,  YES };     std::cout << s[v] <<   n ;   }   void solve(const std::vector<unsigned>& a) {     const size_t n = a.size();     for (size_t i = 1; i < n; ++i) {       if (a[i] >= a[i - 1]) return answer(true);     }     answer(false);   }   void test_case() {     size_t n;     std::cin >> n;     std::vector<unsigned> a(n);     std::cin >> a;     solve(a);   }   int main() {     size_t t;     std::cin >> t;     while (t-- > 0) test_case();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void __print(int x) { cerr << x; };   void __print(long x) { cerr << x; };   void __print(long long x) { cerr << x; };   void __print(unsigned x) { cerr << x; };   void __print(unsigned long x) { cerr << x; };   void __print(unsigned long long x) { cerr << x; };   void __print(float x) { cerr << x; };   void __print(double x) { cerr << x; };   void __print(long double x) { cerr << x; };   void __print(char x) { cerr <<      << x <<     ; };   void __print(const char *x) { cerr <<     << x <<    ; };   void __print(const string &x) { cerr <<     << x <<    ; };   void __print(bool x) { cerr << (x ?  true  :  false ); }   long long powmod(long long a, long long b) {     long long res = 1;     a %= 1000000007;     assert(b >= 0);     for (; b; b >>= 1) {       if (b & 1) res = res * a % 1000000007;       a = a * a % 1000000007;     }     return res;   }   long long string_to_int(string s) {     long long ans = 0;     long long p = 1;     for (long long i = s.size() - 1; i >= 0; i--) {       ans += (s[i] -  0 ) * p;       p *= 10;     }     return ans;   }   long long fast_pow(long long a, long long b) {     if (b == 1) return a;     if (b == 0) return 1;     long long x = fast_pow(a, b / 2);     x *= x;     if (b & 1) x *= a;     return x;   }   template <typename T, typename V>   void __print(const pair<T, V> &x) {     cerr <<  { ;     __print(x.first);     cerr <<  , ;     __print(x.second);     cerr <<  } ;   }   template <typename T>   void __print(const T &x) {     long long f = 0;     cerr <<  { ;     for (auto &i : x) cerr << (f++ ?  ,  :   ), __print(i);     cerr <<  } ;   }   void _print() { cerr <<  ] n ; }   template <typename T, typename... V>   void _print(T t, V... v) {     __print(t);     if (sizeof...(v)) cerr <<  ,  ;     _print(v...);   }   void t_c_c() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long n, m, k;     cin >> n >> m >> k;     long long arr[m];     for (long long i = 0; i < m; i++) {       cin >> arr[i];     }     long long days = 0;     long long pages = k;     long long point = 0;     long long x = 0;     long long xx = 0;     for (long long i = 0; i < m;) {       if (arr[i] - x <= pages) {         while (arr[i] - xx <= pages) {           ;           x++;           i++;         }         xx = x;         days++;       } else {         long long factor = ((arr[i] - x) - pages) / k;         pages +=             (((arr[i] - x) - pages) % k == 0 ? factor * k : (factor + 1) * k);       }     }     cout << days <<   n ;   }   int32_t main() {     t_c_c();     return 0;   }
/**    *    author:  Ujjwal Tripathi    *    created: 15.04.2021 18:04:04   **/              #include<bits/stdc++.h>   using namespace std;       #define ar array<ll, 2>   #define ll long long   #define in insert   #define pb push_back   #define pii pair<ll,ll>   #define vt vector   #define P_Q(x) priority_queue<x>   #define p_q(x) priority_queue<x, vector<x>, greater<x>>   #define For(i, n) for(ll i = 0; i < n; i++)   #define Rev(i, n) for(ll i = n-1; i >= 0; i--)   #define FOR(i, n) for(ll i = 1; i <= n; i++)   #define REV(i, n) for(ll i = n; i >= 1; i--)   #define Rep(i,a,b) for(ll i = a; i <= b; i++)   #define all(x) (x).begin(),(x).end()   #define rall(x) (x).rbegin(), (x).rend()   #define sz(x) (int) (x).size()       // Maximum priority queue   template <typename T>   using mxpq = priority_queue<T>;       // Minimum priority queue   template <typename T>   using mnpq = priority_queue<T, vt<T>, greater<T>>;           // x | (x + 1) sets lowest unset bit of x   // x & (x - 1) unsets lowest set bit of x       const ll mod = 1e9L + 7;   const ll INF = 1e18L + 5;   const ll mxN = 2e5 + 1;           ll n;   ll dp[1000004];   // remember to read no of test_cases   void solve()   {      cin>>n;      vt<ll> v(n);      For(i,n)      {       cin>>v[i];       if(v[i]%2==0)       {           cout<<v[i]<<   ;       }      }           For(i,n)       {         if(v[i]%2==1)         {           cout<<v[i]<<   ;         }       }       cout<<endl;   }       int main()   {     ios::sync_with_stdio(0);  cin.tie(0);     ll t = 1;     cin >> t;     FOR(tt, t) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[200010], b[200010], n, cnt = 0;   int main() {     ios::sync_with_stdio(0);     cin >> n;     for (int i = 2; i <= n; i++) cin >> a[i];     for (int tmp = n; tmp; tmp = a[tmp]) b[++cnt] = tmp;     reverse(b + 1, b + cnt + 1);     for (int i = 1; i <= cnt; i++) cout << b[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     cin.tie(0);     cin.sync_with_stdio(0);     int t;     long long n;     cin >> t;     for (int i = 0; i < t; i++) {       cin >> n;       cout << (-1 * n) + 1 <<     << n <<   n ;     }   }   bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {     return (a.second < b.second);   }   bool sort_descending(int a, int b) { return (a > b); }
#include <bits/stdc++.h>   using namespace std;   const int seed = 131;   const long long LLMAX = 2e18;   const int MOD = 1e9 + 7;   const double eps = 1e-8;   const int MAXN = 1e5 + 10;   const int hmod1 = 0x48E2DCE7;   const int hmod2 = 0x60000005;   inline long long sqr(long long x) { return x * x; }   inline int sqr(int x) { return x * x; }   inline double sqr(double x) { return x * x; }   long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }   long long exgcd(long long a, long long b, long long &x, long long &y) {     long long d;     (b == 0 ? (x = 1, y = 0, d = a)             : (d = exgcd(b, a % b, y, x), y -= a / b * x));     return d;   }   long long qpow(long long a, long long n) {     long long sum = 1;     while (n) {       if (n & 1) sum = sum * a % MOD;       a = a * a % MOD;       n >>= 1;     }     return sum;   }   inline int dcmp(double x) {     if (fabs(x) < eps) return 0;     return (x > 0 ? 1 : -1);   }   long long need[MAXN], tim[MAXN], v[MAXN][2], cnt = 0;   struct node {     long long id, a, b;     node() {}     node(long long x, long long y, long long z) { id = x, a = y, b = z; }     bool operator<(const node &n) const {       if (a - b == n.a - n.b) return a > n.a;       return a - b > n.a - n.b;     }   } in[MAXN];   long long check(long long n, long long a, long long b) {     long long sum = 0;     for (int i = 0; i <= n; i++) tim[i] = need[i];     for (int i = 0; i < cnt; i++) {       if (tim[in[i].id]) {         long long minn = min(tim[in[i].id], a);         sum += in[i].a * minn;         tim[in[i].id] -= minn;         a -= minn;       }       if (tim[in[i].id]) {         long long minn = min(tim[in[i].id], b);         sum += in[i].b * minn;         tim[in[i].id] -= minn;         b -= minn;       }     }     return sum;   }   int main(void) {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long n, s, sum = 0, ans = 0;     cin >> n >> s;     for (int i = 0; i < n; i++) {       cin >> need[i] >> v[i][0] >> v[i][1];       sum += need[i];       in[cnt++] = node(i, v[i][0], v[i][1]);     }     long long all = (sum + s - 1) / s, l = 0, r = all;     need[n] = all * s - sum;     in[cnt++] = node(n, 0, 0);     sort(in, in + cnt);     while (l + 3 < r) {       long long m1 = (l + r) / 2, m2 = (m1 + r) / 2;       if (check(n, m1 * s, (all - m1) * s) > check(n, m2 * s, (all - m2) * s))         r = m2;       else         l = m1;     }     for (long long i = l; i <= r; i++)       ans = max(ans, check(n, i * s, (all - i) * s));     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long poww(long long a, long long b, long long md) {     return (!b ? 1                : (b & 1 ? a * poww(a * a % md, b / 2, md) % md                         : poww(a * a % md, b / 2, md) % md));   }   const long long MAXN = 1e6 + 10;   const long long INF = 8e18;   const long long MOD = 1e9 + 7;   vector<pair<pair<long long, long long>, int>> v;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int t;     cin >> t;     while (t--) {       v.clear();       int n;       cin >> n;       n = n * 2 - 1;       v.resize(n);       for (int i = 0; i < n; i++)         cin >> v[i].first.first >> v[i].first.second, v[i].second = i + 1;       sort((v).begin(), (v).end(),            greater<pair<pair<long long, long long>, int>>());       vector<int> ans = {v.front().second};       for (int i = 1; i < n; i += 2) {         if (v[i].first.second < v[i + 1].first.second)           ans.push_back(v[i + 1].second);         else           ans.push_back(v[i].second);       }       sort((ans).begin(), (ans).end());       cout <<  YES  <<   n ;       for (int e : ans) cout << e <<    ;       cout <<   n ;     }     return 0;   }