#include #include #include #include #include #include using namespace std; #define int long long #define rep(i,n) for(int i = 0; i < (n); i++) #define INF ((long long)1e18) #define MOD ((int)1e9+7) #define endl "\n" #define yn(f) ((f)?"Yes":"No") #define YN(f) ((f)?"YES":"NO") #define MAX 110000 int N, M; int a, b; int hoge[MAX][2]; signed main(){ cin.tie(0); ios::sync_with_stdio(false); cout<>N>>M>>a>>b; x = max(b,a*(M-1)+max(a,b)); for(signed i = 1; i < N; i++){ cin>>a>>b; num = max(a,b); ans = max(ans,max(hoge[i+1][1] += max(b,a*(M-1)+num)+hoge[i][1],hoge[i+1][0] = max(hoge[i][0],hoge[i][1]) +num)); } ans += x; cout<