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 <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define INF (2 << 28)
#define fr first
#define sc second
using namespace std;

#define MAX 1000000

typedef pair< int, int > iP;
typedef pair< iP, int > iiP;

int dp1[MAX * 2 + 1], dp2[MAX * 2 + 1];

int main(){
  
  fill_n(dp1, MAX * 2 + 1, INF);
  fill_n(dp2, MAX * 2 + 1, INF);
  vector< int > num;
  for(int i = 1; i <= 185; i++) {
    num.push_back(i * (i + 1) * (i + 2) / 6);
    dp1[num[num.size() - 1]] = 1;
    if((i * (i + 1) * (i + 2) / 6) % 2) 
      dp2[num[num.size() - 1]] = 1;
  }

  for(int i = 1; i <= MAX; i++) {
    for(int j = 0; j < num.size() && i + num[j] <= MAX; j++) {
      dp1[i + num[j]] = min(dp1[i] + 1, dp1[i + num[j]]);
    }
  }
 
  for(int i = 1; i <= MAX; i++) {
    for(int j = 0; j < num.size() && i + num[j] <= MAX; j++) {
      if(num[j] % 2) dp2[i + num[j]] = min(dp2[i] + 1, dp2[i + num[j]]);
    }
  }

  int N;
  while(cin >> N, N) {
    cout << dp1[N] << " " << dp2[N] << endl;
  }
}

C++: /*
2017_04_13_AC
?????????DP??????????????£????????????????????¨??£??????????¨???????:2*10^8????????§???????????????
*/

#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

/*dp[i]: ??´??°i????§??????§??????????°??????£?????¢?????°????????°*/
int dp1[1000005], dp2[1000005];
void makeDP(){
  vector<int> v1;
  vector<int> v2;
  int tn = 1;
  while(1){
      int tmp = tn*(tn+1)*(tn+2)/6;
      if(tmp < 1000000){
        v1.push_back(tmp);
        if(tmp % 2 != 0) v2.push_back(tmp);
      }else{
        break;
      }
      tn++;
  }
  /*1?????£?????¢?????°????????§??????????????????????????°??????????????°??§?§??????????*/
  REP(i,0,1000005) dp1[i] = i, dp2[i] = i;
  REP(i,1,v1.size()){
    REP(j,0,1000005){
      if(j-v1[i] >= 0) dp1[j] = min(dp1[j], dp1[j-v1[i]] + 1);
    }
  }
  REP(i,1,v2.size()){
    REP(j,0,1000005){
      if(j-v2[i] >= 0) dp2[j] = min(dp2[j], dp2[j-v2[i]] + 1);
    }
  }
}

int main() {

  makeDP();

  int N;
  while(1){
    cin>>N;
    if(N==0) break;
    cout<<dp1[N]<<" "<<dp2[N]<<endl;
  }

  return 0;
}

C++: #include<bits/stdc++.h>
#define INF 1e9
using namespace std;
vector<int> dp(1e6);
vector<int> dp2(1e6);
int num[200];
void solve(){
    for(int i=1;i<200;i++){
        for(int j=0;j<1e6;j++){
            if(j>=num[i]){
                dp[j]=min(dp[j-num[i]]+1,dp[j]);
            }
        }
    }
    for(int i=1;i<200;i++){
        if(num[i]%2==0) continue;
        for(int j=0;j<1e6;j++){
            if(j>=num[i]){
                dp2[j]=min(dp2[j-num[i]]+1,dp2[j]);
            }
        }
    }
}
int main(){
    fill(dp.begin(),dp.end(),INF);
    fill(dp2.begin(),dp2.end(),INF);
    dp[0]=0;
    dp2[0]=0;
    for(int i=1;i<200;i++){
        num[i]=i*(i+1)*(i+2)/6;
    }
    int n;
    solve();
    while(cin>>n,n){
        cout<<dp[n]<<" "<<dp2[n]<<endl;
    }
    
    return 0;
}

C++: #include <iostream>

using namespace std;
#define MAX 1000000
#define INF 1000000000

int dp1[MAX + 1], dp2[MAX + 1];

int main()
{
    for (int i = 1; i < MAX; i++)
    {
        dp1[i] = INF;
        dp1[i] = INF;
    }
    for (int n = 1; n * (n + 1) * (n + 2) <= MAX; n++)
    {
        int a = n * (n + 1) * (n + 2);
        for (int i = a; i < MAX; i++)
        {
            dp1[i] = min(dp1[i], dp1[i - a] + 1);
        }
        if (a % 2 == 0)
            continue;
        for (int i = a; i < MAX; i++)
        {
            dp2[i] = min(dp2[i], dp2[i - a] + 1);
        }
    }

    while (1)
    {
        int n;
        cin >> n;
        if (n == 0)
            break;
        cout << dp1[n] << "" << dp2[n] << endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define ALL( a )        (a).begin(), (a).end()             

const int MAX = 1000000;

int	dp[MAX] = {};
int oddp[MAX];

int main() {
	REP( i, MAX ) dp[i] = oddp[i] = i;

	int i = 2, x = 4;
	while( x < MAX ) {
		for( int j = 0; j + x < MAX; j++ ) {
			dp[j + x] = min( dp[j + x], dp[j] + 1 );
			if( x % 2 == 1 ) {
				oddp[j + x] = min( oddp[j + x], oddp[j] + 1 );
			}

//			if( j + x > ( i + 8 ) * ( i + 9 ) * ( i + 10 ) / 2 ) break;
		}
		i++;
		x = i * ( i + 1 ) * ( i + 2 ) / 6;
	}


	int n;
	while( 1 ) {
		cin >> n; if( n == 0 ) break;
		cout << dp[n] << " " << oddp[n] << endl;
	}

	
}