malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int maxn = 200005;   inline int gi() {     char c = getchar();     while (c <  0  || c >  9 ) c = getchar();     int sum = 0;     while ( 0  <= c && c <=  9 ) sum = sum * 10 + c - 48, c = getchar();     return sum;   }   int n, m, q, A[maxn], B[maxn];   vector<pair<int, int>> vec[maxn];   long long sum[maxn], Min[maxn << 2], tag[maxn << 2];   priority_queue<long long, vector<long long>, greater<long long>> q1, q2;   void build(int s, int l, int r) {     if (l == r) return Min[s] = B[l - 1], void();     build((s << 1), l, ((l + r) >> 1));     build((s << 1 | 1), ((l + r) >> 1) + 1, r);     Min[s] = min(Min[(s << 1)], Min[(s << 1 | 1)]);   }   void modify(int s, int l, int r, int ql, int qr, int v) {     if (ql <= l && r <= qr) return tag[s] += v, Min[s] += v, void();     if (ql <= ((l + r) >> 1)) modify((s << 1), l, ((l + r) >> 1), ql, qr, v);     if (qr >= ((l + r) >> 1) + 1)       modify((s << 1 | 1), ((l + r) >> 1) + 1, r, ql, qr, v);     Min[s] = min(Min[(s << 1)], Min[(s << 1 | 1)]) + tag[s];   }   int main() {     n = gi();     m = gi();     q = gi();     for (int i = 1; i < n; ++i) A[i] = gi(), B[i] = gi();     for (int u, v, w, i = 1; i <= m; ++i) {       u = gi();       v = gi();       w = gi();       vec[u].push_back(make_pair(v, w));     }     build(1, 1, n);     for (int i = 1; i <= n; ++i) {       for (auto j : vec[i]) modify(1, 1, n, 1, j.first, j.second);       sum[i] = Min[1];       q1.push(sum[i] + A[i]);     }     printf( %lld n , q1.top());     for (int i = 1, x, v; i <= q; ++i) {       x = gi();       v = gi();       q2.push(A[x] + sum[x]);       q1.push((A[x] = v) + sum[x]);       while (!q1.empty() && !q2.empty() && q1.top() == q2.top())         q1.pop(), q2.pop();       printf( %lld n , q1.top());     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, ans, sx, sy, ex, ey, endx = -1, endy = -1;   char s[1005][1006];   pair<int, int> xx[1005];   pair<int, int> yy[1005];   bool able(int x, int y) {     int nx = sx, ny = sy;     while (true) {       int nex = nx + x + 1, ney = ny + y + 1;       if (nex > endx && ney > endy) return true;       if (s[nx][ney] ==  X ) {         if (nex <= endx && xx[nex].first <= ny) return false;         ny++;         continue;       } else if (s[nex][ny] ==  X ) {         if (ney <= endy && yy[ney].first <= nx) return false;         nx++;         continue;       } else         return false;     }   }   int main() {     scanf( %d %d , &n, &m);     for (int i = 0; i < n; i++) scanf( %s , s[i]);     int state = 0;     for (int i = 0; i < n; i++) {       xx[i].first = -1;       for (int j = 0; j < m; j++) {         if (s[i][j] ==  X ) xx[i].second = j, endx = i;         if (s[i][j] ==  X  && xx[i].first == -1) xx[i].first = j;       }       if (xx[i].first != -1) {         for (int j = xx[i].first; j <= xx[i].second; j++)           if (s[i][j] !=  X ) {             printf( -1 );             return 0;           }         if (state < 2)           state++;         else if (state == 5) {           printf( -1 );           return 0;         }       } else if (state != 0)         state = 5;       if (state != 2) continue;       if (xx[i].first < xx[i - 1].first || xx[i].second < xx[i - 1].second ||           xx[i].first > xx[i - 1].second) {         printf( -1 );         return 0;       }     }     state = 0;     for (int i = 0; i < m; i++) {       yy[i].first = -1;       for (int j = 0; j < n; j++) {         if (s[j][i] ==  X ) yy[i].second = j, endy = i;         if (s[j][i] ==  X  && yy[i].first == -1) yy[i].first = j;       }       if (yy[i].first != -1) {         for (int j = yy[i].first; j <= yy[i].second; j++)           if (s[j][i] !=  X ) {             printf( -1 );             return 0;           }         if (state < 2)           state++;         else if (state == 5) {           printf( -1 );           return 0;         }       } else if (state != 0)         state = 5;       if (state != 2) continue;       if (yy[i].first < yy[i - 1].first || yy[i].second < yy[i - 1].second ||           yy[i].first > yy[i - 1].second) {         printf( -1 );         return 0;       }     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (s[i][j] ==  X ) {           sx = i, sy = j;           i = n;           break;         }       }     }     if (endx == -1) {       printf( 0 );       return 0;     }     for (int i = sx; i < n; i++) {       if (s[i][sy] ==  X )         ex = i;       else         break;     }     for (int i = sy; i < m; i++) {       if (s[sx][i] ==  X )         ey = i;       else         break;     }     ans = 2140000000;     for (int i = 0; i <= ex - sx; i++) {       if (able(i, ey - sy)) {         ans = min(ans, (i + 1) * (ey - sy + 1));       }     }     for (int i = 0; i <= ey - sy; i++) {       if (able(ex - sx, i)) {         ans = min(ans, (i + 1) * (ex - sx + 1));       }     }     printf( %d , ans == 2140000000 ? -1 : ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 502;   int n, k;   int a[maxn], b[maxn], c[maxn];   bool check(int l, int r) {     if (l == r) return true;     for (int i = l + 1; i <= r; ++i)       if (a[i] != a[l]) return true;     return false;   }   bool print(int p, int r, int dir) {     printf( %d %c n , p, dir == -1 ?  L  :  R );     if (dir == -1) --p;     a[p] += a[p + 1];     for (++p; p < r; ++p) a[p] = a[p + 1];     return true;   }   bool solve(int l, int r) {     if (l == r) return false;     int i, mx = -1;     for (i = l; i <= r; ++i) mx = max(mx, a[i]);     for (i = l; i <= r; ++i) {       if (a[i] != mx) continue;       if (i == l && a[i] > a[i + 1]) return print(l, r, 1);       if (i == r && a[i] > a[i - 1]) return print(r, r, -1);       if (i != l && i != r && a[i] > a[i + 1]) return print(i, r, 1);       if (i != l && i != r && a[i] > a[i - 1]) return print(i, r, -1);     }     return puts( WTF??? );   }   int main() {     int i, j, s = 0;     scanf( %d , &n);     for (i = 1; i <= n; ++i) scanf( %d , &a[i]);     scanf( %d , &k);     for (i = 1; i <= k; ++i) scanf( %d , &b[i]);     for (i = j = 1; i <= n; ++i) {       s += a[i];       if (s < b[j]) continue;       if (s > b[j]) return puts( NO ), 0;       c[j] = i;       s = 0;       if (++j > k && i < n) return puts( NO ), 0;     }     if (j != k + 1) return puts( NO ), 0;     for (i = 1; i <= k; ++i)       if (!check(c[i - 1] + 1, c[i])) return puts( NO ), 0;     puts( YES );     for (i = k; i; --i)       while (solve(c[i - 1] + 1, c[i])) --c[i];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int M[16];   int R[16];   int N;   int main() {     cin >> N;     for (int i = 0; i < N; i++) {       cin >> M[i];     }     for (int i = 0; i < N; i++) {       cin >> R[i];     }     int ans = 0;     for (int i = 0; i < 720720; i++) {       bool checker = false;       for (int j = 0; j < N; j++) {         if (i % M[j] == R[j]) checker = true;       }       if (checker) ans++;     }     cout << ans / 720720.0 << endl;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> v;   long long a, b;   int main() {     ios_base::sync_with_stdio(0);     cin >> a >> b;     while (true) {       v.push_back(b);       if (b % 10 == 1) {         b--;         b /= 10;       } else if (b % 2 == 0) {         b /= 2;       } else {         cout <<  NO n ;         return 0;       }       if (b == a)         break;       else if (b < a) {         cout <<  NO n ;         return 0;       }     }     cout <<  YES n ;     cout << v.size() + 1 <<   n ;     cout << a <<    ;     for (long long i = v.size() - 1; i >= 0; i--) {       cout << v[i];       cout <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, l;     cin >> n >> l;     vector<int> v = vector<int>(n);     for (int i = 0; i < n; i++) cin >> v[i];     sort(v.begin(), v.end());     int vals = 1;     int prev = v[0];     vector<pair<int, int>> vp;     vp.push_back(make_pair(prev, 1));     for (int i = 1; i < n; i++) {       if (v[i] == prev) {         vp[vp.size() - 1].second++;       } else {         prev = v[i];         vp.push_back(make_pair(prev, 1));         vals++;       }     }     double t = log2(vals);     int fs = t;     if (t > fs) fs++;     if (fs * n < l * 8) {       cout << 0 << endl;       return 0;     }     int max_log = (l * 8) / n;     int distinct = 1 << max_log;     int start_p = 0;     int end_p = vp.size() - 1;     vector<int> ps = vector<int>(vp.size() + 1, 0);     ps[0] = 0;     for (int i = 0; i < vp.size(); i++) ps[i + 1] = ps[i] + vp[i].second;     vector<int> ss = vector<int>(vp.size() + 1, 0);     ss[0] = 0;     for (int i = 0; i < vp.size(); i++) {       ss[i + 1] = ss[i] + vp[vp.size() - 1 - i].second;     }     int mn = n;     for (int i = 0; i < vals - distinct; i++) {       if (ps[i] + ss[vals - distinct - i] < mn)         mn = ps[i] + ss[vals - distinct - i];     }     cout << mn << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   set<int> a, b;   set<int> pre;   char str[10];   int main() {     int n;     cin >> n;     long long ans = 1;     a.insert(0);     b.insert(1e9 + 5);     for (int i = 0; i < n; ++i) {       int x;       scanf( %s%d , str, &x);       if (str[1] ==  D ) {         int l = *a.rbegin();         int r = *b.begin();         if (x > l && x < r) {           pre.insert(x);         } else {           if (x < l)             a.insert(x);           else             b.insert(x);         }       } else {         if (pre.count(x)) {           ans *= 2;           ans %= mod;           for (auto it : pre) {             if (it > x)               b.insert(it);             else if (it < x)               a.insert(it);           }           pre.clear();         } else {           int l = *a.rbegin();           int r = *b.begin();           if (x == l) {             a.erase(x);             for (auto it : pre) {               if (it != x) b.insert(it);             }           } else if (x == r) {             b.erase(x);             for (auto it : pre) {               if (it != x) a.insert(it);             }           } else             return puts( 0 );           pre.clear();         }       }     }     int x = pre.size();     ans *= (x + 1);     ans %= mod;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int fx[] = {+0, +0, +1, -1, -1, +1, -1, +1};   const int fy[] = {-1, +1, +0, +0, +1, +1, -1, -1};   long long dp[1005][1005][2];   string s;   int k;   int ar[1026];   long long Dance_of_Death(int x, int rem, int f) {     if (x == s.size()) {       if (ar[rem] + 1 == k) {         return 1;       } else {         return 0;       }     }     if (dp[x][rem][f] != -1) {       return dp[x][rem][f];     }     long long y = 0;     if (!f && s[x] ==  0 ) {       y = Dance_of_Death(x + 1, rem, 0) % 1000000007;     }     if (f) {       y = Dance_of_Death(x + 1, rem, f) % 1000000007;       y = (y + Dance_of_Death(x + 1, rem + 1, f)) % 1000000007;     }     if (f == 0 && s[x] ==  1 ) {       y = Dance_of_Death(x + 1, rem, 1) % 1000000007;       y = (y + Dance_of_Death(x + 1, rem + 1, f)) % 1000000007;     }     return dp[x][rem][f] = y;   }   void build() {     ar[1] = 0;     for (int i = 2; i < 1026; i++) {       int x = i;       int c = 0;       while (x) {         if (x % 2) {           c++;         }         x /= 2;       }       ar[i] = ar[c] + 1;     }     ar[0] = 10000;   }   int main() {     build();     cin >> s;     cin >> k;     memset(dp, -1, sizeof(dp));     if (k == 0) {       cout << 1 << endl;       return 0;     }     int f = 0;     if (k == 1) {       f = 1;     }     cout << Dance_of_Death(0, 0, 0) - f << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 3005;   const int maxm = maxn * maxn << 1;   int n, m, q;   int id[maxn][maxn << 1];   int fa[maxm];   int vis[maxm];   int top = 0;   stack<pair<int, int> > sta;   inline int getfa(int x) {     sta.push(make_pair(x, fa[x]));     return fa[x] == x ? x : fa[x] = getfa(fa[x]);   }   inline void bing(int x, int y) {     if (vis[x] && vis[y]) {       int fax = getfa(x);       int fay = getfa(y);       if (fax != fay) fa[fax] = fay;     }   }   inline void Union(int x, int y) {     int now = id[x][y];     bing(id[x + 1][y], now);     bing(id[x + 1][y - 1], now);     bing(id[x + 1][y + 1], now);     bing(id[x - 1][y], now);     bing(id[x - 1][y - 1], now);     bing(id[x - 1][y + 1], now);     bing(id[x][y - 1], now);     bing(id[x][y + 1], now);   }   inline void rm() {     while (!sta.empty()) {       fa[sta.top().first] = sta.top().second;       sta.pop();     }   }   int main() {     scanf( %d%d%d , &n, &m, &q);     int __cnt = 0;     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= (m << 1); ++j) {         id[i][j] = ++__cnt;         fa[id[i][j]] = id[i][j];       }     }     for (int i = 1; i <= n; ++i) {       id[i][0] = id[i][m << 1];       id[i][m << 1 | 1] = id[i][1];     }     int ans = 0;     while (q--) {       int x, y;       scanf( %d%d , &x, &y);       if (vis[id[x][y]]) continue;       vis[id[x][y]] = vis[id[x][y + m]] = true;       Union(x, y);       Union(x, y + m);       if (getfa(id[x][y]) == getfa(id[x][y + m])) {         rm();         vis[id[x][y]] = vis[id[x][y + m]] = false;       } else         ans++;       while (!sta.empty()) sta.pop();     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }   long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }   long long Max(long long a, long long b) { return a > b ? a : b; }   long long Min(long long a, long long b) { return a < b ? a : b; }   long long power(long long x, long long y, long long p) {     long long res = 1;     x = x % p;     while (y > 0) {       if (y & 1) res = ((res % p) * (x % p)) % p;       y = y >> 1;       x = ((x % p) * (x % p)) % p;     }     return res;   }   bool isprime(long long n) {     if (n == 2) return true;     if (n % 2 == 0) return false;     for (long long i = 3; i * i <= n; i += 2) {       if (n % i == 0) return false;     }     return true;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long n, lo = 0, hi = 1000000007LL, ans = -1000000007LL, flag = 0;     cin >> n;     vector<pair<long long, long long> > arr(n);     vector<pair<long long, long long> > poss(n + 1);     for (long long i = 0; i < n; i++) {       cin >> arr[i].first >> arr[i].second;       if (arr[i].second == 2) flag = 1;     }     if (arr[0].second == 1) {       poss[0].first = 1900;       poss[0].second = 1000000007LL;     } else {       poss[0].first = -1000000007LL;       poss[0].second = 1899;     }     for (long long i = 1; i < n; i++) {       poss[i].first = poss[i - 1].first + arr[i - 1].first;       poss[i].second = poss[i - 1].second + arr[i - 1].first;       if (poss[i].first > poss[i].second) {         cout <<  Impossible ;         return 0;       }       if (arr[i].second == 1) {         poss[i].first = Max(poss[i].first, 1900);         if (poss[i].second < poss[i].first) {           cout <<  Impossible ;           return 0;         }       } else {         poss[i].second = Min(poss[i].second, 1899);         if (poss[i].second < poss[i].first) {           cout <<  Impossible ;           return 0;         }       }     }     poss[n].first = poss[n - 1].first + arr[n - 1].first;     poss[n].second = poss[n - 1].second + arr[n - 1].first;     if (poss[n].first > poss[n].second) {       cout <<  Impossible ;       return 0;     } else if (flag == 0) {       cout <<  Infinity ;     } else {       cout << poss[n].second;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   unsigned long long n, k, c, a, b, d;   multiset<unsigned long long> vn;   multiset<unsigned long long> vk;   unsigned long long mod = 1e9 + 7;   unsigned long long sum = 0;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     cin >> n >> k >> c;     for (int i = 1; i <= n; i++) {       cin >> a >> b;       vn.insert(a), vk.insert(b);       d = c * (b - a);       sum = (sum + d) % mod;     }     multiset<unsigned long long>::iterator it;     while (vn.size() > 0 && vk.size() > 0) {       if (*vn.begin() <= *vk.begin()) {         sum = (k + sum) % mod;         vn.erase(vn.find(*vn.begin()));       } else {         if ((*vn.begin() - *vk.begin()) * c < k) {           int t;           for (it = vk.begin(); it != vk.end(); it++) {             if ((*it) >= *vn.begin()) break;             t = (*it);           }           sum = (sum + (*vn.begin() - t) * c) % mod;           vn.erase(vn.find(*vn.begin()));           vk.erase(vk.find(t));         } else {           vk.erase(*vk.begin());         }       }     }     cout << sum % mod << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1000 + 10;   long long par[maxn], t[maxn], c[maxn];   const long long inf = 1000000000000ll;   long long dist[maxn][maxn], dis[maxn];   bool mark[maxn];   vector<int> v[maxn], u[maxn];   set<pair<long long, int> > s;   vector<long long> cost1[maxn], cost2[maxn];   int main() {     int n, m, x, y;     cin >> n >> m >> x >> y;     x--;     y--;     for (int i = 0; i < m; i++) {       int a, b, z;       cin >> a >> b >> z;       a--;       b--;       v[a].push_back(b);       v[b].push_back(a);       cost1[a].push_back(z);       cost1[b].push_back(z);     }     for (int i = 0; i < n; i++) {       cin >> t[i] >> c[i];     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) dist[i][j] = inf;     }     for (int i = 0; i < n; i++) {       for (int k = 0; k < n; k++) mark[k] = 0;       dist[i][i] = 0;       s.insert(make_pair(0, i));       while (!s.empty()) {         int cur = s.begin()->second;         s.erase(s.begin());         mark[cur] = true;         for (int j = 0; j < v[cur].size(); j++) {           int next = v[cur][j];           if (mark[next] == true) continue;           long long ndist = dist[i][cur] + cost1[cur][j];           if (dist[i][next] > ndist) {             par[next] = cur;             s.erase(make_pair(dist[i][next], next));             dist[i][next] = min(ndist, dist[i][next]);             s.insert(make_pair(dist[i][next], next));           }         }       }     }     for (int i = 0; i < n; i++) mark[i] = 0;     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         if (dist[i][j] > 0 && dist[i][j] <= t[i]) {           u[i].push_back(j);           cost2[i].push_back(c[i]);         }       }     }     for (int i = 0; i < n; i++) dis[i] = inf;     dis[x] = 0;     s.insert(make_pair(0, x));     while (!s.empty()) {       int cur = s.begin()->second;       s.erase(s.begin());       mark[cur] = true;       for (int i = 0; i < u[cur].size(); i++) {         int next = u[cur][i];         if (mark[next] == true) continue;         long long ndist = dis[cur] + cost2[cur][i];         if (dis[next] > ndist) {           s.erase(make_pair(dis[next], next));           dis[next] = min(ndist, dis[next]);           s.insert(make_pair(dis[next], next));         }       }     }     if (mark[y] == true)       cout << dis[y];     else       cout << -1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   const int maxn = 1e5 + 5;   string s;   set<pair<int, int>> t;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> s;     int cnt = 0;     for (int i = (int)s.size() - 1; i >= 0; i--) {       if (s[i] ==  0 )         cnt++;       else {         if (cnt)           cnt--;         else           s[i] =  0 ;       }     }     cout << s;   }
#include <bits/stdc++.h>   using namespace std;   const int NMAX = 50505;   const int LMAX = 1600505;   int N, A[NMAX];   vector<int> G[NMAX];   int currIdx;   unordered_map<int, int> allValues;   vector<int> newValues;   int L[NMAX];   bool mark[NMAX];   vector<int> R;   void read() {     scanf( %d , &N);     for (int i = 1; i <= N; i++) {       scanf( %d , &A[i]);     }     for (int i = 1; i <= N; i++) {       G[i].reserve(30);     }   }   inline int bit(int idx) { return 1 << (idx - 1); }   inline bool hasBit(int mask, int idx) { return mask & bit(idx); }   void findCandidates(int x, int maxV, vector<int>& result) {     int fstBit;     for (int i = 30; i >= 1; i--) {       if (hasBit(x, i)) {         fstBit = i;         break;       }     }     int curr = 0;     for (int i = fstBit; i >= 1; i--) {       curr = (curr << 1) + hasBit(x, i);       if (curr > maxV) {         break;       }       result.push_back(curr);     }   }   void clearPrevIter() {     allValues.clear();     newValues.clear();     for (int i = 1; i <= N; i++) {       G[i].clear();     }     currIdx = N;   }   bool pairup(int x) {     mark[x] = true;     for (auto& y : G[x]) {       if (!R[y] || (!mark[R[y]] && pairup(R[y]))) {         L[x] = y;         R[y] = x;         return true;       }     }     return false;   }   bool canMatch() {     memset(L, 0, sizeof(L));     R.assign(currIdx + 1, 0);     bool improve = true;     int currMatches = 0;     while (improve) {       improve = false;       memset(mark, false, sizeof(mark));       for (int i = 1; i <= N; i++) {         if (!L[i] && pairup(i)) {           improve = true;           currMatches++;         }       }     }     return currMatches == N;   }   bool check(int maxV) {     vector<int> currCandidates;     currCandidates.reserve(30);     clearPrevIter();     for (int i = 1; i <= N; i++) {       currCandidates.clear();       findCandidates(A[i], maxV, currCandidates);       for (auto& cand : currCandidates) {         auto it = allValues.find(cand);         int matchIdx;         if (it == allValues.end()) {           allValues[cand] = ++currIdx;           newValues.push_back(cand);           matchIdx = currIdx;         } else {           matchIdx = it->second;         }         G[i].push_back(matchIdx);       }     }     return canMatch();   }   int bSearch() {     int i, step = (1 << 30);     for (i = 0; step; step >>= 1) {       if (!check(i + step)) {         i += step;       }     }     return ++i;   }   void solve() {     int maxElem = bSearch();     check(maxElem);     for (int i = 1; i <= N; i++) {       if (i > 1) {         printf(   );       }       printf( %d , newValues[L[i] - N - 1]);     }     printf(  n );   }   int main() {     read();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main(void) {     ios::sync_with_stdio(false);     register int i;     register priority_queue<int> Queue;     register int N, T;     cin >> N >> T;     register int Ans;     Ans = 0;     for (i = 1; i <= N; i += 1) {       while (!Queue.empty() && Queue.top() >= T - i) {         Queue.pop();       }       register int X;       cin >> X;       if (max(X, i) < T) {         Queue.push(X - i);       }       Ans = max(Ans, (int)Queue.size());     }     cout << Ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double v[1000006], t[1000006];   int main() {     int n, i;     double a, d;     scanf( %d , &n);     scanf( %lf , &a);     scanf( %lf , &d);     for (i = 0; i < n; i++) {       scanf( %lf , &t[i]);       scanf( %lf , &v[i]);     }     double t0 = sqrt(2 * d / a);     double v0 = a * t0;     double prevt = -1, curt;     for (i = 0; i < n; i++) {       if (v[i] >= v0) {         curt = t[i] + t0;       } else {         double t1 = v[i] / a;         double d1 = 0.5 * a * t1 * t1;         double t2 = (d - d1) / v[i];         curt = t[i] + t1 + t2;       }       curt = max(curt, prevt);       printf( %.9lf n , curt);       prevt = curt;     }     return 0;   }