static boolean canSet ( int x , List < Integer > list ) {
  Set < Integer > set = new HashSet < > ( ) ;
  set . add ( 0 ) ;
  for ( int i : list ) {
    Set < Integer > newSet = new HashSet < > ( ) ;
    for ( int j : set ) {
      newSet . add ( j + i ) ;
      newSet . add ( j - i ) ;
    }
    set = newSet ;
  }
  return set . contains ( x ) ;
}

static boolean canSet ( int x , List < Integer > list ) { Set < Integer > set = new HashSet < > ( ) ; set . add ( 0 ) ; for ( int i : list ) { Set < Integer > newSet = new HashSet < > ( ) ; for ( int j : set ) { newSet . add ( j + i ) ; newSet . add ( j - i ) ; } set = newSet ; } return set . contains ( x ) ; }
(method_declaration (modifiers) type: (boolean_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (generic_type (type_identifier) (type_arguments (type_identifier))) 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)))) (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 (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)))) (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 (assignment_expression left: (identifier) right: (identifier))))) (return_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))))