Initialize all the states of dp to - 1 memset ( dp , - 1 , sizeof ( dp ) ) ;
for i in range ( 505 ) : NEW_LINE INDENT for j in range ( 505 ) : NEW_LINE INDENT dp [ i ] [ j ] = - 1 NEW_LINE DEDENT DEDENT