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 <vector>

using namespace std;

int m;
int f(int n) { return n*(n+1)*(n+2)/6; }
vector<int> l1, l2;

void r(int n, int step, vector<int> &l, int p) {
  if(step+1 >= m) return;
 
  for(int i=p; i>=0; i--) {
    int n2 = n-l[i];
    if(n2<0) continue;
    if(n2==0) {
      m = step+1;
      return;
    }
    if(n2>0) {
      r(n2, step+1, l, i);
    }
  }
  
}

int main() {
  while(1) {
    vector<int> l1, l2;
    int n;

     cin >> n;
     if(n==0) break;
    
    // not over
    for(int i=1; true; i++) {
      int mm = f(i);
      if(mm>n) break;
      l1.push_back(mm);
      if(mm&1) l2.push_back(mm);
    }

    m = n;
    r(n, 0, l1, l1.size()-1);
    cout << m;

    cout << ' ';
    
    m = n;
    r(n, 0, l2, l2.size()-1);
    cout << m;

    cout << "\n";

    
  }
  return 0;
}

C++: #include<iostream>
#include<vector>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
int dp[2][1000001];
int main()
{
	int n;
	for (int i = 0; i < 2; i++)
	{
		for (int j = 0; j <= 1000000; j++)
		{
			if (j == 0)dp[i][j] = 0;
			else dp[i][j] = 999999;
		}
	}
	vector<int> v;
	for (int i = 1;;i++)
	{
		int k = i * (i + 1) * (i + 2) / 6;
		if (k > 1000000)break;
		v.push_back(k);
	}
	while (cin >> n && n != 0)
	{
		for (int i = 0; i <= 1000000; i++)
		{
			for (int j = 0; j < v.size(); j++)
			{
				if (i + v[j] > n)break;
				dp[0][i + v[j]] = min(dp[0][i + v[j]],dp[0][i] + 1);
			}
		}
		for (int i = 0; i <= 1000000; i++)
		{
			for (int j = 0; j < v.size();j++)
			{
				if (v[j] % 2 == 0)continue;
				if (i + v[j] > n)break;
				dp[1][i + v[j]] = min(dp[1][i + v[j]], dp[1][i] + 1);
			}
		}
		cout << dp[0][n] << " " << dp[1][n] << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>

using namespace std;

int main(){
    int n;
    vector<int>v;
    for(int i=1;(i*(i+1)*(i+2))/6 < 1e6;++i){
        v.push_back((i*(i+1)*(i+2))/6);
    }
    while(cin>>n,n){
        vector<int>dp(1e6,1e9);
        vector<int>dp1(1e6,1e9);
        dp[0]=0;
        dp1[0]=0;
        for(int i=0;i<=n;++i){
            for(int j=0;j<v.size();++j){
                if(i+v[j]>=1e6)break;
                dp[i+v[j]]=min(dp[i]+1,dp[i+v[j]]);
                if(v[j]%2==0)continue;
                dp1[i+v[j]]=min(dp1[i]+1,dp1[i+v[j]]);
            }
        }
        cout<<dp[n]<<" "<<dp1[n]<<endl;
    }
}

C++: #include <iostream>
using namespace std;

const int MAX_NUM = 1000000;
const int INF = 1000000000;

int table[2][MAX_NUM];
int tet[2][1000];

int calc(int num,int m)
{
    if(table[m][num]!=INF) {
        return table[m][num];
    } else {
        for(int i=1; tet[m][i]<num; i++) {
            table[m][num]=min(table[m][num],calc(num-tet[m][i],m)+1);
        }
        return table[m][num];
    }
}

int main()
{
    for(int i=0; i<MAX_NUM; i++) {
        table[0][i] = INF;
        table[1][i] = INF;
    }

    for(int i=1; i*(i+1)*(i+2)/6<MAX_NUM; i++) {
        int t=i*(i+1)*(i+2)/6;
        table[0][t] = 1;
        tet[0][i] = t;

        if(t%2 == 1) {
            table[1][t] = 1;
            tet[1][i] = t;
        }
    }

    int in;
    while(cin>>in && in!=0) {
        cout<<calc(in,0)<<" "<<calc(in,1)<<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 > 100000) {
			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);
		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>
#include<algorithm>
using namespace std;
int dp1[1000001],dp2[1000001];
int main(){
  int c1[100000],c2[100000],i,m,p=0,k;
  for(i=0;i*(i+1)*(i+2)/6<=1000000;i++){
    c1[i]=i*(i+1)*(i+2)/6;
    if(c1[i]%2==1){
      c2[p]=c1[i]; 
      p++; 
    }
  }
  for(int j=0;j<=1000000;j++){
    dp1[j]=j;
    dp2[j]=j;
    for(int k=0;k<i;k++){
      if(j-c1[k]>=0)dp1[j]=min(dp1[j],dp1[j-c1[k]]+1);
      if(k<p){
	if(j-c2[k]>=0){
	dp2[j]=min(dp2[j],dp2[j-c2[k]]+1);
       }
      }
    }
  }

  while(1){
  cin >>m;
  if(m==0)break;

  cout << dp1[m]<<" "<<dp2[m]<<endl;
  }
 return 0;
}