public static int solve ( int i , int j , int k ) {
  if ( dp [ i ] [ j ] [ k ] >= 0 ) return dp [ i ] [ j ] [ k ] ;
  else {
    int ans ;
    if ( i > j ) ans = 0 ;
    else if ( i == j ) ans = 1 ;
    else if ( s . charAt ( i ) == s . charAt ( j ) ) ans = solve ( i + 1 , j - 1 , k ) + 2 ;
    else {
      ans = solve ( i + 1 , j , k ) ;
      ans = Math . max ( ans , solve ( i , j - 1 , k ) ) ;
      if ( k > 0 ) ans = Math . max ( ans , solve ( i + 1 , j - 1 , k - 1 ) + 2 ) ;
    }
    dp [ i ] [ j ] [ k ] = ans ;
    return ans ;
  }
}

public static int solve ( int i , int j , int k ) { if ( dp [ i ] [ j ] [ k ] >= 0 ) return dp [ i ] [ j ] [ k ] ; else { int ans ; if ( i > j ) ans = 0 ; else if ( i == j ) ans = 1 ; else if ( s . charAt ( i ) == s . charAt ( j ) ) ans = solve ( i + 1 , j - 1 , k ) + 2 ; else { ans = solve ( i + 1 , j , k ) ; ans = Math . max ( ans , solve ( i , j - 1 , k ) ) ; if ( k > 0 ) ans = Math . max ( ans , solve ( i + 1 , j - 1 , k - 1 ) + 2 ) ; } dp [ i ] [ j ] [ k ] = ans ; return ans ; } }
(method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) index: (identifier)) right: (decimal_integer_literal))) consequence: (return_statement (array_access array: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) index: (identifier))) alternative: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) consequence: (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (method_invocation name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)) (binary_expression left: (identifier) right: (decimal_integer_literal)) (identifier))) right: (decimal_integer_literal)))) alternative: (block (expression_statement (assignment_expression left: (identifier) right: (method_invocation name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)) (identifier) (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (method_invocation name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (identifier) right: (decimal_integer_literal)) (identifier))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (method_invocation name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)) (binary_expression left: (identifier) right: (decimal_integer_literal)) (binary_expression left: (identifier) right: (decimal_integer_literal)))) right: (decimal_integer_literal))))))))))) (expression_statement (assignment_expression left: (array_access array: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) index: (identifier)) right: (identifier))) (return_statement (identifier))))))