static int upper_bound ( int arr [ ] , int x ) {
  int a = Arrays . binarySearch ( arr , x ) ;
  if ( a < 0 ) {
    a *= ( - 1 ) ;
    return a - 1 ;
  }
  else {
    while ( a < arr . length && arr [ a ] == x ) ++ a ;
    return a ;
  }
}

static int upper_bound ( int arr [ ] , int x ) { int a = Arrays . binarySearch ( arr , x ) ; if ( a < 0 ) { a *= ( - 1 ) ; return a - 1 ; } else { while ( a < arr . length && arr [ a ] == x ) ++ a ; return a ; } }
(method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier) dimensions: (dimensions)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (parenthesized_expression (unary_expression operand: (decimal_integer_literal))))) (return_statement (binary_expression left: (identifier) right: (decimal_integer_literal)))) alternative: (block (while_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (field_access object: (identifier) field: (identifier))) right: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier)))) body: (expression_statement (update_expression (identifier)))) (return_statement (identifier))))))