Here is my code -
#include <bits/stdc++.h>
using namespace std;
int setbit(int no , int nt){
int fans = 0 , i;
for( i = no ; i<= nt ;i++){
int ans = 0;
int nu = i;
while(nu>0){
ans += (nu&1);
nu >>= 1;
}
fans += ans ;
}
return fans;
}
int main() {
int t;
cin >>t;
while(t--){
int a,b;
cin>>a>>b;
int l = setbit(a,b);
cout<<l<<"\n";
}
return 0;
}