malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   const long long oo = (long long)1e18 + 1;   using namespace std;   int n, q;   int b[200002];   pair<int, int> a[200002];   int T[200002];   vector<pair<int, int> > query[200002];   int k[200002], p[200002];   int res[200002];   void upd(int x) {     while (x < 200002) {       T[x]++;       x = x + (x & (x ^ (x - 1)));     }   }   int get(int x) {     int res = 0;     while (x > 0) {       res += T[x];       x = x - (x & (x ^ (x - 1)));     }     return res;   }   int find_kth(int cnt) {     int l = 1;     int r = n;     int res = n;     while (l <= r) {       int mid = (l + r) >> 1;       int count_value = get(mid);       if (count_value >= cnt) {         res = mid;         r = mid - 1;       } else         l = mid + 1;     }     return res;   }   bool cmp(pair<int, int> x, pair<int, int> y) {     return x.first > y.first || (x.first == y.first && x.second < y.second);   }   int main() {     ios::sync_with_stdio(false);     cin >> n;     for (int i = 1; i <= n; i++) {       int x;       cin >> x;       b[i] = x;       a[i] = make_pair(x, i);     }     sort(a + 1, a + n + 1, cmp);     cin >> q;     for (int i = 1; i <= q; i++) {       cin >> k[i] >> p[i];       query[k[i]].push_back(make_pair(p[i], i));     }     for (int i = 1; i <= n; i++) {       upd(a[i].second);       for (int j = 0; j < query[i].size(); j++) {         pair<int, int> cur_query = query[i][j];         int pos = cur_query.first;         int rpos = cur_query.second;         res[rpos] = b[find_kth(pos)];       }     }     for (int i = 1; i <= q; i++) cout << res[i] <<   n ;     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /stack:200000000 )   #pragma GCC optimize( Ofast )   #pragma target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native )   using namespace std;   inline int read() {     char c = getchar();     int tot = 1;     while ((c <  0  || c >  9 ) && c !=  - ) c = getchar();     if (c ==  - ) {       tot = -1;       c = getchar();     }     int sum = 0;     while (c >=  0  && c <=  9 ) {       sum = sum * 10 + c -  0 ;       c = getchar();     }     return sum * tot;   }   inline void wr(int x) {     if (x < 0) {       putchar( - );       wr(-x);       return;     }     if (x >= 10) wr(x / 10);     putchar(x % 10 +  0 );   }   inline void wrn(int x) {     wr(x);     putchar(  n );   }   inline void wri(int x) {     wr(x);     putchar(   );   }   inline void wrn(int x, int y) {     wri(x);     wrn(y);   }   inline void wrn(int a, int b, int c) {     wri(a);     wrn(b, c);   }   const int N = 205;   int n, m, now, cnt, l[N], r[N], d[N];   double ans[N], f[N][N], len, ll, rr, p1, p2, p3;   void calc(int L, int R) {     cnt = 1;     for (int i = 0; i <= n; i++)       for (int j = 0; j <= n; j++) f[i][j] = 0;     f[0][0] = 1;     for (int i = 1; i <= n; i++)       if (i != now) {         if (r[i] <= L) {           cnt++;           continue;         }         if (l[i] >= R) continue;         len = r[i] - l[i];         p1 = (L - l[i]) / len;         p2 = (R - L) / len;         p3 = (r[i] - R) / len;         for (int j = i; j >= 0; j--)           for (int k = i - j; k >= 0; k--) {             f[j + 1][k] += f[j][k] * p1;             f[j][k + 1] += f[j][k] * p2;             f[j][k] *= p3;           }       }     for (int i = 0; i + cnt <= n; i++) {       for (int j = n - i - cnt; j >= 0; j--)         ans[i + cnt] += f[i][j] * (R - L) / (j + 1),             ans[i + j + 1 + cnt] -= f[i][j] * (R - L) / (j + 1);     }   }   signed main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d%d , &l[i], &r[i]);       d[++m] = l[i];       d[++m] = r[i];     }     sort(d + 1, d + m + 1);     int k = 1;     for (int i = 2; i <= m; i++)       if (d[i] != d[i - 1]) {         k++;         if (k != i) d[k] = d[i];       }     m = k;     for (int i = 1; i <= n; i++) {       now = i;       for (int j = 1; j <= n; j++) ans[j] = 0;       for (int j = 1; j < m; j++)         if (l[i] <= d[j] && r[i] >= d[j + 1]) calc(d[j], d[j + 1]);       for (int j = 1; j <= n; j++) ans[j] += ans[j - 1];       for (int j = 1; j <= n; j++) printf( %.6lf  , ans[j] / (r[i] - l[i]));       puts(  );     }   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }   const int MAXN = 16;   int n;   int mod[MAXN], rem[MAXN];   int egcd(int a, int b, int &x, int &y) {     if (b == 0) {       x = 1, y = 0;       return a;     }     int g = egcd(b, a % b, x, y);     swap(x, y);     y -= x * (a / b);     return g;   }   int mymod(int x, int mod) {     x %= mod;     if (x < 0) x += mod;     return x;   }   bool combine(int &n1, int &a1, int n2, int a2) {     int m1, m2, g = egcd(n1, n2, m1, m2);     if (a1 % g != a2 % g) return false;     int n3 = n1 / g * n2, a3 = mymod(a1 + m1 * (n1 / g) * (a2 - a1), n3);     n1 = n3, a1 = a3;     return true;   }   void run() {     scanf( %d , &n);     for (int i = (0); i < (n); ++i) scanf( %d , &mod[i]);     for (int i = (0); i < (n); ++i) scanf( %d , &rem[i]);     long long den = 20922789888000LL, num = 0;     for (int i = (0); i < (1 << n); ++i) {       int cmod = 1, crem = 0, cnt = 0;       bool ok = true;       for (int j = (0); j < (n); ++j)         if (i & (1 << j)) {           ++cnt;           if (!combine(cmod, crem, mod[j], rem[j])) ok = false;         }       if (!ok) continue;       if (cnt % 2 == 0)         num += den / cmod;       else         num -= den / cmod;     }     printf( %.9lf n , 1.0 * (den - num) / den);   }   int main() {     run();     return 0;   }
#include <bits/stdc++.h>   template <typename T>   inline bool chkmin(T &a, const T &b) {     return a > b ? a = b, 1 : 0;   }   template <typename T>   inline bool chkmax(T &a, const T &b) {     return a < b ? a = b, 1 : 0;   }   inline int read() {     static char ch;     bool sgn = false;     while (ch = getchar(), ch <  0  || ch >  9 )       if (ch ==  - ) sgn = true;     int res = ch - 48;     while (ch = getchar(), ch >=  0  && ch <=  9 ) res = res * 10 + ch - 48;     return sgn ? -res : res;   }   const int N = 2e5 + 5, M = 1e6 + 1;   const int mod = 1e9 + 7;   int n, m, a[N], l[N], r[N], p[N];   int f[N], ans[N];   int tot, pri[N], min[M], first[M];   bool isp[M];   inline bool cmp(const int &x, const int &y) { return r[x] < r[y]; }   inline int fpm(long long x, int Exp) {     long long res = 1;     for (; Exp > 0; x = x * x % mod, Exp >>= 1)       if (Exp & 1) res = res * x % mod;     return res;   }   inline void prime_init() {     isp[0] = isp[1] = true;     for (int i = 2; i < M; ++i) {       if (!isp[i]) pri[++tot] = i, min[i] = i;       for (int j = 1; j <= tot; ++j) {         if (i * pri[j] >= M) break;         isp[i * pri[j]] = true;         min[i * pri[j]] = pri[j];         if (i % pri[j] == 0) break;       }     }   }   inline void insert(int x, const int &y) {     for (; x <= n; x += x & -x) f[x] = (long long)f[x] * y % mod;   }   inline int Query(int x) {     int res = 1;     for (; x > 0; x -= x & -x) res = (long long)res * f[x] % mod;     return res;   }   inline void add(const int &x) {     int num = a[x], tmp;     while (num > 1) {       tmp = min[num];       if (first[tmp] > 0) {         insert(first[tmp], fpm(tmp - 1, mod - 2));         insert(first[tmp], tmp);       }       first[tmp] = x;       insert(x, tmp - 1);       num /= tmp;     }   }   int main() {     n = read();     for (int i = (1); i <= (n); ++i) a[i] = read(), f[i] = 1;     m = read();     for (int i = (1); i <= (m); ++i) {       l[i] = read();       r[i] = read();       p[i] = i;     }     std::sort(p + 1, p + m + 1, cmp);     prime_init();     int now = 0;     for (int i = (1); i <= (m); ++i) {       while (now < r[p[i]]) add(++now);       ans[p[i]] =           (long long)Query(r[p[i]]) * fpm(Query(l[p[i]] - 1), mod - 2) % mod;     }     for (int i = (1); i <= (m); ++i) printf( %d n , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long st;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long n, m, k;     cin >> n >> m >> k;     if (k < n) {       cout << (long long)(k + 1) <<     << 1;       return 0;     }     k -= (long long)(n - 1);     long long row = k / (long long)(m - 1), col;     if ((long long)row * (long long)(m - 1) != (long long)k) row++;     if ((long long)(row % (long long)2) == (long long)1) {       st = (long long)(row - (long long)1) * (long long)(m - (long long)1);       st++;       col = k - st + (long long)2;     } else {       st = (long long)row * (long long)(m - 1);       col = (long long)2 + st - k;     }     cout << (long long)(n - row + 1) <<     << col;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, a[100000], b, c = 0, x, y, z, m, i, j, t;     string s;     vector<int> v;     cin >> n;     for (i = 0; i < n; i++) {       cin >> x;       v.push_back(x);     }     sort(v.begin(), v.end());     for (i = 0; i < n / 2; i++) {       c += (v[i] + v[n - i - 1]) * (v[i] + v[n - i - 1]);     }     cout << c << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 3e5 + 2;   const long long N1 = 1e2 + 2;   const long long mod = 1e9 + 7;   const int MASK = 1 << 17 + 1;   const int who = 6 * N * log2(N);   long long power(long long a, long long b, long long c) {     long long ret = 1;     while (b) {       if (b % 2 == 1) {         ret = (ret * a) % c;       }       b /= 2;       a = (a * a) % c;     }     return ret;   }   pair<int, int> a[N + 2];   map<pair<int, int>, long long> ma, ma1;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n;     cin >> n;     for (int i = 0; i < n; i++) {       string s;       cin >> s;       int len = s.size();       int plus = 0, minus = 0;       for (int j = 0; j < len; j++) {         if (s[j] ==  ( ) {           plus++;         } else if (s[j] ==  ) ) {           if (plus == 0) {             minus++;           } else {             plus--;           }         }       }       a[i] = make_pair(plus, minus);       if (min(plus, minus) == 0) {         ma[a[i]]++;       }     }     long long tm1 = ma[make_pair(0, 0)];     long long ans = tm1 * tm1;     ma1[make_pair(0, 0)] = 1;     for (int i = 0; i < n; i++) {       int plus = a[i].first, minus = a[i].second;       if (min(plus, minus) > 0 || ma1[a[i]] > 0) {         continue;       }       ma1[a[i]]++;       ma1[make_pair(minus, plus)]++;       ans += ma[a[i]] * ma[make_pair(minus, plus)];     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:36777216 )   using namespace std;   template <typename T1, typename T2>   inline void chkmin(T1 &a, T2 b) {     if (a > b) a = b;   }   template <typename T1, typename T2>   inline void chkmax(T1 &a, T2 b) {     if (a < b) a = b;   }   const string FILENAME =  input ;   const int MAXN = 100228;   int n, m, d;   vector<int> g[MAXN];   bool who[MAXN * 50];   int res = 0;   vector<int> rg[MAXN];   vector<bool> used[102];   vector<int> ord;   int used1[MAXN * 50];   int st[MAXN * 50];   int id[MAXN * 50];   int nxt[MAXN * 50];   int lst[MAXN * 50];   int uks = 0;   int kek[MAXN * 50];   void add(int a, int b) {     if (st[a] == 0) {       uks++;       st[a] = uks;       id[uks] = b;       lst[a] = uks;       nxt[uks] = -1;     } else {       uks++;       nxt[lst[a]] = uks;       nxt[uks] = -1;       lst[a] = uks;       id[uks] = b;     }   }   void dfs1(int u, int t) {     used1[u * d + t] = true;     for (auto h : g[u]) {       if (!used1[h * d + (t + 1) % d]) {         dfs1(h, (t + 1) % d);       }     }     ord.push_back(u * d + t);   }   int used2[MAXN];   void dfs2(int u, int t, int c) {     used1[u * d + t] = c;     if (who[u * d + t]) {       if (used2[u] != c) {         kek[c]++;         used2[u] = c;       }     }     for (auto h : rg[u]) {       if (!used1[h * d + (t - 1 + d) % d]) {         dfs2(h, (t - 1 + d) % d, c);       }     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> m >> d;     for (int i = 0; i < m; i++) {       int u, v;       cin >> u >> v;       u--, v--;       g[u].push_back(v);       rg[v].push_back(u);     }     for (int i = 0; i < n; i++) {       string s;       cin >> s;       for (int j = 0; j < d; j++) {         if (s[j] ==  1 ) {           who[i * d + j] = true;         }       }     }     for (int i = 0; i < n * d; i++) {       if (!used1[i]) {         dfs1(i / d, i % d);       }     }     memset(used1, 0, sizeof(used1));     int cur = 1;     reverse((ord).begin(), (ord).end());     for (auto x : ord) {       if (!used1[x]) {         dfs2(x / d, x % d, cur);         cur++;       }     }     for (int i = 0; i < n * d; i++) {       for (auto x : g[i / d]) {         int f = (i % d + 1) % d;         if (used1[i] != used1[x * d + f]) {           add(used1[i], used1[x * d + f]);         }       }     }     int ff = used1[0];     for (int x = cur - 1; x >= 1; x--) {       int dp = 0;       int cur = st[x];       if (cur) {         while (cur != -1) {           chkmax(dp, kek[id[cur]]);           cur = nxt[cur];         }       }       kek[x] += dp;     }     cout << kek[ff] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   bool f[100009];   pair<int, int> a[100009];   vector<int> v[100009];   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i].first);       a[i].second = i;     }     sort(a + 1, a + n + 1);     for (int i = 1; i <= n; i++)       if (!f[i]) {         int x = i;         while (!f[x]) {           f[x] = 1;           v[m].push_back(x);           x = a[x].second;         }         m++;       }     printf( %d n , m);     for (int i = 0; i < m; i++) {       printf( %d  , v[i].size());       for (int j = 0; j < v[i].size(); j++) printf( %d  , v[i][j]);       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void arr(string &s);   int main() {     int n = 0, k = 0, m = 0;     bool b = 0;     cin >> n >> k;     string s =   ;     cin >> s;     arr(s);     for (int i = 0; i < s.length(); i++) switch (s[i]) {         case  G :           m = i;           i = s.length();           break;       }     for (int i = m; i < s.length(); i += k) switch (s[i]) {         case  T :           b = 1;           i = s.length();           break;         case  # :           i = s.length();           break;       }     switch (b) {       case 1:         cout <<  YES n ;         break;       default:         cout <<  NO n ;     }   }   void arr(string &s) {     int a = 0, b = 0;     string v = s;     for (int i = 0; i < s.length(); i++) {       switch (s[i]) {         case  G :           a = i;           break;         case  T :           b = i;           break;       }     }     if (a > b) {       for (int i = 1; i <= s.length(); i++) v[i - 1] = s[s.length() - i];       s = v;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 7;   int a[N], b[N], na[N], nb[N], t1[N], t2[N], c[N], tp, q[N], mx[N], x, n, m, i,       j;   long long ans;   void init(int* a, int* ans, int n) {     for (memset(ans, 0x3f, (n + 3) << 2), tp = 0, i = 1; i <= n; ++i) {       j = a[i];       while (tp && a[i] < a[q[tp]]) j = max(j, mx[tp--]);       if (tp) ans[i] = min(ans[i], j);       q[++tp] = i;       mx[tp] = j;     }     for (tp = 0, i = n; i; --i) {       j = a[i];       while (tp && a[i] <= a[q[tp]]) j = max(j, mx[tp--]);       if (tp) ans[i] = min(ans[i], j);       q[++tp] = i;       mx[tp] = j;     }   }   void A(int x, int C) {     while (x < N) c[x] += C, x += x & -x;   }   int Q(int x, int C = 0) {     while (x > 0) C += c[x], x -= x & -x;     return C;   }   int main() {     for (scanf( %d%d%d , &n, &m, &x), i = 1; i <= n; ++i)       scanf( %d , a + i), t1[i] = i;     for (i = 1; i <= m; ++i) scanf( %d , b + i), t2[i] = i;     init(a, na, n);     init(b, nb, m);     sort(t1 + 1, t1 + n + 1, [&](int x, int y) { return a[x] < a[y]; });     sort(t2 + 1, t2 + m + 1, [&](int x, int y) { return nb[x] < nb[y]; });     for (i = 1, j = m; i <= n; ++i) {       while (j && a[t1[i]] + nb[t2[j]] > x) A(b[t2[j--]], 1);       ans += Q(x - a[t1[i]]) - Q(x - na[t1[i]]);     }     printf( %lld n , ans);   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     int x = 0, c = getchar(), f = 0;     for (; c >  9  || c <  0 ; f = c ==  - , c = getchar())       ;     for (; c >=  0  && c <=  9 ; x = (x << 1) + (x << 3) + c -  0 , c = getchar())       ;     return f ? -x : x;   }   inline void write(int x) {     if (x < 0) putchar( - ), x = -x;     if (x >= 10) write(x / 10);     putchar(x % 10 + 48);   }   const int N = 100 + 10, oo = 1e9;   int n, m, q, a, b, f[N], ans[N], dis[N][N], st[N], en[N], vis[N];   bool must[N][N];   int dfs(int x, int y, int Time) {     if (x == y) return ans[x];     if (vis[x] == Time) return f[x];     vis[x] = Time;     f[x] = 0;     for (int i = (int)1, _y = n; i <= _y; i++)       if (dis[x][i] == 1 && dis[i][y] + 1 == dis[x][y])         f[x] = max(f[x], dfs(i, y, Time));     return f[x] = min(f[x], ans[x]);   }   int main() {     n = read(), m = read(), a = read(), b = read();     for (int i = (int)1, _y = n; i <= _y; i++)       for (int j = (int)i + 1, _y = n; j <= _y; j++) dis[i][j] = dis[j][i] = oo;     for (int i = (int)1, _y = m; i <= _y; i++) {       int u = read(), v = read();       dis[u][v] = 1;     }     for (int k = (int)1, _y = n; k <= _y; k++)       for (int i = (int)1, _y = n; i <= _y; i++)         if (i != k)           for (int j = (int)1, _y = n; j <= _y; j++)             if (i != j && j != k && dis[i][j] > dis[i][k] + dis[k][j])               dis[i][j] = dis[i][k] + dis[k][j];     q = read();     for (int i = (int)1, _y = q; i <= _y; i++) {       st[i] = read(), en[i] = read();       if (dis[st[i]][en[i]] == oo) continue;       memset(vis, 0, sizeof vis);       for (int j = (int)1, _y = n; j <= _y; j++)         if (dis[st[i]][j] + dis[j][en[i]] == dis[st[i]][en[i]])           vis[dis[st[i]][j]]++;       for (int j = (int)1, _y = n; j <= _y; j++)         if (dis[st[i]][j] + dis[j][en[i]] == dis[st[i]][en[i]] &&             vis[dis[st[i]][j]] == 1)           must[i][j] = 1;     }     for (int i = (int)1, _y = n; i <= _y; i++) ans[i] = oo, vis[i] = 0;     ans[b] = 0;     for (int Time = (int)1, _y = n; Time <= _y; Time++) {       memset(vis, 0, sizeof vis);       for (int i = (int)1, _y = q; i <= _y; i++)         if (dis[st[i]][en[i]] != oo)           for (int j = (int)1, _y = n; j <= _y; j++)             if (must[i][j]) ans[j] = min(ans[j], dfs(j, en[i], i) + 1);     }     printf( %d n , ans[a] == oo ? -1 : ans[a]);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int TESTS = 1;     while (TESTS--) {       long long m = 1, ans = 1;       long long n;       cin >> n;       while (ans < n) {         m++;         ans += 2;       }       cout << m <<   n ;       long long x = 1, y = 1;       cout << 1 <<     << 1 <<   n ;       x++;       for (long long i = 1; i < n; i++) {         cout << x <<     << y <<   n ;         if (i == n - 1) break;         i++;         cout << x <<     << y + 1 <<   n ;         x++;         y++;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int read() {     int x = 0, sgn = 1;     char ch = getchar();     for (; !isdigit(ch); ch = getchar())       if (ch ==  - ) sgn = -1;     for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);     return x * sgn;   }   const int N = 1e5 + 10;   int n, b[N << 1], tot, l[N], r[N], deg[N << 1], h[N << 1], cnt = 1, now[N << 1],                                                              ans[N << 1];   struct edge {     int v, w, nxt;   } e[N << 2];   bool v[N << 2], vis[N << 1];   void link(int x, int y, int w) {     e[++cnt] = (edge){y, w, h[x]};     h[x] = cnt;   }   void dfs(int x) {     vis[x] = 1;     for (int i = now[x], y; i; i = e[now[x]].nxt) {       now[x] = i;       if (v[i]) continue;       y = e[i].v;       v[i] = v[i ^ 1] = 1;       ans[e[i].w] = x < y;       dfs(y);     }   }   int main() {     n = read();     for (int i = 1; i <= n; i++)       b[++tot] = l[i] = read(), b[++tot] = r[i] = read() + 1;     sort(b + 1, b + tot + 1);     tot = unique(b + 1, b + tot + 1) - b - 1;     for (int i = 1; i <= n; i++) {       l[i] = lower_bound(b + 1, b + tot + 1, l[i]) - b;       r[i] = lower_bound(b + 1, b + tot + 1, r[i]) - b;       deg[l[i]]++;       deg[r[i]]++;       link(l[i], r[i], i);       link(r[i], l[i], i);     }     int lst = 0;     for (int i = 1; i <= tot; i++) {       if (!(deg[i] & 1)) continue;       if (lst)         link(lst, i, 0), link(i, lst, 0), lst = 0;       else         lst = i;     }     for (int i = 1; i <= tot; i++) now[i] = h[i];     for (int i = 1; i <= tot; i++)       if (!vis[i]) dfs(i);     for (int i = 1; i <= n; i++) {       if (ans[i])         printf( 1  );       else         printf( 0  );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char *student;   int *arr;   struct node {     int x;     int y;     int val;   };   std::vector<node> v;   std::vector<node> out;   struct edge {     int v;     edge *left;     edge *right;   };   edge *ed;   bool *flag;   bool comp(node &a, node &b) {     return (!(a.val < b.val || (a.val == b.val && a.x < b.x)));   }   void make_node(int x, int y) {     if (student[x] ^ student[y]) {       node temp;       temp.x = x;       temp.y = y;       temp.val = abs(arr[x] - arr[y]);       v.push_back(temp);       push_heap(v.begin(), v.end(), comp);     }   }   void print() {     for (std::vector<node>::iterator it = out.begin(); it != out.end(); ++it) {       node temp = *it;       cout << temp.x + 1 <<     << temp.y + 1 << endl;     }   }   void select() {     while (true) {       int l = -1, r = -1;       while (v.size() > 0) {         node temp = v.front();         pop_heap(v.begin(), v.end(), comp);         v.pop_back();         l = temp.x;         r = temp.y;         if (flag[l] || flag[r]) {           l = -1;           r = -1;           continue;         } else {           flag[l] = true;           flag[r] = true;           out.push_back(temp);           break;         }       }       if (l == -1) break;       edge *lt = ed[l].left;       edge *rt = ed[r].right;       if (lt != NULL) {         lt->right = rt;       }       if (rt != NULL) {         rt->left = lt;       }       if (lt != NULL && rt != NULL) make_node(lt->v, rt->v);     }   }   int main() {     std::cout << std::fixed << std::setprecision(10);     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n;     cin >> n;     student = new char[n];     arr = new int[n];     flag = new bool[n];     string s;     cin >> s;     for (int i = 0; i < n; i++) {       student[i] = s[i];       int x;       cin >> x;       arr[i] = x;       flag[i] = false;     }     for (int i = 0; i < n - 1; i++) {       make_node(i, i + 1);     }     ed = new edge[n];     for (int i = 0; i < n; i++) {       ed[i].v = i;       ed[i].left = i > 0 ? &ed[i - 1] : NULL;       ed[i].right = i < n - 1 ? &ed[i + 1] : NULL;     }     select();     cout << out.size() << endl;     print();   }
#include <bits/stdc++.h>   using namespace std;   long long n, a, b, c;   long long d;   long long cnt1, cnt2;   long long r;   int main() {     cin >> n >> a >> b >> c;     d = b - c;     if (n >= a) {       cnt1 = n / a;       r = n % a;       if (r >= b) cnt1 += (r - b) / d + 1;     }     if (n >= b) {       r = n - b;       long long cnt = r / d + 1;       cnt2 += cnt;       cnt2 += (n - cnt * d) / a;     }     printf( %lld n , max(cnt1, cnt2));     return 0;   }