CODESPTA  2s Complement
One of the basics of Computer Science is knowing how numbers are represented in 2's complement. Imagine that you write down all numbers between A and B in 2's complement representation using 32 bits. How many 1's will you write down in all ?
Input:
The first line contains the number of test cases T. Each of the next T lines contains two integers A and B.
Output:
Output T lines, one corresponding to each test case.
Constraints:
2^31 <= A <= B <= 2^31  1
Sample Input:
3
2 0
3 4
1 4
Sample Output:
63
99
37
Explanation:
For the first case, 2 contains 31 1's followed by a 0 whereas 1 contains 32 1's. Thus the total is 63.
For the second case, the answer is 31 + 31 + 32 + 0 + 1 + 1 + 2 + 1 = 99
hide comments
anurag garg:
20140409 09:56:38
nice and easy my 300th on spoj...:) 

Ashutosh Singla:
20130525 19:02:22
overflows. :< 

pardeep kumar:
20130503 09:07:00
time limit is strict Last edit: 20130503 09:07:40 

preetam:
20130202 16:25:44
woohoooo... AC :) 

Aditya Pande:
20130104 12:24:56
WA and i don't know why?


ɥsǝןǝǝu:
20121026 05:28:33
O(ba) will not pass.... 

Shubham Pandey:
20121025 17:24:10
@Varun


__KIRA__:
20120127 17:23:17
@Varun can u tell me whr my code fail's. wa everytime. solving test cases fine still wa! why ??


BOND:
20111218 23:12:38
time limit is really very strict. 
Added by:  Varun Jalan 
Date:  20111015 
Time limit:  0.378s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ASM64 
Resource:  own problem used for CodeSprint  InterviewStreet Contest 