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 <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

int a[1010101];
int b[1010101];

int main(){
	fill(a ,a + 1010101,1e9);
	fill(b,b + 1010101,1e9);
	a[0] = 0;
	b[0] = 0;

	int MAX = 1e6;

	for(int i = 1;i <= MAX;i++){
		int temp;
		for(int j = 1;(temp = (j) * (j + 1) * (j + 2) / 6) <= i;j++){
			a[i] = min(a[i] , a[i - temp] + 1);
			if(temp % 2 == 1)
				b[i] = min(b[i] , b[i - temp] + 1);
		}
	}

	int n;
	while(cin >> n , n){
		cout << a[n] << " " << b[n] << endl;
	}
}

C++: #include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

int main() {
	vi three;
	int num = 1, tmp = 0;
	while(tmp <= 100000) {
		tmp += num;
		three.push_back(tmp);
		num++;
	}

	vi four;
	tmp = 0;
	int pos = 0;
	while(tmp <= 100000) {
		tmp += three[pos];
		four.push_back(tmp);
		pos++;
	}
	int fsize = four.size();

	int n;
	while(cin >> n, n) {
		vi dp(n+1, INF);
		vi dpk(n+1, INF);
		dp[0] = dpk[0] = 0;

		FOR(i, 1, n) {
			REP(j, fsize) {
				if(i-four[j] >= 0) {
					dp[i] = min(dp[i-four[j]]+1, dp[i]);
				} else {
					break;
				}
			}
		}

		FOR(i, 1, n) {
			REP(j, fsize) {
				if(i-four[j] >= 0) {
					if(four[j]%2) {
						dpk[i] = min(dpk[i-four[j]]+1, dpk[i]);
					}
				} else {
					break;
				}
			}
		}

		cout << dp[n] << " " << dpk[n] << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>

using namespace std;

using ll = long long;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define input(...) __VA_ARGS__; in(__VA_ARGS__)

template<class T>
void print(vector<T> a) {
  cout << "[ ";
  REP(i, a.size()) cout << a[i] << " ";
  cout << "]" << endl;
}

void print() {
  std::cout << std::endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...);
}

void in() { }

template <class Head, class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(std::forward<Tail>(tail)...);
}

ll n;

vector<ll> fvalues;
vector<ll> fvalues2;
ll f(ll x) {
  return x * (x + 1) * (x + 2) / 6;
}

vector<ll> table;
ll dfs(ll x) {
  if (table[x] != -1) return table[x];
  if (x == 0) return 0;

  ll minv = numeric_limits<ll>::max() / 2;

  for (ll i = fvalues.size() - 1; i >= 0; i -= 1) {
    ll value = fvalues[i];
    if (x - value >= 0) {
      minv = min(minv, dfs(x - value) + 1);
    }
  }
  return table[x] = minv;
}

vector<ll> table2;
ll dfs2(ll x) {
  if (table2[x] != -1) return table2[x];
  if (x == 0) return 0;

  ll minv = numeric_limits<ll>::max() / 2;

  for (ll i = fvalues2.size() - 1; i >= 0; i -= 1) {
    ll value = fvalues2[i];
    if (x - value >= 0) {
      minv = min(minv, dfs2(x - value) + 1);
    }
  }
  return table2[x] = minv;
}

bool solve() {
  cin >> n;
  if (n == 0) return false;

  cout << dfs(n) << " " << dfs2(n) << endl;

  return true;
}

int main() {
  ll M = 1000000;
  for (ll i = 1;; i++) {
    ll value = f(i);
    fvalues.push_back(value);
    if (value % 2 == 1) fvalues2.push_back(value);
    if (value > M) break;
  }

  table = vector<ll>(M + 1, -1);
  table2 = vector<ll>(M + 1, -1);
  while (solve());
}