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>
#define INF 2000000000
#define int long long int
#define MOD 1000000007
#define pb push_back
#define cin1(n) (cin >> n)
#define cin2(a,b) (cin >> a >> b)
#define cin3(a,b,c) (cin >> a >> b >> c)
#define cout(n) (cout << n << endl)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define fr first 
#define sc second 
#define EPS (1e-10)

using namespace std;

typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef vector<pair<int,int>> vpii;
typedef vector<string> vs;
typedef vector<vector<string>> vss;
typedef pair<int,int> pii;

int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
int n,m;
int a,b;
int p,q;


int MAX = 1000000;

signed main() {

	vi dp(MAX,MAX); // iテ」ツ?ョテヲツュツ」テ・ツ崢崚ゥツ敖「テ、ツスツ禿」ツ?ョテヲツ慊?・ツーツ湘・ツ?凝ヲツ閉ー
	vi dpo(MAX,MAX);

	dp[0] = 0;
	dpo[0] = 0;
	for (int i = 0;; i++) {
		int polo = i * (i + 1) * (i + 2) / 6;
		if (polo > MAX) break;
		for (int j = polo; j < MAX; j++) {
			dp[j] = min(dp[j],dp[j-polo] + 1);
		}
		if (polo % 2 == 1) {
		for (int j = polo; j < MAX; j++) {
			dpo[j] = min(dpo[j],dpo[j-polo] + 1);
		}
		}
	}

	while(1) {
		cin1(n);
		if (n == 0) break;
		cout << dp[n] << " " << dpo[n] << endl;
	}
	return 0;
}

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

struct P{
  int sum;
  char 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;

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

  int size,n2;
  while( cin>>n && n ){

    ans1=0;
    while( !q.empty() ) q.pop();
    for( int i=1;i<200;i++ ){
      if( a[i]==n ){
	ans1=1; size=i+1;
	break;
      }
      if( a[i]<n ) q.push( P(a[i],i,1) );
      else{
	size=i; break;
      }
    }
    while( !ans1 ){
      p=q.front(); q.pop();
      n2=p.n+1;
      int mm=n-p.sum;
      int *ip = lower_bound( a,a+size,mm );
      if( *ip==mm ){
	ans1=n2; break;
      }
      while( *ip ){
	int i = (ip-a);
	int j=p.sum+(*ip);
	q.push( P(j,i,n2) );
	ip--;
      }
    }

    ans2=0;
    while( !q.empty() ) q.pop();
    for( int i=1;i<size;i++ ){
      if( a[i]%2==1 ){
	if( a[i]==n ){ ans2=1; break; }
	q.push( P(a[i],i,1) );
      }
    }
    while( !ans2 ){
      p=q.front(); q.pop();
      n2=p.n+1;
      int mm=n-p.sum;
      int *ip=lower_bound( a,a+size,mm );
      if( *ip==mm && (*ip)%2==1 ){
	ans2=n2; break;
      }
      while( *ip ){
	int i=(ip-a);
	if( (*ip)%2==1 ){
	  int j=p.sum+(*ip);
	  q.push( P(j,i,n2) );
	}
	ip--;
      }

      /*
      if( mm%2==1 && binary_search( a,a+size,mm ) ){
	ans2=n2; break;
      }
      for( int i=p.k,j;i<size;i++ ){
	if( a[i]%2==1 ){
	  j=p.sum+a[i];
	  if( j>n ) break;
	  q.push( P(j,i,n2) );
	}
      }
      */
    }
    
    cout << ans1 << " " << ans2 << endl;
  }
    
  return 0;
}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)n; ++i)

ll table[1000000];
ll pollock[1000001];
ll dp[1000001];
int main() {
	//freopen("Text.txt", "r", stdin);
	
	ll size = 0;
	{
		ll i = 0;
		table[0] = 0;
		while (1000001 > table[i]) {
			i++;
			table[i] = i*(i + 1)*(i + 2) / 6;
		}
		size = i;
	}

	{
		pollock[0] = 0;
		ll current_i = 0;
		REP(i, 1000001) {
			if (i == 0) continue;
			if (table[current_i + 1] == i) {
				pollock[i] = 1; current_i++;
				continue;
			}

			ll minimum = 1000001;
			for (ll j = 1; j <= current_i; j += 1) {
				minimum = min(pollock[i - table[j]] + 1, minimum);
			}
			pollock[i] = minimum;
		}
	}

	{
		dp[0] = 0;
		ll current_i = -3;
		REP(i, 1000001) {
			if (i == 0) continue;
			if (table[current_i + 4] == i) {
				current_i += 4; dp[i] = 1;
				continue;
			}

			ll minimum = 1000001;
			for(ll j=1; j<=current_i; j+=4) {
				minimum = min(dp[i - table[j]]+1, minimum);
			}
			dp[i] = minimum;
		}
	}

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

}