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 <cassert>
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,l,n) for(int i=l;i<n;++i)
int ans = 0;
int oddans = 0;
int pol[200];
int oddpol[100];
int oddpolcount = 0;
int memo[1000000];
int oddmemo[1000000];
int memorep(int n);
int oddmemorep(int n);
using namespace std;
int main() {
  pol[0] = 1;
  oddpol[oddpolcount++] = 1;
  int def = 3;
  int defdef = 3;
  REP(i,1,180){
    pol[i] = pol[i-1] + def;
    if(pol[i]%2==1) oddpol[oddpolcount++] = pol[i];
    def += defdef++;
  }
  while(1){
    int n;
    cin >> n;
    if(n==0) return 0;
    ans = memorep(n);
    oddans = oddmemorep(n);
    int i = 0;
    cout << ans << " " << oddans << endl;
  }
  return 0;
}

int memorep(int n){
  assert(n < 1000000);
  if(memo[n]!=0) return memo[n];
  int result;
  int min = 1000000;
  for(int i = 179;i>=0;i--){
    result = n-pol[i];
    if(result == 0){
      return memo[n] = 1;
    }
    if(result > 0){
      result = memorep(result) + 1;
      if(min > result) min = result;
    }
  }
  return memo[n] = min;
}

int oddmemorep(int n){
  if(oddmemo[n]!=0) return oddmemo[n];
  int result;
  int min = 1000000;
  for(int i = oddpolcount-1;i>=0;i--){
    result = n-oddpol[i];
    if(result == 0){
      return oddmemo[n] = 1;
    }
    if(result > 0){
      result = oddmemorep(result) + 1;
      if(min > result){
        min = result;
      }
    }
  }
  return oddmemo[n] = min;
}

C++: #include <cstdio>
#include <algorithm>
using namespace std;
static const int INFTY = (1 << 29);
static const int MAXN = 1000000;
static const int LEN = 182;
int T[MAXN+1], T2[MAXN+1];

int main()
{
    int arr[LEN];
    int i = 0, sum = 0;
    while(sum <= MAXN) {
        arr[i] = sum;
        i++;
        sum = i*(i+1)*(i+2) / 6;
    }
    int N;
    for (int i = 0; i <= MAXN; i++) T[i] = T2[i] = INFTY;
    T[0] = T2[0] = 0;
    T[1] = T2[1] = 1;

    for(int i = 2; i < MAXN; i++){
       for(int j = 1; arr[j] <= i; j++){
            T[i] = min(T[i], T[i-arr[j]]+1);
            if(arr[j] % 2 != 0){
                T2[i] = min(T2[i], T2[i-arr[j]]+1);
            }
        }
    }

    for (; ; ) {
        scanf("%d", &N);
        if (N == 0) break;
        printf("%d %d\n", T[N], T2[N]);
    }

    return 0;
}

C++: #include<iostream>

using namespace std;
#define MAX 1000000
#define INF 1000000000

int dp1[MAX+1],dp2[MAX+2];

int main() {
    for(int i = 1;i <= MAX;i++) {
        dp1[i] = INF;
        dp2[i] = INF;
    }

    for(int n = 1;n * (n + 1) * (n + 2) / 6 <= MAX;n++) {
        int a = n * (n + 1) * (n + 2) / 6;
        for(int i = a;i <= MAX;i++) {
            dp1[i] = min(dp1[i],dp1[i - a] + 1);
        }
        if(a % 2 == 0)continue;
        for(int i = a;i <= MAX;i++) {
            dp2[i] = min(dp2[i],dp2[i - a] + 1);
        }
    }

    while(true) {
        int n;
        cin >> n;
        if(n == 0)break;
        cout << dp1[n] << " " << dp2[n] << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

int p[200],q[50];

int f(int n,int m,int c){
	if(c==4&&n>0)return 5;
	if(n<10)return min(c+n/4+n%4,5);
	int rec=5,i=0;
	while(p[i]<n/(4-c))i++;
	for(i;p[i]<=m;i++)rec=min(rec,f(n-p[i],min(p[i],n-p[i]),c+1));
	return rec;
}

int g(int n,int m,int c){
	if(n<165)return c+n/35+n%35;
	int rec=99999;
	for(int i=1;p[i]<=m;i++)rec=min(rec,f(n-p[i],min(p[i],n-p[i]),c+1));
	return rec;
}

int main(){
	for(int i=0;(i+1)*(i+2)*(i+3)/6<=1000000;i++)p[i]=(i+1)*(i+2)*(i+3)/6;
	for(int i=0;(4*i+1)*(4*i+2)*(4*i+3)/6<=1000000;i++)q[i]=(4*i+1)*(4*i+2)*(4*i+3)/6;
	int N;
	while(cin>>N){
		cout<<f(N,N,0)<<" "<<g(N,N,0)<<endl;
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
#define all(a) a.begin(),a.end()
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    vector<int> dp(1000001,0);
    vector<int> dp2(1000001,0);
    iota(all(dp),0);
    iota(all(dp2),0);
    for(int i=2;(i*(i+1)*(i+2)/6)<=1000000;i++){
        int po=(i*(i+1)*(i+2)/6);
        for(int j=0;j+po<=1000000;j++){
            dp[j+po]=min(dp[j+po], dp[j]+1);
        }
        if(po%2==0)continue;
        for(int j=0;j+po<=1000000;j++){
            dp2[j+po]=min(dp2[j+po], dp2[j]+1);
        }
    }
    while(cin>>n,n){
        cout<<dp[n]<<" "<<dp2[n]<<endl;
    }
    return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <iterator>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(c) (c).begin(), (c).end()
const int N = 1000000;

template<typename T> inline void chmin(T& t, T f){if(t > f)t = f;}

vector<int> mem1, mem2;

void calc(vector<int>& v, vector<int>& mem){
    mem.assign(N, 0); iota(all(mem), 0);
    rep(i, N)for(int& j: v){
        if(i < j)break;
        chmin(mem[i], mem[i-j] + 1);
    }
}

void init(){
    vector<int> num, odd;
    for(int i=1, x=1; x<N; ++i, x=i*(i+1)*(i+2)/6)num.push_back(x);
    copy_if(all(num), back_inserter(odd), [](int x){return x&1;});
    calc(num, mem1); calc(odd, mem2);
}

int main(){
    init();
    for(int n; cin >> n, n; cout << mem1[n] << " " << mem2[n] << '\n');
    return 0;
}