Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

// SegmentTree
template <class DataType>
class SegmentTree
{
public:
    using OpType = std::function<DataType(DataType, DataType)>;
    int N;
    std::vector<DataType> dat;
    DataType e; // identity element
    OpType op;

    SegmentTree(std::vector<DataType>& base,
        DataType e0, OpType op0): e(e0), op(op0)
    {
        N = 1;
        while(N < base.size()) N *= 2;
        dat.resize(2*N-1);
        for(int i=0; i<N; i++)
            dat[i+N-1] = (i<base.size()) ? base[i] : e;
        for(int i=N-2; i>=0; i--) dat[i] = op(dat[2*i+1], dat[2*i+2]);
    }
    void update(int index, DataType value){
        int i = index + N-1;
        dat[i] = value;
        while(i > 0){
            i = (i-1) / 2;
            dat[i] = op(dat[2*i+1], dat[2*i+2]);
        }
    }
    DataType subQuery(int qleft, int qright, int tmp, int sleft, int sright){
        if(qleft <= sleft && sright <= qright) return dat[tmp];
        if(sright <= qleft || qright <= sleft) return e;

        int mid = (sleft + sright) / 2;
        return op(subQuery(qleft, qright, 2*tmp+1, sleft, mid),
            subQuery(qleft, qright, 2*tmp+2, mid, sright));
    }
    DataType query(int left, int right){
        return subQuery(left, right, 0, 0, N);
    }
    void print(){
        for(int i=N-1; i<2*N-1; i++) std::cout << dat[i] << " ";
        std::cout << std::endl;
    }
};

int main()
{
    const ll MOD = 998244353;

    ll N;
    cin >> N;
    vector<Pll> R(N);
    for(int i=0; i<N; i++) cin >> R[i].first >> R[i].second;
    sort(R.begin(), R.end());
    vector<ll> X(N), D(N);
    for(int i=0; i<N; i++) X[i] = R[i].first;
    for(int i=0; i<N; i++) D[i] = R[i].second;

    // debug(X);
    vector<ll> T(N);
    SegmentTree<ll> segtree(T, (ll)0, [](ll a, ll b)->ll{
        return max(a, b);
    });
    for(int i=N-1; i>=0; i--){
        auto itr = lower_bound(X.begin(), X.end(), X[i]+D[i]);
        ll j = distance(X.begin(), itr);
        if(i+1==j) T[i] = i;
        else T[i] = segtree.query(i, j);
        segtree.update(i, T[i]); 
    }
    // debug(X);
    // debug(D);
    // debug(T);

    vector<ll> dp(N+1);
    dp[N] = 1;
    for(int i=N-1; i>=0; i--){
        dp[i] = dp[i+1] + dp[T[i]+1];
    }

    cout << dp[0] << endl;
}

Compiler output:
a.cc:31:25: error: 'function' in namespace 'std' does not name a template type
   31 |     using OpType = std::function<DataType(DataType, DataType)>;
      |                         ^~~~~~~~
a.cc:11:1: note: 'std::function' is defined in header '<functional>'; this is probably fixable by adding '#include <functional>'
   10 | #include <cmath>
  +++ |+#include <functional>
   11 | 
a.cc:35:5: error: 'OpType' does not name a type
   35 |     OpType op;
      |     ^~~~~~
a.cc:38:22: error: 'OpType' has not been declared
   38 |         DataType e0, OpType op0): e(e0), op(op0)
      |                      ^~~~~~
a.cc: In constructor 'SegmentTree<DataType>::SegmentTree(std::vector<_Tp>&, DataType, int)':
a.cc:38:42: error: class 'SegmentTree<DataType>' does not have any field named 'op'
   38 |         DataType e0, OpType op0): e(e0), op(op0)
      |                                          ^~
a.cc: In function 'int main()':
a.cc:87:39: error: invalid user-defined conversion from 'main()::<lambda(ll, ll)>' to 'int' [-fpermissive]
   87 |     SegmentTree<ll> segtree(T, (ll)0, [](ll a, ll b)->ll{
      |                                       ^~~~~~~~~~~~~~~~~~~
   88 |         return max(a, b);
      |         ~~~~~~~~~~~~~~~~~              
   89 |     });
      |     ~                                  
a.cc:87:39: note: candidate is: 'constexpr main()::<lambda(ll, ll)>::operator ll (*)(ll, ll)() const' (near match)
   87 |     SegmentTree<ll> segtree(T, (ll)0, [](ll a, ll b)->ll{
      |                                       ^
a.cc:87:39: note:   no known conversion from 'll (*)(ll, ll)' {aka 'long long int (*)(long long int, long long int)'} to 'int'
a.cc:38:29: note:   initializing argument 3 of 'SegmentTree<DataType>::SegmentTree(std::vector<_Tp>&, DataType, int) [with DataType = long long int]'
   38 |         DataType e0, OpType op0): e(e0), op(op0)
      |                      ~~~~~~~^~~
a.cc: In instantiation of 'SegmentTree<DataType>::SegmentTree(std::vector<_Tp>&, DataType, int) [with DataType = long long int]':
a.cc:89:6:   required from here
   89 |     });
      |      ^
a.cc:45:46: error: 'op' was not declared in this scope; did you mean 'op0'?
   45 |         for(int i=N-2; i>=0; i--) dat[i] = op(dat[2*i+1], dat[2*i+2]);
      |                                            ~~^~~~~~~~~~~~~~~~~~~~~~~~
      |                                            op0
a.cc: In instantiation of 'void SegmentTree<DataType>::update(int, DataType) [with DataType = long long int]':
a.cc:95:23:   required from here
   95 |         segtree.update(i, T[i]);
      |         ~~~~~~~~~~~~~~^~~~~~~~~
a.cc:52:24: error: 'op' was not declared in this scope
   52 |             dat[i] = op(dat[2*i+1], dat[2*i+2]);
      |                      ~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc: In instantiation of 'DataType SegmentTree<DataType>::subQuery(int, int, int, int, int) [with DataType = long long int]':
a.cc:64:16:   required from 'DataType SegmentTree<DataType>::query(int, int) [with DataType = long long int]'
   64 |         return subQuery(left, right, 0, 0, N);
      |                ^~~~~~~~
a.cc:94:34:   required from here
   94 |         else T[i] = segtree.query(i, j);
      |                     ~~~~~~~~~~~~~^~~~~~
a.cc:60:18: error: 'op' was not declared in this scope
   60 |         return op(subQuery(qleft, qright, 2*tmp+1, sleft, mid),
      |                ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   61 |             subQuery(qleft, qright, 2*tmp+2, mid, sright));
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~