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;

int main(){
	vector<int> dp1(1000000,1000000);
	dp1[0] = 0;
	vector<int> dp2(1000000,1000000);
	dp2[0] = 0;
	for(int i=1;i*(i+1)*(i+2)<1000000;i++){
		int x = i*(i+1)*(i+2)/6;
		for(int j=0;j<1000000-x;j++){
			dp1[j+x] = min(dp1[j+x],dp1[j] + 1);
			if(x%2 == 1) dp2[j+x] = min(dp2[j+x],dp2[j] + 1);
		}
	}
	
	int a;
	while(cin >> a,a > 0){
		cout << dp1[a] << " " << dp2[a] << endl;
	}
	
	return 0;
}

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

const int MAX_N = 1000000;
const int INF = 1000000000;

int dp_nat[MAX_N]; // dp_nat[i]: 数字iを作るための最小の正四面体の個数
int dp_odd[MAX_N]; // dp_odd[i]: 数字iを作るための最小の奇数の正四面体の個数

int tetras[10000]; // tetras[i]: i番目の正四面体数(添え字は1から始まる)
int num_tetras = 0;

int main() {
  // 正四面体数を事前に計算しておく
  for(int i = 1; 1; i++) {
    int m = i*(i+1)*(i+2)/6;
    if (m > MAX_N) break;
    num_tetras++; // 配列は1始まりなので先にインクリメント
    tetras[num_tetras] = m;
  }

  // 入力のnによらずdp_natとdp_oddの中身は同じになるので、入力を読む前に計算しておく

  // 全ての正四面体数を使ったパターン
  dp_nat[0] = 0;
  for (int i = 1; i < MAX_N; i++) {
    dp_nat[i] = INF;
    for (int j = 1; j <= num_tetras; j++) {
//    cout << "dbg" << i << "," << dp_nat[i] << endl;
      if (i - tetras[j] < 0) break;
      dp_nat[i] = min(dp_nat[i], dp_nat[i - tetras[j]] + 1);
    }
  }

  // 奇数のみのパターン
  dp_odd[0] = 0;
  for (int i = 1; i < MAX_N; i++) {
    dp_odd[i] = INF;
    for (int j = 1; j <= num_tetras; j++) {
      if (i - tetras[j] < 0) break;
      if (tetras[j] % 2 != 0)
        dp_odd[i] = min(dp_odd[i], dp_odd[i - tetras[j]] + 1);
    }
  }

  int n;
  while(cin >> n, n != 0) {
    cout << dp_nat[n] << " " << dp_odd[n] << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
using namespace std;

#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define REPI(i, s, e) for (int i = (s); i <= (e); i++)
#define rep(i, n) REP(i, 0, n)
#define repi(i, n) REPI(i, 0, n)
#define ALL(v) (v).begin(), (v).end()

#define dump(x) (cout << #x << " = " << x << endl)
#define dump2(x, y) (cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl)
#define dump3(x, y, z) (cout << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", "<< z << ")" << endl)

typedef long long ll;
typedef pair<int, int> pii;

int n;

#define MAX 1000000
vector<int> tri;

int dp[MAX];
int odd_dp[MAX];

void gentri()
{
	for (int i = 1;; i++) {
		int t = i*(i+1)*(i+2)/6;
		if (t >= MAX) break;
		tri.push_back(t);
	}
}

int main(void)
{
	gentri();

	dp[0] = 0;
	odd_dp[0] = 0;
	for (int i = 1; i < MAX; i++) {
		dp[i] = i;
		odd_dp[i] = i;
		
		rep(j, tri.size()) {
			int t = i-tri[j];
			if (t < 0) break;
			dp[i] = min(dp[i], dp[t]+1);

			if (tri[j]%2!=0)
				odd_dp[i] = min(odd_dp[i], odd_dp[t]+1);
		}
	}
	
	while(cin >> n, n) {
		cout << dp[n] << " " << odd_dp[n] << endl;
	}
	return 0;
}

C++: // 2013/06/29 Tazoe

#include <iostream>
#include <vector>
using namespace std;

int main()
{
	vector<int> P;
	P.push_back(1);

	for(int i=0; ; i++){
		int p = P[i]*(i+4)/(i+1);

		if(p>=1000000)
			break;

		P.push_back(p);
	}
/*
	for(int i=0; i<P.size(); i++){
		cout << P[i] << endl;
	}
*/
	int DP[1000000];
	int DP2[1000000];
	DP[0] = 0;
	DP2[0] = 0;
	for(int i=1; i<1000000; i++){
		DP[i] = 1000000;
		DP2[i] = 1000000;
	}

	for(int i=0; P[i]<1000000; i++){
		for(int j=0; j+P[i]<1000000; j++){
			if(DP[j]+1<DP[j+P[i]]){
				DP[j+P[i]] = DP[j]+1;
			}

			if(P[i]%2==1 && DP2[j]+1<DP2[j+P[i]]){
				DP2[j+P[i]] = DP2[j]+1;
			}
		}
	}

	while(true){
		int n;
		cin >> n;

		if(n==0)
			break;

		cout << DP[n] << ' ' << DP2[n] << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

void pollock(int po[], int od[]) {
	int i = 1, j = 1;
	while (po[i - 1] < 1000000) {
		po[i] = (i * (i + 1) * (i + 2)) / 6;
		if (po[i] % 2 == 1) {
			od[j] = po[i];
			j++;
		}
		i++;
	}
}

int main() {
	int po[200] = {}, od[200] = {};
	pollock(po, od);
	int n;
	while (cin >> n && n) {
		vector<int> tmp(1000000, 100);
		tmp[0] = 0;
		int t = 1;
		while (po[t] <= n) t++;
		for (int i = 1; i <= t; ++i) {
			for (int j = 0; j + po[i] <= n; ++j) {
				tmp[j + po[i]] = min(tmp[j + po[i]], tmp[j] + 1);
			}
		}
		cout << tmp[n] << " ";

		for (int i = 1; i < 1000000; ++i) tmp[i] = 1000000;
		tmp[0] = 0;
		t = 1;
		while (od[t] <= n) t++;
		for (int i = 1; i <= t; ++i) {
			for (int j = 0; j + od[i] <= n; ++j) {
				tmp[j + od[i]] = min(tmp[j + od[i]], tmp[j] + 1);
			}
		}
		cout << tmp[n] << endl;
	}

	return 0;
}