In the common sign convention, the first law is written ΔU = Q − W: the change in internal energy equals heat added to the system minus work done by the system.
This equation expresses conservation of energy in thermodynamic form. Q is positive when heat enters the system, while W is positive when the system performs work on its surroundings. For pressure–volume work during expansion, W may be written PΔV under suitable constant-pressure conditions, giving ΔU = Q − PΔV.
The symbols matter. Internal energy U is a state function, so its change depends only on the initial and final states. Heat Q and work W are path-dependent transfers, not substances stored inside a system. The same change in U can therefore result from different combinations of heating and mechanical work.
A frequent source of confusion is the alternative convention ΔU = Q + W, in which W means work done on the system. That convention is also valid, but the question explicitly specifies the convention where work done by the system is subtracted.