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<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;
int n;
int dp[5000001];
int dp2[5000001];

int func(int v){
	if(dp[v]!=11451419)return dp[v];
	if(v==0)return 0;
	int cnt=11451419;
	int j=1;
	while(j*(j+1)*(j+2)/6<=v)j++;
	j--;
	for(int i=j;i>=1;i--){
		cnt=min(cnt,func(v-i*(i+1)*(i+2)/6));
	}
	return (dp[v]=cnt+1);
}

int func2(int v){
	if(dp2[v]!=11451419)return dp2[v];
	if(v==0)return 0;
	int cnt=11451419;
	int j=1;
	while(j*(j+1)*(j+2)/6<=v)j++;
	j--;
	for(int i=j;i>=1;i--){
		if((i*(i+1)*(i+2)/6)%2!=1)continue;
		cnt=min(cnt,func2(v-i*(i+1)*(i+2)/6));
	}
	return (dp2[v]=cnt+1);
}

int main(void){
	for(int i=1;i<=2000000;i++)dp[i]=dp2[i]=11451419;
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		printf("%d %d\n",func(n),func2(n));
	}
	return 0;
}

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

int D[182] = {} ; // 10^6 越え → 181
int dp_map[2][1000002] = {} ;

void t(){
	for( int i=1 ; i<182 ; i++ ){
		D[i] = i * (i+1) * (i+2) / 6 ;
	}
}

int cal_2( int x , int c ){
	if( x==0 ) return 0 ;
	else{
		if( dp_map[0][x] != 0 ) return dp_map[0][x] ;
		else return x/D[c] + cal_2( x%D[c] , c-1 ) ;
	}
}

int cal( int m , int q ){
	int ans = m ;
	for( int j=q ; j>1 ; j-- ){
		ans = min( ans , cal_2( m , j ) ) ;
	}
	return ans ;
}

int cal_odd_2( int x , int c ){
	if( x==0 ) return 0 ;
	else{
		if( D[c]%2 == 0 ) return cal_odd_2( x , c-1 ) ;
		else{
			if( dp_map[1][x] != 0 ) return dp_map[1][x] ;
			else return x/D[c] + cal_odd_2( x%D[c] , c-1 ) ;
		}
	}
}

int cal_odd( int m , int q ){
	int ans_2 = m ;
	for( int j=q ; j>1 ; j-- ){
		ans_2 = min( ans_2 , cal_odd_2( m , j ) ) ;
	}
	return ans_2 ;
}

void dp(){
	int p = 1 ;
	for( int i=1 ; i<=1000000 ; i++ ){
		if( p < 182 && i >= D[p] ) p++ ;
		dp_map[0][i] = cal(i,p) ;
		dp_map[1][i] = cal_odd(i,p) ;
	}
}

int main(){
	
	t() ;
	dp() ;
	
	int n ;
	
	while( cin >> n , n ){
		cout << dp_map[0][n] << ' ' ;
		cout << dp_map[1][n] << endl ;
	}
	
return 0 ;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int INF = 100000000;
int main(){
  int n, M = 1000000;
  vector<int> T, T_odd, A(M,INF), odd(M,INF);
  int t = 1, k = 3;
  A[0] = 0;
  odd[0] = 0;
  T.push_back(1);
  T_odd.push_back(1);
  while(t < 1000000){
    T.push_back(t);
    if (t%2) T_odd.push_back(t);
    ++k;
    t *= k;
    t /= (k-3);
  }
  odd.push_back(M);
  for(int i = 0; i < T.size(); ++i){
    for(int j = 1; j <= 5; ++j){
      for(int k = 0; k < T[i] && k+T[i]*j < M; ++k){
	A[k+T[i]*j] = min(A[k+T[i]*j],A[k]+j);
      }
    }
  }
  for(int i = 0; i < T_odd.size()-1; ++i){
    for(int j = 1; j < 100; ++j){
      for(int k = 0; k < T_odd[i] && k+T_odd[i]*j < M; ++k){
	odd[k+T_odd[i]*j] = min(odd[k+T_odd[i]*j],odd[k]+j);
      }
    }
  }
  while(cin >> n, n){
    cout << A[n] << " " << odd[n] << endl;
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define N 1000100
int dp[N], odd[N];
#define reps(i,n,m) for(int i=int(n);i<int(m);i++)
#define rep(i,n) reps(i,0,n)
int func(int x) {
	return x*(x+1)*(x+2)/6;
}
int main() {
	int num = 1;
	int a;
	rep(i,N) {
		dp[i]=N;
		odd[i]=N;
	}
	while((a=func(num)) < N){
		dp[a] = 1;
		if(a%2==1) odd[a]=1;
		reps(i,1,N-a) {
			if(dp[i]!=N) {
				dp[i+a] = min(dp[i+a], dp[i]+1);
			}
			if(a%2==1 && odd[i]!=N) {
				odd[i+a]=min(odd[i+a], odd[i]+1);
			}
		}
		num++;
	}
	int x;
	while(cin>>x&&x!=0) {
		cout<<dp[x]<<" "<<odd[x]<<endl;
	}
	return 0;
}

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

C++: #include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef unsigned long ll;
#define MAX_N 1000001
#define INF 1000000000

int tetrahedron(int num){
	return num*(num+1)*(num+2)/6;
}


int main()
{
	vector<int> dp(MAX_N,INF),oddDp(MAX_N,INF);
	dp[0] = oddDp[0] = 0;
	int num = 0;
	for(int i = 1; num < MAX_N; i++){
		num = tetrahedron(i);
		for(int j = num; j < MAX_N; j++){
			dp[j] = min(dp[j],dp[j-num]+1);
			if(num % 2 == 1){
				oddDp[j] = min(oddDp[j],oddDp[j-num]+1);
			}
		}
	}
	int n;
	cin>>n;
	while( n != 0){
		cout<<dp[n]<<" "<<oddDp[n]<<endl;
		cin>>n;
	}
	return 0;
}