Why would a carved pumpkin rot? Also, where would the energy of the pumpkin originally come from?

the pumpkin would rot because bateria would be eating away at it.

the pumpkin's energy would originally come from the sun.