Element X gives off a green color when heated and element Y gives off red Which is higher energy?
You can answer this question by looking at the visible portion of the electromagnetic spectrum. The electromagnetic spectrum is arranged from left to right in order of increasing frequency and increasing energy of the electromagnetic waves.
So at the far left you have radio waves, very low frequency and very low energy, and at the far right gamma rays which have very high frequency and very high energy.
Now if you examine the visible portion of the spectrum you will see that it starts with red at the left, progressing to orange, yellow, green blue, and finally violet. So red has the lower energy while green has the higher energy when comparing the two colors.
While we think of red as a hot color and blue as a cool color, in terms of their relative energy blue is "hotter" than red.