Why does the coefficient of performance need to be calculated with $W + Q$? 
How much work must a heat pump with a COP of 2.50 do in order to extract 1.00 MJ of thermal energy from the outdoors (the cold reservoir)?

The first formula that came into my mind after reading this question is the 
$$COP=\frac{\lvert Q(\text{cool})\rvert}{\lvert W\rvert}$$
However, when I used the equation above, the answer that I got was 0.4 MJ instead of the answer given which is 0.67 MJ.
And then I tried various other ways to try and get the 0.67 MJ and only when I used this equation that I finally get the answer 0.67 MJ. 
$$COP=\frac{\lvert W+Q(\text{cool})\rvert}{\lvert W\rvert}$$
What I don't understand is that why do we need to add $W$ with $Q$? Or is it not the correct way after all? 
Would somebody explain this to me, please?
 A: The COP for a heat pump is the heat supplied/work consumed.
The heat supplied comes from two sources: the heat extracted from the cold reservoir (Q) and the  work done by the heat pump (W), this is why the W and Q must be added: The electrical energy consumed by the heat pump also contributes to heating.
Imagine a situation where Q = 0, that is, the heat sink is not providing heat, the COP would be 1, the heat pump can still provide heat but is no longer operating as a heat pump, more like a regular electrical heater. The heat supplied is equal to the electrical work supplied. This occurs in real life when the heat sink temp drops too low.
A: By definition, the COP of a heat pump or a refrigerator is the 'useful' heat carried by the machine divided by the 'work' consumed by the machine. A refrigerator lifts heat $Q_c$ from a cold reservoir (the cold box) at an expense of external work $W$, and dumps this $Q_h = Q_c + W$ into a hot reservoir. The 'useful' heat carried in this case is $Q_c$ and hence $COP = Q_c/W$. On the other hand, a heat pump picks heat $Q_c$ from a cold atmosphere, again at an expense of external work $W$ and dumps $Q_h = Q_c + W$ into the space which is to be heated. Hence the 'useful' effect in case of a heat pump is $Q_h$. Therefore, the COP of a heat pump is defined as $COP = Q_h/W = (Q_c + W)/W$.
