when block B rises a distance $x$, block A falls a distance $2x$ and block B's speed will be half of block A's speed. Let the vertical separation of $3x=h$ and let the zero for gravitational potential energy be located at both blocks' initial rest position.

total final energy = total initial energy

$U_B + K_B + U_A + K_A = 0$

$mgx + \dfrac{1}{2}m\left(\dfrac{v}{2}\right)^2 - mg(2x) + \dfrac{1}{2}mv^2 = 0$

collect terms and simplify ...

$\dfrac{5v^2}{8} = gx$

multiply every term by $3$ ...

$\dfrac{15v^2}{8} = 3gx$

since $h = 3x$ ...

$\dfrac{15v^2}{8} = gh$

$v^2 = \dfrac{8gh}{15} \implies v = \sqrt{\dfrac{8gh}{15}}$