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>
using namespace std;

#define MAX 100000
#define INF (1<<24)
int n[100000],M;

int dp[1000005];
int od[1000005];

int main()
{
	for(M=1; ; M++)
	{
		int v=M*(M+1)*(M+2)/6;
		if(v>MAX) break;
		n[M]=v;
	}

	int N;
	while(cin >> N, N)
	{
		for(int i=0; i<=N; i++)
		{
			dp[i]=INF;
			od[i]=INF;
		}

		dp[0]=od[0]=0;

		for(int i=1; i<M; i++)
		for(int j=0; j<=N; j++) 
		{
			if(j+n[i] > N) break;
			if(dp[j]!=INF)
			{
				dp[j+n[i]]=min(dp[j+n[i]], dp[j]+1);
			}
			if(od[j]!=INF&&n[i]%2==1)
			{
				od[j+n[i]]=min(od[j+n[i]], od[j]+1);
			}
		}

		cout << dp[N] << " " << od[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;
vector<int> table(MAX_NUM);
P dp(int N){
    P ans;
    table.assign(N+1,INF);
    table[0] = 0;
    rep(i,0,V.size()){
        rep(j,0,N+1){
            if(j + V[i] > N)break;
            table[j + V[i]] = min(table[j + V[i]], table[j] + 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] > N)break;
            table[j + W[i]] = min(table[j + W[i]], table[j] + 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;
    }
}

C++: #include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  constexpr int N = 1e6;
  V<> a, b;
  for (int i = 1; ; ++i) {
    a.push_back(i * (i + 1) * (i + 2) / 6);
    if (a.back() >= N) {
      a.pop_back();
      break;
    }
    if (a.back() & 1) b.push_back(a.back());
  }
  V<> p(N, -1), q(N, -1);
  p[0] = q[0] = 0;
  queue<int> que;
  que.push(0);
  while (!que.empty()) {
    int i = que.front(); que.pop();
    for (int e : a) if (i + e < N and p[i + e] == -1) {
      p[i + e] = p[i] + 1;
      que.push(i + e);
    }
  }
  que.push(0);
  while (!que.empty()) {
    int i = que.front(); que.pop();
    for (int e : b) if (i + e < N and q[i + e] == -1) {
      q[i + e] = q[i] + 1;
      que.push(i + e);
    }
  }
  while (true) {
    int n; cin >> n;
    if (!n) break;
    cout << p[n] << ' ' << q[n] << '\n';
  }
}

C++: #include <iostream>

using namespace std;

void append(int t, int n, int table[]) {
    table[t] = 1;
    for (int i=0; i<=n-t; i++) {
        if (table[i] < 0) {
            continue;
        }
        if (table[i+t] < 0) {
            table[i+t] = table[i]+1;
        }
        else {
            table[i+t] = min(table[i]+1, table[i+t]);
        }
    }
}

int main() {
    int n;
    int dp[1000000];
    int dp_odd[1000000];
    for (int i=0; i<1000000; i++) {
        dp[i] = -1;
        dp_odd[i] = -1;
    }
    for (int i=0; true; i++) {
        int t = i*(i+1)*(i+2)/6;
        if (t > 1000000) {
            break;
        }
        append(t, 1000000, dp);
        if (t%2 == 1) {
            append(t, 1000000, dp_odd);
        }
    }
    while (true) {
        cin >> n;
        if (n == 0) {
            return 0;
        }
        cout << dp[n] << ' ' << dp_odd[n] << endl;
    }
}

C++: // AOJ 1167
#include<cstdio>
#include<vector>
#define rep(i,a) for( int i = 0; i != (a); ++i )

const int INF = 1<<30;

std::vector<int> tet;
std::vector<int> dp( 1000001, INF ), dpOdd( 1000001, INF );

int main()
{
	for( int i = 1; i*(i+1)*(i+2)/6 <= 200000; ++i )
		tet.push_back( i*(i+1)*(i+2)/6 );

	dp[0] = dpOdd[0] = 0;
	rep( i, 1000001 )
	{
		rep( j, tet.size() )
		{
			if( i-tet[j] >= 0 )
			{
				dp[i] = std::min( dp[i], dp[i-tet[j]]+1 );
			
				if( tet[j]&1 )
					dpOdd[i] = std::min( dpOdd[i], dpOdd[i-tet[j]]+1 );
			}
		}
	}

	int n;
	while( scanf( "%d", &n ), n )
		printf( "%d %d\n", dp[n], dpOdd[n] );

	return 0;
}