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;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
/*
template<class... T>
ostream& operator<<(ostream& os, tuple<T...>& t) {
	for (size_t i = 0; i < tuple_size< tuple<T...> >::value; ++i) {
		if (i) os << " ";
		os << get<0>(t);
	}
	return os;
}
*/
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

const int maxN = 1000000;
int dp1[maxN+1] = {0}, dp2[maxN+1] = {0};
int temp[maxN+1];

typedef long long ll;

int f(ll n) {
	return n * (n+1) * (n+2) / 6;
}

void knapsack(int dp[], const vector<int>& v) {
	int *now = dp, *next = temp;
	fill(now, now+maxN+1, inf); now[0] = 0;
	for (int i = 0; i < v.size(); ++i) {
		fill(next, next+maxN+1, inf);
		for (int j = 0; j <= maxN; ++j) {
			next[j] = min(next[j], now[j]);
			int nj = j + v[i];
			if (nj <= maxN) {
				now[nj] = min(now[nj], now[j]+1);
			}
		}
		swap(now, next);
	}
	for (int i = 0; i <= maxN; ++i) {
		dp[i] = now[i];
	}
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	vector<int> v1, v2;
	REP(i, maxN+1) {
		if ( f(i) >= maxN ) break;
		v1.push_back( f(i) );
		if ( f(i) % 2 == 1 ) {
			v2.push_back( f(i) );
		}
	}
	knapsack(dp1, v1);
	knapsack(dp2, v2);

	int N;
	while (cin >> N, N) {
		cout << dp1[N] << " " << dp2[N] << endl;
	}
}

C++: #include<iostream>
#define MAX 1000001
using namespace std;
const int infty = 1<<25;
int main()
{
  int allnum = 0;
  int oddnum = 0;
  static int KAll[MAX];
  static int KOdd[MAX];
  static int Answer1[MAX];
  static int Answer2[MAX];
  Answer1[0]=0;
  Answer2[0]=0;

  int n = 1;
  while( true ){
    int t = n*(n+1)*(n+2) / 6;
    if( t >= MAX ) break;
    KAll[allnum++]=t;
    if( t % 2 == 1 ){
      KOdd[oddnum++]=t;
    }
    ++n;
  }
  
  for(int i = 1; i < MAX; ++i){
    Answer2[i] = Answer1[i] = infty;
    for(int j = 0; j < allnum && i - KAll[j] >= 0; ++j){
      Answer1[i] = min(Answer1[i], 1+Answer1[i-KAll[j]]);
    }
    for(int j = 0; j < oddnum && i - KOdd[j] >= 0; ++j){
      Answer2[i] = min(Answer2[i], 1+Answer2[i-KOdd[j]]);
    }
  }
  
  while(true){
    int N;
    scanf("%d", &N);
    if( N == 0 ) break;
    printf("%d %d\n", Answer1[N], Answer2[N]);
  }
  return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    vector<ll> all_target, odd_target;
    rep2(i, 1, 500) {
        ll r = (i * (i + 1) * (i + 2)) / 6;
        if (r % 2) {
            odd_target.push_back(r);
        }
        all_target.push_back(r);
    }
    vector<ll> dp1(1e6, INF);
    vector<ll> dp2(1e6, INF);
    dp1[0] = 0;
    dp2[0] = 0;
    rep(i, 1e6) {
        for (ll a : all_target) {
            if (i + a < 1e6) {
                dp1[i + a] = min(dp1[i + a], dp1[i] + 1);
            }
        }
    }
    rep(i, 1e6) {
        for (ll o : odd_target) {
            if (i + o < 1e6) {
                dp2[i + o] = min(dp2[i + o], dp2[i] + 1);
            }
        }
    }
    while (true) {
        ll n;
        cin >> n;
        if (!n) return;
        cout << dp1[n] << ' ';
        cout << dp2[n] << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}