private static long trySearch ( int limit ) {
  byte [ ] ways = new byte [ limit ] ;
  for ( int i = cbrt ( limit - 1 ) ;
  i > 1 ;
  i -- ) {
    int cube = i * i * i ;
    for ( int j = Library . sqrt ( limit - 1 - cube ) ;
    j > 1 ;
    j -- ) {
      int index = cube + j * j ;
      ways [ index ] = ( byte ) Math . min ( ways [ index ] + 1 , TARGET_WAYS + 1 ) ;
    }
  }
  long result = 0 ;
  int count = 0 ;
  for ( int i = 0 ;
  i < ways . length ;
  i ++ ) {
    if ( ways [ i ] == TARGET_WAYS && Library . isPalindrome ( i ) ) {
      result += i ;
      count ++ ;
      if ( count == TARGET_COUNT ) return result ;
    }
  }
  return - 1 ;
}

private static long trySearch ( int limit ) { byte [ ] ways = new byte [ limit ] ; for ( int i = cbrt ( limit - 1 ) ; i > 1 ; i -- ) { int cube = i * i * i ; for ( int j = Library . sqrt ( limit - 1 - cube ) ; j > 1 ; j -- ) { int index = cube + j * j ; ways [ index ] = ( byte ) Math . min ( ways [ index ] + 1 , TARGET_WAYS + 1 ) ; } } long result = 0 ; int count = 0 ; for ( int i = 0 ; i < ways . length ; i ++ ) { if ( ways [ i ] == TARGET_WAYS && Library . isPalindrome ( i ) ) { result += i ; count ++ ; if ( count == TARGET_COUNT ) return result ; } } return - 1 ; }
(method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)))))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (identifier)))))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (identifier))))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (cast_expression type: (integral_type) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal)) (binary_expression left: (identifier) right: (decimal_integer_literal))))))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (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: (field_access object: (identifier) field: (identifier))) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (identifier))) (expression_statement (update_expression (identifier))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (return_statement (identifier))))))) (return_statement (unary_expression operand: (decimal_integer_literal)))))