Simple approach i used :-
#include
using namespace std;
int main()
{
int q;
cin >> q;
while(q–)
{
int a, b;
cin >> a >> b;
int setBit = 0;
for(int i = a; i <= b; i++)
{
setBit += __builtin_popcount(i);
}
cout << setBit << endl;
}
}