public static int binarysearch ( int [ ] price , long m , int start ) {
  int left = start ;
  int right = price . length - 1 ;
  while ( left <= right ) {
    int mid = ( left + right ) / 2 ;
    if ( price [ mid ] == m ) {
      while ( mid + 1 < price . length - 1 && price [ mid ] == price [ mid + 1 ] ) return binarysearch ( price , m , mid + 1 ) ;
      return mid + 1 ;
    }
    else if ( price [ mid ] < m ) left = mid + 1 ;
    else right = mid - 1 ;
  }
  while ( left < price . length - 1 && price [ left - 1 ] == price [ left ] ) return binarysearch ( price , m , left ) ;
  return left ;
}

public static int binarysearch ( int [ ] price , long m , int start ) { int left = start ; int right = price . length - 1 ; while ( left <= right ) { int mid = ( left + right ) / 2 ; if ( price [ mid ] == m ) { while ( mid + 1 < price . length - 1 && price [ mid ] == price [ mid + 1 ] ) return binarysearch ( price , m , mid + 1 ) ; return mid + 1 ; } else if ( price [ mid ] < m ) left = mid + 1 ; else right = mid - 1 ; } while ( left < price . length - 1 && price [ left - 1 ] == price [ left ] ) return binarysearch ( price , m , left ) ; return left ; }
(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)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (decimal_integer_literal)))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (decimal_integer_literal)))) (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier))) consequence: (block (while_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (decimal_integer_literal))) right: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal)))))) body: (return_statement (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier) (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (return_statement (binary_expression left: (identifier) right: (decimal_integer_literal)))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier))) consequence: (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))) alternative: (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))))))) (while_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (decimal_integer_literal))) right: (binary_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (array_access array: (identifier) index: (identifier))))) body: (return_statement (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier) (identifier))))) (return_statement (identifier))))