malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   vector<vector<int> > adjl(500000);   int s[500000] = {0};   long long int a[500000] = {0};   map<pair<int, int>, long long int> mp;   int vis[500000] = {0};   void dfs(int n, vector<pair<int, int> > &ans, int p, long long int sum,            long long int mini) {     if (sum - mini > a[n]) {       ans.push_back(make_pair(n, p));     }     for (int i = 0; i < adjl[n].size(); i++) {       int ch = adjl[n][i];       if (ch != p) {         dfs(ch, ans, n, sum + mp[make_pair(ch, n)],             min(mini, sum + mp[make_pair(ch, n)]));       }     }   }   void dfs1(int n, int p, int &count) {     vis[n] = 1;     count++;     for (int i = 0; i < adjl[n].size(); i++) {       int ch = adjl[n][i];       if (ch != p) {         dfs1(ch, n, count);       }     }   }   int main() {     int n;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i + 1];     }     for (int i = 0; i < (n - 1); i++) {       int a, c;       cin >> a >> c;       adjl[a].push_back(i + 2);       adjl[i + 2].push_back(a);       mp[make_pair(a, i + 2)] = c;       mp[make_pair(i + 2, a)] = c;     }     vector<pair<int, int> > ans;     dfs(1, ans, -1, 0, 0);     long long int ans1 = 0;     for (int i = 0; i < ans.size(); i++) {       if (!vis[ans[i].first]) {         int count = 0;         dfs1(ans[i].first, ans[i].second, count);         ans1 += count;       }     }     cout << ans1 << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long f[100];   int s[100];   long long dp[100][2];   int main() {     f[0] = f[1] = 1;     for (int i = 2; i < 100; i++) {       f[i] = f[i - 1] + f[i - 2];     }     int cas;     cin >> cas;     while (cas--) {       long long n;       cin >> n;       int cnt = 0;       for (int i = 90; i >= 1; i--) {         if (n >= f[i]) {           n -= f[i];           s[++cnt] = i;         }       }       reverse(s + 1, s + cnt + 1);       dp[0][0] = 1;       dp[0][1] = 0;       for (int i = 1; i <= cnt; i++) {         dp[i][0] = dp[i - 1][0] + dp[i - 1][1];         dp[i][1] = dp[i - 1][0] * ((s[i] - s[i - 1] - 1) / 2) +                    dp[i - 1][1] * ((s[i] - s[i - 1]) / 2);       }       cout << dp[cnt][0] + dp[cnt][1] << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long max(long long a, long long b) {     if (a > b) {       return a;     } else {       return b;     }   }   long long min(long long a, long long b) {     if (a < b) {       return a;     } else {       return b;     }   }   string int2str(int& i) {     string s;     stringstream ss(s);     ss << i;     return ss.str();   }   int cnt;   bool done[100000000];   void outputspec(int x) {     if (!done[x]) {       done[x] = 1;       string u = int2str(x);       while (u.length() < 8) {         u =  0  + u;       }       cout << u << endl;       cnt--;     }   }   struct node {     int dir;     node* next;   };   node *h[20001], *ba[20001];   void insert(int data, int tar) {     node* temp = new node;     temp->next = NULL;     temp->dir = data;     ba[tar]->next = temp;     ba[tar] = temp;   }   void trygen(int cur, int id, int act, int yes) {     if (id == 0) {       if ((cur <= 10000) && (cur >= -10000)) {         insert(act, cur + 10000);       }     } else {       for (long long i = 0; i <= 9; i++) {         int cur2 = cur + i, id2 = id / 10, act2 = act + id * i;         trygen(cur2, id2, act2, 0);         cur2 = cur - i;         id2 = id / 10;         act2 = act + id * i;         trygen(cur2, id2, act2, 0);         if (yes) {           cur2 = cur * 10 + i;           id2 = id / 10;           act2 = act + id * i;           trygen(cur2, id2, act2, 1);         }         if (id != 1000) {           cur2 = cur * i;           id2 = id / 10;           act2 = act + id * i;           trygen(cur2, id2, act2, 0);         }       }     }   }   int main() {     int k, m;     cin >> k >> m;     for (long long i = 0; i <= 99999999; i++) {       done[i] = 0;     }     if (k == 0) {       for (long long i = 1; i <= m; i++) {         outputspec(i);       }       return 0;     }     if (k != 0) {       for (long long i = 0; i <= 20000; i++) {         h[i] = new node;         h[i]->next = NULL;         ba[i] = h[i];       }       trygen(0, 1000, 0, 1);       cnt = m;       for (long long j = 1; j <= 9999; j++) {         node* a = h[j + 10000];         if (cnt == 0) {           return 0;         } else {           while (a->next != NULL) {             a = a->next;             node* b = h[k + 10000 - j];             while (b->next != NULL) {               b = b->next;               outputspec(a->dir * 10000 + b->dir);               if (cnt == 0) {                 return 0;               }             }             b = h[-1 * k + j + 10000];             while (b->next != NULL) {               b = b->next;               outputspec(a->dir * 10000 + b->dir);               if (cnt == 0) {                 return 0;               }             }           }         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1e9 + 7;   const long long INF = 1e18;   const long double PI = acos((long double)-1);   const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};   void setIO(string name =   ) {     ios_base::sync_with_stdio(0);     cin.tie(0);     if ((int)(name).size()) {       freopen((name +  .in ).c_str(),  r , stdin);       freopen((name +  .out ).c_str(),  w , stdout);     }   }   int main() {     setIO();     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       int arr[n];       for (int i = (0); i < (n); i++) cin >> arr[i];       int last = 1;       int cnt = 0, prev = 1, c = 0;       for (int i = (1); i < (n - 1); i++) {         if (arr[i] > arr[i + 1]) {           cnt++;         }         c++;         if (cnt >= prev) {           last++;           prev = c;           c = 0;           cnt = 0;         }       }       cout << last <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int SQ = 350;   const int MAX_N = 100000;   deque<int> a[MAX_N / SQ + 10];   int num[MAX_N / SQ + 10][MAX_N + 10];   int N, Q, lastans = 0;   void print() {     for (int i = 0; i <= N / SQ; i++) {       for (int j = 0; j < a[i].size(); j++) {         cout << a[i][j] <<    ;       }     }     cout << endl;     return;   }   int main() {     scanf( %d , &N);     for (int i = 0; i < N; i++) {       int x = i / SQ, k;       scanf( %d , &k);       a[x].push_back(k);       num[x][k]++;     }     scanf( %d , &Q);     for (int i = 0; i < Q; i++) {       int type, l, r, k;       scanf( %d , &type);       if (type == 1) {         scanf( %d %d , &l, &r);         l = (l + lastans - 1) % N;         r = (r + lastans - 1) % N;         if (l > r) swap(l, r);         int lx = l / SQ, ly = l % SQ, rx = r / SQ, ry = r % SQ;         if (lx == rx) {           int f = a[rx][ry];           a[rx].erase(a[rx].begin() + ry);           a[rx].insert(a[rx].begin() + ly, f);         } else {           int f = a[rx][ry];           a[rx].erase(a[rx].begin() + ry);           num[rx][f]--;           for (int j = lx; j < rx; j++) {             int b = a[j].back();             a[j].pop_back();             a[j + 1].push_front(b);             num[j][b]--;             num[j + 1][b]++;           }           a[lx].insert(a[lx].begin() + ly, f);           num[lx][f]++;         }       } else {         scanf( %d %d %d , &l, &r, &k);         l = (l + lastans - 1) % N;         r = (r + lastans - 1) % N;         k = (k + lastans - 1) % N + 1;         if (l > r) swap(l, r);         int lx = l / SQ, ly = l % SQ, rx = r / SQ, ry = r % SQ;         int ans = 0;         if (lx == rx) {           for (int j = ly; j <= ry; j++)             if (a[lx][j] == k) ans++;         } else {           for (int j = ly; j < SQ; j++)             if (a[lx][j] == k) ans++;           for (int j = lx + 1; j < rx; j++) ans += num[j][k];           for (int j = 0; j <= ry; j++)             if (a[rx][j] == k) ans++;         }         lastans = ans;         printf( %d n , ans);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   pair<int, int> operator+(const pair<int, int> &a, const pair<int, int> &b) {     return make_pair(a.first + b.first, a.second + b.second);   }   pair<int, int> operator-(const pair<int, int> &a, const pair<int, int> &b) {     return make_pair(a.first - b.first, a.second - b.second);   }   pair<int, int> &operator+=(pair<int, int> &a, const pair<int, int> &b) {     a.first += b.first;     a.second += b.second;     return a;   }   pair<int, int> &operator-=(pair<int, int> &a, const pair<int, int> &b) {     a.first -= b.first;     a.second -= b.second;     return a;   }   template <class T, class U>   bool cmp_second(const pair<T, U> &a, const pair<T, U> &b) {     return a.second < b.second;   }   template <class T>   T gcd(T a, T b) {     a = abs(a);     b = abs(b);     while (b) {       T t = b;       b = a % b;       a = t;     }     return a;   }   template <class T>   pair<T, T> ext_gcd(T a, T b) {     T a0 = 1, a1 = 0, b0 = 0, b1 = 1;     if (a < 0) {       a = -a;       a0 = -1;     }     if (b < 0) {       b = -b;       b1 = -1;     }     while (b) {       T t, q = a / b;       t = b;       b = a - b * q;       a = t;       t = b0;       b0 = a0 - b0 * q;       a0 = t;       t = b1;       b1 = a1 - b1 * q;       a1 = t;     }     return make_pair(a0, a1);   }   inline int sg(int x) { return x ? (x > 0 ? 1 : -1) : 0; }   int main(void) {     int len, skip;     scanf( %d %d , &(len), &(skip));     len++;     skip++;     long long sol = 0;     for (int a = skip; a <= len - a; a++) {       int b = len - a;       int ab3 = a * b * 3;       int cnt = 0;       for (int c = skip; c <= len - skip; c++) {         int dmax = (ab3 - 1) / (a + c) - b;         dmax = min(dmax, len - skip);         dmax = max(dmax, skip - 1);         if (dmax < skip) break;         cnt += dmax - (skip - 1);       }       sol += cnt + (a < len - a ? cnt : 0);     }     sol *= 3;     cout << sol << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long i, j, k, n, a[100500][3], dp[100500][2];   int main() {     cin >> n;     for (j = 0; j < 3; j++)       for (i = 0; i < n; i++) cin >> a[i][j];     dp[0][0] = a[0][0];     dp[0][1] = a[0][1];     for (i = 1; i <= n; i++) {       dp[i][0] = max(dp[i - 1][0] + a[i][1], dp[i - 1][1] + a[i][0]);       dp[i][1] = max(dp[i - 1][0] + a[i][2], dp[i - 1][1] + a[i][1]);     }     cout << dp[n - 1][0] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 2001111;   long long n, m, k;   long long md = 1000000007;   long long a[N];   set<long long> s;   long long len[N];   vector<long long> t[N];   vector<long long> pref[N];   void merge(vector<long long> &t, vector<long long> a, vector<long long> b,              long long x, long long y) {     long long i = 0;     long long j = 0;     while (i < a.size() && j < b.size()) {       if (a[i] + x <= b[j] + y) {         t.push_back(a[i] + x);         i++;       } else {         t.push_back(b[j] + y);         j++;       }     }     while (i < a.size()) {       t.push_back(a[i] + x);       i++;     }     while (j < b.size()) {       t.push_back(b[j] + y);       j++;     }   }   void build(long long x) {     if (x * 2 <= n) {       build(x * 2);     }     if (x * 2 + 1 <= n) {       build(x * 2 + 1);     }     t[x].push_back(0);     merge(t[x], t[x * 2], t[x * 2 + 1], len[x * 2], len[x * 2 + 1]);     pref[x].push_back(t[x][0]);     for (long long i = 1; i < t[x].size(); i++) {       pref[x].push_back(t[x][i] + pref[x][i - 1]);     }   }   signed main() {     ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);     cin >> n >> m;     for (long long i = 2; i <= n; i++) {       cin >> len[i];     }     build(1);     long long ans = 0;     for (long long i = 1; i <= m; i++) {       long long x, h;       cin >> x >> h;       long long pos = upper_bound(t[x].begin(), t[x].end(), h) - t[x].begin() - 1;       ans = ans + (pos + 1) * h - pref[x][pos];       long long prev = x;       h -= len[x];       x /= 2;       while (x >= 1) {         if (h <= 0) {           break;         }         ans += h;         if (x * 2 != prev && x * 2 <= n) {           h -= len[x * 2];           pos = upper_bound(t[x * 2].begin(), t[x * 2].end(), h) -                 t[x * 2].begin() - 1;           if (pos >= 0) ans = ans + (pos + 1) * h - pref[2 * x][pos];           h += len[x * 2];         }         if (x * 2 + 1 != prev && x * 2 + 1 <= n) {           h -= len[x * 2 + 1];           pos = upper_bound(t[x * 2 + 1].begin(), t[x * 2 + 1].end(), h) -                 t[x * 2 + 1].begin() - 1;           if (pos >= 0) ans = ans + (pos + 1) * h - pref[2 * x + 1][pos];           h += len[x * 2 + 1];         }         h -= len[x];         prev = x;         x /= 2;       }       cout << ans <<   n ;       ans = 0;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   int x, y;   vector<int> v1[200086], v2[200086];   bool ins[200086];   bool vis[200086], vis1[200086], vis2[200086];   bool e[200086];   int ans;   void dfs(int i) {     vis[i] = ins[i] = true;     for (int j = 0; j < v1[i].size(); j++) {       int to = v1[i][j];       if (ins[to]) {         printf( -1 );         exit(0);       }       if (!vis[to]) dfs(to);     }     ins[i] = false;   }   void dfs1(int i) {     vis1[i] = true;     for (int j = 0; j < v1[i].size(); j++) {       int to = v1[i][j];       if (!vis1[to]) dfs1(to);     }   }   void dfs2(int i) {     vis2[i] = true;     for (int j = 0; j < v2[i].size(); j++) {       int to = v2[i][j];       if (!vis2[to]) dfs2(to);     }   }   int main() {     scanf( %d%d , &n, &m);     ans = n;     for (int i = 1; i <= m; i++)       scanf( %d%d , &x, &y), v1[x].push_back(y), v2[y].push_back(x);     for (int i = 1; i <= n; i++)       if (!vis[i]) dfs(i);     for (int i = 1; i <= n; i++) {       if (vis1[i])         e[i] = true;       else         dfs1(i);       if (vis2[i])         e[i] = true;       else         dfs2(i);       if (e[i]) ans--;     }     printf( %d n , ans);     for (int i = 1; i <= n; i++) printf( %c , e[i] ?  E  :  A );   }
#include <bits/stdc++.h>   using namespace std;   int main() {     vector<char> vec(100001);     vec[0] =  a ;     int i = 1;     while (i < 100001) {       if (vec[i - 1] ==  a )         vec[i] =  b ;       else if (vec[i - 1] ==  b )         vec[i] =  c ;       else if (vec[i - 1] ==  c )         vec[i] =  d ;       else if (vec[i - 1] ==  d )         vec[i] =  a ;       i++;     }     int n;     cin >> n;     for (int i = 0; i < n; i++) cout << vec[i];     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   map<long long, int> cont;   int n;   int ans;   int main() {     while (~scanf( %d , &n)) {       int a;       long long num = 0;       for (int i = 1; i <= n; i++) {         scanf( %d , &a);         num += a;         ans = max(ans, ++cont[num]);       }       printf( %d n , n - ans);     }     cont.clear();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, k, d1[200005], d2[200005], ty, re1, re2, re3;   long long s, a[200005], b[200005], te;   vector<pair<long long, int> > v1, v2;   vector<long long> v3;   void bs(int lo, int up) {     int mid = (lo + up) / 2;     if (lo == up) {       v3.clear();       for (int i = 0; i < v2.size(); i++) v3.push_back(v2[i].first * b[mid]);       for (int i = 0; i < v1.size(); i++) {         if (v1[i].first * a[mid] > s) break;         int k1 = upper_bound(v3.begin(), v3.end(), s - v1[i].first * a[mid]) -                  v3.begin();         if (i + 1 + k1 >= k) {           re1 = i, re2 = k - i - 2, re3 = mid;           return;         }       }       if (v3.size() >= k && v3[k - 1] <= s) {         re1 = -1, re2 = k - 1;         re3 = mid;         return;       }     }     v3.clear();     for (int i = 0; i < v2.size(); i++) v3.push_back(v2[i].first * b[mid]);     for (int i = 0; i < v1.size(); i++) {       if (v1[i].first * a[mid] > s) break;       int k1 = upper_bound(v3.begin(), v3.end(), s - v1[i].first * a[mid]) -                v3.begin();       if (i + 1 + k1 >= k) {         re1 = i, re2 = k - i - 2, re3 = mid;         bs(lo, mid);         return;       }     }     if (v3.size() >= k && v3[k - 1] <= s) {       re1 = -1, re2 = k - 1;       re3 = mid;       bs(lo, mid);       return;     }     bs(mid + 1, up);   }   int main() {     cin >> n >> m >> k >> s;     a[0] = 1e9;     b[0] = 1e9;     for (int i = 1; i <= n; i++) {       cin >> a[i];       if (a[i] < a[i - 1])         d1[i] = i;       else         a[i] = a[i - 1], d1[i] = d1[i - 1];     }     v1.clear();     for (int i = 1; i <= n; i++) {       cin >> b[i];       if (b[i] < b[i - 1])         d2[i] = i;       else         b[i] = b[i - 1], d2[i] = d2[i - 1];     }     v2.clear();     for (int i = 1; i <= m; i++) {       cin >> ty;       if (ty == 1) {         cin >> te;         v1.push_back(pair<long long, int>(te, i));       } else {         cin >> te;         v2.push_back(pair<long long, int>(te, i));       }     }     sort(v1.begin(), v1.end());     sort(v2.begin(), v2.end());     for (int i = 1; i < v1.size(); i++) v1[i].first += v1[i - 1].first;     for (int i = 1; i < v2.size(); i++) v2[i].first += v2[i - 1].first;     re3 = 1e9;     v3.clear();     for (int i = 0; i < v2.size(); i++) v3.push_back(v2[i].first * b[n]);     for (int i = 0; i < v1.size(); i++) {       if (v1[i].first * a[n] > s) break;       int k1 =           upper_bound(v3.begin(), v3.end(), s - v1[i].first * a[n]) - v3.begin();       if (i + 1 + k1 >= k) {         re1 = i, re2 = k - i - 2, re3 = n;         break;       }     }     if (v3.size() >= k && v3[k - 1] <= s) {       re1 = -1, re2 = k - 1;       re3 = n;     }     if (re3 != 1e9) {       bs(1, n);       cout << re3 << endl;       for (int i = 0; i <= re1; i++)         cout << v1[i].second <<     << d1[re3] << endl;       for (int i = 0; i <= re2; i++)         cout << v2[i].second <<     << d2[re3] << endl;     } else       cout << -1 << endl;     return 0;   }
#include <bits/stdc++.h>   const int inf = (1ll << 30) - 1;   const int maxn = (int)1e5 + 10;   using namespace std;   int dp[150][(1 << 16) + 100];   int c[111];   int r[111];   int b[111];   char temp[111];   int cntR[(1 << 16) + 10];   int cntB[(1 << 16) + 10];   int n;   void solve() {     memset(dp, -1, sizeof dp);     queue<pair<pair<int, int>, int> > pq;     scanf( %d , &n);     int xx = 0;     for (int i = 0; i < n; i++) {       scanf( %s%d%d , temp, &r[i], &b[i]);       c[i] = temp[0] ==  R  ? 1 : 0;       xx += c[i];     }     for (int i = 0; i < (1 << n); i++) {       for (int j = 0; j < n; j++) {         if (i & (1 << j)) {           if (c[j])             cntR[i]++;           else             cntB[i]++;         }       }     }     dp[0][0] = 0;     pq.push(make_pair(make_pair(0, 0), 0));     while (pq.size() > 0) {       int x = pq.front().first.first;       int y = pq.front().first.second;       int mask = pq.front().second;       pq.pop();       if (dp[x][mask] < y) continue;       for (int i = 0; i < n; i++) {         if (mask & (1 << i)) continue;         int nmask = mask | (1 << i);         int X = x, Y = y;         if (r[i] >= cntR[mask]) {           X += cntR[mask];         } else           X += r[i];         if (b[i] >= cntB[mask]) {           Y += cntB[mask];         } else           Y += b[i];         if (dp[X][nmask] == -1 || dp[X][nmask] < Y) {           dp[X][nmask] = Y;           pq.push(make_pair(make_pair(X, Y), nmask));         }       }     }     int sumA = 0, sumB = 0;     for (int i = 0; i < n; i++) {       sumA += r[i];       sumB += b[i];     }     int ans = inf;     for (int i = 0; i < 144; i++) {       if (dp[i][(1 << n) - 1] == -1) continue;       ans = min(ans, max(sumA - i, sumB - dp[i][(1 << n) - 1]));     }     printf( %d n , ans + n);   }   int main() {     int t = 1;     for (int i = 1; i <= t; i++) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> adj[300005];   vector<int> vec;   int par[300005];   int vis1[300005];   int vis2[300005];   int vis3[300005];   int vis4[300005];   int dia[300005];   int root(int x) { return par[x] = ((par[x] == x) ? x : root(par[x])); }   void unite(int x, int y) { par[root(y)] = root(x); }   void dfs1(int x, int cnt, int &y, int &mx, int t) {     if (t)       vis1[x] = 1;     else       vis2[x] = 1;     int i;     for (i = 0; i < int(adj[x].size()); i++) {       if ((!vis1[adj[x][i]] && t) || (!vis2[adj[x][i]] && !t)) {         dfs1(adj[x][i], cnt + 1, y, mx, t);       }     }     if (cnt > mx) {       mx = cnt;       y = x;     }   }   bool dfs2(int x, int y) {     if (x == y) {       vec.push_back(y);       return true;     }     vis3[x] = 1;     int i;     for (i = 0; i < int(adj[x].size()); i++) {       if (!vis3[adj[x][i]]) {         if (dfs2(adj[x][i], y)) {           vec.push_back(adj[x][i]);           return true;         }       }     }     return false;   }   void dfs3(int x, int y) {     vis4[x] = 1;     unite(y, x);     int i;     for (i = 0; i < int(adj[x].size()); i++) {       if (!vis4[adj[x][i]]) {         dfs3(adj[x][i], y);       }     }   }   int main() {     int i, n, m, q, x, y, c;     scanf( %d %d %d , &n, &m, &q);     for (i = 0; i <= n; i++) par[i] = i;     for (i = 0; i < m; i++) {       scanf( %d %d , &x, &y);       adj[x].push_back(y);       adj[y].push_back(x);     }     int mx = 0;     for (i = 1; i <= n; i++) {       if (!vis1[i]) {         vec.clear();         mx = 0;         x = i;         y = i;         dfs1(i, 0, y, mx, 0);         mx = 0;         dfs1(y, 0, x, mx, 1);         dfs2(x, y);         int k = int(vec.size());         dfs3(x, vec[k / 2]);         dia[vec[k / 2]] = k - 1;       }     }     while (q--) {       scanf( %d %d , &c, &x);       if (c == 1) {         x = root(x);         printf( %d n , dia[x]);       } else {         scanf( %d , &y);         x = root(x);         y = root(y);         if (x == y) continue;         if (dia[x] >= dia[y]) {           unite(x, y);           dia[x] = max(dia[x], 1 + (dia[x] - dia[x] / 2) + (dia[y] - dia[y] / 2));         } else {           unite(y, x);           dia[y] = max(dia[y], 1 + (dia[x] - dia[x] / 2) + (dia[y] - dia[y] / 2));         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int n = 0, s = 0;     cin >> n >> s;     if (s > n) {       if (s % n != 0) {         cout << ((s / n) + 1);       } else {         cout << (s / n);       }     } else {       cout << 1;     }   }
#include <bits/stdc++.h>   using namespace std;   long long int solve(long long int a, long long int b) {     long long int x = sqrt(8 * (a + b) + 1) - 1;     return x / 2;   }   int main() {     long long int a, b;     cin >> a >> b;     long long int x = solve(a, b);     vector<long long int> w1, w2;     for (long long int i = x; i > 0; i--) {       if (a >= i) {         a -= i;         w1.push_back(i);       } else {         b -= i;         w2.push_back(i);       }     }     cout << w1.size() << endl;     for (int i = 0; i < w1.size(); i++) cout << w1[i] <<    ;     cout << endl;     cout << w2.size() << endl;     for (int i = 0; i < w2.size(); i++) cout << w2[i] <<    ;     return 0;   }