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 <vector>
#include <algorithm>
using namespace std;

vector<int> poloc;
vector<int> poloc_odd;

void make_poloc()
{
	int n=1;
	while(1){
		int a = n*(n+1)*(n+2)/6;
		if(a > 1000000)
			break;
		
		poloc.push_back(a);
		if(a % 2 == 1)
			poloc_odd.push_back(a); 
		n++;
	}
}
/*
int search1(int n, int i, int depth)
{
	if(n == 0)
		return depth;
	else if(n < 0 || i < 0)
		return 1000000;
	else
		return min( min(search1(n-poloc[i],i-1,depth+1), search1(n,i-1,depth)), search1(n-poloc[i],i,depth+1));
}
int search2(int n, int i, int depth)
{
	if(n == 0)
		return depth;
	else if(n < 0 || i < 0)
		return 1000000;
	else
		//return min( min(search2(n-poloc_odd[i],i-1,depth+1), search2(n,i-1,depth)), search2(n-poloc_odd[i],i,depth+1));
		return min(search2(n-poloc_odd[i],i-1,depth+1), search2(n,i-1,depth));
}
*/

int main()
{
	make_poloc();
	int n;
	int dp[1000001];
	for(int i=0;i<=1000000;i++){
		dp[i] = 1000000;
	}
	dp[0] = 0;
	for(int i=0;i<poloc.size();i++){
		for(int j=0;j<=1000000;j++){
				if(j+poloc[i] <= 1000000)
					dp[j+poloc[i]] = min(dp[j+poloc[i]],dp[j]+1);
			
		}
	}
	int dpp[1000001] = {0};
	for(int i=0;i<=1000000;i++){
		dpp[i] = 1000000;
	}
	dpp[0] = 0;
	for(int i=0;i<poloc_odd.size();i++){
		for(int j=0;j<=1000000;j++){
				if(j+poloc_odd[i] <= 1000000)
					dpp[j+poloc_odd[i]] = min(dpp[j+poloc_odd[i]],dpp[j]+1);
		}
	}

	while(cin >> n){
		if(n==0)
			break;
		cout << dp[n] << " " << dpp[n] << endl;
	}

	return 0;
	
}

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

#define LET(name, value) __typeof(value) name = value
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define FOREQ(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOREACH(i, c) for (LET(i, (c).begin()); i != (c).end(); ++i)

const int M = 181;
int tetra[M];
int memo1[1000010];
int memo2[1000010];

int dfs1(int n) {
  if (memo1[n] != -1) { return memo1[n]; }
  if (n == 0) { return memo1[n] = 0; }
  int ret = 1000000;
  for (int i = M-1; i >= 0; --i) {
    if (tetra[i] <= n) {
      ret = min(ret, dfs1(n-tetra[i])+1);
    }
  }
  return memo1[n] = ret;
}

int dfs2(int n) {
  if (memo2[n] != -1) { return memo2[n]; }
  if (n == 0) { return memo2[n] = 0; }
  int ret = 1000000;
  for (int i = M-1; i >= 0; --i) {
    if (tetra[i] <= n && tetra[i] % 2 == 1) {
      ret = min(ret, dfs2(n-tetra[i])+1);
    }
  }
  return memo2[n] = ret;
}

int main() {
  memset(memo1, -1, sizeof(memo1));
  memset(memo2, -1, sizeof(memo2));

  int sum = 1;
  tetra[0] = 1;
  FOR(i, 1, M) {
    sum += i+1;
    tetra[i] = tetra[i-1]+sum;
  }

  int n;
  while (scanf("%d", &n), n) {
    printf("%d %d\n", dfs1(n), dfs2(n));
  }
}

C++: #include <map>
#include <set>
#include <list>
#include <cstdio>
#include <cmath>
#include <deque>
#include <stack>
#include <bitset>
#include <cctype>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define fr first
#define sc second
#define mp make_pair
#define foreach(c, it) for(typeof(c) it = (c).begin(); it != (c).end(); it++)

typedef long long int64;
typedef pair< int, int > iP;
typedef pair< iP, int > iiP;

const int MAX = 1000000;
const int INF = 2 << 28;
const double EPS = 1e-10;

int p[4 * MAX + 1], op[4  *MAX + 1];
vector < int > num;
int main() {
    
    for(int i = 0; i < 2 + MAX + 1; i++)
        p[i] = op[i] = INF;
    
    for(int i = 1; i < 200; i++) {
        num.push_back(i * (i + 1) * (i + 2) / 6);
        p[i * (i + 1) * (i + 2) / 6] = 1;
        if((i * (i + 1) * (i + 2) / 6) % 2) op[i * (i + 1) * (i + 2) / 6] = 1;
    }

    for(int i = 1; i <= MAX; i++) {
        for(int j = 0; j <num.size(); j++) {
            if(p[i] != INF) {
                p[i + num[j]] = min(p[i] + 1, p[i + num[j]]);
            }
            if(op[i]  != INF && num[j] % 2) {
                op[i + num[j]] = min(op[i] + 1, op[i + num[j]]);
            }
        }
    }
    
    int N;
    while(cin >> N, N) {
        cout << p[N] << " " << op[N] << endl;
    }
}

C++: #include <iostream>
using namespace std;
int main(){
  int a[190]={0},b[50]={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-1;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;
}