#include #include #include #include #include #define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define FOR(i,m,n) for(int i=(m);i<(n);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() const int INF = 0x3f3f3f3f; const long long LINF = 0x3f3f3f3f3f3f3f3fLL; const double EPS = 1e-8; const int MOD = 1000000007; // 998244353; const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1}; /*-------------------------------------------------*/ int main() { cin.tie(0); ios::sync_with_stdio(false); // freopen("input.txt", "r", stdin); int n; long long m; cin >> n >> m; vector a(n), b(n); REP(i, n) cin >> a[i] >> b[i]; // K = 0 は invalid long long dp_1 = -INF, dp_m = max(a[0] * (m - 1) + max(a[0], b[0]), (long long)b[0]); long long ans = max(dp_1, dp_m); FOR(i, 1, n) { long long ikkai = max(dp_1, dp_m) + max(a[i], b[i]); long long mkai = dp_m + max(a[i] * (m - 1) + max(a[i], b[i]), (long long)b[i]); ans = max({ans, ikkai, mkai}); dp_1 = ikkai; dp_m = mkai; } cout << ans << '\n'; return 0; }