#include #include using namespace boost::multiprecision; #define ll int128_t #define rep(i,x,n) for(ll i=x;i=n;i--) using namespace std; ll calc(ll n){ ll c=0; while(n>1) n/=2,c++; return c; } ll cal2(ll idx){ ll ans=1; while(idx--)ans*=2; return ans; } void solve(){ ll d; cin>>d; ll init=d,mx=calc(d),ans=0; ll res=cal2(80); rrep(i,mx-1,0){ if((d-cal2(i+1)+1) >0) {d-= (cal2(i+1)-1); ans+= cal2(i);} else if((d-cal2(i+1)+1) == 0) {d-= (cal2(i+1)-1); ans+=cal2(i); break;} else res=min(res,ans+cal2(i)); } if(d>0) ans=init; cout<