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 LL long long
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<LL>
#define VVL vector<vector<LL>>
#define VVVL vector<vector<vector<LL>>>
#define VB vector<bool>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

template<class T> T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> void print(T x) { std::cout << x << std::endl; }

const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy = { 0, -1, 0, 1 }, dx = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）

using namespace std;


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

    vector<LL> v, odd;

    FOR(n, 1, 200) {
        LL num = n * (n + 1) * (n + 2) / 6;
        v.emplace_back(num);
        if (num % 2 != 0) {
            odd.emplace_back(num);
        }
    }

    VI dp(1000001, INT_MAX), dp_odd(1000001, INT_MAX);
    dp[0] = 0;
    dp_odd[0] = 0;


    FOR(i, 0, dp.size()) {
        FOE(num, v) {
            if (dp[i] != INT_MAX and i + num < dp.size()) {
                dp[i + num] = min(dp[i + num], dp[i] + 1);
            }
        }
    }
    FOR(i, 0, dp_odd.size()) {
        FOE(num, odd) {
            if (dp_odd[i] != INT_MAX and i + num < dp_odd.size()) {
                dp_odd[i + num] = min(dp_odd[i + num], dp_odd[i] + 1);
            }
        }
    }

    while (true) {
        int n;
        cin >> n;
        if (n == 0) { break; }

        cout << dp[n] << " " << dp_odd[n] << endl;
    }

}

C++: //50
#include<iostream>
#include<algorithm>
#include<vector>

#define INF (1<<29)

using namespace std;

int eo[1000000];
int o[1000000];

int eoc,oc;

int p(int x){
  return x*(x+1)*(x+2)/6;
}

int main(){
  fill_n(eo,1000000,INF);
  fill_n(o,1000000,INF);
  eo[0]=0;
  o[0]=0;
  vector<int> eop,op;
  for(int i=1;p(i)<1000000;i++){
    eop.push_back(p(i));
    if(p(i)%2){
      op.push_back(p(i));
    }
  }
  for(int n;cin>>n,n;){
    while(eo[n]==INF){
      for(int i=0;i<1000000;i++){
	if(eo[i]==eoc){
	  for(int j=0;j<eop.size()&&i+eop[j]<1000000;j++){
	    eo[i+eop[j]]=min(eo[i]+1,eo[i+eop[j]]);
	  }
	}
      }
      eoc++;
    }
    cout<<eo[n]<<' '<<flush;
    while(o[n]==INF){
      for(int i=0;i<1000000;i++){
	if(o[i]==oc){
	  for(int j=0;j<op.size()&&i+op[j]<1000000;j++){
	    o[i+op[j]]=min(o[i]+1,o[i+op[j]]);
	  }
	}
      }
      oc++;
    }
    cout<<o[n]<<endl;
  }
  return 0;
}

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

using namespace std;

int main(void)
{
	int n;
	int i1,i2;
	int nn;
	int p;
	int min;
	int num;

	while(1){
		cin >> n;
		if(n==0) break;

		vector<int> pollock(n+1,0);
		vector<int> pollock2(n+1,0);
		vector<int> p;
		vector<int> p2;
		nn=1;
		num=(nn*(nn+1)*(nn+2))/6;

		for(i1=1;i1<=n;i1++){			

			if(i1==num) {
				if(i1%2==1){
					p.push_back(i1);
					p2.push_back(i1);
					nn++;
					num=(nn*(nn+1)*(nn+2))/6;
					pollock[i1]=1;
					pollock2[i1]=1;
				}
				else {
					nn++;
					num=(nn*(nn+1)*(nn+2))/6;
					p.push_back(i1);
					pollock[i1]=1;
					min=100000;
					for(i2=0;i2<p2.size();i2++){
						if((pollock2[i1-p2[i2]])<min){
							min=pollock2[i1-p2[i2]];
						}
					}
					pollock2[i1]=min+1;
				}
			}
			else {
				min=100000;
				for(i2=0;i2<p.size();i2++){
					if((pollock[i1-p[i2]])<min){
						min=pollock[i1-p[i2]];
					}
				}
				pollock[i1]=min+1;

				min=100000;
				for(i2=0;i2<p2.size();i2++){
					if((pollock2[i1-p2[i2]])<min){
						min=pollock2[i1-p2[i2]];
					}
				}
				pollock2[i1]=min+1;
			}
			//cout<<pollock[i1]<<" ";

		}

		cout << pollock[n] << " " << pollock2[n] << endl;
		

	}

	return 0;
}

C++: #include <cstdio>
using namespace std;

int min(int a,int b){return a<b?a:b;}
int max(int a,int b){return a>b?a:b;}
int n,a[1000010],b[1000010],l[200];
int main(){
    for(int i=1;i<200;i++)
        l[i-1]=(i*(i+1)*(i+2))/6;
    for(int i=1;i<=1000000;i++){
        a[i]=i;
        b[i]=i;
        for(int t=0;l[t]<=i;t++){
            a[i]=min(a[i],a[i-l[t]]+1);
            if(l[t]%2)
                b[i]=min(b[i],b[i-l[t]]+1);
        }
    }
    while(scanf("%d",&n),n){
	    printf("%d %d\n",a[n],b[n]);
    }
    return 0;
}