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 <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 200005
#define INF 1000000005LL

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
static const int N = 1000005;

int n;
ll K;
int dp[N],dpo[N];
ll pollock[N],oollock[N];
ll pmax,omax;
int cmax;
int a;

int pol()
{
	scanf("%d",&n);
	if(n==0)return -1;
	if(cmax>=n){
		a = dpo[n];
		return dp[n];
	}
	while(pollock[pmax]<=n){
		pmax++;
		pollock[pmax] = pmax*(pmax+1)*(pmax+2)/6;
		if(pollock[pmax]%2==1){
			omax++;
			oollock[omax]=pollock[pmax];
		}
	}
	int k=1,j=1,s=1,f=1;
	for(int i=cmax+1;i<=n;i++){
		while(pollock[j]<=i)j++;
		int minv = 9;
		for(int c=(j-10>0?j-10:1);c<j;c++){
			minv = min(minv,dp[i-pollock[c]]+1);
		}
		dp[i] = minv;

		while(oollock[k]<=i&&k<=omax){
			k++;
		}
		minv = 99;
		int c;
		for(c=(k-10>0?1:1);c<k;c++){
			minv = min(minv,dpo[i-oollock[c]]+1);
		}
		dpo[i] = minv;
		//printf("(%d:%d)",i,k);
	}
	cmax=n;
	a = dpo[n];
	return dp[n];
}
int main(){
	pmax=0;
	cmax=omax=0;
	dp[0]=0;
	dpo[0]=0;
	pollock[0]=oollock[0]=0;
	while(1){
		int p = pol();
		if(p==-1)return 0;
		printf("%d %d\n",p,a);
	}
}

C++: #include <stdio.h>
#define INF 0x7FFFFFFF

int main(void){
	int i, j, n, min1,small;
	int dp[1000000];
	scanf("%d",&n);
	while(n != 0){
		for(i = 0;i <= n;i++)
			dp[i] = INF;
		dp[0] = 0;
		small = INF;
		for(i = 0;i < n;i++){
			if(dp[i] < small){
				for(j = 1;(j * (j + 1) * (j + 2)) / 6 + i <= n;j++){
					if(dp[(j * (j + 1) * (j + 2)) / 6 + i] > dp[i] + 1)
						dp[(j * (j + 1) * (j + 2)) / 6 + i] = dp[i] + 1;
				}
			}
			if(small > dp[n])
				small = dp[n];
		}

		min1 = dp[n];
		for(i = 0;i <= n;i++)
			dp[i] = INF;
		dp[0] = 0;
		small = INF;
		for(i = 0;i < n;i++){
			if(dp[i] < small){
				for(j = 1;(j * (j + 1) * (j + 2)) / 6 + i <= n;j++){
					if(dp[(j * (j + 1) * (j + 2)) / 6 + i] > dp[i] + 1 && j * (j + 1) * (j + 2) / 6 % 2 == 1)
						dp[(j * (j + 1) * (j + 2)) / 6 + i] = dp[i] + 1;
				}
			}
			if(small > dp[n])
				small = dp[n];
		}
		printf("%d %d\n",min1,dp[n]);
		scanf("%d",&n);
	}
	return 0;
}

C++: #include<stdio.h>
#define N 1000000

int all[N+1],odd[N+1];
int pollock[1000];
int num;

int BackTrack(int n,int type){
  int i,tmp,ans = N+1;
  if(type && odd[n]<=N)return odd[n];
  if(!type && all[n]<=N)return all[n];
  //if(n==0)return 0;

  for(i=num-1;i>=0;i--){
    //printf("%d\n",pollock[i]);
    if(pollock[i]>n)continue;
    if(type && !(pollock[i]&1) )continue;
    tmp = BackTrack(n-pollock[i],type);
    if(ans > tmp+1)ans = tmp+1;
  }

  if(type)odd[n] = ans;
  if(!type)all[n] = ans;
  return ans;
}

int main(){
  int i,n,tmp;

  for(i=0;i<=N;i++)all[i] = odd[i] = N+1;
  all[0] = odd[0] = 0;

  for(num=1;;num++){
    tmp = num*(num+1)*(num+2)/6;
    if(tmp>N)break;
    pollock[num-1] = tmp;
  }
  num--;
  while(scanf("%d",&n) && n){
    printf("%d %d\n",BackTrack(n,0),BackTrack(n,1));
  }
  return 0;
}

C++: /*
 * aoj/1167_2nd/main.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>

using namespace std;

#define ll long long

#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

const ll MAX_N = 1000100;
ll N;
ll P[180];
ll dp[MAX_N];
ll dp_odd[MAX_N];

void build() {
  for (int n=1; n<=180; n++) {
    P[n-1] = n * (n+1) * (n+2) / 6;
  }
}


bool input() {
  cin >> N;
  if (N==0) return false;
  return true;
}

void receive() {
  for (ll n=1; n<MAX_N; n++) {
    for (int i=0; i<180; i++) {
      if (i==0) { dp[n] = n; dp_odd[n] = n; continue; } // P[i] = 1 (奇数)
      if (n-P[i]>=0) chmin(dp[n], dp[n-P[i]] + 1);
      if (n-P[i]>=0 and P[i] % 2 == 1) chmin(dp_odd[n], dp_odd[n-P[i]] + 1);
    }
  }
}

void solve() {
  cout << dp[N] << " " << dp_odd[N] << endl;
}

int main() {
  // cout.precision(15);
  build();
  receive();
  while (input()) solve();
  return 0;
}