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=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=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 <bits/stdc++.h>
using namespace std;

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  vector<int> sime(181),kisi(46);
  for(int i=0;i<=180;i++){
    sime[i]=(i+1)*(i+2)*(i+3)/6;
  }
  for(int i=0;i<=45;i++){
    kisi[i]=(4*i+1)*(4*i+2)*(4*i+3)/6;
  }
  vector<int> ans(1000001,100000),kians(1000001,100000);
  ans[0]=0;
  for(int i=1;i<=1000000;i++){
    for(int j=0;j<=180;j++){
      if(i-sime[j]>=0){
        ans[i]=min(ans[i],ans[i-sime[j]]+1);
      }
    }
  }
  kians[0]=0;
  for(int i=1;i<=1000000;i++){
    for(int j=0;j<=45;j++){
      if(i-kisi[j]>=0){
        kians[i]=min(kians[i],kians[i-kisi[j]]+1);
      }
    }
  }
  while(1){
    int n;
    cin >> n;
    if(n==0) return 0;
    cout << ans[n] SP kians[n] << endl;
  }
  return 0;
}

C++: #define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to;
	ld cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	/*if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;*/
	return ((a.x + 1)*(a.y + 1)) < ((b.x + 1)*(b.y + 1));
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
ll fact(ll x, ll k, ll p) {//最大値、個数
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
 //#define int long long
const long long Inf = 4523372036854775807;
const int inf = 1500000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
int a[3000000];
int b[3000000];
vector<int>c;
signed main() {
	int x = 1;
	for (int i = 1; i < 2500000; i++) {
		a[i] = i;
		b[i] = i;
	}
	while (x*(x+1)*(x+2)/6<=1000000) {
		c.push_back(x*(x + 1)*(x + 2) / 6);
		x++;
	}
	for (int i = c.size() - 1; i >= 0; i--) {
		for (int j = 0; j <= 1000000; j++) {
			if (j + c[i] > 1000000) break;
			a[j + c[i]] = min(a[j] + 1, a[j + c[i]]);
			if (c[i] % 2 == 1) b[j + c[i]] = min(b[j] + 1, b[j + c[i]]);
		}
	}
	int n;
	while (cin >> n&&n) {
		cout << a[n] << " " << b[n] << endl;
	}
	getchar(); getchar();
}