#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][3]; signed main(){ cin.tie(0); ios::sync_with_stdio(false); cout<>N>>M; cin>>a>>b; x = max(b,a*(M-1)+max(a,b)); for(int i = 1; i < N; i++){ cin>>a>>b; num = max(a,b); temp = max(b,a*(M-1)+num); hoge[i+1][2] += temp+hoge[i][2]; hoge[i+1][1] = max(hoge[i][2],hoge[i][1]) +num; hoge[i+1][0] = max(hoge[i][0],max(hoge[i][2],hoge[i][1])); } ans = max(hoge[N][0],max(hoge[N][2],hoge[N][1]))+x; cout<