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;

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;

vi tetra;
vi tetra_odd;
/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
//    cout << fixed << setprecision(15);

//    construct
    int p;
    for(int i = 1; ; ++i) {
        p = i*(i+1)*(i+2)/6;
        if(p > 1e6) break;
        tetra.push_back(p);
        if(p%2==1) tetra_odd.push_back(p);
    }
//    cout << tetra.size() << '\n';

    vi dp(1e6 + 1, inf);  // dp[i] : iを表現するために必要な正四面体数の最小個数
    vi dp_odd(1e6 + 1, inf);
    dp[0] = 0;
    dp_odd[0] = 0;

    for(int i = 0; i <= 1e6; ++i) {
        for(int j = 0; j < tetra.size(); ++j) {
            if(i+tetra[j]<=1e6) chmin(dp[i+tetra[j]], dp[i] + 1);
        }
    }
    for(int i = 0; i <= 1e6; ++i) {
        for(int j = 0; j < tetra_odd.size(); ++j) {
            if(i+tetra_odd[j]<=1e6) chmin(dp_odd[i+tetra_odd[j]], dp_odd[i] + 1);
        }
    }

//    solve
    int n;
    while(cin >> n) {
        if(n==0) break;
        cout << dp[n] << ' ' << dp_odd[n] << '\n';
    }
//    printf("ExcutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}

C++: #include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int normal[100100];
int odd[100100];

int main() {
  MEMSET(normal, 0x0f);
  MEMSET(odd, 0x0f);
  normal[0] = odd[0] = 0;
  REP(i, 100001) {
    REP(j, 1000) {
      int plus = j * (j + 1) * (j + 2) / 6;
      if (i + plus > 100000) { break; }
      normal[i + plus] = min(normal[i + plus], normal[i] + 1);
      if (plus & 1) {
        odd[i + plus] = min(odd[i + plus], odd[i] + 1);
      }
    }
  }
  int n;
  while (scanf("%d", &n), n) {
    printf("%d %d\n", normal[n], odd[n]);
  }
}

C++: #include <iostream>
#include <vector>
#include <utility>
#define N 1000000

using namespace std;

int main(){
	vector<int> sq;
	vector<int> sqodd;
	int a[N];
	int aodd[N];
	for(int i = 1; i * (i + 1) * (i + 2) <= N; i++)  sq.push_back((i * (i + 1) * (i + 2)) / 6);
	for(int i = 1; i * (i + 1) * (i + 2) <= N; i++){
		if(((i * (i + 1) * (i + 2)) / 6) % 2)
		 	sqodd.push_back((i * (i + 1) * (i + 2)) / 6);
	}
	for(int i = 0; i < N; i++) a[i] = N;
	for(int i = 0; i < N; i++) aodd[i] = N;
	for(int i = 0; i < sq.size(); i++) a[sq[i]] = 1;
	for(int i = 0; i < sqodd.size(); i++) aodd[sqodd[i]] = 1;
	for(int i = 1; i < N; i++){
		if(a[i] == N) continue;
		for(int j = 0; j < sq.size(); j++){
			if(sq[j] + i < N && a[sq[j] + i] > a[i] + 1) a[sq[j] + i] = a[i] + 1;
		}
	}
	for(int i = 1; i < N; i++){
		if(aodd[i] == N) continue;
		for(int j = 0; j < sqodd.size(); j++){
			if(sqodd[j] + i < N && aodd[sqodd[j] + i] > aodd[i] + 1) aodd[sqodd[j] + i] = aodd[i] + 1;
		}
	}	
	int n;
	while(cin >> n, n){
		cout << a[n] << " " << aodd[n] << endl;
	}
	return 0;
}