Language: C++

#include <iostream>
#include <fstream> 
#include <bits/stdc++.h>
using namespace std;
#define long long long
typedef pair < long , long > pii;
#define MAX 210000
class FSilverFoxVsMonster {
    long tree[4*MAX];
    long lazy[4*MAX];
    long A[MAX];
public:
    void build(int node, int start, int end)
    {
        if(start == end)
        {
            // Leaf node will have a single element
            tree[node] = A[start];
        }
        else
        {
            int mid = (start + end) / 2;
          
            build(2*node, start, mid);
           
            build(2*node+1, mid+1, end);
          
            tree[node] = tree[2*node] + tree[2*node+1];
        }
    }
    void updateRange(int node, int start, int end, int l, int r, int val)
    {
        if(lazy[node] != 0)
        {
            tree[node] += (end - start + 1) * lazy[node];    // Update it
            if(start != end)
            {
                lazy[node*2] += lazy[node];                  // Mark child as lazy
                lazy[node*2+1] += lazy[node];                // Mark child as lazy
            }
            lazy[node] = 0;                                  // Reset it
        }
        if(start > end or start > r or end < l)              // Current segment is not within range [l, r]
            return;
        if(start >= l and end <= r)
        {
            // Segment is fully within range
            tree[node] += (end - start + 1) * val;
            if(start != end)
            {
                lazy[node*2] += val;
                lazy[node*2+1] += val;
            }
            return;
        }
        int mid = (start + end) / 2;
        updateRange(node*2, start, mid, l, r, val);
        updateRange(node*2 + 1, mid + 1, end, l, r, val);   
        tree[node] = tree[node*2] + tree[node*2+1];       
 
    long queryRange(int node, int start, int end, int l, int r)
    {
        if(start > end or start > r or end < l)
            return 0;         // Out of range
        if(lazy[node] != 0)
        {
            // This node needs to be updated
            tree[node] += (end - start + 1) * lazy[node];            // Update it
            if(start != end)
            {
                lazy[node*2] += lazy[node];         // Mark child as lazy
                lazy[node*2+1] += lazy[node];    // Mark child as lazy
            }
            lazy[node] = 0;                 // Reset it
        }
        if(start >= l and end <= r)             // Current segment is totally within range [l, r]
            return tree[node];
        int mid = (start + end) / 2;
        long p1 = queryRange(node*2, start, mid, l, r);         
        long p2 = queryRange(node*2 + 1, mid + 1, end, l, r); 
        return (p1 + p2);
    }
	void solve(std::istream& in, std::ostream& out) {
        int n;
        long d;
        long power;
        in>>n>>d>>power;
        vector <long> data;
        long x,y;
        memset(A,0,sizeof A);
        memset(lazy,0,sizeof lazy);
        for(int i=0;i<n;i++){
            in>>x>>y;
            data.push_back(x);
            A[x]=y;
        }
        build(1,1,n);
        long ans=0;
        for(long xx: data){
                long need= queryRange(1,1,n,xx,xx);
                if(need<= 0) continue;
                long needPower = ((need+power-1)/power) * power;
                ans+= needPower;
                updateRange(1,1,n,xx,2*d,needPower*(-1));
        }
        out<<ans<<endl;
 
	}
};
 
 
int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);
	FSilverFoxVsMonster solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Compiler output:
a.cc:119:2: error: expected '}' at end of input
  119 | }
      |  ^
a.cc:8:27: note: to match this '{'
    8 | class FSilverFoxVsMonster {
      |                           ^
a.cc: In member function 'void FSilverFoxVsMonster::updateRange(int, int, int, int, int, int)':
a.cc:62:5: error: a function-definition is not allowed here before '{' token
   62 |     {
      |     ^
a.cc:83:57: error: a function-definition is not allowed here before '{' token
   83 |         void solve(std::istream& in, std::ostream& out) {
      |                                                         ^
a.cc: In member function 'int FSilverFoxVsMonster::main()':
a.cc:117:16: error: 'class FSilverFoxVsMonster' has no member named 'solve'
  117 |         solver.solve(in, out);
      |                ^~~~~
a.cc: At global scope:
a.cc:119:2: error: expected unqualified-id at end of input
  119 | }
      |  ^