Note: There are other possible methods for solving this problem, including among them different choices for the reference of PE. The value of PE is not important. It is the DIFFERENCE of PE that is essential in these calculations. No matter where you choose your 0, your change in PE should be the same as here. You might have a different value for total initial energy because of your choice of 0, but it should work its way out by the end of the problem.
First we find the initial amount of energy we have in the system:
Initial Conditions: Block A: set h=0 where it starts
Initial Conditions: Block B: set h=0 where block ends up
Total Initial Energy of the System: 804J + 5.0J = 809J
Final Conditions: Conservation of energy tells us that we must account for 809J. Some will be lost to friction between block A and the ramp, while the rest will be converted between PE and KE
Energy lost to friction:
We now add that number to the total initial energy to see how much energy we have left to split between KE and PE. 809J-96.3J=713J
We now subrtract off the PE that the two blocks have from the energy left over: 713J-112.4J=600J
This energy can now be split up between the two blocks in the form of KE. The velocity of the blocks is the same because they are connected by the string.