Not accepted on codeforces

My code – https://onlinegdb.com/rkXgI_KZ8
was not accepted on codeforces , i am unable to resolve the error
please check it
codeforce problem link –http://codeforces.com/contest/276/problem/D

This is probably failing on large numbers. long is sometimes 32-bit on codeforces change it to long long.
Also check this simple solution in O(1).

#include <bits/stdc++.h>
using namespace std;

long long int maximizingXor(long long int l, long long int r) {
    return (1LL << int(log2(l ^ r) + 1)) - 1;
}

int main() {
    long long int l, r;
    cin >> l >> r;
    cout << maximizingXor(l, r);
}