and related expenses Any amount determined with respect to an individual under subparagraph (A) which is attributable to a Federal Pell Grant under section 401 of the Higher Education Act of 1965 shall be reduced (but not below zero) by the amount of the expenses (other than qualified tuition and related expenses) which are taken into account in determining the cost of attendance (as defined in section 472 of the Higher Education Act of 1965, as in effect on the date of the enactment of the Expand American Educational Opportunity Act of 2017 ) of such individual at an eligible educational institution for the academic period for which the credit under this section is being determined. (4) Treatment of expenses paid by dependent If a deduction under section 151 with respect to an individual is allowed to another taxpayer for a taxable year beginning in the calendar year in which such individual’s taxable year begins— (A) no credit shall be allowed under this section to such individual for such individual’s taxable year, and (B) qualified tuition and related expenses paid by such individual during such individual’s taxable year shall be treated for purposes of this section as paid by such other taxpayer. (5) Treatment of certain prepayments If qualified tuition and related expenses are paid by the taxpayer during a taxable year for an academic period which begins during the first 3 months following such taxable year, such academic period shall be treated for purposes of this section as beginning during such taxable year. (6) Denial of double benefit No credit shall be allowed under this section for any expense for which a deduction is allowed under any other provision of this chapter. (7) No credit for married individuals filing separate returns If the taxpayer is a married individual (within the meaning of section 7703), this section shall apply only if the taxpayer and the taxpayer’s spouse file a joint return for the taxable year. (8) Nonresident aliens If the taxpayer is a nonresident alien individual for any