malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n;     cin >> n;     map<string, string> mp;     map<string, string>::iterator it;     for (int i = 0; i < n; ++i) {       string x, y;       cin >> x >> y;       it = mp.begin();       bool found = false;       for (; it != mp.end(); ++it) {         if (it->second == x) {           it->second = y;           found = true;         }       }       if (!found) mp[x] = y;     }     cout << mp.size() << endl;     it = mp.begin();     for (; it != mp.end(); it++) cout << it->first <<     << it->second << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   pair<int, int> h[100010], h1[100010];   long long cnt[100010], pre[100010], sum[100010];   int num[100010], mx[100010], n, tt, t1;   inline int rd() {     int x = 0;     char ch = getchar();     for (; ch <  0  || ch >  9 ; ch = getchar())       ;     for (; ch >=  0  && ch <=  9 ; ch = getchar()) x = x * 10 + ch -  0 ;     return x;   }   inline int gcd(int x, int y) { return (!y) ? x : gcd(y, x % y); }   inline long long calc(long long l, long long r) {     return (l + r) * (r - l + 1) / 2;   }   inline long long anol_gcd(long long n, long long a, long long b, long long c) {     if (n < 0) return 0;     if (!a) return (b / c) * (n + 1);     if (a >= c || b >= c)       return (a / c) * n * (n + 1) / 2 + (b / c) * (n + 1) +              anol_gcd(n, a % c, b % c, c);     long long hh = (a * n + b) / c;     return n * hh - anol_gcd(hh - 1, c, c - b - 1, a);   }   inline long long gao(int x, int y, long long mid) {     if (!cnt[x] || !cnt[y]) return 0;     mid -= pre[y - 1] - pre[x];     if (mid < 0) return 0;     long long mn = (mid - cnt[y] * y) / x;     mn = max(mn, 0LL);     if (mn >= cnt[x]) return cnt[x] * cnt[y];     long long res = mn * cnt[y];     mn++;     long long mx = mid / x;     mx = min(mx, cnt[x]);     if (mn <= mx) res += anol_gcd(mx - mn, x, mid - mx * x, y);     return res;   }   inline long long check(long long mid) {     long long res = 0;     int now = 1;     for (int i = 1; i <= 100000; i++) {       now = max(now, i);       long long hh = min(mid / i, cnt[i]);       if (cnt[i]) res += calc(cnt[i] - hh + 1, cnt[i]);       while (now + 1 <= 100000 && pre[now + 1] - pre[i - 1] <= mid) now++;       res += (sum[now] - sum[i]) * cnt[i];       mx[i] = now;     }     for (int i = 1; i <= 100000; i++)       for (int j = mx[i] + 1; j <= min(mx[i + 1] + 1, 100000); j++)         res += gao(i, j, mid);     return res;   }   int main() {     n = rd();     for (int i = 1; i <= n; i++) num[i] = rd();     cnt[num[1]]++;     h[tt = 1] = pair<int, int>(1, num[1]);     for (int i = 2; i <= n; i++) {       t1 = tt;       for (int j = 1; j <= t1; j++)         h1[j] = h[j], h1[j].second = gcd(h1[j].second, num[i]);       h1[++t1] = pair<int, int>(1, num[i]);       tt = 0;       for (int j = 1; j <= t1;) {         int k = j, now = 0;         for (; k <= t1 && h1[k].second == h1[j].second; k++) now += h1[k].first;         h[++tt] = pair<int, int>(now, h1[j].second);         j = k;       }       for (int j = 1; j <= tt; j++) cnt[h[j].second] += h[j].first;     }     for (int i = 1; i <= 100000; i++)       pre[i] = pre[i - 1] + cnt[i] * i, sum[i] = sum[i - 1] + cnt[i];     long long all = (long long)n * (n + 1) / 2;     all = all * (all + 1) / 2;     all = (all + 1) / 2;     long long l = 0, r = (long long)n * (n + 1) / 2 * 100000;     while (l < r) {       long long mid = (l + r) >> 1;       if (check(mid) >= all)         r = mid;       else         l = mid + 1;     }     printf( %lld n , l);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int w[505], p[1005], t[5001], was[105];   int main() {     int a, b, c, d, f = 0, n, m, x, y, i, j;     memset(was, 0, sizeof was);     memset(t, 0, sizeof t);     scanf( %d %d , &n, &m);     for (a = 1; a <= n; a++) scanf( %d , &w[a]);     for (a = 1; a <= m; a++) scanf( %d , &p[a]);     t[1] = p[1];     d = 2;     for (a = 2; a <= m; a++) {       y = 0;       for (i = 1; i < d; i++) {         if (t[i] == p[a]) {           for (b = i; b > 1; b--) {             t[b] = t[b - 1];             f += w[t[b]];           }           t[1] = p[a];           y = 1;           break;         }       }       if (y == 0) {         for (b = d; b > 1; b--) {           t[b] = t[b - 1];           f += w[t[b]];         }         t[1] = p[a];         d++;       }     }     printf( %d n , f);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   const int maxn = 4001;   long long dp[maxn], c[maxn][maxn], s[maxn][maxn], sum[maxn];   long long pow(int k) {     if (k == 0) return 1LL;     if (k == 1) return 2LL;     long long ans = pow(k >> 1);     ans *= ans;     if (k % 2) ans *= 2LL;     return (ans % 1000000007);   }   void pre() {     c[0][0] = c[1][0] = c[1][1] = 1LL;     s[1][0] = 0;     s[1][1] = 1LL;     for (int i = 2; i <= n; i++) {       c[i][0] = 1LL;       s[i][0] = 0;       for (int j = 1; j <= i; j++) {         c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % 1000000007;         s[i][j] = (j * s[i - 1][j] + s[i - 1][j - 1]) % 1000000007;       }     }     for (int i = 1; i <= n; i++)       for (int j = 0; j <= i; j++) sum[i] = (sum[i] + s[i][j]) % 1000000007;   }   int main() {     cin >> n;     pre();     dp[1] = 1;     dp[2] = 3;     for (int i = 3; i <= n; i++) {       dp[i] = 1;       for (int j = 1; j <= n - 1; j++)         dp[i] = (dp[i] + (dp[j] + sum[j]) * c[i - 1][j]) % 1000000007;     }     if (dp[n] < 0) dp[n] += 1000000007;     printf( %I64d n , dp[n]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k, a[101], m;   int main() {     m = 101;     cin >> n >> k;     for (int i = 1; i <= n; i++) {       cin >> a[i];       if (k % a[i] == 0) m = min(m, k / a[i]);     }     cout << m;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int cnt[50];   int main() {     int n, k;     cin >> n >> k;     int aa;     for (int i = 0; i < n; i++) {       int tmp = 0;       for (int j = k - 1; j >= 0; j--) {         scanf( %d , &aa);         tmp += (aa << j);       }       cnt[tmp]++;     }     if (cnt[0]) {       cout <<  YES ;       return 0;     }     int tot = (1 << k) - 1;     for (int i = 1; i <= tot; i++) {       if (cnt[i]) {         for (int j = 1; j <= tot; j++) {           if (cnt[j] && (i & j) == 0) {             cout <<  YES ;             return 0;           }         }       }     }     cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline void read(int &x) {     x = 0;     int f = 1;     char c = getchar();     while (c >  9  || c <  0 ) {       if (c ==  - ) f = -1;       c = getchar();     }     while (c >=  0  && c <=  9 )       x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();     x *= f;   }   const int maxn = 100100;   struct node {     int v, nxt;   } e[maxn];   int head[maxn], tot;   inline void add(int x, int y) {     tot++;     e[tot].v = y;     e[tot].nxt = head[x];     head[x] = tot;   }   struct AA {     int s, num;   };   map<string, int> h;   vector<AA> ask[maxn];   set<int> hip[maxn];   int n, q, s, t, cnt, name[maxn], dep[maxn], son[maxn], size[maxn], ans[maxn];   bool vis[maxn];   char ch[30];   inline void dfs1(int x, int fa) {     size[x] = 1;     dep[x] = dep[fa] + 1;     for (int i = head[x]; i; i = e[i].nxt) {       int v = e[i].v;       if (v == fa) continue;       dfs1(v, x);       size[x] += size[v];       if (son[x] == 0 || size[v] > size[son[x]]) son[x] = v;     }   }   inline void calc(int x, int fa) {     hip[dep[x]].insert(name[x]);     for (int i = head[x]; i; i = e[i].nxt) {       int v = e[i].v;       if (v == fa || vis[v]) continue;       calc(v, x);     }   }   inline void dfs2(int x, int fa, int keep) {     for (int i = head[x]; i; i = e[i].nxt) {       int v = e[i].v;       if (v == fa || v == son[x]) continue;       dfs2(v, x, 0);     }     if (son[x]) dfs2(son[x], x, 1), vis[son[x]] = true;     calc(x, fa);     vis[son[x]] = false;     for (int i = 0; i < ask[x].size(); i++) {       if (dep[x] + ask[x][i].s <= n)         ans[ask[x][i].num] = hip[dep[x] + ask[x][i].s].size();     }     if (!keep) {       for (int i = dep[x]; !hip[i].empty(); i++) {         hip[i].clear();       }     }   }   int main() {     read(n);     for (int i = 1; i <= n; i++) {       scanf( %s , ch);       if (h.find(ch) == h.end()) h[ch] = ++cnt;       name[i] = h[ch];       read(s), add(s, i);     }     read(q);     AA tmp;     for (int i = 1; i <= q; i++) {       read(s), read(t);       tmp.s = t;       tmp.num = i;       ask[s].push_back(tmp);     }     dep[0] = -1;     dfs1(0, 0);     dfs2(0, 0, 1);     for (int i = 1; i <= q; i++) printf( %d n , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> v[250005];   int visited[250005];   int n, m, x, y;   void zero() {     for (int i = 0; i <= n + 2; i++) {       visited[i] = 0;       v[i].clear();     }   }   void bipartite(int u) {     if (visited[u] == 1) {       x++;     } else if (visited[u] == 2) {       y++;     }     for (int i = 0; i < v[u].size(); i++) {       int a = v[u][i];       if (visited[a] == 0 && visited[u] == 1) {         visited[a] = 2;         bipartite(a);       } else if (visited[a] == 0 && visited[u] == 2) {         visited[a] = 1;         bipartite(a);       }     }   }   int main() {     int i, a, b, t;     scanf( %d , &t);     while (t--) {       scanf( %d %d , &n, &m);       zero();       for (i = 1; i <= m; i++) {         scanf( %d %d , &a, &b);         v[a].push_back(b);         v[b].push_back(a);       }       visited[1] = 1;       x = 0;       y = 0;       bipartite(1);       printf( %d n , min(x, y));       if (x <= y) {         for (i = 1; i <= n; i++) {           if (visited[i] == 1) {             printf( %d  , i);           }         }       } else {         for (i = 1; i <= n; i++) {           if (visited[i] == 2) {             printf( %d  , i);           }         }       }       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   #pragma GCC optimize( unroll-loops )   using namespace std;   using ll = long long;   using db = long double;   using ii = pair<int, int>;   const int N = 1e7 + 5, LG = 19, MOD = 1e9 + 7;   const int SQ = 225;   const long double EPS = 1e-7;   int fast(int b, int e) {     int res = 1;     for (; e; e >>= 1, b = 1ll * b * b % MOD)       if (e & 1) res = 1ll * res * b % MOD;     return res;   }   vector<int> adj[10005];   int n, k;   map<int, map<int, ll>> mat;   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n >> k;     vector<int> deg(n + 1);     for (int i = 1; i <= k; i++)       for (int j = i + 1; j <= k; j++) {         adj[j].push_back(i);         deg[j]++;         deg[i]++;       }     for (int i = k + 1; i <= n; i++) {       for (int j = 0; j < k; j++) {         int x;         cin >> x;         adj[i].push_back(x);         deg[i]++;         deg[x]++;       }     }     for (int i = 1; i <= n; i++) {       mat[i][i] = deg[i];       for (auto x : adj[i]) {         mat[i][x] = MOD - 1;         mat[x][i] = MOD - 1;       }     }     ll ans = 1;     for (int i = n; i >= 2; --i) {       ll v = mat[i][i];       ll inv = fast(MOD - v, MOD - 2);       ans = 1ll * ans * v % MOD;       for (auto j : adj[i]) {         ll coff = inv * mat[j][i] % MOD;         for (auto k : adj[i]) {           mat[j][k] = (mat[j][k] + mat[i][k] * coff) % MOD;         }       }     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1000000007;   long long powermodm(long long x, long long n, long long M) {     long long result = 1;     while (n > 0) {       if (n % 2 == 1) result = (result * x) % M;       x = (x * x) % M;       n = n / 2;     }     return result;   }   long long power(long long _a, long long _b) {     long long _r = 1;     while (_b) {       if (_b % 2 == 1) _r = (_r * _a);       _b /= 2;       _a = (_a * _a);     }     return _r;   }   long long gcd(long long a, long long b) {     if (a == 0) return b;     return gcd(b % a, a);   }   long long lcm(long long a, long long b) {     return (max(a, b) / gcd(a, b)) * min(a, b);   }   long long modInverse(long long x) { return powermodm(x, mod - 2, mod); }   long long fact[100005];   long long ncrmodm(long long n, long long r, long long m) {     return (fact[n] * (modInverse(fact[n - r]) * modInverse(fact[r])) % m) % m;   }   void init_fact() {     fact[0] = 0;     for (long long i = 1; i < 100001; i++) fact[i] = fact[i - 1] * i;   }   void write(long long a[], long long n) {     for (long long i = 0; i < n; i++) cout << a[i] <<    ;     cout << endl;   }   void show(vector<long long> v) {     for (long long i = 0; i < v.size(); i++) cout << v[i] <<    ;     cout << endl;   }   vector<vector<long long> > vec;   vector<long long> visited;   void dfs(int x, int p = -1) {     visited[x] = 1;     for (int i = 0; i < vec[x].size(); i++) {       if (p == vec[x][i]) continue;       if (!visited[vec[x][i]]) {         visited[vec[x][i]] = 1;         dfs(vec[x][i], x);       }     }   }   bool prime[100000];   void seive() {     int n = 100000;     memset(prime, true, sizeof(prime));     for (int p = 2; p * p <= n; p++) {       if (prime[p] == true) {         for (int i = p * p; i <= n; i += p) prime[i] = false;       }     }   }   void solve() {     long long n, k;     cin >> n >> k;     long long a[n];     long long ma = -INT_MAX, mi = INT_MAX;     for (long long i = 0; i < n; i++) {       cin >> a[i];       ma = max(ma, a[i]);       mi = min(mi, a[i]);     }     if (k % 2) {       for (long long i = 0; i < n; i++) {         cout << ma - a[i] <<    ;       }       cout << endl;     } else {       for (long long i = 0; i < n; i++) {         cout << -mi + a[i] <<    ;       }       cout << endl;     }   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int t = 1;     cin >> t;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int arr[503][503];   int main() {     int n, k;     cin >> n >> k;     int p = 1;     for (int i = 1; i <= n; i++) {       for (int j = 1; j < k; j++) {         arr[i][j] = p++;       }     }     for (int i = 1; i <= n; i++) {       for (int j = k; j <= n; j++) {         arr[i][j] = p++;       }     }     int sum = 0;     for (int i = 1; i <= n; i++) {       sum += arr[i][k];     }     cout << sum << endl;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         cout << arr[i][j] <<    ;       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 310, INF = (1 << 27);   int d[MAXN][MAXN];   int all[20][MAXN][MAXN];   int ans[MAXN][MAXN];   int main() {     ios::sync_with_stdio(false);     int n, m;     cin >> n >> m;     for (int i = 0; i < n; i++)       for (int j = 0; j < n; j++) d[i][j] = INF;     for (int i = 0; i < n; i++) d[i][i] = 0;     for (int i = 0; i < m; i++) {       int x, y, w1, w2;       cin >> x >> y >> w1 >> w2;       x--;       y--;       w1 = -w1;       w2 = -w2;       d[x][y] = w1;       d[y][x] = w2;     }     for (int i = 0; i < n; i++)       for (int j = 0; j < n; j++) all[0][i][j] = ans[i][j] = d[i][j];     for (int k = 0; k < n; k++)       for (int i = 0; i < n; i++)         for (int j = 0; j < n; j++) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);     bool hasNeg = false;     for (int i = 0; i < n; i++)       if (d[i][i] < 0) hasNeg = true;     if (!hasNeg) {       cout << 0 << endl;       return 0;     }     int ind;     for (ind = 1; (1 << ind) < n; ind++) {       for (int i = 0; i < n; i++)         for (int j = 0; j < n; j++) {           all[ind][i][j] = INF;           for (int k = 0; k < n; k++)             all[ind][i][j] =                 min(all[ind][i][j], all[ind - 1][i][k] + all[ind - 1][k][j]);         }     }     ind--;     int length = 1;     while (ind >= 0) {       int tmp[MAXN][MAXN];       for (int i = 0; i < n; i++)         for (int j = 0; j < n; j++) {           tmp[i][j] = INF;           for (int k = 0; k < n; k++)             tmp[i][j] = min(tmp[i][j], ans[i][k] + all[ind][k][j]);         }       hasNeg = false;       for (int i = 0; i < n; i++)         if (tmp[i][i] < 0) hasNeg = true;       if (!hasNeg) {         for (int i = 0; i < n; i++)           for (int j = 0; j < n; j++) ans[i][j] = tmp[i][j];         length += (1 << ind);       }       ind--;     }     cout << length + 1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e6 + 7;   const int mod = 51123987;   const int inv2 = mod + 1 >> 1;   struct Edge {     int to, last, v;   } E[maxn];   int fa[maxn];   int len[maxn];   int dep[maxn];   int head[maxn];   int tot;   int last;   int cnt;   int n;   char s[maxn];   int pre[maxn];   long long suf[maxn];   void Init() {     for (int i = 0; i <= tot; ++i) {       fa[i] = len[i] = dep[i] = 0;       head[i] = 0;     }     cnt = 0;     fa[last = 0] = fa[tot = 1] = 1;     len[1] = -1;   }   int Getfail(int x, int ed) {     while (s[ed] ^ s[ed - len[x] - 1]) x = fa[x];     return x;   }   int Check(int x, int v) {     for (int i = head[x], y; y = E[i].to, i; i = E[i].last)       if (E[i].v == v) return E[i].to;     return 0;   }   void Adde(int x, int y, int z) {     E[++cnt] = (Edge){y, head[x], z};     head[x] = cnt;   }   void Extend(int x, int ed) {     int p = Getfail(last, ed);     int np = Check(p, x);     if (!np) {       np = ++tot;       int pp = Getfail(fa[p], ed);       fa[np] = Check(pp, x);       Adde(p, np, x);       len[np] = len[p] + 2;       dep[np] = dep[fa[np]] + 1;     }     last = np;   }   int main() {     Init();     scanf( %d , &n);     scanf( %s , s + 1);     for (int i = 1; i <= n; ++i) Extend(s[i] -  a , i), pre[i] = dep[last];     Init();     reverse(s + 1, s + n + 1);     for (int i = 1; i <= n; ++i)       Extend(s[i] -  a , i), suf[n - i + 1] = dep[last];     for (int i = n; i; --i) suf[i] += suf[i + 1], suf[i] %= mod;     int ans = 0;     for (int i = 1; i <= n; ++i) (ans += 1LL * pre[i] * suf[i + 1] % mod) %= mod;     int sum = 1LL * suf[1] * (suf[1] - 1) / 2 % mod;     ans = (sum - ans) % mod;     ans < 0 ? ans += mod : 0;     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool vis[200005];   vector<int> v[200005], ak, d1, dn;   vector<int> bfs(int n) {     queue<int> q;     vector<int> dis(200005);     q.push(n);     vis[n] = true;     dis[n] = 0;     while (!q.empty()) {       int x = q.front();       q.pop();       for (int i = 0; i < v[x].size(); i++) {         int u = v[x][i];         if (vis[u] == false) {           vis[u] = true;           dis[u] = dis[x] + 1;           q.push(u);         }       }     }     return dis;   }   bool cmp(int x, int y) { return d1[x] < d1[y]; }   int main() {     int n, m, k, n1, n2, sp, ans = 0;     scanf( %d %d %d , &n, &m, &k);     for (int i = 0; i < k; i++) {       scanf( %d , &sp);       ak.push_back(sp);     }     for (int i = 0; i < m; i++) {       scanf( %d %d , &n1, &n2);       v[n1].push_back(n2);       v[n2].push_back(n1);     }     d1 = bfs(1);     memset(vis, false, sizeof(vis));     dn = bfs(n);     sort(ak.begin(), ak.end(), cmp);     for (int i = 1; i < ak.size(); i++) {       int x = ak[i - 1];       int y = ak[i];       ans = max(ans, d1[x] + 1 + dn[y]);     }     ans = min(ans, d1[n]);     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX_N = 1050;   pair<int, int> a[MAX_N];   int cnt[MAX_N];   int sub[MAX_N];   map<int, int> ids;   int inds[MAX_N];   int id = 0;   int countplz(int f0, int f1) {     memset((sub), 0, sizeof(sub));     ++sub[a[f0].second];     ++sub[a[f1].second];     int ans = 2;     while (true) {       int fnval = a[f0].first + a[f1].first;       auto it = ids.find(fnval);       if (it == ids.end()) {         return ans;       }       int fnid = it->second;       int fn = inds[fnid];       int rest = cnt[fnid] - sub[fnid];       if (rest <= 0) {         return ans;       }       ++ans;       sub[fnid]++;       f0 = f1;       f1 = fn;     }   }   int main() {     int n;     cin >> n;     for (int i = 0; i < n; ++i) {       int x;       cin >> x;       if (ids.count(x) == 0) {         ids[x] = id;         inds[id] = i;         ++id;       }       a[i] = make_pair(x, ids[x]);       cnt[ids[x]]++;     }     int maxs = 2;     if (ids.count(0) > 0) {       maxs = max(maxs, cnt[ids[0]]);     }     for (int i = 0; i < n; ++i) {       for (int j = 0; j < n; ++j) {         if (i == j || (a[i].first == a[j].first && a[i].first == 0)) {           continue;         }         maxs = max(maxs, countplz(i, j));       }     }     cout << maxs << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   class TaskB {    public:     long long dist(pair<long long, long long> f, pair<long long, long long> s) {       return (f.first - s.first) * (f.first - s.first) +              (f.second - s.second) * (f.second - s.second);     }     void solve(std::istream& cin, std::ostream& cout) {       ios_base::sync_with_stdio(0);       cin.tie(0);       cout.tie(0);       vector<pair<long long, long long> > v(3);       set<pair<long long, long long> > st;       for (long long i = 0; i < 3; i++) {         cin >> v[i].first >> v[i].second;       }       vector<pair<long long, long long> > ans;       if (1 || dist(v[1], v[2]) <= dist(v[0], v[1]) + dist(v[0], v[2])) {         ans.push_back({v[1].first + v[2].first - v[0].first,                        v[1].second + v[2].second - v[0].second});       }       if (1 || dist(v[0], v[2]) <= dist(v[2], v[1]) + dist(v[1], v[0])) {         ans.push_back({v[0].first + v[2].first - v[1].first,                        v[0].second + v[2].second - v[1].second});       }       if (1 || dist(v[1], v[0]) <= dist(v[2], v[1]) + dist(v[0], v[2])) {         ans.push_back({v[1].first + v[0].first - v[2].first,                        v[1].second + v[0].second - v[2].second});       }       cout << ans.size() << endl;       for (long long i = 0; i < ans.size(); i++)         cout << ans[i].first <<     << ans[i].second << endl;     }   };   int main() {     TaskB solver;     std::istream& in(std::cin);     std::ostream& out(std::cout);     solver.solve(in, out);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   string a, b;   set<int> A, B;   queue<int> qA, qB;   map<char, queue<int> > q;   vector<pair<int, int> > resp;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> n >> a >> b;     for (int i = 0; i < n; ++i) {       if (a[i] ==  ? )         qA.push(i);       else {         q[a[i]].push(i);         A.insert(i);       }     }     for (int i = 0; i < n; ++i) {       if (b[i] ==  ? )         qB.push(i);       else         B.insert(i);     }     for (int i = 0; i < n; ++i) {       if (!q[b[i]].empty()) {         resp.push_back({q[b[i]].front(), i});         B.erase(i);         A.erase(q[b[i]].front());         q[b[i]].pop();       }     }     while (!qA.empty() && !B.empty()) {       auto it = B.begin();       resp.push_back({qA.front(), *it});       qA.pop();       B.erase(it);     }     while (!qB.empty() && !A.empty()) {       auto it = A.begin();       resp.push_back({*it, qB.front()});       qB.pop();       A.erase(it);     }     while (!qA.empty() && !qB.empty()) {       resp.push_back({qA.front(), qB.front()});       qA.pop();       qB.pop();     }     cout << (int)resp.size() <<   n ;     for (auto x : resp) cout << x.first + 1 <<     << x.second + 1 <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     int n;     double p[111];     cin >> n;     for (int i = 0; i < n; i++) cin >> p[i];     sort(p, p + n);     double ans = p[n - 1], notAns = 1 - p[n - 1];     for (int i = n - 2; i >= 0 && ans < notAns; i--) {       ans = ans * (1 - p[i]) + notAns * p[i];       notAns *= (1 - p[i]);     }     printf( %.12lf n , ans);   }