Language: C++

#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

template <class operator_monoid> class dual_segment_tree{
public:
	typedef typename operator_monoid::underlying_type underlying_type;
	typedef typename operator_monoid::value_type value_type;
	size_t n;
	vector<underlying_type> v;
	vector<value_type> w;
	underlying_type e = operator_monoid::unit();
	dual_segment_tree(size_t size){
		n = 1;
		while(n < size) n <<= 1;
		v.resize(2*n, e);
		w.resize(size, operator_monoid::default_value());
	}
	dual_segment_tree(vector<value_type> _w){
		size_t size = w.size();
		n = 1;
		while(n < size) n <<= 1;
		v.resize(2*n, e);
		w(_w);
	}
	void range_operate(underlying_type f, size_t a, size_t b, size_t k, size_t l, size_t r){
		if(r <= a || b <= l) return;
		if(a <= l && r <= b) v[k] = operator_monoid::compose(f, v[k]);
		else{
			if(2*k < v.size())
				v[2*k] = operator_monoid::compose(v[k], v[2*k]);
			if(2*k+1 < v.size())
				v[2*k+1] = operator_monoid::compose(v[k], v[2*k+1]);
			v[k] = operator_monoid::unit();
			range_operate(f, a, b, 2*k, l, (l+r+1)/2);
			range_operate(f, a, b, 2*k+1, (l+r+1)/2, r);
		}
	}
	void range_operate(underlying_type f, size_t a, size_t b){
		range_operate(f, a, b, 1, 0, n);
	}
	value_type point_get(size_t i){
		range_operate(e, i, i+1, 1, 0, n);
		return operator_monoid::operate(v[i+n], w[i]);
	}
};
struct assign_operator_monoid{
	using underlying_type = pair<bool, Int>;
	using value_type = Int;
	static underlying_type unit(){
		return pair<bool, int>(true, 0);
	}
	static underlying_type compose(underlying_type l, underlying_type r){
		if(l == unit()) return r;
		return l;
	}
	static value_type default_value(){
		return 0;
	}
	static value_type operate(underlying_type f, value_type x){
		return f.first ? x : f.second;
	}
};
struct add_operator_monoid{
	using underlying_type = Int;
	using value_type = Int;
	static underlying_type unit(){
		return 0;
	}
	static underlying_type compose(underlying_type l, underlying_type r){
		return l + r;
	}
	static value_type default_value(){
		return 0;
	}
	static value_type operate(underlying_type f, value_type x){
		return f + x;
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int n, d, a; cin >> n >> d >> a;
	using P = pair<Int, Int>;
	vector<P> v(n);
	for(Int i=0; i<n; ++i)
		cin >> v[i].first >> v[i].second;
	sort(v.begin(), v.end());
	dual_segment_tree<add_operator_monoid> dst(n);
	Int ans = 0;
	for(Int i=0; i<n; ++i){
		Int r = upper_bound(v.begin(), v.end(), P(v[i].first + 2*d, 1e9+1)) - 1 - v.begin();
		Int l = lower_bound(v.begin(), v.end(), P(v[r].first - 2*d, 0ll)) - v.begin();
		Int m = (max(0ll, v[i].second - dst.point_get(i)*a) + a - 1) / a;
		ans += m;
		dst.range_operate(m, l, r+1);
//		cout << i << " " << ans << " " << r << "\n";
//		cout << "dst\n";
//		for(int j=0; j<n; ++j)
//			cout << j << " " << dst.point_get(j) << "\n";
	}
	cout << ans << "\n";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:95:29: error: no matching function for call to 'max(long long int, long int)'
   95 |                 Int m = (max(0ll, v[i].second - dst.point_get(i)*a) + a - 1) / a;
      |                          ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:95:29: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long int')
   95 |                 Int m = (max(0ll, v[i].second - dst.point_get(i)*a) + a - 1) / a;
      |                          ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:95:29: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   95 |                 Int m = (max(0ll, v[i].second - dst.point_get(i)*a) + a - 1) / a;
      |                          ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~