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 <cstring>
#include <algorithm>
 
using namespace std;
 
const int SIZE = 181 + 1;
const int MAX = 1000000;
 
int T[SIZE];
int cost1[MAX], cost2[MAX];
 
int main( void )
{  
    for(int i=0; i < SIZE; ++i) T[i] = i * (i + 1) * (i + 2) / 6;
 
    fill(cost1, cost1+MAX, MAX);
    fill(cost2, cost2+MAX, MAX + MAX);
    cost1[0] = cost2[0] = 0;
    for(int i=0; i < MAX; ++i) {
        //if(cost1[i] < 6) {
            for(int j=0; j < SIZE; ++j) {
                int tj = T[j];
                if(i + tj < MAX && cost1[i] < 5)
                    cost1[i + tj] = min(cost1[i + tj], cost1[i] + 1);
                if((T[j] & 1) && (i + tj < MAX)) {
                        cost2[i + tj] = min(cost2[i + tj], cost2[i] + 1);
                }
            }
    }
    int n;
    while(cin >> n, n) {
        cout << cost1[n] << ' ' << cost2[n] << endl;
    }
    return 0;
}

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

const int INF = 1<<28;
int dp1[1000001];
int dp2[1000001];

int search(int n, int k){
	if(k == 0){
		if(dp1[n] != -1)
			return dp1[n];
	}
	else{
		if(k == 1){
			if(dp2[n] != -1)
				return dp2[n];
		}
	}
	
	if(n <= 0)
		return 0;
		
	int res = INF;
	for(int i = 1; i <= 1000000; ++i){
		int a = i * (i + 1) * (i + 2) / 6;
		if(a > n)
			break;
		if(k == 1 && a % 2 == 0)
			continue;
			
		if(k == 0)
			res = min(res, search(n - a, k) + 1);
		else
			res = min(res, search(n - a, k) + 1);
	}
	if(k == 0)
		return dp1[n] = res;
	else
		return dp2[n] = res;
}

int main() {
	memset(dp1, -1, sizeof(dp1));
	memset(dp2, -1, sizeof(dp2));
	
	for(int i = 1; i <= 1000000; ++i){
		search(i, 0);
		search(i, 1);
	}
	int n;
	while(cin >> n && n){
		cout << dp1[n] << " " << dp2[n] << endl;
	}
	return 0;
}

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

#define int long long
#define dotimes(i, n) for (int i : range(n))

using namespace std;

class range {
  class iterator {
    int i, s;
  public:
    iterator(int i, int s): i(i), s(s) {}
    int& operator*() {
      return i;
    }
    void operator++() {
      i += s;
    }
    bool operator!=(iterator const& that) {
      return i < that.i;
    }
  };
  iterator b, e;
public:
  range(int e): b({0, 1}), e({e, 1}) {}
  range(int b, int e): b({b, 1}), e({e, 1}) {}
  range(int b, int e, int s): b({b, s}), e({e, s}) {}
  iterator begin() {
    return b;
  }
  iterator end() {
    return e;
  }
};

int rint() {
  int n;
  scanf("%lld", &n);
  return n;
}

void wint(int n) {
  printf("%lld\n", n);
}

template<typename T>
inline int size(T container) {
  return static_cast<int>(container.size());
}

template<typename T>
inline bool maxs(T& a, T const& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template<typename T>
inline bool mins(T& a, T const& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

const int N = static_cast<int>(1e6);
int dp[N][2];

signed main() {
  vector<int> pollock;
  // skip n = 1
  for (int n = 2;; n++) {
    int p = n*(n+1)*(n+2)/6;
    if (p >= N)
      break;
    pollock.emplace_back(p);
  }
  dotimes(i, N) dotimes(j, 2)
    dp[i][j] = i;
  for (int p : pollock) {
    if (p % 2)
      dotimes(i, N - p) {
        mins(dp[p+i][0], dp[i][0] + 1);
        mins(dp[p+i][1], dp[i][1] + 1);
      }
    else
      dotimes(i, N - p)
        mins(dp[p+i][0], dp[i][0] + 1);
  }
  for (;;) {
    int x = rint();
    if (!x)
      break;
    printf("%lld %lld\n", dp[x][0], dp[x][1]);
  }
  return 0;
}

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

#define rep(i,a) for(int i = 0;i < (a); i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)
#define repd(i,a,b) for(int i = (a); i >= (b); i--)
#define repit(i,a) for(__typeof((a).begin()) i = (a).begin(); i != (a).end(); i++)
#define all(u) (u).begin(),(u).end()
#define rall(u) (u).rbegin(),(u).rend()
#define UNIQUE(u) (u).erase(unique(all(u)),(u).end())
#define pb push_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define PI acos(-1.0)

using namespace std;

typedef long long ll;
typedef vector<int> vi;

#define N 1000001

int dp[N], dp1[N];

void gen()
{
    memset(dp, 37, sizeof(dp));
    memset(dp1, 37, sizeof(dp1));
    dp[0] = dp1[0] = 0;

    for (int n = 1; ; ++n) {
        int p = n * (n + 1) * (n + 2) / 6;
        if (p >= N)
            break;
        for (int i = p; i < N; ++i) {
            dp[i] = min(dp[i], dp[i - p] + 1);
            if (p & 1)
                dp1[i] = min(dp1[i], dp1[i - p] + 1);
        }
    }
}

int main()
{
    gen();

    int t;
    while (cin >> t && t)
        cout << dp[t] << ' ' << dp1[t] << endl;

    return 0;
}