Universal resources for quantum approximate optimization algorithm and quantum annealing