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 _sel(_1, _2, x, ...) x
#define repn(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, ...) _sel(__VA_ARGS__, reps, repn)(i, __VA_ARGS__)
#define reppn(i, n) for (ll i = 1; i <= (n); i++)
#define repps(i, a, b) for (ll i = (a); i <= (b); i++)
#define repp(i, ...) _sel(__VA_ARGS__, repps, reppn)(i, __VA_ARGS__)
#define rrepn(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, a, b) for (ll i = (b) - 1; i >= (a); i--)
#define rrep(i, ...) _sel(__VA_ARGS__, rreps, rrepn)(i, __VA_ARGS__)
#define rreppn(i, n) for (ll i = (n); i >= 1; i--)
#define rrepps(i, a, b) for (ll i = (b); i >= (a); i--)
#define rrepp(i, ...) _sel(__VA_ARGS__, rrepps, rreppn)(i, __VA_ARGS__)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define rng(v) (v).begin(), (v).end()
#define rrng(v) (v).rbegin(), (v).rend()
#define _shwv(v) for (auto _t1 : v) cerr << _t1 << " "; cerr << endl;
#define dbg(x) cerr << #x << ": " << (x) << endl;
#define dbgv(v) cerr << #v << ": "; _shwv(v);
#define dbgm(m) cerr << #m << ":" << endl; for (auto _t2 : m) { _shwv(_t2); }

using namespace std;
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
const int DX[4] = {1, 0, -1, 0};
const int DY[4] = {0, 1, 0, -1};

template<typename T> inline void prt(T x) { cout << x << endl; }
template<typename T> inline void getv(T& v) { for (auto& t : v) cin >> t; }
template<typename T> inline int siz(T& x) { return x.size(); }
template<typename T> inline ll pow2(T n) { return 1ll << n; }
template<typename T, typename U> inline int bit(T x, U n) { return x >> n & 1; }
template<typename T, typename U>
inline bool umax(T& m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool umin(T& m, U x) { if (m > x) { m = x; return true; } return false; }


int main() {
    vi n;
    int m = 0;
    while (true) {
        int a; cin >> a;
        if (a == 0) break;
        umax(m, a);
        n.pb(a);
    }
    vi dp(m + 1, 0);
    vi dp2(m + 1, 0);
    repp(i, m) {
        dp[i] = INF;
        dp2[i] = INF;
        repp(j, INF) {
            ll num = j * (j + 1) * (j + 2) / 6;
            if (i < num) break;
            umin(dp[i], dp[i - num] + 1);
            if (num % 2 == 1)
                umin(dp2[i], dp2[i - num] + 1);
        }
    }
    for (auto t : n) {
        cout << dp[t] << " " << dp2[t] << endl;
    }

    return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

int n;

int dp[2][1000010], adp[2][1000010];
int INF = 1e9;
int add[200], oadd[200];

void solve() {
	for (int i=0; i<2; i++) {
		fill(dp[i], dp[i]+1000010, INF);
		fill(adp[i], adp[i]+1000010, INF);
	}
	
	dp[0][0] = 0;
	for (int i=0; i<200; i++) {
		int nw = i%2, nx = (i+1)%2;
		for (int j=0; j<=1000000; j++) {
			if (add[i] <= j) {
				dp[nx][j] = min(dp[nw][j], dp[nx][j-add[i]] + 1);
			} else {
				dp[nx][j] = dp[nw][j];
			}
		}
	}
	
	adp[0][0] = 0;
	for (int i=0; i<200; i++) {
		int nw = i % 2, nx = (i+1)%2;
		
		for (int j=0; j<=1000000; j++) {
			if (oadd[i] <= j) {
				adp[nx][j] = min(adp[nw][j], adp[nx][j-oadd[i]] + 1);
			} else {
				adp[nx][j] = adp[nw][j];
			}
		}
	}
}

void qer() {	
	int ans1 = INF, ans2 = INF;
	for (int i=0; i<2; i++) {
		ans1 = min(ans1, dp[i][n]);
		ans2 = min(ans2, adp[i][n]);
	}
	cout << ans1 << " " << ans2 << endl;
}

int main() {
	int p = 0;
	for (int i=0; i<200; i++) {
		add[i] = i * (i+1) * (i+2) / 6;
		if (add[i] % 2 == 1) oadd[p++] = add[i];
	}
	solve();
	
	while (1) {
		cin >> n; if (n==0) break;
		qer();
	}
	
	return 0;
}

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

#define int long long
#define pb push_back 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for( int i = 0; i < (n); i++ )
#define Rrep(i, a, n) for( int i = (a); i < (n); i++ )
#define All(v) v.begin(), v.end()

typedef pair<int, int> Pii; 
typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;

int dp[200][1000001];
int dp_odd[40][1000001];
int four[210];
int x;

signed main() {
  Rep(i, 210) four[i] = i * (i+1) * (i+2) / 6;
  
  memset(dp, 1e6+1, sizeof(dp));
  Rep(i, 1000001) dp[1][i] = i;
  Rrep(i, 2, 200) {
    Rep(j, 1000001) {
      dp[i][j] = min(dp[i][j], dp[i-1][j]);
      if ( j+four[i] <= 1000000 ) {
	dp[i][j+four[i]] = min(dp[i][j+four[i]], dp[i][j]+1);
      }
    }
  }

  memset(dp_odd, 1e6+1, sizeof(dp_odd));
  Rep(i, 1000001) dp_odd[1][i] = i;
  Rrep(i, 2, 40) {
    Rep(j, 1000001) {
      dp_odd[i][j] = min(dp_odd[i][j], dp_odd[i-1][j]);
      if ( j+four[(i-1)*4+1] <= 1000000 ) {
	dp_odd[i][j+four[(i-1)*4+1]] = min(dp_odd[i][j+four[(i-1)*4+1]], dp_odd[i][j]+1);
      }
    }
  }
 
  while ( cin >> x, x ) {
    cout << dp[199][x] << " " << dp_odd[39][x] << endl;
  }
  return 0;
}