malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   template <typename S, typename T>   ostream& operator<<(ostream& out, pair<S, T> const& p) {     out <<  (  << p.first <<  ,   << p.second <<  ) ;     return out;   }   template <typename T>   ostream& operator<<(ostream& out, vector<T> const& v) {     int l = v.size();     for (int i = 0; i < l - 1; i++) out << v[i] <<    ;     if (l > 0) out << v[l - 1];     return out;   }   template <typename T>   void trace(const char* name, T&& arg1) {     cout << name <<   :   << arg1 << endl;   }   template <typename T, typename... Args>   void trace(const char* names, T&& arg1, Args&&... args) {     const char* comma = strchr(names + 1,  , );     cout.write(names, comma - names) <<   :   << arg1 <<   |  ;     trace(comma + 1, args...);   }   vector<int> htov(string s) {     vector<int> ret;     for (char c : s) {       if (c <=  9 )         ret.push_back(c -  0 );       else         ret.push_back(10 + c -  a );     }     reverse(ret.begin(), ret.end());     return ret;   }   void sub(vector<int>& v) {     int n = v.size();     if (n == 1 and v[0] == 0) return;     int i = 0;     while (i < n and v[i] == 0) i++;     v[i]--;     if (i > 0) {       for (int j = 0; j < i; j++) v[j] = 15;       if (v[i] == 0 and (i + 1) == v.size()) v.resize(i);     }     return;   }   const int N = 17;   long long dp[N][2][2];   long long get(vector<int> v) {     reverse(v.begin(), v.end());     int n = v.size();     long long res = 0;     for (int d = 1; d < 16; d++) {       if ((d / 4) + 1 > n) break;       memset(dp, 0, sizeof dp);       dp[0][1][0] = 1;       for (int i = 0; i < n; i++) {         for (int eq = 0; eq < 2; eq++) {           for (int flag = 0; flag < 2; flag++) {             long long val = dp[i][eq][flag];             if (!val) continue;             int max_nd = min(d, (eq == 0) ? 15 : v[i]);             for (int nd = 0; nd <= max_nd; nd++) {               if (n - i - 1 == d / 4 and (nd & (1 << (d % 4))) == 0) continue;               int neq = (eq and nd == v[i]);               int nflag = (flag or nd == d);               dp[i + 1][neq][nflag] += val;             }           }         }       }       for (int eq = 0; eq < 2; eq++) {         res += dp[n][eq][1];       }     }     return res;   }   void solve() {     string l, r;     cin >> l >> r;     vector<int> R = htov(r);     vector<int> L = htov(l);     sub(L);     cout << get(R) - get(L) << endl;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int q;     cin >> q;     while (q--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct fenwick_tree_t {     vector<int> t;     void init(int n) { t.assign(n, 0); }     void inc(int pos, int x = 1) {       while (pos < (int)t.size()) {         t[pos] += x;         pos = pos | (pos + 1);       }     }     int get(int pos) const {       int ret = 0;       while (pos >= 0) {         ret += t[pos];         pos = (pos & (pos + 1)) - 1;       }       return ret;     }   };   vector<int> ord(vector<int> const &a) {     fenwick_tree_t tree;     tree.init(a.size() + 1);     vector<int> ret(a.size(), 0);     for (int i = (int)ret.size() - 1; i >= 0; --i) {       ret[i] = tree.get(a[i]);       tree.inc(a[i]);     }     return ret;   }   ostream &operator<<(ostream &out, vector<int> const &a) {     for (int x : a) out << x <<    ;     return out;   }   vector<int> solve(vector<int> const &a, vector<int> const &b) {     vector<int> ord_a = ord(a);     vector<int> ord_b = ord(b);     vector<int> ord_ans(ord_a.size(), 0);     for (int i = 0; i < (int)ord_ans.size(); ++i)       ord_ans[i] = ord_a[i] + ord_b[i];     reverse(ord_ans.begin(), ord_ans.end());     for (int i = 0; i < (int)ord_ans.size(); ++i) {       if (ord_ans[i] >= i + 1) {         if (i + 1 < (int)ord_ans.size()) ++ord_ans[i + 1];         ord_ans[i] -= i + 1;       }     }     reverse(ord_ans.begin(), ord_ans.end());     vector<int> ans(ord_ans.size(), 0);     fenwick_tree_t t;     t.init(ord_ans.size() + 1);     for (int i = 0; i < (int)ans.size(); ++i) t.inc(i);     for (int i = 0; i < (int)ans.size(); ++i) {       int l = -1, r = ans.size() - 1;       while (r - l > 1) {         int m = (l + r) / 2;         if (t.get(m) < ord_ans[i] + 1) {           l = m;         } else {           r = m;         }       }       t.inc(r, -1);       ans[i] = r;     }     return ans;   }   int main() {     ios_base::sync_with_stdio(false);     int n;     cin >> n;     vector<int> a(n), b(n);     for (int i = 0; i < n; ++i) cin >> a[i];     for (int i = 0; i < n; ++i) cin >> b[i];     cout << solve(a, b) << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC target( avx,avx2,fma )   using namespace std;   bool sortbysec(const pair<char, int> &a, const pair<char, int> &b) {     return (a.second < b.second);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     string ip, hh, mm;     cin >> ip;     hh = ip.substr(0, 2);     string hr = hh;     reverse(hr.begin(), hr.end());     mm = ip.substr(3, 4);     if (hh ==  23  && (stoi(mm) >= stoi(hr)))       cout <<  00:00 ;     else if (hh ==  06  || hh ==  07  || hh ==  08  || hh ==  09 )       cout <<  10:01 ;     else if (hh ==  15  && stoi(mm) >= 51 || hh ==  16  || hh ==  17  ||              hh ==  18  || hh ==  19 )       cout <<  20:02 ;     else if (stoi(mm) < stoi(hr))       cout << hh <<  :  << hr;     else {       int x = (stoi(hh) + 1) % 10 * 10 + stoi(hh) / 10;       int y = stoi(hh) + 1;       if (y >= 10)         cout << y <<  :  << x;       else         cout <<  0  << y <<  :  << x;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f;   const int N = 1e5 + 10;   char a[N], b[N];   int main() {     int t;     scanf( %d , &t);     while (t--) {       int n;       scanf( %d , &n);       scanf( %s%s , a, b);       int t = 0;       int t1 = 0, t2 = 0;       for (int i = 0; i < n; i++) {         if (a[i] != b[i]) {           t++;           if (t == 1)             t1 = i;           else if (t == 2)             t2 = i;         }         if (t == 3) break;       }       if (t != 2)         printf( No n );       else {         if (t == 0 || (a[t1] == a[t2] && b[t1] == b[t2]))           printf( Yes n );         else           printf( No n );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int n, c;     cin >> n >> c;     int a[n], t[n];     for (int i = 0; i < n; i++) cin >> a[i];     for (int j = 0; j < n; j++) cin >> t[j];     int b = 0, e = 0, e1 = 0;     for (int i = 0; i < n; i++) {       b += t[i];       e += max(0, a[i] - c * b);     }     b = 0;     for (int i = n - 1; i >= 0; i--) {       b += t[i];       e1 += max(0, a[i] - c * b);     }     if (e > e1)       cout <<  Limak ;     else if (e == e1)       cout <<  Tie ;     else       cout <<  Radewoosh ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long vis[1009];   vector<long long> v[1000];   long long th, n;   void dfs(long long s) {     if (vis[s]) return;     vis[s] = 1;     for (long long i = 0; i < v[s].size(); i++) {       if (s <= n) th++;       dfs(v[s][i]);     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long i, j, k, m, l, a, prothom = 1, kake, ans = 0;     cin >> n >> m;     for (i = 1; i <= n; i++) {       cin >> k;       while (k--) {         cin >> a;         v[a + n].push_back(i);         v[i].push_back(a + n);       }     }     for (i = 1; i <= n; i++) {       if (vis[i] == 0) {         ans++;         dfs(i);       }     }     if (ans == n && th == 0)       cout << n << endl;     else       cout << ans - 1 << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a[7];     while (scanf( %d , &a[0]) != EOF) {       int maxx = a[0];       int minn = a[0];       int ans = 0;       for (int i = 1; i < 6; i++) {         cin >> a[i];       }       ans = (a[0] + a[1] + a[2]) * (a[0] + a[2] + a[1]) - a[0] * a[0] -             a[2] * a[2] - a[4] * a[4];       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #pragma GCC optimize( -O3 )   using ld = long double;   const long long int mod = 1000000007;   const long long int inf = 1000000000000000000;   const long long int rk = 256;   const ld PI = 3.141592653589793;   ostream& operator<<(ostream& os, pair<long long int, long long int> const& x) {     os << x.first <<  ,  << x.second;     return os;   }   template <class T>   ostream& operator<<(ostream& os, vector<T> const& x) {     os <<  {  ;     for (auto& y : x) os << y <<    ;     return os <<  } ;   }   template <class T>   ostream& operator<<(ostream& os, set<T> const& x) {     os <<  {  ;     for (auto& y : x) os << y <<    ;     return os <<  } ;   }   template <class Ch, class Tr, class Container>   basic_ostream<Ch, Tr>& operator<<(basic_ostream<Ch, Tr>& os,                                     Container const& x) {     os <<  {  ;     for (auto& y : x) os << y <<    ;     return os <<  } ;   }   template <class X, class Y>   ostream& operator<<(ostream& os, pair<X, Y> const& p) {     return os <<  [   << p.first <<  ,   << p.second <<  ] ;   }   const int tot = 1e6 + 5;   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     int n;     cin >> n;     vector<long long int> a(2 * tot, 0);     for (int i = 1; i <= n; i++) cin >> a[i];     long long int q;     vector<long long int> pos(2 * tot, 0);     vector<long long int> ans(2 * tot, 0);     cin >> q;     for (int time = 1; time <= q; time++) {       long long int operation, p, x;       cin >> operation;       if (operation == 1) {         cin >> p >> x;         a[p] = x;         pos[p] = time;       } else {         cin >> ans[time];       }     }     for (int i = q; i >= 1; i--) {       ans[i] = max(ans[i], ans[i + 1]);     }     for (int i = 1; i <= n; i++) cout << max(a[i], ans[pos[i] + 1]) <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 100005, val1 = 20, val2 = 50, val3 = 120;   long long in[N], sum[N];   int n;   long long Sum(int pos) {     if (pos < 0) return 0LL;     return sum[pos];   }   int main() {     cin >> n;     for (int i = 0; i < n; i++) cin >> in[i];     for (int i = 0; i < n; i++) {       int t1 = in[i], t2 = in[i] - 90 + 1, t3 = in[i] - 1440 + 1;       int pos2 = lower_bound(in, in + n, t2) - in - 1;       int pos3 = lower_bound(in, in + n, t3) - in - 1;       int pos1 = i - 1;       long long Min = val1 + Sum(pos1);       Min = min(Min, Sum(pos2) + val2);       Min = min(Min, Sum(pos3) + val3);       sum[i] = Min;       cout << Min - sum[i - 1] <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 200005;   int n;   int a[MAXN];   int inc[MAXN], p;   int de[MAXN], q;   bool flag;   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i) scanf( %d , &a[i]);     sort(a + 1, a + n + 1);     for (int i = 3; i <= n; ++i)       if (a[i] == a[i - 1] && a[i - 1] == a[i - 2]) {         flag = true;         break;       }     if (flag) {       printf( NO n );     } else {       printf( YES n );       a[0] = -0x3f3f3f3f;       for (int i = 1; i <= n; ++i) {         if (a[i - 1] == a[i]) {           de[++q] = a[i];         } else           inc[++p] = a[i];       }       printf( %d n , p);       for (int i = 1; i <= p; ++i) printf( %d  , inc[i]);       printf(  n%d n , q);       for (int i = q; i >= 1; --i) printf( %d  , de[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int p, n, m, x[10005], ans;   char c[10005], *s;   void Init() {     scanf( %d , &p);     scanf( %s , c + 1);     if (c[1] ==  - )       s = c + 1;     else {       c[0] =  + ;       s = c;     }     n = strlen(s);     int d, t;     for (int i = 0; i <= n - 1; ++i) {       if (s[i] ==  + )         d = 1;       else         d = -1;       ++i;       if (s[i] ==  + )         ans += d, x[++m] = d;       else if (s[i] ==  a )         x[++m] = d;       else {         t = 0;         while (s[i] !=  * ) {           t = t * 10 + (s[i] - 48) * d;           ++i;         }         ++i;         if (s[i] ==  + )           ans += t, x[++m] = t;         else if (s[i] ==  a )           x[++m] = t;       }       i += 2;     }   }   void Work() {     sort(x + 1, x + 1 + m);     for (int i = 1; i <= m; ++i) {       ans += x[i] * p;       ++p;     }     printf( %d n , ans);   }   int main() {     Init();     Work();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 1e6 + 5, mod = 1e9 + 7;   long long n, k, pre[N], suf[N], fac[N], qx[N], qy[N];   long long mul(long long x, long long n, long long mod) {     long long ans = mod != 1;     for (x %= mod; n; n >>= 1, x = x * x % mod)       if (n & 1) ans = ans * x % mod;     return ans;   }   long long calc(long long n, long long k, long long qx[N], long long qy[N]) {     fac[0] = pre[0] = suf[n + 2] = 1;     for (long long i = 1; i <= n + 1; i++)       pre[i] = pre[i - 1] * (k - qx[i] + mod) % mod,       fac[i] = fac[i - 1] * i % mod;     for (long long i = n + 1; i >= 1; i--)       suf[i] = suf[i + 1] * (k - qx[i] + mod) % mod;     long long ans = 0;     for (long long i = 1; i <= n + 1; i++) {       long long s = fac[i - 1] * ((n + 1 - i) & 1 ? mod - 1 : 1) % mod *                     fac[n + 1 - i] % mod;       ans = (ans + qy[i] * (pre[i - 1] * suf[i + 1] % mod) % mod *                        mul(s, mod - 2, mod) % mod) %             mod;     }     return ans;   }   signed main() {     scanf( %lld%lld , &n, &k);     for (long long i = 1; i <= k + 2; i++)       qx[i] = i, qy[i] = (qy[i - 1] + mul(i, k, mod)) % mod;     printf( %lld n , calc(k + 1, n, qx, qy));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, r, s, range = 0;     scanf( %d%d , &n, &m);     vector<int> sub[m + 1];     set<int> st;     for (int i = 0; i < n; i++) {       scanf( %d%d , &s, &r);       sub[s].push_back(r);       st.insert(s);     }     for (auto it : st) {       int sz = sub[it].size();       range = max(range, sz);       sort(sub[it].begin(), sub[it].end(), greater<int>());       for (int i = 1; i < sz; i++) {         sub[it][i] += sub[it][i - 1];       }     }     int ans = 0;     for (int i = 1; i <= range; i++) {       set<int> t = st;       int sum = 0;       for (auto it : t) {         if ((int)sub[it].size() < i) {           st.erase(it);         } else if (sub[it][i - 1] < 0) {           st.erase(it);         } else           sum += sub[it][i - 1];       }       ans = max(ans, sum);     }     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 998244353;   long long po[1000006];   long long sr[1000006];   long long a[1000006];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     po[0] = 1;     sr[0] = 1;     for (int i = 1; i <= 1000002; i++) {       po[i] = po[i - 1] * 2;       po[i] %= mod;     }     sr[1] = 3;     for (int i = 2; i <= 1000002; i++) {       sr[i] = ((i + 2) * po[i - 1]) % mod;     }     long long n;     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i];     int pos = 0;     long long ret = 0;     for (int i = n - 1; i >= 0; i--) {       long long co = sr[pos++];       long long temp = (co * a[i]) % mod;       ret += temp;       ret %= mod;     }     cout << ret << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int a[n];     for (int i = 0; i < n; i++) cin >> a[i];     sort(a, a + n);     for (int i = 0; i < n; i++) {       if (a[i] != i + 1) {         cout << i + 1;         return 0;       }     }     cout << n + 1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int vis[100005], tick = 0;   vector<int> G[100005];   int a[200001], b[200005];   int main() {     int n, m, h, t;     scanf( %d%d%d%d , &n, &m, &h, &t);     for (int i = 1; i <= m; ++i) {       int u, v;       scanf( %d%d , &u, &v);       G[u].push_back(v);       G[v].push_back(u);       a[i * 2 - 1] = u;       b[i * 2 - 1] = v;       a[i * 2] = v;       b[i * 2] = u;     }     for (int i = 1; i <= n; ++i) sort(G[i].begin(), G[i].end());     bool flag = 0;     for (int i = 1; i <= 2 * m; ++i) {       int u = a[i], v = b[i];       if (G[u].size() - 1 < h || G[v].size() - 1 < t) continue;       bool done = 0;       if (G[u].size() > G[v].size()) {         swap(u, v);         done = 1;       }       int acnt = 0, bcnt = 0, bothcnt = 0;       for (int j = 0; j < G[u].size(); ++j) {         if (G[u][j] == v) continue;         if (binary_search(G[v].begin(), G[v].end(), G[u][j])) {           bothcnt++;         } else {           acnt++;         }       }       bcnt = G[v].size() - 1 - bothcnt;       if (done) {         swap(acnt, bcnt);         swap(u, v);       }       if (max(0, h - acnt) + max(0, t - bcnt) > bothcnt) continue;       tick++;       for (int j = 0; j < G[u].size(); ++j)         if (G[u][j] != v) {           vis[G[u][j]] = tick;         }       vector<int> A, B, BOTH;       tick++;       for (int j = 0; j < G[v].size(); ++j)         if (G[v][j] != u) {           if (vis[G[v][j]] == tick - 1) {             BOTH.push_back(G[v][j]);           } else {             B.push_back(G[v][j]);           }           vis[G[v][j]] = tick;         }       for (int j = 0; j < G[u].size(); ++j)         if (G[u][j] != v) {           if (vis[G[u][j]] != tick) {             A.push_back(G[u][j]);           }         }       if (max(0, h - (int)A.size()) + max(0, t - (int)B.size()) <=           (int)BOTH.size()) {         flag = 1;         puts( YES );         printf( %d %d n , u, v);         int k = 0;         while (A.size() < h) A.push_back(BOTH[k++]);         while (B.size() < t) B.push_back(BOTH[k++]);         for (int i = 0; i < h; ++i) printf( %d%c , A[i],    n [i == h - 1]);         for (int i = 0; i < t; ++i) printf( %d%c , B[i],    n [i == t - 1]);         break;       }     }     if (!flag) puts( NO );   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 5e3 + 5;   char a[maxn], b[maxn];   int dp[maxn][maxn];   int main() {     int n, m;     cin >> n >> m;     scanf( %s%s , a + 1, b + 1);     int max_ = 0;     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= m; ++j) {         if (a[i] == b[j]) dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 2);         dp[i][j] = max(dp[i][j], dp[i][j - 1] - 1);         dp[i][j] = max(dp[i][j], dp[i - 1][j] - 1);         max_ = max(max_, dp[i][j]);       }     }     cout << max_ << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = int(1e9) + 7;   const long long int MOD64 = (long long int)(1e18) + 7;   const int INF = 0x7fffffff;   const long long int INF64 = 0x7fffffffffffffff;   const int N = 2e4 + 200;   int a[60][N];   int sum[60][N];   int dp[60][N];   int t[4 * N], lazy[4 * N];   void update_lazy(int i, int lo, int hi) {     if (lazy[i]) {       t[i] += lazy[i];       if (lo != hi) {         lazy[i * 2] += lazy[i];         lazy[i * 2 + 1] += lazy[i];       }       lazy[i] = 0;     }   }   int update(int i, int lo, int hi, int l, int r, int val) {     update_lazy(i, lo, hi);     if (lo > r || hi < l) return t[i];     if (l <= lo && hi <= r) {       t[i] += val;       if (lo != hi) {         lazy[i * 2] += val;         lazy[i * 2 + 1] += val;       }       return t[i];     }     int mid = (lo + hi) / 2;     return t[i] = max(update(i * 2, lo, mid, l, r, val),                       update(i * 2 + 1, mid + 1, hi, l, r, val));   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, m, k;     cin >> n >> m >> k;     for (int i = int(1); i < int(n + 1); i++) {       for (int j = int(1); j < int(m + 1); j++) {         cin >> a[i][j];         sum[i][j] = sum[i][j - 1] + a[i][j];       }     }     int mm = m - k + 1;     for (int i = int(1); i < int(mm + 1); i++)       dp[1][i] =           sum[1][i + k - 1] - sum[1][i - 1] + sum[2][i + k - 1] - sum[2][i - 1];     for (int i = int(2); i < int(n + 1); i++) {       memset(t, 0, sizeof(t));       memset(lazy, 0, sizeof(lazy));       for (int j = int(1); j < int(mm + 1); j++)         update(1, 1, mm, j, j, dp[i - 1][j]);       for (int j = int(1); j < int(k + 1); j++) update(1, 1, mm, 1, j, -a[i][j]);       for (int j = int(1); j < int(mm + 1); j++) {         dp[i][j] = t[1] + sum[i][j + k - 1] - sum[i][j - 1] +                    sum[i + 1][j + k - 1] - sum[i + 1][j - 1];         if (j != mm) {           update(1, 1, mm, max(1, j - k + 1), j, a[i][j]);           update(1, 1, mm, j + 1, j + k, -a[i][j + k]);         }       }     }     cout << *max_element(dp[n] + 1, dp[n] + mm + 1) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long v[200005];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long tc;     cin >> tc;     while (tc--) {       long long n;       cin >> n;       for (long long int i = 0; i < n; i++) {         cin >> v[i];       }       long long i = n - 1, prev = 0;       while (v[i] >= prev && i >= 0) {         prev = v[i];         i--;       }       while (v[i] <= prev && i >= 0) {         prev = v[i];         i--;       }       cout << i + 1 <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 105;   int n, m, c[N], s[N];   bool cmp(int a, int b) { return a > b; }   int main() {     int cnt = 0, p = 0, q = 0;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d , &m);       int tmp = m / 2;       for (int j = 0; j < m; j++) {         scanf( %d , &c[j]);         if (j < tmp)           p += c[j];         else           q += c[j];       }       if (m & 1) {         q -= c[tmp];         s[cnt++] = c[tmp];       }     }     sort(s, s + cnt, cmp);     for (int i = 0; i < cnt; i++) {       if (i & 1)         q += s[i];       else         p += s[i];     }     printf( %d %d n , p, q);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1200;   int n;   const double eps = 1e-9;   double c, t;   double dp[110][110][1110];   double skill[110];   pair<int, int> a[N];   inline bool cmp(pair<int, int> a, pair<int, int> b) {     return a.first > b.first;   }   inline long long get() {     int ss = 0;     for (int i = 1; i <= n; ++i) ss += a[i].second;     for (int i = 0; i <= n; ++i)       for (int j = 0; j <= n; ++j)         for (int b = 0; b <= ss; ++b) dp[i][j][b] = 1e9;     double s = 1;     skill[0] = s;     dp[0][0][0] = 0;     for (int k = 1; k <= n; ++k) skill[k] = skill[k - 1] * 0.9;     for (int i = 1; i <= n; ++i) {       for (int k = 0; k <= n; ++k)         for (int b = 0; b <= ss; ++b) {           dp[i][k][b] = min(dp[i][k][b], dp[i - 1][k][b]);           if (k > 0 && b >= a[i].second) {             double was = dp[i - 1][k - 1][b - a[i].second];             was += a[i].first / skill[k];             dp[i][k][b] = min(dp[i][k][b], was);           }         }     }     int ans = 0;     for (int i = 0; i <= n; ++i) {       if (i * 10 > t) continue;       for (int b = 0; b <= ss; ++b) {         double timer = dp[n][i][b];         if (timer + 10 * i - eps <= t)           ans = max(ans, b);         else {           double l = 1, r = t * c + 1;           for (int it = 1; it <= 100; ++it) {             double m1 = l + (r - l) / 3.0;             double m2 = r - (r - l) / 3.0;             if (timer / m1 + (m1 - 1) / c <= timer / m2 + (m2 - 1) / c)               r = m2;             else               l = m1;           }           double ti = timer / l + (l - 1) / c;           if (ti - eps + i * 10 <= t) ans = max(ans, b);         }       }     }     return ans;   }   inline void solve() {     cin >> n >> c >> t;     for (int i = 1; i <= n; ++i) cin >> a[i].first >> a[i].second;     sort(a + 1, a + n + 1, cmp);     cout << get() <<   n ;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int tc;     cin >> tc;     while (tc--) {       solve();     }     return 0;   }