Seol mar théacs é seo: Induced subgraph density. II. Sparse and dense sets in cographs