#include #include #include #include //#define local #ifdef local #include "dbg-macro/dbg.h" #endif #define p std::pair #define ll long long #define ull unsigned long long #define pi (acos(-1)) #define all(x) (x).begin(), (x).end() #define rep(i, n) for (unsigned long long i = 0; i < (unsigned long long)(n); ++i) #define vec std::vector using namespace std; std::vector genprimevec(const unsigned ll N); int main() { int n, m; cin >> n >> m; vec> v(m); rep(i, m) { cin >> v[i].first >> v[i].second; } sort(all(v), [](p lhs, p rhs) { return lhs.first < rhs.first; }); int cur = 0; rep(i, m) { if (v[i].first >= abs(v[i].second - cur)) { // ok] cur = v[i].second; }else{ cout<<"No"< genprimevec(const unsigned ll N) { std::vector is_prime(N + 1); for (unsigned ll i = 0; i <= N; i++) { is_prime[i] = true; } std::vector P; for (unsigned ll i = 2; i <= N; i++) { if (is_prime[i]) { for (unsigned ll j = 2 * i; j <= N; j += i) { is_prime[j] = false; } P.emplace_back(i); } } return P; }