malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   #pragma GCC optimize( Ofast,no-stack-protector )   using namespace std;   void err(istream_iterator<string> it) {}   template <typename T, typename... Args>   void err(istream_iterator<string> it, T a, Args... args) {     cerr << *it <<   =   << a <<   n ;     err(++it, args...);   }   function<void(void)> ____ = []() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);   };   template <typename T>   vector<T> &operator<<(vector<T> &__container, T x) {     __container.push_back(x);     return __container;   }   template <typename T>   ostream &operator<<(ostream &out, vector<T> &__container) {     for (T _ : __container) out << _ <<    ;     return out;   }   void sci() {}   template <typename... Args>   void sci(int &x, Args &...args) {     scanf( %d , &x);     sci(args...);   }   void scl() {}   template <typename... Args>   void scl(long long int &x, Args &...args) {     scanf( %lld , &x);     scl(args...);   }   const int MAXN = 2e5 + 7;   double ret;   int rt;   int n, w[MAXN], root, sz[MAXN], maxsz[MAXN];   double derivative[MAXN];   bool vis[MAXN];   vector<pair<int, int> > G[MAXN];   void findroot(int u, int par, int tot) {     sz[u] = 1;     maxsz[u] = 0;     for (auto &e : G[u]) {       int v = e.first, c = e.second;       if (vis[v] or v == par) continue;       findroot(v, u, tot);       sz[u] += sz[v];       ((maxsz[u]) = (maxsz[u]) > (sz[v]) ? (maxsz[u]) : (sz[v]));     }     ((maxsz[u]) = (maxsz[u]) > (tot - sz[u]) ? (maxsz[u]) : (tot - sz[u]));     if (maxsz[u] < maxsz[root]) root = u;   }   double cost;   void dfs(int u, int par, int wt) {     cost += pow(wt, 1.5) * w[u];     derivative[u] = w[u] * 1.5 * pow(wt, 0.5);     for (auto &e : G[u]) {       int v = e.first, c = e.second;       if (v == par) continue;       dfs(v, u, wt + c);       derivative[u] += derivative[v];     }   }   void divide(int u) {     if (vis[u]) return;     vis[u] = true;     cost = 0;     double sd = 0;     for (auto &e : G[u]) {       int v = e.first, c = e.second;       dfs(v, u, c);       sd += derivative[v];     }     if (cost < ret) ret = cost, rt = u;     for (auto &e : G[u]) {       int v = e.first;       if (sd - 2 * derivative[v] >= 0) continue;       root = 0;       findroot(v, u, sz[v]);       divide(root);       return;     }   }   void solve() {     sci(n);     for (int i = 1; i <= n; i++) sci(w[i]);     for (int i = 1; i < n; i++) {       int u, v, c;       sci(u, v, c);       G[u] << pair<int, int>(v, c);       G[v] << pair<int, int>(u, c);     }     ret = LLONG_MAX;     maxsz[root = 0] = 0x3f3f3f3f;     findroot(1, 0, n);     divide(root);     cout << rt <<     << fixed << setprecision(10) << ret <<   n ;   }   int main() {     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 998244353, maxn = 5e5 + 79;   void upd(int& a, const int& b) { a = (a + b) % mod; }   int mul(const int& a, const int& b) { return (a * 1ll * b) % (long long)mod; }   vector<vector<int> > dp(maxn, vector<int>(2, 0));   vector<vector<int> > g(maxn);   vector<int> pw2(maxn, 1);   int sum = 0, n;   int dfs(int u, int p = -1) {     dp[u][0] = 1;     int e = 0;     for (int v : g[u]) {       if (v == p) continue;       e += 1 + dfs(v, u);       vector<int> dp2(2, 0);       upd(dp2[1], mul(dp[u][0], dp[v][0]));       upd(sum, mul(2, mul(mul(dp[u][0], dp[v][0]), pw2[n - 1 - e])));       upd(dp2[0], mul(dp[u][0], dp[v][1]));       upd(dp2[1], mul(dp[u][1], dp[v][0]));       upd(dp2[1], mul(dp[u][1], dp[v][1]));       upd(dp2[0], mul(dp[u][0], dp[v][0]));       upd(dp2[0], mul(dp[u][0], dp[v][1]));       upd(dp2[1], mul(dp[u][1], dp[v][0]));       upd(dp2[1], mul(dp[u][1], dp[v][1]));       dp[u] = dp2;     }     return e;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     for (int i = 1; i < maxn; i++) pw2[i] = mul(pw2[i - 1], 2);     cin >> n;     for (int i = 0, u, v; i < n - 1; i++) {       cin >> u >> v;       g[--u].push_back(--v), g[v].push_back(u);     }     dfs(0);     cout << sum <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int sum[1000000 + 10][27];   char c1[1000000 + 10], c2[1000000 + 10];   long long n, m;   long long len1, len2;   long long gcd(long long a, long long b) {     long long t = a;     while (b) {       a = b;       b = t % b;       t = a;     }     return a;   }   int main() {     cin >> n >> m;     scanf( %s%s , c1, c2);     len1 = strlen(c1), len2 = strlen(c2);     long long t = gcd(len1, len2);     long long k = n / (len2 / t);     long long res = 0;     for (int i = 0; i < len2; ++i) sum[i % t][c2[i] -  a ]++;     for (int i = 0; i < len1; ++i)       for (int j = 0; j < 26; ++j)         if (j != c1[i] -  a ) res += sum[i % t][j];     res *= k;     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string x;     cin >> x;     int c1 = 0, c0 = 0;     bool f = 0;     for (int i = 0; i < x.size(); i++) {       if (x[i] ==  0 ) {         c0++;       } else if (x[i] ==  1 ) {         c1++;       }       if (c0 < 7 && x[i] ==  1 ) {         c0 = 0;       }       if (c1 < 7 && x[i] ==  0 ) {         c1 = 0;       }     }     if (c1 >= 7 || c0 >= 7) {       cout <<  YES  << endl;     } else {       cout <<  NO  << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int x, y;     while (scanf( %d %d , &x, &y) != EOF) {       while (x >= 0 && y >= 0) {         if (x >= 2 && y >= 2) {           x -= 2;           y -= 2;         } else if (x == 1 && y >= 12) {           x -= 1;           y -= 12;         } else if (x == 0 && y >= 22) {           y -= 22;         } else {           puts( Hanako );           break;         }         if (y >= 22) {           y -= 22;         } else if (y >= 12 && x >= 1) {           x -= 1;           y -= 12;         } else if (x >= 2 && y >= 2) {           x -= 2;           y -= 2;         } else {           puts( Ciel );           break;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3e5 + 10, LEN = 5e3 + 10, S = 51, INF = 1e18;   long long f[N], l[N], r[N], sum[N];   long long lq[S], rq[S], sq[S], mq[S];   long long a[LEN], sx[LEN], mx[LEN];   int n, m;   int main() {     scanf( %d%d , &n, &m);     memset(mq, -0x3f, sizeof mq);     for (int i = 1, s; i <= n; i++) {       scanf( %d , &s);       for (int j = 1; j <= s; j++) scanf( %lld , &a[j]);       for (int j = 1; j <= s; j++) sx[j] = sx[j - 1] + a[j];       for (int j = 1; j <= s; j++) {         mx[j] = max(mx[j - 1] + a[j], a[j]);         mq[i] = max(mq[i], mx[j]);       }       lq[i] = a[1];       for (int j = 2; j <= s; j++) lq[i] = max(lq[i], sx[j]);       rq[i] = a[n];       for (int j = s - 2; j >= 0; j--) rq[i] = max(rq[i], sx[s] - sx[j]);       sq[i] = sx[s];     }     long long res = -INF;     for (int i = 1, x; i <= m; i++) {       scanf( %d , &x);       l[i] = lq[x];       r[i] = rq[x];       sum[i] = sum[i - 1] + sq[x];       res = max(res, mq[x]);     }     f[1] = l[1];     long long maxv = r[1] - sum[1], ans = f[1];     for (int i = 2; i <= m; i++) {       f[i] = sum[i - 1] + l[i] + maxv;       maxv = max(maxv, r[i] - sum[i]);       ans = max(ans, f[i]);     }     printf( %lld n , max(ans, res));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long a, b;     cin >> a >> b;     long long ships = 0;     while (a != 0 && b != 0) {       if (b > a) {         ships += b / a;         b = b % a;       } else {         ships += a / b;         a = a % b;       }     }     cout << ships << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int getsum(string st) {     int rest = 0;     for (int i = 0; i < st.size(); i++) {       rest += st[i] -  0 ;     }     return rest;   }   string streverse(string st) {     for (int i = 0; i < st.size() / 2; i++) {       char tmp = st[i];       st[i] = st[st.size() - 1 - i];       st[st.size() - 1 - i] = tmp;     }     return st;   }   string getGreater(int a, int num, string st) {     int increase = a - num;     for (int i = st.size() - 1; i >= 0; i--) {       if (st[i] -  0  < 9) {         int increment = min(9 - (st[i] -  0 ), increase);         st[i] += increment;         increase -= increment;       }       if (increase == 0) return st;     }     string rest =   ;     for (int i = 0; i < a / 9; i++) rest = rest +  9 ;     if (a % 9 > 0) {       rest = rest + (char)( 0  + a % 9);     }     return streverse(rest);   }   string getLess(int a, int num, string st) {     int decrease = num - a;     decrease++;     int sum = 0;     for (int i = st.size() - 1; i >= 1; i--) {       sum += st[i] -  0 ;       if (sum >= decrease) {         if (st[i - 1] -  0  < 9) {           st[i - 1]++;           sum = sum - decrease;           for (int j = i; j < st.size(); j++) st[j] =  0 ;           int indx = st.size() - 1;           while (sum > 0) {             if (sum > 9) {               st[indx] += 9;               sum -= 9;             } else {               st[indx] += sum;               sum = 0;             }             indx--;           }           return st;         }       }     }     st =  1  + st;     for (int i = 1; i < st.size(); i++) {       st[i] =  0 ;     }     a--;     int k;     for (k = 0; k < a / 9; k++) {       st[st.size() - 1 - k] =  9 ;     }     if (a % 9) {       for (int i = st.size() - 1; i >= 0; i--) {         if (st[i] ==  0 ) {           st[i] = (char)( 0  + a % 9);           break;         }       }     }     return st;   }   string getnum(int a, string st) {     int num = getsum(st);     if (a > num) {       return getGreater(a, num, st);     }     return getLess(a, num, st);   }   int main() {     getnum(13,  1093 );     int n;     cin >> n;     string pre =   ;     for (int i = 0; i < n; i++) {       int a;       cin >> a;       string rest = getnum(a, pre);       cout << rest << endl;       pre = rest;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = 1e9 + 10, N = 2e5 + 10, mod = 998244353, lg = 20,                   sq = 450;   long long t, n, k, first[N], ans;   inline long long power(long long x, long long y) {     long long ret = 1;     x %= mod;     while (y) {       if (y & 1) ret = (ret * x) % mod;       x = (x * x) % mod;       y >>= 1;     }     return ret;   }   inline long long C(long long x, long long y) {     long long ret = first[y];     ret = (ret * power(first[x], mod - 2)) % mod;     ret = (ret * power(first[y - x], mod - 2)) % mod;     return ret;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     first[0] = 1;     for (int i = 1; i < N; i++) first[i] = (first[i - 1] * i) % mod;     cin >> n >> k;     if (k >= n) return cout << 0, 0;     for (int i = 0; i <= n - k; i += 2)       ans = (ans + ((power(n - k - i, n) * C(n - k - i, n - k)) % mod)) % mod;     for (int i = 1; i <= n - k; i += 2)       ans =           (mod + ans - ((power(n - k - i, n) * C(n - k - i, n - k)) % mod)) % mod;     ans = (ans * C(n - k, n)) % mod;     if (k) ans = (ans * 2) % mod;     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   long long Deci(int arr[], int base, int n) {     long long power = 1;     long long num = 0;     for (int i = n - 1; i >= 0; i--) {       num += arr[i] * power;       power = power * base;     }     return num;   }   int main() {     int n, m, x, y;     cin >> n >> x;     int arr[n + 3];     for (int i = 0; i < n; i++) {       cin >> arr[i];     }     cin >> m >> y;     int brr[m + 3];     for (int i = 0; i < m; i++) {       cin >> brr[i];     }     long long X = Deci(arr, x, n);     long long Y = Deci(brr, y, m);     if (X < Y)       cout <<  < n ;     else if (X > Y)       cout <<  > n ;     else       cout <<  = n ;   }
#include <bits/stdc++.h>   using namespace std;   long long power(long long x, long long y, long long m) {     if (y == 0) return 1;     long long p = power(x, y / 2, m) % m;     p = (p * p) % m;     return (y % 2 == 0) ? p : (x * p) % m;   }   long long gcd(long long a, long long b) {     if (a > b) swap(a, b);     if (a == 0) return b;     return gcd(b % a, a);   }   long long modInverse(long long a, long long m) { return power(a, m - 2, m); }   int main() {     ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);     srand(time(NULL));     ;     long long t;     cin >> t;     while (t--) {       long long x;       cin >> x;       string s;       cin >> s;       long long c = 1, ans = s.size();       while (c <= x) {         long long k = s[c - 1] -  1 ;         if (s.size() < x) {           string a;           a = s.substr(c, s.size());           ans += a.size() * k;           while (k--) s += a;           c++;           ans = ans % 1000000007;         } else {           ans += (ans - c) * k;           ans = ans % 1000000007;           c++;         }       }       cout << (ans + 1000000007) % 1000000007 << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   vector<string> v;   int a[26] = {0};   int main() {     int n, i, j, co = 0, F = -1;     string s, s2;     cin >> s;     for (i = 0; i < s.size(); i++) {       a[s[i] -  a ] = 1;     }     cin >> s2 >> n;     while (n--) {       cin >> s;       v.push_back(s);     }     for (i = 0; i < v.size(); i++) {       co = 0;       if (v[i].size() < s2.size() - 1) {         cout <<  NO  << endl;         continue;       }       for (j = 0; j < s2.size(); j++) {         if (s2[j] ==  * ) {           F = j;           break;         }         if ((s2[j] != v[i][j] && s2[j] !=  ? ) ||             (s2[j] ==  ?  && a[v[i][j] -  a ] == 0)) {           cout <<  NO  << endl;           co = 1;           break;         }       }       if (co != 1) {         int K = v[i].size() - 1;         for (j = s2.size() - 1; j >= 0; j--) {           if (s2[j] ==  * ) break;           if ((s2[j] != v[i][K] && s2[j] !=  ? ) ||               (s2[j] ==  ?  && a[v[i][K] -  a ] == 0)) {             cout <<  NO  << endl;             co = 1;             break;           }           K--;         }       }       if (co != 1 && v[i].size() >= s2.size() && F != -1) {         int p = v[i].size() - (s2.size() - 1);         for (j = F; p != 0; j++) {           if (a[v[i][j] -  a ] == 1) {             cout <<  NO  << endl;             co = 1;             break;           }           p--;         }       }       if (F == -1 && v[i].size() > s2.size() && co != 1) {         cout <<  NO  << endl;         co = 1;       }       if (co == 0) cout <<  YES  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, m, ans = 0, res = 0;     cin >> n >> m;     vector<pair<long long, long long>> v;     set<pair<long long, long long>> s;     for (int i = 0; i < n; i++) {       long long p, q;       cin >> p >> q;       v.push_back(make_pair(q, p));     }     sort(v.begin(), v.end(), greater<pair<long long, long long>>());     for (int i = 0; i < n; i++) {       res += v[i].second;       s.insert(make_pair(v[i].second, i));       while (s.size() > m) {         auto it = s.begin();         res -= it->first;         s.erase(it);       }       ans = max(ans, res * v[i].first);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1e9 + 7;   const long double E = 1e-9;   char ccc;   bool _minus = false;   inline void read(int &n) {     n = 0;     _minus = false;     while (true) {       ccc = getchar();       if (ccc ==     || ccc ==   n ) break;       if (ccc ==  - ) {         _minus = true;         continue;       }       n = n * 10 + ccc -  0 ;     }     if (_minus) n *= -1;   }   char wwww[12];   int kkkk;   inline void write(int x) {     kkkk = 0;     if (!x) ++kkkk, wwww[kkkk] =  0 ;     while (x) {       ++kkkk;       wwww[kkkk] = char(x % 10 +  0 );       x /= 10;     }     for (int i = kkkk; i >= 1; --i) putchar(wwww[i]);     putchar(   );   }   template <typename T>   inline T sqr(T t) {     return t * t;   }   const int MAX = 1e5;   vector<int> v1[MAX], v2[MAX];   bool ok1[MAX], ok2[MAX];   int ar[MAX];   void dfs1(int pos) {     ok1[pos] = true;     for (int i = 0; i < (int)v1[pos].size(); i++) {       if (!ok1[v1[pos][i]]) {         dfs1(v1[pos][i]);       }     }   }   void dfs2(int pos) {     ok2[pos] = true;     if (ar[pos] == 1) return;     for (int i = 0; i < (int)v2[pos].size(); i++) {       if (!ok2[v2[pos][i]]) {         dfs2(v2[pos][i]);       }     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     srand(time(NULL));     cout.precision(15);     cout << fixed;     int n, m;     cin >> n >> m;     for (int i = 0; i < n; i++) cin >> ar[i];     while (m--) {       int a, b;       cin >> a >> b;       a--, b--;       v1[a].push_back(b);       v2[b].push_back(a);     }     for (int i = 0; i < n; i++) {       if (ar[i] == 1 && !ok1[i]) {         dfs1(i);       } else if (ar[i] == 2 && !ok2[i]) {         dfs2(i);       }     }     for (int i = 0; i < n; i++) cout << (ok1[i] && ok2[i] ? 1 : 0) <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       map<int, int> m;       bool f = true;       vector<int> v;       while (n--) {         int a;         cin >> a;         v.push_back(a);         m[a] += 1;         if (m[a] > 1) f = false;       }       if (!f || !m[1]) {         cout << -1 << endl;         continue;       }       vector<int> o;       set<int> s;       for (int a : v) {         o.push_back(a);         s.insert(a);         for (int i = a + 1; i < 201; i++)           if (!m[i] && s.find(i) == s.end()) {             o.push_back(i);             s.insert(i);             m[i] += 1;             break;           }       }       bool r = true;       int p;       for (int a : s) {         if (f) p = a, f = false;         if (a - p > 1) {           r = false;           break;         }         p = a;       }       f = false;       if (r)         for (int a : o) {           if (f) cout <<    ;           cout << a;           f = true;         }       else         cout << -1;       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct data {     int x, y;   } v[300005];   inline bool cmp(data d1, data d2) {     if (d1.x != d2.x) return d1.x < d2.x;     return d1.y < d2.y;   }   inline bool cmp2(data d1, data d2) { return d1.y < d2.y; }   int n;   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , &v[i].x);       v[i].y = i;     }     sort(v + 1, v + n + 1, cmp);     int minv = 0;     for (int i = 1; i <= n; i++) {       if (minv < v[i].x) {         minv = v[i].x + 1;       } else {         v[i].x = minv;         minv++;       }     }     sort(v + 1, v + n + 1, cmp2);     for (int i = 1; i <= n; i++) printf( %d  , v[i].x);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using VI = vector<int>;   using PII = pair<int, int>;   using ll = long long;   const int M = 1e9 + 7;   const int N = 2010;   VI d{1110111, 10010,   1011101, 1011011, 111010,        1101011, 1101111, 1010010, 1111111, 1111011};   int GetDiff(int x, int y) {     return __builtin_popcount(x) - __builtin_popcount(y);   }   int Convert(int x) {     int s = 0, k = 1;     while (x) {       if (x % 10) s += k;       x /= 10;       k <<= 1;     }     return s;   }   int main() {     for (auto& v : d) v = Convert(v);     int n, k;     scanf( %d %d , &n, &k);     vector<VI> f(n + 1, VI(k + 1, -1));     VI a(n);     vector<vector<PII>> g(n);     for (int i = 0; i < n; ++i) {       int t;       scanf( %d , &t);       a[i] = t = Convert(t);       for (int j = 9; j >= 0; --j) {         if ((d[j] & t) == t) g[i].push_back({j, GetDiff(d[j], t)});       }     }     for (auto& v : g[n - 1])       f[n - 1][v.second] = max(f[n - 1][v.second], v.first);     for (int i = n - 2; i >= 0; --i) {       for (auto& v : g[i]) {         for (int j = 0; j < k + 1 - v.second; ++j) {           if (f[i + 1][j] != -1)             f[i][j + v.second] = max(f[i][j + v.second], v.first);         }       }     }     if (f[0][k] == -1)       puts( -1 );     else {       for (int i = 0; i < n; ++i) {         printf( %d , f[i][k]);         k -= GetDiff(d[f[i][k]], a[i]);       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, s1, s2, t1, t2, l1, l2;   vector<int> adj[3333];   int dist[3333][3333];   void bfs(int index) {     queue<int> q;     q.push(index);     dist[index][index] = 0;     while (!q.empty()) {       int cur = q.front();       q.pop();       for (int to : adj[cur]) {         if (dist[index][to] != -1) continue;         dist[index][to] = dist[index][cur] + 1;         q.push(to);       }     }   }   int main() {     while (scanf( %d %d , &n, &m) == 2) {       memset(dist, -1, sizeof dist);       for (int i = 0; i < n; i++) adj[i].clear();       for (int i = 0; i < m; i++) {         int a, b;         scanf( %d %d , &a, &b);         adj[--a].push_back(--b);         adj[b].push_back(a);       }       scanf( %d %d %d , &s1, &t1, &l1);       --s1, --t1;       scanf( %d %d %d , &s2, &t2, &l2);       --s2, --t2;       for (int i = 0; i < n; i++) bfs(i);       if (dist[s1][t1] > l1 || dist[s2][t2] > l2) {         puts( -1 );         continue;       }       int ans = dist[s1][t1] + dist[s2][t2];       for (int i = 0; i < n; i++)         for (int j = 0; j < n; j++) {           {             int p1 = dist[s1][i] + dist[i][j] + dist[j][t1];             int p2 = dist[s2][i] + dist[i][j] + dist[j][t2];             if (p1 <= l1 && p2 <= l2) ans = min(ans, p1 + p2 - dist[i][j]);           }           {             int p1 = dist[t1][i] + dist[i][j] + dist[j][s1];             int p2 = dist[s2][i] + dist[i][j] + dist[j][t2];             if (p1 <= l1 && p2 <= l2) ans = min(ans, p1 + p2 - dist[i][j]);           }         }       ans = m - ans;       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   const double INF = 1e20;   const int N = 102;   const int M = 1010;   const int K = 10;   int n;   double C, T;   const double Y = 1. / 0.9;   pair<int, int> a[N];   double dp[N][M];   void read() {     scanf( %d , &n);     scanf( %lf%lf , &C, &T);     for (int i = 0; i < n; i++) scanf( %d%d , &a[i].first, &a[i].second);     sort(a, a + n);   }   int solve() {     read();     dp[0][0] = 0;     for (int it = 1; it <= n; it++) {       for (int j = 0; j <= it * K; j++) dp[it][j] = INF;       for (int i = it - 1; i >= 0; i--)         for (int j = 0; j <= i * K; j++) {           if (dp[i][j] >= INF / 2) continue;           dp[i + 1][j + a[it - 1].second] = min(dp[i + 1][j + a[it - 1].second],                                                 dp[i][j] * Y + a[it - 1].first);         }     }     for (int x = n * K; x >= 0; x--)       for (int p = 0; p <= n; p++) {         if (p * K < x || dp[p][x] >= INF / 2) continue;         double X = dp[p][x] * Y;         double t = X;         if (C * X >= 1) t = 2 * sqrt(X / C) - 1. / C;         t += p * 10;         if (t <= T) return x;       }     throw;   }   int main() {     int t;     scanf( %d , &t);     while (t--) printf( %d n , solve());     return 0;   }