I am going to save you a lot of time reading this blog and just say the answer is "intake manifold gasket."
That's where this blog ends, but it is important to note that many technicians get too intimidated by system lean DTCs like the much feared P0171 and P0174 DTCs. Technicians better than me get confused between MAF and speed-density systems and overly complicate system lean diagnostics.
For example, I have heard of more than one technician smoking the older speed-density Toyota Corollas looking for "vacuum leaks." At this point I do not need to even ask why... they have a lean code. The problem is, vehicles that do not use a MAF sensor to determine air flow run rich when they have a vacuum leak, not lean.
It's theoretical problems like this that often make not-so-bad cars turn into nightmares-from-hell trouble cars. Even though MAF systems like the newer Corollas and Matrixes with the 1G-GZE engines are "simpler," they are only simpler because many of our diagnostic assumptions presume the vehicle is a MAF-system to begin with. However, on these simpler systems I can see people getting confused on them too.
Take for example Corollas with a 1G-GZE engine throwing a P0171. These vehicles have a lot of MAF sensors that go bad. They also have a recall for PCMs.
Both of the preceding component failures can set the DTC. So, usually a technician will smoke the car, find no leaks, go WOT and check volumetric efficiency on generic OBD II. If volumetric efficiency is below 90 percent he removes the MAF sensor. If it looks "kinda" dirty, he replaces it.
If volumetric efficiency is good, the same technician calls the dealer to find out if the recall was done on the PCM. If so, he probably still throws a MAF sensor at it anyway.
Then, months can pass and the tech looks like a genius, because the code will never come back, until it does, of course.
Be sure to check Freeze Frame when you have a P0171 system lean DTC on one of these vehicles. If the long term fuel trim on the vehicle is below +/- 7 percent, but in Freeze Frame is elevated and setting at a low engine temperature, then you have bad intake manifold gasket that you will never catch.
Why? For some reason, smoke will never be found when you have this problem. Maybe CO2 gas and an emissions analyzer will catch the leak. But even if you get the Toyota ice cold, you might not catch it. Normal temperatures will cause thermal expansion in the gasket and seal the leak.
So, next time you see this DTC, know what you are looking at with fuel trims and volumetric efficiency. With them lies your answer as to whether the problem is the MAF or the intake manifold gasket.