If all students are assigned
if ( row >= len ( a ) ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT if ( dp [ mask ] != - 1 ) : NEW_LINE INDENT return dp [ mask ] NEW_LINE DEDENT ans = 0 NEW_LINE for i in range ( len ( a ) ) : NEW_LINE