A simple model for the evolution of molecular codes driven by the interplay of accuracy, diversity and cost