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++: /*
 * Problem     : AOJ1167
 * Title       : Pollock's conjecture (ポロック予想)
 * Author      : mizo0203
 * Language    : C++
 * Copyright   : Your copyright free
 * Description : 動的計画法
 */
#include <stdio.h>
#include <algorithm>

using namespace std;

int n;
int dp1[1000000];
int dp2[1000000];

void init() {
  int i, j;
  int tmp, cnt;

  tmp = 1;
  cnt = 1;
  while (tmp < 1000000) {
    //printf("%d\n", tmp);
    dp1[tmp] = 1;
    if (tmp % 2 == 1)
      dp2[tmp] = 1;
    cnt++;
    for (i = 1; i <= cnt; i++) {
      tmp += i;
    }
  }
  /*
   for (i = 500000; i > 0; i--) {
   if (!dp[i])
   continue;
   for (j = 1; i * j < 1000000; j++) {
   if (!dp[i * j] || dp[i * j] > dp[i] * j) {
   dp[i * j] = dp[i] * j;
   }
   }
   }
   */

  for (i = 1; i < 1000000; i++) {
    if (dp1[i] == 1) {
      for (j = i; i + j < 1000000; j++) {
        if (!dp1[i + j] || dp1[i + j] > dp1[i] + dp1[j])
          dp1[i + j] = dp1[i] + dp1[j];
      }
      if (dp2[i] == 1)
        for (j = i; i + j < 1000000; j++) {
          if (!dp2[i + j] || dp2[i + j] > dp2[i] + dp2[j])
            dp2[i + j] = dp2[i] + dp2[j];
        }
    }
  }
/*
  for (i = 1; i < 1000000; i++) {
    printf("%d\n", dp1[i]);
  }
  */
  //printf("%d\n", cnt);

}

bool input() {
  //int i;

  scanf("%d", &n);
  if (!n)
    return false;

  return true;
}

int main() {

  init();
  while (input()) {
    printf("%d %d\n", dp1[n], dp2[n]);
  }
  return 0;
}

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

const int N = 1e6+1;

ll dp[N], dp2[N];

int main() {

    dp[0] = dp2[0] = 0;
    for (int i=1; i<N; ++i) {
        dp[i] = dp2[i] = i;
        for (int j=1; ; ++j) {
            int p=j*(j+1)*(j+2)/6;
            if (p > i) break;
            dp[i] = min(dp[i], dp[i-p]+1);
            if (p%2) {
                dp2[i] = min(dp2[i], dp2[i-p]+1);
            }
        }
    }

    int n;
    while (cin >> n and n) {
        cout << dp[n] << " " << dp2[n] << endl;
    }

    return 0;
}

C++: 
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
using namespace std;

const int MAX_N = 1e6; 
vector<int>dp1, dp2;
vector<int>tetra;

int main(void)
{
	int n = 1;
	do
	{
		tetra.push_back(n * (n + 1) * (n + 2) / 6);
		++n;
	} while (tetra.back() <= MAX_N);
	dp1.push_back(0);
	dp2.push_back(0);
	for (int i = 1; i <= n; ++i)
	{
		int a1 = INT_MAX, a2 = INT_MAX;
		for (int t : tetra)
		{
			if (t > i)break;
			a1 = min(a1, dp1[i - t] + 1);
			if (t % 2)
			{
				a2 = min(a2, dp2[i - t] + 1);
			}
		}
		dp1.push_back(a1);
		dp2.push_back(a2);
	}
	int x;
	while (cin >> x, x)
	{
		cout << dp1[x] << " " << dp2[x] << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

ll dp[1000010];
ll dp2[1000010];
int main(void){
    ll n,i,j,k,h;
    std::vector<ll> v(200),v2(200);
    h=0;k=0;
    for(i=1;(i*(i+1)*(i+2)/6)<=1000000;i++){
        v[k++]=(i*(i+1)*(i+2)/6);
        if((i*(i+1)*(i+2)/6)%2)v2[h++]=(i*(i+1)*(i+2)/6);
    }
    ll vs = k;

    fill(dp,dp+(1000000+1),1000000);
        //cout << dp[0][0] << endl;
    dp[0]=0;

    for(i=1;i<=vs;i++){
        for(j=v[i-1];j<=1000000;j++){
            dp[j]=min(dp[j-v[i-1]]+1,dp[j]);
        }
    }

    vs = h;
    fill(dp2,dp2+(1000000+1),1000000);
    dp2[0]=0;
    for(i=1;i<=vs;i++){
        for(j=v2[i-1];j<=1000000;j++){
            dp2[j]=min(dp2[j-v2[i-1]]+1,dp2[j]);
        }
    }
    while(cin >> n && n){
        cout << dp[n] << " " << dp2[n] << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int INF = 100000000;
int main(){
  int n, M = 1000000;
  vector<int> T, T_odd, A(M,INF), odd(M,INF);
  int t = 1, k = 3;
  A[0] = 0;
  odd[0] = 0;
  T.push_back(1);
  T_odd.push_back(1);
  while(t < 1000000){
    T.push_back(t);
    if (t%2) T_odd.push_back(t);
    ++k;
    t *= k;
    t /= (k-3);
  }
  for(int i = 0; i < T.size(); ++i){
    for(int j = 1; j <= 5; ++j){
      for(int k = 0; k < T[i] && k+T[i]*j < M; ++k){
	A[k+T[i]*j] = min(A[k+T[i]*j],A[k]+j);
      }
    }
  }
  for(int i = 0; i < T_odd.size(); ++i){
    for(int j = 1; j < 35; ++j){
      for(int k = 0; k < T_odd[i] && k+T_odd[i]*j < M; ++k){
	odd[k+T_odd[i]*j] = min(odd[k+T_odd[i]*j],odd[k]+j);
      }
    }
  }
  while(cin >> n, n){
    cout << A[n] << " " << odd[n] << endl;
  }
  return 0;
}