static int minCostRec ( int cost [ ] [ ] , int s , int d ) {
  if ( s == d || s + 1 == d ) return cost [ s ] [ d ] ;
  int min = cost [ s ] [ d ] ;
  for ( int i = s + 1 ;
  i < d ;
  i ++ ) {
    int c = minCostRec ( cost , s , i ) + minCostRec ( cost , i , d ) ;
    if ( c < min ) min = c ;
  }
  return min ;
}

static int minCostRec ( int cost [ ] [ ] , int s , int d ) { if ( s == d || s + 1 == d ) return cost [ s ] [ d ] ; int min = cost [ s ] [ d ] ; for ( int i = s + 1 ; i < d ; i ++ ) { int c = minCostRec ( cost , s , i ) + minCostRec ( cost , i , d ) ; if ( c < min ) min = c ; } return min ; }
(method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier) dimensions: (dimensions)) (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (identifier)))) consequence: (return_statement (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier) (identifier))) right: (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier) (identifier)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (expression_statement (assignment_expression left: (identifier) right: (identifier)))))) (return_statement (identifier))))