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>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
int MAX_NUM = 1000000;
main(){
    vector<int> V,W;
    for(int i = 1;i * (i + 1) * (i + 2) / 6 <= MAX_NUM;i++){
        int num = i * (i + 1) * (i + 2) / 6; 
        V.push_back(num);
        if(i % 4 == 1)W.push_back(num);
    }
    vector<int> t1(MAX_NUM,INF),t2(MAX_NUM,INF);
    t1[0] = t2[0] = 0;
    rep(i,0,V.size()){
        rep(j,0,MAX_NUM){
            if(j + V[i] > MAX_NUM)break;
            t1[j + V[i]] = min(t1[j + V[i]], t1[j] + 1);
        }
    }
    rep(i,0,W.size()){
        rep(j,0,MAX_NUM){
            if(j + W[i] > MAX_NUM)break;
            t2[j + W[i]] = min(t2[j + V[i]], t2[j] + 1);
        }
    }
    int N;
    cin >> N;
    while(N){
        cout << t1[N] << " " << t2[N] << endl;
        cin >> N;
    }
}

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

#define MAX 1000000
using ll = long long;

int main(){
    vector<ll> v;
    vector<ll> odd_v;

    for(ll i = 1; i <= MAX; ++i){
        ll num = i * (i + 1) * (i + 2) / 6;
        v.push_back(num);
        if(num & 1) odd_v.push_back(num);
    }

    while(true){
        int n; cin >> n;
        if(!n) break;

        vector<int> dp(n+1, INT_MAX);
        vector<int> odd_dp(n+1, INT_MAX);
        dp[0] = 0;
        odd_dp[0] = 0;

        for(int i = 0; i <= n; ++i){
            for(int j = 0; j < v.size(); ++j){
                if(n < v[j]) break;
                if(i - v[j] >= 0){
                    dp[i] = min(dp[i - v[j]] + 1, dp[i]);
                }
            }

            for(int j = 0; j < odd_v.size(); ++j){
                if(n < odd_v[j]) break;
                if(i - odd_v[j] >= 0){
                    odd_dp[i] = min(odd_dp[i - odd_v[j]] + 1, odd_dp[i]);
                }
            }
        }
        cout << dp[n] << ' ' << odd_dp[n] << endl;
    }

    return EXIT_SUCCESS;
}

C++: #include<iostream>
#include<algorithm>
#define N 1000000
#define M 200

using namespace std;

int dp[M], dp1[N], dp2[N];

void init(){
  dp[0]=0; dp1[0]=0; dp2[0]=0;
  for(int i=1; i<M; ++i) dp[i]=i*(i+1)*(i+2)/6;
  for(int i=1; i<N; ++i){
    dp1[i]=N; dp2[i]=N;
    for(int j=1; j<N; ++j){
      if(i-dp[j] < 0) break;
      dp1[i] = min(dp1[i], dp1[i-dp[j]]+1);
      if(dp[j]%2) dp2[i] = min(dp2[i], dp2[i-dp[j]]+1);
    }
  }
}

int main(){
  init();
  int n;
  while(1){
    cin >> n;
    if(!n) break;
    cout << dp1[n] << " " << dp2[n] << endl;
  }
  return 0;
}

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

#define MAX 100000
#define INF (1<<24)
int n[100000],M;

int dp[100005];
int od[100005];

int main()
{
	for(M=1; ; M++)
	{
		int v=M*(M+1)*(M+2)/6;
		if(v>MAX) break;
		n[M]=v;
	}

	int N;
	while(cin >> N, N)
	{
		for(int i=0; i<=N; i++)
		{
			dp[i]=INF;
			od[i]=INF;
		}

		dp[0]=od[0]=0;

		for(int i=1; i<M; i++)
		for(int j=0; j<=N; j++) 
		{
			if(j+n[i] > N) break;
			if(dp[j]!=INF)
			{
				dp[j+n[i]]=min(dp[j+n[i]], dp[j]+1);
			}
			if(od[j]!=INF&&n[i]%2==1)
			{
				od[j+n[i]]=min(od[j+n[i]], od[j]+1);
			}
		}

		cout << dp[N] << " " << od[N] << endl;
	}


}

C++: #include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#define REP(i,n) for(int i=0;i<(n);++i)
#define SET(a,c) memset(a,c,sizeof(a))
#define PB push_back
using namespace std;

const int MAX_N = 1e6;
const int INF = 0x3f3f3f3f;

void solve(int n)
{
	vector<int> m;
	int dp[MAX_N], dp_odd[MAX_N];
	SET(dp, INF);
	SET(dp_odd, INF);
	
	REP(i, MAX_N) {
		m.PB( (i+1)*(i+2)*(i+3)/6 );
		if (m.back() > n) break;
	}

	dp[0] = 0;
	dp_odd[0] = 0;
	REP(i, m.size()) {
		REP(j, n + 1) {
			if (j < m[i]) continue;
			dp[j] = min(dp[j], dp[j - m[i]] + 1);
			if (m[i] % 2) dp_odd[j] = min(dp_odd[j], dp_odd[j - m[i]] + 1);
		}
	}	
	printf("%d %d\n", dp[n], dp_odd[n]);
}

int main()
{
	int n;
	while (1) {
		scanf("%d", &n);
		if (!n) break;
		solve(n);
	}

	return 0;
}

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

typedef long long ll;
const int INF = 1e9;

#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define ALL( a )        (a).begin(), (a).end()             

const int L = 1000001;

// iを作るのに必要な正四面体数
int dp[L] = {};
int odp[L] = {};
// 正四面体数: 1 4 10 20 35 ...
int x[L] = {};
int ox[L] = {};

int main() {

	int xsize = 0, oxsize = 0;
	for( int i = 1; i * ( i + 1 ) * ( i + 2 ) / 6 <= L; i++ ) {
		x[i] = i * ( i + 1 ) * ( i + 2 ) / 6;
		xsize++;
		if( x[i] % 2 == 1 ) {
			ox[oxsize++] = x[i];
		}
	}

	REP( i, L ) dp[i] = odp[i] = i;

	REP( i, L ) {
		REP( j, xsize ) {
			if( i < x[j] ) break;
			dp[i] = min( dp[i - x[j]] + 1, dp[i] );
		}
		REP( j, oxsize ) {
			if( i < ox[j] ) break;
			odp[i] = min( odp[i - ox[j]] + 1, odp[i] );
		}
	}

	int n;
	while( cin >> n, n ) {
		cout << dp[n] << " " << odp[n] <<  endl;
	}
	
}