static int check ( int i , int sum , int n , int k , int a [ ] , int dp [ ] [ ] ) {
  if ( sum <= 0 ) {
    return 0 ;
  }
  if ( i >= n ) {
    if ( sum == k ) {
      return 1 ;
    }
    return 0 ;
  }
  if ( dp [ i ] [ sum ] != - 1 ) {
    return dp [ i ] [ sum ] ;
  }
  dp [ i ] [ sum ] = check ( i + 1 , sum - 2 * a [ i ] , n , k , a , dp ) | check ( i + 1 , sum , n , k , a , dp ) ;
  dp [ i ] [ sum ] = check ( i + 1 , sum - ( i + 1 ) , n , k , a , dp ) | dp [ i ] [ sum ] ;
  dp [ i ] [ sum ] = check ( i + 1 , sum + i + 1 , n , k , a , dp ) | dp [ i ] [ sum ] ;
  return dp [ i ] [ sum ] ;
}

static int check ( int i , int sum , int n , int k , int a [ ] , int dp [ ] [ ] ) { if ( sum <= 0 ) { return 0 ; } if ( i >= n ) { if ( sum == k ) { return 1 ; } return 0 ; } if ( dp [ i ] [ sum ] != - 1 ) { return dp [ i ] [ sum ] ; } dp [ i ] [ sum ] = check ( i + 1 , sum - 2 * a [ i ] , n , k , a , dp ) | check ( i + 1 , sum , n , k , a , dp ) ; dp [ i ] [ sum ] = check ( i + 1 , sum - ( i + 1 ) , n , k , a , dp ) | dp [ i ] [ sum ] ; dp [ i ] [ sum ] = check ( i + 1 , sum + i + 1 , n , k , a , dp ) | dp [ i ] [ sum ] ; return dp [ i ] [ sum ] ; }
(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)) (formal_parameter type: (integral_type) name: (identifier) dimensions: (dimensions)) (formal_parameter type: (integral_type) name: (identifier) dimensions: (dimensions))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (return_statement (decimal_integer_literal)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (return_statement (decimal_integer_literal)))) (return_statement (decimal_integer_literal)))) (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (unary_expression operand: (decimal_integer_literal)))) consequence: (block (return_statement (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier))))) (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (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: (binary_expression left: (decimal_integer_literal) right: (array_access array: (identifier) index: (identifier)))) (identifier) (identifier) (identifier) (identifier))) right: (method_invocation name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)) (identifier) (identifier) (identifier) (identifier) (identifier)))))) (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (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: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal)))) (identifier) (identifier) (identifier) (identifier))) right: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier))))) (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (binary_expression left: (method_invocation name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)) (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (decimal_integer_literal)) (identifier) (identifier) (identifier) (identifier))) right: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier))))) (return_statement (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)))))