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>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
#include<climits>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)

const int lim = 300;
const int lim_ = 1000001;
int tri[lim];
int tetra[lim];
int n;
int table[lim_];
int odd[lim_];
int main() {
    tri[1] = 1;
    rrep(i, 2, lim) {
        tri[i] = tri[i - 1];
        tri[i] += i;
    }
    //cout << tri[lim - 1] << endl;
    tetra[1] = 1;
    rrep(i, 2, lim) {
        tetra[i] = tetra[i - 1];
        tetra[i] += tri[i];
    }
    //rep(i, 5) cout << tetra[i] << " "; cout << endl;
    //cout << tetra[lim - 1] << endl;
    rep(i, lim_) table[i] = odd[i] = inf;
    table[0] = odd[0] = 0;
    rep(i, lim) {
        rep(j, lim_) {
            if (table[j] != inf && j + tetra[i] < lim_) {
                chmin(table[j + tetra[i]], table[j] + 1);
            }
        }
        if (tetra[i] % 2 == 0) continue;
        rep(j, lim_) {
            if (odd[j] != inf && j + tetra[i] < lim_) {
                chmin(odd[j + tetra[i]], odd[j] + 1);
            }
        }
    }
    
    while (cin >> n && n) {
        cout << table[n] << " " << odd[n] << endl;
    }
    
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
#define INF (1<<25)
int N;
int pr[102];
int dp[1000002];
void init(){
  for(int i=0;i<=N;i++) dp[i]=INF;
}
int solve(int g){
  dp[0]=0;
  for(int i=0;i<=N;i++){
    if(dp[i]==INF) continue;
    for(int j=0;j<102;j++){
      if(g==2 && pr[j]%g==0) continue;
      if(i+pr[j]>N) continue;
      dp[i+pr[j]] = min(dp[i+pr[j]],dp[i]+1);
    }
  }

  //  for(int i=0;i<=N;i++) printf("id=%d => %d\n",i,dp[i]);
  return dp[N];
}

int main(){
  for(int i=0;i<102;i++) pr[i] = (i+1)*(i+2)*(i+3)/6;
  //  for(int i=0;i<102;i++) printf("%d\n",pr[i]);
  //  for(int i=0;i<102;i++) if(!(i%2)) printf("%d\n",pr[i]);
  while(1){
    scanf("%d",&N);
    if(!N) break;
    init();
    int res1 = solve(1);
    init();
    int res2 = solve(2);
    printf("%d %d\n",res1,res2);
  }
}

C++: #include <iostream>
#include <cassert>
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,l,n) for(int i=l;i<n;++i)
int ans = 0;
int oddans = 0;
int pol[200];
int oddpol[100];
int oddpolcount = 0;
int memo[1000000];
int oddmemo[1000000];
int memorep(int n);
int oddmemorep(int n);
using namespace std;
int main() {
  pol[0] = 1;
  oddpol[oddpolcount++] = 1;
  int def = 3;
  int defdef = 3;
  REP(i,1,180){
    pol[i] = pol[i-1] + def;
    if(pol[i]%2==1) oddpol[oddpolcount++] = pol[i];
    def += defdef++;
  }
  while(1){
    int n;
    cin >> n;
    if(n==0) return 0;
    ans = memorep(n);
    oddans = oddmemorep(n);
    int i = 0;
    cout << ans << " " << oddans << endl;
  }
  return 0;
}

int memorep(int n){
  assert(n < 1000000);
  if(memo[n]!=0) return memo[n];
  int result;
  int min = 1000000;
  for(int i = 179;i>=0;i--){
    result = n-pol[i];
    if(result == 0){
      return memo[n] = 1;
    }
    if(result > 0){
      result = memorep(result) + 1;
      if(min > result) min = result;
    }
  }
  return memo[n] = min;
}

int oddmemorep(int n){
  if(oddmemo[n]!=0) return oddmemo[n];
  int result;
  int min = 1000000;
  for(int i = oddpolcount-1;i>=0;i--){
    result = n-oddpol[i];
    if(result == 0){
      return oddmemo[n] = 1;
    }
    if(result > 0){
      result = oddmemorep(result) + 1;
      if(min > result){
        min = result;
      }
    }
  }
  return oddmemo[n] = min;
}

C++: #include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>

using namespace std;

int dp[1000005];
int dp2[1000005];
int pl[180];

int main() {
	//init
	for (int i = 1; i<=180; i++)pl[i-1] = (i*(i + 1)*(i + 2)) / 6;
	memset(dp, 0x7f, sizeof(dp));
	memset(dp2, 0x7f, sizeof(dp2));
	dp[0] = 0;
	dp2[0] = 0;
	for (int i = 0; i < 1000000; i++) {
		for (int j = 0; j < 180; j++) {
			if(i+pl[j] <= 1000000)dp[i + pl[j]] = min(dp[i] + 1, dp[i + pl[j]]);
			if (i + pl[j] <= 1000000 && pl[j]&1)dp2[i + pl[j]] = min(dp2[i] + 1, dp2[i + pl[j]]);
		}
	}
	while (1) {
		int n;
		scanf("%d", &n);
		if (n == 0)break;
		printf("%d %d\n", dp[n], dp2[n]);
	}
	return 0;
}