malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   const ll INF = 1e18 + 1;   const ll mod = 1e9 + 7;   vector<vector<ll> > adj;   vector<ll> desc, max_n;   ll gmnc = INF;   void print_vec(vector<ll> vec) {     for (int i = 0; i < vec.size(); ++i) {       cout << vec[i] <<    ;     }     cout << endl;   }   ll desc_cnt(ll curr, ll par) {     ll cnt = 1;     for (auto it : adj[curr]) {       if (it != par) {         cnt += desc_cnt(it, curr);       }     }     desc[curr] = cnt;     return cnt;   }   void max_neigh_cnt(ll curr, ll par) {     ll mnc = -INF;     mnc = max(mnc, desc[1] - desc[curr]);     for (auto it : adj[curr]) {       if (it != par) {         mnc = max(mnc, desc[it]);       }     }     gmnc = min(gmnc, mnc);     max_n[curr] = mnc;     for (auto it : adj[curr]) {       if (it != par) {         max_neigh_cnt(it, curr);       }     }   }   int main() {     cin.tie(0);     ios_base::sync_with_stdio(0);     ll t;     cin >> t;     while (t--) {       ll n;       cin >> n;       adj.clear();       desc.clear();       max_n.clear();       gmnc = INF;       adj.resize(n + 1);       desc.resize(n + 1);       max_n.resize(n + 1);       for (int i = 1; i <= n - 1; ++i) {         ll x, y;         cin >> x >> y;         adj[x].push_back(y);         adj[y].push_back(x);       }       desc_cnt(1, 1);       max_neigh_cnt(1, 1);       vector<ll> cn;       for (int i = 1; i <= n; ++i) {         if (max_n[i] == gmnc) {           cn.push_back(i);         }       }       pair<ll, ll> e1, e2;       if (cn.size() > 1) {         for (auto it : adj[cn[0]]) {           if (it != cn[1]) {             e1 = make_pair(cn[0], it);             e2 = make_pair(cn[1], it);             break;           }         }       } else {         e1 = make_pair(cn[0], adj[cn[0]][0]);         e2 = e1;       }       cout << e1.first <<     << e1.second << endl;       cout << e2.first <<     << e2.second << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   char s[400010];   int a[200];   vector<int> S;   vector<int> d, q;   int main() {     int n;     scanf( %d %s , &n, s);     for (int i = 0; i < n; i++) a[s[i]]++;     int p = 0;     for (int i = 0; i < 128; i++) {       if (a[i] % 2) p++, a[i]--, S.push_back(i);       if (a[i]) {         d.push_back(i);         q.push_back(a[i]);       }     }     if (p == 0) {       int cn = 0;       for (int i = 0; i < 128; i++) {         while (a[i]) s[cn++] = i, a[i] -= 2;       }       for (int i = 0; i < cn; i++) s[cn + i] = s[cn - i - 1];       s[n] =   0 ;       printf( 1 n%s n , s);     } else {       int Min = n;       for (int i = 1; i * i <= n; i++) {         if (n % i == 0) {           if (i % 2 && n / i >= p && (n / i - p) % 2 == 0) Min = min(Min, n / i);           if (n / i % 2 && i >= p && (i - p) % 2 == 0) Min = min(Min, i);         }       }       printf( %d n , Min);       int L = n / Min;       int pi = L / 2;       int now = 0;       for (int i = 0; i < Min; i++) {         int x = pi + i * L;         if (S.size() > i)           s[x] = S[i];         else {           while (!q[now]) now++;           s[x] = d[now];           S.push_back(d[now]);           S.push_back(d[now]);           q[now] -= 2;         }         for (int i = 0; i < L / 2; i++) {           while (!q[now]) now++;           s[x - i - 1] = d[now];           s[x + i + 1] = d[now];           q[now] -= 2;         }       }       for (int i = 0; i < n; i++) {         printf( %c , s[i]);         if (i % L == L - 1 && i != n - 1) printf(   );       }       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6, SZ = 800, INF = 1 << 29;   const long long LINF = (1LL << 60), mod = 1e9 + 7;   const long double eps = 1e-8, PI = acos(-1.0);   inline int dcmp(double x, double y = 0.0) { return abs(x - y) < eps; }   template <typename Type>   inline Type ru(Type &v) {     static char READ_DATA;     static int SIGNAL_INPUT = 1;     while ((READ_DATA = getchar()) <  0  || READ_DATA >  9 )       if (READ_DATA ==  - )         SIGNAL_INPUT = -1;       else if (READ_DATA == EOF)         return EOF;     v = READ_DATA -  0 ;     while ((READ_DATA = getchar()) >=  0  && READ_DATA <=  9 )       v = v * 10 + READ_DATA -  0 ;     v *= SIGNAL_INPUT;     return v;   }   template <typename A, typename B>   inline int ru(A &x, B &y) {     if (ru(x) == EOF) return EOF;     ru(y);     return 2;   }   template <typename A, typename B, typename C>   inline int ru(A &x, B &y, C &z) {     if (ru(x) == EOF) return EOF;     ru(y);     ru(z);     return 3;   }   long long gcd(long long a, long long b) {     a = abs(a);     b = abs(b);     while (b) {       a %= b;       swap(a, b);     }     return a;   }   const int maxn = 1e6 + 5;   int n, a[maxn], m, d[maxn], id[maxn];   int cmp(const int &i, const int &j) { return d[(i + 1) / 2] > d[(j + 1) / 2]; }   int main() {     ru(n);     for (int i = 1; i <= n; i++) {       ru(d[i]);     }     for (int i = 1; i < 2 * n; i += 2) {       a[++m] = i;     }     sort(a + 1, a + m + 1, cmp);     for (int i = 2; i <= m; i++) {       printf( %d %d n , a[i - 1], a[i]);     }     for (int i = 1; i <= n; i++) {       int j = (a[i] + 1) / 2;       if (i + d[j] - 1 <= m) {         printf( %d %d n , 2 * j, a[i + d[j] - 1]);         if (i + d[j] - 1 == m) {           a[++m] = 2 * j;         }       } else {         printf( %d %d n , 2 * j, a[i - d[j] + 1]);       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int t;     cin >> t;     while (t--) {       int kq = 0;       vector<pair<int, int> > res;       int n, k;       cin >> n >> k;       vector<bool> used(2 * n + 1, false);       for (int i = 1; i <= k; i++) {         int u, v;         cin >> u >> v;         res.push_back({min(u, v), max(u, v)});         used[u] = true;         used[v] = true;       }       vector<int> conlai;       for (int i = 1; i <= 2 * n; i++) {         if (!used[i]) conlai.push_back(i);       }       int len = n - k;       for (int i = 0; i < len; i++) {         res.push_back({conlai[i], conlai[i + len]});       }       for (int i = 0; i < res.size(); i++) {         for (int j = i + 1; j < res.size(); j++) {           int a = (res[j].first - res[i].first) * (res[j].second - res[i].first);           int b =               (res[j].first - res[i].second) * (res[j].second - res[i].second);           if (a * b < 0) {             kq++;           }         }       }       cout << kq << endl;     }   }
#include <bits/stdc++.h>   int main() {     long n, k, x, a, y;     scanf( %ld %ld , &n, &k);     a = n;     x = n;     while (x >= k) {       y = x % k;       x = x / k;       a = a + x;       x = x + y;     }     printf( %ld n , a);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T, typename U>   inline void smin(T &a, U b) {     if (a > b) a = b;   }   template <typename T, typename U>   inline void smax(T &a, U b) {     if (a < b) a = b;   }   int power(int a, int b, int m, int ans = 1) {     for (; b; b >>= 1, a = 1LL * a * a % m)       if (b & 1) ans = 1LL * ans * a % m;     return ans;   }   const int maxn = 110;   int a[maxn];   int arr[maxn * maxn];   int cat[maxn * maxn][maxn];   map<set<int>, int> mp;   int top;   int recure(set<int> s) {     if (s.empty()) return 0;     if (mp.count(s)) return mp[s];     int d = *(--s.end());     int vis[maxn];     memset(vis, 0, sizeof(vis));     for (int i = 1; i <= d; i++) {       set<int> res;       for (set<int>::iterator it = s.begin(); it != s.end(); it++) {         if (*it < i)           res.insert(*it);         else if (*it > i)           res.insert(*it - i);       }       vis[recure(res)] = 1;     }     int g;     for (int i = 0; i < maxn; i++)       if (!vis[i]) {         g = i;         break;       }     mp[s] = g;     return g;   }   int main() {     int n, Num = 0;     cin >> n;     for (int i = 0; i < n; i++) scanf( %d , &a[i]);     for (int i = 0; i < n; i++) {       long long num = 1ll * a[i];       for (int j = 2; 1ll * j * j <= num; j++) {         if (num % j) continue;         while (num % j == 0) num /= j;         arr[Num++] = j;       }       if (num > 1) {         arr[Num++] = (int)num;       }     }     sort(arr, arr + Num);     Num = unique(arr, arr + Num) - arr;     for (int i = 0; i < n; i++) {       long long num = 1ll * a[i];       for (int j = 2; 1ll * j * j <= num; j++) {         if (num % j) continue;         int cnt = 0;         while (num % j == 0) num /= j, cnt++;         int t = lower_bound(arr, arr + Num, j) - arr;         cat[t][cnt] = 1;       }       if (num > 1) {         int t = lower_bound(arr, arr + Num, (int)num) - arr;         cat[t][1] = 1;       }     }     int ok = 0;     for (int i = 0; i < Num; i++) {       set<int> res;       res.clear();       for (int j = 1; j < maxn; j++) {         if (cat[i][j]) res.insert(j);       }       ok ^= recure(res);     }     if (ok)       puts( Mojtaba );     else       puts( Arpa );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 505;   int n, now, siz[N], f[N];   bool vis[N];   vector<int> g, ans[N];   inline bool cmp(int x, int y) { return siz[x] < siz[y]; }   void divide(int l, int r) {     if (l > r) return;     cout << 1 << endl << 1 << endl << r - l + 1 << endl;     for (int i = l; i <= r; ++i) cout << g[i] <<    ;     cout << endl << now << endl;     int x, mid = (l + r) >> 1;     cin >> x;     if (!x) return;     if (l == r) return vis[g[l]] = 1, ans[now].push_back(g[l]);     divide(l, mid), divide(mid + 1, r);   }   int main() {     cin >> n, siz[1] = n;     for (int i = 2; i <= n; ++i) {       cout << 1 << endl << 1 << endl << n - 1 << endl;       for (int j = 2; j <= n; ++j) cout << j <<    ;       cout << endl << i << endl;       cin >> siz[i];     }     for (int i = 1; i <= n; ++i) f[i] = i;     sort(f + 1, f + n + 1, cmp);     for (int i = 1; i <= n; ++i) {       now = f[i];       divide(0, g.size() - 1);       for (unsigned i = 0; i < g.size(); ++i)         if (vis[g[i]]) g.erase(g.begin() + i--);       g.push_back(now);     }     cout <<  ANSWER  << endl;     for (int i = 1; i <= n; ++i)       for (int j : ans[i]) cout << i <<     << j << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, k;   long long c[100006], freq[100006], people[100006], h[100006];   long long catche[5005][505];   long long dp(long long left, long long pep) {     if (left == 0 || pep == 0) return 0;     long long &ans = catche[left][pep];     if (ans != -1) return ans;     ans = 0;     for (long long j = 1; j <= min(left, k); j++) {       ans = max(ans, h[j] + dp(left - j, pep - 1));     }     return ans;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cin >> n >> k;     long long ans = 0;     long long i, j;     for (i = 1; i <= (n * k); i++) {       long long x;       cin >> x;       freq[x]++;     }     for (i = 1; i <= n; i++) {       long long x;       cin >> x;       people[x]++;     }     for (i = 1; i <= k; i++) {       cin >> h[i];     }     for (i = 1; i <= 100005; i++) {       if (!people[i]) {         continue;       }       for (j = 0; j <= freq[i]; j++) {         for (long long kk = 0; kk <= people[i]; kk++) {           catche[j][kk] = -1;         }       }       ans += dp(freq[i], people[i]);     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const long long int N = 100005;   void solve() {     long long int m, n;     cin >> n >> m;     long long int count = 0;     for (long long int i = 1; i <= n; i++) {       count += (m + i % 5) / 5;     }     cout << count << endl;     return;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   bool uin(T &a, T b) {     if (a > b) {       a = b;       return true;     }     return false;   }   template <class T>   bool uax(T &a, T b) {     if (a < b) {       a = b;       return true;     }     return false;   }   const int MAXN = 1100000;   vector<int> lft[MAXN], rgt[MAXN];   int leftf[MAXN], anyf[MAXN];   int lc[MAXN], rc[MAXN];   char s[10];   struct TNode {     int left, right;     int L, R;     int maxk;     TNode(int L = -1, int R = -1) : left(-1), right(-1), L(L), R(R), maxk(-1e9) {}   };   const int MAXT = 2100000;   TNode t[MAXT];   int tc = 0;   int buildTree(int L, int R) {     int node = tc++;     t[node] = TNode(L, R);     if (R - L == 1) return node;     int M = (L + R) / 2;     t[node].left = buildTree(L, M);     t[node].right = buildTree(M, R);     return node;   }   int getMax(int node, int L, int R) {     if (max(L, t[node].L) >= min(R, t[node].R)) return -1e9;     if (L <= t[node].L && t[node].R <= R) return t[node].maxk;     return max(getMax(t[node].left, L, R), getMax(t[node].right, L, R));   }   void setMax(int node, int i, int x) {     if (i >= t[node].R || i < t[node].L) return;     if (i == t[node].L && i + 1 == t[node].R) {       t[node].maxk = x;       return;     }     setMax(t[node].left, i, x);     setMax(t[node].right, i, x);     t[node].maxk = max(t[t[node].left].maxk, t[t[node].right].maxk);   }   bool buildAns(int l, int r) {     if (anyf[l] > r) return false;     for (int x : rgt[l]) {       if (x <= leftf[l]) return false;     }     if (leftf[l] == l) {       lc[l] = -1;       if (r == l) return true;       rc[l] = l + 1;       return buildAns(l + 1, r);     }     lc[l] = l + 1;     if (!buildAns(lc[l], leftf[l])) return false;     if (leftf[l] == r) return true;     rc[l] = leftf[l] + 1;     return buildAns(rc[l], r);   }   void print(int v) {     if (v == -1) return;     print(lc[v]);     printf( %d  , v + 1);     print(rc[v]);   }   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     cout.precision(10);     cout << fixed;     int N, C;     scanf( %d%d , &N, &C);     bool ok = true;     int root = buildTree(0, N);     for (int i = 0; i < (int)(C); ++i) {       int x, y;       scanf( %d%d%s , &x, &y, s);       --x;       --y;       ok &= x < y;       if (s[0] ==  L )         lft[x].push_back(y);       else         rgt[x].push_back(y);     }     if (!ok) {       cout <<  IMPOSSIBLE n ;       return 0;     }     for (int i = (int)(N)-1; i >= 0; --i) {       leftf[i] = anyf[i] = i;       for (int x : lft[i]) {         uax(leftf[i], getMax(root, i, x + 1));       }       for (int x : rgt[i]) {         uax(anyf[i], getMax(root, i, x + 1));       }       uax(anyf[i], leftf[i]);       setMax(root, i, anyf[i]);     }     for (int i = 0; i < (int)(N); ++i) lc[i] = rc[i] = -1;     if (!buildAns(0, N - 1)) {       cout <<  IMPOSSIBLE n ;       return 0;     }     print(0);     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int cnt[15];   string a[100009];   const long long mod = 998244353LL;   int main() {     int i, len1, len2, n, j;     long long p, sum, val;     cin >> n;     for (i = 1; i <= n; i++) {       cin >> a[i];       reverse(a[i].begin(), a[i].end());       cnt[a[i].size()]++;     }     for (i = 1, val = 0; i <= n; i++) {       len2 = a[i].size();       for (len1 = 1; len1 <= 10; len1++) {         sum = 0;         if (len1 < len2) {           for (j = 0, p = 1; j < len1; j++) {             sum += p * (a[i][j] - 48);             p = (p * 10LL) % mod;             sum += p * (a[i][j] - 48);             p = (p * 10LL) % mod;           }           for (j = len1; j < len2; j++) {             sum += p * (a[i][j] - 48);             sum += p * (a[i][j] - 48);             p = (p * 10LL) % mod;           }         } else {           for (j = 0, p = 1; j < len2; j++) {             sum += p * (a[i][j] - 48);             p = (p * 10LL) % mod;             sum += p * (a[i][j] - 48);             p = (p * 10LL) % mod;           }         }         val += (sum % mod) * cnt[len1];         val %= mod;       }     }     cout << val <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T, size_t N>   int SIZE(const T (&t)[N]) {     return N;   }   template <typename T>   int SIZE(const T(&t)) {     return t.size();   }   string to_string(char b) { return     + string({b}) +    ; }   string to_string(bool b) { return (b ?  true  :  false ); }   string to_string(const string &t, int x1 = 0, int x2 = 1e9) {     string ret =   ;     for (int i = min(x1, SIZE(t)), _i = min(x2, SIZE(t) - 1); i <= _i; ++i) {       ret += t[i];     }     return     + ret +    ;   }   string to_string(const char *t) {     string ret(t);     return to_string(ret);   }   template <size_t N>   string to_string(const bitset<N> &t, int x1 = 0, int x2 = 1e9) {     string ret =   ;     for (int i = min(x1, SIZE(t)), _i = min(x2, SIZE(t) - 1); i <= _i; ++i) {       ret += t[i] +  0 ;     }     return     + ret +    ;   }   template <typename T, typename... Coords>   string to_string(const T(&t), int x1 = 0, int x2 = 1e9, Coords... C);   template <typename T, typename S>   string to_string(const pair<T, S>(&t)) {     return  (  + to_string(t.first) +  ,   + to_string(t.second) +  ) ;   }   template <typename T, typename... Coords>   string to_string(const T(&t), int x1, int x2, Coords... C) {     string ret =  [ ;     x1 = min(x1, SIZE(t));     auto e = begin(t);     advance(e, x1);     for (int i = x1, _i = min(x2, SIZE(t) - 1); i <= _i; ++i) {       ret += (i != x1 ?  ,   :   ) + to_string(*e, C...);       e = next(e);     }     return ret +  ] ;   }   void dbgm() { ; }   template <typename T, typename... S>   void dbgm(T t, S... s) {     cout << to_string(t) <<   |  ;     dbgm(s...);   }   void dbgs() { ; }   template <typename T, typename... S>   void dbgs(T t, S... s) {     cout << t <<    ;     dbgs(s...);   }   const long long N = 2e5 + 3, M = 1e9 + 7;   int v[N], h[N];   int main() {     int n, m;     cin >> n >> m;     for (int i = 1, _i = n; i <= _i; ++i) {       int x;       cin >> x;       v[i] = x;     }     sort(v + 1, v + 1 + n);     int pt = 0, hans = 0;     for (int i = 1, _i = m; i <= _i; ++i) {       int x1, x2, y;       cin >> x1 >> x2 >> y;       if (x1 == 1) {         if (x2 == 1e9) {           hans++;         } else {           h[++pt] = x2;         }       }     }     m = pt;     sort(h + 1, h + 1 + m, greater<int>());     int j = n;     int ans = 1e9;     for (int i = 1, _i = m + 1; i <= _i; ++i) {       while (v[j] > h[i]) {         --j;       }       ans = min(ans, j + max(i - 1, 0));     }     dbgs(ans + hans);   }
#include <bits/stdc++.h>   using namespace std;   ifstream fin( fisier.in );   ofstream fout( fisier.out );   int v[1000000], minl[1000000], minr[1000000];   int main() {     int n, i;     cin >> n;     for (i = 1; i <= n; ++i) cin >> v[i];     for (i = 1; i <= n; ++i) minl[i] = min(minl[i - 1] + 1, v[i]);     for (i = n; i >= 1; --i) minr[i] = min(minr[i + 1] + 1, v[i]);     int res = 0;     for (i = 1; i <= n; ++i) res = max(res, min(minr[i], minl[i]));     cout << res;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long dx[] = {1, 0, -1, 0};   long long dy[] = {0, 1, 0, -1};   long long gcd(long long x, long long y) {     if (y == 0)       return x;     else       return gcd(y, x % y);   }   long long expo(long long n, long long m, long long p) {     long long r = 1;     n = n % p;     while (m > 0) {       if (m % 2) r = (r * n) % p;       n = (n * n) % p;       m = m / 2;     }     return r % p;   }   bool isPrime(long long n) {     if (n <= 1) return false;     if (n <= 3) return true;     if (n % 2 == 0 || n % 3 == 0) return false;     for (long long i = 5; i * i <= n; i = i + 6)       if (n % i == 0 || n % (i + 2) == 0) return false;     return true;   }   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     long long t;     cin >> t;     long long tc = 1;     while (t--) {       long long n;       cin >> n;       if (n == 1) {         cout <<  1337  <<   n ;       } else if (n == 2) {         cout <<  11337  <<   n ;       } else if (n == 3) {         cout <<  111337  <<   n ;       } else {         long long m;         for (long long i = 1; i <= n; i++) {           long long x = (i * (i - 1)) / 2;           if (x > n) {             m = i - 1;             break;           }         }         long long r = n - (m * (m - 1)) / 2;         string ans;         ans.push_back( 1 );         ans.push_back( 3 );         ans.push_back( 3 );         while (r) {           ans.push_back( 7 );           r--;         }         m -= 2;         while (m) {           ans.push_back( 3 );           m--;         }         ans.push_back( 7 );         cout << ans <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int n, m, x, y, z, k, w, ans;   int A[400], B[400];   char c[2];   int main() {     scanf( %d , &n);     for (int i = (0); i < (n); i++) {       scanf( %s%d%d , &c, &x, &y);       if (c[0] ==  M ) {         for (int j = (x); j <= (y); j++) A[j]++;       } else {         for (int j = (x); j <= (y); j++) B[j]++;       }     }     for (int i = (1); i <= (366); i++) ans = max(ans, min(A[i], B[i]));     printf( %d n , ans * 2);     return 0;   }
// author: xay5421   // created: Mon May  3 17:34:21 2021   #include<bits/stdc++.h>   #define rep(i,a,b) for(int i=(a);i<=(b);++i)   #define per(i,a,b) for(int i=(a);i>=(b);--i)   using namespace std;   typedef long long LL;   const LL INFLL=0X3F3F3F3F3F3F3F3FLL;   const int N=200005;   int n,Q,_w[N],_v[N],id[N],_id[N];   LL _a[N],sw0[N*4][18],sv0[N*4][18],sw1[N*4][18];   void bud(int k1,int k2,int k3,int k4,int k5){    if(k2>k5||k3<k4)return;    if(k2==k3){     rep(k,1,17){      if(_w[id[k2]]<(1<<k)){       sw0[k1][k]=_a[id[k2]]*_w[id[k2]];       sv0[k1][k]=_a[id[k2]]*_v[id[k2]];      }      sw1[k1][k]=INFLL;      if(_w[id[k2]]>=(1<<(k-1))&&_w[id[k2]]<(1<<k)&&_a[id[k2]]){       sw1[k1][k]=_w[id[k2]];      }     }     return;    }    int mid=(k2+k3)>>1;    bud(k1*2,k2,mid,k4,k5),bud(k1*2+1,mid+1,k3,k4,k5);    rep(k,1,17){     sw0[k1][k]=sw0[k1*2][k]+sw0[k1*2+1][k];     sv0[k1][k]=sv0[k1*2][k]+sv0[k1*2+1][k];     if(sw1[k1*2][k]<sw0[k1*2][k-1]+sw1[k1*2+1][k]){      sw1[k1][k]=sw1[k1*2][k];     }else{      sw1[k1][k]=sw0[k1*2][k-1]+sw1[k1*2+1][k];     }    }   }   void add(int x,int y){    _a[x]+=y;    bud(1,1,n,_id[x],_id[x]);   }   LL rem,vv; int _k;   void clip(){    while(_k>0&&(1<<(_k-1))>rem)--_k;   }   void qry(int k1,int k2,int k3){    if(k2==k3){     LL tt=min(_a[id[k2]],rem/_w[id[k2]]);     rem-=tt*_w[id[k2]];     vv+=tt*_v[id[k2]];     return;    }    int mid=(k2+k3)>>1;    clip();    if(sw0[k1][_k]<=rem){     rem-=sw0[k1][_k];     vv+=sv0[k1][_k];     return;    }    if(sw1[k1][_k]>rem&&sw0[k1][_k-1]<=rem){     rem-=sw0[k1][_k-1];     vv+=sv0[k1][_k-1];     return;    }    qry(k1*2,k2,mid);    clip();    qry(k1*2+1,mid+1,k3);   }   void sol(LL x){    _k=17,rem=x,vv=0;    clip();    qry(1,1,n);    printf( %lld n ,vv);   }   int main(){   #ifdef xay5421    freopen( a.in , r ,stdin);   #endif    scanf( %d%d ,&n,&Q);    rep(i,1,n){     scanf( %lld%d%d ,&_a[i],&_w[i],&_v[i]);     id[i]=i;    }    sort(id+1,id+1+n,[&](int x,int y){return _v[x]^_v[y]?_v[x]>_v[y]:_w[x]<_w[y];});    rep(i,1,n)_id[id[i]]=i;    bud(1,1,n,1,n);    while(Q--){     int t;     scanf( %d ,&t);     if(t==1){      int x,y;      scanf( %d%d ,&x,&y);      add(y,x);     }else if(t==2){      int x,y;      scanf( %d%d ,&x,&y);      add(y,-x);     }else{      LL x;      scanf( %lld ,&x);      sol(x);     }    }    return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double EPS = 1e-10;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int ax, ay, bx, by, cx, cy;     cin >> ax >> ay >> bx >> by >> cx >> cy;     complex<long double> a(ax, ay), b(bx, by), c(cx, cy);     long double d1 = abs(b - a), d2 = abs(c - b);     long double ang1 = arg(b - a), ang2 = arg(c - b);     cout << ((abs(d1 - d2) < EPS && abs(ang1 - ang2) > EPS) ?  Yes  :  No )          << endl;   }