By analyzing the given codes:
- '786' means Study very hard, where '7' corresponds to Study, '8' to very, and '6' to hard.
- '958' means Hard work pays, where '9' corresponds to hard, '5' to work, and '8' to pays.
- '645' means Study and work, where '6' corresponds to Study, '4' to and, and '5' to work.
From this, we can conclude that the code for 'very' is '7'.
Thus, the correct answer is 7.