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 rep(i,a,n) for(int i=a;i<n;i++)
#define repr(i,a,n) for(int i=a;i>=n;i--)
#define INF 999999999
#define pb(a) push_back(a)

using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef vector<pii> VP;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main() {
    int n;
    int a[1000];
    int b[1000];
    int dp1[1000000];
    int dp2[1000000];
    while(cin >> n) {
        if(n == 0) break;
        rep(i,0,1000) {
            a[i] = 0;
            b[i] = 0;
        }

        int cnt = 0;
        for(int i = 1; i * (i+1) * (i+2) / 6 <= n; i++) {
            a[i-1] = i * (i+1) * (i+2) / 6;

            if(i * (i+1) * (i+2) / 6 % 2 == 1) {
                b[cnt] = i * (i+1) * (i+2) / 6;
                cnt++;
            }
        }

/*
        for(int i = 1; i * (i+1) * (i+2) / 6 <= n; i++) {
            cout << a[i-1] << endl;
        }

        cout << endl;

        for(int i = 0; b[i] != 0; i++) {
            cout << b[i] << endl;
        }
*/

        rep(i,0,1000000) {
            dp1[i] = i;
            dp2[i] = i;
        }

        int k = 0;
        while(a[k] != 0) {
            rep(j,0,n+1) {
                dp1[j+a[k]] = min(dp1[j+a[k]], dp1[j] + 1);
            }
            k++;
        }

        k = 0;
        while(b[k] != 0) {
            rep(j,0,n+1) {
                dp2[j+b[k]] = min(dp2[j+b[k]], dp2[j] + 1);
            }
            k++;
        }

        cout << dp1[n] << " "<< dp2[n] << endl;
    }
    return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
#define INF (1<<25)
int N;
int pr[102];
int dp[100002];
void init(){
  for(int i=0;i<=N;i++) dp[i]=INF;
}
int solve(int g){
  dp[0]=0;
  for(int i=0;i<=N;i++){
    if(dp[i]==INF) continue;
    for(int j=0;j<102;j++){
      if(g==2 && pr[j]%g==0) continue;
      if(i+pr[j]>N) continue;
      dp[i+pr[j]] = min(dp[i+pr[j]],dp[i]+1);
    }
  }

  //  for(int i=0;i<=N;i++) printf("id=%d => %d\n",i,dp[i]);
  return dp[N];
}

int main(){
  for(int i=0;i<102;i++) pr[i] = (i+1)*(i+2)*(i+3)/6;
  //  for(int i=0;i<102;i++) printf("%d\n",pr[i]);
  //  for(int i=0;i<102;i++) if(!(i%2)) printf("%d\n",pr[i]);
  while(1){
    scanf("%d",&N);
    if(!N) break;
    init();
    int res1 = solve(1);
    init();
    int res2 = solve(2);
    printf("%d %d\n",res1,res2);
  }
}

C++: #include<iostream>
#include<vector>
#define MAX 1000000
using namespace std;
vector<int> box,ans1(MAX+10),ans2(MAX+10);
void tab_make(){
	for(int i=1;i*(i+1)*(i+2)/6<=MAX;i++)
		box.push_back(i*(i+1)*(i+2)/6);
}
void ans_make(){
	ans1[0]=ans2[0]=0;
	for(int i=1;i<=MAX;i++){
		ans1[i]=ans2[i]=i;
		for(int j=0;i-box[j]>=0;j++){
			ans1[i]=min(ans1[i],ans1[i-box[j]]+1);
			if(box[j]%2==1)
			ans2[i]=min(ans2[i],ans2[i-box[j]]+1);
		}
	}
}
int main(){
	int x;
	tab_make();
	ans_make();
	while(cin>>x,x){
		cout<<ans1[x]<<' '<<ans2[x]<<endl;
	}
	return 0;
}

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

#define REP(i,n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i,p,k) for (int i = p; i < (int)(k); ++i)
#define FOREACH(it,x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); ++it)
#define ALL(x) x.begin(), x.end()
#define DEBUG(x) cerr<<#x":"<<(x)<<" "
template<class T> void DUMP(const T& v) { FOREACH(it,v) cerr<<*it<<' '; cerr<<endl; }

const int INF = 12345678;
vector<int> nums;

int memo[1000005][2];

int solve(int rest, int odd) {
  if (rest < 0) return INF;
  if (rest == 0) {
    return 0;
  }
  int& minv = memo[rest][odd];
  if (minv >= 0) return minv;
  minv = rest;
  for (int i = nums.size()-1; i >= 2; --i) {
    int v = nums[i];
    if (odd && v % 2 == 0) continue;
    if (rest < v) continue;
    if (minv <= rest / v) continue;
    minv = min(minv, solve(rest - v, odd) + 1);
  }
  return minv;
}

int main() {
  int n;
  for (int i = 0; ; i++) {
    int v = i * (i+1) * (i+2) / 6;
    if (v > 1000000) break;
    nums.push_back(v);
  }
  memset(memo, -1, sizeof(memo));
  while (cin >> n, n) {
    cout << solve(n, 0) << " " << solve(n, 1) << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i = 0 ; i < n ; i++)

int dp[100001] , dp2[100001];

vector<int> item;

int main(){
	int n;
	for(int i = 1 ; i * (i+1) * (i+2) / 6 <= 100000 ; i++) item.push_back(i * (i+1) * (i+2) / 6);
	rep(i,100001) dp[i] = 9999;
	rep(i,100001) dp2[i]= 9999;
	dp[0] = dp2[0] = 0;

	for(int i = 0 ; i <= 100000 ; i++){
		for(int j = 0 ; j < item.size() && item[j]+i <= 100000 ; j++){
			dp[i + item[j]] = min(dp[i + item[j]] , dp[i] + 1);
		}
	}
	for(int i = 0 ; i <= 100000 ; i++){
		for(int j = 0 ; j < item.size() && item[j]+i <= 100000 ; j++){
			if(item[j] % 2) dp2[i + item[j]] = min(dp2[i + item[j]] , dp2[i] + 1);
		}
	}
	
	while(cin >> n && n){
		cout << dp[n] << " " << dp2[n] << endl;
	}
}