Click Here for Problem Statement
#include < iostream>
#include< map>
using namespace std;
map < long long int,long long int> mem;
long long int temp,t1,t2,t3;
long long int f(long long int x)
{
if(mem[x])
{
return mem[x];
}
else if(x<6)
{
return x;
}
else
{
temp=f(x/2)+f(x/3)+f(x/4);
}
mem[x]=temp;
return temp;
}
int main()
{
long long int n;
while(cin>>n)
{
cout << max(n,f(n));
cout << endl;
}
return 0;
}