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>
using namespace std;

const int MAX_N = 1000000;
const int INF = 1000000000;

int dp_nat[MAX_N]; // dp_nat[i]: 数字iを作るための最小の正四面体の個数
int dp_odd[MAX_N]; // dp_odd[i]: 数字iを作るための最小の奇数の正四面体の個数

vector<int> tetras; // 正四面体数
vector<int> odd_tetras; // 奇数の正四面体数

int main() {
  // 正四面体数を事前に計算しておく
  for(int i = 1; 1; i++) {
    int m = i*(i+1)*(i+2)/6;
    if (m > MAX_N) break;
    tetras.push_back(m);
    if (m % 2 != 0) odd_tetras.push_back(m);
  }

  // 入力のnによらずdp_natとdp_oddの中身は同じになるので、入力を読む前に計算しておく

  // 全ての正四面体数を使ったパターン
  dp_nat[0] = 0;
  for (int i = 1; i < MAX_N; i++) {
    dp_nat[i] = INF;
    for (int j = 0; j < tetras.size(); j++) {
//    cout << "dbg" << i << "," << dp_nat[i] << endl;
      if (i - tetras[j] < 0) break;
      dp_nat[i] = min(dp_nat[i], dp_nat[i - tetras[j]] + 1);
    }
  }

  // 奇数のみのパターン
  dp_odd[0] = 0;
  for (int i = 1; i < MAX_N; i++) {
    dp_odd[i] = INF;
    for (int j = 0; j < odd_tetras.size(); j++) {
      if (i - odd_tetras[j] < 0) break;
      dp_odd[i] = min(dp_odd[i], dp_odd[i - odd_tetras[j]] + 1);
    }
  }

  int n;
  while(cin >> n, n != 0) {
    cout << dp_nat[n] << " " << dp_odd[n] << endl;
  }
  return 0;
}

C++: #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

//ll dx[4] = {1, 0, -1, 0};
//ll dy[4] = {0, 1, 0, -1};

const ll MAX = 1e6;
ll dp[MAX];
ll dp2[MAX];
int main() {
	IOS;
	vector<ll> a, a2;
	ll n   = 1;
	ll tmp = 2;
	while (tmp < 1e6) {
		tmp = n * (n + 1) * (n + 2) / 6;
		a.push_back(tmp);
		if (tmp % 2 == 1) a2.push_back(tmp);
		n++;
	}
	Fill(dp, INF);
	Fill(dp2, INF);
	ll m  = a.size();
	ll m2 = a2.size();
	dp[0] = dp2[0] = 0;
	for (int i = 1; i <= MAX; i++) {
		for (int j = 0; j < m; j++) {
			if (i >= a[j]) dp[i] = min(dp[i], dp[i - a[j]] + 1);
		}
	}
	for (int i = 1; i <= MAX; i++) {
		for (int j = 0; j < m2; j++) {
			if (i >= a2[j]) dp2[i] = min(dp2[i], dp2[i - a2[j]] + 1);
		}
	}

	ll i = 1;
	while (i) {
		cin >> i;
		if (i == 0) break;
		cout << dp[i] << " " << dp2[i] << endl;
	}
	return 0;
}

C++: #include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define NMAX 1000000
int main(){
  vector<int> L;
  int i=1;
  while (true){
    int t=i*(i+1)*(i+2)/6;
    if (t>NMAX) break;
    L.push_back(t);
    i++;
  }
  int E[NMAX];
  int O[NMAX];
  for (int i=0;i<NMAX;i++){
    E[i]=i;
    O[i]=i;
  }
  for (int i=0;i<NMAX;i++)
    for (int j=0;j<L.size();j++){
      if (L[j]>i) break;
      int c=i/L[j]+E[i%L[j]];
      E[i]=min(E[i],c);
      if (L[j]%2==1){
        c=i/L[j]+O[i%L[j]];
        O[i]=min(O[i],c);
      }
    }
  while (true){
    int n;
    cin>>n;
    if (n==0) return 0;
    cout<<E[n]<<" "<<O[n]<<endl;
  }
}