Hmmm...I think you are somewhat misstating the issue....somewhat, because it must be an IRA-RMD that is distributed as a QCD in order to not be included for determining the medicare premium. And you must be age 70.5 or older to do that.
.......but no, 401k RMDs cannot be removed from the AGI/MAGI.
................if you re planning for making a QCD for 2016....you are somewhat correct, any "QCD" will not be included in your AGI.
...IF you were 70.5 or older in 2016, and some/or all of your IRA distribution went directly from the IRA to a Charity as a QCD, then that QCD amount (up to 100,000) will not be included in your AGI on a 2016 tax return..
No..it cannot come from a 401k's RMD, it must come from an IRA.
......IF your QCD is less than your IRA-RMD, then you need to make sure that you take out the remaining part of your RMD, to yourself, and that second part of your RMD will be taxed and included in your AGI.
......IF the QCD is greater than your IRA-RMD (up to 100,000), then none of that distribution is taxable nor included as being taxable in your AGI when you prepare your tax return. (it must be entered on your tax return, but it won't be included in your AGI)
In the end, your premium will be determined by your MAGI, and the MAGI will then be your AGI + (Tax-exempt interest and dividends (i.e.line 8b on a 1040 or 1040A))..................where any QCD ill not be in your AGI in the first place ...if you enter it properly in the software,.
_____________________________________________
Now, what some people can do (especially if they have no IRA) is make sure they take their 401k RMD first, and then roll-over some funds from the 401k into an IRA (or supplement an existing IRA), and then the next year they can take some or all of that IRA-RMD as a QCD. But any remaining $$ in the 401k are still subject to its own RMD the next year...which will be smaller since you removed some funds.
____________*Answers are correct to the best of my knowledge when posted, but should not be considered to be legal or official tax advice.*