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>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll N;
vector <ll> All, Odd;
int C1[int(1e6 + 5)], C2[int(1e6 + 5)];
int Prepare(){
  ll cnt = 1, now = 1;
  while (now < 1e6){
    now = cnt * (cnt + 1) * (cnt + 2) / 6;
    All.push_back(now);
    if (now % 2 != 0) Odd.push_back(now);
    cnt++;
  }

  queue <int> que; que.push(0);
  while (!que.empty()){
    int Q = que.front(); que.pop();
    for (int i = 0; i < All.size(); i++){
      int num = Q + All[i];
      if (num > 1e6) break;
      if (C1[num] == 0){
        C1[num] = C1[Q] + 1; que.push(num);
      }
    }
  }
  que.push(0);
  while (!que.empty()){
    int Q = que.front(); que.pop();
    for (int i = 0; i < Odd.size(); i++){
      int num = Q + Odd[i];
      if (num > 1e6) break;
      if (C2[num] == 0){
        C2[num] = C2[Q] + 1; que.push(num);
      }
    }
  }
  return 0;
}


int main(){
  Prepare();
  while (cin >> N){
    if (N == 0) return 0;
    cout << C1[N] << " " << C2[N] << endl;
  }
  
  return 0;
}

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

int main() {
	
	int min0[1000000];
	int min1[1000000];
	fill(min0,min0+1000000,100);
	fill(min1,min1+1000000,100);

	for(int j=1;j<300;j++){
		int n = j*(j+1)*(j+2)/6;
		if( n>=1000000) break;
		min0[n] = 1;
		if((j%2)==1){
			min1[n] = 1;
		}
	}


	for(int i=1;i<1000000;i++)
	{
		for(int j=1;j<300;j++){
			int n = i + j*(j+1)*(j+2)/6;
			if( n>=1000000) break;
			min0[n] = min( min0[n], min0[i]+1);
			if( (j%2)==1){
				min1[n] = min( min1[n], min1[i]+1);
			}
		}
	}


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

	return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
#include <queue>
#include <stack>
 
using namespace std;
 
const int N=1e6;

int main()
{

	vector<int> t;
	t.push_back(1);
	for(int i=2;t.back()<=N;i++) t.push_back(i*(i+1)*(i+2)/6);

	vector<int> ans(N+1,N),ans2(N+1,N);

	ans[0]=ans2[0]=0;

	for(int i=0;i<N;i++){
//		cout<<i<<endl;
		for(int j=0;j<t.size() && i+t[j]<=N;j++){
			ans[i+t[j]]=min(ans[i+t[j]],ans[i]+1);
			if(t[j]%2) ans2[i+t[j]]=min(ans2[i+t[j]],ans2[i]+1);
		}
	}

//	cout<<"ok"<<endl;

	long long n;
	while(cin>>n,n){

		cout<<ans[n]<<" "<<ans2[n]<<endl;

	}


	return 0;
}

C++: #include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

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 T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int N = (int)1e6;

int main(void){
    vi sa, saodd;
    for(int a = 1, next; (next = a * (a + 1) * (a + 2) / 6) < N; a++){
        sa.pb(next);
        if(next % 2) saodd.pb(next);
    }

    vi dp(N, inf), dpodd(N, inf);
    dp[0] = 0; dpodd[0] = 0;
    rep(i, N){
        rep(j, sa.size()){
            if(N <= i + sa[j]) break;
            dp[i + sa[j]] = min(dp[i + sa[j]], dp[i] + 1);
        }
        rep(j, saodd.size()){
            if(N <= i + saodd[j]) break;
            dpodd[i + saodd[j]] = min(dpodd[i + saodd[j]], dpodd[i] + 1);
        }
    }

    for(int n; cin >> n, n; cout << dp[n] << " " << dpodd[n] << endl);

	return 0;
}