I was doing a Putnam problem whose solution stated that $$\displaystyle \int_0^{2\pi}\prod_{k=1}^m \left(e^{ikx} + e^{-ikx}\right)dx = \sum_{e_k = \pm 1}\int_0^{2\pi}e^{ix(e_1+2e_2+...+me_m)}dx,$$ over all $2^m$ $m$-tuples $(e_1, e_2, ..., e_m)$.
Where exactly does this come from?
It is really just an expansion of the product. Say $m=2$. Then $$(e^{i1x}+e^{-i1x})(e^{i2x}+e^{-i2x})=e^{ix(1+2)}+e^{ix(1-2)}+e^{ix(-1+2)}+e^{ix(-1-2)}$$ In the general case you need to add all terms $e^{ix(\pm1\pm2\pm3\pm...\pm m)}$