using System.Collections.Generic; using System.Linq; using System; public class UnionFind { private int[] data; public UnionFind(int size) { data = new int[size]; for (int i = 0; i < size; i++) data[i] = -1; } public bool Unite(int x, int y) { x = Root(x); y = Root(y); if (x != y) { if (data[y] < data[x]) { var tmp = y; y = x; x = tmp; } data[x] += data[y]; data[y] = x; } return x != y; } public bool IsSameGroup(int x, int y) { return Root(x) == Root(y); } private int Root(int x) { return data[x] < 0 ? x : data[x] = Root(data[x]); } } public class Hello { public static void Main() { string[] line = Console.ReadLine().Trim().Split(' '); var n = int.Parse(line[0]); var m = int.Parse(line[1]); var a = new List[n]; for (int i = 0; i < n; i++) a[i] = new List(); var uf = new UnionFind(n); line = Console.ReadLine().Trim().Split(' '); var s1 = int.Parse(line[0]); var s2 = int.Parse(line[1]); a[s1].Add(s2); a[s2].Add(s1); uf.Unite(s1, s2); var start = s1; for (int i = 1; i < m; i++) { line = Console.ReadLine().Trim().Split(' '); s1 = int.Parse(line[0]); s2 = int.Parse(line[1]); a[s1].Add(s2); a[s2].Add(s1); uf.Unite(s1, s2); } for (int i = 0; i < n; i++) if (a[i].Count() > 0 && !uf.IsSameGroup(start, i)) { Console.WriteLine("NO"); goto end; } if (!checkE(a)) { Console.WriteLine("NO"); goto end; } Console.WriteLine("YES"); end:; } public static bool checkE(List[] a) { var n = a.Length; var count = 0; for (int i = 0; i < n; i++) if (a[i].Count() % 2 == 1) count++; if (count == 0 | count == 2) return true; else return false; } }