#include<bits/stdc++.h> usingnamespacestd; typedeflonglong ll; typedefdouble db; #define pii pair<int, int> #define mk make_pair constint N = 1e6 + 10; constint mod = 1e9 + 7; intread() { int x = 0, f = 1; char c = getchar(); while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + c - '0', c = getchar(); return x * f; } ll sum[N], a[N], x[N]; db ans = 0; ll d; db f(int i, int j) { return1.00 * (sum[i] - sum[j - 1]) / (x[i] + (i - j) * d); } db slope(int i, int j) { return1.00 * (sum[i - 1] - sum[j - 1]) / (i * d - j * d); } int q[N]; intmain() { int n = read(); d = read(); for (int i = 1; i <= n; i++) { a[i] = read(); x[i] = read(); } for (int i = 1; i <= n; i++) sum[i] = a[i] + sum[i - 1]; int head = 1, tail = 0; for (int i = 1; i <= n; i++) { while (head < tail && slope(q[tail], i) < slope(q[tail - 1], q[tail])) tail--; q[++tail] = i; int l = 1, r = tail; while (l != r) { int x = (r - l + 1) / 3; int mid1 = l + x - 1, mid2 = l + 2 * x - 1; if (mid1 == mid2) break; if (f(i, q[mid1]) < f(i, q[mid2])) l = mid1 + 1; else r = mid2 - 1; }
ans += max(f(i, q[l]), f(i, q[r])); } printf("%.0lf\n", ans); }