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 <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

const int MAX_N = 1000000, Inf = 1<<28;
int dp[2][MAX_N];

int main() {
  rep(i,MAX_N) rep(j,2) dp[j][i] = Inf;
  dp[0][0] = dp[1][0] = 0;

  for (int i = 1; i*(i+1)*(i+2)/6 < MAX_N; ++i) {
    const int v = i*(i+1)*(i+2)/6;
    for (int j = 1; j < MAX_N; ++j) {
      if (j-v < 0) continue;
      dp[0][j] = min(dp[0][j], dp[0][j-v]+1);
      if (v%2)
        dp[1][j] = min(dp[1][j], dp[1][j-v]+1);
    }
  }

  int in;
  while (scanf("%d",&in),in) {
    printf("%d %d\n",dp[0][in], dp[1][in]);
  }
  return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef pair<int, pii> pip;
 
 
 
const int INF = 1000000;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
 
int dp[1000010];
int dp2[1000010];

int main(){
	int a = 1, b;
	vi v;
	vi u;
	while((b = a*(a+1)*(a+2)/6)<1e6){
		v.pb(b);
		if(b%2 == 1){
			u.pb(b);
		}
		a++;
	}
	//cout<<v.size()<<endl;
	for(int i = 0; i < 1000010; i++){
		dp[i] = INF;
		dp2[i] = INF;
	}
	dp[0] = 0;
	dp2[0] = 0;
	for(int i = 0; i < v.size(); i++){
		for(int j = v[i]; j < 1000010; j++){
			dp[j] = min(dp[j], dp[j-v[i]]+1);
			if(j < u.size()){
				dp2[j] = min(dp2[j], dp2[j-u[i]]+1);
			}
		}
	}
	//cout<<"OK"<<endl;
	int n;
	while(cin>>n && n > 0){
		cout<<dp[n]<<" "<<dp2[n]<<endl;
	}
}

C++: #include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;


int main() {
    ios_base::sync_with_stdio(false);
    vector<int> dp(1000010,1e9),odddp(1000010,1e9);
    dp[0]=0;
    odddp[0]=0;
    repr(i,1,1010) {
        int a=i*(i+1)*(i+2)/6;
        rep(j,1000010) {
            if (j>=a) dp[j]=min(dp[j],dp[j-a]+1);
            if (a%2==1 && j>=a) odddp[j]=min(odddp[j],odddp[j-a]+1); 
        }
    }
    // rep(i,50) cout << dp[i] << endl;
    while (1) {
        int n;
        cin >> n;
        if (n==0) break;
        cout << dp[n] << ' ' << odddp[n] << endl;
    }
    return 0;   
}

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

using namespace std;
long long tetra[190];

class Node{
public:
	int deep;
	int sum;
	int num;
	Node(int d,int s,int n){
		deep=d;
		sum=s;
		num=n;
	}
	bool operator < (const Node &o) const{
		return deep >o.deep;
	}
};
typedef queue <Node> Q;

int bfs(int limit){
	Q pq;
	pq.push(Node(0,0,1));
	while(!pq.empty()){
		Node cur=pq.front();
		pq.pop();
		if(cur.sum==limit)return cur.deep;
		for(int i=cur.num;i<=182;i++){
			if(cur.sum+tetra[i]>limit)break;
			pq.push(Node(cur.deep+1,cur.sum+tetra[i],i));
		}
	}
	return -1;
}
int bfs2(int limit){
	Q pq;
	pq.push(Node(0,0,1));
	while(!pq.empty()){
		Node cur=pq.front();
		pq.pop();
		if(cur.sum==limit)return cur.deep;
		for(int i=cur.num;i<=182;i++){
			if(cur.sum+tetra[i]>limit)break;
			if(!(tetra[i]%2))continue;
			pq.push(Node(cur.deep+1,cur.sum+tetra[i],i));
		}
	}
	return -1;
}

int
main(){
	tetra[1]=1;
	for(int i=0;i<=192;i++){
		tetra[i]=(i*(i+1)*(i+2))/6;
	}
	while(true){
		int n;
		cin>>n;
		if(!n)break;
		int count;
		if((count=bfs(n))>0){
			cout<<count;
		}
		if((count=bfs2(n))>0){
			cout<<" "<<count<<endl;
		}
	}
	return 0;
}