static boolean dp ( List < Integer > list , int goal ) {
  Set < Integer > set = new HashSet < > ( ) , buf = new HashSet < > ( ) ;
  set . add ( 0 ) ;
  for ( int v : list ) {
    buf . clear ( ) ;
    for ( int base : set ) {
      buf . add ( base + v ) ;
      buf . add ( base - v ) ;
    }
    set . clear ( ) ;
    set . addAll ( buf ) ;
  }
  return set . contains ( goal ) ;
}

static boolean dp ( List < Integer > list , int goal ) { Set < Integer > set = new HashSet < > ( ) , buf = new HashSet < > ( ) ; set . add ( 0 ) ; for ( int v : list ) { buf . clear ( ) ; for ( int base : set ) { buf . add ( base + v ) ; buf . add ( base - v ) ; } set . clear ( ) ; set . addAll ( buf ) ; } return set . contains ( goal ) ; }
(method_declaration (modifiers) type: (boolean_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (generic_type (type_identifier) (type_arguments (type_identifier))) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments)) arguments: (argument_list))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments)) arguments: (argument_list)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal)))) (enhanced_for_statement type: (integral_type) name: (identifier) value: (identifier) body: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) (enhanced_for_statement type: (integral_type) name: (identifier) value: (identifier) body: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier))))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))))) (return_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))))