public static long orNum ( long A , long B ) {
  long q = 1L << 59 ;
  for ( ;
  q > 0 ;
  q = q >> 1 ) {
    if ( ( A & q ) == 0 && ( B & q ) == 0 ) continue ;
    if ( ( A & q ) != 0 && ( B & q ) != 0 ) {
      A -= q ;
      B -= q ;
      continue ;
    }
    if ( ( A & q ) == 0 && ( B & q ) != 0 ) {
      break ;
    }
    if ( ( ( A & q ) != 0 && ( B & q ) == 0 ) ) {
      return 0 ;
    }
  }
  if ( A == B ) {
    return 1 ;
  }
  long ans = q - A ;
  ans = ans * 2 + 1 ;
  B -= q ;
  ans += Math . min ( A - 1 , orNum ( 1 , B ) ) ;
  return ans ;
}

public static long orNum ( long A , long B ) { long q = 1L << 59 ; for ( ; q > 0 ; q = q >> 1 ) { if ( ( A & q ) == 0 && ( B & q ) == 0 ) continue ; if ( ( A & q ) != 0 && ( B & q ) != 0 ) { A -= q ; B -= q ; continue ; } if ( ( A & q ) == 0 && ( B & q ) != 0 ) { break ; } if ( ( ( A & q ) != 0 && ( B & q ) == 0 ) ) { return 0 ; } } if ( A == B ) { return 1 ; } long ans = q - A ; ans = ans * 2 + 1 ; B -= q ; ans += Math . min ( A - 1 , orNum ( 1 , B ) ) ; 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 (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (decimal_integer_literal) right: (decimal_integer_literal)))) (for_statement condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (decimal_integer_literal)) right: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (decimal_integer_literal)))) consequence: (continue_statement)) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (decimal_integer_literal)) right: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (decimal_integer_literal)))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (identifier))) (expression_statement (assignment_expression left: (identifier) right: (identifier))) (continue_statement))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (decimal_integer_literal)) right: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (decimal_integer_literal)))) consequence: (block (break_statement))) (if_statement condition: (parenthesized_expression (parenthesized_expression (binary_expression left: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (decimal_integer_literal)) right: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (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 (return_statement (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal)))) (expression_statement (assignment_expression left: (identifier) right: (identifier))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)) (method_invocation name: (identifier) arguments: (argument_list (decimal_integer_literal) (identifier))))))) (return_statement (identifier))))