Let x be the size of the small room and 2x, the big room
The larger room requires 3 coats and the smaller, 2 coats
All requires exactly 8 gal.
2.x + (2x).3 = 8 Gal, 8x = 8 and x = 1 (size of te smallest)
if it's the small room, then it will need 2 coats or 2x1 = 2 Gal, and the paint left is 8-2 = 6 Gal.
if it's the large one, 6x or 6 Gal, and remaining 2 Gal