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>
using namespace std;
const int dx[]={0,1,0,-1,1,-1,-1,1};
const int dy[]={-1,0,1,0,1,1,-1,-1};
const int INF = 1<<30;
const int EPS = 1e-8;
#define PB push_back
#define mk make_pair
#define fi first
#define se second
#define ll long long
#define reps(i,j,k) for(int i = (j); i < (k); i++)
#define rep(i,j) reps(i,0,j)
#define MOD 1000000007
typedef pair<int,int> Pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
int dp[1000010][2];
int data[1000010];
int main(){
	int index=1;
	while(index*(index+1)*(index+2)/6 < 10000000){
		data[index-1] = index*(index+1)*(index+2)/6;
		index++;
	}
	fill(dp[0],dp[0]+1000000,INF);
	fill(dp[1],dp[1]+1000000,INF);
	dp[0][0] = dp[0][1] = 0;
	rep(i,1000000){
		rep(j,index){
			if(i+data[j] < 1000000){
				dp[i+data[j]][0] = min(dp[i+data[j]][0],dp[i][0]+1);
				if(data[j] % 2 == 1){
					dp[i+data[j]][1] = min(dp[i+data[j]][1],dp[i][1]+1);
				}
			}
		}
	}

	int N;

	while(scanf("%d",&N),N){
		printf("%d %d\n",dp[N][0],dp[N][1]);
	}
	return 0;
}

C++: #include <bits/stdc++.h>

int ans1[1048576];
int ans2[1048576];
std::vector<int> num34;
std::vector<int> numodd4;

int main(int argc, char *argv[]) {

  // step 1
  for(int i = 1; ; ++i) {
    int t = i * (i + 1) / 2;
    if( t >= 1048576 ) break;
    num34.push_back(t);
  }
  for(int i = 1; ; ++i) {
    int t = i * (i + 1) * (i + 2) / 6;
    if( t >= 1048576 ) break;
    num34.push_back(t);
    if( t % 2 == 1 ) numodd4.push_back(t);
  }
  std::sort(std::begin(num34), std::end(num34));
  std::sort(std::begin(numodd4), std::end(numodd4));
  num34.erase(std::unique(std::begin(num34), std::end(num34)), std::end(num34));
  numodd4.erase(std::unique(std::begin(numodd4), std::end(numodd4)), std::end(numodd4));

  // step 2
  for(int i = 1; i < 1048576; ++i) {
    int min = 1048576;
    for(int dx : num34) {
      int previ = i - dx;
      if( previ < 0 ) break;
      min = std::min(min, ans1[previ] + 1);
    }
    ans1[i] = min;
  }

  // step 3
  ans2[0] = 0;
  for(int i = 1; i < 1048576; ++i) {
    int min = 1048576;
    for(int dx : numodd4) {
      int previ = i - dx;
      if( previ < 0 ) break;
      min = std::min(min, ans2[previ] + 1);
    }
    ans2[i] = min;
  }

  // step 4
  for(;;) {
    int N;
    scanf("%d", &N);
    if( N == 0 ) break;
    printf("%d %d\n", ans1[N], ans2[N]);
  }
  
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <utility>
#define N 1000000

using namespace std;

int main(){
	vector<int> sq;
	vector<int> sqodd;
	int a[N];
	int aodd[N];
	for(int i = 1; i * (i + 1) * (i + 2) <= N; i++)  sq.push_back((i * (i + 1) * (i + 2)) / 6);
	for(int i = 1; i * (i + 1) * (i + 2) <= N; i++){
		if(((i * (i + 1) * (i + 2)) / 6) % 2)
		 	sqodd.push_back((i * (i + 1) * (i + 2)) / 6);
	}
	for(int i = 0; i < N; i++) a[i] = N;
	for(int i = 0; i < N; i++) aodd[i] = N;
	for(int i = 0; i < sq.size(); i++) a[sq[i]] = 1;
	for(int i = 0; i < sqodd.size(); i++) aodd[sqodd[i]] = 1;
	for(int i = 1; i < N; i++){
		if(a[i] == N) continue;
		for(int j = 0; j < sq.size(); j++){
			if(sq[j] + i < N && a[sq[j] + i] > a[i] + 1) a[sq[j] + i] = a[i] + 1;
		}
	}
	for(int i = 1; i < N; i++){
		if(aodd[i] == N) continue;
		for(int j = 0; j < sqodd.size(); j++){
			if(sqodd[j] + i < N && aodd[sqodd[j] + i] > aodd[i] + 1) aodd[sqodd[j] + i] = aodd[i] + 1;
		}
	}	
	int n;
	while(cin >> n, n){
		cout << a[n] << " " << aodd[n] << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int dp1[1000010],dp2[1000010];

int main() {
    vector<int> c,d;
    int x=1;
    while((x*(x+1)*(x+2))/6<1000010){
        int y=(x*(x+1)*(x+2))/6;
        c.push_back(y);
        if(y%2==1) d.push_back(y);
        x++;
    }

    //rep(i,10) cout<<d[i]<<endl;
    
    rep(i,1000010){
        dp1[i]=INF;
        dp2[i]=INF;
    }
    dp1[0]=0;
    dp2[0]=0;
    rep(i,1000010){
        rep(j,c.size()){
            if(i+c[j]<1000010) dp1[i+c[j]]=min(dp1[i+c[j]],dp1[i]+1);
        }

        rep(j,d.size()){
            if(i+d[j]<1000010) dp2[i+d[j]]=min(dp2[i+d[j]],dp2[i]+1);
        }
    }

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

    return 0;
}