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 <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>
#include <stack>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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; }

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

const ll MAX_N = 1000005;
// const ll MAX_N = 200;

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  vector<ll> table(205); // table[n] .. n(n+1)(n+2)/6
  rep(i,205) {
    table[i] = i*(i+1)*(i+2)/6;
  }
  // dp[i] .. min count to represent i.
  vector<ll> dp(MAX_N, INF);
  dp[0] = 0;
  dp[1] = 1;
  rep(i,MAX_N) {
    rep(j,205) {
      if (table[j] > i) { break; }
      assert(i-table[j] >= 0);
      chmin(dp[i], dp[i-table[j]] + 1);
    }
  }
  // printvec(dp);

  // dp2[i] .. min count to represent i when using only odd.
  vector<ll> dp2(MAX_N, INF);
  dp2[0] = 0;
  rep(i,MAX_N) {
    rep(j,205) {
      if (table[j] > i) { break; }
      assert(i-table[j] >= 0);
      if (table[j]%2 == 0) { continue; } // even
      chmin(dp2[i], dp2[i-table[j]] + 1);
      // cout << "j:" << j << endl;
      // cout << "table[j]:" << table[j] << endl;
      // cout << "i:" << i << endl;
      // cout << "dp2[i]:" << dp2[i] << endl;
      // cout << "dp2[i-table[i]]:" << dp2[i-table[j]] << endl;
    }
  }

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

C++: #include <bits/stdc++.h>
using namespace std;
int INF = 1000000;
int main(){
  vector<int> dp1(1000000, INF);
  vector<int> dp2(1000000, INF);
  dp1[0] = 0;
  dp2[0] = 0;
  for (int i = 1; i * (i + 1) * (i + 2) / 6 <= 1000000; i++){
    int t = i * (i + 1) * (i + 2) / 6;
    for (int j = t; j <= 1000000; j++){
      dp1[j] = min(dp1[j], dp1[j - t] + 1);
    }
    if (t % 2 == 1){
      for (int j = t; j <= 1000000; j++){
        dp2[j] = min(dp2[j], dp2[j - t] + 1);
      }
    }
  }
  while (1){
    int N;
    cin >> N;
    if (N == 0){
      break;
    }
    cout << dp1[N] << ' ' << dp2[N] << endl;
  }
}

C++: 
#include<bits/stdc++.h>
using namespace std;
typedef long long L;
#define mx 1000001
L n,dp1[mx],dp2[mx],data[205];
void init(){
    for(L i=0;i<=200;i++){
        data[i]=(i*(i+1)*(i+2))/6;
    }
    dp1[0]=dp2[0]=0;
    for(L i=1;i<mx;i++){
        dp1[i]=dp2[i]=i;
        for(L j=0;i-data[j]>=0;j++){
            dp1[i]=min(dp1[i],dp1[i-data[j]]+1);
            if(data[j]%2==1){
                dp2[i]=min(dp2[i],dp2[i-data[j]]+1);
            }
        }
    }
}
int main()
{
    init();
    while(scanf("%lld",&n)&&n){
        printf("%lld %lld\n",dp1[n],dp2[n]);
    }
    return 0;
}

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


int main() {
  vector<int> v, ov;
  for (int i = 1; i*(i+1)*(i+2)/6 < 1000000; i++)
    v.push_back(i*(i+1)*(i+2)/6);

  vector<int> table(1000000, INT_MAX);
  vector<int> otable(1000000, INT_MAX);
  for (int i = 0; i < v.size(); i++) {
    table[v[i]] = 1;
    if (v[i] % 2)
      otable[v[i]] = 1;
  }
  
  for (int i = 1; i < 1000000; i++) {
    for (int j = 0; j < v.size() && v[j] < i; j++) {
      table[i] = min(table[v[j]] + table[i-v[j]], table[i]);
      if (v[j] % 2)
        otable[i] = min(otable[v[j]] + otable[i-v[j]], otable[i]);
    }
    //   cout << i << " " << table[i] << endl;
  }

  int n;
  while (cin >> n && n)
    printf("%d %d\n", table[n], otable[n]);
}