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);     long long int n, m, k, i, j;     cin >> n >> m >> k;     long long int a[n];     vector<pair<long long int, long long int> > v;     for (i = 0; i < n; i++) {       cin >> a[i];       v.push_back(make_pair(a[i], i));     }     long long int y = m * k;     long long int x = n - y;     sort(v.begin(), v.end());     long long int mark[n];     memset(mark, 0, sizeof(mark));     i = n - 1;     while (i >= 0 && y > 0) {       mark[v[i].second] = 1;       i--;       y--;     }     i = 0;     long long int z;     long long int ans = 0;     vector<long long int> p;     while (i < n) {       z = 0;       j = i;       while (z < m && j < n) {         if (mark[j] == 1) {           z++;           ans = ans + a[j];         }         j++;       }       p.push_back(j);       if (p.size() == k) break;       i = j;     }     cout << ans << endl;     for (i = 0; i < p.size() - 1; i++) {       cout << p[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 3e5 + 7;   vector<pair<int, int> > G[MAXN];   int n;   int sz[MAXN];   long long MAX, MIN;   void dfs(int u, int fa) {     sz[u] = 1;     for (pair<int, int> edge : G[u]) {       int v = edge.first;       if (v == fa) continue;       dfs(v, u);       sz[u] += sz[v];     }     for (pair<int, int> edge : G[u]) {       int v = edge.first, w = edge.second;       if (v == fa) continue;       if (sz[v] & 1) MIN += w;       MAX += 1ll * w * min(sz[v], (n - sz[v]));     }   }   int main() {     int T;     scanf( %d , &T);     while (T--) {       int k;       scanf( %d , &k);       n = 2 * k;       for (int i = 1, u, v, w; i < n; i++) {         scanf( %d%d%d , &u, &v, &w);         G[u].push_back({v, w});         G[v].push_back({u, w});       }       MAX = MIN = 0;       dfs(1, 0);       printf( %lld %lld n , MIN, MAX);       for (int i = 1; i <= n; i++) G[i].clear();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-8;   int s[2], t[200007][2];   int x[200007];   int n, m, st[200007];   int absi(int x) { return x > 0 ? x : -x; }   int main() {     cin >> n >> m;     for (int i = 0; i < n; i++) scanf( %d , &x[i]);     memset(s, 0, sizeof(s));     memset(t, 0, sizeof(t));     memset(st, 0, sizeof(st));     for (int i = 0; i < n; i++) ++s[x[i] > 0];     for (int i = 0; i < n; i++) t[absi(x[i])][x[i] > 0]++;     int cnt = 0;     for (int i = 1; i <= n; ++i) {       int fake = 0;       fake += t[i][1] + s[0] - t[i][0];       if (fake == m) {         st[i] = 1;         ++cnt;       }     }     for (int i = 0; i < n; i++) {       int ss = 0;       if (x[i] > 0 && st[x[i]]) ss |= 1;       if (x[i] > 0 && !st[x[i]]) ss |= 2;       if (x[i] > 0 && cnt > 1) ss |= 2;       if (x[i] < 0 && !st[-x[i]]) ss |= 1;       if (x[i] < 0 && st[-x[i]]) ss |= 2;       if (x[i] < 0 && cnt > 1) ss |= 1;       if (ss == 1) cout <<  Truth n ;       if (ss == 2) cout <<  Lie n ;       if (ss == 3) cout <<  Not defined n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long getnum() {     char c = getchar();     long long num, sign = 1;     for (; c <  0  || c >  9 ; c = getchar())       if (c ==  - ) sign = -1;     for (num = 0; c >=  0  && c <=  9 ;) {       c -=  0 ;       num = num * 10 + c;       c = getchar();     }     return num * sign;   }   char S[200020];   char T[200020];   vector<pair<int, int> > V;   int main() {     int n = getnum(), k = getnum();     gets(T + 3);     int rot = 3;     for (rot = 3; rot <= n + 2; rot++) {       if (T[rot] == T[rot + 1]) break;     }     for (int i = 3, j = rot; i <= n + 2; i++, j++) {       if (j == n + 3) j = 3;       S[i] = T[j];     }     S[1] = S[n + 1];     S[2] = S[n + 2];     S[n + 3] = S[3];     S[n + 4] = S[4];     for (int i = 0; i <= n + 4;) {       int x = i;       while (S[i] == S[x] && i <= n + 4) i++;       if (i - x > 1) V.push_back(make_pair(x, i - 1));     }     if (V.size() == 0) {       if (k % 2) {         for (int i = 3; i <= n + 2; i++) S[i] =  B  +  W  - S[i];       }       S[n + 3] = 0;       printf( %s , S + 3);       return 0;     }     for (int i = 0; i < V.size() - 1; i++) {       int l = V[i].second;       int r = V[i + 1].first;       int t = min(k, (r - l) / 2);       l++, r--;       for (int tt = 1; tt <= t; l++, tt++) S[l] = S[V[i].second];       for (int tt = 1; tt <= t; r--, tt++) S[r] = S[V[i + 1].first];       for (; l <= r; l++) S[l] =  B  +  W  - S[l - 1];     }     T[n + 3] = 0;     for (int i = rot, j = 3; j <= n + 2; i++, j++) {       if (i == n + 3) i = 3;       T[i] = S[j];     }     printf( %s , T + 3);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int cnt = 0;     while (n > 0) {       if (n >= 100) {         n -= 100;         cnt++;       } else if (n >= 20) {         n -= 20;         cnt++;       } else if (n >= 10) {         n -= 10;         cnt++;       } else if (n >= 5) {         n -= 5;         cnt++;       } else if (n >= 1) {         n -= 1;         cnt++;       }     }     cout << cnt;   }
#include <bits/stdc++.h>   using namespace std;   int num[105];   int main() {     int n;     cin >> n;     set<int> s;     while (n--) {       int a;       cin >> a;       s.insert(a);       num[a]++;     }     if (s.size() == 2 && num[*s.begin()] == num[*s.rbegin()]) {       cout <<  YES n ;       cout << *s.begin() <<     << *s.rbegin() << endl;     } else {       cout <<  NO n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, q, acum = 0, ultimo = 0, type, a, count;     scanf( %d%d , &n, &q);     vector<queue<int>> notificaciones_app(n);     unordered_set<int> todas_notificaciones;     while (q--) {       scanf( %d%d , &type, &a);       a--;       switch (type) {         case 1:           acum++;           todas_notificaciones.insert(acum);           notificaciones_app[a].push(acum);           break;         case 2:           while (!notificaciones_app[a].empty())             todas_notificaciones.erase(notificaciones_app[a].front()),                 notificaciones_app[a].pop();           break;         case 3:           a++;           for (int i = ultimo; i <= a; i++) todas_notificaciones.erase(i);           if (a > ultimo) ultimo = a;           break;       }       printf( %d n , todas_notificaciones.size());     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     scanf( %d , &t);     while (t--) {       int n, p;       scanf( %d , &n);       scanf( %d , &p);       vector<pair<int, int> > ans;       int edges = 2 * n + p;       for (int i = int(1); i <= int(n); i++) {         for (int j = int(i + 1); j <= int(n); j++) {           if (edges) {             ans.push_back(pair<int, int>(i, j));             edges--;           }         }       }       for (vector<pair<int, int> >::iterator it = (ans).begin();            it != (ans).end(); it++)         printf( %d %d n , it->first, it->second);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     string a, b;     cin >> a >> b;     if (a.size() < b.size()) a = string(b.size() - a.size(),  0 ) + a;     if (b.size() < a.size()) b = string(a.size() - b.size(),  0 ) + b;     if (a == b) cout <<  = ;     if (a < b) cout <<  < ;     if (b < a) cout <<  > ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct point {     int x, y, h;   } a[100010];   bool cmp(point a, point b) {     if (a.y != b.y) return a.y < b.y;     return a.x < b.x;   }   int dp[100010];   int main() {     int n;     while (~scanf( %d , &n)) {       for (int i = 0; i < n; i++) scanf( %d%d%d , &a[i].x, &a[i].y, &a[i].h);       sort(a, a + n, cmp);       stack<point> p;       long long ans = 0;       long long mx = 0;       for (int i = n - 1; i >= 0; i--) {         while (1) {           if (p.empty()) break;           point f = p.top();           if (f.y >= a[i].y && f.x < a[i].y) break;           ans -= f.h;           p.pop();         }         p.push(a[i]);         ans += a[i].h;         mx = max(mx, ans);       }       printf( %I64d n , mx);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int m[10][10] = {0};     for (int i = 1; i <= 3; i++) {       for (int j = 1; j <= 3; j++) {         cin >> m[i][j];       }     }     int s = 0;     for (int i = 1; i <= 3; i++) {       for (int j = 1; j <= 3; j++) {         s = m[i][j];         s += m[i + 1][j];         s += m[i - 1][j];         s += m[i][j + 1];         s += m[i][j - 1];         s % 2 ? cout << 0 : cout << 1;       }       cout <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n / 2; i++) {       for (int j = 1; j <= m; j++) {         printf( %d %d n , i, j);         printf( %d %d n , n - i + 1, m - j + 1);       }     }     if (n & 1) {       for (int i = 1; i <= m / 2; i++) {         printf( %d %d n , n / 2 + 1, i);         printf( %d %d n , n / 2 + 1, m - i + 1);       }       if (m & 1) printf( %d %d n , n / 2 + 1, m / 2 + 1);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<vector<int>> edges;   vector<int> large;   bool ok = true;   vector<pair<long long, long long>> dfs(int cur) {     vector<pair<long long, long long>> child;     for (int i : edges[cur]) {       auto temp = dfs(i);       child.insert(child.end(), temp.begin(), temp.end());     }     sort(child.begin(), child.end());     vector<pair<long long, long long>> res;     int add = 0;     if (large[cur] > child.size()) {       ok = false;     }     for (auto it : child) {       if (res.size() == large[cur]) {         res.push_back({res.size() + 1, cur});       }       res.push_back({res.size() + 1, it.second});     }     if (res.size() == child.size()) {       res.push_back({res.size() + 1, cur});     }     return res;   }   void solve() {     int n;     cin >> n;     edges.clear();     edges.resize(n + 1);     vector<pair<long long, long long>> in(n);     for (auto& it : in) {       cin >> it.first >> it.second;     }     int par = -1;     large.clear();     large.resize(n + 1);     for (int i = 0; i < n; i++) {       if (in[i].first != 0) {         edges[in[i].first].push_back(i + 1);       } else {         par = i + 1;       }       large[i + 1] = in[i].second;     }     auto res = dfs(par);     if (!ok) {       cout <<  NO  << endl;       return;     }     cout <<  YES  << endl;     for (auto it : res) {       large[it.second] = it.first;     }     for (int i = 1; i <= n; i++) {       cout << large[i] <<    ;     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int t = 1;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   void maxtt(T& t1, T t2) {     t1 = max(t1, t2);   }   template <typename T>   void mintt(T& t1, T t2) {     t1 = min(t1, t2);   }   bool debug = 0;   int n, m, k;   int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};   string direc =  URDL ;   const long long MOD2 = (long long)998244353 * (long long)998244353;   long long ln, lk, lm;   void etp(bool f = 0) {     puts(f ?  YES  :  NO );     exit(0);   }   void addmod(int& x, int y, int mod = 998244353) {     assert(y >= 0);     x += y;     if (x >= mod) x -= mod;     assert(x >= 0 && x < mod);   }   void et(int x = -1) {     printf( %d n , x);     exit(0);   }   long long fastPow(long long x, long long y, int mod = 998244353) {     long long ans = 1;     while (y > 0) {       if (y & 1) ans = (x * ans) % mod;       x = x * x % mod;       y >>= 1;     }     return ans;   }   long long gcd1(long long x, long long y) { return y ? gcd1(y, x % y) : x; }   long long rL;   int a[1035], b[1035];   long long ansl[1035], ansr[1035];   long long rd(int id, long long x) {     printf( ? %d %lld n , id, x);     fflush(stdout);     scanf( %lld , &lk);     return lk;   }   void cal(int l, int r, long long L, long long R) {     if (l == r) {       ansl[a[l]] = L;       ansr[a[l]] = R;       return;     }     int m1 = (l + r) / 2;     long long X = rL / n * m1, m2;     mt19937 ttrand((int)time(0));     for (int p = l, q = r;;) {       int i = uniform_int_distribution<int>(p, q)(ttrand);       long long lb = L, rb = R;       while (lb < rb) {         long long mb = (lb + rb) / 2;         if (rd(a[i], mb) < X)           lb = mb + 1;         else           rb = mb;       }       int l2 = p, r2 = q;       vector<int> e;       for (int j = p; j <= q; ++j) {         long long y = rd(a[j], lb);         if (y > X)           b[l2++] = a[j];         else if (y < X)           b[r2--] = a[j];         else           e.push_back(a[j]);       }       for (int(j) = 0; (j) < (int)(e.size()); (j)++) b[l2 + j] = e[j];       for (int z = p; z <= q; z++) a[z] = b[z];       if (l2 <= m1 && m1 <= r2) {         m2 = lb;         break;       }       if (l2 < m1)         p = l2 + 1;       else         q = l2 - 1;     }     cal(l, m1, L, m2);     cal(m1 + 1, r, m2, R);   }   void fmain(int tid) {     scanf( %d%lld , &n, &rL);     for (int(i) = 1; (i) <= (int)(n); (i)++) a[i] = i;     cal(1, n, 0, 1e18);     puts( ! );     for (int(i) = 1; (i) <= (int)(n); (i)++)       printf( %lld %lld n , ansl[i], ansr[i]);   }   int main() {     int t = 1;     for (int(i) = 1; (i) <= (int)(t); (i)++) {       fmain(i);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline T sqr(const T &a) {     return a * a;   }   template <class T>   inline T middle(const T &a, const T &b) {     return (a + b) / 2;   }   template <class T>   inline int len(const T &c) {     return static_cast<int>(c.size());   }   const long double EPS = 1e-9;   const long double PI = 2 * acos(0.0);   const int N = 100;   struct Item {     long long r;     char c;     Item() {}     Item(long long rr, char cc) : r(rr), c(cc) {}     void Read() { scanf( %I64d-%c , &r, &c); }   };   int ReadLine(int n, vector<Item> &s) {     Item tmp;     for (int i = 0; i < n; ++i) {       tmp.Read();       if (!s.empty() && s.back().c == tmp.c) {         s.back().r += tmp.r;       } else {         s.push_back(tmp);       }     }     return len(s);   }   inline bool Check1(const vector<Item> &s, const Item &cur, int n, int j) {     if (s[j].c != cur.c) {       return false;     }     if (j == 0 || j == n - 1) {       return s[j].r <= cur.r;     }     return s[j].r == cur.r;   }   int main() {     int n, m;     scanf( %d%d n , &n, &m);     vector<Item> t, s;     n = ReadLine(n, t);     m = ReadLine(m, s);     s.push_back(Item(0,  # ));     s.insert(s.end(), t.begin(), t.end());     long long ans = 0;     vector<int> pi(len(s), 0);     for (int i = 1; i < len(pi); ++i) {       Item &cur = s[i];       int j = pi[i - 1];       while (j && !Check1(s, cur, m, j)) {         j = pi[j - 1];       }       if (Check1(s, cur, m, j)) {         ++j;       }       if (j == m) {         if (m > 1) {           ++ans;         } else {           assert(cur.c == s[0].c);           long long val = cur.r - s[0].r + 1;           ans += val;         }         --j;         if (j) {           j = pi[j - 1];         }         if (Check1(s, cur, m, j)) {           ++j;         }       }       pi[i] = j;     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, a, b, c, D, e;   int cs[200020];   int all[200020], A[4], AA[4];   int i, x, y, z, tmp, tim, m;   int main() {     cin >> n;     cin >> a >> b >> c;     if (a > c) swap(a, c);     if (a > b) swap(a, b);     if (b > c) swap(b, c);     A[1] = a;     A[2] = b;     A[3] = c;     for (i = 1; i <= n; i++) {       scanf( %d , &D);       if (D > a + b + c) {         cout << -1 << endl;         return 0;       }       if (D > b + c) {         tim++;         continue;       }       m++;       all[m] = D;     }     AA[1] = m;     AA[2] = m;     AA[3] = m;     sort(all + 1, all + m + 1);     for (i = m; i >= 1; i--) {       if (all[i] && c < all[i]) {         if (a + b >= all[i])           e = 3;         else if (a + c >= all[i])           e = 2;         else           e = 1;         AA[e] = min(AA[e], i - 1);         while (AA[e] >= 0 && all[AA[e]] == 0 || all[AA[e]] > A[e]) AA[e]--;         tim++;         all[AA[e]] = 0;         all[i] = 0;       }     }     n = 0;     for (i = 1; i <= m; i++)       if (all[i]) {         n++;         cs[n] = all[i];       }     if (n == 0) {       cout << tim << endl;       return 0;     }     int l = 1;     int r = n - 1;     int ress = n;     while (l <= r) {       m = (l + r) / 2;       int k = n - m;       if (a + b < cs[k]) {         l = m + 1;         continue;       }       int ja = 0;       for (ja = 1; ja <= k; ja++)         if (cs[ja] > a) break;       ja--;       int jb = 0;       for (jb = 1; jb <= k; jb++)         if (cs[jb] > b) break;       jb--;       while (jb - ja < ja) ja--;       if (max(ja, jb - ja) + k - jb <= m) {         ress = m;         r = m - 1;       } else         l = m + 1;     }     cout << ress + tim << endl;   }
#include <bits/stdc++.h>   using namespace std;   using LL = long long;   LL g_l, g_r;   LL gcd(LL a, LL b) {     if (b == 0) return a;     return gcd(b, a % b);   }   bool input() {     cin >> g_l >> g_r;     if (cin.eof()) return false;     return true;   }   void solve() {     for (LL i = g_l; i <= g_r; ++i) {       for (LL j = i + 1; j <= g_r; ++j) {         for (LL k = j + 1; k <= g_r; ++k) {           if (gcd(i, k) != 1 && gcd(i, j) == 1 && gcd(j, k) == 1) {             cout << i <<     << j <<     << k << endl;             return;           }         }       }     }     cout << -1 << endl;   }   int main() {     while (input()) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100010;   long long read() {     long long x = 0, f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = (x << 3) + (x << 1) + ch -  0 ;       ch = getchar();     }     return x * f;   }   long long n, m, a[N], op, x, y, z;   struct SegmentTree {     long long l, r, sum, maxn;   } tree[N << 2];   void pushup(int k) {     tree[k].sum = tree[k << 1].sum + tree[k << 1 | 1].sum;     tree[k].maxn = max(tree[k << 1].maxn, tree[k << 1 | 1].maxn);   }   void build(int k, int l, int r) {     tree[k].l = l, tree[k].r = r;     if (l == r) {       tree[k].sum = tree[k].maxn = a[l];       return;     }     int mid = (l + r) / 2;     build(k << 1, l, mid), build(k << 1 | 1, mid + 1, r);     pushup(k);   }   void changemod(int k, int ql, int qr, long long mod) {     if (tree[k].maxn < mod) return;     if (ql <= tree[k].l && tree[k].r <= qr && tree[k].l == tree[k].r) {       tree[k].sum %= mod, tree[k].maxn %= mod;       return;     }     int mid = (tree[k].l + tree[k].r) / 2;     if (ql <= mid) changemod(k << 1, ql, qr, mod);     if (mid < qr) changemod(k << 1 | 1, ql, qr, mod);     pushup(k);   }   void modify(int k, int q, long long v) {     if (tree[k].l > q || q > tree[k].r) return;     if (tree[k].l == tree[k].r) {       tree[k].sum = tree[k].maxn = v;       return;     }     int mid = (tree[k].l + tree[k].r) / 2;     if (q <= mid)       modify(k << 1, q, v);     else       modify(k << 1 | 1, q, v);     pushup(k);   }   long long query(int k, int ql, int qr) {     long long res = 0;     if (ql <= tree[k].l && tree[k].r <= qr) return tree[k].sum;     int mid = (tree[k].l + tree[k].r) / 2;     if (ql <= mid) res += query(k << 1, ql, qr);     if (mid < qr) res += query(k << 1 | 1, ql, qr);     return res;   }   int main() {     n = read(), m = read();     for (int i = 1; i <= n; i++) a[i] = read();     build(1, 1, n);     while (m--) {       op = read();       if (op == 1) {         x = read(), y = read();         printf( %lld n , query(1, x, y));       }       if (op == 2) {         x = read(), y = read(), z = read();         changemod(1, x, y, z);       }       if (op == 3) {         x = read(), y = read();         modify(1, x, y);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct BipartiteMatcher {     vector<vector<int>> g;     vector<int> L, R;     vector<bool> vis;     BipartiteMatcher(int n, int m) : g(n), L(n, -1), R(m, -1), vis(n) {}     void addEdge(int a, int b) { g[a].emplace_back(b); }     bool match(int x) {       if (vis[x]) return 0;       vis[x] = 1;       for (int v : g[x])         if (R[v] == -1) return R[L[x] = v] = x, 1;       for (int v : g[x])         if (match(R[v])) return R[L[x] = v] = x, 1;       return 0;     }     int solve() {       int cnt = 1;       while (cnt--) {         fill(vis.begin(), vis.end(), 0);         for (int i = 0; i < L.size(); ++i) {           cnt |= L[i] == -1 and match(i);         }       }       int res = 0;       for (int i = 0; i < L.size(); ++i) res += L[i] != -1;       return res;     }   };   int solve(int n, int m) {     BipartiteMatcher BM(n * m, n * m);     for (int i = 0; i < n; ++i)       for (int j = 0; j < m; ++j) {         if ((i + j) % 2 == 1) continue;         for (int k = max(i - 3, 0); k <= min(i + 3, n - 1); ++k) {           for (int l = max(j - 3, 0); l <= min(j + 3, m - 1); ++l) {             if ((k + l) % 2 == 0) continue;             if (abs(i - k) + abs(j - l) == 3) {               BM.addEdge(i * m + j, k * m + l);             }           }         }       }     return 2 * BM.solve();   }   int main() {     int n, m;     cin >> n >> m;     if (n > m) swap(n, m);     if (n <= 20 and m <= 20)       cout << solve(n, m) << endl;     else if (n == 1)       cout << 2 * (m / 6 * 3 + max(m % 6 - 3, 0)) << endl;     else       cout << (n * 1ll * m) / 2 * 2 << endl;     ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long x[60002];   long long v[60002];   double ans = 1e12;   long long n;   double ma(double a, double b) {     if (a > b) return a;     return b;   }   double calc(double xx, double& bd) {     double time = -1;     for (int i = 0; i < n; i++) {       double d = abs(xx - x[i]);       if (d / v[i] > time) {         time = d / v[i];         bd = x[i];       }     }     return time;   }   void bs(double s, double e) {     if (s < e - 0.0000001) {       double mid = s + (e - s) / 2;       double xx;       double x1 = calc(mid, xx);       if (ans > x1) {         ans = x1;       }       if (xx > mid)         bs(mid, e);       else         bs(s, mid);     }   }   int main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     cin >> n;     for (int i = 0; i < n; i++) cin >> x[i];     for (int i = 0; i < n; i++) cin >> v[i];     bs(1, 1000000000);     cout << fixed << setprecision(10) << ans;     return 0;   }
#include <bits/stdc++.h>   int main() {     int t;     scanf( %d , &t);     while (t--) {       int n;       scanf( %d , &n);       int a[20005], b[20005];       for (int i = 0; i < n; i++) scanf( %d %d , &a[i], &b[i]);       int num = 1;       for (int i = 0; i < n; i++) {         if (num < a[i]) {           num = a[i];         }         if (num <= b[i]) {           printf( %d  , num);           num++;         } else           printf( 0  );       }       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const long long int INFL = 0x3f3f3f3f3f3f3f3fLL;   const int MOD = 1e9 + 7;   const int MAX = 1e5 + 5;   int a[1001];   int __attribute__((optimize( -O3 ))) main() {     cin.sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i];     }     int ans = 1;     for (int i = 0; i < n; i++) {       int l = i, r = i;       while (l > 0 and a[l] >= a[l - 1]) {         l--;       }       while (r < n - 1 and a[r] >= a[r + 1]) {         r++;       }       ans = max(ans, r - l + 1);     }     cout << ans <<   n ;     return 0;   }