#include <bits/stdc++.h>
using namespace std;
struct str{
int l,t;
}a[100005];
int tp,tc;
int cmp(str,str);
priority_queue <long long> q;
int n,dmax,l;
long long s;
int main(){
freopen("lupu.in","r",stdin);
freopen("lupu.out","w",stdout);
cin>>n>>dmax>>l;
for (int i=1;i<=n;i++){
int d;
cin>>d>>a[i].l;
if (d>dmax){
a[i].t=0;
}
else {
a[i].t=(dmax-d)/l+1;
}
}
sort(a+1,a+n+1,cmp);
tp=0;
long long i=1;
while (i<=n){
tp=a[i-1].t;
tc=a[i].t;
while (tp>tc&&!q.empty()){
s+=q.top();
q.pop();
tp--;
}
while (a[i].t==tc&&i<=n){
q.push(a[i].l);
i++;
}
}
cout<<s+q.top();
}
int cmp(str a,str b){
return a.t>b.t;
}