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;
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(j, b[i], 1000001) {
      dp2[j] = min(dp2[j], dp2[j-b[i]] + 1);
    }
  }
  //cout << "a" << endl;
/*  FOR(i, 1, 100) {
    FOR(j, b[i], 1000001) {
      dp2[j] = min(dp2[j], dp2[j-b[i]] + 1);
    }
  }
  *///cout << "b" << endl;

  //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;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int d1[1000001]={},d2[1000001]={};
int main(){
	int n,i=0,j=0;
	int pollock1[181]={},pollock2[46]={};
	for(i=1;i*(i+1)*(i+2)/6<1000000;i++){
		pollock1[i-1]=i*(i+1)*(i+2)/6;
		if(pollock1[i-1]%2)
		pollock2[j++]=pollock1[i-1];
	}
	for(i=0;i<1000001;i++){
		d1[i]=9999999;
		d2[i]=9999999;
	}
	for(i=0;i<180;i++)
		d1[pollock1[i]]=1;
	for(i=0;i<45;i++)
		d2[pollock2[i]]=1;
	
	for(i=1;i<1000001;i++){
		for(j=0;j<180;j++){
			if(d1[i] && i+pollock1[j]<1000001){
				d1[i+pollock1[j]]=min(d1[i+pollock1[j]],d1[i]+1);
			}
		}
	}
	for(i=1;i<1000001;i++){
		for(j=0;j<45;j++){
			if(d2[i] && i+pollock2[j]<1000001){
				d2[i+pollock2[j]]=min(d2[i+pollock2[j]],d2[i]+1);
			}
		}
	}
	for(i=0;i<40;i++){
		cout<<d1[i]<<' '<<d2[i]<<endl;
	}
	while(cin>>n,n){
		cout<<d1[n]<<' '<<d2[n]<<endl;
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7+1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/


ll dp[1000001];
ll dpOdd[1000001];

int main()
{
	REP(i, 100001)
	{
		dp[i] = dpOdd[i] = i;
	}

	for (int n = 2; ; n++) {
		ll bNumber = n * (n + 1) * (n + 2) / 6;
		if (bNumber > 1000001) break;

		for (int i = 0; i <= 1000001; i++) {
			if (i - bNumber < 0) continue;
			dp[i] = min(dp[i], dp[i - bNumber] + 1);
			if (bNumber % 2 == 1) dpOdd[i] = min(dpOdd[i], dpOdd[i - bNumber] + 1);
		}
	}

	for (;;) {
		ll Value;
		cin >> Value;
		if (!Value) break;
		cout << dp[Value] << " " << dpOdd[Value] << endl;
	}

	return 0;
}

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

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;

vvi tetra(2);
vvi dp(2, vi(1e6, 1e6));

void preset() {
    int n;
    for (int i=0; (n = i*(i+1)*(i+2)/6) < 1e6; i++) {
        tetra[0].push_back(n);
        if (n % 2 == 1) tetra[1].push_back(n);
    }

    for (int i=0; i<2; i++) {
        dp[i][0] = 0;
        for (int k : tetra[i]) {
            for (int j=k; j<1e6; j++) {
                dp[i][j] = min(dp[i][j], dp[i][j-k]+1);
            }
        }
    }
}

int main() {
    preset();

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

    return 0;
}