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 <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <climits>
#include <cassert>
using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF INT_MAX/3
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define debug(x) cout<<#x<<":"<<x<<endl
#define debug2(x,y) cout<<#x","<<#y":"<<x<<","<<y<<endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

vi num;
vi num_odd;
int N;
int N_odd;

void init(){
    int t=1;
    int i=1;
    while(t<1000000){
        num.EB(t);
        i++;
        t = i*(i+1)*(i+2)/6;
    }
    N = num.size();

    for(i=0;i<N;i++){
        if(num[i]%2==1) num_odd.emplace_back(num[i]);
    }
    N_odd = num_odd.size();
}

void solve(int n){
    vvi dp(N+1,vi(n+10,INF));
    for(int i=0;i<N;i++) dp[i][0]=0;
    for(int i=0;i<N;i++){
        for(int j=0;j<=n;j++){
            if(j-num[i]>=0){
                dp[i+1][j] = min(dp[i][j],dp[i+1][j-num[i]]+1);
            }else{
                dp[i+1][j] = dp[i][j];
            }
        }
    }



    cout << dp[N][n] << " ";


    dp.shrink_to_fit();
    dp.resize(N_odd+1,vi(n+10,INF));

    for(int i=0;i<N_odd;i++) dp[i][0]=0;


    for(int i=0;i<N_odd;i++){
        for(int j=0;j<=n;j++){
            if(j-num_odd[i]>=0) dp[i+1][j] = min(dp[i][j],dp[i+1][j-num_odd[i]]+1);
            else dp[i+1][j] = dp[i][j];
        }
    }
    //for(int i=0;i<5;i++){
    //    for(int j=0;j<=n;j++){
    //        printf("%02d ",dp[i][j]);
    //    }
    //    cout << endl;
    //}
    cout << dp[N_odd][n] << endl;
}

int main(){
    init();
    int n;


    while(cin>>n){
        if(n==0) break;
        solve(n);
    }
}

C++: #include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
    int n=1000010;
    vector<int>em(260,0);
    for(int i=0;i<250;i++){
        em[i]=i*(i+1)*(i+2)/6;
      //  clog<<em[i]<<endl;
    }
    vector<pair<int,int>>dp(1000010,mp(INF,INF));
    while(1){
        dp[0] = mp(0, 0);
        for (int i = 0; em[i] <= n; i++)
        {
            for (int j = 0; j + em[i] <= n; j++)
            {
                chmin(dp[j + em[i]].F, dp[j].F + 1);
                if (em[i] % 2 == 1)
                {
                    chmin(dp[j + em[i]].S, dp[j].S + 1);
                }
            }
        }
        cin>>n;
        if(n==0){
            break;
        }
        

        cout << dp[n].F<<" "<<dp[n].S << endl;
    }
    
   
}

C++: // 2013/06/29 Tazoe

#include <iostream>
#include <vector>
using namespace std;

int main()
{
	vector<int> P;
	P.push_back(1);

	for(int i=0; ; i++){
		int p = P[i]*(i+4)/(i+1);

		if(p>=1000000)
			break;

		P.push_back(p);
	}
/*
	for(int i=0; i<P.size(); i++){
		cout << P[i] << endl;
	}
*/
	while(true){
		int n;
		cin >> n;

		if(n==0)
			break;

		int DP[1000000];
		int DP2[1000000];
		DP[0] = 0;
		DP2[0] = 0;
		for(int i=1; i<=n; i++){
			DP[i] = 1000000;
			DP2[i] = 1000000;
		}

		for(int i=0; P[i]<=n; i++){
			for(int j=0; j+P[i]<=n; j++){
				if(DP[j]+1<DP[j+P[i]]){
					DP[j+P[i]] = DP[j]+1;
				}

				if(P[i]%2==1 && DP2[j]+1<DP2[j+P[i]]){
					DP2[j+P[i]] = DP2[j]+1;
				}
			}
		}

		cout << DP[n] << ' ' << DP2[n] << endl;
	}

	return 0;
}