#include using namespace std; #include using ll = long long; constexpr ll mod = 998244353; // 座標圧縮 map compress(vector a) { map mem; for (auto i: a) mem[i] = 0; int cnt = 0; for (auto& [i, j]: mem) j = cnt++; return mem; } int main() { // 入力 int n; cin >> n; vector> points(n); for (auto& [i, j]: points) { ll x, y; cin >> x >> y; i = x + y; j = y - x; } // 座標を反転しておく if (points.front().first > points.back().first) { for (auto& [i, j]: points) i = -i; } if (points.front().second > points.back().second) { for (auto& [i, j]: points) j = -j; } // pointsのy座標を座標圧縮 vector y(n); for (int i = 0; i < n; ++i) y[i] = points[i].second; auto mem = compress(y); for (auto& [i, j]: points) j = mem[j]; // ソート sort(points.begin() + 1, points.end() - 1); // y座標がより小さい頂点の個数を順に調べる atcoder::fenwick_tree ft(mem.size()); ft.add(points.front().second, 1); for (int i = 1; i < n - 1; ++i) { if (points[i].first < points.front().first || points.back().first < points[i].first) continue; ft.add(points[i].second, ft.sum(0, points[i].second + 1)); } // 出力 cout << ft.sum(0, points.back().second + 1).val() << '\n'; }