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>

using std::cout;
using std::cin;
using std::endl;
using std::vector;

vector<int> make_table(vector<int> v) {
    vector<int> dp(1000000, 0);
    dp[1] = 1;
    int j;
    int min;
    for (int i = 2; i < dp.size(); i++) {
        j = 0;
        min = 1e09;
        while (i >= v[j]) {
            if (min > dp[i - v[j]]) {
                min = dp[i - v[j]];
            }
            j++; 
        }
        dp[i] = min + 1;
    }
    return dp; 
}

int main(void) {
    vector<int> all;
    vector<int> odd;

    int tetra = 0;
    int times = 1;
    while (1) {
        tetra = times * (times + 1) * (times + 2) / 6;
        all.push_back(tetra);
        if (tetra % 2 == 1) {
            odd.push_back(tetra);
        }
        times++;
        if (tetra > 1000000) {
            break;
        }
    }
    vector<int> dp_all = make_table(all);
    vector<int> dp_odd = make_table(odd);
    int input;
    while (1) {
        cin >> input;
        if (input == 0) {
            break;
        }
        cout << dp_all[input] << " " << dp_odd[input] << endl;
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define MAX 1000000

int calc(int n) { return n*(n + 1)*(n + 2) / 6; }
int p[200];
int p1[200];
int dp[MAX] = { 0 };
int dp1[MAX] = { 0 };

int func(int n, int P[], int DP[])
{
	if (n <= 0)return MAX;
	if (DP[n] != 0)return DP[n];
	else
	{
		int min_t = MAX;
		int i = 0;
		while (1)
		{
			if (P[i] <= n && n <= P[i + 1])break;
			if (P[i] == 1004731)
			{
				i--;
				break;
			}
			i++;
		}
		for (int t = i; t>0; t--)
		{
			if (min_t > func(n - P[t], P, DP) + 1)
			{
				min_t = func(n - P[t], P, DP) + 1;
			}
		}
		DP[n] = min_t;
		return DP[n];
	}
}

int main()
{
	int index = 1;
	FOR(i, 1, 200)
	{
		int temp = calc(i);
		if (temp > 1004731)break;
		p[i] = temp;
		dp[p[i]] = 1;
		if (temp % 2 == 1)
		{
			p1[index] = temp;
			dp1[p1[index]] = 1;
			index++;
		}
	}
	while (1)
	{
		int N;
		cin >> N;
		if (N == 0)break;
		cout << func(N, p, dp) << " " << func(N, p1, dp1) << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int MAX = 1e6+10;

int func(ll x) {
  return x*(x+1)/2*(x+2)/3;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<int> dp1(MAX, INF), dp2(MAX, INF);
  dp1[0] = dp2[0] = 0;
  for (int i = 1; i < MAX; i++) {
    for (int j = 1; ; j++) {
      ll num = func(j);
      if (i-num < 0)
        break;
      chmin(dp1[i], dp1[i-num]+1);
      if (num%2)
        chmin(dp2[i], dp2[i-num]+1);
    }
  }
  int tmp;
  while (cin >> tmp && tmp)
    cout << dp1[tmp] << ' ' << dp2[tmp] << '\n';
  return 0;
}

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

vector<int>data[2];
int mins;

int check(int i,int sum,int cnt,int tar)
{
  if(sum==0)
    {
      if(cnt<mins)
        mins=cnt;
      return mins;
    }
  if(sum<0 || i<0 || cnt>=mins)
    return mins;
  check(i,sum-data[tar][i],cnt+1,tar);
  check(i-1,sum,cnt,tar);
  return mins;
}

void set()
{
  int sum=0;
  int num=0;
  for(int i=1;sum<=1000000;i++)
    {
      num=i+num;
      sum+=num;
      data[0].push_back(sum);
      if(sum%2==1)
        data[1].push_back(sum);
    }
}


int main()
{
  set();
  int n;
  for(;cin>>n,n;)
    {
      int a,b;
      mins=99999999;
      a=check(data[0].size()-1,n,0,0);
      mins=99999999;
      b=check(data[1].size()-1,n,0,1);

      cout<<a<<" "<<b<<endl;
    }


}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

int main(){
    const int max_n = 1000002;
    vector<int> nums;
    for(int i=1;i<200;i++){
        int n = i * (i + 1) * (i + 2) / 6;
        if(max_n < n) break;
        nums.push_back(n);
    }

    vector<int> all(max_n, max_n);
    vector<int> odd(max_n, max_n);

    all[0] = 0;
    odd[0] = 0;
    for(int i=0;i<max_n;i++){
        for(int n : nums){
            if(max_n <= i + n) break;
            all[i+n] = min(all[i+n], all[i] + 1);
        }
        for(int n : nums){
            if(max_n <= i + n) break;
            if(n % 2 == 1) odd[i+n] = min(odd[i+n], odd[i] + 1);
        }
    }

    while(true){
        int N;
        cin >> N;
        if(N == 0) break;
        cout << all[N] << " " << odd[N] << endl;
    }

    return 0;
}