Songs that get stuck in your head help boost memory and could be used to treat dementia, a new study has found.