Engine light blinking diagnostic - G6 1.6 2001


I have a Toyota Corolla G6 1.6 2001, 210k km and it's been running well so far (apart from oil consumption haha!) but I've had some problem lately and I'm trying to narrow down what could be wrong, here is my "diagnostic" so far:

1. The engine light came on (not blinking).
2. I've checked the OBD2 code, got P0171 "System Too Lean" - I thought I would erase the code for now and wait if it comes back to check if it was a sensor problem.
3. Everything was fine for a while, I drove probably an other 200-300km
4. The engine light came on bliking this time, everytime I would push the gaz a bit (and the car would lose power). Then it would turn off when I wasn't accelerating too much. Basically as soon as the car needed to accelerate a bit more (going uphill or highway) it would turn on and the car loses power. (Haven't got the chance to read the OBD2 again)

Do you have any idea what to look at?

Thanks a lot!