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>
using namespace std;
int main(){
    vector<int> s;
    for(int i=1;;i++){
        int p=i*(i+1)*(i+2)/6;
        if(p>1000000)break;
        else s.push_back(p);
    }
    int n=s.size();
    vector<int> dp(1000000);
    for(int i=0;i<n;i++){
        vector<int> ndp(1000000);
        for(int j=0;j<1000000;j++){
            if(!i)ndp[j]=j;
            else if(j<s[i])ndp[j]=dp[j];
            else ndp[j]=min(dp[j],min(dp[j-s[i]]+1,ndp[j-s[i]]+1));
        }
        dp=ndp;
    }
    vector<int> DP(1000000);
    for(int i=0;i<n;i++){
        if(s[i]%2==0)continue;
        vector<int> ndp(1000000);
        for(int j=0;j<1000000;j++){
            if(!i)ndp[j]=j;
            else if(j<s[i])ndp[j]=DP[j];
            else ndp[j]=min(DP[j],min(DP[j-s[i]]+1,ndp[j-s[i]]+1));
        }
        DP=ndp;
    }
    while(true){
        int p;scanf("%d",&p);
        if(!p)break;
        printf("%d %d\n",dp[p],DP[p]);
    }
    return 0;
}

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

static const int MAX = 1000000+10;
static const int INF = 1<<30;

int main(){
    vector<int> dp(MAX,INF);
    vector<int> odd(MAX,INF);
    dp[0] = odd[0] = 0;
    for(int i=1; ; i++){
        int cur = i*(i+1)*(i+2)/6;
        if(cur > MAX) break;
        for(int j=cur; j<MAX; j++){
            dp[j] = min(dp[j],dp[j-cur]+1);
            if(cur % 2 != 0) odd[j] = min(odd[j],odd[j-cur]+1);
        }
    }

    int N;
    
    while(cin>>N){
        if(N == 0) break;
        cout<<dp[N]<<" "<<odd[N]<<endl;
    }

    return 0;
}

C++: #include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    int yon[200] = {};
    rep(i,0,200){
        yon[i] = i*(i+1)*(i+2)/6;
    }
//    vector<vector<int> > dp1(1000001,vector<int>()),dp2(1000001,vector<int>());
    vector<int> dp1(1000001,INF),dp2(1000001,INF);
    dp1[0] = dp2[0] = 0;
    for(int i = 0; i < 1000001; i++){
        rep(j,0,200){
            if(i + yon[j] < 1000001){
                dp1[i + yon[j]] = min(dp1[i] + 1,dp1[i + yon[j]]);
                if(yon[j] % 2){
                    dp2[i + yon[j]] = min(dp2[i] + 1,dp2[i + yon[j]]);
                }
            }
        }
    }

    while(true){
        int tmp;
        cin >> tmp;
        if(tmp == 0) break;
        cout << dp1[tmp] << " " << dp2[tmp] << endl;
    }
    return 0;
}

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

#include <string.h>

using namespace std;

#define MAX_D 100000
#define MAX_N 1000000
#define MAX_F 200

#define INF 100000000

int main()
{
	static int N[MAX_D], F[MAX_F], dp1[MAX_N], dp2[MAX_N];

	int c = 0;

	for (int i = 0; i < MAX_N; i++) { dp1[i] = INF; dp2[i] = INF; }

	while (true)
	{
		cin >> N[c];

		if (N[c] == 0) { break; }

		c++;
	}

	int max = *max_element(N, N + c);

	for (int i = 1; i < MAX_F; i++)
	{
		F[i] = i * (i + 1) * (i + 2) / 6;
	}

	dp1[0] = 0;
	dp2[0] = 0;

	for (int i = 1; i <= max; i++)
	{
		for (int j = 1; j < MAX_F; j++)
		{
			if (i < F[j])
			{
				goto Exit1;
			}
			else
			{
				if (dp1[i - F[j]] + 1 < dp1[i])
				{
					dp1[i] = dp1[i - F[j]] + 1;
				}
			}

		Exit1:;
		}
	}

	for (int i = 1; i <= max; i++)
	{
		for (int j = 1; j < MAX_F; j++)
		{
			if (F[j] % 2 == 1)
			{
				if (i < F[j])
				{
					goto Exit2;
				}
				else
				{
					if (dp2[i - F[j]] + 1 < dp2[i])
					{
						dp2[i] = dp2[i - F[j]] + 1;
					}
				}
			}

		Exit2:;
		}
	}

	for (int i = 0; i < c; i++)
	{
		cout << dp1[N[i]] << ' ' << dp2[N[i]] << endl;
	}

	return 0;
}