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>
using namespace std;
int main(){
  int a[200],b[200],c[1000001]={0,1,2,3},d[1000001],k=0,i,j,n;
  for(i=1;i<200;i++)a[k++]=i*(i+1)*(i+2)/6;
  for(j=k=0;j<i;j++)if(a[j]%2)b[k++]=a[j];
  for(i=1;i<195;i++)for(j=a[i];j<a[i+1];j++)c[j]=c[j-a[i]]+1;
  for(i=0;i<36;i++)d[i]=i;
  for(i=1;i<k-2;i++)for(j=b[i];j<b[i+1];j++)d[j]=d[j-b[i]]+1;
  while(cin>>n,n)cout<<c[n]<<' '<<d[n]<<endl;
}

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

const int INF = 1e+8;
// f[k] := k テ」ツつ津ヲツュツ」テ・ツ崢崚ゥツ敖「テ、ツスツ禿ヲツ閉ーテ」ツ?ョテ・ツ陳古」ツ?ィテ」ツ?療」ツ?ヲティツ。ツィテ」ツ?凖」ツ?淌」ツつ?」ツ?ォテ・ツソツ?ィツヲツ?」ツ?ェテヲツュツ」テ・ツ崢崚ゥツ敖「テ、ツスツ禿ヲツ閉ーテ」ツ?ョテ・ツ?凝ヲツ閉ーテ」ツ?ョテヲツ慊?・ツーツ湘・ツ?、
int f[1000001];
// g[k] := k テ」ツつ津・ツ・ツ?ヲツ閉ーテ」ツ?ョテヲツュツ」テ・ツ崢崚ゥツ敖「テ、ツスツ禿ヲツ閉ーテ」ツ?ョテ・ツ陳古」ツ?ィテ」ツ?療」ツ?ヲティツ。ツィテ」ツ?凖」ツ?淌」ツつ?」ツ?ォテ・ツソツ?ィツヲツ?」ツ?ェテ・ツ・ツ?ヲツ閉ーテ」ツ?ョテヲツュツ」テ・ツ崢崚ゥツ敖「テ、ツスツ禿ヲツ閉ーテ」ツ?ョテ・ツ?凝ヲツ閉ーテ」ツ?ョテヲツ慊?・ツーツ湘・ツ?、
int g[1000001];

int main(){
	fill(f, f + 1000001, INF);
	fill(g, g + 1000001, INF);
	vector<int> a, b;
	for(int i = 0 ; true ; i++ ){
		int k = i * (i + 1) * (i + 2) / 6;
		if( 1e+6 < k ) break;
		
		if( k % 2 == 1 ){
			b.push_back(k);
			g[k] = 1;
		}
		a.push_back(k);
		f[k] = 1;
	}
	for(int i = 0 ; i < 1000001 ; i++ ){
		if( f[i] ){
			for(int j = 0 ; j < a.size() ; j++ ){
				int k = i + a[j];
				if( 1e+6 < k ) break;
				f[k] = min(f[k], f[i] + 1);
			}
		}
		if( g[i] ){
			for(int j = 0 ; j < b.size() ; j++ ){
				int k = i + b[j];
				if( 1e+6 < k ) break;
				g[k] = min(g[k], g[i] + 1);
			}
		}
	}
	
	int N;
	while( cin >> N , N ){
		cout << f[N] << " " << g[N] << endl;
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
  int i,j,k,b[1000001],c[1000001],a[200],n;
  for(i=0;a[i-1]<1000000;i++)a[i]=i*(i+1)*(i+2)/6;
  for(j=0;j<=1000000;j++)b[j]=c[j]=j;
  for(j=2;j<i;j++)for(k=a[j];k<=1000000;k++){
    if(a[j+1]>b[k+1])break;
    b[k]=min(b[k],b[k-a[j]]+1);
    if(a[j]%2)c[k]=min(c[k],c[k-a[j]]+1);
  }
while(cin>>n,n)cout<<b[n]<<' '<<c[n]<<endl;
return 0;
}

C++: #include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

int N, M, K, Q, W, H, R, C;
vector<int> p;
vector<int> podd;
int dp[1100000], dp2[1100000];

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

    int id = 1;
    int v = id * (id + 1) * (id + 2) / 6;
    while (v < 1010000) {
        p.push_back(v);
        if (v % 2 == 1) podd.push_back(v);
        id++;
        v = id * (id + 1) * (id + 2) / 6;
    }

    REP(i, 1010000) { dp[i] = INF; }
    dp[0] = 0;
    REP(i, 1010000) {
        REP(j, (int)p.size()) {
            if (i - p[j] < 0) break;
            chmin(dp[i], dp[i - p[j]] + 1);
        }
    }

    REP(i, 1010000) { dp2[i] = INF; }
    dp2[0] = 0;
    REP(i, 1010000) {
        REP(j, (int)podd.size()) {
            if (i - podd[j] < 0) break;
            chmin(dp2[i], dp2[i - podd[j]] + 1);
        }
    }

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

C++: #include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 1e9
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int dp[1000010]={};
  int dp2[1000010]={};
  for(int i=1;i<=1000000;i++){dp[i]=INF;dp2[i]=INF;}
  vector<ll> gu;
  vector<ll> ki;
  ll cnt=1;
  while(1){
    if((cnt*(cnt+1)*(cnt+2)/6)>1000000)break;
    if(((cnt*(cnt+1)*(cnt+2))/6)%2){ki.pb(cnt*(cnt+1)*(cnt+2)/6);dp[ki[ki.size()-1]]=1;dp2[gu[gu.size()-1]]=1;}
    else {gu.pb(cnt*(cnt+1)*(cnt+2)/6);dp[gu[gu.size()-1]]=1;}
    cnt++;
  }
  dp[1]=1;
  dp2[1]=1;
  for(int i=1;i<1000000;i++){
    for(int j=0;j<gu.size();j++){
      if(i+gu[j]>1000000)break;
      dp[i+gu[j]]=min(dp[i+gu[j]],(dp[i]+1));
    }
    for(int j=0;j<ki.size();j++){
      if(i+ki[j]>1000000)break;
      dp[i+ki[j]]=min(dp[i+ki[j]],(dp[i]+1));
      dp2[i+ki[j]]=min(dp2[i+ki[j]],(dp2[i]+1));
    }
  }
  int n;
  while(cin>>n,n){
    cout<<dp[n]<<" "<<dp2[n]<<endl;
  }
  return 0;
}