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;
const long long int mod = 1000000007;

//i*2^X>=K
//2^X>=
int main() {
	vector<int>Prk(181),dp(1000001,mod), dpi(1000001, mod);
	for (size_t i = 1; i <= 180; i++)
	{
		Prk.at(i) = i * (i + 1) * (i + 2) / 6;
	}
	dp.at(0) = 0;
	dpi.at(0) = 0;
	for (size_t i = 1; i <= 180; i++)
	{
		for (size_t j = Prk.at(i); j <= 1000000; j++)
		{
			dp.at(j) = min(dp.at(j - Prk.at(i)) + 1, dp.at(j));
			if (Prk.at(i) % 2)dpi.at(j) = min(dpi.at(j - Prk.at(i))+1, dpi.at(j));
		}
	}
	int task;
	while (true)
	{
		cin >> task;
		if (task == 0)return 0;
		cout << dp.at(task) << " " << dpi.at(task) << endl;
	}
}

C++: #include<bits/stdc++.h>
#define MAX_N  int(pow(10.0,6.0))

using namespace std;
int calc(int x){
    return int(x*(x+1)*(x+2)/6);
}


int main(){
    int n;

    int dp[MAX_N];
    int dp_odd[MAX_N];
    int L[200]; //200くらいで正四面体数は10**6を超える
    for(int i=0;i<MAX_N;i++){
        dp[i]=MAX_N;
        dp_odd[i]=MAX_N;
    }
    dp[0]=0;//dp[n]はnを作るのに必要な正四面体数の、最小の個数
    dp_odd[0]=0;//奇数version

    for(int i=0;i<200;i++){
        L[i]=calc(i);
    }

    int new_val;
    for(int x=0;x<MAX_N;x++){
        for(int y=0;y<200;y++){
            new_val= x-L[y];
            if (new_val>=0){
                dp[x] = min(dp[x],dp[new_val]+1);
                if (L[y]%2==1){
                    dp_odd[x] = min(dp_odd[x],dp_odd[new_val]+1); 
                }
            }
        }
    }

    while(true){
        cin >> n;
        if(n==0){
            break;
        }
        printf("%d %d\n",dp[n],dp_odd[n]);
    }
    return 0;
}

C++: #include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
  int INF=(1<<29),n,i,j,dp[1000010],dp1[1000010];
  vector<int> a,b;
  i=0;
  while(1){
    a.push_back((i+1)*(i+2)*(i+3)/6);
    if(a[i]%2==1){
      b.push_back(a[i]);
    }
    if(a[i]>1000000){
      break;
    }
    i++;
  }
  for(i=0;i<=1000000;i++){
    dp[i]=INF;
    dp1[i]=INF;
  }
  dp[0]=0,dp1[0]=0;
  for(i=0;i<a.size();i++){
    for(j=0;j<=1000000;j++){
      if(j-a[i]>=0){
        dp[j]=min(dp[j],dp[j-a[i]]+1);
      }
    }
  }
  for(i=0;i<b.size();i++){
    for(j=0;j<=1000000;j++){
      if(j-b[i]>=0){
        dp1[j]=min(dp1[j],dp1[j-b[i]]+1);
      }
    }
  }
  while(1){
    scanf("%d\n",&n);
    if(n==0){
      break;
    }
    printf("%d %d\n",dp[n],dp1[n]);
  }
  return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
#define EPS (long double) 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;

int dp1[1000001];
int dp2[1000001];

set<int> por;
vector<int> porv;
set<int> pork;
vector<int> porkv;

int rec1(int n) {
	cout<<n<<endl;
	if(n < 0) return INF;
	if(dp1[n] != INF) return dp1[n];
	if(por.count(n) != 0) return 1;
	int res = INF;
	REP(i, porv.size()) {
		res = min(res, rec1(n - porv[i] ) + 1);
	}
	return dp1[n] = res;
}

int rec2(int n) {
	cout<<n<<endl;
	if(n < 0) return INF;
	if(dp2[n] != INF) return dp2[n];
	if(pork.count(n) != 0) return 1;
	int res = INF;
	REP(i, porkv.size()) {
		res = min(res, rec2(n - porkv[i]) + 1);
	}
	return dp2[n] = res;
}

int main() {
	REP(i, 1000001) dp1[i] = dp2[i] = INF;
	dp1[0] = 0;
	dp2[0] = 0;
	int buf = 1;
	while(buf * (buf + 1) * (buf + 2) / 6 <= pow(10, 6)) {
		por.insert(buf * (buf + 1) * (buf + 2) / 6);
		porv.pb(buf * (buf + 1) * (buf + 2) / 6);
		if((buf * (buf + 1) * (buf + 2) / 6) % 2 == 1) {
			pork.insert(buf * (buf + 1) * (buf + 2) / 6);
			porkv.pb(buf * (buf + 1) * (buf + 2) / 6);
		}
		++buf;
	}
	sort(ALL(porv));
	sort(ALL(porkv));
	REP(i, 1000001) {
		if(i == 0) dp1[i] = 0;
		else if(por.count(i) != 0) dp1[i] = 1;
		else {
			int roc = 0;
			int res = INF;
			while(roc < porv.size() && i - porv[roc] >= 0) {
				res = min(res, dp1[i - porv[roc]] + 1);
				++roc;
			}
			dp1[i] = res;
		}
	}
	REP(i, 1000001) {
		if(i == 0) dp2[i] = 0;
		else if(pork.count(i) != 0) dp2[i] = 1;
		else {
			int roc = 0;
			int res = INF;
			while(roc < porkv.size() && i - porkv[roc] >= 0) {
				res = min(res, dp2[i - porkv[roc]] + 1);
				++roc;
			}
			dp2[i] = res;
		}
	}
	while(1) {
		int n;
		cin>>n;
		if(n == 0) break;
		cout<<dp1[n]<<" "<<dp2[n]<<endl;
	}
}