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++: // clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return ~n & 1; }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

main {
  vector<int> dp1(1000001), dp2(1000001);
  iota(all(dp1), 0), iota(all(dp2), 0);
  for (int g = 2;; g++) {
    int p = g * (g + 1) * (g + 2) / 6;
    if (p > 1000000) break;
    for (int i = p; i <= 1000000; i++) cmin(dp1[i], dp1[i - p] + 1);
    if (odd(p)) {
      for (int i = p; i <= 1000000; i++) cmin(dp2[i], dp2[i - p] + 1);
    }
  }
  while (true) {
    int n = in();
    if (n == 0) break;
    cout << dp1[n] << ' ' << dp2[n] << endl;
  }
}

C++: #include <iostream>
#include <set>
#define MAXNUM 10000
using namespace std;

int all[MAXNUM], odd[MAXNUM];
set<int> allfour, oddfour;
int max(int a, int b);
int min(int a, int b);
int getall(int n);
int getodd(int n);

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

	//1からMAXまでの中に存在する正四面体数をsetに入れる．
	int now = 0, four;
	while (1){
		now++;
		four = now  *(now + 1)*(now + 2) / 6;
		if (four > MAXNUM)
			break;
		allfour.insert(four);
		if (four % 2 == 1)
			oddfour.insert(four);
	}

	//1からMAXNUMまで，配列を埋める.
	for (int i = 1; i <= MAXNUM; i++){
		all[i] = getall(i);
		odd[i] = getodd(i);
	}

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

	return 0;

}




int max(int a, int b){
	if (a > b)
		return a;
	else
		return b;
}

int min(int a, int b){
	if (a > b)
		return b;
	else
		return a;
}

int getall(int n){
	set<int>::iterator it = allfour.find(n);
	if (it != allfour.end())
		return 1;
	else{
		int minnum = 1000;
		for (int i = 1; i < n / 2 + 1; i++){
			minnum = min(minnum, all[i] + all[n - i]);
		}
		return minnum;
	}
}

int getodd(int n){
	set<int>::iterator it = oddfour.find(n);
	if (it != oddfour.end())
		return 1;
	else{
		int minnum = 1000;
		for (int i = 1; i < n / 2 + 1; i++){
			minnum = min(minnum, odd[i] + odd[n - i]);
		}
		return minnum;
	}
}

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, tetra_odd;

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

  for (int i = 0; i < MAX; ++i)
    dp[i] = dp_odd[i] = i;

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

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