F题 说实话我也不知道什么原理,希望各位大佬指点指点

#include<iostream>
using namespace std;

const int N = 1e6+10;

void solve()
{
    int x,y;
    cin>>x>>y;
    int resa = x;
    int c = x+y;
    int resb = c;
    while(x)
    {
        x/=2;
        resa+=x;
    }
    
    while(c)
    {
        c/=2;
        resb+=c;
    }
    cout<<resb-resa<<"\n";
}

int main()
{
    int t;
    cin>>t;
    while(t--)
    solve();

    return 0;
}