public static long calc ( long A , long B ) {
  if ( A == B ) {
    return 1 ;
  }
  long ans = 0 ;
  long k = 1 ;
  for ( int i = 0 ;
  i <= 60 ;
  i ++ ) {
    k = k * 2 ;
  }
  while ( ( A & k ) == ( B & k ) ) {
    A = ( A | k ) ^ k ;
    B = ( B | k ) ^ k ;
    k = k / 2 ;
  }
  long s1 = k - A ;
  long s2 = k - A ;
  long s3 = maxbit ( B - k ) ;
  ans = s1 + s2 + s3 ;
  long rb = k + s3 - 1 ;
  long lb = k + A ;
  if ( rb >= lb ) {
    ans = ans - ( rb - lb + 1 ) ;
  }
  return ans ;
}

public static long calc ( long A , long B ) { if ( A == B ) { return 1 ; } long ans = 0 ; long k = 1 ; for ( int i = 0 ; i <= 60 ; i ++ ) { k = k * 2 ; } while ( ( A & k ) == ( B & k ) ) { A = ( A | k ) ^ k ; B = ( B | k ) ^ k ; k = k / 2 ; } long s1 = k - A ; long s2 = k - A ; long s3 = maxbit ( B - k ) ; ans = s1 + s2 + s3 ; long rb = k + s3 - 1 ; long lb = k + A ; if ( rb >= lb ) { ans = ans - ( rb - lb + 1 ) ; } return ans ; }
(method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (return_statement (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: (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (while_statement condition: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))))) body: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier)))))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (decimal_integer_literal)))))))) (return_statement (identifier))))