#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef unsigned long long int ull; typedef long long int ll; typedef pair pll; typedef pair pi; typedef pair pd; typedef pair pdl; #define F first #define S second const ll E=1e18+7; const ll MOD=1000000007; int main(){ ll n,m; cin>>n>>m; vector A(n); ll ans=-E; ll sum=0; ll meat=0; ll egg=0; for(auto &I:A){cin>>I.F>>I.S;} for(auto &I:A){ meat+=max(I.F,I.S); sum+=max(max(I.F*m-max(I.F,I.S),I.F*(m-1)+I.S-max(I.F,I.S)),I.S-max(I.F,I.S)); if(sum>egg){egg=sum;} ans=max(ans,egg+meat); } cout<