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;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n;
string s;

int main() {
    Vi v, vodd;
    int i = 1, val = i*(i+1)*(i+2)/6;
    while (val < 1e6) {
        v.push_back(val);
        if (val%2 == 1) vodd.push_back(val);
        i++; val = i*(i+1)*(i+2)/6;
    }
    Vl dp(1e6, 1e18), dpodd(1e6, 1e18);
    dp[0] = 0; dpodd[0] = 0;
    REP(i, 1e6) REP(j, v.size()) {
        if (i >= v[j]) dp[i] = min(dp[i-v[j]]+1, dp[i]);
    }
    REP(i, 1e6) REP(j, vodd.size()) {
        if (i >= vodd[j]) dpodd[i] = min(dpodd[i-vodd[j]]+1, dpodd[i]);
    }

    while (true) {
        cin >> n;
        if (n == 0) break;
        printf("%lld %lld\n", dp[n], dpodd[n]);
    }

    return 0;
}

C++: #include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<string>
#include<vector>
#include<climits>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define	mp	make_pair
#define	pb	push_back
#define	pf	push_front

using namespace std;

typedef	vector<int>		vi;
typedef	pair<int,int>	pii;

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

int main()
{
	int t[181];
	for(int i=1;i<=180;i++)	t[i]=i*(i+1)*(i+2)/6;	// T_181==1004731

	static int memo[1000000],memo_odd[1000000];
	memo[0]=memo_odd[0]=0;
	for(int i=1;i<1000000;i++)	memo[i]=memo_odd[i]=200;
	for(int i=1;i<1000000;i++){
		for(int j=1;j<=180;j++){
			if(t[j]>i)	break;
			memo[i]=min(memo[i],memo[i-t[j]]+1);

			if((j-1)%4==0)
				memo_odd[i]=min(memo_odd[i],memo_odd[i-t[j]]+1);
		}
	}

	for(int n;cin>>n,n;)	cout<<memo[n]<<' '<<memo_odd[n]<<endl;

	return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); i++)
#define ll long long
using namespace std;

int main() {
  int n;
  vector<int> X(200, 0);
  rep(i, 200) X[i]=i*(i+1)*(i+2)/6;
  int INF=1e9;
  int MAX_N=1000001;
  vector<int> dp(MAX_N, INF);
  vector<int> dp2(MAX_N, INF);
  dp[0]=0;
  rep(i, 200) {
    for (int j=X[i]; j<MAX_N; j++) {
      dp[j]=min(dp[j], dp[j-X[i]]+1);
    }
  }
  dp2[0]=0;
  rep(i, 200) {
    for (int j=X[i]; j<MAX_N; j++) {
      if (X[i]%2==0) continue;
      dp2[j]=min(dp2[j], dp2[j-X[i]]+1);
    }
  }

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

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
  int i,j,k,b[1000001],c[1000001],a[200],n;
  for(i=0;a[i-1]<1000000;i++)a[i]=i*(i+1)*(i+2)/6;
  for(j=0;j<=1000000;j++)b[j]=c[j]=j;
  for(j=2;j<i;j++){
    for(k=a[j];k<=1000000;k++){
      b[k]=min(b[k],b[k-a[j]]+1);
      if(a[j]%2){
        c[k]=min(c[k],c[k-a[j]]+1);
      }
    }
  }
while(cin>>n,n){
cout<<b[n]<<' '<<c[n]<<endl;
}
return 0;
}