Sometimes the sensor part of the Mass Airflow Sensor gets dirty and causes a code because it can't get a proper read. So, you could be able to clean the sensor with some MAF cleaner. Be sure to follow the instructions.
Other times you will need to replace it. Some sensors are replaceable in the housing and some are not.
What you are driving, where you buy the replacement MAF and if it is a sensor replacement or the whole unit, will determine the cost.
How easy it is to replace can be easy or difficult depending on where it is mounted in the engine bay.