if previous count is odd , then multiply answer by ways [ prev_count - 1 ] . since one has already been reserved , remaining will be even . reduce prev_count = 0 , since we don 't need it now.
if prev_count & 1 : NEW_LINE INDENT ans = ( ans * ways [ prev_count - 1 ] ) % mod NEW_LINE count_vector [ i - 1 ] [ 1 ] = 0 NEW_LINE DEDENT else : NEW_LINE