Your landlord sounds terrible. If in apt for 22 years, they are going to have to remove the carpet anyway because it is so old. The life of apt rugs is about 5 years.
I don't know if this is a single apt or a complex but a apt complex has a program such as YARDY that keeps tabs on how old the carpet is , etc. Most people move in and out of apts much shorter than 22 years.
Ask him/her this: If I didn't change the carpet and tile, is it not true you would had have to remove them anyway? Charging me for normal wear and tear of an apartment is unethical and illegal.
I don't know what state you live in but check the landlord tenant rules for your state. This is for AZ only:
ARS 33-1342. Rules and regulations
A. A landlord, from time to time, may adopt rules or regulations, however described, concerning the tenant's use and occupancy of the premises. Such rules or regulations are enforceable against the tenant only if: 5. They are not for the purpose of evading the obligations of the landlord.
Housing Counseling Hotline: (602) 262-7210 (602) 262-7210 (provides help to tenants about their rights and responsibilities)
Arizona Tenant Advocates: (480) 557-8905(480) 557-89