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, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    cout << fixed << setprecision(10);
    int max_n = 1e6+1, INF = max_n+1;

    // max_nを超えるまで、正四面体数を用意する
    vector<int> st, ost;
    int tn = 0, ti = 1;
    while (tn <= max_n) {
        tn = ti * (ti+1) * (ti+2) / 6;
        st.emplace_back(tn);
        if (tn % 2 == 1) {
            ost.emplace_back(tn);
        }
        ti += 1;
    }

    // 全ての数を使用する
    vector<int> dp(max_n+1, INF);
    dp[0] = 0;
    rep(i, max_n) {
        rep(j, st.size()) {
            if (i+1 - st[j] >= 0) {
                dp[i+1] = min(dp[i+1], dp[i+1 - st[j]] + 1);
            }
        }
    }

    // 奇数だけ使用
    vector<int> odp(max_n+1, INF);
    odp[0] = 0;
    rep(i, max_n) {
        rep(j, ost.size()) {
            if (i+1 - ost[j] >= 0) {
                odp[i+1] = min(odp[i+1], odp[i+1 - ost[j]] + 1);
            }
        }
    }

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

    return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
typedef complex<double> P;
static const double EPS = 1e-8;
static const int INF = (int)1e8;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) for (int i=0; i<(int)(n); ++i)
#define FOREQ(i,k,n) for (int i=(k); i<=(int)(n); ++i)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FIND(m,w) ((m).find(w)!=(m).end())
int MAX_N = 1000001;
int main(void){
  int dp[MAX_N];
  int dp2[MAX_N];
  vector<int> four;
  REP(i,MAX_N) dp[i] = INF;
  REP(i,MAX_N) dp2[i] = INF;
  dp[0] = 0;
  dp2[0] = 0;
  for(int i=1; i*(i+1)*(i+2)/6<=MAX_N; i++){
    four.push_back(i*(i+1)*(i+2)/6);
  }
  REP(i,four.size())FOR(j,four[i],MAX_N){
    dp[j] = min(dp[j],dp[j-four[i]]+1);
    if(four[i]%2) dp2[j] = min(dp2[j],dp2[j-four[i]]+1);
  }
  int N;
  while(cin>>N,N)cout<<dp[N]<<" "<<dp2[N]<<endl;
  return 0;
}

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

using namespace std;

int main(){
	static int dpA[1000001], dpB[1000001];
	vector<int> v;
	for(int i=0;i<=1000000;i++) dpA[i] = dpB[i] = 10000;
	dpA[0] = dpB[0] = 0;
	for(int i=1;;i++){
		int s = i*(i+1)*(i+2)/6;
		if(s > 1000000) break;
		v.push_back(s);
	}
	for(int i=0;i<=1000000;i++){
		for(int j=0;j<v.size()&&i+v[j]<=1000000;j++){
			dpA[i+v[j]] = min(dpA[i+v[j]], dpA[i]+1);
			if(v[j]%2==1){
				dpB[i+v[j]] = min(dpB[i+v[j]], dpB[i]+1);
			}
		}
	}
	int t;
	while(cin >> t && t){
		cout << dpA[t] << " " << dpB[t] << endl;
	}
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 1e9
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int dp[1000010]={};
  int dp2[1000010]={};
  for(int i=1;i<=1000000;i++){dp[i]=INF;dp2[i]=INF;}
  vector<ll> gu;
  vector<ll> ki;
  ll cnt=1;
  while(1){
    if((cnt*(cnt+1)*(cnt+2)/6)>1000000)break;
    if(((cnt*(cnt+1)*(cnt+2))/6)%2)ki.pb(cnt*(cnt+1)*(cnt+2)/6);
    else gu.pb(cnt*(cnt+1)*(cnt+2)/6);
    cnt++;
  }
  dp[1]=1;
  dp2[1]=1;
  for(int i=1;i<1000000;i++){
    for(int j=0;j<gu.size();j++){
      if(i+gu[j]>1000000)break;
      dp[i+gu[j]]=min(dp[i+gu[j]],(dp[i]+1));
    }
    for(int j=0;j<ki.size();j++){
      if(i+ki[j]>1000000)break;
      dp[i+ki[j]]=min(dp[i+ki[j]],(dp[i]+1));
      dp2[i+ki[j]]=min(dp2[i+ki[j]],(dp2[i]+1));
    }
  }
  int n;
  while(cin>>n,n){
    cout<<dp[n]<<" "<<dp2[n]<<endl;
  }
  return 0;
}

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

int dpt1[1000001];
int dpt2[1000001];
bool dpb1[1000001];
bool dpb2[1000001];
int tr[301];
int sq[301];

int dp1(int s) {
  if(dpb1[s])
    return dpt1[s];

  int m = 1000111000;
  int r;
  for(int i=1; s-sq[i] >= 0; i++) {
    r = dp1(s-sq[i]);
    if(r < m) m = r;
  }

  dpt1[s] = m + 1;
  dpb1[s] = true;
  return m + 1;
}

int dp2(int s) {
  if(dpb2[s])
    return dpt2[s];

  int m = 1000111000;
  int r;
  for(int i=1; s-sq[i] >= 0; i++) {
    if(sq[i]%2 == 0)
      continue;
    r = dp2(s-sq[i]);
    if(r < m) m = r;
  }

  dpt2[s] = m + 1;
  dpb2[s] = true;
  return m + 1;
}

int main() {

  for(int i=1; i <= 300; i++) {
    tr[i] = tr[i-1] + i;
    sq[i] = sq[i-1] + tr[i];
  }
  dpt1[0] = 0;
  dpb1[0] = true;
  dpt2[0] = 0;
  dpb2[0] = true;
  int n;
  while(cin >> n, n) {
    cout << dp1(n) << " " << dp2(n) << endl;
  }

  return 0;
}