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++: // -*- coding: utf-8 -*-
// Last-Updated : <2014/06/18 23:38:15 by samui>

#include <algorithm>
#include <iostream>
#include <cstdio>
#include <string>
#include <climits>
#define MP(a, b) make_pair(a, b)
#define X first
#define Y second
#define rep(i,n) for(int (i) = 0; (i) < (int)(n); ++(i))
#define rer(i,l,n) for(int (i) = l; (i) <= (int)(n); ++(i))
#define reu(i,l,n) for(int (i) = l; (i) < (int)(n); ++(i))
template<typename T,typename U> inline void amin(T &x,U y){ if(y<x) x = y;}
template<typename T,typename U> inline void amax(T &x,U y){ if(x<y) x = y;}
template<typename TYPE,std::size_t SIZE>
std::size_t len(const TYPE (&array)[SIZE]){return SIZE;}
int answer(int A);
int main(int argc, char *argv[])
{
  int i;
  while(std::cin>>i){
    if(i == 0){
      break;
    }
    answer(i);
  }
  return 0;
}
int answer(int A)
{
  
  int N = A;
  float e = 1000000;
  rep(i,A){
    if(  std::abs(i*(i+1)*(i+2)/6-A) <= e  ){
      e = std::abs(i*(i+1)*(i+2)/6-A);
      N = i;
    }else{
      N+=2; // N+1でいいが。
      break;
    }
  }

  std::vector<int> s(N);
  std::vector<int> dp(A+1,1000000000);
  std::vector<int> dp2(A+1,1000000000);
  dp[0] = 0;
  dp2[0] = 0;
  rep(i,N){
    s[i] = i*(i+1)*(i+2)/6;
  }

  rep(i,A+1){
    rep(j,s.size()){
      if(i-s[j]>=0){
	amin(dp[i],dp[i-s[j]]+1);
      }
      if(i-s[j]>=0 && s[j]%2 == 1){
	amin(dp2[i],dp2[i-s[j]]+1);
      }
    }
  }

  std::cout<<dp[A]<<" "<<std::flush;
  std::cout<<dp2[A]<<std::endl;
  
  return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
 
ll dp[1000010];
ll dp_odd[1000010];


int main(void){
    for(ll i=0;i<1000010;i++){
        dp[i]=(ll)INF;
        dp_odd[i]=(ll)INF;
    }
    vector<ll>a,b,c;
    for(ll i=1;;i++){
        ll tmp = i*(i+1)/2;
        if(i>1000000)break;
        a.push_back(tmp);
    }
    ll sum = 0;
    for(ll i=0;;i++){
        sum+=a[i];
        if(sum>1000000)break;
        b.push_back(sum);
        if(sum%2==1)c.push_back(sum);
    }
    ll asize = a.size();
    ll bsize = b.size();
    ll csize = c.size();
    dp[0]=0;
    dp_odd[0]=0;
    for(ll i=1;i<1000000;i++){
        for(ll j=0;j<bsize;j++){
            if(i>=b[j])dp[i]=min(dp[i],dp[i-b[j]]+1);
            else break;
        }
    }
    for(ll i=1;i<1000000;i++){
        for(ll j=0;j<csize;j++){
            if(i>=c[j])dp_odd[i]=min(dp_odd[i],dp_odd[i-c[j]]+1);
            else break;
        }
    }
    while(true){
        int n;
        cin>>n;
        if(n==0)break;
        cout<<dp[n]<<" "<<dp_odd[n]<<endl;
    }
    return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<set>
#include<vector>
#include<queue>
#include<map>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include <climits>
using namespace std;

#define REP(i,a,n) for(int i = a ; i < n ; i++)
#define rep(i,n) REP(i,0,n)

typedef long long ll;

int dpAll[1000010];
int dpOdd[1000010];
vector<int> v;

int dfsAll(int rem){
  if(rem == 0) return 0;
  if(dpAll[rem] != INT_MAX) return dpAll[rem];

  int res = INT_MAX;
  for(int i=0;i<v.size() && v[i]<=rem;i++){
    int tmp = dfsAll(rem-v[i]);
    if(tmp != INT_MAX && res > tmp + 1) res = tmp + 1;
  }
  return dpAll[rem]=res;
}

int dfsOdd(int rem){
  if(rem == 0) return 0;
  if(dpOdd[rem] != INT_MAX) return dpOdd[rem];

  int res = INT_MAX;
  for(int i=0;i<v.size() && v[i]<=rem;i++){
    if(v[i] % 2 == 1){
      int tmp = dfsOdd(rem-v[i]);
      if(tmp != INT_MAX && res > tmp + 1) res = tmp + 1;
    }
  }
  return dpOdd[rem]=res;
}

int main(){
  int n;

  for(int i=1;i*(i+1)*(i+2)/6<=1000100;i++){
    v.push_back(i*(i+1)*(i+2)/6);
  }

  rep(i,1000010) dpAll[i] = INT_MAX;
  rep(i,1000010) dpOdd[i] = INT_MAX;
  for(int i=1;i<=1000002;i+=10000) dfsAll(i);
  for(int i=1;i<=1000002;i+=10000) dfsOdd(i);

  while(cin>>n,n){
    cout<<dpAll[n]<<" "<<dpOdd[n]<<endl;
  }
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <queue>
using namespace std;

int dp[500];
int dp1[11111500];
int dp2[11111100];
int main(){
    dp[1]=1;
    for(int i=2;i<210;i++){
        dp[i]=dp[i-1]+i;
    }
    for(int i=2;i<210;i++){
        dp[i]=dp[i-1]+dp[i];
    }
   // fill(dp,dp+400,0);
    fill(dp1,dp1+1111100,9999999999);
    fill(dp2,dp2+1111100,9999999999);
    dp1[0]=0;dp2[0]=0;
    for(int i=1;i<210;i++){
        int now=dp[i];
        for(int k=now;k<1100000;k++){
            if(dp1[k]>dp1[k-now]+1){
                dp1[k]=dp1[k-now]+1;
            }
        }
    }
    for(int i=1;i<300;i++){
        int now=dp[i];
        if(now%2==0)
            continue;
        for(int k=now;k<1100000;k++){
            if(dp2[k]>dp2[k-now]+1)
                dp2[k]=dp2[k-now]+1;
        }
    }
    int n;
    while(1){
        cin>>n;
        cout<<dp1[n]<<" "<<dp2[n]<<endl;
    }
    return 0;
}