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 sum[200] = {0};
int memo[200][2] = {0};
int ans[1000005][2] = {0};
int n, size[2];

void setans();

int main() {
  setans();
  while(1) {
    cin >> n;
    if(n == 0) break;
    cout << ans[n][0] << " " << ans[n][1] << endl;
  }
  return 0;
}

void setans() {
  size[0] = size[1] = 1;
  sum[0] = memo[0][0] = memo[0][1] = 1;
  while(memo[size[0] - 1][0] < 1000000) {
    sum[size[0]] = sum[size[0] - 1] + size[0] + 1;
    memo[size[0]][0] = memo[size[0] - 1][0] + sum[size[0]];
    if(memo[size[0]][0] % 2 == 1)
      memo[size[1]++][1] = memo[size[0]][0];
    ++size[0];
  }
  --size[1];
  --size[0];
  for(int t = 0; t < 2; ++t)
    for(int i = 1; i < 1000001; ++i) ans[i][t] = 100000000;
  for(int t = 0; t < 2; ++t)
    for(int i = 0; i < size[t]; ++i)
      for(int j = 1; j < 1000001; ++j) {
        int now = memo[i][t];
        if(j >= now)
          ans[j][t] = min(ans[j][t], ans[j - now][t] + 1);
      }
}

C++: #include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define MOD 1000000007
#define ALL(a) begin((a)),end((a))
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

vector<int> tri;
vector<int> b;
vector<int> a;
int ansa[1000005];
int ansb[1000005];

int main()
{
	tri.push_back(0);
	a.push_back(0);
	FOR(i, 1, 10000) tri.push_back(tri[i - 1] + i);
	FOR(i, 1, 10000)
	{
		a.push_back(a[i - 1] + tri[i]);
		if (a.back() & 1) b.push_back(a.back());
		if (a.back() > 1000001) break;
	}
	fill(ALL(ansa), INF);
	fill(ALL(ansb), INF);

	REP(i, a.size())
	{
		ansa[a[i]] = 1;
		REP(j, 1000001)
		{
			int t = j + a[i];
			if (t > 1000001) break;
			ansa[t] = min(ansa[t],ansa[j] + 1);
		}
	}
	REP(i, b.size())
	{
		ansb[b[i]] = 1;
		REP(j, 1000001)
		{
			int t = j + b[i];
			if (t > 1000001) break;
			ansb[t] = min(ansb[t],ansb[j] + 1);
		}
	}


	int n;
	while (cin >> n, n)
	{
		cout << ansa[n] << " " << ansb[n] << endl;
	}
	return 0;
}

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

int dp1[1000001], dp2[1000001];
int solve(vector<int> const& v, int n, int dp[]) {
  for (int i = 0; i <= n; i++)
    dp[i] = i;
  for (int i = 0; i < v.size(); i++) {
    for (int j = v[i]; j <= n; j++) {
      dp[j] = min(dp[j], dp[j-v[i]] + 1);
    }
  }
  return dp[n];
}

int main(void) {
  vector<int> tetra, tetra_odd;

  for (int i = 1; ; i++) {
    int t = (i*(i+1)*(i+2) / 6);
    if (t > 1000000)
      break;
    tetra.push_back(t);
    if (t % 2 == 1)
      tetra_odd.push_back(t);
  }

  solve(tetra, 1000000, dp1);
  solve(tetra_odd, 1000000, dp2);

  int n;
  while (cin >> n, n) {
    cout << dp1[n] << ' ' << dp2[n] << endl;
  }

  return 0;
}

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

#define MAX 1000000
#define INF (1<<24)
int n[100000],M;

int dp[1000005];
int od[1000005];

int main()
{
	for(M=1; ; M++)
	{
		int v=M*(M+1)*(M+2)/6;
		if(v>MAX) break;
		n[M]=v;
	}



	for(int i=0; i<=MAX; i++)
	{
		dp[i]=INF;
		od[i]=INF;
	}

	dp[0]=od[0]=0;

	for(int i=1; i<M; i++)
	for(int j=0; j<=MAX; j++) 
	{
		if(j+n[i] > MAX) break;
		if(dp[j]!=INF)
		{
			dp[j+n[i]]=min(dp[j+n[i]], dp[j]+1);
		}
		if(od[j]!=INF&&n[i]%2==1)
		{
			od[j+n[i]]=min(od[j+n[i]], od[j]+1);
		}
	}
	int N;
	while(cin >> N, N)
	{

		cout << dp[N] << " " << od[N] << endl;
	}


}

C++: #include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    vector<int> v(201);
    for(int i=1; i<=200; i++){
        v[i] = i * (i + 1) * (i + 2) / 6;
    }

    while(1){
        int n; cin>>n;
        if(n == 0) return 0;

        vector<int> dp1(n+10, 1e9);
        dp1[0] = 0;
        auto dp2 = dp1;

        for(int i=1; i<=200; i++){
            for(int j=0; j<=n; j++){
                if(j - v[i] >= 0) dp1[j] = min(dp1[j], dp1[j-v[i]] + 1);

                if(v[i] % 2){
                    if(j - v[i] >= 0) dp2[j] = min(dp2[j], dp2[j-v[i]] + 1);
                }
            }
        }

        cout << dp1[n] << " " << dp2[n] << endl;
    }
}