Hamiltonian cycles and paths with a prescribed set of edges in hypercubes and dense sets