#include using namespace std; /*{{{*/ //template #define REP(i,n) for(int i=0;i ostream& operator<<(ostream& os,const vector& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; } template ostream& operator<<(ostream& os,const pair& p){ os << "(" << p.first << ","<< p.second <<")"; return os; } typedef long long ll; typedef unsigned long long ull; typedef pair pii; typedef vector vi; typedef vector vvi; ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); } constexpr ll mod = 1e9+7; const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1}; /*}}}*/ ll N,K; int main(){ cin>>N>>K; vector T(N+2),D(N+2); rep(i,N) cin>>T[i+1]>>D[i+1]; T[0] = -K-10; D[0] = 0; T[N] = T[N-1]+K+10; D[N] = 0; ll sum = 0; rep(i,N) sum += D[i]; vector dp(N+10,0); dp[0]=0; set ans; for(int i=0;i(ret,D[i]); } cout << ret << endl; ll mx = dp[N]; cout << sum-mx << endl; }