#include #include #include #define let auto #define fn auto #define usize size_t using namespace std; #define LIMIT (((usize) 1 << 63) - 1); fn fastio() { ios::sync_with_stdio(false); cin.tie(nullptr); } fn main() -> int { fastio(); usize n, s; cin >> n >> s; let costs = vector(n); let yopps = vector(n); // it needs cost S for storing 1 litre of milk for a week. let cummin = vector(n); for (usize i = 0; i < n; i++) { cin >> costs[i] >> yopps[i]; } let curr_min = (usize) LIMIT; for (usize i = 0; i < n; i++) { curr_min = min(curr_min + s, costs[i]); cummin[i] = curr_min; } let total = (usize) 0; for (usize i = 0; i < n; i++) { total += cummin[i] * yopps[i]; } cout << total << endl; }