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<cmath>
#include<complex>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define NEXT(i,n) ((i+1)%(n))
const int N = 1000001;
int dp1[N],dp2[N];  
main(){
  vector<int> simen;
  REP(i,1,N+1){
    simen.push_back(i*(i+1)*(i+2)/6);
    if (simen[i-1] > N+1)break;
  }
  
  dp1[0]=0;
  dp2[0]=0;
  REP(i,1,N){
    dp1[i]=10000000;
    dp2[i]=10000000;
    rep(j,simen.size()){
      if (i-simen[j] < 0)break;
      dp1[i]=min(dp1[i],dp1[i-simen[j]]+1);
      if (simen[j]%2 == 1){
	dp2[i]=min(dp2[i],dp2[i-simen[j]]+1);
      }
    }
  }
  
  int n;
  while(cin>>n && n){
    cout << dp1[n] <<" " << dp2[n] << endl;
  }

}

C++: #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 1000010
using namespace std;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
vector<int> num(200);
vector<int> num_odd(200);
vector<int> dp(1000011,INF);
vector<int> dp_odd(1000011,INF);
int main()
{
	int i = 0;
	while(i <= 185)
	{
		long tmp = i*(i+1)*(i+2)/6;
		num[i] = tmp;
		if(num[i] % 2) num_odd.push_back(tmp);
		i++;
	}
	dp[0] = dp_odd[0] = 0;
	for(int i=0; i<num.size(); i++)
	{
		for(int j=num[i]; j<=1000000; j++)
		{
			dp[j] = min(dp[j], dp[j - num[i]] + 1);
		}
	}
	for(int i=0; i<num_odd.size(); i++)
	{
		for(int j=num_odd[i]; j<=1000000; j++)
		{
			dp_odd[j] = min(dp_odd[j], dp_odd[j - num_odd[i]] + 1);
		}
	}
	int N;
	while(cin >> N, N)
	{
		cout << dp[N] << " " << dp_odd[N] << endl;
	}
	return 0;
}

C++: #include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

int main() {
	vi four;
	int n = 1;
	while(true) {
		int num = n*(n+1)*(n+2)/6;
		if(num > 1000000) {
			break;	
		} else {
			four.push_back(num);
			n++;
		}
	}
	int fsize = four.size();

	while(cin >> n, n) {
		//vi dp(n+1, INF);
		//vi dpk(n+1, INF);
		int dp[1000001], dpk[1000001];
		FOR(i, 1, 1000000) {
			dp[i] = dpk[i] = INF;
		}

		dp[0] = dpk[0] = 0;

		FOR(i, 1, n) {
			REP(j, fsize) {
				if(i-four[j] >= 0) {
					dp[i] = min(dp[i-four[j]]+1, dp[i]);
					if(four[j]%2) {
						dpk[i] = min(dpk[i-four[j]]+1, dpk[i]);
					}
				} else {
					break;
				}
			}
		}

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

	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int n,i,j,k,t=0,a[200]={},b[200]={},c[1000005]={1000000},d[1000005]={1000000};
  for(i=1;i<201;i++) {
    a[i-1]=i*(i+1)*(i+2)/6;
    if(a[i-1]%2==1)b[t++]=m[i-1];
  }
  for(i=c[0]=d[0]=0;i<200;i++) {
    for(j=a[i];j<1000005;j++){
      c[j]=min(c[j],c[j-a[i]]+1);
    }
  }
  for(i=0;i<t;i++) {
    for(j=b[i];j<1000005;j++){
      d[j]=min(d[j],d[j-b[i]]+1);
    }
  }
  while(cin>>n,n)cout<<c[n]<<" "<<b[n]<<endl;
return 0;
}

C++: #include<iostream>
#include<algorithm>
#define INF 1<<28
using namespace std;

int p[1000001];
int memo[1000001];
int memo2[1000001];

int solve(int n, int count){
  
  if(!n) return 0;
  if(n <= 0 || !count) return INF;
  if(memo[n]) return memo[n];
  
  int ans = INF;
  for(int i=0;p[i]<=n; i++) ans = min(ans, solve(n-p[i], count-1)+1);
  
  return memo[n] = ans;
}

int solve2(int n){
  
  if(!n) return 0;
  if(n<0) return INF;
  if(memo2[n]) return memo2[n];
  
  int ans = INF;
  for(int i=0;p[i]<=n;i++){
    if(!(p[i]%2)) continue;
    ans = min(ans, solve2(n-p[i])+1);
  }
  
  return memo2[n] = ans;
}

int main(){
  
  int n;
  
  for(int i=0;i<=1000000;i++) p[i] = i*(i+1)*(i+2)/6;
  //for(int i=1;i<=1000000;i++) solve(i, 5), solve2(i);
  
  while(cin >> n, n) cout << solve(n, 5) << " " << solve2(n) << endl;
}