static int memo ( int index , int evenSum , int oddSum , int tight ) {
  if ( index == v . size ( ) ) {
    if ( evenSum > oddSum ) {
      return 1 ;
    }
    else {
      return 0 ;
    }
  }
  if ( dp [ index ] [ evenSum ] [ oddSum ] [ tight ] != - 1 ) {
    return dp [ index ] [ evenSum ] [ oddSum ] [ tight ] ;
  }
  int limit = ( tight > 0 ) ? v . get ( index ) : 9 ;
  int ans = 0 ;
  for ( int d = 0 ;
  d <= limit ;
  d ++ ) {
    int currTight = 0 ;
    if ( d == v . get ( index ) ) {
      currTight = tight ;
    }
    if ( d % 2 != 0 ) {
      ans += memo ( index + 1 , evenSum , oddSum + d , currTight ) ;
    }
    else {
      ans += memo ( index + 1 , evenSum + d , oddSum , currTight ) ;
    }
  }
  dp [ index ] [ evenSum ] [ oddSum ] [ tight ] = ans ;
  return ans ;
}

static int memo ( int index , int evenSum , int oddSum , int tight ) { if ( index == v . size ( ) ) { if ( evenSum > oddSum ) { return 1 ; } else { return 0 ; } } if ( dp [ index ] [ evenSum ] [ oddSum ] [ tight ] != - 1 ) { return dp [ index ] [ evenSum ] [ oddSum ] [ tight ] ; } int limit = ( tight > 0 ) ? v . get ( index ) : 9 ; int ans = 0 ; for ( int d = 0 ; d <= limit ; d ++ ) { int currTight = 0 ; if ( d == v . get ( index ) ) { currTight = tight ; } if ( d % 2 != 0 ) { ans += memo ( index + 1 , evenSum , oddSum + d , currTight ) ; } else { ans += memo ( index + 1 , evenSum + d , oddSum , currTight ) ; } } dp [ index ] [ evenSum ] [ oddSum ] [ tight ] = 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)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) consequence: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (return_statement (decimal_integer_literal))) alternative: (block (return_statement (decimal_integer_literal)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (array_access array: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) index: (identifier)) index: (identifier)) right: (unary_expression operand: (decimal_integer_literal)))) consequence: (block (return_statement (array_access array: (array_access array: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) index: (identifier)) index: (identifier))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (ternary_expression condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) alternative: (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (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: (decimal_integer_literal))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (method_invocation name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)) (identifier) (binary_expression left: (identifier) right: (identifier)) (identifier)))))) alternative: (block (expression_statement (assignment_expression left: (identifier) right: (method_invocation name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)) (binary_expression left: (identifier) right: (identifier)) (identifier) (identifier))))))))) (expression_statement (assignment_expression left: (array_access array: (array_access array: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) index: (identifier)) index: (identifier)) right: (identifier))) (return_statement (identifier))))