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>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)	
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<string> vs;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
Def inf = sizeof(Def) == sizeof(ll) ? 2e18 : 1e9+10;
int main(){
	vi w;
	loop(i,1,200)if(i*(i+1)*(i+2)/6<1000100)w.pb(i*(i+1)*(i+2)/6);
	const int n=1000100;
	vi dp(n+1,inf),dp2(n+1,inf);
	dp[0]=dp2[0]=0;
	rep(i,w.size())rep(j,n){
		int t=j+w[i];
		if(t<n+1)dp[t]=min(dp[t],dp[j]+1);
		if(t<n+1&&w[i]%2)dp2[t]=min(dp2[t],dp2[j]+1);
	}
	int m;
	while(cin>>m,m){
		cout<<dp[m]<<" "<<dp2[m]<<endl;
	}
}

C++: #include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;
typedef vector<vector<int> > VVI;
const int INF = 1e9;
const double EPS = 1e-6;

const int MAX = 1e6;
vector<int> num;

int main()
{
	int dp[MAX+1], dp2[MAX+1];
	fill(dp, dp+MAX+1, INF);
	fill(dp2, dp2+MAX+1, INF);
	
	dp[0] = dp2[0] = 0;
	dp[1] = dp2[1] = 1;
	
	for (int i=1; ; i++) {
		int n = i*(i+1)*(i+2)/6;
		if (n > MAX) break;
		num.push_back(n);
	}
	
	for (int i=0; i<=MAX; i++) {
		for (int j=0; j<num.size(); j++) {
			int n = i + num[j];
			if (n <= MAX) {
				dp[n] = min(dp[n], dp[i]+1);
				if (num[j]%2==1)
					dp2[n] = min(dp2[n], dp2[i]+1);
			}
		}
	}
	
	int N;
	while (cin>>N, N) {
		cout << dp[N] << " " << dp2[N] << endl;
	}
}

C++: #include <algorithm>
#include <iostream>

using namespace std;

int dp1[100010]={0};
int dp2[100010]={0};
int List[100];

void setpolloc(){
	int i,j,li;
	for(i=1;i*(i+1)*(i+2)/6<=100000;i++){
		List[i]=i*(i+1)*(i+2)/6;
		dp1[i*(i+1)*(i+2)/6]=1;
		if((i*(i+1)*(i+2)/6)%2) dp2[i*(i+1)*(i+2)/6]=1;
	}
	List[i]=i*(i+1)*(i+2)/6;
	for(i=1;i<=100000;i++){
		if(dp2[i]) continue;
		for(j=1;List[j]<=i-1;j+=2)if(!dp2[i] || dp2[List[j]]+dp2[i-List[j]] < dp2[i]) dp2[i]=dp2[List[j]]+dp2[i-List[j]];
		if(dp1[i]) continue;
		for(j=1;List[j]<=i-1;j++) if(!dp1[i] || dp1[List[j]]+dp1[i-List[j]] < dp1[i]) dp1[i]=dp1[List[j]]+dp1[i-List[j]];
	}
}


int main(){
	int n;
	setpolloc();
	while(cin>>n,n){
//		cout << dp1[n] << ' ' << dp2[n] << endl;
	}
	return 0;
}

C++: #include "iostream"

using  namespace std;

#define N 1000000
#define M 300

int tet_num[M];
int tet_num_odd[M];
int ans_integer[N];
int ans_odd[N];

int main(){

	int n;
	int j = 1;

	for (int i = 0; i < M; i++){
		tet_num[i] = i*(i + 1)*(i + 2) / 6;
		if (tet_num[i] % 2 == 1){
			tet_num_odd[j] = tet_num[i];
			j++;
		}
	}

	for (int i = 0; i < N; i++){
		ans_integer[i] = N;
		ans_odd[i] = N;
	}

	while (1){

		cin >> n;

		if (n == 0)break;

		for (int m = 1; m <= n; m++){
			if (ans_integer[m] == N){
				for (int i = 1; i <= N; i++){
					if (m == tet_num[i]){
						ans_integer[m] = 1;
						break;
					}
					if (m - tet_num[i] > 0){
						if (ans_integer[m] > ans_integer[m - tet_num[i]] + 1)
							ans_integer[m] = ans_integer[m - tet_num[i]] + 1;
					}
					else break;
				}
				for (int i = 1; i <= N; i++){
					if (m == tet_num_odd[i]){
						ans_odd[m] = 1;
						break;
					}
					if (m - tet_num_odd[i] > 0){
						if (ans_odd[m] > ans_odd[m - tet_num_odd[i]] + 1)
							ans_odd[m] = ans_odd[m - tet_num_odd[i]] + 1;
					}
					else break;
				}
			}
		}

		cout << ans_integer[n] << " " << ans_odd[n] << endl;

	}


	return 0;

}