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 <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
//#include "h.h"
using namespace std;

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

int main(){

	vector<ll> TPN, TPN_ODD;

	//pre_calc
	int cnt = 1;
	do{
		TPN.pb(cnt * (cnt + 1) * (cnt + 2) / 6);
		if((cnt * (cnt + 1) * (cnt + 2) / 6)%2 == 1){
			TPN_ODD.pb(cnt * (cnt + 1) * (cnt + 2) / 6);
		}
		cnt ++;
	}while(cnt * (cnt + 1) * (cnt + 2) / 6 <= 1000000);
	int TPNSize = TPN.size(), TPN_ODDSize = TPN_ODD.size();

	//cout << "TPNSize = " << TPNSize << endl;
	//cout << "TPN_ODDSize = " << TPN_ODDSize << endl;

	vector<ll> V1(1000001), V2(1000001);
	V1[0] = 0;
	for(ll i = 1; i < 1000001; i ++){
		ll ret = 100;
		for(ll j = 0; j < TPNSize && TPN[j] <= i; j ++){
			ret = min(ret, 1 + V1[i - TPN[j]]);
		}
		V1[i] = ret;
	}
	V2[0] = 0;
	for(ll i = 1; i < 1000001; i ++){
		ll ret = 100;
		for(ll j = 0; j < TPN_ODDSize && TPN_ODD[j] <= i; j ++){
			ret = min(ret, 1 + V2[i - TPN_ODD[j]]);
		}
		V2[i] = ret;
	}

	//solve
	while(true){
		int N;
		cin >> N;
		if(N == 0)break;

		cout << V1[N] << " " << V2[N] << endl;
	}

	return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int ele[1000001];
int dp1[1000001];
int dp2[1000001];

int main() {
  rep(i, 181) ele[i] = (i + 1) * (i + 2) * (i + 3) / 6;
  vector<int> nn;
  while (1) {
    int n;
    cin >> n;
    if (n < 1) break;
    nn.push_back(n);
  }
  memset(dp1, 1, sizeof(dp1));
  memset(dp2, 1, sizeof(dp2));

  dp1[0] = 0;
  dp2[0] = 0;
  rep(i, 1000001) rep(j, 180) {
    if (i + ele[j] > 1000001) break;
    dp1[i + ele[j]] = min(dp1[i + ele[j]], dp1[i] + 1);
    if (ele[j] % 2 == 1) dp2[i + ele[j]] = min(dp2[i + ele[j]], dp2[i] + 1);
  }

  for (int n : nn) {
    printf("%d %d\n", dp1[n], dp2[n]);
  }
  return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define INF 1e9
#define rep(i,n) for(int i=0;i<n;i++)

int p[200],q[50],dp1[1000000],dp2[1000000],n;

int main(){
	rep(i,200)p[i]=(i+1)*(i+2)*(i+3)/6;
	rep(i,50)q[i]=(4*i+1)*(4*i+2)*(4*i+3)/6;
	for(int i=1;i<1e6;i++){
		dp1[i]=dp2[i]=INF;
		rep(j,200)if(p[j]<=i)dp1[i]=min(dp1[i],dp1[i-p[j]]+1);
		rep(j,50)if(q[j]<=i)dp2[i]=min(dp2[i],dp2[i-q[j]]+1);
	}
	while(cin>>n&&n){
		cout<<dp1[n]<<" "<<dp2[n]<<endl;
	}
}

C++: #define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
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 int MAX = 1000100;

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

  vector<int> dp(MAX, INF), odddp(MAX, INF);
  dp[0] = odddp[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[j] = min(dp[j], dp[j - num] + 1);
      if (num & 1) odddp[j] = min(odddp[j], odddp[j - num] + 1);
    }
  }

  int n;
  while (cin >> n) {
    if (n == 0) break;
    cout << dp[n] << " " << odddp[n] << "\n";
  }

  return 0;
}