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++: //http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1167&lang=jp
//Pollock's conjecture
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
ll calc_vol(ll n){
	return n*(n+1)*(n+2)/6;
}
constexpr ll INF=2LL<<60;

int main(){
#if LOCAL&01
	std::ifstream in("./test/sample-1.in");
	//std::ifstream in("./input.txt");
	std::cin.rdbuf(in.rdbuf());
#else
	cin.tie(0);
	ios::sync_with_stdio(false);
#endif

	ll val=1e+6;
	ll limit=1;
	vector<ll> vols0(2),vols1(2);
	vols0[0]=0; vols1[0]=0;
	vols0[1]=1; vols1[1]=1;
	while(calc_vol(limit+1)<=val){
		auto v=calc_vol(limit+1);
		vols0.push_back(v);
		if(v%2==1)vols1.push_back(v);
		limit++;
	}

	auto mktbl = [&val](vector<ll>& dp, const auto& vols){
		dp[0]=0;
		ll lim = vols.size()-1;
		FOR(i,0,lim){
			ll vol=vols.at(i+1);
			dump(vol);
			FOR(j,0,val+1){
				if(j-vol>=0)chmin(dp[j],dp[j-vol]+1);
			}
		}
	};
	vector<ll> dp0(val+1,INF);
	mktbl(dp0,vols0);

	vector<ll> dp1(val+1,INF);
	mktbl(dp1,vols1);

	while(true){
		ll t; cin>>t;
		if(t==0)break;
		cout<<dp0[t]<<" "<<dp1[t]<<endl;
	}

	return 0;
}

ll solve(const ll val){
	ll limit=1;
	while(calc_vol(limit+1)<=val){
		limit++;
	}
	dump(limit,calc_vol(limit));

	vector<ll> dp(val+1,INF);
	dp[0]=0;
	FOR(i,0,limit+1){
		ll vol=calc_vol(i+1);
		FOR(j,0,val+1){
			//chmin(dp[i+1][j],dp[i][j]);
			if(j-vol>=0)chmin(dp[j],dp[j-vol]+1);
			//if(j-vol>=0)chmin(dp[j],dp[j-vol]+1);
		}
	}
	dump(dp);

	return dp[val];
}
ll solve2(const ll val){
	ll limit=1;
	vector<ll> vols(2);
	vols[0]=0;
	vols[1]=1;
	while(calc_vol(limit+1)<=val){
		auto v=calc_vol(limit+1);
		if(v%2==1)vols.push_back(v);
		limit++;
	}
	dump(limit,calc_vol(limit));

	vector<ll> dp(val+1,INF);
	dp[0]=0;
	limit = vols.size()-1;
	FOR(i,0,limit){
		//ll n2=lim2i(i);
		//ll vol=calc_vol(n2);
		ll vol=vols.at(i+1);
		dump(vol);
		FOR(j,0,val+1){
			//chmin(dp[i+1][j],dp[i][j]);
			if(j-vol>=0)chmin(dp[j],dp[j-vol]+1);
			//if(j-vol>=0)chmin(dp[j],dp[j-vol]+1);
		}
	}
	dump(dp);

	return dp[val];
}
int main_() {
#if LOCAL&01
	std::ifstream in("./test/sample-1.in");
	//std::ifstream in("./input.txt");
	std::cin.rdbuf(in.rdbuf());
#else
	cin.tie(0);
	ios::sync_with_stdio(false);
#endif
	//solve2(40); return 0;
	while(true){
		ll t; cin>>t;
		if(t==0)break;
		cout<<solve(t)<<" "<<solve2(t)<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

const int MAX = 100010;

vector<int> tetras;
vector<int> oddTetras;

int dp[MAX];
int oddDp[MAX];

int main() {
	for (int i = 1; i < 100; i++) {
		int n = i * (i + 1) * (i + 2) / 6;
		tetras.push_back(n);
		if (n % 2 == 1)
			oddTetras.push_back(n);
	}

	for (int i = 0; i < MAX; i++) {
		dp[i] = oddDp[i] = i;
	}
	for (int i = 1; i < MAX; i++) {
		for (int j = 0; tetras[j] <= i; j++) {
			dp[i] = min(dp[i], dp[i - tetras[j]] + 1);
		}
		for (int j = 0; oddTetras[j] <= i; j++) {
			oddDp[i] = min(oddDp[i], oddDp[i - oddTetras[j]] + 1);
		}
	}

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

C++: #include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 1145141919
#define MOD 1000000007
#define ALL(a) begin((a)),end((a))
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
typedef vector<edge> edges;
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///
vi all, odd, v;
int allt[1000005], oddt[1000005];

int main()
{
	v.push_back(0);
	FOR(i, 1, 1000) v.push_back(v[i - 1] + i);
	all.push_back(0);
	FOR(i,1, v.size())
	{
		all.push_back(all[i - 1] + v[i]);
		if (i & 1) odd.push_back(all[i - 1] + v[i]);
		if (all[i] > 1000000) break;
	}
	int n;
	fill(ALL(allt), INF); fill(ALL(oddt), INF);
	allt[0] = oddt[0] = 0;
	REP(i, 1000001)REP(j, all.size())
	{
		int t = i + all[j];
		if (t >= 1000001) break;
		allt[t] = min(allt[i] + 1, allt[t]);
	}

	REP(i, 1000001)REP(j, odd.size())
	{
		int t = i + odd[j];
		if (t >= 1000001) break;
		oddt[t] = min(oddt[i] + 1, oddt[t]);
	}
	while (cin >> n, n) cout << allt[n] << " " << oddt[n] << endl;
	return 0;
}