#include using namespace std; typedef long long ll; #define int ll const int N = 2e5 + 7; const int inf = 1e18; int n, m, f[N][2], a[N], b[N], res = -inf; signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; for (int i = 1; i <= n; i++) cin >> a[i] >> b[i]; memset(f, 0x80, sizeof(f)); f[1][0] = max({b[1], a[1] * m, a[1] * (m - 1) + b[1]}); for (int i = 2; i <= n; i++) { f[i][0] = f[i - 1][0] + max({b[i], a[i] * m, a[i] * (m - 1) + b[i]}); f[i][1] = max(f[i - 1][0], f[i - 1][1]) + max(a[i], b[i]); } for (int i = 1; i <= n; i++) res = max({res, f[i][0], f[i][1]}); cout << res; }