public static int binaryIndexedTree ( int [ ] bit , int val ) {
  int res = 0 ;
  int value = val ;
  while ( val > 0 ) {
    res = Math . max ( bit [ val ] , res ) ;
    val -= ( - val ) & val ;
  }
  res ++ ;
  val = value ;
  while ( val < bit . length ) {
    bit [ val ] = Math . max ( bit [ val ] , res ) ;
    val += ( - val ) & val ;
  }
  return res ;
}

public static int binaryIndexedTree ( int [ ] bit , int val ) { int res = 0 ; int value = val ; while ( val > 0 ) { res = Math . max ( bit [ val ] , res ) ; val -= ( - val ) & val ; } res ++ ; val = value ; while ( val < bit . length ) { bit [ val ] = Math . max ( bit [ val ] , res ) ; val += ( - val ) & val ; } return res ; }
(method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (integral_type) dimensions: (dimensions)) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (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: (identifier))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) body: (block (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier)) (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (parenthesized_expression (unary_expression operand: (identifier))) right: (identifier)))))) (expression_statement (update_expression (identifier))) (expression_statement (assignment_expression left: (identifier) right: (identifier))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (field_access object: (identifier) field: (identifier)))) body: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier)) (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (parenthesized_expression (unary_expression operand: (identifier))) right: (identifier)))))) (return_statement (identifier))))