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++: // #define USE_CPP11
// #define USE_PRINTF

#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <utility>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <complex>
#include <memory>
#include <sstream>

#ifdef USE_CPP11
#include <unordered_map>
#include <unordered_set>
#include <functional>
#endif

#define PRINT(obj) cout << obj << endl
#define REP(i, n) for(int (i) = 0; (i) < (n); i++)
#define SPACE " "

typedef long long ll;

using namespace std;

const int INF = 1e9;

namespace Scanner {
#ifdef USE_PRINTF
  int    nextInt()    { int    d; scanf("%d" , &d); return d; }
  float  nextFloat()  { float  f; scanf("%f" , &f); return f; }
  double nextDouble() { double f; scanf("%lf", &f); return f; }  
  string nextString() { string s; scanf("%s" , &s); return s; }
  ll     nextll()     { ll     l; scanf("%ll", &l); return l; }
#else
  int    nextInt()    { int    d; cin >> d; return d; }
  float  nextFloat()  { float  f; cin >> f; return f; }
  double nextDouble() { double f; cin >> f; return f; }  
  string nextString() { string s; cin >> s; return s; }
  ll     nextll()     { ll     l; cin >> l; return l; }
#endif

  string getLine() { 
    string input;
    getline(cin, input);
    return input;
  }
};

namespace myLibrary {
  vector<string> split(const string& str, char delim) {
    vector<string> ret;
    size_t current = 0, found;
    while ((found = str.find_first_of(delim, current)) != string::npos) {
      ret.push_back(string(str, current, found - current));
      current = found + 1;
    }
    ret.push_back(string(str, current, str.size() - current));
    return ret;
  }
  
#ifdef USE_CPP11
  ///
  /// higher-order functional
  /// This is something like map in haskell, python, etc.
  /// Sample usage:
  ///   vector<int> a = {1, 2, 3, 4, 5};
  ///   vector<int> b = myLibrary::_Map<int, int>(a, [](int n){
  ///     return n * n;
  ///   });
  /// Result:
  ///   b = 1, 4, 9, 16, 25
  ///
  template<typename T_IN, typename T_OUT, class Functor>
  vector<T_OUT> _Map(vector<T_IN> src, Functor func) {
    vector<T_OUT> ret;
    for (int i = 0; i < src.size(); i++) {
      ret.push_back(func(src[i]));
    }
    return ret;
  }
#endif

};

/// BEGIN //////////////////////////////////////////////////////////

int memo[(int)1e6 + 1];
int memo_odd[(int)1e6 + 1];

int solve(int n) {
  int ret = 0;
  int s_min = INF;
  if (n < 1) return memo[n] = 0;
  if (memo[n] > 0) return memo[n];
  for (int i = sqrt(n); i >= 1; i--) {
    int t = i * (i + 1) * (i + 2) / 6;
    if (t > n) continue;
    if (t == n) return memo[n] = 1;
    int s = solve(n - t);
    if (s == 0) continue;
    if (s < s_min) {
      s_min = s;
    } 
  }
  
  return memo[n] = (s_min + 1);
}

int solve_odd(int n) {
  int ret = 0;
  int s_min = INF;
  if (n < 1) return memo_odd[n] = 0;
  if (memo_odd[n] > 0) return memo_odd[n];
  for (int i = sqrt(n); i >= 1; i--) {
    int t = i * (i + 1) * (i + 2) / 6;
    if (t % 2 == 0) continue;
    if (t > n) continue;
    if (t == n) return memo_odd[n] = 1;
    int s = solve_odd(n - t);
    if (s == 0) continue;
    if (s < s_min) {
      s_min = s;
    } 
  }
  
  return memo_odd[n] = (s_min + 1);
}

void calc(int n) {
  cout << solve(n) << SPACE << solve_odd(n) << endl;
}

int main() {
  while (true) {
    int n = Scanner::nextInt();
    if (n == 0) break;
    calc(n);
  }
  return 0;
}

/// END   //////////////////////////////////////////////////////////

C++: #include <iostream>
#define REP(i, a, n) for(int i = (a); i <= (n); i++)
#define INF 100000000
using namespace std;

const int M = 1000000;
int N, base1[M + 1], base2[M + 2], dp1[M + 1], dp2[M + 1];

int dfs1(int n) {
  if(dp1[n] > 0) return dp1[n];
  if(base1[n]) return dp1[n] = 1;

  int ret = INF;
  REP(i, 1, n - 1) ret = min(ret, dfs1(i) + dfs1(n - i));
  return dp1[n] = ret;
}

int dfs2(int n) {
  if(dp2[n] > 0) return dp2[n];
  if(base2[n]) return dp2[n] = 1;

  int ret = INF;
  REP(i, 1, n - 1) ret = min(ret, dfs2(i) + dfs2(n - i));
  return dp2[n] = ret;
}

int main(void) {
  REP(i, 1, M) dp1[i] = dp2[i] = 0;
  for(int i = 1, n; n = i * (i + 1) * (i + 2) / 6, n <= M; i++) {
    base1[n] = 1;
    if(n % 2 == 1) base2[n] = 1;
  }

  while(cin >> N, N) {
    cout << dfs1(N) << " " << dfs2(N) << endl;
  }

  return 0;
}