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 <bits/stdc++.h>
using namespace std;

//#define int long long
#define pb push_back 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for( int i = 0; i < (n); i++ )
#define Rrep(i, a, n) for( int i = (a); i < (n); i++ )
#define All(v) v.begin(), v.end()

typedef pair<int, int> Pii; 
typedef pair<int, Pii> Pip;
//const int INF = 1107110711071107;

int dp[1000001];
int dp_odd[1000001];
int four[300];
int x;

signed main() {
  Rep(i, 210) four[i] = i * (i+1) * (i+2) / 6;
  
  Rep(i, 1000001) dp[i] = i;
  Rrep(i, 2, 300) {
    Rep(j, 1000001) {
      if ( j+four[i] <= 1000000 ) {
	dp[j+four[i]] = min(dp[j+four[i]], dp[j]+1);
      }
    }
  }

  Rep(i, 1000001) dp_odd[i] = i;
  Rrep(i, 2, 50) {
    Rep(j, 1000001) {
      dp_odd[j] = min(dp_odd[j], dp_odd[j]);
      if ( j+four[(i-1)*4+1] <= 1000000 ) {
	dp_odd[j+four[(i-1)*4+1]] = min(dp_odd[j+four[(i-1)*4+1]], dp_odd[j]+1);
      }
    }
  }
 
  while ( cin >> x, x ) {
    cout << dp[x] << " " << dp_odd[x] << endl;
  }
  return 0;
}

C++: #include<stdio.h>
#include<vector>
std::vector<int>t,o;
const int N=1000000,V=1<<9;
int a[N],b[N];
int main()
{
	int i,j,n;
	for(i=1;i<N;++i)a[i]=b[i]=V;
	for(i=1;n=(i*(i+1)*(i+2))/6,n<N;++i)if(a[n]=1,t.push_back(n),n&1)b[n]=1,o.push_back(n);
	for(i=t.size()-1;i>=0;--i)
	{
		a[t[i]]=1;
		for(j=t[i];j+t[i]<N;++j)if(a[j]-V&&a[j]>9)break;else if(a[j]+1<a[j+t[i]])a[j+t[i]]=a[j]+1;
	}
	for(i=o.size()-1;i>=0;--i)
	{
		b[o[i]]=1;
		for(j=o[i];j+o[i]<N;++j)if(b[j]-V&&b[j]>37)break;else if(b[j]+1<b[j+o[i]])b[j+o[i]]=b[j]+1;
	}
	while(scanf("%d",&n),n)printf("%d %d\n",a[n],b[n]);
	return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <iomanip>
#include <stack>
  
using namespace std;

#define pi 3.141592653589793

int main()
{
	int result[1000001] = {};
	int odd_result[1000001] = {};
	fill(result, result + 1000000, 1000000);
	fill(odd_result, odd_result + 1000000, 1000000);
	int trangular_sum = 0, tetrahedral_sum = 0;
	result[0] = 0;
	odd_result[0] = 0;
	for(int i = 1; tetrahedral_sum < 1000000; i++){
		trangular_sum += i;
		tetrahedral_sum += trangular_sum;
		// result[trangular_sum] = 1;
		result[tetrahedral_sum] = 1;
		if(tetrahedral_sum % 2 == 1) odd_result[tetrahedral_sum] = 1;
	}
	for(int i = 1; i < 1000000; i++){
		for(int j = 1; j < i; j++){
			result[i] = min(result[i], result[i - j] + result[j]);
			if(j % 2 == 1) odd_result[i] = min(odd_result[i], odd_result[i - j] + odd_result[j]);
		}
		// cout << i  << " " << result[i] << " " << odd_result[i] << endl;
	}
	int n;
	while(1){
		cin >> n;
		if(n == 0) break;
		cout << result[n] << " " odd_result[n] << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int dp[2][1000001];

int odd(int n,int w){
  for(int i=0;i<2;i++)
    for(int j=0;j<=n;j++){
      dp[i][j]=99999999;
      if(i==0)dp[i][j]=j;
      if(j==0)dp[i][j]=0;
    }

    for(int i=1;i<=w;i++){
      for(int j=1;j<=n;j++){
	if((i*(i+1)*(i+2)/6)%2==0){
	  dp[i&1][j]=dp[i&1^1][j];
	}else if(j<i*(i+1)*(i+2)/6){
	  dp[i&1][j]=dp[i&1^1][j];
	}else{
	  dp[i&1][j]=min(dp[i&1^1][j],dp[i&1][j-i*(i+1)*(i+2)/6]+1);
	}
	//cout << "dp[" << i << "][" << j <<"]:"<< dp[i][j] << endl;
      }
    }
    return dp[w%2][n];
}

int main(){
  int n;
  while(cin>>n,n){
    int w=0;
    while(w*(w+1)*(w+2)/6 < n){
      w++;
    }
    for(int i=0;i<2;i++)
      for(int j=0;j<=n;j++){
	dp[i][j]=99999999;
	if(i==0)dp[i][j]=j;
	if(j==0)dp[i][j]=0;
      }
    for(int i=1;i<=w;i++){
      for(int j=1;j<=n;j++){
	if(j<i*(i+1)*(i+2)/6){
	  dp[i&1][j]=dp[i&1^1][j];
	}else{
	  dp[i&1][j]=min(dp[i&1^1][j],dp[i&1][j-i*(i+1)*(i+2)/6]+1);
	}
	//cout << "dp[" << i << "][" << j <<"]:"<< dp[i][j] << endl;
      }
    }
    cout << dp[w%2][n] << " " << odd(n,w) << endl;
  }
  return 0;
}

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

#define NMAX 1000001
int nm[NMAX],nm2[NMAX];

int main()
{
	int N;
	for(int i=0; i<NMAX; i++)
	{
		nm[i] = nm2[i] = (1<<25);
	}
	nm[0]=nm2[0]=0;
	
	for(int n=1; true; n++)
	{
		int V=n*(n+1)*(n+2)/6;
		if(V>=NMAX) break;		
	
		for(int i=V; i<NMAX; i++)
		{
			nm[i]=min(nm[i],nm[i-V]+1);
		}	
	}
	
	for(int n=1; true; n++)
	{
		int V=n*(n+1)*(n+2)/6;
		if(V>=NMAX) break;
		
		if(V%2==0) continue;		
	
		for(int i=V; i<NMAX; i++)
		{
			nm2[i]=min(nm2[i],nm2[i-V]+1);
		}	
	}	
	
	while(cin >> N, N)
	{		
		cout << nm[N] << " " << nm2[N] << endl;
	}
}