The first is actually creativity, because it's during REM sleep and dreaming specifically when the brain starts to collide all of the information that you've recently learned together with all of this back catalog of autobiographical information that you've got stored up in the brain.
Why your brain needs to dream
Everything you need to know about dreaming and how to have a good night sleep.