There are two transactions involved on the deployment of a contract into the blockchain.
The code itself, the class or jar file, is a data cloud transaction. Nothing special about it.
The second one is a "contract reference" transaction. This links the account, the name and the setup parameters for the contract to the contract code itself. The account is just the sender of the transaction. The "contract reference" transaction includes the name given to the contract (note that this is independent from the code itself), where to find the code (the full hash of the data cloud transaction) and the setup parameters if any.
Back to your example:
R1 was upload by some account (let's say A), so it cannot be used by any other account. v4 and v5 of the contract would be different data cloud transactions. They could be from any account.
Then account A can set a contract reference pointing to v4 code. And account B can set one pointing to v5 code. They can use any name they want, that's inside the contract reference transaction. Note that names only matter for contract references in the same account.
When there are multiple contract reference on the same account with the same contract name the most recent is used. That's how you deploy a new contract version on the same account.
To wrap up, this is what a contract reference transaction contains:
Here you can see the name, the parameters and the full hash (what's referred as contract) of the contract code. The account that sent this contract reference transactions is the one that will be running this contract.