#include #include #include using namespace std; bool solve(){ int N, M; cin >> N >> M; vector> intervals; for(int i=0;i> L >> R; if(L < M - R - 1){ intervals.emplace_back(L, R); } else { intervals.emplace_back(M - R - 1, M - L - 1); } } sort(intervals.begin(), intervals.end()); int L = 0, R = M - 1; for(auto ps : intervals){ bool right = false; if(L <= ps.first){ // 左におくべき if(R < ps.second){ return false; } L = ps.second + 1; } else if(M - ps.first - 1 <= R){ // 右におくべき if(M - ps.second - 1 < L){ return false; } R = M - ps.second - 1 - 1; } else { // ダメポ return false; } } return true; } int main(){ cout << (solve() ? "YES" : "NO") << endl; return 0; }