The correct option is A (M−m)g(M+m+ 2Ir2)
Since the pulleys in the question are not massless, the tension in the string cannot be uniform. There should be different tensions in each part of the string to account for the torque required for the angular acceleration of the pulleys.
Let the acceleration of the boxes be a and the angular acceleration of the pulleys be α
Let the tension in the portion of the string attached to M be T1
Let the tension in the portion of the string between the pulleys be T2
Let the tension in the portion of the string attached to m be T3
Since the rope does not slip on the pulleys, a=rα
Examining the forces on M, Mg−T1=Ma - (1)
Examining the forces on m, T3−mg=ma - (2)
Examining the torque acting on the right pulley, (T1−T2)r=Iar - (3)
Examining the torque acting on the left pulley, (T2−T3)r=Iar - (4)
Adding (1) and (2), T3−T1=(M+m)a+(m−M)g - (5)
Adding (3) and (4), T1−T3=2Iar2 - (6)
Adding (5) and (6), a(2Ir2+(M+m))=(M−m)g
=> a=(M−m)g(M+m+2Ir2)