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 LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RFOR(i, a, b) for (int i = (int)(b - 1); i >= (int)(a); --i)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for (int i = (int)(n - 1); i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define SQ(x) ((x) * (x))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define MAX_N 181
#define INF 100000000

int r[MAX_N];

int main() {
    r[0] = 0;
    r[1] = 1;
    int j = 3;
    FOR(i, 2, MAX_N) {
        r[i] = r[i-1] + j;
        j += i+1;
    }

    int n;
    while (cin >> n, n) {
        vvi dp(2, vi(n+1, INF));
        FOR(i, 1, MAX_N) {
            if (r[i] <= n) {
                dp[0][r[i]] = 1;
            } else {
                break;
            }
        }
        while (dp[0][n] == INF) {
            FOR(i, 1, n+1) {
                if (dp[0][i] != INF) {
                    REP(j, MAX_N) {
                        if (i + r[j] <= n) {
                            dp[1][i+r[j]] = min(dp[0][i+r[j]], dp[0][i] + 1);
                        }
                    }
                }
            }
            dp[0] = dp[1];
        }
        cout << dp[0][n] << " ";

        fill(ALL(dp[0]), INF);
        fill(ALL(dp[1]), INF);
        FOR(i, 1, MAX_N) {
            if (r[i] <= n) {
                if (r[i] % 2 == 1) dp[0][r[i]] = 1;
            } else {
                break;
            }
        }
        while (dp[0][n] == INF) {
            FOR(i, 1, n+1) {
                if (dp[0][i] != INF) {
                    REP(j, MAX_N) {
                        if (r[j] % 2 == 1 && i + r[j] <= n) {
                            dp[1][i+r[j]] = min(dp[0][i+r[j]], dp[0][i] + 1);
                        }
                    }
                }
            }
            dp[0] = dp[1];
        }
        cout << dp[0][n] << endl;
    }
}

C++: #include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  int n;

  const int INF = 1e9;
  const int N_MAX = 1e6;

  vector<int> dp(N_MAX, INF), dpo(N_MAX, INF);
  dp[0] = 0;
  dpo[0] = 0;

  for (int i = 1, t = 1; t < N_MAX; ++i, t = i * (i + 1) * (i + 2) / 6) {
    for (int j = 0; j < (int)(N_MAX); ++j) {
      int nj = j + t;
      if (nj < N_MAX) chmin(dp[nj], dp[j] + 1);
      if (nj < N_MAX && t % 2 == 1) chmin(dpo[nj], dpo[j] + 1);
    }
  }

  while (true) {
    cin >> n;
    if (n == 0) return 0;
    cout << dp[n] << " " << dpo[n] << endl;
  }
}

C++: //#include "bits/stdc++.h"

#include <iostream>
#include <vector>
// #include <map>
// #include <string>
// #include <algorithm>
// #include <numeric>
// #include <limits>

using namespace std;

using uint = unsigned int;

const uint s = 1.E6;

uint ans[s];
uint ans_odd[s];

inline uint regularTetrahedronNum(uint n) {
	return n * (n + 1) * (n + 2) / 6;
}

inline void update(uint rt_num) {
	for (uint i = rt_num; i < s; i++) {
		ans[i] = min(ans[i], ans[i - rt_num] + 1);
	}
	if (rt_num % 2 == 0) {
		return;
	}
	for (uint i = rt_num; i < s; i++) {
		ans_odd[i] = min(ans_odd[i], ans_odd[i - rt_num] + 1);
	}
}

void print() {
	std::cout << "debug " << std::endl; // debug
	for (uint i = 0; i < s; i++) {
		cout << i << ": " << ans[i] << " " << ans_odd[i] << endl;
	}
}

int main() {
	for (uint i = 0; i < s; i++) {
		ans[i] = i;
		ans_odd[i] = i;
	}
	for (uint i = 2; i < s; i++ ) {
		auto num = regularTetrahedronNum(i);
		if (num > s) {
			break;
		}
		update(num);
	}

	//print();
	while (true) {
		uint tmp;
		cin >> tmp;
		if (tmp == 0) {
			break;
		}
		cout << ans[tmp] << " " << ans_odd[tmp] << endl;

	}

	//std::cout << "\e[38;5;0m\e[48;5;40m --- end ---  \e[m" << std::endl; // debug
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int x[8000000][2], a[999], b[999], s, n;
int main() {
	a[0] = 1; b[0] = 1;
	for (int i = 1; i < 300; i++) {
		a[i] = a[i - 1] + (i + 1)*(i + 2) / 2;
		if (a[i] % 2 == 1) {
			s++; b[s] = a[i];
		}
	}
	n = 1200000;
	memset(x, 127, sizeof(x));
	x[0][0] = 0; x[0][1] = 0;
	for (int i = 0; i < 200; i++) {
		for (int j = 0; j < n; j++) {
			x[j + a[i]][0] = min(x[j + a[i]][0], x[j][0] + 1);
		}
	}
	for (int i = 0; i < 50; i++) {
		for (int j = 0; j < n; j++) {
			x[j + b[i]][1] = min(x[j + b[i]][1], x[j][1] + 1);
		}
	}
	while (true) {
		cin >> n; if (!n) { break; }
		cout << x[n][0] << ' ' << x[n][1] << endl;
	}
}