public static long solve ( int [ ] u , int [ ] v ) {
  int n = u . length + 1 ;
  List < Integer > [ ] adjLists = new List [ n ] ;
  for ( int i = 0 ;
  i < adjLists . length ;
  i ++ ) {
    adjLists [ i ] = new ArrayList < > ( ) ;
  }
  for ( int i = 0 ;
  i < u . length ;
  i ++ ) {
    adjLists [ u [ i ] - 1 ] . add ( v [ i ] - 1 ) ;
    adjLists [ v [ i ] - 1 ] . add ( u [ i ] - 1 ) ;
  }
  count1 = 0 ;
  count2 = 0 ;
  search ( adjLists , new boolean [ n ] , 0 , true ) ;
  return ( long ) count1 * count2 - ( n - 1 ) ;
}

public static long solve ( int [ ] u , int [ ] v ) { int n = u . length + 1 ; List < Integer > [ ] adjLists = new List [ n ] ; for ( int i = 0 ; i < adjLists . length ; i ++ ) { adjLists [ i ] = new ArrayList < > ( ) ; } for ( int i = 0 ; i < u . length ; i ++ ) { adjLists [ u [ i ] - 1 ] . add ( v [ i ] - 1 ) ; adjLists [ v [ i ] - 1 ] . add ( u [ i ] - 1 ) ; } count1 = 0 ; count2 = 0 ; search ( adjLists , new boolean [ n ] , 0 , true ) ; return ( long ) count1 * count2 - ( n - 1 ) ; }
(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: (array_type element: (integral_type) dimensions: (dimensions)) name: (identifier))) body: (block (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)))) (local_variable_declaration type: (array_type element: (generic_type (type_identifier) (type_arguments (type_identifier))) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (type_identifier) dimensions: (dimensions_expr (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: (field_access object: (identifier) field: (identifier))) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (object_creation_expression type: (generic_type (type_identifier) (type_arguments)) arguments: (argument_list)))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (field_access object: (identifier) field: (identifier))) update: (update_expression (identifier)) body: (block (expression_statement (method_invocation object: (array_access array: (identifier) index: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) name: (identifier) arguments: (argument_list (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))))) (expression_statement (method_invocation object: (array_access array: (identifier) index: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) name: (identifier) arguments: (argument_list (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))))))) (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))) (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))) (expression_statement (method_invocation name: (identifier) arguments: (argument_list (identifier) (array_creation_expression type: (boolean_type) dimensions: (dimensions_expr (identifier))) (decimal_integer_literal) (true)))) (return_statement (binary_expression left: (binary_expression left: (cast_expression type: (integral_type) value: (identifier)) right: (identifier)) right: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal)))))))