Magnetism, superconductivity and charge density waves in two-dimensional crystals