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>
#include<vector>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
int dp[2][1000001];
int v[1000];
int main()
{
	int n;
	for (int i = 0; i < 2; i++)
	{
		for (int j = 0; j <= 1000000; j++)
		{
			if (j == 0)dp[i][j] = 0;
			else dp[i][j] = 999999;
		}
	}
	for (int i = 1;;i++)
	{
		int k = i * (i + 1) * (i + 2) / 6;
		if (k > 1000000)break;
		v[i - 1] = k;
	}
	while (cin >> n && n != 0)
	{
		for (int i = 0; i <= 1000000; i++)
		{
			for (int j = 0;;j++)
			{
				if (i + v[j] > n)break;
				dp[0][i + v[j]] = min(dp[0][i + v[j]],dp[0][i] + 1);
				if (v[j] % 2 == 0)continue;
				dp[1][i + v[j]] = min(dp[1][i + v[j]], dp[1][i] + 1);
			}
		}
		cout << dp[0][n] << " " << dp[1][n] << endl;
	}
	return 0;
}

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

using namespace std;

const int MAX_N = 1000000;

vector<int> tetra;
vector<int> tetra_odd;

int dp[MAX_N+1];
int dp_odd[MAX_N+1];

void init() {
	int n = 1;
	while (true){
		int m = n * (n + 1) * (n + 2) / 6;
		if (m > MAX_N) {
			break;
		}
		tetra.push_back(m);
		if (m % 2 == 1) {
			tetra_odd.push_back(m);
		}
		n++;
	}
}

void solve() {
	dp[0] = dp_odd[0] = 0;
	for (int i = 1; i <= MAX_N; i++) {
		int ans = MAX_N;
		int ans_odd = MAX_N;
		for (int j = 0; tetra[j] <= i; j++) {
			//cout << i << " " << tetra[j] << endl;
			ans = min(ans, dp[i-tetra[j]]);
		}
		
		for (int j = 0; tetra_odd[j] <= i; j++) {
			ans_odd = min(ans_odd, dp_odd[i-tetra_odd[j]]);
		}
		dp[i] = ans + 1;
		dp_odd[i] = ans_odd + 1;
		//cout << i << " " << dp[i] << " " << dp_odd[i] << endl;
	}
}

int main() {
	init();
	solve();
	while (true) {
		int n;
		cin >> n;
		if (n == 0) {
			break;
		}
		
		cout << dp[n] << " " << dp_odd[n] << endl;
	}
}

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

struct P{
  int sum,k,n;
  P(){}
  P(int S,int K,int N){ sum=S;k=K;n=N; }
};

int a[200];

int main(){
  int n, ans1,ans2;
  queue<P> q;
  P p;


  for( int i=1;i<200 ; i++ )
    if( (a[i]=i*(i+1)*(i+2)/6)>1000000 )
      break;

  while( cin>>n && n ){

    
    while( !q.empty() ) q.pop();
    for( int i=1;i<200;i++ ){
      if( a[i]<=n ) q.push( P(a[i],i,1) );
      else          break;
    }
    while( !q.empty() ){
      p=q.front(); q.pop();

      if( p.sum==n ){
	ans1=p.n; break;
      }

      for( int i=p.k,j;i<200;i++ ){
	j=p.sum+a[i];
	if( j<=n ) q.push( P(j,i,p.n+1) );
	else       break;
      }
    }


    while( !q.empty() ) q.pop();
    for( int i=1;i<200;i++ ){
      if( a[i]<=n ){
	if( a[i]%2==1 ) q.push( P(a[i],i,1) );
      }else          break;
    }
    while( !q.empty() ){
      p=q.front(); q.pop();

      if( p.sum==n ){
	ans2=p.n; break;
      }

      for( int i=p.k,j;i<200;i++ ){
	if( a[i]%2==1 ){
	  j=p.sum+a[i];
	  if( j<=n ) q.push( P(j,i,p.n+1) );
	  else       break;
	}
      }
    }

    cout << ans1 << " " << ans2 << endl;
  }

  return 0;
}

C++: //#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
ll n;
vector<ll> ans,ansodd;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<ll> dp(1000001,INF), odddp(1000001,INF);
    dp[0]=0;
    odddp[0]=0;
    ll k=1;
    while(true){
        ll count=k*(k+1)*(k+2)/6;
        if(count>1000000) break;
        for(int i=count;i<=1000000;i++){
            dp[i]=min(dp[i],dp[i-count]+1);
            if(count%2){
                odddp[i]=min(odddp[i],odddp[i-count]+1);
            }
        }
        k++;
    }
    while(cin>>n,n){
        cout<<dp[n]<<" "<<odddp[n]<<"\n";
    }
}