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;

int N;

typedef long long ll;

const int inf = 1e9;
const int maxN = 1000000;
int dp[maxN+1];

ll f(ll n) {
	return n * (n+1) * (n+2) / 6;
}

vector<int> makeS(int mod, int d) {
	vector<int> res;
	for (int n = 1; f(n) <= maxN; ++n) {
		if ( f(n) % mod == d ) {
			res.push_back( f(n) );
		}
	}
	return res;
}
int solve(const vector<int>& s) {
	fill(dp, dp+N+1, inf); dp[0] = 0;
	for (int i = 0; i < s.size(); ++i) {
		if (s[i] > N) break;
		for (int j = 0; j <= N; ++j) {
			int nj = j + s[i];
			if (nj <= N) {
				dp[nj] = min(dp[nj], dp[j]+1);
			}
		}
	}
	return dp[N];
}

int main() {
	vector<int> s0 = makeS(1, 0);
	vector<int> s1 = makeS(2, 1);
	while (cin >> N, N) {
		cout << solve(s0) << " " << solve(s1) << endl;
	}
}

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

int dp[2][1000001];

int f(int n)
{
    return n * (n + 1) * (n + 2) / 6;
}

int main()
{
    int n;
    for(int k = 0; k < 2; k++)
        fill(dp[k], dp[k] + 1000001, 1000000);
    
    dp[0][0] = dp[1][0] = 0;
    for(int i = 1; i <= n; i++) {
        for(int k = 1; ; k++) {
            int num = f(k);
            if(i - num >= 0) {
                dp[0][i] = min(dp[0][i], dp[0][i - num] + 1);
                if((num % 2) == 1) {
                    dp[1][i] = min(dp[1][i], dp[1][i - num] + 1);
                }
            } else {
                break;
            }
        }
    }
    
    while(cin >> n && n) {
        cout << dp[0][n] << " " << dp[1][n] << endl;
    }
}

C++: #include <bits/stdc++.h>
using namespace std;

typedef pair<long long int, long long int> PLL;

int main() {
	//vector<long long int>A( 1000001, LLONG_MAX / 6 ), B( 1000001, LLONG_MAX / 6 );
	vector<long long int>X, Y;
	for( size_t i = 1; i < 1000; i++ ) {
		long long int now = i*(i + 1)*(i + 2) / 6;
		X.push_back( now );
		if( now % 2 ) {
			Y.push_back( now );
			//cout << now << endl;
		}
	}
	long long int N;
	while( cin >> N, N ) {
		priority_queue<PLL, vector<PLL>, greater<PLL>>que, que2;
		que.push( make_pair( 0, N ) );
		set<PLL>SPLL;
		while( que.size() ) {
			auto now = que.top(); que.pop();
			if( now.second == 0 ) {
				cout << now.first << " ";
				break;
			}
			long long int i = 0;
			while( now.second >= X[i] ) {
				auto next = make_pair( now.first + 1, now.second - X[i] );
				if( SPLL.find( next ) == SPLL.end() ) {
					SPLL.insert( next );
					que.push( next );
				}
				i++;
			}
		}
		que = que2;
		que.push( make_pair( 0, N ) );
		SPLL.clear();
		while( que.size() ) {
			auto now = que.top(); que.pop();
			if( now.second == 0 ) {
				cout << now.first << endl;
				break;
			}
			long long int i = 0;
			while( now.second >= Y[i] ) {
				auto next = make_pair( now.first + 1, now.second - Y[i] );
				if( SPLL.find( next ) == SPLL.end() ) {
					SPLL.insert( next );
					que.push( next );
				}
				i++;
			}
		}
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
  int a[190]={0},b[60]={0},c[200001]={0,1,2,3},d[200001],k=0,i,j,n;
  for(i=1;i<100;i++){a[k++]=i*(i+1)*(i+2)/6;}
  for(j=k=0;j<i;j++){if(a[j]%2)b[k++]=a[j];}
  for(i=1;i<99;i++){for(j=a[i];j<a[i+1];j++)c[j]=c[j-a[i]]+1;}
  for(i=0;i<36;i++){d[i]=i;}
  for(i=1;i<k-2;i++){for(j=b[i];j<b[i+1];j++)d[j]=d[j-b[i]]+1;}
  while(cin>>n,n)cout<<c[n]<<' '<<d[n]<<endl;
}

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

int main(){
  const int N = 1000000;
  int dp1[N+1], dp2[N+1], n;
  
  for(int i=0;i<=N;i++)dp1[i] = dp2[i] = N;
  dp1[0] = dp2[0] = 0;
  
  int val = 1;
  for(int i=1;val<=N;i++){
    for(int j=0;j+val<=N;j++){
      int nxt = j+val;
      dp1[nxt] = min(dp1[nxt],dp1[j] + 1);
      if(val&1)dp2[nxt] = min(dp2[nxt],dp2[j] + 1);
    }
    val = i*(i+1)*(i+2)/6;
  }

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

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

int n, a[1000000];

void set() {
	for (int i = 0; i < 1000000; i++) {
		a[i] = 1;
		for (int j = 1; j <= 3; j++) {
			a[i] *= (i + j);
		}
		a[i] /= 6;
		if (a[i] > 1000000)break;
	}
}

int main() {
	set();

	while (true) {
		cin >> n;

		if (n == 0)break;

		int b;
		for (int i = 0; i < n; i++) {
			int c = 1;
			for (int j = 1; j <= 3; j++) {
				c *= (i + j);
			}
			c /= 6;
			//cout << "c:" << c << endl;
			if (c <= n) {
				b = i;
			}
			else {
				break;
			}
		}

		int sum1 = n, ans1 = 0, sum2 = n, ans2 = 0, sum3 = n, ans3 = 0;
		for (int i = b; i >= 0; i--) {
			//cout << "a[i]:" << a[i] << "i:" << i << endl;
			while (sum1 >= a[i]) {
				//cout << "sum1:" << sum1 << endl;
				sum1 -= a[i];
				ans1++;
			}

			if (i != b) {
				while (sum2 >= a[i]) {
					//cout << "sum2:" << sum2 << "a[i]:" << a[i] << "i:" << i << endl;
					sum2 -= a[i];
					ans2++;
				}
			}

			if (a[i] % 2 == 1) {
				while (sum3 >= a[i]) {
					sum3 -= a[i];
					ans3++;
				}
			}
		}

		cout << min(ans1, ans2) << " " << ans3 << endl;
	}
}