#include #include #include #include #include template std::map compress(std::vector& v) { std::sort(v.begin(), v.end()); v.erase(std::unique(v.begin(), v.end()), v.end()); std::map rev; for (int i = 0; i < (int)v.size(); ++i) rev[v[i]] = i; return rev; } struct UnionFind { std::vector par, sz; int gnum; explicit UnionFind(int n) : par(n), sz(n, 1), gnum(n) { std::iota(par.begin(), par.end(), 0); } int find(int v) { return (par[v] == v) ? v : (par[v] = find(par[v])); } void unite(int u, int v) { u = find(u), v = find(v); if (u == v) return; if (sz[u] < sz[v]) std::swap(u, v); sz[u] += sz[v]; par[v] = u; --gnum; } bool same(int u, int v) { return find(u) == find(v); } bool ispar(int v) { return v == find(v); } int size(int v) { return sz[find(v)]; } }; void solve() { int n, m; std::cin >> n >> m; std::vector> es(m); std::vector vs; for (auto& e : es) { std::cin >> e.first >> e.second; vs.push_back(e.first); vs.push_back(e.second); } auto vrev = compress(vs); n = vs.size(); UnionFind uf(n); std::vector deg(n, 0); for (auto& e : es) { e.first = vrev[e.first]; e.second = vrev[e.second]; uf.unite(e.first, e.second); ++deg[e.first]; ++deg[e.second]; } int onum = std::count_if(deg.begin(), deg.end(), [](auto d) { return d % 2 != 0; }); std::cout << (uf.gnum == 1 && onum <= 2 ? "YES" : "NO") << "\n"; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }