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 <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )

#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define DRANGE( c, p ) (c).begin(), (c).begin() + p, (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

int main()
{
	cin.tie( 0 );
	ios::sync_with_stdio( false );

	const int MAXN = 1000000;

	VI dpAll( MAXN, INT_MAX ), dpOdd( MAXN, INT_MAX );
	dpAll[0] = dpOdd[0] = 0;
	REP( i, 0, MAXN )
	{
		REP( j, 1, 1000001 )
		{
			const int s = j * ( j + 1 ) * ( j + 2 ) / 6;
			if ( MAXN <= i + s )
			{
				break;
			}

			dpAll[ i + s ] = min( dpAll[ i + s ], dpAll[i] + 1 );
			if ( s % 2 )
			{
				dpOdd[ i + s ] = min( dpOdd[ i + s ], dpOdd[i] + 1 );
			}
		}
	}

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

		if ( !n )
		{
			break;
		}

		cout << dpAll[n] << ' ' << dpOdd[n] << endl;
	}

	return 0;
}

C++: #include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;
// using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
///////////////////////////////////////////////

int dp[1001001], dp2[1001001];

int main() {
    int n;
    int inf = 1e6+10;
    vector<int> a(201);
    repf(i,1,201) {
        a[i] = i*(i+1)*(i+2)/6;
    }
    memset(dp, inf, sizeof(dp));
    memset(dp2, inf, sizeof(dp2));
    dp[0] = dp2[0] = 0;
        
    repf(i,1,201) rep(j,1e6+1) {
        int nj = j+a[i];
        if (nj > 1e6+1) continue;
        chmin(dp[nj] ,dp[j]+1);
        if (a[i]%2==1) chmin(dp2[nj] ,dp2[j]+1);
    }

    while (1) {
        cin >> n;
        if (n == 0) break;
        cout << dp[n] << ' ' << dp2[n] << endl;
    }
    return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

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

const long long MAX = 1100000;
const long long INF = 1LL << 60;
const long long mod = 1000000007LL;
//const long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

ll dp1[MAX];
ll dp2[MAX];
int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	vector<ll> all, odd;
	for (ll i = 1; i * (i + 1) * (i + 2) / 6 <= MAX; i++) {
		ll nx = i * (i + 1) * (i + 2) / 6;
		all.push_back(nx);
		if (nx & 1) odd.push_back(nx);
	}
	for (ll i = 0; i < MAX; i++) dp1[i] = INF, dp2[i] = INF;
	dp1[0] = 0;
	dp2[0] = 0;
	for (ll i = 0; i < MAX; i++) {
		for (ll e : all) {
			if (i + e < MAX) chmin(dp1[i + e], dp1[i] + 1);
		}
	}
	for (ll i = 0; i < MAX; i++) {
		for (ll e : odd) {
			if (i + e < MAX) chmin(dp2[i + e], dp2[i] + 1);
		}
	}
	while (1) {
		ll n; scanf("%lld", &n);
		if (n == 0) break;
		printf("%lld %lld\n", dp1[n], dp2[n]);
	}
	return 0;
}

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

#define MAX (1000000)
#define INF (1<<30)

int main() {
  
  int dp_all[MAX+2], dp_odd[MAX+2];
  
  fill(dp_all, dp_all+MAX+1, INF);
  fill(dp_odd, dp_odd+MAX+1, INF);
  
  dp_all[0] = dp_odd[0] = 0;
  
  for(int i=1; ; i++) {
    int num = i*(i+1)*(i+2) / 6;
    if(num > MAX) break;
    for(int j=num; j<=MAX; j++) {
      dp_all[j] = min(dp_all[j], dp_all[j-num]+1);
      if(num % 2)
	dp_odd[j] = min(dp_odd[j], dp_odd[j-num]+1);
    }
  }
  
  int n;
  while(cin >> n && n) {
    cout << dp_all[n] << " " << dp_odd[n] << endl;
  }
  
  return 0;
}