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;
using LL = long long;
using P = pair<int, int>;
using Tapris = tuple<int, int, int>;

#define REP(i, n) for(LL i = 0; i < n; ++i)
#define FOR(i, a, n) for(LL i = a; i < n; ++i)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

//#define int long long

/*************** using variables ***************/
int n;
int dp1[1000005], dp2[1000005];
vector<int> sei5, sei5_odd;
/**********************************************/

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    for(int i = 1; ; i++){
        int x = i * (i+1) * (i+2) / 6;
        if(x > 1000000) break;
        sei5.pb(x);
        if(x % 2 == 1) sei5_odd.pb(x);
    }

    REP(i, 1000001){
        dp1[i] = INF;
        dp2[i] = INF;
    }
    dp1[0] = 0;
    dp2[0] = 0;
    FOR(i, 1, 1000001){
        REP(j, sei5.size()){
            if(i-sei5[j] < 0) break;
            dp1[i] = min(dp1[i], dp1[i-sei5[j]] + 1);
        }
    }
    FOR(i, 1, 1000001){
        REP(j, sei5_odd.size()){
            if(i-sei5_odd[j] < 0) break;
            dp2[i] = min(dp2[i], dp2[i-sei5_odd[j]] + 1);
        }
    }
    while(cin >> n, n){
        cout << dp1[n] << " " << dp2[n] << endl;
    }
}

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

const int MAX = 1000005;
const int INF = 1 << 29;

int main(){
    vector<int> dp(MAX, INF), dp_odd(MAX, INF);
    // j を作るための最小数
    dp[0] = dp_odd[0] = 0;
    for(int i = 1; ; i++){
        int t = i * (i + 1) * (i + 2) / 6;
        if(t >= MAX) break;
        for(int j = t; j < MAX; j++){
            dp[j] = min(dp[j], dp[j - t] + 1);
            if(t & 1){
                dp_odd[j] = min(dp_odd[j], dp_odd[j - t] + 1);
            }
        }
    }
    int n;
    while(cin >> n, n){
        cout << dp[n] << " " << dp_odd[n] << endl;
    }
}

C++: #define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	vector<int> dp(1000000, INT_MAX / 2);
	dp[0] = 0;
	vector<int> _dp = dp;
	for (int i = 1; i <= 200; i++) {
		int x = i * (i + 1) * (i + 2) / 6;
		for (int j = x; j < 1000000; j++)
			dp[j] = min(dp[j], dp[j - x] + 1);
		if (x % 2 == 1)
			for (int j = x; j < 1000000; j++)
				_dp[j] = min(_dp[j], _dp[j - x] + 1);
	}
	for (;;) {
		int n; cin >> n;
		if (n == 0) break;
		cout << dp[n] << ' ' << _dp[n] << endl;
	}
}

C++: #include <iostream>
#include <set>
#define MAXNUM 100
using namespace std;

int all[MAXNUM], odd[MAXNUM];
set<int> allfour, oddfour;
int max(int a, int b);
int min(int a, int b);
int getall(int n);
int getodd(int n);

int main()
{
	int n;
	int counter = 0;

	//1からMAXまでの中に存在する正四面体数をsetに入れる．
	int now = 0, four;
	while (1){
		now++;
		four = now  *(now + 1)*(now + 2) / 6;
		if (four > MAXNUM)
			break;
		allfour.insert(four);
		if (four % 2 == 1)
			oddfour.insert(four);
	}

	//1からMAXNUMまで，配列を埋める.
	for (int i = 1; i <= MAXNUM; i++){
		all[i] = getall(i);
		odd[i] = getodd(i);
	}

	//入力
	while (cin >> n, n)
		cout << all[n] << " " << odd[n] << endl;

	return 0;

}




int max(int a, int b){
	if (a > b)
		return a;
	else
		return b;
}

int min(int a, int b){
	if (a > b)
		return b;
	else
		return a;
}

int getall(int n){
	set<int>::iterator it = allfour.find(n);
	if (it != allfour.end())
		return 1;
	else{
		int minnum = 1000;
		for (int i = 1; i < n / 2 + 1; i++){
			minnum = min(minnum, all[i] + all[n - i]);
			if (minnum == 2)
				break;
		}
		return minnum;
	}
}

int getodd(int n){
	set<int>::iterator it = oddfour.find(n);
	if (it != oddfour.end())
		return 1;
	else{
		int minnum = 1000;
		for (int i = 1; i < n / 2 + 1; i++){
			minnum = min(minnum, odd[i] + odd[n - i]);
			if (minnum == 2)
				break;
		}
		return minnum;
	}
}

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

using namespace std;
vector<int> P;
vector<int> oddP;
int memo[1001001];
int mome[1001001];

void hoge(){

    for(int i=1; ; i++){
        int p=i*(i+1)*(i+2)/6;
        if(p>=1001001) break;
        P.push_back(p);
    }
    for(int i=0; i<P.size(); i++){
        memo[P[i]]=1;
        if(P[i]%2) mome[P[i]]=1;
    }
}

int rec(int n, bool odd){

    if(odd){
        if(mome[n]!=0) return mome[n];
    }else{
        if(memo[n]!=0) return memo[n];
    }
    int ret=1001001;
    for(int i=0; n-P[i]>0; i++){
        if(odd&&(P[i]%2==0)) continue;
        ret=min(ret, rec(n-P[i], odd)+1);
    }
    if(odd){
        return mome[n]=ret;
    }else{
        return memo[n]=ret;
    }

}

int main(){

    hoge();
    bool odd=true;
    while(1){
        int N;
        cin>> N;
        if(!N) break;

        cout<< rec(N, !odd)<<" ";
        cout<< rec(N, odd)<< endl;
    }

    return 0;
}