Calculate partial sums
incr [ i + 1 ] = incr [ i ] NEW_LINE if ( s [ i ] == '0' ) : NEW_LINE INDENT incr [ i + 1 ] = incr [ i + 1 ] + 1 NEW_LINE DEDENT for i in range ( 0 , n + 1 ) : NEW_LINE for j in range ( i + 1 , n ) : NEW_LINE