malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N = 20;   const int mod = 998244353;   struct node {     int sum, tot;     node(){};     node(int S, int T) {       sum = S;       tot = T;     }     bool check() { return ~sum && ~tot; }   } f[2][2][N][1 << 10];   int A[N], ret, pw[30], k;   int lowbit(int x) { return x & -x; }   int ccount(int x) {     int cnt = 0;     if (!x) return 0;     while (x) {       x ^= lowbit(x);       cnt++;     }     return cnt;   }   node dfs(bool lim, bool zero, int pos, int st) {     if (!pos) return node(0, 1);     node& now = f[lim][zero][pos][st];     if (now.check()) return now;     now.sum = now.tot = 0;     for (int i = 0; i <= (lim ? A[pos] : 9); i++) {       if (ccount(zero && !i ? 0 : st | (1 << i)) <= k) {         node nxt = dfs(lim && i == A[pos], zero && !i, pos - 1,                        zero && !i ? 0 : st | (1 << i));         now.sum =             (now.sum + nxt.sum + 1ll * i * nxt.tot % mod * pw[pos - 1] % mod) %             mod;         now.tot = (now.tot + nxt.tot) % mod;       }     }     f[lim][zero][pos][st] = now;     return now;   }   int calc(long long x) {     ret = 0;     memset(f, -1, sizeof(f));     while (x) {       A[++ret] = x % 10;       x /= 10;     }     return dfs(1, 1, ret, 0).sum;   }   int main() {     pw[0] = 1;     for (int i = 1; i <= 20; i++) pw[i] = 10ll * pw[i - 1] % mod;     long long l, r;     cin >> l >> r >> k;     cout << (mod + calc(r) - calc(l - 1)) % mod;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1005;   const int dx[] = {0, 0, -1, 1};   const int dy[] = {-1, 1, 0, 0};   char mat[N][N];   int dist[N][N][3];   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, m;     cin >> n >> m;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         cin >> mat[i][j];       }     }     for (int i = 0; i < 3; i++) {       list<pair<int, int> > q;       for (int x = 0; x < n; x++) {         for (int y = 0; y < m; y++) {           if (mat[x][y] ==  1  + i) {             dist[x][y][i] = 0;             q.emplace_back(x, y);           } else             dist[x][y][i] = -1;         }       }       while (!q.empty()) {         int x = q.front().first, y = q.front().second;         q.pop_front();         for (int j = 0; j < 4; j++) {           int tx = x + dx[j], ty = y + dy[j];           if (tx >= 0 && tx < n && ty >= 0 && ty < m && mat[tx][ty] !=  # ) {             int td = dist[x][y][i] + (mat[tx][ty] ==  . );             if (dist[tx][ty][i] == -1 || dist[tx][ty][i] > td) {               dist[tx][ty][i] = td;               if (mat[tx][ty] ==  . )                 q.emplace_back(tx, ty);               else                 q.emplace_front(tx, ty);             }           }         }       }     }     int ans = 1000000000;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (dist[i][j][0] != -1 && dist[i][j][1] != -1 && dist[i][j][2] != -1) {           ans = min(ans, dist[i][j][0] + dist[i][j][1] + dist[i][j][2] -                              2 * (mat[i][j] ==  . ));         }       }     }     cout << (ans == 1000000000 ? -1 : ans);   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1100;   template <class nmsl>   inline void read(nmsl &x) {     x = 0;     char ch = getchar(), w = 0;     while (!isdigit(ch)) w = (ch ==  - ), ch = getchar();     while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();     x = w ? -x : x;   }   long long n, m, a, b, c, val[N], tot, cnt, ans[N], tt;   int main() {     read(n);     for (register int i = 1; i <= n; i++) read(val[i]), tot += val[i];     tt = val[1];     for (register int i = 2; i <= n; i++)       if (val[i] * 2 <= val[1]) ans[++cnt] = i, tt += val[i];     if (tt * 2 > tot) {       cout << cnt + 1 << endl << 1 <<    ;       for (register int i = 1; i <= cnt; i++) cout << ans[i] <<    ;     } else       cout << 0;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 100;   const double PI = 3.14159;   vector<string> v;   long long n, m, k, d, ans[101], c, sum, a[105][105];   set<string> st;   string s, b;   bool flag;   set<string>::iterator it;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cin >> n;     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         cin >> a[i][j];       }     }     for (int i = 0; i < n; i++) {       c = 0;       for (int j = 0; j < n; j++) {         if (i == j) continue;         if (a[i][j] == 0 || a[i][j] == 2) c++;       }       if (c == n - 1) {         sum++;         d = i + 1;         ans[d / 32] |= (1 << (d % 32));       }     }     cout << sum << endl;     for (int i = 1; i <= n; i++) {       if (ans[i / 32] & (1 << (i % 32))) cout << i <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int U = 200;   const int M = U + 5;   int n;   long double p, q;   long double f[M][M], F[M][M];   long double a[M][M];   long double C[M][M];   void input() {     int pp;     scanf( %d %d , &n, &pp);     p = pp / 1000000000.;     q = p * (1 - p);   }   void prepare() {     f[1][1] = p, F[1][1] = p, f[1][2] = 1 - p, F[1][2] = 2 - 2 * p;     for (int k = 2; k <= U; k++) {       f[k][1] = q;       for (int i = 2; i <= k; i++) F[k][1] += F[k - 1][i];       if (k > 2)         F[k][1] = F[k][1] * q / (1 - q) + q;       else         F[k][1] = 3 * q;       f[k][2] = 1 - q;       for (int i = 3; i <= k + 1; i++) f[k][i] = f[k][i - 1] * f[k - 1][i - 1];       for (int i = 2; i <= k + 1; i++) {         for (int j = i - 1; j >= 1; j--) {           F[k][i] += F[k - 1][j];         }         F[k][i] = F[k][i] * f[k][i] + i * (f[k][i] - f[k][i + 1]);       }     }     a[1][U] = q;     for (int j = 2; j < U; j++) a[1][j] = q / (1 - q);     for (int i = 2; i < U; i++) {       a[i][U] = i * (f[U][i] - f[U][i + 1]);       for (int j = i - 1; j >= 1; j--) a[i][j] = f[U][i];     }     a[U][U] = 1;   }   long double t[M][M];   void multi(long double C[][M], long double a[][M]) {     memset(t, 0, sizeof t);     for (int i = 1; i <= U; i++)       for (int j = 1; j <= U; j++)         for (int k = 1; k <= U; k++) t[i][k] += C[i][j] * a[j][k];     for (int i = 1; i <= U; i++)       for (int j = 1; j <= U; j++) C[i][j] = t[i][j];   }   double solve() {     long double rlt = 0;     if (n <= U) {       for (int i = 1; i <= n + 1; i++) rlt += F[n][i];       return rlt;     }     n -= U;     for (int i = 1; i <= U; i++) C[i][i] = 1;     while (n) {       if (n & 1) multi(C, a);       n >>= 1;       multi(a, a);     }     F[U][U] = 1;     for (int i = 1; i < U; i++) {       for (int j = 1; j <= U; j++) rlt += C[i][j] * F[U][j];     }     return rlt;   }   int main() {     input();     int nn = n;     n = min(1000000, n);     prepare();     double rlt = solve();     if (nn > 1000000) rlt = rlt / 1000000 * nn;     printf( %.15lf n , rlt);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     long long int n, o = 0, t = 0;     cin >> n;     for (long long int i = 0; i < n; i++) {       long long int x;       cin >> x;       if (x == 1)         o++;       else         t++;     }     if (t) {       cout << 2 <<    ;       t--;     }     if (o) {       cout << 1 <<    ;       o--;     }     while (t--) cout << 2 <<    ;     while (o--) cout << 1 <<    ;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   string grid[101];   int nb, l = 200, r = -1, u = 200, d = -1;   int main() {     scanf( %d %d , &n, &m);     for (int i = 0; i < n; i++) cin >> grid[i];     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++)         if (grid[i][j] ==  B ) {           nb++;           l = min(l, j);           r = max(r, j);           u = min(u, i);           d = max(d, i);         }     }     if (nb == 0) {       cout << 1 << endl;       return 0;     }     int h = d - u + 1, w = r - l + 1;     if (w > h) {       if (w > n) {         cout << -1 << endl;         return 0;       }       cout << w * w - nb << endl;     } else {       if (h > m) {         cout << -1 << endl;         return 0;       }       cout << h * h - nb << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = (int)5e5 + 50;   int n;   int ans[N];   vector<int> G[N];   int q[N];   int dep[N];   vector<pair<int, int> > hist[N];   void upd(int u, int val) { q[u] = max(q[u], val); }   void calc(int v, int p) {     dep[v] = 0;     for (int nxt : G[v]) {       if (nxt == p) continue;       calc(nxt, v);       dep[v] = max(dep[nxt] + 1, dep[v]);     }   }   void merge(vector<pair<int, int> > h1, vector<pair<int, int> > h2) {     int r = 0;     if (r < h2.size() && h2[r].second == 1) r++;     for (int i = 0; i < h1.size(); i++) {       if (h1[i].second == 1) continue;       while (r < h2.size() && (h2[r].first >= h1[i].first)) {         r++;       }       if (r - 1 >= 0 && h2[r - 1].second > 1)         upd(2 * h1[i].first, h2[r - 1].second + h1[i].second - 2);     }   }   void dfs(int v, int p = -1, int up_dep = -1) {     vector<int> deps;     if (up_dep != -1) deps.push_back(up_dep + 1);     for (int nxt : G[v]) {       if (nxt != p) deps.push_back(dep[nxt] + 1);     }     sort(deps.begin(), deps.end(),          [](const int a, const int b) { return a > b; });     for (int i = 0; i < deps.size(); i++) {       upd(2 * deps[i], i + 1);       upd(2 * deps[i] - 1, i + 1);       if (i > 0 && deps[i - 1] > deps[i]) upd(2 * deps[i] + 1, i + 1);     }     for (int i = 0; i < deps.size(); i++) {       if (hist[v].empty() || hist[v].back().first != deps[i])         hist[v].push_back({deps[i], 1});       else         hist[v].back().second++;     }     for (int i = 1; i < hist[v].size(); i++)       hist[v][i].second += hist[v][i - 1].second;     for (int nxt : G[v]) {       if (nxt == p) continue;       dfs(nxt, v,           (deps.size() == 1 ? 0 : (deps[0] == dep[nxt] + 1 ? deps[1] : deps[0])));       merge(hist[nxt], hist[v]);       merge(hist[v], hist[nxt]);     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cin >> n;     for (int i = 0; i < n - 1; i++) {       int a, b;       cin >> a >> b;       a--, b--;       G[a].push_back(b);       G[b].push_back(a);     }     for (int i = 0; i < n; i++) {       ans[1] = max(ans[1], (int)G[i].size() + 1);     }     calc(0, -1);     dfs(0);     int rmax = 0;     for (int i = (n - 1) / 2 * 2 + 1; i >= 2; i -= 2) {       rmax = max(rmax, q[i]);       ans[i] = rmax;     }     rmax = 0;     for (int i = n / 2 * 2; i >= 2; i -= 2) {       rmax = max(rmax, q[i]);       ans[i] = rmax;     }     for (int i = 1; i <= n; i++) cout << max(ans[i], 1) <<    ;   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = 0x3f3f3f3f3f3f3f3f;   int n, m, a[100010];   int tot[100010], Lpos = 1, Rpos = 0;   long long f[100010], g[100010], MO;   inline int read() {     int x = 0, w = 0;     char ch = 0;     while (!isdigit(ch)) {       w |= ch ==  - ;       ch = getchar();     }     while (isdigit(ch)) {       x = (x << 1) + (x << 3) + (ch ^ 48);       ch = getchar();     }     return w ? -x : x;   }   void add(int x) { MO += (tot[x]++); }   void del(int x) { MO -= (--tot[x]); }   long long calc(int l, int r) {     while (Lpos < l) del(a[Lpos++]);     while (Lpos > l) add(a[--Lpos]);     while (Rpos < r) add(a[++Rpos]);     while (Rpos > r) del(a[Rpos--]);     return MO;   }   void solve(int L, int R, int st, int ed) {     if (st > ed || L > R) return;     int M = (st + ed) >> 1;     M = max(M, L + 1);     long long temp = inf, pos = 0;     for (int i = L; i <= R; i++)       if (temp > g[i] + calc(i + 1, M)) temp = g[pos = i] + calc(i + 1, M);     f[M] = temp;     solve(L, pos, st, M - 1);     solve(pos, R, M + 1, ed);   }   int main() {     n = read();     m = read();     for (int i = 1; i <= n; i++) a[i] = read();     memset(g, 0x3f, sizeof g);     g[0] = 0;     while (m-- > 0) {       solve(0, n - 1, 1, n);       swap(f, g);     }     cout << g[n] <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = (int)1e9;   const double eps = (double)1e-8;   const int mod = (int)1000000007;   const int maxn = (int)2 * 1e5 + 5;   int n, x, y, mx;   int u[maxn], pr[maxn];   pair<int, int> t[maxn];   vector<pair<int, int> > a[maxn];   vector<int> ans;   list<int> q;   list<int>::iterator it1;   void dzen(int v, int p) {     pr[v] = p;     if (a[v].size() > 1 || v == 1) {       q.push_back(v);       u[v] = 0;       if (a[v][0].first == p) u[v] = 1;     }     mx = max((int)a[v].size(), mx);     for (int i = (0); i < (a[v].size()); i++) {       if (a[v][i].first == p) continue;       dzen(a[v][i].first, v);     }     return;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     cin >> n;     for (int i = (2); i <= (n); i++) {       cin >> x >> y;       a[x].push_back(make_pair(y, i - 1));       a[y].push_back(make_pair(x, i - 1));     }     mx = 0;     dzen(1, 0);     memset(t, -1, sizeof t);     cout << mx <<   n ;     while (mx--) {       ans.clear();       for (list<int>::iterator it = q.begin(); it != q.end();) {         if (t[pr[*it]].first == mx && t[pr[*it]].second == *it) {           it++;           continue;         }         t[*it] = make_pair(mx, a[*it][u[*it]].first);         ans.push_back(a[*it][u[*it]].second);         u[*it]++;         if (u[*it] < (int)a[*it].size() && a[*it][u[*it]].first == pr[*it])           u[*it]++;         if (u[*it] == (int)a[*it].size()) {           it1 = it;           it++;           q.erase(it1);         } else           it++;       }       cout << ans.size() <<    ;       for (int i = (0); i < (ans.size()); i++) {         cout << ans[i] <<    ;       }       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string k;   long long n;   long long Judge(int L, int R) {     int flag = 0;     for (int i = L; i <= R; i++) {       if (k[i] !=  0 ) flag = 1;     }     if (flag == 1 && k[L] ==  0 ) return -1;     long long ans = 0;     for (int i = L; i <= R; i++) {       ans = (ans * 10 + (k[i] -  0 ));     }     if (ans >= n) {       return -1;     } else       return ans;   }   int getL(int l, int r) {     for (int i = l; i <= r; i++) {       if (k[i] !=  0 ) return i;     }     return r;   }   int main() {     cin >> n >> k;     long long ans = 0;     int len = k.size();     long long base = 1;     int l = len - 1;     int r = len - 1;     long long val;     while (r >= 0) {       for (int i = 0; i <= r; i++) {         if (r - i > 17) continue;         val = 0;         for (int j = i; j <= r; j++) val = val * 10 + k[j] -  0 ;         if (val < n) {           l = i;           break;         }       }       while (l < r && k[l] ==  0 ) l++;       ans = ans + base * val;       base *= n;       r = l - 1;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxN = 5000 + 5;   const int lim = 1000 * 1000 * 1000;   const int inf = 1000 * 1000 * 1000 + 5;   int a[maxN];   vector<int> v[maxN];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n;     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i];     v[0].push_back(a[0]);     for (int i = 1; i < n; i++) {       int fl = 1;       for (int j = 0; j < v[i - 1].size(); j++) {         if (v[i - 1][j] < a[i])           v[i].push_back(v[i - 1][j]);         else {           if (fl) v[i].push_back(a[i]), fl = 0;           v[i].push_back(v[i - 1][j]);         }       }       if (fl) v[i].push_back(a[i]);     }     int ans = 0;     for (int i = 0; i < n; i++)       ans += v[i].size() - 1 -              (lower_bound(v[i].begin(), v[i].end(), a[i]) - v[i].begin());     int cnt = 0;     int answer = inf;     for (int i = 0; i < n; i++)       for (int j = i + 1; j < n; j++) {         if (a[i] < a[j]) continue;         int tmp = ans;         tmp -= v[i].size() - 1 -                2 * (lower_bound(v[i].begin(), v[i].end(), a[i]) - v[i].begin());         tmp -= v[j].size() - 1 -                2 * (lower_bound(v[j].begin(), v[j].end(), a[j]) - v[j].begin());         tmp += v[i].size() -                2 * (lower_bound(v[i].begin(), v[i].end(), a[j]) - v[i].begin());         tmp += v[j].size() -                2 * (lower_bound(v[j].begin(), v[j].end(), a[i]) - v[j].begin());         if (a[i] > a[j])           tmp--;         else           tmp++;         if (tmp < answer)           answer = tmp, cnt = 1;         else if (tmp == answer)           cnt++;       }     cout << answer <<     << cnt << endl;     return 0;   }
#include <bits/stdc++.h>   const int INF = 1e9 + 7;   const int MAXN = 3e5 + 10;   using namespace std;   int main() {     int a, b, c, d;     cin >> a >> b >> c >> d;     for (int i = a; i <= 2 * a; i++) {       for (int j = b; j <= 2 * b; j++) {         for (int k = c; k <= 2 * c; k++) {           if (i > j && j > k && d <= i && d <= j && d <= k) {             if (k <= d + d && j > d + d && i > d + d) {               cout << i <<   n  << j <<   n  << k;               return 0;             }           }         }       }     }     cout << -1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const double EPS = 1e-9;   int T, n;   int num[1000015], p[1000015], cnt, sum[1000015];   int main() {     scanf( %d , &T);     while (T--) {       scanf( %d , &n);       for (int i = 1; i <= n; ++i) {         scanf( %d , &p[i]);       }       num[cnt = 1] = 1;       for (int i = 2; i <= n; ++i) {         if (p[i] == p[i - 1]) {           ++num[cnt];         } else {           num[++cnt] = 1;         }       }       for (int i = 1; i <= cnt; ++i) {         sum[i] = sum[i - 1] + num[i];       }       sum[cnt + 1] = INF;       int g = 0, s = 0, b = 0;       for (int i = 1, j = 2, k = 3; k <= n; ++i) {         while (j <= n && sum[j] - sum[i] <= sum[i]) ++j;         while (k < n && sum[k + 1] <= sum[cnt] / 2) ++k;         if (j <= n && k <= n && sum[i] < sum[k] - sum[j] &&             sum[k] <= sum[cnt] / 2) {           g = sum[i];           s = sum[j] - sum[i];           b = sum[k] - sum[j];         } else {           break;         }       }       printf( %d %d %d n , g, s, b);     }     return 0;   }
#include <bits/stdc++.h>   #pragma warning(disable : 4996)   using namespace std;   long long int a[100010];   int n;   int main() {     int i, j;     while (scanf( %d , &n) != EOF) {       for (i = 1; i <= n; i++) {         scanf( %lld , &a[i]);       }       sort(a + 1, a + 1 + n);       long long sum = a[1];       int ans = 1;       for (i = 2; i <= n; i++) {         if (a[i] >= sum) {           ans++;           sum += a[i];         }       }       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 105;   const double EPS = 1e-9;   int n, k;   double e;   int px0, py0;   int x[MAXN], y[MAXN];   double dp[MAXN][2];   double dist(int x1, int y1, int x2, int y2) {     return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));   }   double prob(int ind, double rad) {     double _dist = dist(x[ind], y[ind], px0, py0);     if (_dist <= rad) return 1;     return exp(1 - pow(_dist, 2) / pow(rad, 2));   }   bool check(double rad) {     for (int i = 0; i < MAXN; i++) dp[i][0] = dp[i][1] = 0;     dp[0][0] = 1;     for (int i = 0; i < n; i++) {       double p = prob(i, rad);       for (int j = 0; j < MAXN - 1; j++) {         dp[j + 1][1] += dp[j][0] * p;         dp[j][1] += dp[j][0] * (1 - p);       }       for (int j = 0; j < MAXN; j++) dp[j][0] = dp[j][1], dp[j][1] = 0;     }     double sum = 0;     for (int i = 0; i < k; i++) sum += dp[i][0];     return sum < e;   }   int main() {     ios ::sync_with_stdio(0);     if (fopen( input.txt ,  r )) freopen( input.txt ,  r , stdin);     cin >> n >> k;     int _e;     cin >> _e;     e = 1. * _e / 1000;     cin >> px0 >> py0;     for (int i = 0; i < n; i++) cin >> x[i] >> y[i];     double lo = 0, hi = 5000;     while (abs(hi - lo) > 2 * EPS) {       double mid = (lo + hi) / 2;       if (check(mid))         hi = mid;       else         lo = mid + EPS;     }     cout << fixed << setprecision(10) << lo << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int dp[100010];   long long int sum[100010];   int main() {     int n;     int k;     int m;     cin >> m >> k;     dp[0] = 1;     for (int i = 1; i < k; i++) {       dp[i] = 1;     }     for (int i = k; i <= 100002; i++) {       dp[i] = (dp[i - 1] + dp[i - k]) % 1000000007;     }     sum[0] = 0;     for (int i = 1; i <= 100002; i++) {       sum[i] = (sum[i - 1] + dp[i]) % 1000000007;     }     int a, b;     while (m--) {       cin >> a >> b;       long long int val = ((sum[b] - sum[a - 1]) + 1000000007) % 1000000007;       cout << val << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T1, typename T2>   inline T1 max(T1 a, T2 b) {     return a < b ? b : a;   }   template <typename T1, typename T2>   inline T1 min(T1 a, T2 b) {     return a < b ? a : b;   }   const char lf =   n ;   namespace ae86 {   const int bufl = 1 << 15;   char buf[bufl], *s = buf, *t = buf;   inline int fetch() {     if (s == t) {       t = (s = buf) + fread(buf, 1, bufl, stdin);       if (s == t) return EOF;     }     return *s++;   }   inline int ty() {     int a = 0;     int b = 1, c = fetch();     while (!isdigit(c)) b ^= c ==  - , c = fetch();     while (isdigit(c)) a = a * 10 + c - 48, c = fetch();     return b ? a : -a;   }   inline double td() {     double a = 0, d = 0.1;     int b = 1, c = fetch();     while (!isdigit(c)) b ^= c ==  - , c = fetch();     while (isdigit(c)) a = a * 10 + c - 48, c = fetch();     if (c !=  . ) return b ? a : -a;     while (c = fetch(), isdigit(c)) a += d * (c - 48), d *= 0.1;     return b ? a : -a;   }   }  // namespace ae86   using ae86::td;   using ae86::ty;   const int _ = 23, __ = 1 << 20;   int n, nn, lim, bcnt[__] = {0};   double ps[_], sps[__] = {0}, f[__] = {0}, ans[_] = {0};   int main() {     ios::sync_with_stdio(0), cout.tie(nullptr);     n = ty(), nn = 1 << n, lim = ty();     int cnts = 0;     for (int i = 0; i < n; i++) ps[i] = td(), cnts += ps[i] > 0;     if (cnts < lim) {       for (int i = 0; i < n; i++) cout <<  01 [ps[i] > 0] <<    n [i == n - 1];       return 0;     }     for (int i = 0; i < nn; i++)       for (int j = 0; j < n; j++)         if ((((i) >> (j)) & 1)) sps[i] += ps[j];     bcnt[0] = 0;     for (int i = 1; i < nn; i++) bcnt[i] = bcnt[i >> 1] + (i & 1);     f[0] = 1;     for (int i = 0; i < nn; i++) {       if (bcnt[i] == lim)         for (int j = 0; j < n; j++)           if ((((i) >> (j)) & 1)) ans[j] += f[i];       if (bcnt[i] >= lim) continue;       for (int j = 0; j < n; j++)         if (!(((i) >> (j)) & 1)) f[i | (1 << (j))] += f[i] * ps[j] / (1 - sps[i]);     }     for (int i = 0; i < n; i++)       cout << setprecision(11) << fixed << ans[i] <<    n [i == n - 1];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #pragma GCC optimize( Ofast )   const long long maxn = 3000 + 10, N = 2e5 + 10, SQ = 320, base = 800287,                   mod = 1e9 + 7, INF = 1e18 + 10, lg = 22;   const long double eps = 1e-4;   long long n, m, q, dis[maxn][maxn], res[N];   long long V[N], U[N], r[N], s[N], t[N];   vector<long long> query[N];   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> n >> m >> q;     for (long long i = 0; i < m; ++i) {       cin >> V[i] >> U[i];       V[i]--, U[i]--;     }     for (long long i = 0; i < n; ++i) {       for (long long j = 0; j < n; ++j) {         dis[i][j] = (i != j ? INF : m);       }     }     for (long long i = 0; i < q; ++i) {       long long l;       cin >> l >> r[i] >> s[i] >> t[i];       l--, r[i]--, s[i]--, t[i]--;       query[l].push_back(i);     }     for (long long idx = m - 1; idx >= 0; --idx) {       dis[V[idx]][U[idx]] = dis[U[idx]][V[idx]] = idx;       for (long long i = 0; i < n; ++i) {         long long val = min(dis[V[idx]][i], dis[U[idx]][i]);         dis[V[idx]][i] = dis[U[idx]][i] = val;       }       for (auto i : query[idx]) {         if (dis[s[i]][t[i]] > r[i]) {           res[i] = 0;         } else {           res[i] = 1;         }       }     }     for (long long i = 0; i < q; ++i) {       cout << (res[i] ?  Yes n  :  No n );     }   }