Language: C++

#include<iostream>
#include<cmath>
using namespace std;

long long XOR(long long x){
  int n;
  if(x<=0)return 0;
  for(int i=0;i<x;i++){
    if(pow(2,i)>x){
      n=i;
      break;
    }
  }
  long long sum=0;
  for(int i=1;i<=n;i++){
    long long temp=x%pow(2,i);
    if(temp-pow(2,i-1)>0){
      if(temp-pow(2,i-1)%2==1){
        sum+=pow(2,i-1);
      }
    }
  }
  return sum;
}


int main(){
  long long A,B;
  cin>>A>>B;
  if(A!=B){
    cout<<XOR(A-1)^XOR(B);
  }else{
    cout<<0;
  }
  return 0;
}
  

Compiler output:
a.cc: In function 'long long int XOR(long long int)':
a.cc:16:21: error: invalid operands of types 'long long int' and '__gnu_cxx::__promote<double>::__type' {aka 'double'} to binary 'operator%'
   16 |     long long temp=x%pow(2,i);
      |                    ~^~~~~~~~~
      |                    |    |
      |                    |    __gnu_cxx::__promote<double>::__type {aka double}
      |                    long long int
a.cc:18:25: error: invalid operands of types '__gnu_cxx::__promote<double>::__type' {aka 'double'} and 'int' to binary 'operator%'
   18 |       if(temp-pow(2,i-1)%2==1){
      |               ~~~~~~~~~~^~
      |                  |       |
      |                  |       int
      |                  __gnu_cxx::__promote<double>::__type {aka double}
a.cc: In function 'int main()':
a.cc:31:19: error: no match for 'operator^' (operand types are 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} and 'long long int')
   31 |     cout<<XOR(A-1)^XOR(B);
      |     ~~~~~~~~~~~~~~^~~~~~~
      |         |             |
      |         |             long long int
      |         std::basic_ostream<char>::__ostream_type {aka std::basic_ostream<char>}
a.cc:31:19: note: candidate: 'operator^(int, long long int)' (built-in)
   31 |     cout<<XOR(A-1)^XOR(B);
      |     ~~~~~~~~~~~~~~^~~~~~~
a.cc:31:19: note:   no known conversion for argument 1 from 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} to 'int'
In file included from /usr/include/c++/14/bits/memory_resource.h:38,
                 from /usr/include/c++/14/string:68,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/cstddef:146:3: note: candidate: 'constexpr std::byte std::operator^(byte, byte)'
  146 |   operator^(byte __l, byte __r) noexcept
      |   ^~~~~~~~
/usr/include/c++/14/cstddef:146:18: note:   no known conversion for argument 1 from 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} to 'std::byte'
  146 |   operator^(byte __l, byte __r) noexcept
      |             ~~~~~^~~
/usr/include/c++/14/bits/ios_base.h:94:3: note: candidate: 'constexpr std::_Ios_Fmtflags std::operator^(_Ios_Fmtflags, _Ios_Fmtflags)'
   94 |   operator^(_Ios_Fmtflags __a, _Ios_Fmtflags __b) _GLIBCXX_NOTHROW
      |   ^~~~~~~~
/usr/include/c++/14/bits/ios_base.h:94:27: note:   no known conversion for argument 1 from 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} to 'std::_Ios_Fmtflags'
   94 |   operator^(_Ios_Fmtflags __a, _Ios_Fmtflags __b) _GLIBCXX_NOTHROW
      |             ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/ios_base.h:144:3: note: candidate: 'constexpr std::_Ios_Openmode std::operator^(_Ios_Openmode, _Ios_Openmode)'
  144 |   operator^(_Ios_Openmode __a, _Ios_Openmode __b) _GLIBCXX_NOTHROW
      |   ^~~~~~~~
/usr/include/c++/14/bits/ios_base.h:144:27: note:   no known conversion for argument 1 from 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} to 'std::_Ios_Openmode'
  144 |   operator^(_Ios_Openmode __a, _Ios_Openmode __b) _GLIBCXX_NOTHROW
      |             ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/ios_base.h:191:3: note: candidate: 'constexpr std::_Ios_Iostate std::operator^(_Ios_Iostate, _Ios_Iostate)'
  191 |   operator^(_Ios_Iostate __a, _Ios_Iostate __b) _GLIBCXX_NOTHROW
      |   ^~~~~~~~
/usr/include/c++/14/bits/ios_base.h:191:26: note:   no known conversion for argument 1 from 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} to 'std::_Ios_Iostate'
  191 |   operator^(_Ios_Iostate __a, _Ios_Iostate __b) _GLIBCXX_NOTHROW
      |             ~~~~~~~~~~~~~^~~