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 <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;

//FILE *in = freopen("C", "r", stdin);

int data[] = {1, 4, 10, 20, 35, 56, 84, 120, 165, 220, 286, 364, 455, 560, 680, 816, 969, 1140, 1330, 1540, 1771, 2024, 2300, 2600, 2925, 3276, 3654, 4060, 4495, 4960, 5456, 5984, 6545, 7140, 7770, 8436, 9139, 9880, 10660, 11480, 12341, 13244, 14190, 15180, 16215, 17296, 18424, 19600, 20825, 22100, 23426, 24804, 26235, 27720, 29260, 30856, 32509, 34220, 35990, 37820, 39711, 41664, 43680, 45760, 47905, 50116, 52394, 54740, 57155, 59640, 62196, 64824, 67525, 70300, 73150, 76076, 79079, 82160, 85320, 88560, 91881, 95284, 98770, 102340, 105995, 109736, 113564, 117480, 121485, 125580, 129766, 134044, 138415, 142880, 147440, 152096, 156849, 161700, 166650, 171700, 176851, 182104, 187460, 192920, 198485, 204156, 209934, 215820, 221815, 227920, 234136, 240464, 246905, 253460, 260130, 266916, 273819, 280840, 287980, 295240, 302621, 310124, 317750, 325500, 333375, 341376, 349504, 357760, 366145, 374660, 383306, 392084, 400995, 410040, 419220, 428536, 437989, 447580, 457310, 467180, 477191, 487344, 497640, 508080, 518665, 529396, 540274, 551300, 562475, 573800, 585276, 596904, 608685, 620620, 632710, 644956, 657359, 669920, 682640, 695520, 708561, 721764, 735130, 748660, 762355, 776216, 790244, 804440, 818805, 833340, 848046, 862924, 877975, 893200, 908600, 924176, 939929, 955860, 971970, 988260, 1004731};
int data2[] = {1, 35, 165, 455, 969, 1771, 2925, 4495, 6545, 9139, 12341, 16215, 20825, 26235, 32509, 39711, 47905, 57155, 67525, 79079, 91881, 105995, 121485, 138415, 156849, 176851, 198485, 221815, 246905, 273819, 302621, 333375, 366145, 400995, 437989, 477191, 518665, 562475, 608685, 657359, 708561, 762355, 818805, 877975, 939929, 1004731};

int n;
int d1[1000010];
int d2[1000010];

void process() {
	fill(d1, d1 + n + 1 , 0x7fffffff);
	fill(d2, d2 + n + 1 , 0x7fffffff);
	d1[0] = 0;
	d2[0] = 0;
	for(int i = 0; i < 181; i++) {
		for(int j = data[i]; j <= n; j++) {
			//if(d1[j - data[i]] != -1) {d1[j] == -1 || 
				if(d1[j] > d1[j-data[i]] + 1) {
					d1[j] = d1[j-data[i]] + 1;
				}
			//}
		}
	}
	for(int i = 0; i < 46; i++) {
		for(int j = data2[i]; j <= n; j++) {
			//if(d2[j - data2[i]] != -1) {d2[j] == -1 || 
				if(d2[j] > d2[j-data2[i]] + 1) {
					d2[j] = d2[j-data2[i]] + 1;
				}
			//}
		}
	}

	//printf("%d %d\n", d1[n], d2[n]);
}

int main() {
	n = 1000000;
	process();
	while(true) {
		scanf("%d", &n);
		if(n == 0) break;
		printf("%d %d\n", d1[n], d2[n]);
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <string>
#define REP(i,a,b) for (int i = a; i < (b); i++)
#define sz(t) int(t.size())
#define INF 1000000000
const int DIV = 1000000000 + 7;
using namespace std;
typedef long long ll;

int main(void) {
    vector<int> ps;
    // vector<int> ps_odd;
    REP(i, 1, 182) {
        int val = i * (i + 1) * (i + 2) / 6;
        ps.push_back(val);
        // if (val % 2 == 1) {
        //     ps_odd.push_back(val);
        // }
    }
    vector<int> dp(1000005, INF);
    vector<int> dp_odd(1000005, INF);

    dp[0] = 0;
    dp_odd[0] = 0;
    REP(i, 0, ps.size()) {
        int p = ps[i];
        REP(j, 0, 1000005) {
            if (j >= p) {
                dp[j] = min(dp[j - p] + 1, dp[j]);
                if (p % 2 == 1) {
                    dp_odd[j] = min(dp_odd[j - p] + 1, dp_odd[j]);
                }
            }
        }
    }

    for (;;) {
        int x;
        cin >> x;
        if (x == 0) {
            break;
        }
        cout << dp[x] << ' ' << dp_odd[x] << endl;
    }
}

C++: #include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define repi(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,a) repi(i,0,a)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define repit(i,a) for(__typeof((a).begin()) i=(a).begin();i!=(a).end();i++)

#define all(u) (u).begin(),(u).end()
#define rall(u) (u).rbegin(),(u).rend()
#define UNIQUE(u) (u).erase(unique(all(u)),(u).end())

#define pb push_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define PI acos(-1.0)

using namespace std;

typedef long long ll;
typedef vector<int> vi;

const int N = 1000;
const int M = 1000010;

int a[N], dp[M] = {}, dp1[M] = {};

void prepare()
{
    rep(i, N) a[i] = 1;
    rep(i, N - 1) a[i + 1] += a[i];
    rep(i, N - 1) a[i + 1] += a[i];
    rep(i, N - 1) a[i + 1] += a[i];

    repi(i, 1, M) dp[i] = dp1[i] = M;

    rep(i, N) {
        if (a[i] >= M) break;
        for (int j = a[i]; j < M; ++j) {
            dp[j] = min(dp[j], dp[j - a[i]] + 1);
            if (a[i] & 1) dp1[j] = min(dp1[j], dp1[j - a[i]] + 1);
        }
    }
}

int main()
{
    prepare();

    int n;
    while (cin >> n and n) {
        cout << dp[n] << ' ' << dp1[n] << endl;
    }

    return 0;
}