static void getAverageCountArray ( int [ ] a , int x , int N ) {
  HashMap < Integer , Integer > map = new HashMap < Integer , Integer > ( ) ;
  int [ ] avg = new int [ N ] ;
  int val , av ;
  for ( int i = 0 ;
  i < N ;
  i ++ ) {
    if ( ! map . containsKey ( a [ i ] ) ) {
      map . put ( a [ i ] , 1 ) ;
    }
    else {
      val = map . get ( a [ i ] ) ;
      val ++ ;
      map . remove ( a [ i ] ) ;
      map . put ( a [ i ] , val ) ;
    }
  }
  for ( int i = 0 ;
  i < N ;
  i ++ ) {
    av = ( a [ i ] + x ) / 2 ;
    if ( map . containsKey ( av ) ) {
      val = map . get ( av ) ;
      avg [ i ] = val ;
    }
  }
  for ( int i = 0 ;
  i < N ;
  i ++ ) {
    System . out . print ( avg [ i ] + " " ) ;
  }
}

static void getAverageCountArray ( int [ ] a , int x , int N ) { HashMap < Integer , Integer > map = new HashMap < Integer , Integer > ( ) ; int [ ] avg = new int [ N ] ; int val , av ; for ( int i = 0 ; i < N ; i ++ ) { if ( ! map . containsKey ( a [ i ] ) ) { map . put ( a [ i ] , 1 ) ; } else { val = map . get ( a [ i ] ) ; val ++ ; map . remove ( a [ i ] ) ; map . put ( a [ i ] , val ) ; } } for ( int i = 0 ; i < N ; i ++ ) { av = ( a [ i ] + x ) / 2 ; if ( map . containsKey ( av ) ) { val = map . get ( av ) ; avg [ i ] = val ; } } for ( int i = 0 ; i < N ; i ++ ) { System . out . print ( avg [ i ] + " ▁ " ) ; } }
(method_declaration (modifiers) type: (void_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: (generic_type (type_identifier) (type_arguments (type_identifier) (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments (type_identifier) (type_identifier))) arguments: (argument_list)))) (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))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier)) declarator: (variable_declarator name: (identifier))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (unary_expression operand: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier)))))) consequence: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier)) (decimal_integer_literal))))) alternative: (block (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier)))))) (expression_statement (update_expression (identifier))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier)) (identifier)))))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier))) right: (decimal_integer_literal)))) (if_statement condition: (parenthesized_expression (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier))))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (string_literal)))))))))