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 lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int k = 180;
    vector<int> a(k);
    iota(a.begin(), a.end(), 1);
    for (int i = 1; i < k; ++i) {
        a[i] += a[i - 1];
    }
    for (int i = 1; i < k; ++i) {
        a[i] += a[i - 1];
    }
    vector<int> o;
    for (int i = 0; i < k; ++i) {
        if (a[i] % 2 == 1)
            o.push_back(a[i]);
    }
    int l = o.size();
    vector<int> dp(1000001, 1000000);
    dp[0] = 0;
    for (int i = 0; i < k; ++i) {
        for (int j = 0; j < 1000000; ++j) {
            if (j + a[i] <= 1000000)
                chmin(dp[j + a[i]], dp[j] + 1);
            else
                break;
        }
    }
    vector<int> dpo(1000001, 1000000);
    dpo[0] = 0;
    for (int i = 0; i < l; ++i) {
        for (int j = 0; j < 1000000; ++j) {
            if (j + o[i] <= 1000000)
                chmin(dpo[j + o[i]], dpo[j] + 1);
            else
                break;
        }
    }
    while (true) {
        int n;
        cin >> n;
        if (n == 0)
            return 0;
        cout << dp[n] << " " << dpo[n] << "\n";
    }
    return 0;
}

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

const int INF = 1e9;

int main(){
  int lim = 1e6;
  vector<int> cube;
  for(int i=1;;i++){
    int c = i*(i+1)*(i+2)/6;
    if(c>lim)break;
    cube.push_back(c);
  }

  vector<int> dp1(lim+1,INF), dp2(lim+1,INF);
  dp1[0] = dp2[0] = 0;

  for(int i=0;i<=lim;i++){
    for(int c : cube){
      if(i+c<=lim){
	dp1[i+c] = min(dp1[i+c], dp1[i]+1);
	if(c%2==1){
	  dp2[i+c] = min(dp2[i+c], dp2[i]+1);
	}
      }
    }
  }

  int n;
  while(cin >> n){
    if(n==0)break;
    cout << dp1[n] << " " << dp2[n] << endl;
  }
}

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

int a[180];
int ans[1000001];
int ansb[1000001];
const int INF=1<<28;

int main()
{
	for(int i=1;i<=180;i++)
	{
		a[i-1]=i*(i+1)*(i+2);
		a[i-1]/=6;
	}
	ans[0]=0;
	ansb[0]=0;
	for(int i=1;i<=1000000;i++)
	{
		ans[i]=10;
		ansb[i]=INF;
		for(int j=0;j<180&&i-a[j]>=0;j++)
		{
			ans[i]=min(ans[i],ans[i-a[j]]+1);
			if(j%4==0)ansb[i]=min(ansb[i],ansb[i-a[j]]+1);
		}
	}
	int n;
	while(cin>>n,n)
	{
		cout<<ans[n]<<" "<<ansb[n]<<endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(const T a, const T b){return a>=0 ? a/b : (a+1)/b-1;}
template<class T> T div_ceil(const T a, const T b){return a>=0 ? (a-1)/b+1 : a/b;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 1000010;

int dp[2][MAX];
vector<int> x[2];

void solve(int c){
    rep(i, MAX) dp[c][i] = MAX;
    dp[c][0] = 0;
    rep(i, MAX)if(dp[c][i] < MAX){
        for(int j: x[c]){
            if(i+j >= MAX) break;
            chmin(dp[c][i+j], dp[c][i] + 1);
        }
    }
}

int f(int i){
    return i*(i+1)*(i+2) / 6;
}

int main(){
    for(int i=1; f(i)<=MAX; ++i){
        x[0].push_back(f(i));
        if(f(i) % 2 == 1) x[1].push_back(f(i));
    }
    rep(i, 2) solve(i);
    int n;
    while(scanf("%d", &n) && n){
        printf("%d %d\n", dp[0][n], dp[1][n]);
    }
}

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

#define MAX 1000000

int main()
{
  int triangle,tetra[MAX];
  int i,j,T;
  int dp[MAX],dpOdd[MAX];
  int n;
  T=0;
  tetra[0]=1;
  tetra[1]=4;
  triangle=1;
  for(i=2;triangle<MAX;i++){
    triangle+=i;
    tetra[i-1]=tetra[i-2]+triangle;
    T++;
  }

  for(i=0;i<MAX;i++)dp[i]=dpOdd[i]=INT_MAX;
  dp[0]=dpOdd[0]=0;
  for(i=0;i<T;i++){
    for(j=tetra[i]; j<MAX; j++){
      if(dp[j-tetra[i]]+1 < dp[j])
	dp[j]=dp[j-tetra[i]]+1;
      if(tetra[i]&1 && dpOdd[j-tetra[i]]+1 < dpOdd[j])
	dpOdd[j]=dpOdd[j-tetra[i]]+1;
    }
  }

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