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 <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>

using namespace std;

int limit = 1e6;

int memo(const int cur, vi &dp, const vi &list) {
  if (dp[cur] != limit)
    return dp[cur];
  for (const auto li : list) {
    if (cur - li >= 0) {
      dp[cur] = min(dp[cur], memo(cur - li, dp, list) + 1);
    }
  }
  return dp[cur];
}

int main() {
  vi list, oddList;
  for (int i = 1; i * (i + 1) * (i + 2) / 6 < limit; i++) {
    int num = i * (i + 1) * (i + 2) / 6;
    list.push_back(num);
    if (num % 2 == 1)
      oddList.push_back(num);
  }

  vi dp(1e6, limit), dpOdd(1e6, limit);
  dp[0] = dpOdd[0] = 0;
  FOR(i, 1, 1e6) {
    memo(i, dp, list);
    memo(i, dpOdd, oddList);
  }

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

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

const int INF = 2140000000;
int nums[1000000];
int nums_k[1000000];

int main(){
	int n;
	int p;
	queue<int> q, q_k;
	for(int i = 0; i < 1000000; i++){
		nums_k[i] = INF;
		nums[i] = INF;
	}
	for(int i = 0; i * (i+1) * (i+2) / 6 < 1000000; i++){
		int j = i*(i+1)*(i+2)/6;
		nums[j] = 1;
		q.push(j);
		if(j % 2 == 1){
			q_k.push(j);
			nums_k[j] = 1;
		}
	}
	while(!q.empty()){
		p = q.front();
		q.pop();
		for(int i = 1; i*(i+1)*(i+2)/6 < 1000000-p; i++){
			int j = i*(i+1)*(i+2)/6;
			if(nums[p+j] == INF){
				nums[p+j] = nums[p]+1;
				q.push(p+j);
			}
		}
	}
	while(!q_k.empty()){
		p = q_k.front();
		q_k.pop();
		for(int i = 1; i*(i*1)*(i+2)/6 < 1000000-p; i++){
			int j = i*(i+1)*(i+2)/6;
			if(j % 2 == 1 && nums_k[p+j] == INF){
				nums_k[p+j] = nums_k[p]+1;
				q_k.push(p+j);
			}
		}
	}
	while(cin >> n){
		if(n == 0) break;
		cout << nums[n] << " " << nums_k[n] << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;++i)
#define SZ(a) (int)((a).size())
#define mp make_pair
#define pb push_back
#define F first
#define S second
typedef pair<int,int> PI;
int dx[] = {0,1,0,-1};
int dy[] = {-1,0,1,0};


int dp[120000];
int odp[120000];
int n;
void solve(){
  
}

int main(){
  rep(i,120000) dp[i]=1<<28;
  rep(i,120000) odp[i]=1<<28;

  dp[0]=0;
  odp[0]=0;
  
  for(int i=1;;++i){
    int p = i*(i+1)*(i+2)/6;
    if(p>110000) break;
    //cout <<  i << endl;
    for(int j=0;j+p<120000;++j)
      dp[j+p]=min(dp[j+p],dp[j]+1);
    if(p&1)
      for(int j=0;j+p<120000;++j)
        odp[j+p]=min(odp[j+p],odp[j]+1);
      // for(int j=110000-p;j>=0;--j)
      //   odp[j+p]=min(odp[j+p],odp[j]+1);
  }
  
  //return 0;
  
  while(cin >> n,n) cout << dp[n] << " " << odp[n] << endl;
}

C++: #include "bits/stdc++.h"

#define int long long
#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define mod 1000000007
#define show(n) cerr<<#n<<" = "<<n<<endl
#define showp(n) cerr<<n.fs<<", "<<n.sc<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showsp(n) for(auto z:n){cerr<<z.fs<<" "<<z.sc<<", "}cerr<<endl

#define yes printf("Yes\n")
#define no printf("No\n")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

const int INF=1LL<<55;

int n;
int a[1000001],b[1000001];
int v;

void ume(){
    REP(i,1,1000001){
        a[i]=b[i]=i;
        for(int j=0;;j++){
            v=j*(j+1)*(j+2)/6;
            if(i-v<0) break;
            a[i]=min(a[i], a[i-v]+1);
            if(v&1) b[i]=min(b[i],b[i-v]+1);
        }
    }
}

void solve(){
    
    cout<<a[n]<<" "<<b[n]<<endl;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ume();
    while(cin>>n,n){
        solve();
    }

    return 0;
}