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;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

int A[2111111];
int B[2111111];
int seica[11111];


int main(){
	
	REP(i,1111111)A[i] = B[i] = INF;
	A[0] = B[0] = 0;
	REP(i,11111){
		seica[i] = i*(i+1)*(i+2)/6;
		if(seica[i] > 1000000)break;
	}
	
	REP(i,1000000){
		for(int j = 1;j < 10000;j++){
			A[i+seica[j]] = min(A[i]+1,A[i+seica[j]]);
			if(i + seica[j] > 1000000)break;
		}
	}
			
	REP(i,1000000){
		for(int j = 1;j < 10000;j++){
			if(seica[j]%2==1)B[i+seica[j]] = min(B[i]+1,B[i+seica[j]]);
			if(i + seica[j] > 1000000)break;
		}
	}	
	
	DBG(SHOW1d(A,100);)
	DBG(SHOW1d(B,100);)
	
	int n;
	while(cin >> n ,n){
		cout << A[n] << ' ' << B[n] << endl;
	}
	
	return 0;
}

C++: #include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

unsigned int dp[1000010];
map<int,int> memo;
int main(){ _;
  int n;
  while(cin>>n,n!=0){
    REP(i,n+1)dp[i]=-1;
    dp[0]=0;
    REP(i,n){
      for(int j=1;;j++){
	int& k=memo[j];
	if(k==0) k=j*(j+1)*(j+2)/6;
	if(i+k>n) break;
	else dp[i+k]=min(dp[i+k],dp[i]+1);
      }
    }
    cout<<dp[n]<<" ";
    REP(i,n+1)dp[i]=-1;
    dp[0]=0;
    REP(i,n){
      for(int j=1;;j++){
	int& k=memo[j];
	if(k==0) k=j*(j+1)*(j+2)/6;
	if(((k>>1)<<1)==k) continue;
	if(i+k>n) break;
	else dp[i+k]=min(dp[i+k],dp[i]+1);
      }
    }
    cout<<dp[n]<<endl;
  }
}

C++: #include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

int p[200],q[50];

int f(int n,int m,int c){
	if(c==4&&n>0)return 5;
	if(n<10)return min(c+n/4+n%4,5);
	int rec=5,i=0;
	while(p[i]<n/(4-c))i++;
	for(i;p[i]<=m;i++)rec=min(rec,f(n-p[i],min(p[i],n-p[i]),c+1));
	return rec;
}

int g(int n,int m,int c,int *M){
	if(c==*M)return *M;
	if(n<165)return c+n/35+n%35;
	int i=44;
	while(q[i]>m)i--;
	for(i;i>0;i--){
		*M=min(*M,g(n-q[i],min(q[i],n-q[i]),c+1,M));
	}
	return *M;
}

int main(){
	for(int i=0;(i+1)*(i+2)*(i+3)/6<=1000000;i++)p[i]=(i+1)*(i+2)*(i+3)/6;
	for(int i=0;(4*i+1)*(4*i+2)*(4*i+3)/6<=1000000;i++)q[i]=(4*i+1)*(4*i+2)*(4*i+3)/6;
	int N;
	while(cin>>N){
		if(!N)return 0;
		int ans=9999;
		cout<<f(N,N,0)<<" "<<g(N,N,0,&ans)<<endl;
	}
}

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

int main(void)
{
  for(;;){
    int x;
    cin >> x;

    if(x==0)
      break;

    int count=0;
    int count_ki=0;
    int tmp;
    

    int coin[100000];
    int coin_ki[100000];
   
    int tmp2=0;
  
    for(int i=1;i<x;i++){
      tmp=i*(i+1)*(i+2)/6;
      if(tmp>x)break;
      coin[i-1]=tmp;
      count=i;
      if(coin[i-1]%2==1){
	coin_ki[tmp2++]=coin[i-1];
	count_ki=tmp2;
      }
    }
    ////
    int dp[10000];
    //fill(dp,dp + x+1,100000);
  

    dp[0]=0;
    for(int i = 0;i<x+1;i++){
      for(int j=0;j<count;j++){
	if(i+coin[j]<=x){
	  dp[i+coin[j]]=min(dp[i+coin[j]],dp[i]+1);
	}
      }
    }

    cout << dp[x] << " ";
    //fill(dp,dp + x + 1,100000);
  
    //printf("%d\n",count_ki);
    dp[0]=0;
    for(int i = 0;i<x+1;i++){
      for(int j=0;j<count_ki;j++){
	if(i+coin_ki[j]<=x){
	  dp[i+coin_ki[j]]=min(dp[i+coin_ki[j]],dp[i]+1);
	}
      }
    }
   
    cout << dp[x] << endl;
  
    ///*/
  }
  return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  vector<int> smt(1,0);
  vector<int> ksmt(1,0);
  int a;
  for(int i=1;i<10000;i++){
    a=i*(i+1)*(i+2)/6;
    smt.push_back(a);
    if(a%2==1)ksmt.push_back(a);
    if(a>1000000)break;
    //cout << a << endl;
  }
    //cout <<smt.size()<<" "<<ksmt.size()<<endl;
  int dp[2][1000001]={};
  //cout <<"2"<<endl;
  //
  for(int i=1;i<=1000000;i++){
    dp[0][i]=i;
    dp[1][i]=i;
  }
  //all
  for(int i=1;i<smt.size();i++){
    for(int j=1;j<=1000000;j++){
      if(smt[i]>j) dp[0][j]=dp[0][j];
      else{
	dp[0][j]=min(dp[0][j],dp[0][j-smt[i]]+1);
      }
      //cout <<dp[k][j]<<" ";
    }
  }
  //kisuu
  for(int i=1;i<ksmt.size();i++){
    for(int j=1;j<=1000000;j++){
      if(ksmt[i]>j) dp[1][j]=dp[1][j];
      else{
	dp[1][j]=min(dp[1][j],dp[1][j-ksmt[i]]+1);
      }
    }
  }
  while(1){
    int n;
    cin >> n;
    if(n==0)break;
    cout << dp[0][n]<<" "<<dp[1][n]<<endl;
  }
return 0;
}