Language: C++

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

template <class I, class Op>
class SegmentTree {
 private:
  int n;
  vector<I> dat;
  Op op;
  I e;

 public:
  SegmentTree(int n_, const Op& op, const I& e) : op(op), e(e) {
    n = 1;
    while (n < n_) n *= 2;
    dat.resize(2 * n - 1, e);
  }
  SegmentTree(const vector<I>& init, const Op& op, const I& e)
      : SegmentTree(init.size(), op, e) {
    for (int i = 0; i < init.size(); i++) {
      dat[i + n - 1] = init[i];
    }
    for (int i = n - 2; i >= 0; i--) {
      dat[i] = op(dat[i * 2 + 1], dat[i * 2 + 2]);
    }
  }
  const I& operator[](int k) const { return dat[k + n - 1]; }
  void update(int k, const I& a) {
    k += n - 1;
    dat[k] = a;
    while (k > 0) {
      k = (k - 1) / 2;
      dat[k] = op(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
  }
  // [a, b)
  I query(int a, int b) const {
    a += n - 1;
    b += n - 1;
    I vl = e;
    I vr = e;
    while (a < b) {
      if ((a & 1) == 0) vl = op(vl, dat[a]);
      if ((b & 1) == 0) vr = op(dat[b - 1], vr);
      a = a / 2;
      b = (b - 1) / 2;
    }
    return op(vl, vr);
  }
  // query(0, i) >= x 縺ｨ縺ｪ繧区怙蟆上�ｮi
  int kth(const I& x) const {
    int k = 0;
    I v = e;
    while (k < n - 1) {
      I t = op(v, dat[k * 2 + 1]);
      if (x <= t) {
        k = k * 2 + 1;
      } else {
        v = t;
        k = k * 2 + 2;
      }
    }
    return k - (n - 1) + 1;
  }
};

using R = pair<int, int>;

template <std::uint_fast64_t Modulus>
class modint {
  using u64 = std::uint_fast64_t;

 public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept
      : a(x % Modulus) {
  }
  constexpr u64 &value() noexcept {
    return a;
  }
  constexpr const u64 &value() const noexcept {
    return a;
  }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(const modint rhs) noexcept {
    return *this *= ~rhs;
  }
  constexpr modint power(u64 exp) const noexcept {
    modint v = 1, x = *this;
    while (exp) {
      if (exp & 1) {
        v *= x;
      }
      x *= x;
      exp >>= 1;
    }
    return v;
  }
  constexpr modint operator~() const noexcept {
    return power(Modulus - 2);
  }
};

using mint = modint<998244353>;

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  while (cin >> N) {
    vector<R> robots(N);
    for (auto &x : robots) cin >> x.fst >> x.snd;
    sort(robots.begin(), robots.end());
    auto op = [&](int a, int b) { return max(a, b); };
    SegmentTree<int, delctype(op)> seg(N + 1, op, -1);
    vector<int> leftMost(N, -1);
    leftMost[N - 1] = N - 1;
    seg.update(N - 1, N - 1);
    for (int i = N - 2; i >= 0; i--) {
      int X = robots[i].fst, D = robots[i].snd;
      auto ed = partition_point(robots.begin() + i + 1, robots.end(), [&](auto& x) {
        return x.fst < X + D;
      });
      int j = distance(robots.begin(), ed);
      if (i + 1 >= j) {
        leftMost[i] = i;
        seg.update(i, i);
      } else {
        int mx = seg.query(i + 1, j);
        leftMost[i] = mx;
        seg.update(i, mx);
      }
    }
    vector<mint> dp(N + 1, mint(0));
    dp[0] = 1;
    for (int i = 0; i < N; i++) {
      dp[i + 1] += dp[i];
      dp[leftMost[i] + 1] += dp[i];
    }
    cout << dp[N].value() << endl;
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:177:22: error: 'delctype' was not declared in this scope; did you mean 'decltype'?
  177 |     SegmentTree<int, delctype(op)> seg(N + 1, op, -1);
      |                      ^~~~~~~~
      |                      decltype
a.cc:177:34: error: template argument 2 is invalid
  177 |     SegmentTree<int, delctype(op)> seg(N + 1, op, -1);
      |                                  ^
a.cc:177:53: error: expression list treated as compound expression in initializer [-fpermissive]
  177 |     SegmentTree<int, delctype(op)> seg(N + 1, op, -1);
      |                                                     ^
a.cc:180:9: error: request for member 'update' in 'seg', which is of non-class type 'int'
  180 |     seg.update(N - 1, N - 1);
      |         ^~~~~~
a.cc:189:13: error: request for member 'update' in 'seg', which is of non-class type 'int'
  189 |         seg.update(i, i);
      |             ^~~~~~
a.cc:191:22: error: request for member 'query' in 'seg', which is of non-class type 'int'
  191 |         int mx = seg.query(i + 1, j);
      |                      ^~~~~
a.cc:193:13: error: request for member 'update' in 'seg', which is of non-class type 'int'
  193 |         seg.update(i, mx);
      |             ^~~~~~