Go: package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	var nums []int
	for i := 1; i < 2*100+1; i++ {
		nums = append(nums, i*(i+1)*(i+2)/6)
	}
	var ins []int
	N := 0
	for true {
		n := sc.nextInt()
		if n == 0 {
			break
		}
		ins = append(ins, n)
		N = max(N, n)
	}
	dp := make([]int, N+1)
	dp2 := make([]int, N+1)
	for i := 1; i < N+1; i++ {
		dp[i] = INF
		dp2[i] = INF
	}
	for i := 0; i < len(nums); i++ {
		n := nums[i]
		if n > N {
			break
		}
		for j := 0; j < N+1; j++ {
			if j >= n {
				dp[j] = min(dp[j], dp[j-n]+1)
				if n%2 != 0 {
					dp2[j] = min(dp2[j], dp2[j-n]+1)
				}
			}
		}
	}
	for i := 0; i < len(ins); i++ {
		fmt.Fprintln(wtr, dp[ins[i]], dp2[ins[i]])
	}
}

C++: #include<iostream>
#include<fstream>

using namespace std;

#define MAX 1000000

int ans[MAX];
int ans_odd[MAX];

int square(int n){
    return n * (n + 1) * (n + 2) / 6;
}

int calc(int n){

    if(ans[n] != MAX)return ans[n];


    int num = 0;
    while(square(num) <= n){
        ans[square(num)] = 1;
        num++;
    }
    num--;

    for(int i = num; i > 0; i--){
        int tmp = calc(n - square(i));
        if(ans[n] > tmp + 1)ans[n] = tmp + 1;
    }

    return ans[n];
}

int calcOdd(int n){
    if(ans_odd[n] != MAX)return ans_odd[n];


    int num = 1;
    while(square(num) <= n){
        ans_odd[square(num)] = 1;
        num+=4;
    }
    num-=4;

    for(int i = num; i > 0; i-=4){
        int tmp = calcOdd(n - square(i));
        if(ans_odd[n] > tmp + 1)ans_odd[n] = tmp + 1;
    }

    return ans_odd[n];
}

int main(){
//    ifstream fin("in.txt");
    int n = 0;

    for(int i = 0; i < MAX; i++){
        ans[i] = ans_odd[i] = MAX;
    }


    while((cin >> n), n){

        cout << calc(n) << " " << calcOdd(n) << endl;
    }

    return 0;
}

C++: #include<cstdio>
#include<vector>
#include<algorithm>
#define N (int)1e6
using namespace std;

int main(){
  int n,tmp,dp[N+1],dp_odd[N+1];
  vector<int> plc;

  for(int i=0;i<=N;i++)dp[i] = dp_odd[i] = N+1;
  dp[0] = dp_odd[0] = 0;

  tmp = 1;
  for(int i=1;;i++){
    plc.push_back(tmp);
    tmp *= i+3; tmp /= i;
    if(tmp>N)break;
  }

  for(int i=(int)plc.size()-1;i>=0;i--){
    for(int j=0;j+plc[i]<=N;j++){
      if(dp[j]>N)continue;
      tmp = j+plc[i];
      dp[tmp] = min(dp[tmp],dp[j]+1);
    }
    if(plc[i]&1){
      for(int j=0;j+plc[i]<=N;j++){
	if(dp_odd[j]>N)continue;
	tmp = j+plc[i];
	dp_odd[tmp] = min(dp_odd[tmp],dp_odd[j]+1);
      }
    }
  }

  while(scanf("%d",&n) && n)printf("%d %d\n",dp[n],dp_odd[n]);
}

C++: #include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}

ll cal(ll n){return n*(n+1)*(n+2)/6;}

ll dp[1000010],dp2[1000010];

int main(){
	ll N;
	vector<ll> v;
	for(int i=0;cal(i)<=1000000;i++)v.push_back(cal(i));
	ll M=v.size();
	for(int i=0;i<1000010;i++)dp2[i]=INF;
	dp2[0]=0;
	for(int i=0;i<1000010;i++){
		for(int j=0;j<M;j++){
			if(i-v[j]<0)break;
			dp2[i]=min(dp2[i],dp2[i-v[j]]+1);
		}
	}
	vector<ll> v_k;
	for(int i=0;cal(i)<=1000000;i++){
		ll x=cal(i);
		if(cal(i)%2==0)continue;
		v_k.push_back(cal(i));
	}
	for(int i=0;i<1000010;i++)dp[i]=INF;
	dp[0]=0;
	for(int i=0;i<1000010;i++){
		for(int j=0;j<v_k.size();j++){
			if(i-v_k[j]<0)break;
			dp[i]=min(dp[i],dp[i-v_k[j]]+1);
		}
	}
	while(1){
		cin>>N;
		if(N==0)break;
		cout<<dp2[N]<<" "<<dp[N]<<endl;
	}
}

C++: #include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int dp[1000010];
int dp2[1000010];

signed main() {
	int n;
	while (cin >> n && n) {
		rep(i, 0, n+1) {
			dp[i] = 10;
			dp2[i] = 10000000;
		}
		dp[0] = 0;
		dp2[0] = 0;
		rep(i, 1, 150) {
			int a = i*(i + 1)*(i + 2) / 6;
			if (a > n) break;
			rep(j, 0, n + 1) {
				if (j + a > n) break;
				dp[j + a] = min(dp[j + a], dp[j] + 1);
				if (a % 2 == 0) continue;
				dp2[j + a] = min(dp2[j + a], dp2[j] + 1);
			}
		}
		cout << dp[n] << " " << dp2[n] << endl;
	}
}

C++: #include<bits/stdc++.h>
const int MAX=1e6+10;
using namespace std;
int main(){
    vector<int>precal;
    vector<int>dp(MAX,MAX);
    vector<bool>flag(MAX,false);
    int n;
    precal.push_back(0);
    dp[0]=0;
    for(int i=1;;i++){
        int cnt=((i)*(i+1)*(i+2))/6;
        if(cnt>MAX)break;
        precal.push_back(cnt);
        flag[cnt]=true;
    }
    for(int i=1; i<=MAX-9;i++){
        if(flag[i]){dp[i]=1; continue;}
        int index=upper_bound(precal.begin(),precal.end(),i)-precal.begin();
        for(int j=0; j<=index;j++)
            dp[i]=min(dp[i],dp[precal[j]]+dp[i-precal[j]]);
    }
    vector<int>oddcal;
    vector<int>odp(MAX,MAX);
    vector<bool>oddflag(MAX,false);
    oddcal.push_back(0);
    odp[0]=0;
    for(int i=1;;i++){
        int cnt=(i*(i+1)*(i+2))/6;
        if(cnt>MAX)break;
        if(!(cnt%2))continue;
        oddcal.push_back(cnt);
        oddflag[cnt]=true;
    }
    for(int i=1; i<=MAX-9;i++){
        if(oddflag[i]){odp[i]=1;continue;}
        int index=upper_bound(oddcal.begin(), oddcal.end(), i)-oddcal.begin();
        for(int j=0;j<=index;j++)
            odp[i]=min(odp[i],odp[oddcal[j]]+odp[i-oddcal[j]]);
        
    }
    while(cin>>n,n){
        cout<<dp[n]<<" "<<odp[n]<<endl;
    }
}