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>
using namespace std;
int main(){
  int a[190]={0},b[60]={0},c[1000001]={0,1,2,3},d[1000001],k=0,i,j,n;
  for(i=1;i<190;i++)a[k++]=i*(i+1)*(i+2)/6;
  for(j=k=0;j<i;j++)if(a[j]%2)b[k++]=a[j];
  for(i=1;i<189;i++)for(j=a[i];j<a[i+1];j++)c[j]=c[j-a[i]]+1;
  for(i=0;i<36;i++)d[i]=i;
  for(i=1;i<k-2;i++)for(j=b[i];j<b[i+1];j++)d[j]=d[j-b[i]]+1;
  while(cin>>n,n)cout<<c[n]<<' '<<d[n]<<endl;
}

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

#define MAXNUM 1000001
#define INF 1000
using namespace std;

int all[MAXNUM + 2], odd[MAXNUM + 2], fourall[1000], fourodd[1000];

int main()
{
	int n;
	int counter = 0;

	//配列の初期化
	for (int i = 0; i < MAXNUM; i++){
		all[i] = INF;
		odd[i] = INF;

	}

	//1からMAXNUMまでの中に存在する正四面体数を洗い出す．
	int now = 0, four, allcounter = 1, oddcounter = 1;
	while (1){
		now++;
		four = now  *(now + 1)*(now + 2) / 6;
		all[four] = 1;
		fourall[allcounter++] = four;
		if (four % 2 == 1){
			odd[four] = 1;
			fourodd[oddcounter++] = four;
		}
		if (four > MAXNUM * 2)
			break;

	}

	//1からMAXNUMまで，配列を埋める.
	for (int i = 1; i < MAXNUM; i++){
		for (int j = 1; i > fourall[j]; j++){
			all[i] = min(all[i], 1 + all[i - fourall[j]]);
		}
		for (int j = 1; i > fourodd[j]; j++){
			odd[i] = min(odd[i], 1 + odd[i - fourodd[j]]);
		}
			//cout << i << endl;
	}
	//cout << "a";


	//入力
	while (cin >> n, n)
		cout << all[n] << " " << odd[n] << endl;

	return 0;

}

C++: #include <bits/stdc++.h>
using namespace std;

int dp[100000];
int dpodd[100000];
int num[200];
int INF = 1000000;
int main(){
	for(int i = 0; i < 200; i++){
		num[i] = (i + 1) * (i + 2) * (i + 3)/ 6;
	}
	dp[0] = 0;
	dpodd[0] = 0;
	for(int i = 1; i < 100000; i++){
		dp[i] = INF;
		dpodd[i] = INF;
		for(int j = 0; num[j] <= i; j++){
			dp[i] = min(dp[i], dp[i - num[j]] + 1);
			if(num[j] % 2 == 1){
				dpodd[i] = min(dpodd[i], dpodd[i - num[j]] + 1);
			}
		}
	}
	int N;
	while(cin >> N, N){
		cout << dp[N] << " " << dpodd[N] << endl;
	}
}

C++: #include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int MAX;
vector<int> V;
vector<int> D;
int N;
int M;

void solve(int n) {
	bool **dp = new bool*[6];
	for (int i=0; i<6; i++) {
		dp[i] = new bool[MAX+10];
		for (int j=0; j<MAX+10; j++)
			dp[i][j] = 0;
	}

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

	for (int i=1; i<5; i++) {
		for (int j=0; j<n; j++) {
			if (!dp[i-1][j]) continue;
			for (int k=0; j+V[k]<=n; k++)
				dp[i][j+V[k]] = 1;
		}
	}

	for (int i=0; i<5; i++) {
		if (dp[i][n]) {
			cout << i+1 << " ";
			break;
		}
	}

	for (int i=0; i<6; i++)
		delete [] dp[i];
	delete [] dp;


	// 
	bool **dp2 = new bool*[n+5];
	for (int i=0; i<n+5; i++) {
		dp2[i] = new bool[MAX+10];
		for (int j=0; j<MAX+10; j++)
			dp2[i][j] = 0;
	}

	for (int i=0; i<M; i++)
		dp2[0][D[i]] = 1;
	
	for (int i=1; i<n; i++) {
		for (int j=0; j<n; j++) {
			if (!dp2[i-1][j]) continue;
			for (int k=0; j+D[k]<=n; k++)
				dp2[i][j+D[k]] = 1;
		}
	}

	for (int i=0; i<n; i++) {
		if (dp2[i][n]) {
			cout << i+1 << endl;
			break;
		}
	}

	for (int i=0; i<n+5; i++)
		delete [] dp2[i];
	delete [] dp2;
}

int main() {
	MAX = (int)pow(10.0, 6);
	for (int i=1; i*(i+1)*(i+2)/6<=MAX; i++) {
		V.push_back(i*(i+1)*(i+2)/6);
		if ( (i*(i+1)*(i+2)/6)%2==1 ) D.push_back(i*(i+1)*(i+2)/6);
	}
	N = (int)V.size();
	M = (int)D.size();

	int n;
	cin >> n;
	while (n!=0) { 
		solve(n);
		cin >> n;
	}
	return 0;
}

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

const int MAX = 1000000;

int dp[MAX], dp_odd[MAX];

int main()
{
  vector<int> tetra;

  for (int i = 1; ; ++i) {
    int d = i * (i + 1) * (i + 2) / 6;
    if (d >= MAX)
      break;
    tetra.push_back(d);
  }

  dp[0] = dp_odd[0] = 0;
  for (int i = 1; i < MAX; ++i) {
    dp[i] = dp_odd[i] = i;
    for (int j = 0; j < tetra.size(); ++j) {
      if (tetra[j] > i)
	break;
      dp[i] = min(dp[i], dp[i-tetra[j]]+1);
      if (tetra[j] % 2 == 1)
	dp_odd[i] = min(dp_odd[i], dp_odd[i-tetra[j]]+1);
    }
  }

  int in;
  for ( ; ; ) {
    cin >> in;
    if (in == 0)
      break;
    cout << dp[in] << " " << dp_odd[in] << endl;
  }
  return 0;
}

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

using namespace std;

const static int MAX=1000005;
const static int INF=(1<<28);
int T[MAX];
int res(int n){
	vector<int> C;
	for(int i=1;i*(i+1)*(i+2)/6<=n;i++){
		C.push_back(i*(i+1)*(i+2)/6);
	}
	
	
	for(int i=0;i<=n;i++){
		T[i]=INF;
	}
	
	T[0]=0;
	
	int k=C.size();
	
	for(int i=0;i<k;i++){
		for(int j=0;j+C[i]<=n;j++){
			T[j+C[i]]=min(T[j+C[i]],T[j]+1);
		}
	}
	return T[n];
}

int odd(int n){
	vector<int> C;
	for(int i=1;i*(i+1)*(i+2)/6<=n;i++){
		int t=i*(i+1)*(i+2)/6;
		if(t%2==1){
			C.push_back(t);
		}
	}	
	for(int i=0;i<=n;i++){
		T[i]=INF;
	}
	
	T[0]=0;
	
	int k=C.size();
	
	for(int i=0;i<k;i++){
		for(int j=0;j+C[i]<=n;j++){
			T[j+C[i]]=min(T[j+C[i]],T[j]+1);
		}
	}
	return T[n];	
}

int main()
{
	int n;
	while(true){
		cin>>n;
		if(n==0)break;
		int a=res(n);
		int b=odd(n);
		cout<<a<<" "<<b<<endl;
	}	
}