def select_best_block(blocks):
<EOL>if not blocks:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>best_block = max(blocks, key=lambda b: b[<NUM_LIT:1>]['<STR_LIT>'])<EOL>if best_block[<NUM_LIT:1>]['<STR_LIT>'] == <NUM_LIT:0>:<EOL><INDENT>best_block = max(blocks,<EOL>key=lambda b: (b[<NUM_LIT:1>]['<STR_LIT>'] + b[<NUM_LIT:1>]['<STR_LIT>'] + b[<NUM_LIT:1>]['<STR_LIT>'],<EOL>b[<NUM_LIT:1>]['<STR_LIT>'], b[<NUM_LIT:1>]['<STR_LIT>'], b[<NUM_LIT:1>]['<STR_LIT>']))<EOL><DEDENT>return best_block[<NUM_LIT:0>]<EOL>
Return best block selected based on simple heuristic.