An apple and cupcake are around the same size if you compare them in that respect.
As for energy, a cupcake gives you a lot of energy at that moment, called a “sugar rush”. But an apple has more fat and protein, giving you more energy an hour or a bit more later, but the apple’s energy will not drop off later leaving you feeling fatigued unlike the cupcake.