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>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define P pair<int, int>
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
//#define int long long
const int N = 1e6 + 10;
const int INF = 1e9 + 10;

int main() {
  vector<int> v, vv;
  for(int i = 1; i * (i + 1) * (i + 2) / 6 < N; ++i) v.push_back(i * (i + 1) * (i + 2) / 6);
  REP(i, v.size()) if(v[i] % 2) vv.push_back(v[i]);
  vector<int> dp(N, INF), dp_odd(N, INF);
  dp[0] = dp_odd[0] = 0;
  REP(i, v.size()) for(int j = v[i]; j < N; ++j) dp[j] = min(dp[j], dp[j - v[i]] + 1);
  REP(i, vv.size()) for(int j = vv[i]; j < N; ++j) dp_odd[j] = min(dp_odd[j], dp_odd[j - vv[i]] + 1);
  int n;
  while(cin >>n && n) cout <<dp[n] <<" " <<dp_odd[n] <<endl;
  return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using pii = pair<int, int>;

template<class T> inline bool chmax(T &a, T b) {
	if (a < b) { a = b; return true; }
	return false;
}

template<class T> inline bool chmin(T &a, T b) {
	if (a > b) { a = b; return true; }
	return false;
}

const int INF = 1e8;

int main() {
	vector<int> v;
	for (int i = 1; ; i++) {
		int t = (i * (i + 1) * (i + 2)) / 6;
		if (t >= 1e6) break;
		v.push_back(t);
	}
	vector<int> dp1(1000005, INF);
	vector<int> dp2(1000005, INF);
	dp1[0] = 0;
	dp2[0] = 0;
	rep(i, 1000005) {
		rep(j, (int)v.size()) {
			if (i < v[j]) continue;
			chmin(dp1[i], dp1[i - v[j]] + 1);
			if (v[j] % 2 == 1) chmin(dp2[i], dp2[i - v[j]] + 1); 
		}
	}
	int n;
	while (cin >> n) {
		if (n == 0) break;
		cout << dp1[n] << " " << dp2[n] << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<cstring>
#define INF 1<<28
using namespace std;

int p[1111111];
int memo[1111111];
int memo2[1111111];

int solve(int n){
  
  if(!n) return 0;
  if(~memo[n]) return memo[n];

  int ans = INF;
  for(int i=199;i>0;i--) if(n >= p[i]) ans = min(ans, solve(n-p[i])+1);
  
  return memo[n] = ans;
}

int solve2(int n){
  
  if(!n) return 0;
  if(~memo2[n]) return memo2[n];

  int ans = INF;
  for(int i=0;p[i]<=n;i++) if(p[i]&1) ans = min(ans, solve2(n-p[i])+1);

  return memo2[n] = ans;
}

int main(){
  
  int n;
  
  memset(memo, -1, sizeof(memo));
  memset(memo2, -1, sizeof(memo2));

  for(int i=0;i<200;i++) p[i] = i*(i+1)*(i+2)/6;
  while(cin >> n, n) cout << solve(n) << " " << solve2(n) << endl;

}

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

using ll = long long;
#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define INF 1e9
// const ll INF = 1LL << 60;

int cal(int n){
  return n*(n+1)*(n+2)/6;
}
constexpr int maxd = 1e6+10;
int dp[maxd], dp2[maxd];
int main(){
  vector<int> P;
  int p;
  for(int i = 1; (p=cal(i)) <= 1e6; i++){
    P.push_back(p);
  }
  REP(i, maxd){
    dp[i] = dp2[i] = INF;
  }
  dp[0] = 0;
  dp2[0] = 0;
  REP(i, P.size()){
    int a = P[i];
    REP(j, 1e6){
      if(j+a > 1e6) continue;
      dp[j+a] = min(dp[j+a], dp[j]+1);
      if(a % 2){
        dp2[j+a] = min(dp2[j+a], dp2[j]+1); 
      }
    }
  }
  while(true){
    int n;
    cin >> n;
    if(n == 0) break;
    cout << dp[n] << " " << dp2[n] << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(b);i>=(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
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;}

#define MAX 1000000
void solve(){
    vl a,b;
    ll v1=0,v2=0,v3=0;
    while(1){
        v1++;
        v2+=v1;
        v3+=v2;
        if(v3>MAX)break;
        a.push_back(v3);
        if(v3%2)b.push_back(v3);
    }
    reverse(all(a));
    reverse(all(b));

    vl dpA(MAX+1,LINF);
    dpA[0]=0;
    rep(i,a.size()){
        fore(j,a[i],MAX)chmin(dpA[j],dpA[j-a[i]]+1);
    }
    vl dpB(MAX+1,LINF);
    dpB[0]=0;
    rep(i,b.size()){
        fore(j,b[i],MAX)chmin(dpB[j],dpB[j-b[i]]+1);
    }
    
    while(1){
        ll n;cin>>n;
        if(n==0)return;
        cout<<dpA[n]<<" "<<dpB[n]<<endl;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    solve();
}