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<cstdio>
using namespace std;

const int N = 1000000;
int dp[2][N+1];

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

  int val = 1;
  for(int i=1;val<=N;i++){
    for(int j=0;j+val<=N;j++){
      int nxt = j+val;
      if(dp[0][nxt]>dp[0][j]+1)dp[0][nxt] = dp[0][j] + 1;
      if( (val&1) && (dp[1][nxt]>dp[1][j]+1))dp[1][nxt] = dp[1][j] + 1;
    }
    val *= (i+3), val /= i;
  }

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

C++: #include <iostream>
#include <algorithm>
using namespace std;

const int MAX_NUM = 1000000;
const int INF = 100000000;

int table[2][MAX_NUM];
int tet[2][1000];

int solve(int num,int m)
{
    if(table[m][num]==INF) {
        for(int i=1; tet[m][i]<num; i++) {
            table[m][num]=min(table[m][num],solve(num-tet[m][i],m)+1);
        }
    }
    return table[m][num];
}

int main()
{
    for(int i=0; i<MAX_NUM; i++) {
        table[0][i] = INF;
        table[1][i] = INF;
    }

    for(int i=1; i*(i+1)*(i+2)/6<MAX_NUM; i++) {
        int t=i*(i+1)*(i+2)/6;
        table[0][t] = 1;
        tet[0][i] = t;

        if(t%2 == 1) {
            table[1][t] = 1;
            tet[1][i] = t;
        }
    }

    int in;
    while(cin>>in && in) {
        cout<<solve(in,0)<<" "<<solve(in,1)<<endl;
    }

    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define pb(a) push_back(a)
#define pr(a) cout<<(a)<<endl
#define PR(a,b) cout<<(a)<<" "<<(b)<<endl
#define R cin>>
#define F first
#define S second
#define ll long long
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

int main() {
  vector<int> v[2];
  for(int i=1; i<=200; i++) {
    v[0].pb(i*(i+1)*(i+2)/6);
    v[i*(i+1)*(i+2)/6%2].pb(i*(i+1)*(i+2)/6);
  }
  int d[2][1000001];
  rep(i,2)rep(j,1000001) d[i][j]=MAX;
  d[0][0]=d[1][0]=0;
  rep(k,2) {
    rep(i,v[k].size()) {
      rep(j,1000001) {
	if(v[k][i]+j>1000001) break;
	d[k][v[k][i]+j]=min(d[k][v[k][i]+j],d[k][j]+1);
      }
    }
  }
  int n;
  while(R n && n) PR(d[0][n],d[1][n]);
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 1145141919
#define MOD 1000000007
#define ALL(a) begin((a)),end((a))
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
typedef vector<edge> edges;
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///
vi all, odd, v;
int allt[1000005], oddt[1000005];

int main()
{
	v.push_back(0);
	FOR(i, 1, 1000) v.push_back(v[i - 1] + i);
	all.push_back(0);
	FOR(i,1, v.size())
	{
		all.push_back(all[i - 1] + v[i]);
		if (all[i] & 1) odd.push_back(all[i]);
		if (all[i] > 1000000) break;
	}
	int n;
	fill(ALL(allt), INF); fill(ALL(oddt), INF);
	allt[0] = oddt[0] = 0;
	REP(i, 1000001)REP(j, all.size())
	{
		int t = i + all[j];
		if (t >= 1000001) break;
		allt[t] = min(allt[i] + 1, allt[t]);
	}

	REP(i, 1000001)REP(j, odd.size())
	{
		int t = i + odd[j];
		if (t >= 1000001) break;
		oddt[t] = min(oddt[i] + 1, oddt[t]);
	}
	while (cin >> n, n)
	{
		cout << allt[n] << " " << oddt[n] << endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <algorithm>
#include <iostream>
using namespace std;
int dp[1000001],Odp[1000001];
int Tn[200],OTn[200]; 
int n = 1000000;

int main(){
    int count = 0;  //pollocks numberの生成
    for(int i = 1;i < 200;i++){
        Tn[i-1] = i * (i + 1) * (i + 2) / 6;
        if(Tn[i-1] % 2 == 1){
            OTn[count] = Tn[i-1];
            count++;
        }
    }

    //個数の初期化
    for(int j = 0;j <= n;j++){
        dp[j] = j;
        Odp[j] = j;
    }
    
    for(int i = 0;i < 200;i++){
        for(int j = OTn[i];j <= n;j++){    //奇数正四面体数の個数の最小値
            if(j >= OTn[i])
                Odp[j] = min(Odp[j],Odp[j-OTn[i]] + 1);
        }
        for(int j = Tn[i];j <= 1000000;j++){    //正四面体数の個数の最小値
            if(j >= Tn[i])
                dp[j] = min(dp[j],dp[j-Tn[i]] + 1);
        }
    }

    //入出力
    while(cin >> n,n)
        cout << dp[n] << ' ' <<  Odp[n] << endl;


    return 0;
}