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 <iostream>
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,l,n) for(int i=l;i<n;++i)
int ans = 0;
int oddans = 0;
int pol[180];
int oddpol[50];
int oddpolcount = 0;
int memo[100000];
int oddmemo[1000000];
int memorep(int n);
int oddmemorep(int n);
using namespace std;
int main() {
  pol[0] = 1;
  oddpol[oddpolcount++] = 1;
  int def = 3;
  int defdef = 3;
  REP(i,1,180){
    pol[i] = pol[i-1] + def;
    if(pol[i]%2==1) oddpol[oddpolcount++] = pol[i];
    def += defdef++;
  }
  while(1){
    int n;
    cin >> n;
    if(n==0) return 0;
    ans = memorep(n);
    oddans = oddmemorep(n);
    cout << ans << " " << oddans << endl;
  }
  return 0;
}

int memorep(int n){
  if(memo[n]!=0) return memo[n];
  int result;
  int min = 100000;
  for(int i = 179;i>=0;i--){
    result = n-pol[i];
    if(result == 0){
      return memo[n] = 1;
    }
    if(result > 0){
      result = memorep(result) + 1;
      if(min > result) min = result;
    }
  }
  return memo[n] = min;
}

int oddmemorep(int n){
  if(oddmemo[n]!=0) return oddmemo[n];
  int result;
  int min = 1000000;
  for(int i = oddpolcount-1;i>=0;i--){
    result = n-oddpol[i];
    if(result == 0){
      return oddmemo[n] = 1;
    }
    if(result > 0){
      result = oddmemorep(result) + 1;
      if(min > result) min = result;
    }
  }
  return oddmemo[n] = min;
}

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

int f(int n)
{
  return n*(n+1)*(n+2)/6;
}

int main()
{
  static const int M = 1000000;
  static int tetra[200];
  int tetra_size = 0;
  for (int i = 1; f(i) <= M; i++) {
    tetra[tetra_size++] = f(i);
  }

  static int dp[M+1], odd_dp[M+1];
  fill_n(dp+1, M, 1000000);
  fill_n(odd_dp+1, M, 1000000);
  for (int i = 0; i < tetra_size; i++) {
    for (int j = tetra[i]; j <= M; j++) {
      dp[j] = min(dp[j], dp[j-tetra[i]] + 1);
    }
    if (tetra[i] % 2 == 1) {
      for (int j = tetra[i]; j <= M; j++) {
        odd_dp[j] = min(odd_dp[j], odd_dp[j-tetra[i]] + 1);
      }
    }
  }
  int N;
  while (cin >> N && N != 0) {
    cout << dp[N] << ' ' << odd_dp[N] << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n);++i)
using namespace std;
template <class _t> inline bool chmax (_t& a,_t b){if(a<b){a=b;return true;}return false;} template <class _t> inline bool chmin (_t& a,_t b){if(a>b){a=b;return true;}return false;}

const long long inf = 1ll << 60;
const long long mod = 1000000007;

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

int main() {
    int n=1000000;
    vector<int> dp(n),dp_odd(n);
    vector<int> table;
    rep(i,n) dp[i] = dp_odd[i] =  10010010;
    for(int i=1;i<=200;i++){
	int tmp = i*(i+1)*(i+2)/6;
	if(tmp>=n)break;
	dp[tmp] = 1;

	table.push_back(tmp);
	if(tmp%2==1) dp_odd[tmp]=1;
    }
	for(int j=0;j<n;j++){
	    for(int k=0;k<table.size();k++){
		if(j>table[k])chmin(dp[j],dp[j-table[k]]+1);
		if(j>table[k] && table[k]%2==1)chmin(dp_odd[j],dp_odd[j-table[k]]+1);
	    } 
	}
    while(1){
	int m;cin >> m;
	if(m==0) return 0;
	cout << dp[m] << " " << dp_odd[m]<< endl;;
    }
    return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<functional>
#define rep(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
using namespace std;
#define ull unsigned long long
int memo[150];
int  dp[1000002];
int  dp2[1000002];
void inset(){
	dp[0]=0;
	fill(dp,dp+1000001,10000);
	fill(dp2,dp2+1000001,10000);
	dp[0]=0;
	dp2[0]=0;
	rep(i,1,150){
		memo[i]=i*(i+1)*(i+2),memo[i]/=6;
		rep(j,1,1000001)
			if(j-memo[i]>=0){
		if(dp[j]>dp[j-memo[i]]+1)dp[j]=dp[j-memo[i]]+1;
		if(memo[i]&1)if(dp2[j]>dp2[j-memo[i]]+1)dp2[j]=dp2[j-memo[i]]+1;
		}
	}
	//rep(i,1,1000001){
	//	if(dp2[i]==0){
	//	printf("[%d]%d\n",i,dp2[i]);
	//	break;
	//	}
	//}
}


int main(void){
	inset();
	int x;
	while(true){
		cin>>x;if(x==0)return(0);
		cout<<dp[x]<<" "<<dp2[x]<<endl;
	}

}

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

vector<int> s;
vector<int> odd_s;

void make_shimentai(){
    for(int i = 1; ; ++i){
        int sum = i * (i + 1) * (i + 2) / 6;

        if(sum >= 1000000) break;

        s.emplace_back(sum);

        if(sum % 2 == 1) odd_s.emplace_back(sum);
    }
}

int solve(int v, vector<int> s){
    decltype(s)::iterator it = lower_bound(s.begin(), s.end(), v);
    if(*it != v) it--;

    int ans = INT_MAX;
    for(;it != s.begin()-1; it--){
        vector<int>::iterator it_ = it;
        int v_ = v;
        int count = 0;
        while(true){
            if(v_ == 0) break;
            if(v_ - *it_ < 0){
                it_--;
                continue;
            }

            v_ -= *it_;
            count++;
            if(ans < count) break;
        }
        ans = min(ans, count);
    }

    return ans;
}

int main(){
    make_shimentai();

    while(true){
        int v;
        cin >> v;
        if(v == 0) break;

        int ans = solve(v, s);
        cout << ans << " ";
        ans = solve(v, odd_s);
        cout << ans << "\n";
    }

    return EXIT_SUCCESS;
}