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 rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int dp[1000010];
int dp2[1000010];

signed main() {
	int n;
	rep(i, 0, 1000010) {
		dp[i] = 10;
		dp2[i] = 10000000;
	}
	dp[0] = 0;
	dp2[0] = 0;
	rep(i, 1, 200) {
		int a = i*(i + 1)*(i + 2) / 6;
		if (a > 1000000) break;
		rep(j, 0, 1000001) {
			if (j + a > 1000000) break;
			dp[j + a] = min(dp[j + a], dp[j] + 1);
			if (a % 2 == 0) continue;
			dp2[j + a] = min(dp2[j + a], dp2[j] + 1);
		}
	}
	while (cin >> n && n) {
		cout << dp[n] << " " << dp2[n] << endl;
	}
}

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

const int MAX = 1e6+1;

vector<int> tetra;
int all[MAX];
int odd_only[MAX];

void prepare() {
    for (int i=1; i*(i+1)*(i+2)/6<MAX; ++i) {
        tetra.push_back(i*(i+1)*(i+2)/6);
    }

    fill_n(all, MAX, INT_MAX);
    all[0] = 0;
    fill_n(odd_only, MAX, INT_MAX);
    odd_only[0] = 0;

    for (int t: tetra) {
        for (int i=0; i+t<MAX; ++i) {
            all[i+t] = min(all[i+t], all[i]+1);
            if (t % 2) odd_only[i+t] = min(odd_only[i+t], odd_only[i]+1);
        }
    }
}

int main() {
    prepare();
    int n;
    while (cin >> n, n) {
        cout << all[n] << " " << odd_only[n] << endl;
    }
    return 0;
}

C++: //#include <bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

int dp[1000001] = {};
int ki[1000001] = {};

int main(void) {
	int poll[181] = {};

	FOR(i, 1, 180) {
		poll[i] = i * (i + 1)*(i + 2);
		poll[i] /= 6;
		//cout << poll[i] << endl;
	}
	FOR(i, 2, 1000000) {
		dp[i] = INF;
		ki[i] = INF;
	}
	dp[1] = 1;
	ki[1] = 1;
	FOR(i, 1, 1000000) {
		FOR(j, 1, 180) {
			if (i - poll[j] > 0) {
				dp[i] = min(dp[i], dp[i - poll[j]] + 1);
			}
			else if (i == poll[j]) {
				dp[i] = 1;
			}
			else {
				break;
			}
			
		}
	}
	FOR(i, 1, 1000000) {
		for(int j=1;j<=180;j+=4) {
			if (i - poll[j] > 0) {
				ki[i] = min(ki[i], ki[i - poll[j]] + 1);
			}
			else if (i == poll[j]) {
				ki[i] = 1;
			}
			else {
				break;
			}

		}
	}
	/*FOR(i, 1, 1000000) {
		cout << i << " " << ki[i] << endl;
	}*/
	while (1) {
		int n;
		int first = 0;
		int second = 0;

		cin >> n;
		if (n == 0) {
			break;
		}
		cout << dp[n] << " " << ki[n] << endl;

	}

	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7+1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/


ll dp[1000005];
ll dpOdd[1000005];

int main()
{
	REP(i, 1000001)
	{
		dp[i] = dpOdd[i] = i;
	}

	for (ll n = 2;; n++) {
		ll bNumber = n * (n + 1) * (n + 2) / 6;
		if (bNumber > 1000001) break;

		for (ll i = 0; i <= 1000001; i++) {
			if (i - bNumber < 0) continue;
			dp[i] = min(dp[i], dp[i - bNumber] + 1);
			if (bNumber % 2 == 1) dpOdd[i] = min(dpOdd[i], dpOdd[i - bNumber] + 1);
		}
	}

	for (;;) {
		ll Value;
		cin >> Value;
		if (!Value) break;
		cout << dp[Value] << " " << dpOdd[Value] << endl;
	}

	return 0;
}