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>
#include <algorithm>

using namespace std;

#define max 1000000

//正四面体数を返す
int getRt(int n){
	return (n) * (n + 1) * (n + 2) / 6;
}
int min(int p, int q) {
	if( p > q ) return q;
	return p;
}

int main(void){
//	FILE* fp_in = freopen("data.txt", "r", stdin);
	
	vector<int> Rtlist;
	vector<int> Rtlist2;
	vector<int> vn;
	vector<int> vo;
	//正四面体数テーブル
	for(int i = 1; getRt(i) <= max; i++) {
		Rtlist.push_back( getRt(i) );
		if( getRt(i) % 2 != 0 ) Rtlist2.push_back( getRt(i) );
	}
	//答えのテーブル
	for(int i = 0; i <= max; i++) {
		vn.push_back(i);
		vo.push_back(i);
	}
	for(int i = 0; i < Rtlist.size(); i++)
		vn.at( Rtlist.at(i) ) = 1;
	for(int i = 0; i < Rtlist2.size(); i++)
		vo.at( Rtlist2.at(i) ) = 1;
	
	//動的計画法を用いる
	/*
		正四面体数p
		vn(n+p) = min( vn(n) + 1, vn(n+p) ) 
	*/
	for(int i = 1; i <= max; i++ )
		for(int j = 0; j < Rtlist.size() && i + Rtlist.at(j) <= max ; j++)
			vn.at( i + Rtlist.at(j) ) = min( vn.at( i ) + 1, vn.at( i + Rtlist.at(j) ) );
	for(int i = 1; i <= max; i++ )
		for(int j = 0; j < Rtlist2.size()  && i + Rtlist2.at(j) <= max ; j++)
			vo.at( i + Rtlist2.at(j) ) = min( vo.at( i ) + 1, vo.at( i + Rtlist2.at(j) ) );

	
	while(1){
		int n, tmp;
		cin >> n;
		if( n == 0 ) break;

		cout << vn.at(n) << " " << vo.at(n) << endl;

	}

//	while(1){}

	return 0;
}

C++: #include "bits/stdc++.h"
using namespace std;
#define MAXN 1000000
#define ll long long

ll dp[MAXN + 1];
ll Odp[MAXN + 1];

int main() {
	cin.tie(0); ios::sync_with_stdio(false);

	for (int i = 0; i < MAXN + 1;i++) {
		dp[i] = i;
		Odp[i] = i;
	}
	// n := n???????????£?????¢???
	// p := ??£?????¢?????°
	// n = 1 p = 1 ?????´???????????????
	// n = 2, p = 2*3*4/6 = 4??????
	ll p = 4;
	for (int n = 2; p <= MAXN;n++) {
		 p = n*(n + 1)*(n + 2) / 6;
		 //cout << n << " " << p << endl;
		for (int i = 0; i + p <= MAXN;i++) {
			dp[i + p] = min(dp[i + p], dp[i] + 1);
			if (p % 2 == 1) {
				Odp[i + p] = min(Odp[i + p], Odp[i] + 1);
			}
		}
	}
	int N;
	while (cin >> N,N) {
		cout << dp[N] << " " << Odp[N] << endl;
	}

}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define mp make_pair
typedef pair<int,int> pi;

const int inf=1<<28;
const int MX=1000000;

int tri[1000],ntri;
int dp[MX],dpOdd[MX];

int main(){
	
	ntri=0;
	for(;;ntri++)
	{
		tri[ntri]=ntri*(ntri+1)*(ntri+2)/6;
		if(tri[ntri]>=MX)break;
	}
	
	rep(i,MX)dp[i]=dpOdd[i]=inf;
	dp[0]=dpOdd[0]=0;
	int mx=0;
	rep(i,5)rep(j,mx+1)
	{
		rep(k,ntri)
		{
			if(j+tri[k]>=MX)break;
			if(tri[k]%2==1)dpOdd[j+tri[k]]=min(dpOdd[j+tri[k]],dpOdd[j]+1);
			dp[j+tri[k]]=min(dp[j+tri[k]],dp[j]+1);
			mx=max(mx,j+tri[k]);
			mx=min(mx,MX-1);
		}
	}
	
	int n;
	while(cin>>n,n)cout<<dp[n]<<" "<<dpOdd[n]<<endl;
	
	return 0;
}

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

using namespace std;

int const MAX = 1000001;
int const INF = 1<<29;
int dpa[MAX+1];
int dpo[MAX+1];

int main() {
  
  
  fill(dpa, dpa+MAX, INF);
  fill(dpo, dpo+MAX, INF);
  
  dpa[0] = dpo[0] = 0;
  
  for(int i=1; ; i++) {
    int n = i*(i+1)*(i+2)/6;
    if(n > MAX) break;
    for(int j=n; j<=MAX; j++) {
      dpa[j] = min(dpa[j], dpa[j-n]+1);
      if(n%2) {
	dpo[j] = min(dpo[j], dpo[j-n]+1);
      }
    }
  }
  
  for(int N; cin >> N && N;) {
    cout << dpa[N] << ' ' << dpo[N] << endl;
  }
  
  
  return 0;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    int i,j;
    int n = 1e6;
    int tmpnmax = 200;
    vector<ll> sankaku(tmpnmax);
    for(i = 0;i < tmpnmax;++i){
        sankaku.at(i) = i+1;
    }
    for(i = 1;i < tmpnmax;++i){
        sankaku.at(i) += sankaku.at(i-1);
    }
    vector<ll> simen = sankaku;
    for(i = 1;i < tmpnmax;++i){
        simen.at(i) += simen.at(i-1);
    }
    vector<ll> dp1(n+1,1e9);
    vector<ll> dp2(n+1,1e9);
    dp1.at(0) = 0;
    dp2.at(0) = 0;
    for(i = 1;i <= tmpnmax;++i){
        if(simen.at(i-1) > n) break;
        for(j = 0;j + simen.at(i-1) <= n;++j){
            dp1.at(j + simen.at(i-1)) = min(dp1.at(j) + 1, dp1.at(j + simen.at(i-1)));
            if(simen.at(i-1)%2) dp2.at(j + simen.at(i-1)) = min(dp2.at(j) + 1, dp2.at(j + simen.at(i-1)));
        }
    }
    while(true){
        int nn;
        cin >> nn;
        if(nn == 0) return 0;
        cout << dp1.at(nn) << " " << dp2.at(nn) << endl;
    }

    return 0;
}

C++: // AOJ 1167
#include<iostream>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;

typedef long long int number;

const number NMAX = 1e6 + 8;

int dp[NMAX], odp[NMAX];

int main() {
  REP(i, NMAX) {
    dp[i] = odp[i] = i;
  }
  for (number i = 2; i * (i + 1) * (i + 2) / 6 < NMAX; i++) {
    int tetr = i * (i + 1) * (i + 2) / 6;
    int limit = min(NMAX, (i + 2) * (i + 3) * (i + 4) / 6 + 8);
    for (number j = tetr; j < limit; j++) {
      dp[j] = min(dp[j], dp[j - tetr] + 1);
    }

    if (tetr % 2 != 0) {
      int limit = min(NMAX, NMAX);
      for (number j = tetr; j < limit; j++) {
        odp[j] = min(odp[j], odp[j -tetr] + 1);
      }
    }
  }

  int n;
  while (cin >> n and n) {
    cout << dp[n] << " " << odp[n] << endl;
  }
}