#if __INCLUDE_LEVEL__ == 0 #include __BASE_FILE__ void Solve() { int Q, K; IN(Q, K); if (Q >= 6) { if (K >= 5) { OUT("Yes"); OUT(1, 2); OUT(1, 2); OUT(3, 4); OUT(3, 5); OUT(3, 5); for (int _ : Rep(0, Q - 5)) { OUT(6, 7); } } else { OUT("No"); } return; } vector> ops; ops.reserve(Q); vector> ans; Fix([&](auto self, int n) -> void { if (Sz(ans)) { return; } if (Sz(ops) == Q) { bool ok = true; for (int a0 : Rep(0, 2)) { for (int a1 : Rep(0, 2)) { vector a{a0, a1}; a.reserve(Q + 2); for (auto [i, j] : ops) { a.push_back((a[i] & a[j]) ^ 1); } ok &= int(ranges::count(a, 1)) <= K; } } if (ok) { ans = ops; } return; } for (int i : Rep(0, n)) { for (int j : Rep(i + 1, n)) { ops.emplace_back(i, j); self(n + 1); ops.pop_back(); } } })(2); if (Sz(ans)) { OUT("Yes"); for (auto [i, j] : ans) { OUT(i + 1, j + 1); } } else { OUT("No"); } } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); Solve(); } #elif __INCLUDE_LEVEL__ == 1 #include template class Fix { public: explicit Fix(F f) : f_(std::move(f)) {} template decltype(auto) operator()(Ts&&... xs) { return f_(std::ref(*this), std::forward(xs)...); } template decltype(auto) operator()(Ts&&... xs) const { return f_(std::ref(*this), std::forward(xs)...); } private: F f_; }; template concept MyRange = std::ranges::range && !std::convertible_to; template concept MyTuple = std::__is_tuple_like::value && !MyRange; namespace std { istream& operator>>(istream& is, MyRange auto&& r) { for (auto&& e : r) is >> e; return is; } istream& operator>>(istream& is, MyTuple auto&& t) { apply([&](auto&... xs) { (is >> ... >> xs); }, t); return is; } ostream& operator<<(ostream& os, MyRange auto&& r) { auto sep = ""; for (auto&& e : r) os << exchange(sep, " ") << e; return os; } ostream& operator<<(ostream& os, MyTuple auto&& t) { auto sep = ""; apply([&](auto&... xs) { ((os << exchange(sep, " ") << xs), ...); }, t); return os; } } // namespace std using namespace std; #define _ _ [[maybe_unused]] #define Rep(...) [](int l, int r) { return views::iota(min(l, r), r); }(__VA_ARGS__) #define Sz(r) int(size(r)) #define IN(...) (cin >> forward_as_tuple(__VA_ARGS__)) #define OUT(...) (cout << forward_as_tuple(__VA_ARGS__) << '\n') #endif // __INCLUDE_LEVEL__ == 1