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>
using namespace std;
int main(void){
    int i;
    int n;
    int j = 0;
    int a[84];
    int b[22];
    long long t[1000010];
    for(i = 0; i < 83; i++){
        a[i] = (i+1)*(i+2)*(i+3)/6;
        if(a[i] % 2 == 1){
            b[j] = a[i];
            j++;
        }
    }
    //cout << a[82] << b[20] << endl;
    /*for(i = 0; i < 83; i++){
        cout << "a[i] = " << a[i] << endl;
    }
    for(i = 0; i < 21; i++){
        cout << "b[i] = " << b[i] << endl;
    }*/
    while(1){
        cin >> n;
        if(n == 0){
            break;
        }
        for(i = 0; i <= n; i++){
            t[i] = i;
        }
        for(i = 0; i <= 82; i++){
            for(j = a[i]; j <= n; j++){
                if(t[j] > t[j - a[i]] + 1){
                    t[j] = t[j -a[i]] + 1;
                }
            }
        }
        cout << t[n] << " ";

        for(i = 0; i <= n; i++){
            t[i] = i;
        }
        for(i = 0; i <= 20; i++){
            for(j = b[i]; j <= n; j++){
                if(t[j] > t[j - b[i]] + 1){
                    t[j] = t[j - b[i]] + 1;
                }
            }
        }
        cout << t[n] << endl;
    }
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define print(a) cout<<a<<endl;
int aaa[200] = {}, bbb[200] = {}, counta=1,countb=1,xxx[1100000] = {}, yyy[1100000] = {};

int foo(int n, int x){
	int mi = 1000000;
	if(xxx[n]) return xxx[n]+x;
	if(x > 5) return mi;
	for(int i = counta-1; i >= 1; i--){
		if(aaa[i] < n){
			mi = min(foo(n-aaa[i],x+1), mi);
			if(mi - n == 1)break;
		}
	}
	
	xxx[n] = mi;
	return mi;
}
int boo(int n, int x){
	int mi = 1000000;
	if(yyy[n]) return yyy[n]+x;
	for(int i = countb-1; i >= 1; i--){
		if(bbb[i] < n){
			mi = min(boo(n-bbb[i],x+1), mi);
			if(mi - n == 1)break;
		}
	}
	yyy[n] = mi;
	return mi;
}

int main(){
	int i, n, abc;
	for(i = 1; abc <= 1000000; i++){
		abc = (i*(i+1)*(i+2))/6;
		xxx[abc] = 1;
		if(abc%2){
			yyy[abc] = 1;
			bbb[countb++] = abc;
		}
		aaa[counta++] = abc;
	}
	for(i = 1; i <= 1000000; i++){
		xxx[i] = foo(i, 0);
		yyy[i] = boo(i, 0);
	}
	while(1){
		cin>>n;
		if(n == 0) break;
		cout<<xxx[n]<<" "<<yyy[n]<<endl;
	}
	return 0;
}

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

using namespace std;

int dp1[1000500];
int dp2[1000500];

int main(void)
{
	vector <int> data;
	int n = 1;
	while (1){
		int tmp = n * (n + 1) * (n + 2) / 6;
		if (1000000 < tmp) break;
		data.push_back(tmp);
		n++;
	}
	fill(dp1, dp1 + 1000500, 99999);
	fill(dp2, dp2 + 1000500, 99999);
	dp1[0] = dp2[0] = 0;
	for (int i = 0; i < 1000500; i++){
		for (int j = 0; j < data.size(); j++){
			if (1000500 < i + data[j]) break;
			dp1[i + data[j]] = min(dp1[i + data[j]], dp1[i] + 1);
		}
	}
	for (int i = 0; i < 1000500; i++){
		for (int j = 0; j < data.size(); j++){
			if (1000000 < i + data[j]) break;
			if (data[j] % 2 == 1) dp2[i + data[j]] = min(dp2[i + data[j]], dp2[i] + 1);
		}
	}

	while (cin >> n, n){
		cout << dp1[n] << " " << dp2[n] << endl;
	}

	return 0;
}

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

vector<int> n;
void mkn(){
  n.push_back(1);
  for(int i=2;n[i-2]<1005000;i++){
    n.push_back(i*(i+1)*(i+2)/6);
  }
}


vector<int> dp;
vector<int> dp2;
void mktable(){
  dp.resize(1000100);
  dp2.resize(1000100);
  for(int i=0;i<dp.size();i++){
    dp[i]=1000100;
    dp2[i]=1000100;
  }
  dp[0]=dp2[0]=0;
  for(int i=0;i<n.size();i++){
    for(int j=0;j<dp.size();j++){
      if(n[i]%2==1){
        if(j-n[i]>=0){
          dp2[j]=min(dp2[j],dp2[j-n[i]]+1);
        }else{
          dp2[j]=dp2[j];
        }
      }
      if(j-n[i]>=0){
        dp[j]=min(dp[j],dp[j-n[i]]+1);
      }else{
        dp[j]=dp[j];
      }
    }
  }
}

void init(){
  n.clear();
  dp.clear();
  mkn();
  mktable();
}

bool solve(){
  int a;
  cin>>a;
  if(a==0){
    return false;
  }
  cout<<dp[a]<<" "<<dp2[a]<<endl;
  return true;
}
int main(){
  init();
  while(solve());
}

C++: 
#include <iostream>
#include <string>
#include <algorithm>
#include <list>
#include <set>
#define foreach(t,p) for(t::iterator it=p.begin();it!=p.end();++it)
#define rforeach(t,p) for(t::reverse_iterator it=p.rbegin();it!=p.rend();++it)
using namespace std;
#define REP(n) for(int i=0;i<n;i++)
#define N 1000001
#define POL 180
int pol[POL];
int pol2[POL];
int dp1[N];
int dp2[N];
int num;

void solve1() {
    REP(N) dp1[i] = N;
    dp1[0] = 0;
        for(int k=0;k<N;k++) {
                for(int j=0;j<POL;j++) 
                    if(k+pol[j] <=N)
                        dp1[k+pol[j] ] = min(dp1[k+pol[j]],dp1[k]+1);
        }
}

void solve2() {
    REP(N) dp2[i] = N;
    dp2[0] = 0;
    for(int i=0;i<N;i++) {
          //                cout << i << " "  << " " << dp2[i] << endl;
            for(int j=0;j<num;j++) {
                if(i+pol2[j] <= N) {
                    dp2[i+pol2[j] ] = min(dp2[i+pol2[j]],dp2[i]+1);
                }
            }
    }
}

int main() {
    num = 0;
    REP(POL){
        pol[i] = (i+1)*(i+2)*(i+3)/6;
        if(pol[i]%2 == 1) pol2[num++] = pol[i];
    }
    solve1();
    solve2();
//    REP(30) cout << dp1[i];
    int q;
    while(cin >> q && q) {
        cout << dp1[q] << " " << dp2[q] << endl;
    }

    return 0;
}