malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int Ask(int x, int y) {     printf( ? %d %d n , x, y);     fflush(stdout);     int t;     scanf( %d , &t);     return t;   }   int vis[105], t[105], n;   struct bt {     bitset<105> A;     int id;     int operator[](int x) { return A[x]; }     friend bool operator<(bt x, bt y) {       for (int i = n; ~i; i--)         if (x[i] ^ y[i]) return x[i] < y[i];       return 0;     }     int mx() {       for (int i = n; ~i; i--)         if (A[i]) return i;       return -1;     }   } dp[105];   map<pair<int, int>, int> val;   priority_queue<bt> q;   vector<int> e[105];   bool chk(vector<bt> f) {     for (auto x : f) q.push(x);     if (q.empty()) return 1;     for (int i = n; ~i; i--)       if (t[i]) {         bt x = q.top();         q.pop();         int v = x.mx();         if (v > i)           break;         else if (v == i)           x.A[v] = 0, q.emplace(x);         if (!q.size()) return 1;       }     while (q.size()) q.pop();     return 0;   }   void produce(int u, vector<bt> f) {     for (auto x : f) q.push(x);     if (q.empty()) return;     for (int i = n; ~i; i--)       if (t[i]) {         bt x = q.top();         q.pop();         int v = x.mx();         if (v == i)           x.A[v] = 0, q.emplace(x);         else           val[pair<int, int>(x.id, u)] = val[pair<int, int>(u, x.id)] = i;         if (!q.size()) break;       }     while (q.size()) q.pop();   }   void dfs1(int u, int fa) {     vector<bt> g;     dp[u].id = u;     for (int v : e[u])       if (v != fa) dfs1(v, u), g.push_back(dp[v]);     fill(t, t + n, 1);     t[n] = 0;     for (int i = n; ~i; i--, t[i] = 0)       if (!chk(g)) t[i] = 1;     for (int i = 0; i <= n; i++) dp[u].A[i] = t[i];     produce(u, g);   }   pair<int, int> id;   void dfs2(int u, int fa, int &mx) {     for (int v : e[u])       if (!vis[v] && v != fa) {         int k = val[pair<int, int>(u, v)];         if (k > mx) mx = k, id = pair<int, int>(u, v);         dfs2(v, u, mx);       }   }   void solve(int u, int fa) {     int mx = -1;     dfs2(u, fa, mx);     if (mx == -1) printf( ! %d n , u), fflush(stdout), exit(0);     int res = Ask(id.first, id.second);     if (res == id.first)       vis[id.second] = 1, solve(id.first, id.second);     else       vis[id.first] = 1, solve(id.second, id.first);   }   int main() {     scanf( %d , &n);     for (int i = 1, u, v; i < n; i++)       scanf( %d%d , &u, &v), e[u].emplace_back(v), e[v].emplace_back(u);     dfs1(1, 0);     solve(1, 0);   }
#include <bits/stdc++.h>   using namespace std;   template <typename... T>   inline void inp(T &...args) {     ((cin >> args), ...);   }   template <typename T>   inline istream &operator>>(istream &in, vector<T> &a) {     for (auto &x : a) in >> x;     return in;   }   template <typename T, typename U>   inline istream &operator>>(istream &in, pair<T, U> &a) {     in >> a.first >> a.second;     return in;   }   const long long int MX = 1e6 + 10;   const long long int Mod = 998244353;   inline long long int md(long long int x, long long int M = Mod) {     x %= M;     return ((x < 0) ? (x + M) : x);   }   vector<long long int> fact(MX), invfact(MX), inv(MX);   void init_fact(long long int m = Mod) {     inv[0] = 0;     inv[1] = fact[0] = fact[1] = invfact[0] = invfact[1] = 1;     for (long long int i = 2; i < MX; i++) {       fact[i] = md(fact[i - 1] * i, m);       inv[i] = m - (m / i) * inv[m % i] % m;       invfact[i] = md(inv[i] * invfact[i - 1], m);     }   }   long long int NPR(long long int n, long long int r) {     if (0 <= r and r <= n) {       return md(fact[n] * invfact[n - r]);     }     return 0;   }   long long int NCR(long long int n, long long int r) {     if (0 <= r and r <= n) {       return md(fact[n] * md(invfact[r] * invfact[n - r]));     }     return 0;   }   void solve(int &T) {     long long int n, k;     cin >> n >> k;     vector<pair<long long int, long long int>> a;     for (long long int i = (0); ((1) > 0 ? i < (n) : i > (n)); i += (1)) {       long long int x, y;       cin >> x >> y;       a.push_back({x, 1});       a.push_back({y + 1, -1});     }     sort((a).begin(), (a).end());     long long int cnt = 0, ans = 0;     for (long long int i = (0); ((1) > 0 ? i < (2 * n) : i > (2 * n)); i += (1)) {       if (a[i].second == 1) {         if (cnt >= k - 1) {           ans = md(ans + NCR(cnt, k - 1));         }         cnt++;       } else {         cnt--;       }     }     cout << ans <<   n ;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     init_fact();     int t = 1;     for (int i = 1; i <= t; i++) {       if (0) cerr <<  Case #  << i <<   n ;       solve(i);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   long long a[100005];   long long sum1[100005], sum2[100005];   int main() {     memset(sum1, 0, sizeof(sum1));     memset(sum2, 0, sizeof(sum2));     cin >> n;     for (int i = 1; i <= n; ++i) {       cin >> a[i];       sum1[i] = sum1[i - 1] + a[i];     }     sort(a + 1, a + n + 1);     for (int i = 1; i <= n; ++i) {       sum2[i] = sum2[i - 1] + a[i];     }     cin >> m;     for (int i = 0; i < m; ++i) {       int q, l, r;       cin >> q >> l >> r;       if (q == 1) {         cout << sum1[r] - sum1[l - 1] << endl;       } else {         cout << sum2[r] - sum2[l - 1] << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   bool fun(long long a);   using namespace std;   int main() {     long long num, num1, num2;     cin >> num;     if (num % 2 == 0) {       num1 = num / 2;       num2 = num / 2;       while (!fun(num1) || !fun(num2)) {         num1 -= 1;         num2 += 1;       }     } else {       num1 = num / 2;       num2 = num / 2 + 1;       while (!fun(num1) || !fun(num2)) {         num1 -= 1;         num2 += 1;       }     }     cout << num1 <<     << num2;   }   bool fun(long long a) {     int c = 0;     for (int i = 2; i < a; i++) {       if (a % i == 0) {         c = 1;         break;       }     }     return c == 1;   }
#include <bits/stdc++.h>   using namespace std;   int n, tab[1000001];   void draw() {     for (int i = 0; i < n; i++) {       cout << tab[i] <<    ;     }     cout << endl;   }   int main() {     cin >> n;     for (int i = 0; i < n; i++) {       cin >> tab[i];     }     sort(tab, tab + n);     if (n % 2 == 1) {       cout << tab[n / 2] << endl;     } else {       cout << tab[n / 2 - 1] << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline T read(T& x) {     x = 0;     int f = 0;     char ch = getchar();     while (ch <  0  || ch >  9 ) f |= (ch ==  - ), ch = getchar();     while (ch >=  0  && ch <=  9 ) x = x * 10 + ch -  0 , ch = getchar();     return x = f ? -x : x;   }   const int N = 3e5 + 10;   const int INF = 2000000000;   int n, k, i, ans, minx, maxx, miny, maxy, x[N], y[N];   int main() {     read(n);     minx = miny = INF, maxx = maxy = -INF;     for (i = 0; i < n; ++i) {       read(x[i]), read(y[i]);       minx = min(minx, x[i]);       miny = min(miny, y[i]);       maxx = max(maxx, x[i]);       maxy = max(maxy, y[i]);     }     for (ans = -INF, i = 0; i < n; ++i) {       ans = max(ans, 2 * (maxx - x[i]) + 2 * (maxy - y[i]));       ans = max(ans, 2 * (maxx - x[i]) + 2 * (y[i] - miny));       ans = max(ans, 2 * (x[i] - minx) + 2 * (maxy - y[i]));       ans = max(ans, 2 * (x[i] - minx) + 2 * (y[i] - miny));     }     printf( %d%c , ans, n == 3 ?   n  :    );     for (i = 4; i <= n; ++i)       printf( %d%c , 2 * (maxx - minx + maxy - miny), i == n ?   n  :    );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool debug = 1;   int n, m, k;   int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};   long long ln, lk, lm;   vector<int> mp[100005];   int r1, r2, fa[100005], s[100005], no[100005], cnt, d[100005], w[100005];   bool vis[100005];   int bfs(int x) {     queue<int> q;     q.push(x);     fa[x] = 0;     vis[x] = 1;     while (!q.empty()) {       x = q.front();       q.pop();       for (int c : mp[x])         if (!vis[c]) {           fa[c] = x;           vis[c] = 1;           q.push(c);         }     }     for (int(i) = 0; (i) < (int)(100005); (i)++) vis[i] = 0;     return x;   }   void dfs(int x, int dp, int fa, int col) {     d[x] = dp;     no[x] = col;     w[col] = max(w[col], dp);     for (int c : mp[x])       if (c != fa && !vis[c]) {         dfs(c, dp + 1, x, col);       }   }   int T[2][100005][20];   void init() {     for (int(i) = 1; (i) <= (int)(cnt); (i)++) {       T[0][i][0] = w[i] + i;       T[1][i][0] = w[i] - i;     }     for (int j = 1; (1 << j) <= cnt; j++) {       for (int i = 1; i + (1 << j) - 1 <= cnt; i++) {         for (int(x) = 0; (x) < (int)(2); (x)++)           T[x][i][j] = max(T[x][i][j - 1], T[x][i + (1 << (j - 1))][j - 1]);       }     }   }   int qym(int l, int r, int p) {     if (l > r) return -(1 << 30);     int x = log(r - l + 1) / log(2);     int y = max(T[p][l][x], T[p][r - (1 << x) + 1][x]);     return y;   }   int main() {     scanf( %d , &n);     for (int i = 0, u, v; i < n - 1; i++) {       scanf( %d%d , &u, &v);       mp[u].push_back(v);       mp[v].push_back(u);     }     r1 = bfs(1);     r2 = bfs(r1);     for (int(i) = 0; (i) < (int)(100005); (i)++) vis[i] = 0;     for (int i = r2; i; i = fa[i]) {       vis[i] = 1;       s[++cnt] = i;       no[i] = cnt;     }     for (int(i) = 1; (i) <= (int)(cnt); (i)++) dfs(s[i], 0, 0, i);     init();     scanf( %d , &m);     for (int i = 0, x, y, ans; i < m; i++) {       scanf( %d%d , &x, &y);       int l = no[x], r = no[y];       if (r < l) {         swap(l, r);         swap(x, y);       }       if (l == r) {         ans = max(l - 1, cnt - r) + min(d[x], d[y]);       } else {         int mid2 = l + r - d[x] + d[y];         if (mid2 <= l * 2) {           ans = d[y] + max(r - 1, cnt - r);         } else if (mid2 >= r * 2) {           ans = d[x] + max(l - 1, cnt - l);         } else {           int mid = mid2 / 2;           int L = max(l - 1, qym(l + 1, mid, 0) - l) + d[x];           int R = max(cnt - r, qym(mid + 1, r - 1, 1) + r) + d[y];           ans = max(L, R);         }       }       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   namespace fio {   streambuf* in = cin.rdbuf();   char bb[1000000], *s = bb, *t = bb;   inline long long read() {     long long x = 0;     char ch =         (s == t && (t = (s = bb) + in->sgetn(bb, 1000000), s == t) ? EOF : *s++);     while (ch < 48)       ch = (s == t && (t = (s = bb) + in->sgetn(bb, 1000000), s == t) ? EOF                                                                       : *s++);     while (ch >= 48)       x = x * 10 + ch - 48,       ch = (s == t && (t = (s = bb) + in->sgetn(bb, 1000000), s == t) ? EOF                                                                       : *s++);     return x;   }   }  // namespace fio   using fio::read;   long long n;   int m, llm;   int lim[26];   vector<int> road[26];   map<array<int, 26>, int> huaji;   array<int, 26> pm;   class mat {    public:     int val[125][125];     int* operator[](int x) { return val[x]; }     mat operator*(mat _) {       mat ans;       for (int i = 1; i <= llm; i++)         for (int u = 1; u <= llm; u++) {           ans[i][u] = 0;           for (int j = 1; j <= llm; j++)             ans[i][u] = (ans[i][u] + val[i][j] * _[j][u]) % 12345;         }       return ans;     }   };   mat ksm(mat x, long long y) {     mat ans = x;     y--;     for (; y; y >>= 1, x = x * x)       if (y & 1) ans = ans * x;     return ans;   }   mat base;   int ans;   int main() {     n = read(), m = read();     if (!n) return cout << 1, 0;     if (!m) return cout << 0, 0;     for (int i = 1, x, y; i <= m; i++)       x = read() +  0  -  A , road[x].emplace_back(y = read()),       lim[x] = max(lim[x], 1) * road[x].back();     while (pm[25] < max(lim[25], 1)) {       huaji[pm] = ++llm, pm[0]++;       for (int i = 0; i < 25; i++)         if (lim[i])           pm[i + 1] += pm[i] / lim[i], pm[i] %= lim[i];         else           pm[i + 1] += pm[i], pm[i] = 0;     }     for (pair<array<int, 26>, int> it : huaji)       for (int i = 0; i < 26; i++)         if (lim[i])           it.first[i] = (it.first[i] + 1) % lim[i],           base[it.second][huaji[it.first]]++,           it.first[i] = (it.first[i] - 1 + lim[i]) % lim[i];     base = ksm(base, n);     for (pair<array<int, 26>, int> it : huaji) {       bool flag = 1;       for (int i = 0, fx = 0; flag && i < 26; i++, flag &= fx, fx = 0)         if (!lim[i])           fx = 1;         else           for (int p : road[i]) fx |= !(it.first[i] % p);       flag ? ans = (ans + base[1][it.second]) % 12345 : ans;     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   vector<vector<set<int> > > setgrid;   vector<string> grid;   int k;   int ro[4] = {1, -1, 0, 0};   int co[4] = {0, 0, -1, 1};   struct s {     s() : r(-1), c(-1), set(-1), path(  ), let( A ), d(0) {}     s(int nr, int nc, unsigned int nset, string npath, char nlet, int nd)         : r(nr), c(nc), set(nset), path(npath), let(nlet), d(nd) {}     int r, c, d;     unsigned int set;     string path;     char let;   };   bool operator<(const s &lhs, const s &rhs) {     if (lhs.d == rhs.d)       if (lhs.path == rhs.path)         return lhs.let >= rhs.let;       else         return lhs.path >= rhs.path;     else       return lhs.d >= rhs.d;   }   bool visited(int r, int c, unsigned int set) {     unsigned int subset = set;     do {       subset = (subset - 1) & set;       if (setgrid[r][c].find(subset) != setgrid[r][c].end()) {         return true;       }     } while (subset != set);     return false;   }   int main(void) {     s qf;     int rs, cs, nr, nc;     unsigned int nset, one = 0x00000001;     priority_queue
 q;     vector
 pv, tv;     cin >> rs >> cs >> k;     grid.resize(rs);     for (int i = 0; i < rs; i++) cin >> grid[i];     setgrid.resize(rs);     for (int i = 0; i < rs; i++) setgrid[i].resize(cs);     int sr, sc;     for (int i = 0; i < rs; i++)       for (int j = 0; j < cs; j++)         if (grid[i][j] ==  S ) {           sr = i;           sc = j;           break;         }     q.push(s(sr, sc, 0,   ,  a , 0));     setgrid[sr][sc].insert(0);     while (!q.empty()) {       pv.clear();       qf = q.top();       for (int i = 0; i < 4; i++) {         nr = qf.r + ro[i];         nc = qf.c + co[i];         if (nr < 0 || nr >= rs || nc < 0 || nc >= cs) continue;         if (grid[nr][nc] ==  T ) goto success;         nset = qf.set | (one << int(grid[nr][nc] -  a ));         if ((__builtin_popcount(nset) > k) || visited(nr, nc, nset)) continue;         pv.push_back(             s(nr, nc, nset, qf.path + grid[nr][nc], grid[nr][nc], qf.d + 1));         setgrid[nr][nc].insert(nset);       }       sort(pv.begin(), pv.end());       for (int i = 0; i < pv.size(); i++) q.push(pv[i]);       q.pop();     }     cout << -1 <<   n ;     return 0;   success:     if (qf.path !=   ) cout << qf.path <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, x, y;   bool a[401][401];   bool viz[401];   int dist[401];   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cerr.tie(0);     cout.tie(0);     cin >> n >> m;     while (m--) {       cin >> x >> y;       a[x][y] = a[y][x] = 1;     }     queue<int> q;     q.push(1);     viz[1] = 1;     while (!q.empty()) {       int u = q.front();       q.pop();       for (int i = 1; i <= n; i++)         if (!viz[i] && (a[u][i] ^ a[1][n])) {           q.push(i);           viz[i] = 1;           dist[i] = dist[u] + 1;         }     }     return cout << ((!viz[n]) ? -1 : max(1, dist[n])), 0;   }
#include <bits/stdc++.h>   using namespace std;   int main(int argc, char** argv) {     char s[3][3];     bool is = false;     for (int i = 0; i < 3; i++) {       for (int j = 0; j < 3; j++) {         cin >> s[i][j];         if (s[i][j] ==  X ) is = true;       }     }     int i = 0, j = 0;     bool isY = true;     for (int i = 0; i < 3; i++) {       for (int j = 0; j < 3; j++)         if (s[i][j] != s[2 - i][2 - j]) isY = false;     }     if (isY)       cout <<  YES ;     else       cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double p1, p2;   double fastPow(double b, int n) {     if (n == 0) return 1.0;     double po = fastPow(b, n / 2);     po = po * po;     if (n & 1) return po * b;     return po;   }   double proba(int turno) {     double ans = 1;     ans = ans * fastPow(1 - p1, turno / 2);     ans = ans * fastPow(1 - p2, turno / 2);     return ans * p1;     return ans * p1;   }   int main() {     double a, b, c, d;     while (cin >> a >> b >> c >> d) {       double prob = 0;       p1 = a / b;       p2 = c / d;       for (int i = 1; i < 100000; i += 2) prob = prob + proba(i);       cout << prob << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxN = 3e5 + 5;   map<pair<int, int>, int> mp;   int counts[maxN];   set<int> s[maxN];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int N, P;     cin >> N >> P;     for (int i = 0; i < N; i++) {       pair<int, int> xy;       cin >> xy.first >> xy.second;       xy = {min(xy.first, xy.second), max(xy.first, xy.second)};       if (mp.count(xy) > 0)         mp[xy]++;       else         mp[xy] = 1;       counts[xy.first]++;       counts[xy.second]++;       s[xy.first].insert(xy.second);       s[xy.second].insert(xy.first);     }     vector<int> ordered;     for (int i = 1; i <= N; i++) {       ordered.push_back(counts[i]);     }     sort(ordered.begin(), ordered.end());     long long ans = 0;     for (int i = 1; i <= N; i++) {       int rem = P - counts[i];       int k = lower_bound(ordered.begin(), ordered.end(), rem) - ordered.begin();       int tot = N - k;       if (counts[i] >= rem) tot--;       for (auto it = s[i].begin(); it != s[i].end(); it++) {         pair<int, int> ordp = {min(i, *it), max(i, *it)};         if (counts[i] + counts[*it] >= P &&             counts[i] + counts[*it] - mp[ordp] < P) {           tot--;         }       }       ans += tot;     }     cout << ans / 2;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     string second, a =  1968 ;     string rem[10];     cin >> second;     int zero = 0;     bool one = 0, six = 0, eight = 0, nine = 0;     string alt =   ;     for (int i = 0; i < second.size(); i++) {       if (second[i] ==  0 ) zero++;       if (second[i] ==  1  && one) alt += second[i];       if (second[i] ==  6  && six) alt += second[i];       if (second[i] ==  8  && eight) alt += second[i];       if (second[i] ==  9  && nine) alt += second[i];       if (second[i] ==  1 )         one = 1;       else if (second[i] ==  6 )         six = 1;       else if (second[i] ==  8 )         eight = 1;       else if (second[i] ==  9 )         nine = 1;       else if (second[i] !=  0 )         alt += second[i];     }     int t = 1, mo = 0;     for (int i = 0; i < zero; i++) {       t = (t * 10) % 7;     }     int ft = t;     do {       int m = 0;       t = ft;       for (int i = 4 - 1; i >= 0; i--) {         m = (m + t * (a[i] -  0 )) % 7;         t = (t * 10) % 7;       }       rem[m] = a;     } while (next_permutation(a.begin(), a.end()));     for (int i = alt.size() - 1; i >= 0; i--) {       mo = (mo + (alt[i] -  0 ) * t) % 7;       t = (t * 10) % 7;     }     rem[7] = rem[0];     cout << alt << rem[7 - mo];     for (int i = 0; i < zero; i++) cout << 0;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 1e5, OO = 1e14;   const int di[] = {1, -1, 0, 0};   const int dj[] = {0, 0, 1, -1};   long long TC, n, m, k, a, b, c, cnt, u, mx, mn, ans, arr[N];   bool f, vis[N], mark[N];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> TC;     while (TC--) {       cin >> n >> m;       cnt = f = 0;       m += (2 * n);       for (int i = 1; i <= n && !f; i++) {         for (int j = i + 1; j <= n; j++) {           cout << i <<     << j <<   n ;           if (++cnt == m) {             f = 1;             break;           }         }       }     }     return 0;   }
#pragma GCC optimize( O3 )   #pragma GCC target( avx2 )   #include<bits/stdc++.h>      using namespace std;      #define int long long      signed main() {       int t;       cin >> t;       for (int u = 0; u < t; ++u) {           string s;           cin >> s;           int b1 = 0, b2 = 0;           int ans = 0;           for (char c : s) {               if (c ==  ( ) {                   ++b1;               } else if (c ==  [ ) {                   ++b2;               } else if (c ==  )  && b1) {                   --b1;                   ++ans;               } else if (c ==  ]  && b2) {                   --b2;                   ++ans;               }           }           cout << ans <<   n ;       }   }
#include <bits/stdc++.h>   using namespace std;   string toString(long long n) {     string str =   ;     while (n) {       str += n % 10 +  0 ;       n /= 10;     }     reverse(str.begin(), str.end());     return str;   }   int main() {     string s =   ;     for (auto i = (1); i <= (10000); ++i) {       string t = toString(i);       s += t;     }     long long n;     scanf( %lld , &n);     if (n <= (int)s.size())       printf( %c n , s[n - 1]);     else {       n -= 9;       long long cur = 180LL;       int digit = 2;       long long power = 10;       while (n > cur) {         n -= cur;         power *= 10LL;         ++digit;         cur = 9LL * digit * power;       }       power += n / digit - 1;       n %= digit;       if (n) ++power;       string str = toString(power);       if (n == 0)         cout << str[(int)str.size() - 1] << endl;       else         cout << str[n - 1] << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, b;     cin >> n >> b;     long long int a[n], i, j, k, l, t1, t2, sum = 0, ad[n];     for (i = 0; i < n; i++) {       cin >> a[i];       ad[i] = a[i];     }     vector<pair<long long int, long long int>> v;     map<long long int, long long int> mp;     for (i = 0; i < b; i++) {       cin >> t1 >> t2;       v.push_back(make_pair(t1, t2));     }     sort(v.begin(), v.end());     sort(a, a + n);     i = j = sum = 0;     for (i = 0; i < n; i++) {       while (a[i] >= v[j].first && j < b) {         sum = sum + v[j].second;         j++;       }       mp[a[i]] = sum;     }     for (i = 0; i < n; i++) {       cout << mp[ad[i]] <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 5;   int n;   double p[maxn], dp[maxn];   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) scanf( %lf , &p[i]);     double sol = 0.;     dp[0] = 0;     for (int i = 1; i < n; i++) {       dp[i] = (dp[i - 1] + p[i - 1]) * p[i];       sol += 2. * dp[i];     }     for (int i = 0; i < n; i++) sol += p[i];     printf( %.9lf n , sol);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int numTest;     cin >> numTest;     for (int num = 0; num < numTest; ++num) {       int n;       cin >> n;       int arr[n];       for (int i = 0; i < n; ++i) {         cin >> arr[i];       }       sort(arr, arr + n);       int temp = arr[0], temp2 = 0;       for (int i = 1; i < n; ++i) {         temp2 += arr[i - 1];         arr[i] -= temp;         temp += arr[i];         if (arr[0] < arr[i]) arr[0] = arr[i];       }       cout << arr[0] << endl;     }   }