#pragma region satashun //#pragma GCC optimize("Ofast") //#pragma GCC optimize("unroll-loops") #include using namespace std; using uint = unsigned int; using ll = long long; using ull = unsigned long long; using pii = pair; template using V = vector; template using VV = V>; template V make_vec(size_t a) { return V(a); } template auto make_vec(size_t a, Ts... ts) { return V(ts...))>(a, make_vec(ts...)); } #define pb push_back #define eb emplace_back #define mp make_pair #define fi first #define se second #define rep(i, n) rep2(i, 0, n) #define rep2(i, m, n) for (int i = m; i < (n); i++) #define per(i, b) per2(i, 0, b) #define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--) #define ALL(c) (c).begin(), (c).end() #define SZ(x) ((int)(x).size()) constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); } template void chmin(T& t, const U& u) { if (t > u) t = u; } template void chmax(T& t, const U& u) { if (t < u) t = u; } template void mkuni(vector& v) { sort(ALL(v)); v.erase(unique(ALL(v)), end(v)); } template vector sort_by(const vector& v) { vector res(v.size()); iota(res.begin(), res.end(), 0); stable_sort(res.begin(), res.end(), [&](int i, int j) { return v[i] < v[j]; }); return res; } template istream& operator>>(istream& is, pair& p) { is >> p.first >> p.second; return is; } template ostream& operator<<(ostream& os, const pair& p) { os << "(" << p.first << "," << p.second << ")"; return os; } template istream& operator>>(istream& is, vector& v) { for (auto& x : v) { is >> x; } return is; } template ostream& operator<<(ostream& os, const vector& v) { os << "{"; rep(i, v.size()) { if (i) os << ","; os << v[i]; } os << "}"; return os; } #ifdef LOCAL void debug_out() { cerr << endl; } template void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...); } #define debug(...) \ cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__) #define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl #else #define debug(...) (void(0)) #define dump(x) (void(0)) #endif template void scan(vector& v, T offset = T(0)) { for (auto& x : v) { cin >> x; x += offset; } } template void print(T x, int suc = 1) { cout << x; if (suc == 1) cout << "\n"; else if (suc == 2) cout << " "; } template void print(const vector& v, int suc = 1) { for (int i = 0; i < v.size(); ++i) print(v[i], i == int(v.size()) - 1 ? suc : 2); } template void show(T x) { print(x, 1); } template void show(Head H, Tail... T) { print(H, 2); show(T...); } struct prepare_io { prepare_io() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } prep_io; #pragma endregion satashun class unionfind { vector par, rank; public: void init(int n) { par.resize(n); rank.resize(n); for (int i = 0; i < n; i++) { par[i] = i; rank[i] = 0; } } unionfind() {} unionfind(int n) { init(n); } int find(int x) { if (par[x] == x) return x; else return par[x] = find(par[x]); } bool unite(int x, int y) { x = find(x); y = find(y); if (x == y) return false; if (rank[x] < rank[y]) par[x] = y; else { par[y] = x; if (rank[x] == rank[y]) ++rank[x]; } return true; } bool same(int x, int y) { return (find(x) == find(y)); } }; template class Edge { public: int from, to, idx; T cost; Edge() = default; Edge(int from, int to, T cost = T(1), int idx = -1) : from(from), to(to), cost(cost), idx(idx) {} operator int() const { return to; } bool operator<(const Edge& e) const { return cost < e.cost; } }; template class Graph { public: using E = Edge; vector> g; vector edges; int es; Graph() {} Graph(int n) : g(n), edges(0), es(0){}; int size() const { return g.size(); } virtual void add_directed_edge(int from, int to, T cost = 1) { g[from].emplace_back(from, to, cost, es++); } virtual void add_edge(int from, int to, T cost = 1) { g[from].emplace_back(from, to, cost, es); g[to].emplace_back(to, from, cost, es++); } inline vector& operator[](const int& k) { return g[k]; } inline const vector& operator[](const int& k) const { return g[k]; } void read(int M, int offset = -1, bool directed = false, bool weighted = false) { for (int i = 0; i < M; i++) { int a, b; cin >> a >> b; a += offset; b += offset; T c = T(1); if (weighted) cin >> c; edges.emplace_back(a, b, c); if (directed) add_directed_edge(a, b, c); else add_edge(a, b, c); } } }; // cost = 1 or tree template V bfs(const Graph& g, int s = 0) { const T inf = numeric_limits::max() / 2; int n = g.size(); V ds(n, inf); queue que; que.push(s); ds[s] = 0; while (!que.empty()) { auto v = que.front(); que.pop(); for (auto e : g[v]) { T nx = ds[v] + e.cost; if (ds[e.to] > nx) { ds[e.to] = nx; que.push(e.to); } } } for (auto& x : ds) if (x == inf) x = -1; return ds; } // must be optimized template V bfs01(const Graph& g, int s = 0) { const T inf = numeric_limits::max() / 2; int n = g.size(); V ds(n, inf); using P = pair; deque que; que.push_back(s); ds[s] = 0; while (!que.empty()) { auto v = que.front(); que.pop_front(); for (auto e : g[v]) { T nx = ds[v] + e.cost; if (ds[e.to] > nx) { ds[e.to] = nx; if (e.cost == 0) { que.push_front(e.to); } else { que.push_back(e.to); } } } } for (auto& x : ds) if (x == inf) x = -1; return ds; } template V dijkstra(const Graph& g, int s = 0) { const T inf = numeric_limits::max() / 2; int n = g.size(); V ds(n, inf); using P = pair; priority_queue, greater

> que; que.emplace(0, s); ds[s] = 0; while (!que.empty()) { auto p = que.top(); que.pop(); int v = p.se; if (ds[v] < p.fi) continue; for (auto e : g[v]) { T nx = ds[v] + e.cost; if (ds[e.to] > nx) { ds[e.to] = nx; que.emplace(nx, e.to); } } } for (auto& x : ds) if (x == inf) x = -1; return ds; } // allow multiple edges and self loops, multiple components template struct EulerianTrail : Graph { public: using Graph::g; using Graph::Graph; using Graph::edges; using Graph::es; using E = Edge; V used_vertex, used_edge, deg; void init(int n) { deg.assign(n, 0); used_vertex.assign(n, 0); } void add_directed_edge(int from, int to, T cost = 1) { g[from].emplace_back(from, to, cost, es++); deg[from]++; deg[to]--; } void add_edge(int from, int to, T cost = 1) { g[from].emplace_back(from, to, cost, es); g[to].emplace_back(to, from, cost, es++); deg[from]++; deg[to]++; } EulerianTrail(int n) : Graph(n), used_vertex(n), deg(n) {} E get_edge(int idx) const { return edges[idx]; } /* vector> enumerate_eulerian_trail() { if (directed) { for (auto& p : deg) if (p != 0) return {}; } else { for (auto& p : deg) if (p & 1) return {}; } used_edge.assign(M, 0); vector> ret; for (int i = 0; i < (int)g.size(); i++) { if (g[i].empty() || used_vertex[i]) continue; ret.emplace_back(go(i)); } return ret; }*/ VV enumerate_semi_eulerian_trail() { unionfind uf(g.size()); for (auto& e : edges) { uf.unite(e.from, e.to); } VV group(g.size()); rep(i, g.size()) group[uf.find(i)].push_back(i); VV res; used_edge.assign(es, 0); for (auto& vs : group) { if (!SZ(vs)) continue; int s = -1, t = -1; if (directed) { for (auto& v : vs) { if (abs(deg[v]) > 1) { return {}; } else if (deg[v] == 1) { if (s != -1) return {}; s = v; } } } else { for (auto& v : vs) { if (deg[v] & 1) { if (s == -1) s = v; else if (t == -1) t = v; else return {}; } } } debug(s, t); if (s == -1) s = vs[0]; res.emplace_back(go(s)); if (!SZ(res.back())) res.pop_back(); } return res; } // return {id of edges} V go(int s) { stack> st; V ord; st.emplace(s, -1); while (!st.empty()) { int idx = st.top().first; used_vertex[idx] = true; if (g[idx].empty()) { ord.emplace_back(st.top().second); st.pop(); } else { auto e = g[idx].back(); g[idx].pop_back(); if (used_edge[e.idx]) continue; used_edge[e.idx] = true; st.emplace(e.to, e.idx); } } ord.pop_back(); reverse(ord.begin(), ord.end()); return ord; } }; int main() { int N, M; cin >> N >> M; V A(M), B(M); EulerianTrail g(N); g.read(M, 0); auto res = g.enumerate_semi_eulerian_trail(); debug(res); show(SZ(res) == 1 ? "YES" : "NO"); return 0; }