使用了哈希表来写
#include<bits/stdc++.h>
using namespace std;
#define i64 long long
unordered_map<i64, i64> ump;
i64 f(i64 n) {
if(n < 2) return 0;
if(ump.find(n) != ump.end()) return ump[n];
return ump[n] = n + f(n / 2) + f((n + 1) / 2);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
i64 N;
cin >> N;
cout << f(N) << "\n";
return 0;
}