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 <algorithm>
#include <vector>
#include <queue>
using namespace std;

#define DEBUG(x) cerr << #x << " = " << x << endl

const int MAX_N = 1000000;
const int INF = (int)1e9;

int main() {
    vector<int> tetra;
    for(int i = 1, k; k = i * (i + 1) * (i + 2) / 6, k <= MAX_N; i++) {
        tetra.push_back(k);
    }

    vector<int> dp(MAX_N + 1, INF);
    vector<int> dp2(MAX_N + 1, INF);
    queue<int> Q;
    queue<int> Q2;
    for(int i = 0; i < (int)tetra.size(); i++) {
        dp[tetra[i]] = 1;
        Q.push(tetra[i]);
        if(tetra[i] % 2 == 1) {
            dp2[tetra[i]] = 1;
            Q2.push(tetra[i]);
        }
    }

    while(Q.empty() == false) {
        int k = Q.front(); Q.pop();
        for(int i = 0; i < (int)tetra.size() && k + tetra[i] <= MAX_N; i++) {
            if(dp[k + tetra[i]] > dp[k] + 1) {
                dp[k + tetra[i]] = dp[k] + 1;
                Q.push(k + tetra[i]);
            }
        }
    }

    while(Q2.empty() == false) {
        int k = Q2.front(); Q2.pop();
        for(int i = 0; i < (int)tetra.size() && k + tetra[i] <= MAX_N; i++) {
            if(tetra[i] % 2 == 0) continue;
            if(dp2[k + tetra[i]] > dp2[k] + 1) {
                dp2[k + tetra[i]] = dp2[k] + 1;
                Q2.push(k + tetra[i]);
            }
        }
    }

    for(int N; cin >> N, N > 0; ) {
        cout << dp[N] << ' ' << dp2[N] << endl;
    }
}

C++: #include <cstdio>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <iostream>

using namespace std;

#define MAX_N 1000000

int N;
int inf = 1000000000;

int d[MAX_N+1]; // ?????????j??¨?????????????????????????°??????°

int calc_sn(int n){
	return n*(n+1)*(n+2)/6;
}

void solve(){
	d[0] = 0;
    for(int i = 1; i <= N; i++){
    	d[i] = inf;
       	for (int j = 1; ; j++)
        {
        	if(i < calc_sn(j)) break;
            d[i] = min(d[i], d[i-calc_sn(j)]+1);
        }
    }
    cout << d[N] << " ";
    d[0] = 0;
    for(int i = 1; i <= N; i++){
    	d[i] = inf;
       	for (int j = 1; ; j++)
        {
        	if(i < calc_sn(j)) break;
        	if(calc_sn(j) % 2 == 0) continue;
            d[i] = min(d[i], d[i-calc_sn(j)]+1);
        }
    }
    cout << d[N] << endl;
}

int main() {
    while(1){
    	cin >> N;
    	if(N == 0) break;
    	solve();
    }
    return 0;
}

C++: #include<iostream>
#include<algorithm>
#define INF 1<<28
using namespace std;

int p[1000001];
int memo[1000001];
int memo2[1000001];

int solve(int n, int count){
  
  if(!n) return 0;
  if(n <= 0 || !count) return INF;
  if(memo[n]) return memo[n];
  
  int ans = INF;
  for(int i=0;p[i]<=n; i++) ans = min(ans, solve(n-p[i], count-1)+1);
  
  return memo[n] = ans;
}

int solve2(int n){
  
  if(!n) return 0;
  if(n<0) return INF;
  if(memo2[n]) return memo2[n];
  
  int ans = INF;
  for(int i=0;p[i]<=n;i++){
    if(!(p[i]%2)) continue;
    ans = min(ans, solve2(n-p[i])+1);
  }
  
  return memo2[n] = ans;
}

int main(){
  
  int n;
  
  for(int i=0;i<=1000000;i++) p[i] = i*(i+1)*(i+2)/6;
  for(int i=1;i<=1000000;i+=100000) solve(i, 5), solve2(i);
  
  while(cin >> n, n) cout << solve(n, 5) << " " << solve2(n) << endl;
}

C++: #include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<math.h>
#include <string>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;
ll mod=1e9+7;
int N=1e6;
int cnt[1000000];
int odd[1000000];
int main(){
	vector<int> v(180),u(181);
	v[0]=0;
	for(int i=1;i<=180;i++){
		v[i]=(i*(i+1)*(i+2)/6);
	}
	u[0]=0;
	for(int i=1;i<=180;i++){
		u[i]=u[i-1]+i;
	}
	cnt[0]=odd[0]=0;
	for(int i=1;i<N;i++){
		cnt[i]=1e9;
		odd[i]=1e9;
	}
	for(int i=1;i<N;i++){
		for(int j=1;j<=180;j++){
			if(i-v[j]>=0){
				if(cnt[i]>cnt[i-v[j]]+1){
					cnt[i]=cnt[i-v[j]]+1;
				}
				if(v[j]%2==1&&odd[i]>odd[i-v[j]]+1){
					odd[i]=odd[i-v[j]]+1;
				}
			}
		}
	}
	while(1){
		int n; cin >>n;
		if(n==0)break;
		cout << cnt[n] << " " << odd[n] << endl;
	}
}

C++: #include<iostream>
using namespace std;
int main(){
  int a,b,c,n,x[9999],y[9999],X[1000001],Y[1000001];
  a=b=c=1;
  while(1){
    x[a]=c*(c+1)*(c+2)/6;
    if(x[a]>1000000)break;
    a++;
    if(x[a-1]%2==1){
      y[b]=x[a-1];
      b++;
    }
    c++;
  }

  X[0]=0;
  for(int i=1;i<=1000000;i++)X[i]=i;
  for(int i=1;i<a;i++){
    for(int j=x[i];j<=1000000;j++){
      if(X[j]>X[j-x[i]]+1)X[j]=X[j-x[i]]+1;
    }
  }

  Y[0]=0;
  for(int i=1;i<=1000000;i++)Y[i]=i;
  for(int i=1;i<b;i++){
    for(int j=y[i];j<=1000000;j++){
      if(Y[j]>Y[j-y[i]]+1)Y[j]=Y[j-y[i]]+1;
    }
  }
  while(1){
    cin>>n;
    if(n==0)break;
    cout<<X[n]<<' '<<Y[n]<<endl;
  }
  return 0;
}