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>

using namespace std;

int main() {
	int N;
	int v[200];
	static int ansA[1000000], ansB[1000000];
	for (int i = 0; i<=200; i++) v[i] = i * (i + 1)*(i + 2) / 6;
	ansA[0] = ansB[0] = 0;
	for (int i = 1; i<1000000; i++) {
		ansA[i] = ansB[i] = i;
		for (int j = 0; i - v[j] >= 0; j++) {
			ansA[i] = min(ansA[i], ansA[i - v[j]] + 1);
			if (v[j] % 2 == 1)
				ansB[i] = min(ansB[i], ansB[i - v[j]] + 1);
		}
	}
	while (cin >> N, N)
		cout << ansA[N] << " " << ansB[N] << endl;
}

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;
	}

	
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int n;

vector<int> table;

int dp[2][100][1001000];

int main() {
	for (int i = 1; i*(i + 1)*(i + 2) / 6 <= 100000; i++) {
		table.push_back(i*(i + 1)*(i + 2) / 6);
	}
	REP(i, 2) {
		REP(j, 100) {
			REP(k, 1001000)dp[i][j][k] = INF;
		}
	}
	dp[0][0][0] = 0;
	dp[1][0][0] = 0;

	REP(i, table.size()) {
		int num = table[i];
		REP(j, 1000000 + 1) {
			if (j + num <= 1000000) {
				dp[0][i + 1][j + num] = min(dp[0][i][j] + 1, dp[0][i][j + num]);
				if (i % 2 == 0) {
					dp[1][i + 1][j + num] = min(dp[1][i][j] + 1, dp[1][i][j + num]);
				}
			}
		}
	}

	while (cin >> n&&n) {
		cout << dp[0][table.size()][n] << " "
			<< dp[0][table.size()][n] << endl;
	}
}

C++: #include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX

int inf = 1000005;

int ok[1000010]={};
int dp[1000010]={};
int dp2[1000010]={};

int main(void){
	
	reg(i,1,1000){
		int no=(i*(i+1)*(i+2))/6;
		if(no>inf)break;
		ok[no]=1;
	}
	
	rep(i,inf)dp[i]=dp2[i]=inf;
	
	rep(i,inf){
		if(!ok[i])continue;
		//printf("ok! %d\n",i);
		dp[i]=1;
		rep(j,inf){
			int to=i+j;
			if(to>inf)continue;
			dp[to]=min(dp[to],dp[j]+1);
		}
	}
	
	rep(i,inf){
		if(!ok[i] || i%2==0)continue;
		//printf("ok! %d\n",i);
		dp2[i]=1;
		rep(j,inf){
			int to=i+j;
			if(to>inf)continue;
			dp2[to]=min(dp2[to],dp2[j]+1);
		}
	}
	
	
	for(;;){
		int p;
		scanf("%d",&p);
		if(!p)break;
		printf("%d %d\n",dp[p],dp2[p]);
	}
		
	return 0;
}

C++: #include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <vector>

#define el endl
#define fd fixed
#define INF INT_MAX/2-1
#define pb push_back

using namespace std;

#define MAX 1000000

void makelist(int *list, int x) {
  for (int i = x; i < MAX; i++) {
    list[i] = min(list[i], list[i-x]+1);
  }
}

int main() {
  int list1[MAX], list2[MAX], a, n;
  for (int i = 1; i < MAX; i++) {
    list1[i] = list2[i] = INF;
  }
  for (int i = 1; ; i++) {
    a = i*(i+1)*(i+2)/6;
    if (a >= MAX) break;
    makelist(list1, a);
    if (a & 1) makelist(list2, a);
  }
  while (cin >> n, n) {
    cout << list1[n] << " " << list2[n] << el;
  }
}