malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int64_t Nmax = 2e5 + 10;   const int64_t mod = 1000000007;   vector<int64_t> prime;   int64_t is_power_of_two(int64_t a) { return a && (!(a & (a - 1))); }   int64_t isperfectsquare(int64_t a) {     double b = sqrt(a);     return (b - ceil(b) == 0);   }   int64_t pow(int64_t a, int64_t b, int64_t m) {     a = a % m;     int64_t res = 1;     while (b > 0) {       if (b & 1) {         res = res * a % m;       }       a = a * a % m;       b = b / 2;     }     return res;   }   int64_t mod_add(int64_t a, int64_t b, int64_t m) {     a = a % m;     b = b % m;     return (((a + b) % m) + m) % m;   }   int64_t mod_mul(int64_t a, int64_t b, int64_t m) {     a = a % m;     b = b % m;     return (((a * b) % m) + m) % m;   }   int64_t mod_sub(int64_t a, int64_t b, int64_t m) {     a = a % m;     b = b % m;     return (((a - b) % m) + m) % m;   }   int64_t mod_div(int64_t a, int64_t b, int64_t m) {     a = a % m;     b = b % m;     return (mod_mul(a, pow(b, m - 2, m), m));   }   void sieve(int64_t n) {     bool isprime[n + 1];     memset(isprime, true, sizeof(isprime));     prime.push_back(2);     for (int64_t i = 3; i <= sqrt(n); i += 2) {       if (isprime[i]) {         for (int64_t j = i * i; j <= n; j += i) {           isprime[j] = false;         }       }     }     for (int64_t i = 3; i <= n; i += 2) {       if (isprime[i]) {         prime.push_back(i);       }     }   }   vector<pair<int64_t, int64_t>> Getprimefactors(int64_t n) {     vector<pair<int64_t, int64_t>> pr;     for (int64_t i = 2; i <= sqrt(n); i++) {       int64_t cnt = 0;       while (n % i == 0) {         cnt++;         n /= i;       }       if (cnt) pr.push_back({i, cnt});     }     if (n > 1) {       pr.push_back({n, 1});     }     return pr;   }   void solve() {     int64_t n, k, ans = INT_MAX;     cin >> n >> k;     string s;     cin >> s;     char rgb[] = { R ,  G ,  B };     for (int64_t i = 0; i <= n - k; i++) {       string tmp = s.substr(i, k);       int64_t val1 = 0, val2 = 0, val3 = 0;       for (int64_t j = 0; j <= k - 1; j++) {         if (tmp[j] != rgb[(j) % 3]) val1++;         if (tmp[j] != rgb[(j + 1) % 3]) val2++;         if (tmp[j] != rgb[(j + 2) % 3]) val3++;       }       ans = min({val1, val2, val3, ans});     }     cout << ans <<   n ;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int64_t t = 1;     cin >> t;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int Maxn = 1e5 + 2;   const int Nn = 251;   char s[Maxn];   int a[Maxn][26], f[Nn][Nn][Nn], length[3], i, j, k, l, Min, n, m, id, p;   char ss[3][Nn], op, c, sss[Nn];   void done() {     for (int i = 0; i < 26; i++) {       a[n][i] = n + 1;       a[n + 1][i] = n + 1;     }     for (int i = n - 1; i >= 0; i--) {       for (int j = 0; j < 26; j++) a[i][j] = a[i + 1][j];       a[i][s[i] -  a ] = i + 1;     }     f[0][0][0] = 0;   }   int pos(int i, int j, int k, char c) { return a[f[i][j][k]][c -  a ]; }   void func(int i, int j, int k) {     f[i][j][k] = n + 2;     if (i > 0) {       Min = pos(i - 1, j, k, ss[0][i]);       if (Min < f[i][j][k]) f[i][j][k] = Min;     }     if (j > 0) {       Min = pos(i, j - 1, k, ss[1][j]);       if (Min < f[i][j][k]) f[i][j][k] = Min;     }     if (k > 0) {       Min = pos(i, j, k - 1, ss[2][k]);       if (Min < f[i][j][k]) f[i][j][k] = Min;     }   }   int main() {     scanf( %d%d , &n, &m);     scanf( %s n , s);     done();     for (l = 0; l < m; l++) {       scanf( %c , &op);       switch (op) {         case  + :           scanf( %d %c , &id, &c);           gets(sss);           id %= 3;           ++length[id];           ss[id][length[id]] = c;           if (id == 0) {             for (j = 0; j <= length[1]; j++)               for (k = 0; k <= length[2]; k++) func(length[id], j, k);           }           if (id == 1) {             for (i = 0; i <= length[0]; i++)               for (k = 0; k <= length[2]; k++) func(i, length[id], k);           }           if (id == 2) {             for (i = 0; i <= length[0]; i++)               for (j = 0; j <= length[1]; j++) func(i, j, length[id]);           }           break;         case  - :           scanf(  %d , &id);           gets(sss);           id %= 3;           --length[id];           break;       }       p = f[length[0]][length[1]][length[2]];       if (p <= n)         printf( YES n );       else         printf( NO n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> graph[100001];   int color[100001];   vector<int> b, w;   void bfs(int v) {     queue<int> q;     q.push(v);     color[v] = 1;     b.push_back(v);     while (!q.empty()) {       int v = q.front();       q.pop();       for (int u : graph[v]) {         if (color[u] == 0) {           if (color[v] == 1)             color[u] = 2, w.push_back(u);           else             color[u] = 1, b.push_back(u);           q.push(u);         }         if (color[v] == color[u]) {           printf( -1 );           exit(0);         }       }     }   }   int main() {     int n, m;     scanf( %d %d , &n, &m);     while (m--) {       int a, b;       scanf( %d %d , &a, &b);       graph[a].push_back(b);       graph[b].push_back(a);     }     for (int i = 1; i <= n; i++)       if (color[i] == 0) bfs(i);     printf( %d n , (int)b.size());     for (int i = 0; i < b.size(); i++) printf( %d  , b[i]);     printf(  n%d n , (int)w.size());     for (int i : w) printf( %d  , i);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using vi = vector<int>;   using vvi = vector<vi>;   using ii = pair<int, int>;   double x[60000], v[60000];   int n;   bool f(double t) {     vector<tuple<double, int> > a;     for (int i = 0; i < n; ++i) {       a.emplace_back(x[i] - v[i] * t, 0);       a.emplace_back(x[i] + v[i] * t + 1e-7, 1);     }     sort(a.begin(), a.end());     int m = 0;     for (int i = 0; i < n; ++i) {       auto [x, e] = a[i];       if (e == 0)         m++;       else         m--;       if (m == n) return true;     }     return false;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> n;     for (int i = 0; i < n; ++i) cin >> x[i];     for (int i = 0; i < n; ++i) cin >> v[i];     double lo = 0, hi = 1e9;     while (hi - lo > 1e-7) {       double mid = (hi + lo) / 2;       if (f(mid))         hi = mid;       else         lo = mid;     }     cout << setprecision(15) << fixed << lo;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const long long LINF = 0x3f3f3f3f3f3f3f3fll;   vector<int> a;   vector<int> b;   vector<int> c;   vector<vector<int> > g;   int n, m, k;   int dp[5005][5005];   int solve(int at, int homens) {     if (at == n) {       return 0;     }     if (dp[at][homens] != -1) {       return dp[at][homens];     }     if (a[at] > homens) {       return dp[at][homens] = -INF;     }     int novoHomens = homens + b[at];     int resposta = solve(at + 1, novoHomens);     int valor = 0;     int quant = 0;     for (int viz : g[at]) {       quant++;       valor += viz;       if (novoHomens - quant >= 0) {         resposta = max(resposta, valor + solve(at + 1, novoHomens - quant));       }     }     return dp[at][homens] = resposta;   }   bool comp(int a, int b) { return c[a] > c[b]; }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n >> m >> k;     a.resize(n);     b.resize(n);     c.resize(n);     for (int I = 0; I < n; I++) {       cin >> a[I] >> b[I] >> c[I];     }     g.resize(n);     int x, y;     vector<int> conexoes(n);     for (int I = 0; I < n; I++) {       conexoes[I] = I;     }     for (int I = 0; I < m; I++) {       cin >> x >> y;       x--;       y--;       conexoes[y] = max(conexoes[y], x);     }     for (int I = 0; I < n; I++) {       g[conexoes[I]].push_back(c[I]);     }     for (int I = 0; I < n; I++) {       sort(g[I].rbegin(), g[I].rend());     }     memset(dp, -1, sizeof(dp));     int resposta = solve(0, k);     if (resposta < 0) {       cout << -1 <<   n ;     } else {       cout << resposta <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename Arg1>   void __f(const char* name, Arg1&& arg1) {     cerr << name <<   :   << arg1 <<   n ;   }   template <typename Arg1, typename... Args>   void __f(const char* names, Arg1&& arg1, Args&&... args) {     const char* comma = strchr(names + 1,  , );     cerr.write(names, comma - names) <<   :   << arg1 <<   |  ;     __f(comma + 1, args...);   }   template <typename T>   using minpq = priority_queue<T, vector<T>, greater<T>>;   template <typename T>   using maxpq = priority_queue<T>;   inline long long CC(long long n, long long y) {     return (((n) + (y - 1) - 1) / (y - 1)) - (((n) + (y)-1) / (y));   }   inline long long FF(long long n, long long y) { return n / y - n / (y + 1); }   inline long long __gcd(long long a, long long b) {     return !b ? a : __gcd(b, a % b);   }   inline int add(int a, int b, int p = 1000000007) {     int c = a + b;     if (c >= p) c -= p;     return c;   }   inline int sub(int a, int b, int p = 1000000007) {     int c = a - b;     if (c < 0) c += p;     return c;   }   inline int mul(int a, int b, int p = 1000000007) { return (a * 1ll * b) % p; }   long long a, b, k, L;   long long lcm(long long a, long long b) { return a / __gcd(a, b) * b; }   long long bfs(long long src, long long dest) {     __f( src, dest , src, dest);     queue<long long> q;     vector<bool> vis(src - dest + 1);     q.push(src);     q.push(0);     vis[src - dest] = 1;     while (1) {       long long u = q.front();       q.pop();       long long d = q.front();       q.pop();       if (u == dest) return d;       if (!vis[u - 1 - dest]) q.push(u - 1), q.push(d + 1);       for (long long i = 2; i <= k; i++) {         long long v = u / i * i;         if (v >= dest && !vis[v - dest]) {           vis[v - dest] = 1;           q.push(v);           q.push(d + 1);         }       }     }   }   int32_t main() {     ios_base::sync_with_stdio(false), cin.tie(NULL);     clock_t clk = clock();     cerr <<  I will return... n ;     cin >> a >> b >> k;     if (k == 2) {       cout << a - b;       return 0;     }     L = 1;     for (long long i = (2); i < (k + 1); i++) L = lcm(L, i);     long long ans = 0;     long long cnt = a / L - (b - 1) / L;     __f( L, cnt , L, cnt);     if (cnt) {       long long m = bfs(L, 0);       ans = m * (cnt - 1);       __f( ans , ans);     }     if (!cnt) {       ans += bfs(a, b);       __f( ans , ans);     } else {       ans += bfs(a, a / L * L);       ans += bfs((((b) + (L)-1) / (L)) * L, b);       __f( ans , ans);     }     cout << ans <<   n ;     cerr <<  ...don t you ever hang your head. n ;     cerr <<  Time (in ms):   << double(clock() - clk) * 1000.0 / CLOCKS_PER_SEC          <<   n ;   }
#include <bits/stdc++.h>   int main() {     int n;     while (std::cin >> n) {       if (n % 2 == 0) {         std::cout << -1 << std::endl;         continue;       }       std::vector<int> a(n), b(n), c(n), was(n);       for (int i = 0; i < n; ++i) {         a[i] = i;         b[i] = (i + 1) % n;         c[i] = (a[i] + b[i]) % n;         assert(!was[c[i]]);         was[c[i]] = 1;       }       for (auto it : a) {         std::cout << it <<    ;       }       std::cout << std::endl;       for (auto it : b) {         std::cout << it <<    ;       }       std::cout << std::endl;       for (auto it : c) {         std::cout << it <<    ;       }       std::cout << std::endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int pr[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};   const int m = 16;   const int INF = 1e9;   int n, d[110], por[110], vv[110], opr[110];   int f[110][65560], to[110][65560], pi[110][65560];   void init() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &d[i]);     for (int i = 1; i < 59; i++) {       for (int j = 0; j < m; j++)         if (!(i % pr[j])) opr[i] |= (1 << j);     }     for (int i = 0; i <= n; i++)       for (int j = 0; j <= 65536; j++) f[i][j] = INF;   }   int main() {     init();     f[0][0] = 0;     for (int i = 1; i <= n; i++) {       for (int k = 0; k < (1 << m); k++)         if (f[i - 1][k] != INF) {           for (int j = 1; j < 59; j++) {             if (!(k & opr[j]) && f[i][k | opr[j]] > f[i - 1][k] + abs(d[i] - j)) {               f[i][k | opr[j]] = f[i - 1][k] + abs(d[i] - j);               to[i][k | opr[j]] = k;               pi[i][k | opr[j]] = j;             }           }         }     }     int ss = INF, yu = 0;     for (int i = 0; i < (1 << m); i++)       if (ss > f[n][i]) ss = f[n][i], yu = i;     for (int i = yu, c = n; c > 0; i = to[c][i], c--) vv[c] = pi[c][i];     for (int i = 1; i <= n; i++) printf( %d  , vv[i]);     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int gridSize = 1000;   long long getPairs(int n) {     long long result = 0;     for (int i = 1; i < n; i++) result += n - i;     return result;   }   int main() {     std::cout.sync_with_stdio(false);     int n, i, x, y, j;     cin >> n;     bool a[gridSize + 1][gridSize + 1];     for (i = 1; i <= gridSize; i++)       for (j = 1; j <= gridSize; j++) a[i][j] = false;     for (i = 0; i < n; i++) {       cin >> x >> y;       a[x][y] = true;     }     long long result = 0, attacking = 0;     pair<int, int> startPoint(1, 1);     for (i = 1; i <= gridSize; i++) {       attacking = 0;       startPoint = make_pair(1, i);       do {         if (a[startPoint.first][startPoint.second]) attacking++;         startPoint.second++;         startPoint.first++;       } while (startPoint.second <= gridSize && startPoint.first <= gridSize);       if (attacking > 1) result += getPairs(attacking);     }     for (i = 2; i <= gridSize; i++) {       attacking = 0;       startPoint = make_pair(i, 1);       do {         if (a[startPoint.first][startPoint.second]) attacking++;         startPoint.second++;         startPoint.first++;       } while (startPoint.second <= gridSize && startPoint.first <= gridSize);       if (attacking > 1) result += getPairs(attacking);     }     for (i = gridSize; i >= 1; i--) {       attacking = 0;       startPoint = make_pair(1, i);       do {         if (a[startPoint.first][startPoint.second]) attacking++;         startPoint.second--;         startPoint.first++;       } while (startPoint.second >= 1 && startPoint.first <= gridSize);       if (attacking > 1) result += getPairs(attacking);     }     for (i = 2; i <= gridSize; i++) {       attacking = 0;       startPoint = make_pair(i, gridSize);       do {         if (a[startPoint.first][startPoint.second]) attacking++;         startPoint.second--;         startPoint.first++;       } while (startPoint.second >= 1 && startPoint.first <= gridSize);       if (attacking > 1) result += getPairs(attacking);     }     cout << result;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<int> vt;     for (int i = 0; i < n; i++) {       int v;       cin >> v;       vt.push_back(v);     }     sort(vt.begin(), vt.end());     int ans = 0;     int prev = vt[0];     for (int i = 1; i < n; i++) {       int cur = vt[i];       int diff = cur - prev;       if (diff > 1) {         ans += (diff - 1);       }       prev = cur;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     static int n;     static int a[300010], b[300010];     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d%d , &a[i], &b[i]);     int cnt[2] = {};     for (int i = 1; i <= n; i++) {       if (a[i] < b[i])         cnt[0]++;       else         cnt[1]++;     }     if (cnt[0] > cnt[1]) {       vector<pair<int, int> > vec;       for (int i = 1; i <= n; i++) {         if (a[i] < b[i]) vec.push_back(pair<int, int>(-a[i], i));       }       sort(vec.begin(), vec.end());       printf( %d n , cnt[0]);       for (int i = 0; i < vec.size(); i++) {         printf( %d%c , vec[i].second, (i + 1 == vec.size()) ?   n  :    );       }     } else {       vector<pair<int, int> > vec;       for (int i = 1; i <= n; i++) {         if (a[i] > b[i]) vec.push_back(pair<int, int>(b[i], i));       }       sort(vec.begin(), vec.end());       printf( %d n , cnt[1]);       for (int i = 0; i < vec.size(); i++) {         printf( %d%c , vec[i].second, (i + 1 == vec.size()) ?   n  :    );       }     }   }
#include <bits/stdc++.h>   using namespace std;   char s[10000];   int num[100];   int main() {     int T, t, i, j, k, n, m = 0, len;     scanf( %s , &s);     len = strlen(s);     for (i = 0; i < len; i++) {       k = s[i] -  a  + 1;       num[k]++;     }     for (i = 1; i <= 26; i++)       if (num[i] % 2 == 1) m++;     if (m == 0 || m == 1)       printf( First n );     else if (m % 2 == 0)       printf( Second n );     else       printf( First n );   }
#include <bits/stdc++.h>   using namespace std;   bool ask(long long l, long long r) {     cout << l <<     << r <<   n ;     cout.flush();     string res;     cin >> res;     return res ==  Yes ;   }   int main() {     srand(time(NULL));     ios_base::sync_with_stdio(false);     long long n, k;     cin >> n >> k;     long long l = 1, r = n;     while (true) {       if (r - l > 60ll) {         long long mid = l + r >> 1;         if (ask(l, mid)) {           l = max(1ll, l - k);           r = min(mid + k, n);         } else {           l = max(mid + 1 - k, 1ll);           r = min(r + k, n);         }       } else {         long long mid = rand() % (r - l + 1) + l;         if (ask(mid, mid)) return 0;         l = max(l - k, 1ll);         r = min(r + k, n);       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int INF = INT_MAX;   const long long LINF = LLONG_MAX;   const unsigned long long ULINF = ULLONG_MAX;   const double EPS = 0.000001;   char v[150][150], v_new[150][150];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int w, h;     cin >> w >> h;     for (int i = 0; i < h; i++)       for (int j = 0; j < w; j++) cin >> v[i][j];     for (int i = 0; i < h; i++)       for (int j = 0; j < w; j++) v_new[j][i] = v[i][j];     for (int i = 0; i < w; i++) {       for (int j = 0; j < h; j++) {         cout << v_new[i][j];         cout << v_new[i][j];       }       cout <<   n ;       for (int j = 0; j < h; j++) {         cout << v_new[i][j];         cout << v_new[i][j];       }       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct {     int begin, end;   } P1[60], P2[60];   int main() {     int num1, num2, first, last;     scanf( %d %d %d %d , &num1, &num2, &first, &last);     int ans = 0;     for (int i = 1; i <= num1; i++) scanf( %d %d , &P1[i].begin, &P1[i].end);     for (int i = 1; i <= num2; i++) scanf( %d %d , &P2[i].begin, &P2[i].end);     for (int i = first; i <= last; i++) {       for (int j1 = 1; j1 <= num1; j1++) {         bool flag = 1;         for (int j2 = 1; j2 <= num2; j2++) {           if ((P2[j2].begin + i >= P1[j1].begin &&                P2[j2].begin + i <= P1[j1].end) ||               (P2[j2].end + i >= P1[j1].begin && P2[j2].end + i <= P1[j1].end) ||               (P2[j2].begin + i <= P1[j1].begin &&                P2[j2].end + i >= P1[j1].end)) {             ans++;             flag = 0;             break;           }         }         if (!flag) break;       }     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   void dbs(string str, T t) {     cerr << str <<   :   << t <<   n ;   }   template <class T, class... S>   void dbs(string str, T t, S... s) {     long long idx = str.find( , );     cerr << str.substr(0, idx) <<   :   << t <<  ,  ;     dbs(str.substr(idx + 1), s...);   }   template <class T>   void prc(T a, T b) {     cerr <<  [ ;     for (T i = a; i != b; ++i) {       if (i != a) cerr <<  ,  ;       cerr << *i;     }     cerr <<  ] n ;   }   template <class T>   void prall(T a) {     prc(a.begin(), a.end());   }   const int inf = 1000 * 1000 * 1000 + 9;   const long long infl = 1ll * inf * inf;   const int mod = 1000 * 1000 * 1000 + 7;   void solve() {     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       int o = 0, e = 0;       for (int i = 0; i < n; i++) {         int p;         cin >> p;         if (p & 1)           o++;         else           e++;       }       long long ans = 0;       int m;       cin >> m;       for (int i = 0; i < m; i++) {         int p;         cin >> p;         if (p & 1) {           ans += o;         } else           ans += e;       }       cout << ans <<   n ;     }   }   int main() {     ios_base::sync_with_stdio(NULL);     cin.tie(NULL);     cout << fixed << setprecision(13);     solve();   }
#include <bits/stdc++.h>   using namespace std;   int const N = 2 * 1e5 + 5;   int ans = 0;   int i, j, n, m, k, z, y, x, t, mi, ma;   long long a[N];   long long dp[N][2], d[N][2];   char st[N];   long long poisk(int x, int t) {     if (dp[x][t] != 0) return dp[x][t];     long long y = x;     d[x][t]++;     if (d[x][t] > 1) {       d[x][t] = -1;       return d[x][t];     }     if (t == 0)       y += a[x];     else       y -= a[x];     if (y < 1 || y > n) {       dp[x][t] = a[x];       return dp[x][t];     }     long long z = poisk(y, 1 - t);     if (z > 0)       dp[x][t] = a[x] + z;     else       dp[x][t] = -1;     return dp[x][t];   }   int main() {     scanf( %d , &n);     for (i = 2; i <= n; i++) scanf( %I64d , &a[i]);     for (i = 1; i < n; i++) {       a[1] = i;       d[1][0] = 0;       long long k = poisk(1 + i, 1);       if (k > 0) k += i;       printf( %I64d n , k);     }   }
#include <bits/stdc++.h>   struct M {     int p, b;   };   struct F {     const int p, i;     int r, c;     F(int p, int t, int i) : p(p), i(i), r(p + t), c(0) {}     int t() { return r - p; }   };   void solve(std::vector<F> &fs, std::vector<M> &ms) {     std::multimap<int, int> ms_landed;     std::map<int, F *> fs_active;     {       std::vector<F *> fs_sort;       fs_sort.reserve(fs.size());       for (int i = 0; i < fs.size(); i++) fs_sort.push_back(&fs[i]);       std::sort(fs_sort.begin(), fs_sort.end(),                 [](const F *lhs, const F *rhs) { return lhs->p < rhs->p; });       fs_active.insert({fs_sort[0]->p, fs_sort[0]});       int curr = fs_sort[0]->r;       for (int i = 1; i < fs_sort.size(); i++) {         F &f = *fs_sort[i];         if (f.r > curr) {           int l = std::max(curr + 1, f.p);           curr = f.r;           fs_active.insert({l, &f});         }       }     }     auto update = [&](F &f, std::map<int, F *>::iterator &f_succ, const int &b) {       f.c++;       f.r += b;       while (f_succ != fs_active.end()) {         int l_succ = f_succ->first;         int r_succ = f_succ->second->r;         if (f.r < r_succ) {           if (f.r >= l_succ) {             fs_active.erase(f_succ);             f_succ = fs_active.insert({f.r + 1, f_succ->second}).first;           }           break;         }         f_succ = fs_active.erase(f_succ);       }     };     for (const M &m : ms) {       auto f_it = --fs_active.upper_bound(m.p);       const int l = f_it->first;       F &f = *f_it->second;       if (l <= m.p && m.p <= f.r) {         update(f, ++f_it, m.b);         auto m_it = ms_landed.lower_bound(l);         while (m_it != ms_landed.end()) {           M m{m_it->first, m_it->second};           if (l <= m.p && m.p <= f.r) {             update(f, f_it, m.b);             m_it = ms_landed.erase(m_it);           } else {             break;           }         }       } else {         ms_landed.insert({m.p, m.b});       }     }     for (F &f : fs) {       printf( %d %d n , f.c, f.t());     }   }   int main() {     int n, m;     scanf( %d%d , &n, &m);     std::vector<F> fs;     fs.reserve(n);     std::vector<M> ms;     ms.reserve(m);     for (int i = 0; i < n; i++) {       int p, t;       scanf( %d%d , &p, &t);       fs.push_back({p, t, i});     }     for (int i = 0; i < m; i++) {       int p, b;       scanf( %d%d , &p, &b);       ms.push_back({p, b});     }     solve(fs, ms);     return 0;   }