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<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
int a[1001],ta[1001],tta[1001];
int dp[1000021],dp2[1000010];
const int INF=99999999;
int main(){
	a[1]=1,ta[1]=1,tta[1]=1;
	int cnt=1;
	for(int i=2;i<=1000;i++)a[i]=i+a[i-1];
	for(int i=2;i<=1000;i++){
	ta[i]=a[i]+ta[i-1];
	if(ta[i]%2==1)tta[++cnt]=ta[i];
	}

	fill(dp,dp+1000001,INF);
	fill(dp2,dp2+1000001,INF);
	dp[0]=0,dp2[0]=0;
	for(int i=1;i<=200;i++){
		for(int j=1;j<=1000000;j++){
		if(j>=ta[i])dp[j]=min(dp[j],dp[j-ta[i]]+1);
		}//
	}//endfor
	for(int i=1;i<=100;i++){
		for(int j=1;j<=1000000;j++){
		if(j>=tta[i])dp2[j]=min(dp2[j],dp2[j-tta[i]]+1);
		}
	}//endfor
	int n;
	while(true){
	scanf("%d",&n);
	if(n==0)break;
	cout<<dp[n]<<" "<<dp2[n]<<endl;
	}//endwhile
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define nmax 1000000
#define INF 1000000000
int dp[nmax],dp2[nmax];


int main()
{
    for (int i=0;i<nmax;i++)
    {
        dp[i]=INF;
        dp2[i]=INF;
    }
    int i=1;
    dp[0]=0;dp2[0]=0;
    vector<int> nums;
    while (i*(i+1)*(i+2)/6<nmax)
    {
        nums.push_back(i*(i+1)*(i+2)/6);
        dp[i*(i+1)*(i+2)/6]=1;
        if (i*(i+1)*(i+2)/6%2==1) dp2[i*(i+1)*(i+2)/6]=1;
        i++;
    }
    for (int i=0;i<nums.size();i++)
    {
        for (int j=0;j<nmax;j++)
        {
            if (j+nums[i]<nmax) dp[j+nums[i]]=min(dp[j+nums[i]],dp[j]+1);
            if (j+nums[i]<nmax && nums[i]%2==1) dp2[j+nums[i]]=min(dp2[j+nums[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 <vector>
#include <algorithm>
#include <climits>
#define V_MAX 1000
using namespace std;

int main(){
  int n;
  vector<int> v(V_MAX);
  int i=0,mx=0;
  int p[200],size;

  while( cin>>n && n ){
    if( i<V_MAX ) v[i]=n;
    else          v.push_back(n);
    i++;
    mx=max(mx,n);
  }
  int vSize=i;

  p[0]=0;
  for( size=1; ; size++ ){
    p[size]= size*(size+1)*(size+2)/6;
    if( p[size]>mx ) break;
  }

  int dMAX = p[size-1] + 1;
  int dp1[dMAX],dp2[dMAX];
  int m,j ;
  fill( dp1,dp1+dMAX,INT_MAX );
  fill( dp2,dp2+dMAX,INT_MAX );

  dp1[0]=0;
  for( i=1;i<size;i++){
    m=p[i];
    for( j=m;j<dMAX;j++ )
      dp1[j] = min( dp1[j],dp1[j-m]+1 );
  }

  dp2[0]=0;
  for( i=1;i<size;i++){
    if( p[i]%2==0 ) continue;
    m=p[i];
    for( j=m;j<dMAX;j++ )
      dp2[j] = min( dp2[j],dp2[j-m]+1 );
  }


  
  for( i=0;i<vSize;i++ )
    cout << dp1[ v[i] ] << " " << dp2[ v[i] ] << endl;

  return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }

int main() {
    int M = 1000000;
    vector<int> v, u;
    for (int i = 1; i*(i+1)*(i+2)/6 <= M; ++i) {
        v.emplace_back(i*(i+1)*(i+2)/6);
        if(v[i-1]&1) u.emplace_back(v[i-1]);
    }
    v.emplace_back(MOD);
    u.emplace_back(MOD);
    vector<int> dp(M, INF<int>);
    dp[0] = 0;
    for (int i = 0; i < M; ++i) {
        for (int j = 0; v[j] <= i; ++j) {
            chmin(dp[i], dp[i-v[j]]+1);
        }
    }
    vector<int> dq(M, INF<int>);
    dq[0] = 0;
    for (int i = 0; i < M; ++i) {
        for (int j = 0; u[j] <= i; ++j) {
            chmin(dq[i], dq[i-u[j]]+1);
        }
    }
    int p;
    while(cin >> p, p){
        cout << dp[p] << " " << dq[p] << "\n";
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int h;
vector<int> vv;
vector<int> vvb;

int dp[1000000]={};
int dpb[1000000]={};
void pir_cal(){
	for(int i=1;i<1000000;i++){
		dp[i]=1000000;
		dpb[i]=1000000;
	}
	for(int i=1;i<200;i++){
		ll j=(ll)i*(i+1)*(i+2)/6;
		if(j>=1000000){
			break;
		}
		vv.push_back(j);
		dp[j]=1;
		if(j%2==1){
			vvb.push_back(j);
			dpb[j]=1;
		}
	}
	/*for(int i=0;i<vv.size();i++)
		cout<<vv[i]<<endl;*/
}

void cal_dp(){
	
	for(int i=1;i<1000000;i++){
		
		for(int j=0;j<vv.size()&&vv[j]<i;j++){
			dp[i]=min(dp[i],dp[i-vv[j]]+1);
			
		}
		for(int j=0;j<vvb.size()&&vvb[j]<i;j++){
			dpb[i]=min(dpb[i],dpb[i-vvb[j]]+1);
			
		}
		
	}
}
		
int main(){
	pir_cal();
	cal_dp();
	while(1){
		cin>>h;
		if(h==0)break;
		printf("%d %d\n",dp[h],dpb[h]);
	}
	return 0;
}