Why Energy is not conserved? 
Two masses $\mathrm{A}$ and $\mathrm{B}$ each of $5~\mathrm{kg}$ are suspended by a light inextensible string passing over a smooth, massless pulley such that mass $\mathrm{A}$ rests on a smooth table and $\mathrm{B}$ is held at the position as shown. Mass $\mathrm{B}$ is now gently lifted up to the pulley and allowed to fall from rest. Determine up to what height will $\mathrm{A}$ rise for ensuing motion. 
Diagram - 
 

Now, let us consider the moment when the string is about to become taut(when $\mathrm{B}$ comes down by $1~\mathrm{m}$):
Just before the string becomes taut, the velocity of $\mathrm{B}$ is $\sqrt{2g}$.
CASE I: If we apply the concept of impulse and conservation of momentum:
Let impulse received by $\mathrm{A}$ be $P$. Then impulse received by $\mathrm{B}$ is $-P$ (Since the tension in a massless string is same everywhere)
So, $$V_\mathrm{A}=\frac{P}{5}$$ and  $$V_\mathrm{B} = \sqrt{(2g)} - \frac{P}{5} $$  
From constraints, $V_\mathrm{A}=V_\mathrm{B}$  
Solving, $$V_\mathrm{A}=\sqrt{\frac{g}{2}}$$  
Then we can proceed further...
CASE II: If we apply conservation of energy:  
$$\frac{1}{2} m V_{\mathrm{A,i}}^2 + \frac{1}{2} m V_{\mathrm{B,i}}^2 = \frac{1}{2} m V_{\mathrm{A,f}}^2 + \frac{1}{2} m V_{\mathrm{B,f}}^2$$  
Now , $V_{\mathrm{A,i}}= 0$ and $V_{\mathrm{B,i}} = \sqrt{2g}$
and by constraints $V_{\mathrm{A,f}}= V_{\mathrm{B,f}}$.
Thus, by solving we get $$V_{\mathrm{A,f}} =  V_{\mathrm{B,f}}=\sqrt{g}$$.
But why do CASE I and CASE II give different answers for $V_\mathrm{A}$ ?
 A: This is really an inelastic collision type problem with kinetic energy not conserved.
Energy is conserved but the difficulty is that having an ideal system of masses and string makes it appear that energy is not conserved.
To this end you have to allow either the masses or the string or both to be distorted.
If you do not allow that to happen then you would have the impossible situation when the string first becomes taut, that the left hand mass is not moving and the right hand mass is moving and yet the separation of the masses (length of the string) is not changing.
Another possibility is that the support for the pulley or the pulley itself distorts.  
Once you allow such distortions you could say that pulses/vibration are initiated and/or the distortions are permanent and these would account for the reduction in the kinetic energy.
A: The two masses are exactly the same. This means that the tension is equal to the weight of either of the two masses.
This system is already in equilibrium: the vincular reaction from the ground is zero. Then this equilibrium is somehow altered: B is lifted from height $h$by an amount $\Delta{h}$. If we set the zero potential at ground level, we get:
$$ mg(h + \Delta{h}) = \frac{1}{2}m{v_b}^2 + mgh$$
$$ \implies v_b = \sqrt{2g\Delta{h}} $$
At the exact time B gets back where it was it has gained this velocity. A must be lifted upwards. Only gravitational forces apply from now on, so this means total mechanical energy is conserved. Let $h_a, h_b$ be two numbers so that their sum is $h$. These are going to be the two vertical displacements of our masses. The following is true at every instant of time.
$$ \frac{1}{2}m{v_b}^2 + mgh = \frac{1}{2}m{v_{af}}^2 + mgh_a + \frac{1}{2}m{v_{bf}}^2 + mgh_b $$
Which simplifies down to:
$$ {v_{b}}^2 = {v_{af}}^2 + {v_{bf}}^2 $$
And as you have correctly stated, the velocities must be the same in magnitude. Wrapping it up:
$$ 2g\Delta{h} = 2{v_{af}}^2 $$
$$ v_{af} = \sqrt{g\Delta{h}}$$
Oh and of course this means A is going to stop at height $h + \Delta{h}$. But B reaches the ground before A, so it only stops at $h$. You get this result from the third last equation, setting $v_{af}$ and $v_{bf}$ to zero.
You could get this result by sheer force of reason. Think: the masses are equal, and we introduce energy into the system by lifting B. The only thing that could happen is the two masses switching places.
A: Case I gives the correct answer because momentum is being conserved in this solution. Kinetic energy is not necessarily conserved during a collision, but momentum must always be conserved. The constraint $V_A=V_B$ ensures that this collision is inelastic - ie that it will not conserve kinetic energy.
Case II is incorrect because it does not ensure that momentum is conserved : the final momentum is $2\sqrt{g}$ whereas the initial momentum is $\sqrt{2g}$. 
Although you have required that kinetic energy is conserved, this is not consistent with both the constraint $V_A=V_B$ and the conservation of momentum. These 3 constraints are mutually incompatible : one of them has to be violated. If you remove the unnecessary constraint $V_A=V_B$ then it is possible to conserve both momentum and kinetic energy. If you remove the constraint that KE is conserved, you get Case I.

@blue and I discussed this problem in the JEE Preparation chatroom. We disagreed over what the solution should be because we were accustomed to using different models for the string. The context in which the question was set (JEE) assumes that strings are totally inelastic (ie COR=0). The given solution confirms that the examiner expected this assumption to be made.
Real strings are to a substantial extent elastic, so a model in which the COR=1 is more realistic, as argued in the articles cited in my answer to Force Transfer Between two bodies linked by a rope. Experiments by Roper and Hartley found COR=0.65.  
I agree with Farcher that the elastic model is not incompatible with the string being inextensible, for the reasons given by Farcher. No real string can be massless, but we use this approximation routinely. In the same way, a string can be elastic but so stiff that it is - for all practical purposes - inextensible.
