#include <iostream>
using namespace std;
int main() {
int n;
int s;
cin >> n >> s;
int c[10005];
int y[10005];
for (int i = 0; i < n; i++) {
cin >> c[i] >> y[i];
}
long long t = 0;
long long o = c[0];
for (int i = 0; i < n; i++) {
if (i > 0) {
if (o + s < c[i]) {
o = o + s;
} else {
o = c[i];
}
}
t += c[i] * y[i];
}
cout << t;
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: