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); var start = 0; var getstart = false; for (int i = 1; i < m; i++) { line = Console.ReadLine().Trim().Split(' '); var s1 = int.Parse(line[0]); var s2 = int.Parse(line[1]); if (!getstart) { start = s1; getstart = true; } a[s1].Add(s2); a[s2].Add(s1); uf.Unite(s1, s2); } var count = 0; for (int i = 0; i < n; i++) { if (a[i].Count() > 0 && !uf.IsSameGroup(start, i)) { Console.WriteLine("NO"); goto end; } if (a[i].Count() % 2 == 1) count++; } if (!(count == 0 | count == 2)){ Console.WriteLine("NO"); goto end; } Console.WriteLine("YES"); end:; } }