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<stdio.h>
#include<cstdio>
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<utility>
#include<queue>
#define pi 3.14159
#define Inf (int)pow(2., 12.)

using namespace std;
typedef std::pair<int, int> mypair;
queue<mypair> qu;
#define M 1000000
 
int odd[M+1], all[M+1];
 
void update(int *ar, int x){
    for(int i = x; i <= M; ++i){
        ar[i] = min(ar[i], ar[i - x] + 1);
    }
}
 
int main(){
	odd[0] = all[0] = 0;
    for(int i = 1; i <= M; ++i){
        odd[i] = all[i] = 10000000;
    }
 
    for(int i = 1; ; ++i){
        int x = i * (i + 1) * (i + 2) / 6;
        if(x > M) break;
        update(all, x);
        if(x % 2 == 1) update(odd, x); 
    }
     
    int n;
    while(1) {
		cin >> n;
		if(n == 0) break;
		cout << all[n] << " " << odd[n] <<endl;
	}
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int n;

vector<ll> table, table2;

ll dp[2][2][1001000];

int main() {
	for (int i = 1; i*(i + 1)*(i + 2) / 6 <= 1000000; i++) {
		table.push_back(i*(i + 1)*(i + 2) / 6);
		if ((i*(i + 1)*(i + 2) / 6) % 2 == 1)table2.push_back(i*(i + 1)*(i + 2) / 6);
	}
	//cout << table.size() << endl;
	REP(i, 2) {
		REP(j, 2) {
			REP(k, 1001000)dp[i][j][k] = INF;
		}
	}
	dp[0][0][0] = 0;
	dp[1][0][0] = 0;

	REP(i, table.size()) {
		int num = table[i];
		REP(j, 1000000) {
			if (j - num >= 0) {
				dp[0][(i + 1) % 2][j] = min(dp[0][(i + 1) % 2][j - num] + 1, dp[0][i % 2][j]);
			}
			else dp[0][(i + 1) % 2][j] = dp[0][i % 2][j];
		}
	}

	for (int i = 0; i < table2.size(); i++) {
		int num = table2[i];
		//cout << num << endl;
		REP(j, 1000000) {
			if (j - num >= 0) {
				dp[1][(i + 1) % 2][j] = min(dp[1][(i + 1) % 2][j - num] + 1, dp[1][i % 2][j]);
			}
			else dp[1][(i + 1) % 2][j] = dp[1][i % 2][j];
		}
	}
	
	while (cin >> n&&n) {
		cout << dp[0][table.size() % 2][n] << " "
			<< dp[1][table2.size() % 2][n] << endl;
	}
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 1e9
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int dp[1000010]={};
  int dp2[1000010]={};
  for(int i=1;i<=1000000;i++){dp[i]=INF;dp2[i]=INF;}
  vector<ll> gu;
  vector<ll> ki;
  ll cnt=1;
  while(1){
    if((cnt*(cnt+1)*(cnt+2)/6)>1000000)break;
    if(((cnt*(cnt+1)*(cnt+2))/6)%2){ki.pb(cnt*(cnt+1)*(cnt+2)/6);dp[ki[ki.size()-1]]=1;dp2[ki[ki.size()-1]]=1;}
    else {gu.pb(cnt*(cnt+1)*(cnt+2)/6);dp[gu[gu.size()-1]]=1;}
    cnt++;
  }
  dp[1]=1;
  dp2[1]=1;
  for(int i=1;i<1000000;i++){
    for(int j=0;j<gu.size();j++){
      if(i+gu[j]>1000000)break;
      dp[i+gu[j]]=min(dp[i+gu[j]],(dp[i]+1));
    }
    for(int j=0;j<ki.size();j++){
      if(i+ki[j]>1000000)break;
      dp[i+ki[j]]=min(dp[i+ki[j]],(dp[i]+1));
      dp2[i+ki[j]]=min(dp2[i+ki[j]],(dp2[i]+1));
    }
  }
  int n;
  while(cin>>n,n){
    cout<<dp[n]<<" "<<dp2[n]<<endl;
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define print(a) cout<<a<<endl;
int aaa[200] = {}, bbb[200] = {}, counta=1,countb=1, ansa, ansb, xxx[1100000] = {}, yyy[1100000] = {};

int foo(int n, int x){//cout<<n<<" "<<x<<" "<<xxx[x]<<endl;;
	int mi = 1000000;
	if(xxx[n]) return xxx[n]+x;
	if(x > 5) return mi;
	for(int i = counta-1; i >= 1; i--){
		if(aaa[i] < n){
			mi = min(foo(n-aaa[i],x+1), mi);
		//	if(mi - n == 1)break;
		} //else if(aaa[i] < n/2) break;
	}
	
	xxx[n] = mi;
	return mi;
}
int boo(int n, int x){//cout<<n<<" "<<x<<" "<<yyy[n]<<endl;cin>>ansb;
	int mi = 1000000;
	if(yyy[n]) return yyy[n]+x;
	for(int i = countb-1; i >= 1; i--){
	//	cout<<bbb[i]<<" "<<n<<endl;
		if(bbb[i] < n){
			mi = min(boo(n-bbb[i],x+1), mi);
			//if(mi - n == 1)break;
		}// else if(bbb[i] < n/2) break;
	}
	//cout<<"aaaa "<<n<<" "<<x<<" "<<mi<<endl;
	yyy[n] = mi;
	return mi;
}

int main(){
	int i, n, abc;
	for(i = 1; abc <= 1000000; i++){
		abc = (i*(i+1)*(i+2))/6;
		xxx[abc] = 1;
		if(abc%2 == 1){
			yyy[abc] = 1;
			bbb[countb++] = abc;
		}
		aaa[counta++] = abc;
	//	cout<<counta<<" "<<i<<" "<<abc<<endl;;
	}
//	print(1);
	for(i = 1; i <= 100000; i++){
		xxx[i] = foo(i, 0);
		yyy[i] = boo(i, 0);
	}
//	print('a');
	while(1){
		cin>>n;
		if(n == 0) break;
		cout<<foo(n,0)<<" "<<boo(n,0)<<endl;
	}
	return 0;
}