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;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < (n); i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

// 素因数分解; 返り値は(素数, 乗数)のvector配列
vector<pair<ll, int>> factorize(ll n) {
	vector<pair<ll, int>> res;
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i) continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1) res.emplace_back(n, 1);
	return res;
}

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };
constexpr auto MAX = 100000;

// ──────────────────────────────────────────────────────────────────

int dp1[1000000];
int dp2[1000000];

int main() {
	vi a, b;

	int num = 1;
	int val = 1;
	while (val <= 1000000) {
		a.push_back(val);
		if (val % 2 == 1) b.push_back(val);
		val = num * (num + 1) * (num + 2) / 6;
		num++;
	}

	memset(dp1, inf, sizeof(dp1));
	memset(dp2, inf, sizeof(dp2));
	dp1[0] = dp2[0] = 0;

	Rep(i, 1000000) {
		rep(j, a.size()) {
			if (i >= a[j]) chmin(dp1[i], dp1[i - a[j]] + 1);
		}
	}
	Rep(i, 1000000) {
		rep(j, b.size()) {
			if (i >= b[j]) {
				chmin(dp2[i], dp2[i - b[j]] + 1);
			}
		}
	}

	while (true) {
		int n;
		cin >> n;

		if (!n) break;

		cout << dp1[n] << " " << dp2[n] << endl;
	}
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
vector <int> c;
vector <int> a,b;

int main() {


  c.push_back(0);
  for(int i=1;c[i-1]<=1000010;i++) c.push_back(i*(i+1)*(i+2)/6);
   
  for(int i=0;i<=1000000;i++) {
    a.push_back(i);
    b.push_back(i);
  }
  
  for(int i=0;i<c.size();i++) {
    for(int j=1;j<=1000000;j++) {
      
      if(j-c[i] >=0) { 
     
	if(a[j-c[i]] >= 0) a[j] = min(a[j], a[j-c[i]]+1);

	if(c[i] % 2 == 1 && b[j-c[i]] >0){
	  b[j] = min(b[j],b[j-c[i]]+1);
	}
      }
      
    }
  }

 while(1) {
    int m;
  cin >> m;
  if(m == 0) break;
  
  cout << a[m] <<" " << b[m] << endl;
  
  }
  return 0;
}

C++: # include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <numeric>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 10007;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);

int dp[1001000],dp2[1001000];
vector<int> pollock, pollock2;
int main() {
	for (int i = 1;; i++) {
		LL num = i*(i + 1)*(i + 2)/6;

		if (num > 1000000)break;

		if (num % 2 == 1)pollock2.emplace_back(num);
		pollock.emplace_back(num);
	}
	//cout << 1 << endl;
	for (int i = 0; i < 1000000; i++) {
		dp[i] = dp2[i] = i;
	}
	//cout << 2 << endl;
	for (int i = 1; i < pollock.size(); i++) {
		for (int j = pollock[i]; j <= 1000000; j++) {
			dp[j] = min(dp[j], dp[j - pollock[i]] + 1);
		}
	}
	//cout << 3 << endl;
	for (int i = 1; i < pollock2.size(); i++) {
		for (int j = pollock2[i]; j <= 1000000; j++) {
			dp2[j] = min(dp2[j], dp2[j - pollock2[i]] + 1);
		}
	}
	//cout << 4 << endl;
	int n;
	while (cin >> n&&n) {
		cout << dp[n] << " " << dp2[n] << endl;
	}
}