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 <iostream>
#include <vector>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(c) (c).begin(), (c).end()
const int N = 1000000;

template<typename T> inline void chmin(T& t, T f){if(t > f)t = f;}

vector<int> mem1, mem2;

void calc(vector<int>& v, vector<int>& mem){
    mem.resize(N); iota(all(mem), 0);
    rep(i, N)for(auto j: v){
        if(i < j)break;
        chmin(mem[i], mem[i-j]+1);
    }
}

void init(){
    vector<int> num, odd;
    for(int i=1, x=1; x<N; ++i, x=i*(i+1)*(i+2)/6){
        num.push_back(x);
        if(x&1)odd.push_back(x);
    }
    calc(num, mem1);
    calc(odd, mem2);
}

int main(){
    init();
    int n;
    while(cin >> n, n)cout << mem1[n] << ' ' << mem2[n]<< '\n';
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
long long shimen[200];
long long dp[1000010];
long long dp2[1000010];
int main () {
	long long N;
	for (long long n = 1; n * n * n < 6000000; n++) {
		shimen[n] = n * (n + 1) * (n + 2) / 6;
		N = n;
	}
	
	for (int i = 1; i < 1000001; i++) {
		dp[i] = 100000;
		dp2[i] = 100000;
	}
	dp[0] = 0;
	for (long long i = 0; i < 1000001; i++) {
		for (int j = 0; j < N; j++) {
			if (shimen[j] + i > 1000001) continue;
			dp[i + shimen[j]] = min(dp[i + shimen[j]], dp[i] + 1);
			if (shimen[j] % 2) {
				dp2[i + shimen[j]] = min(dp2[i + shimen[j]], dp2[i] + 1);
			}
		}
	}
	cin >> N;
	while (N) {
		cout << dp[N] << " " << dp2[N] << endl;
		cin >> N;
	}
}

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

int main(){
  int N,i=0,a,cnt=0;
  int f[1000];
  int dp[1000000],odp[1000000];
  while(1){
    f[i]=(i+1)*(i+2)*(i+3)/6;
    if(f[i]>1000000) break;
    cnt++;
    i++;
  }
  dp[0]=0;dp[1]=1;
  odp[0]=0;odp[1]=1;
  for(int i=2;i<1000000;i++){
    dp[i]=odp[i]=10000000;
  }
  for(int i=2;i<1000000;i++){
    for(int j=0;j<cnt;j++){
      if((i-f[j])<0) break;
      else dp[i]=min(dp[i-f[j]]+1,dp[i]);
    }
  }
  for(int i=2;i<1000000;i++){
    for(int j=0;j<cnt;j++){
      if((i-f[j])<0) break;
      else if(j%4!=0) continue;
      else odp[i]=min(odp[i-f[j]]+1,odp[i]);
    }
  }
  while(1){
    cin>>N;
    if(N==0) break;
    cout<<dp[N]<<" "<<odp[N]<<endl;
  }
  return 0;
}

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

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

inline int tetnum(int n) {
	return n * (n + 1) * (n + 2) / 6;
}

int main () {
	dp[0] = 0;
	fill(dp, dp + 1000010, 0x7ffffff);
	fill(dp2, dp2 + 1000010, 0x7ffffff);
	for (int i = 0; tetnum(i) < 1000010; i++) dp[tetnum(i)] = 1;
	for (int i = 0; tetnum(i) < 1000010; i++) {
		if (tetnum(i) & 1) dp2[tetnum(i)] = 1;
	}
	for (int i = 1; i <= 1000010; i++) {
		for (int j = 0; i - tetnum(j) > 0; j++) {
			dp[i] = min(dp[i], dp[i - tetnum(j)] + 1);
			if (tetnum(j) & 1) {
				dp2[i] = min(dp2[i], dp2[i - tetnum(j)] + 1);
			}
		}
	}
	int n;
	while (cin >> n, n) {
		cout << dp[n] << ' ' << dp2[n] << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	vector<int>q;
	loop(i,1,10000000){
		int tmp=i*(i+1)*(i+2)/6;
		if(tmp>1000000)break;
		q.pb(tmp);
	}
	vector<int>out(1000010);
	rep(i,1000010)out[i]=inf;
	out[0]=0;
	rep(i,q.size())loop(j,q[i],1000010)out[j]=min(out[j],out[j-q[i]]+1);
	
	vector<int>out2(1000010);
	rep(i,1000010)out2[i]=inf;
	out2[0]=0;
	rep(i,q.size()){
		if(q[i]%2==0)continue;
		loop(j,q[i],1000010)out2[j]=min(out2[j],out2[j-q[i]]+1);
	}
	int n;
	while(cin>>n,n)cout<<out[n]<<" "<<out2[n]<<endl;
}

C++: #include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
vector<int> V,W;
int MAX_NUM = 1000000;
P dp(int N){
    P ans;
    vector<int> table(N+1,INF);
    table[0] = 0;
    rep(i,0,V.size()){
        rep(j,0,N+1){
            if(j - V[i] >= 0)table[j] = min(table[j], table[j - V[i]] + 1);
        }
    }
    ans.first = table[N]; 
    table.assign(N+1,INF);
    table[0] = 0;
    rep(i,0,W.size()){
        rep(j,0,N+1){
            if(j - W[i] >= 0)table[j] = min(table[j], table[j - W[i]] + 1);
        }
    }
    ans.second = table[N];
    return ans;
}
main(){
    for(int i = 1;i * (i + 1) * (i + 2) / 6 <= MAX_NUM;i++){
        int num = i * (i + 1) * (i + 2) / 6; 
        V.push_back(num);
        if(i % 4 == 1)W.push_back(num);
    }

    int N;
    cin >> N;
    while(N){
        auto ans = dp(N);
        cout << ans.first << " " << ans.second << endl;
        cin >> N;
    }
}