Language: C++

#include <bits/stdc++.h>


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = rbegin(s); i != rend(s); ++i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.ne(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<typename A, int N, typename T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

template<class T>
struct ModInt {
    T x;
    ModInt(T x = 0) :x((x + mod) % mod) {}
    ModInt& operator+=(const ModInt a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(const ModInt a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator*=(const ModInt a) {
        (x *= a.x) %= mod;
        return *this;
    }
    ModInt operator+(const ModInt a) const {
        ModInt res(*this);
        return res += a;
    }
    ModInt operator-(const ModInt a) const {
        ModInt res(*this);
        return res -= a;
    }
    ModInt operator*(const ModInt a) const {
        ModInt res(*this);
        return res *= a;
    }
    ModInt pow(T t) const {
        if (!t) return 1;
        ModInt a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    ModInt inv() const {
        return pow(mod - 2);
    }
    ModInt& operator/=(const ModInt a) {
        return (*this) *= a.inv();
    }
    ModInt operator/(const ModInt a) const {
        ModInt res(*this);
        return res /= a;
    }
};
using mint = ModInt<long long>;


template<class T>
class SegmentTree {
public:
    SegmentTree(int n_) : n(1) {
        while (n < n_) n *= 2;
        node.resize(2 * n - 1, def);
    }

    T comp(T a, T b) { return std::max(a, b); }
    // d[k] = a
    void update(int k, T x) {
        k += n - 1;
        node[k] = x;
        while (k > 0) {
            k = (k - 1) >> 1;
            node[k] = comp(node[2 * k + 1], node[2 * k + 2]);
        }
    }
    // comp() [a,b)
    T query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0)
            r = n;

        if (r <= a || b <= l)
            return def;
        if (a <= l && r <= b)
            return node[k];
        int vl = query(a, b, 2 * k + 1, l, (l + r) >> 1);
        int vr = query(a, b, 2 * k + 2, (l + r) >> 1, r);
        return comp(vl, vr);
    }
private:
    static const T def = std::numeric_limits<T>::min();
    int n;
    vector<T> node;
};

int n;
ll x[200005], d[200005];
pair<ll, ll> pos[200005];
mint dp[200005];
int r[200005];
void solve() {
    mod = 998244353;
    cin >> n;
    rep(i, n) cin >> x[i] >> d[i];

    rep(i, n) pos[i] = { x[i],x[i] + d[i] };
    sort(pos, pos + n);

    SegmentTree<int> st(n);
    repd(i, n) {
        auto p = distance(pos, lower_bound(pos + i + 1, pos + n, pair<ll, ll>(pos[i].second, 0)));
        r[i] = max(i + 1, st.query(i + 1, p));
        st.update(i, r[i]);
    }

    dp[n] = 1;
    repd(i, n) {
        dp[i] += dp[i + 1];
        dp[i] += dp[r[i]];
    }

    cout << dp[0].x << endn;

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Compiler output:
/usr/bin/ld: /tmp/ccSwIdJs.o: warning: relocation against `_ZN11SegmentTreeIiE3defE' in read-only section `.text._ZN11SegmentTreeIiEC2Ei[_ZN11SegmentTreeIiEC5Ei]'
/usr/bin/ld: /tmp/ccSwIdJs.o: in function `SegmentTree<int>::SegmentTree(int)':
a.cc:(.text._ZN11SegmentTreeIiEC2Ei[_ZN11SegmentTreeIiEC5Ei]+0x5e): undefined reference to `SegmentTree<int>::def'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status