The Time Limit Exceeds even after doing n&(n-1) trick for each number
Time Limit Exceeded
This is a quite simple problem to tackle. Just loop through all the numbers between a and b and calculate the no of set bits using either brian kernighan algo or the inbuilt function for counting set bits