The evolution of ideas by crowds and communities: Competition vs. cooperation