Fill prefix array
for i in range ( 1 , N + 1 ) : NEW_LINE INDENT if ( st [ i - 1 ] == ' a ' ) : NEW_LINE INDENT prefix_a [ i ] = ( prefix_a [ i - 1 ] + 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT prefix_a [ i ] = prefix_a [ i - 1 ] NEW_LINE DEDENT if ( st [ i - 1 ] == ' b ' ) : NEW_LINE INDENT prefix_b [ i ] = ( prefix_b [ i - 1 ] + 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT prefix_b [ i ] = prefix_b [ i - 1 ] NEW_LINE DEDENT if ( st [ i - 1 ] == ' c ' ) : NEW_LINE INDENT prefix_c [ i ] = ( prefix_c [ i - 1 ] + 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT prefix_c [ i ] = prefix_c [ i - 1 ] NEW_LINE DEDENT DEDENT