#include using namespace std; int main(){ int64_t N, M, A[100000], B[100000]; cin >> N >> M; for(int i=0; i> A[i] >> B[i]; int64_t a = 0, b = 0, c = 0; int64_t ans = -1e18; for(int i=0; i B[i] ? A[i] : 0); b += max(A[i], B[i]); c += max(M*A[i], B[i]); }else{ int64_t x, y; if(A[i] >= 0){ x = A[i]; y = max(A[i], B[i]); }else{ x = 0; y = B[i]; } a += x; b += y; c += (M-1)*x + y; } if(b <= c){ a = 0; b = c; } if(i == 0){ ans = c; }else{ ans = max({ans, b, c}); } } cout << ans << endl; return 0; }