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;
typedef long long ll;
 
#define rep(i, n) for(int i=0; i<(n); ++i)

const int size = 200;
const int limit = 1000001;
int dp[limit], dp_odd[limit];
int tetra[size], odd[size];

int main(void){
    int size_odd = 0;
    for(int i=1; i<size+1; ++i) {
        ll t = i*(i+1)*(i+2)/6;
        tetra[i-1] = t;
        if(t%2==1) {odd[size_odd]=t; size_odd++;}
    }
    int inf = numeric_limits<int>::max();
    rep(i, limit) dp[i] = dp_odd[i] = inf;
    dp[0] = 0;
    dp_odd[0] = 0;
    rep(i, size) {
        for(int j=tetra[i]; j<limit; ++j) 
            dp[j] = min(dp[j-tetra[i]]+1, dp[j]);
    }
    rep(i, size_odd) {
        for(int j=odd[i]; j<limit; ++j) 
            dp_odd[j] = min(dp_odd[j-odd[i]]+1, dp_odd[j]);
    }

    int n;
    while(cin >> n && n) {
        cout << dp[n] << " ";
        cout << dp_odd[n] << endl;
    }
}

C++: #include<iostream>
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=2;val<=N;i++){
    for(int j=0;j+val<=N;j++){
      int nxt = j+val;
      dp[0][nxt] = min(dp[0][nxt],dp[0][j] + 1);
      if(val&1)dp[1][nxt] = min(dp[1][nxt],dp[1][j] + 1);
    }
    val = i*(i+1)*(i+2)/6;
  }

  int n;
  while(cin >> n,n)cout << dp[0][n] << " " << dp[1][n] << endl;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
  int i,j,k,b[1000001],c[1000001],a[200],n;
  for(i=0;n[i-1]<1000000;i++)a[i]=i*(i+1)*(i+2)/6;
  for(j=0;j<=1000000;j++)ki[j]=all[j]=j;
  for(j=2;j<i;j++){
    for(k=n[j];k<=1000000;k++){
      b[k]=min(b[k],b[k-a[j]]+1);
      if(n[j]%2){
        c[k]=min(c[k],c[k-a[j]]+1);
      }
    }
  }
while(cin>>n,n){
cout<<all[a]<<" "<<ki[a]<<endl;
}
return 0;
}

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

#define INF 1 << 28

vector<int> t;
vector<int> odd_t;
int ns[1000001];
int odd_ns[1000001];

int count_t(int n) {
	if (ns[n] != 0) return ns[n];
	if (binary_search(t.begin(), t.end(), n)) {
		ns[n] = 1;
		return 1;
	}
	ns[n] = INF;
	for (int i = 0; n-t[i] >= 0; i++) {
		ns[n] = min(ns[n], count_t(n-t[i])+1);
	}
	return ns[n];
}

int count_odd_t(int n) {
	if (odd_ns[n] != 0) return odd_ns[n];
	if (binary_search(odd_t.begin(), odd_t.end(), n)) {
		odd_ns[n] = 1;
		return 1;
	}
	odd_ns[n] = INF;
	for (int i = 0; n-odd_t[i] >= 0; i++) {
		odd_ns[n] = min(odd_ns[n], count_odd_t(n-odd_t[i])+1);
	}
	return odd_ns[n];
}

int main() {
	memset(ns, 0, sizeof(ns));
	memset(odd_ns, 0, sizeof(odd_ns));

	for (int i = 0; i < 500; i++) {
	   	t.push_back((i+1)*(i+2)*(i+3) / 6);
		if (*(t.end()-1) % 2 == 1) odd_t.push_back(*(t.end()-1));
	}
	//for (int i = 0; i < odd_t.size(); i++) cout << odd_t[i] << ' ';
	//cout << endl;
	int n;
	while (cin >> n, n) {
		cout << count_t(n) << ' ' << count_odd_t(n) << endl;
	}
	return 0;
}

C++: #include <stdio.h>
#define INF 0x7FFFFFFF

int main(void){
	int i, j, n, min1,small;
	int dp[200000];
	scanf("%d",&n);
	while(n != 0){
		for(i = 0;i <= n;i++)
			dp[i] = INF;
		dp[0] = 0;
		small = INF;
		for(i = 0;i < n;i++){
			if(small > dp[i]){
				for(j = 1;(j * (j + 1) * (j + 2)) / 6 + i <= n;j++){
					if(dp[(j * (j + 1) * (j + 2)) / 6 + i] > dp[i] + 1)
						dp[(j * (j + 1) * (j + 2)) / 6 + i] = dp[i] + 1;
				}
			}
				if(small > dp[n])
					small = dp[n];
		}

		min1 = dp[n];
		for(i = 0;i <= n;i++)
			dp[i] = INF;
		dp[0] = 0;
		small = INF;
		for(i = 0;i < n;i++){
			if(dp[i] < small){
				for(j = 1;(j * (j + 1) * (j + 2)) / 6 + i <= n;j++){
					if(dp[(j * (j + 1) * (j + 2)) / 6 + i] > dp[i] + 1 && j * (j + 1) * (j + 2) / 6 % 2 == 1)
						dp[(j * (j + 1) * (j + 2)) / 6 + i] = dp[i] + 1;
				}
			}
			if(small > dp[n])
				small = dp[n];
		}
		printf("%d %d\n",min1,dp[n]);
		scanf("%d",&n);
	}
	return 0;
}

C++: #include<bits/stdc++.h>
#define M 1111111
#define INF 1<<28
using namespace std;

int data[M];
int memo[M], memo2[M];

int solve(int n){

  if(!n) return 0;
  if(n < 0) return INF;
  if(~memo[n]) return memo[n];
  
  int ret = INF;
  for(int i=1;data[i]<=n;i++) ret = min(ret, solve(n-data[i])+1);

  return memo[n] = ret;
}

int solve2(int n){

  if(!n) return 0;
  if(n < 0) return INF;
  if(~memo2[n]) return memo2[n];
  
  int ret = INF;
  for(int i=1;data[i]<=n;i+=2)
    if(data[i]&1) ret = min(ret, solve2(n-data[i])+1);

  return memo2[n] = ret;
}

int main(){

  for(int i=0;i<M;i++) data[i] = (i*(i+1)*(i+2))/6;
  
  int n;

  while(cin >> n, n){

    memset(memo, -1, sizeof(memo));
    memset(memo2, -1, sizeof(memo2));
    
    cout << solve(n) << " " << solve2(n) << endl;

  }
}