Prompt and non-prompt J/ψ production cross sections at midrapidity in proton-proton collisions at √s = 5.02 and 13 TeV