static int solve ( int freq [ ] ) {
  int n = 0 ;
  int max_freq = 0 ;
  int first = 0 ;
  int flag = 0 ;
  for ( int i = 0 ;
  i < 26 ;
  i ++ ) {
    n += freq [ i ] ;
    if ( freq [ i ] != 0 && flag == 0 ) {
      first = freq [ i ] ;
      flag = 1 ;
    }
    if ( max_freq < freq [ i ] ) {
      max_freq = freq [ i ] ;
    }
  }
  if ( n == 0 ) {
    return 0 ;
  }
  if ( first != max_freq ) {
    flag = 1 ;
  }
  else {
    flag = 0 ;
  }
  return Math . min ( ( n - 1 ) / 2 , n - max_freq - flag ) ;
}

static int solve ( int freq [ ] ) { int n = 0 ; int max_freq = 0 ; int first = 0 ; int flag = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) { n += freq [ i ] ; if ( freq [ i ] != 0 && flag == 0 ) { first = freq [ i ] ; flag = 1 ; } if ( max_freq < freq [ i ] ) { max_freq = freq [ i ] ; } } if ( n == 0 ) { return 0 ; } if ( first != max_freq ) { flag = 1 ; } else { flag = 0 ; } return Math . min ( ( n - 1 ) / 2 , n - max_freq - flag ) ; }
(method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier) dimensions: (dimensions))) 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: (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: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal)) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (array_access array: (identifier) index: (identifier)))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (identifier)))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (return_statement (decimal_integer_literal)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal)))) alternative: (block (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))))) (return_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (decimal_integer_literal)) (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier)))))))