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,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
 
const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

int main(){
    vector<ll> rt, rt_odd;
    rt.push_back(1);
    rt_odd.push_back(1);

    for(int i = 4; i <= 1000; ++i){
        ll s = i * rt.back() / (i-3);
        rt.push_back(s);
    }

    ll rt_len = rt.size();

    //dp[i][0] : 正四面体数でiを作る最小値
    //dp[i][1] : 奇数の正四面体数i作る最小値
    vector<vector<ll>> dp(1000001, vector<ll>(2));
    rep(i, 1000001){
        dp[i][0] = INF;
        dp[i][1] = INF;
    }

    dp[0][0] = 0;
    dp[0][1] = 0;
    rep(i, 1000001)rep(j, rt_len){
        if(rt[j] <= i){
            dp[i][0] = min(dp[i][0], dp[i-rt[j]][0]+1);

            if(rt[j] & 1){
                dp[i][1] = min(dp[i][1], dp[i-rt[j]][1]+1);
            }
        }
    }

    ll n;
    vector<pll> ans;
    while(cin >> n, n != 0){
        cout << dp[n][0] << " " << dp[n][1] << endl;
        // ans.push_back(make_pair(dp[n][0], dp[n][1]));
    }

    // rep(i, ans.size())cout << ans[i].first << ", " << ans[i].second << endl;
}

C++: #include <iostream>
using namespace std;
int main(){
  int a[200],b[150],c[1000010],d[1000010],k=0,i,j,n;

  for(i=0;i<200;i++)a[i]=i*(i+1)*(i+2)/6;

  for(j=0;j<i;j++)if(a[j]%2)b[k++]=a[j];

  for(i=0;i<1000010;i++)c[i]=d[i]=i;

  for(i=1;i<198;i++)for(j=a[i];j<1000010;j++){
    c[j]=min(c[j],c[j-a[i]]+1);
  }
  for(i=1;i<k-1;i++)for(j=b[i];j<10000010;j++){
    d[j]=min(d[j],d[j-b[i]]+1);
  }
 while(cin>>n,n)cout<<c[n]<<' '<<d[n]<<endl;
}

C++: #include <iostream>
using namespace std;
int main(){
  int a[190]={0},b[50]={0},c[1000001]={0,1,2,3},d[1000001],k=0,i,j,n;

  for(i=1;i<190;i++)a[k++]=i*(i+1)*(i+2)/6;

  for(j=k=0;j<i;j++)if(a[j]%2)b[k++]=a[j];

  for(i=1;i<189;i++)for(j=a[i];j<a[i+1];j++)c[j]=c[j-a[i]]+1;

  for(i=0;i<36;i++)d[i]=i;
  for(i=1;i<k-1;i++)for(j=b[i];j<b[i+1];j++)d[j]=d[j-b[i]]+1;

  while(cin>>n,n){
    cout<<c[n]<<' ';
    for(i=0;i<36;i++)d[i]=i;
  for(i=1;i<k-1;i++)for(j=b[i];j<b[i+1];j++)d[j]=d[j-b[i]]+1;
cout<<d[n]<<endl;
}

C++: #include <cstdio>
#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<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    vector<int> a, b;
    int x = 1;
    while(1){
        ll y = (x * (x + 1) * (x + 2)) / 6;
        if(y > 1000000){
            break;
        }
        a.push_back(y);
        if(y % 2 == 1) b.push_back(y);
        x++;
    }
    vector<int> dp1(1000001, INF), dp2(1000001, INF);
    dp1[0] = 0;
    dp2[0] = 0;
    for(auto&& i : a){
        for(int j = 0; j <= 1000000 - i; j++){
            dp1[j + i] = min(dp1[j + i], dp1[j] + 1); 
        }
    }
    for(auto&& i : b){
        for(int j = 0; j <= 1000000 - i; j++){
            dp2[j + i] = min(dp2[j + i], dp2[j] + 1); 
        }
    }
    while(1){
        int n;
        cin >> n;
        if(n == 0){
            break;
        }
        cout << dp1[n] << " " << dp2[n] << endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL << 30)
#define LLINF (1LL << 60)
#define PI 3.14159265359
#define EPS 1e-12
#define int ll

int dp1[1000010], dp2[1000010];
signed main(void) {
  VL a, b;
  FOR(i, 1, 500) {
    int tmp = i * (i + 1) * (i + 2) / 6;
    if (tmp % 2)
      b.PB(tmp);
    a.PB(tmp);
  }
  //cout << a[100] << a[150] << " " << a[200] << endl;
  //cout << b.size() << endl;
  //a 200?????§???b 100?????§

  REP(i, 1000001) dp1[i] = dp2[i] = i;
  FOR(i, 1, 200) {
    FOR(j, a[i], 1000001) {
      dp1[j] = min(dp1[j], dp1[j-a[i]] + 1);
    }
  }
  FOR(i, 1, 100) {
    FOR(j, b[i], 1000001) {
      dp2[j] = min(dp2[j], dp2[j-b[i]] + 1);
    }
  }

  //REP(i, 50) cout << dp1[i] << " "; cout << endl;
  //REP(i, 50) cout << dp2[i] << " "; cout << endl;

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

  return 0;
}