#define _USE_MATH_DEFINES #include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define MT make_tuple #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)<; using vi = vector; using vll = vector; const ll MI = LLONG_MIN / 3; ll dp[100005][3]; void solve() { int N; ll M; cin >> N >> M; rep(i, N + 1)rep(j, 3)dp[i][j] = MI; dp[0][2] = 0; rep(i, N) { // 卵、肉 int A, B; cin >> A >> B; rep(j, 3) { rep(jj, j + 1) { if (jj == 0) { smax(dp[i + 1][0], dp[i][j]); } else if (jj == 1) { smax(dp[i + 1][1], dp[i][j] + max(A, B)); } else { ll va = max(max(A*M, B), A*(M - 1) + B); smax(dp[i + 1][2], dp[i][j] + va); } } } } ll ans = MI; rep(i, 3)smax(ans, dp[N][i]); cout << ans << endl; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15); solve(); return 0; }