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<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
int a[1001],ta[1001],tta[1001];
int dp[1000021];
const int INF=99999999;
int main(){
	a[1]=1,ta[1]=1,tta[1]=1;
	int cnt=1;
	for(int i=2;i<=1000;i++)a[i]=i+a[i-1];
	for(int i=2;i<=1000;i++){
	ta[i]=a[i]+ta[i-1];
	if(ta[i]%2==1)tta[++cnt]=ta[i];
	}
	int n;
	while(true){
	cin>>n;
	if(n==0)break;
	ta[1]=1;

	fill(dp+1,dp+1000021,INF);
	for(int i=0;i<=181;i++){
		for(int j=1;j<=n;j++){
		if(j>=ta[i])dp[j]=min(dp[j],dp[j-ta[i]]+1);
		}
	}//endfor
	cout<<dp[n]<<" ";
	fill(dp+1,dp+1000021,INF);
	for(int i=0;i<=92;i++){
		for(int j=1;j<=n;j++){
		if(j>=tta[i])dp[j]=min(dp[j],dp[j-tta[i]]+1);
		}
	}//endfor
	cout<<dp[n]<<endl;
	}//endwhile
	return 0;
}

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

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

int solve(int n, int count){

  if(!n) return 0;
  if(n <= 0 || !count) return INF;
  if(memo[n][count]) return memo[n][count];

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

  return memo[n][count] = 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(n, 5), solve2(i);

  while(cin >> n, n)
    cout << solve(n, 5) << " " << solve2(n) << endl;
}

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

int p[1111111];
int memo[1111111];
int memo2[1111111];

int solve(int n){
  
  if(!n) return 0;
  if(~memo[n]) return memo[n];

  int ans = INF;
  for(int i=199;i>0;i--) if(n >= p[i]) ans = min(ans, solve(n-p[i])+1);
  
  return memo[n] = ans;
}

int solve2(int n){
  
  if(!n) return 0;
  if(~memo2[n]) return memo2[n];

  int ans = INF;
  for(int i=199;i>0;i--) if(p[i]&1 && n >= p[i]) ans = min(ans, solve2(n-p[i])+1);

  return memo2[n] = ans;
}

int main(){
  
  int n;
  
  memset(memo, -1, sizeof(memo));
  memset(memo2, -1, sizeof(memo2));

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

}

C++: #include <bits/stdc++.h>
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 long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    VI p;
    FOR(i,1,1000){
        if(i*(i+1)*(i+2)/6 > 1e6) break;
        p.push_back(i*(i+1)*(i+2)/6);
    }

    VI dp(1e6,INT_INF);
    dp[0] = 0;
    for(int i : p){
        for(int j = i; j < 1e6; j++) chmin(dp[j], dp[j-i]+1);
    }
    VI dp1(1e6,INT_INF);
    dp1[0] = 0;
    for(int i : p){
        if(i%2 == 0) continue;
        for(int j = i; j < 1e6; j++) chmin(dp1[j], dp1[j-i]+1);
    }

    int x; cin >> x;
    while(x != 0){
        cout << dp[x] << " " << dp1[x] << en;
        cin >> x;
    }
    return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0; i < (n); i++)

const int MAX_N = 1000000;
const int INF = 10000000;

int main() {
  vector<int> simen, odd_simen;

  int n = 1, nv = 1;
  while (nv <= MAX_N) {
    simen.push_back(nv);
    if (nv % 2 == 1) odd_simen.push_back(nv);
    n++;
    nv = n*(n+1)*(n+2) / 6;
  }
  vector<int> dp(MAX_N + 1, INF);
  vector<int> odd_dp(MAX_N + 1, INF);
  dp[0] = odd_dp[0] = 0;

  for (int i = 1; i <= MAX_N; i++) {
    for(int j = 0; j < simen.size(); j++) {
      if (i < simen[j]) break;
      dp[i] = min(dp[i], dp[i - simen[j]] + 1);
    }
    for(int j = 0; j < odd_simen.size(); j++) {
      if (i < odd_simen[j]) break;
      odd_dp[i] = min(odd_dp[i], odd_dp[i - odd_simen[j]] + 1);
    }
  }

  cout << nv << endl;
  while (true) {
    int m;
    cin >> m;
    if (m == 0) break;

    cout << dp[m] << " " << odd_dp[m] << endl;
  }
  return 0;
}