Intake pipe is in great condition.
Did you take it off to inspect it?
So the Mazda Protege shop manual says the following are the possible causes of P0171 (page 1-02B-67, in attached file):
" Misfire
HO2S (front) deterioration
HO2S (front) heater malfunction
PRC solenoid valve malfunction
Pressure regulator malfunction
Fuel pump malfunction
Fuel filter clogged or restricted
Fuel leakage on fuel line from fuel delivery pipe and fuel pump
Fuel return hose clogged
Leakage from exhaust system
Purge solenoid valve malfunction
Purge solenoid hoses improper connection
Insufficient compression"
1. intake air leak/vacuum hoses. If the intake tube is intact, then the next likely culprit is a cracked or disconnected vacuum hose. Trace all of the hoses coming off the air intake+throttle body and inspect them for cracks and make sure they are securely connected. Alternately, you can try spraying starting fluid around the air intake and vacuum hoses--if there is a crack letting air in, the engine will temporarily rise in speed when starting fluid enters the intake air.
2. O2 sensor. The upstream oxygen sensor might be on the fritz. Testing it requires connecting to the OBDII port. Alternately, you can just replace it with one from RockAuto, though this is an expensive way to diagnose it.
3. MAF. The MAF might be dirty or malfunctioning. You can try cleaning it with a MAF cleaner. Monitoring its function also requires connecting to the OBDII port.
4. Purge solenoid valve. I've attached the inspection procedure below. It might be easier to clamp off the line going to the throttle body for a while to see if that causes the code to go away. An unlikely cause.
P0171 inspection procedure:
purge solenoid valve inspection procedure: