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<algorithm>

using namespace std;

int N;
int dp[1000001], dpodd[1000001];

int main() {

	//前計算でdpテーブルを計算。8sもあるのでオーダーは怪しいけど大丈夫のはず

	for (int i = 0; i <= 1000000; i++)dp[i] = 1145141919, dpodd[i] = 1145141919;

	dp[0] = 0, dpodd[0] = 0;
	for (int i = 1; i <= 180; i++) {
		int cur = i * (i + 1) * (i + 2) / 6;
		for (int j = cur; j <= 1000000; j++) {
			if (i % 2 == 1) {
				dpodd[j] = min(dpodd[j], dpodd[j - cur] + 1);
			}

			dp[j] = min(dp[j], dp[j - cur] + 1);
		}
	}

	while (1) {
		cin >> N;
		if (N == 0)break;
		cout << dp[N] << " " << dpodd[N] << endl;
	}
	return 0;
}

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

using namespace std;

int main() {
	vector<int> data;
	vector<int> data2;
	vector<int> dp(1000001, 10);
	vector<int> dp2(1000001, 1000000);
	long long int n = 0;
	for (long long int i = 1; ; i++) {
		n = i*(i+1)*(i+2)/6;
		if (n > 1000000) {
			break;
		}
		data.push_back(n);
		dp[n] = 1;
		if (n % 2 == 1) {
			data2.push_back(n);
			dp2[n] = 1;
		}
	}

	for (int i = 0; i < data.size(); i++) {
		for (int j = data[i]+1; j <= 1000000; j++) {
			dp[j] = min(dp[j], dp[j-data[i]]+1);
		}
	}

	for (int i = 0; i < data2.size(); i++) {
		for (int j = data2[i]+1; j <= 1000000; j++) {
			dp2[j] = min(dp2[j], dp2[j-data2[i]]+1);
		}
	}

	int a;
	while (cin >> a) {

		if (a == 0) {
			break;
		}
		cout << dp[a] << ' ' << dp2[a] << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define MOD 1000000007
#define ALL(a) begin((a)),end((a))
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

vector<int> tri;
vector<int> b;
vector<int> a;
int ansa[1000005];
int ansb[1000005];

int main()
{
	tri.push_back(0);
	a.push_back(0);
	FOR(i, 1, 10000) tri.push_back(tri[i - 1] + i);
	FOR(i, 1, 10000)
	{
		a.push_back(a[i - 1] + tri[i]);
		if (a.back() & 1) b.push_back(a.back());
		if (a.back() > 1000001) break;
	}
	fill(ALL(ansa), INF);
	fill(ALL(ansb), INF);
	ansa[0] = ansb[0] = 0;
	REP(j, 1000001)
	{
		REP(i, a.size())
		{
			int t = j + a[i];
			if (t > 1000001) break;
			ansa[t] = min(ansa[t],ansa[j] + 1);
		}
	}
	REP(j, 1000001)
	{
		REP(i, b.size())
		{
			int t = j + b[i];
			if (t > 1000001) break;
			ansb[t] = min(ansb[t],ansb[j] + 1);
		}
	}


	int n;
	while (cin >> n, n)
	{
		cout << ansa[n] << " " << ansb[n] << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int n, dp[1000000], dp2[1000000];

void solve() {
  cout<<dp[n]<<" "<<dp2[n]<<endl;
}

int main (int argc, char const* argv[]) {
  memset(dp, -1, sizeof dp);
  memset(dp2, -1, sizeof dp2);
  
  dp[0] = dp2[0] = 0;
  for (int i = 1; i < 1000000; i += 1) {
    dp[i] = dp2[i] = i;
    for (int j = 1;; j += 1) {
      int s = j * (j + 1) * (j + 2) / 6;
      if (s > i) break;
      dp[i] = min(dp[i], dp[i - s] + 1);
      if (s % 2) {
        dp2[i] = min(dp2[i], dp2[i - s] + 1);
      }
    }
  }
  
  while (cin>>n, n) {
    solve();
  }
  return 0;
}