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;
const int M = 179,R = 1000001;
int dp1[R],dp2[R],T[M];

void solve(void) {
    for (int i = 1; i < R; i++) dp1[i] = dp2[i] = R;
    for (int i = 1; i <= M+1; i++) T[i-1] = i*(i+1)*(i+2)/6;
    for (int i = 0; i < M; i++) {
        int t = T[i];
        for (int j = t; j < R; j++) {
            if (dp1[j-t] < R) dp1[j] = min(dp1[j], dp1[j-t]+1);
            if (t%2 == 0) continue;
            if (dp2[j-t] < R) dp2[j] = min(dp2[j], dp2[j-t]+1);
        }
    }
}

int main(void){
    solve();
    while (1) {
        int N;
        cin >> N;
        if (N == 0) break;
        printf("%d %d\n",dp1[N],dp2[N]);
    }
    return 0;    
}

C++: #include<iostream>
using namespace std;
int main(){
  int i,j,k,t=0,a[200]={},b[200]={},c[1000005]={1000000},d[1000005]={1000000};
  for(i=1;i<201;i++) {
    a[i-1]=i*(i+1)*(i+2)/6;
    if(m[i-1]%2==1)b[t++]=m[i-1];
  }
  for(i=c[0]=d[0]=0;i<200;i++) {
    for(j=a[i];j<1000005;j++){
      c[j]=min(c[j],c[j-a[i]]+1);
    }
  }
  for(i=0;i<t;i++) {
    for(j=b[i];j<1000005;j++){
      d[j]=min(d[j],d[j-b[i]]+1);
    }
  }
  while(cin>>n,n)cout<<c[n]<<" "<<b[n]<<endl;
return 0;
}

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

#define MAX 1000000
using ll = long long;

int main(){
    vector<ll> v;
    vector<ll> odd_v;

    for(ll i = 1; i < MAX; ++i){
        ll num = i * (i + 1) * (i + 2) / 6;
        v.push_back(num);
        if(num & 1) odd_v.push_back(num);
    }

    int dp[MAX];
    int odd_dp[MAX];
    fill(dp, dp+MAX, INT_MAX);
    fill(odd_dp, odd_dp+MAX, INT_MAX);
    dp[0] = 0;
    odd_dp[0] = 0;

    for(int i = 0; i < MAX; ++i){
        for(int j = 0; j < v.size(); ++j){
            if(i - v[j] >= 0) dp[i] = min(dp[i - v[j]] + 1, dp[i]);
            else break;
        }

        for(int j = 0; j < odd_v.size(); ++j){
            if(i - odd_v[j] >= 0) odd_dp[i] = min(odd_dp[i - odd_v[j]] + 1, odd_dp[i]);
            else break;
        }
    }

    while(true){
        int n; cin >> n;
        if(!n) break;

        cout << dp[n] << ' ' << odd_dp[n] << endl;
    }

    return EXIT_SUCCESS;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
vector<int> x,y;
const int inf=1e6;
int a[inf],b[inf];
int main(){
	for(int i=1;;i++){
		int p=i*(i+1)*(i+2)/6;
		if(p>=inf) break;
		x.pb(p);
		if(p%2) y.pb(p);
	}
	rep(i,inf) a[i]=b[i]=inf;
	a[0]=0,b[0]=0;
	for(int p:x){
		rep(i,inf-p){
			a[i+p]=min(a[i+p],a[i]+1);
		}
	}
	for(int p:y){
		rep(i,inf-p){
			b[i+p]=min(b[i+p],b[i]+1);
		}
	}
	while(true){
		int n;
		cin>>n;
		if(n==0) break;
		cout<<a[n]<<" "<<b[n]<<endl;
	}
}

C++: #include <stdio.h>
#include <stack>
#include <math.h>

using namespace std;

int main(){

	int n,table[183];
	int* dp = new int[1000000];
	int* odd_dp = new int[1000000];

	for(int i=0; i < 183; i++)table[i] = i*(i+1)*(i+2)/6;

	for(int i=0; i < 1000000; i++){
		odd_dp[i] = 20000000;
		dp[i] = 20000000;
	}

	dp[0] = 0;
	dp[1] = 1;

	odd_dp[0] = 0;
	odd_dp[1] = 1;

	for(int i = 2; i < 1000000; i++){
		for(int k = 1; table[k] <= i; k++){
			dp[i] = (dp[i] <= dp[i-table[k]]+1)?dp[i]:dp[i-table[k]]+1;
			if(table[k]%2 == 1){
				odd_dp[i] = (odd_dp[i] <= odd_dp[i-table[k]]+1)?odd_dp[i]:odd_dp[i-table[k]]+1;
			}
		}
	}


	while(true){
		scanf("%d",&n);
		if(n == 0)break;

		printf("%d %d\n",dp[n],odd_dp[n]);
	}

    return 0;
}

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]!=INF)return dp[v];
	if(v==0)return 0;
	int cnt=INF;
	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]!=INF)return dp2[v];
	if(v==0)return 0;
	int cnt=INF;
	int j=1,i;
	while(j*(j+1)*(j+2)/6<=v)j++;
	j--;
	for(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]=INF;
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		printf("%d %d\n",func(n),func2(n));
	}
	return 0;
}