Comments

hack test for problem A (VK Cup): n = 65538 m = 98305 and any edges which unite all 65536 vertices in one component.

let x be number of vertices in component

let y be number of edges in component

Who wrote if (x * (x - 1) / 2 != y) puts("NO") and used int32, failed on this test.