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 <algorithm>
#include <vector>
using namespace std;
vector <int> c;
vector <int> a,b;

int main() {


  c.push_back(0);
  for(int i=1;c[i-1]<=1000010;i++) c.push_back(i*(i+1)*(i+2)/6);
   
  for(int i=0;i<=1000001;i++) {
    a.push_back(i);
    b.push_back(i);
  }
  
  for(int i=0;i<c.size();i++) {
    for(int j=1;j<=1000000;j++) {
      
      if(j-c[i] >=0) { 
     
	if(a[j-c[i]] >= 0) a[j] = min(a[j], a[j-c[i]]+1);

	if(c[i] % 2 == 1 && b[j-c[i]] >=0){
	  b[j] = min(b[j],b[j-c[i]]+1);
	}
      }
      
    }
  }

 while(1) {
    int m;
  cin >> m;
  if(m == 0) break;
  
  cout << a[m] <<" " << b[m] << endl;
  
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define int             long long
#define rep(i, n)       for(int i=0; i<(n); ++i)
#define REP(i, d, n)    for(int i=(d); i<(n); ++i)
#define all(v)          v.begin(), v.end()
using P = pair<int, int>;

template<class T> 
inline bool chmax(T &a, const T &b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

template<class T> 
inline bool chmin(T &a, const T &b){
    if(a > b){
        a = b;
        return true;
    }
    return 0;
}

signed main() {

    vector<int> tetra;
    for(int i = 1; ; ++i){
        int p = i*(i+1)*(i+2) / 6;  // 連続する3つの整数の積は6の倍数なので必ず割り切れる
        if(p > 1e6){
            break;
        }
        tetra.push_back(p);
    }
    int m = tetra.size();
    
    vector<int> dp(1e6 + 1, 1LL << 60), dp_odd(1e6 + 1, 1LL << 60);
    dp[0] = 0;
    dp_odd[0] = 0;
    rep(i, 1e6+1){
        rep(j, m){
            if(i + tetra[j] >= 1e6){
                break;
            }
            chmin(dp[i+tetra[j]], dp[i]+1);
            if(tetra[j] % 2){   // 正四面体数が奇数の時
                chmin(dp_odd[i+tetra[j]], dp_odd[i]+1);
            }
        }
    }
    
    int n;
    while(true){
        cin >> n;
        if(n == 0){
            break;
        }
        cout << dp[n] << ' ' << dp_odd[n] << '\n';
    }
    return 0;
}

C++: #include <cstdio>
#include <utility>
#include <algorithm>
#include <array>
#include <numeric>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_in(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in(gcu());}
_sc(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
//_sc(string &s){int c;s="";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
template <typename H,typename... T> _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
template <typename T>
_vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
//_vo(string &s){for (char c: s) pcu(c);}
template <typename H,typename... T> _vo(H&& h, T&&... t){out(h);out(move(t)...);}
//template <typename T> _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
_vl(){out('\n');}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

enum {N = 1000000};

int main() {
	array<int, N> s1, s2;
	iota(s1.begin(), s1.end(), 0);
	iota(s2.begin(), s2.end(), 0);
	for (int i = 1, n; (n = i * (i + 1) * (i + 2) / 6) < N; i++) {
		for (auto j = s1.begin() + n; j != s1.end(); j++)
			*j = min(*j, *(j - n) + 1);
		if (n % 2)
			for (auto j = s2.begin() + n; j != s2.end(); j++)
				*j = min(*j, *(j - n) + 1);
	}
	for (int n; (n = in());)
		outl(s1[n], ' ', s2[n]);
}

C++: #include <bits/stdc++.h>
using namespace std;

using ll = long long;

constexpr int INF = 1e9;

int main() {
    constexpr int MAX = 1000000;
    ll now = 1;
    vector<ll> v;
    while(now*(now+1)*(now+2)/6 <= MAX) {
        ll t = now*(now+1)*(now+2)/6;
        v.push_back(t);
        now++;
    }
    vector<int> dp1(MAX+1, INF);
    vector<int> dp2(MAX+1, INF);
    dp1[0] = dp2[0] = 0;
    for(auto t : v) {
        for(int i=0; i+t<=MAX; ++i) {
            dp1[i+t] = min(dp1[i+t], dp1[i] + 1);
            if(t & 1) {
                dp2[i+t] = min(dp2[i+t], dp2[i] + 1);
            }
        }
    }
    int n;
    while(cin >> n, n) {
        cout << dp1[n] << ' ' << dp2[n] << endl;
    }
}

C++: #include <iostream>
#define REP(i, a, n) for(int i = (a); i <= (n); i++)
#define INF 100000000
using namespace std;

const int M = 1000000;
int N, base1[M + 1], base2[M + 2], dp1[M + 1], dp2[M + 1];

int dfs1(int n) {
  if(dp1[n] >= 0) return dp1[n];
  if(base1[n]) return dp1[n] = 1;

  int ret = INF;
  REP(i, 1, n - 1) {
    if(!base1[i]) continue;
    ret = min(ret, dfs1(i) + dfs1(n - i));
  }
  return dp1[n] = ret;
}

int dfs2(int n) {
  if(dp2[n] >= 0) return dp2[n];
  if(base2[n]) return dp2[n] = 1;

  int ret = INF;
  REP(i, 1, n - 1) {
    if(!base2[i]) continue;
    ret = min(ret, dfs2(i) + dfs2(n - i));
  }
  return dp2[n] = ret;
}

int main(void) {
  REP(i, 1, M) dp1[i] = dp2[i] = -1, base1[i] = base2[i] = 0;
  for(int i = 1, n; n = i * (i + 1) * (i + 2) / 6, n <= M; i++) {
    base1[n] = 1;
    if(n % 2 == 1) base2[n] = 1;
  }

  while(cin >> N, N) {
    cout << dfs1(N) << " " << dfs2(N) << endl;
  }

  return 0;
}