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;

/*sqrt<3>(NMAX)==100*/

int Nkake[100+1];
int c,maxc,max2c;

void searchA(int c,int N){
	if(maxc<=c) return;
	if(N==0){
		if(maxc>c) maxc=c;
		return;
	}
	for(int i=100;;i--){
		if(N>=Nkake[i]){
			searchA(c+1,N-Nkake[i]);
		}
		if(i<=1) return;
		if(maxc<=c) return;
	}
}

void searchB(int c,int N){
	if(max2c<=c) return;
	if(N==0){
		if(max2c>c) max2c=c;
		return;
	}
	for(int i=100;;i--){
		if(Nkake[i]%2==1&&N>=Nkake[i]){
			searchB(c+1,N-Nkake[i]);
		}
		if(i<=1) return;
		if(max2c<=c) return;
	}
}

int main(){

	int N;
	
	for(int i=1;i<=100;i++){
		Nkake[i]=i*(i+1)*(i+2)/6;
	}
	while(1){
		cin>>N;
		if(N==0) break;
		int g=N;
		int c=0;
		maxc=10000000;
		max2c=10000000;
		searchA(0,N);
		searchB(0,N);
		cout<<maxc<<" "<<max2c<<endl;
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
int main(){
    vector<int> a;
    int n = 1;
    a.pb(0);
    vector<int> b;
    int m = 1;
    b.pb(0);
    while(n * (n + 1) * (n + 2) / 6 < 1000000){
        a.pb(n * (n + 1) * (n + 2) / 6);
        if (((n * (n + 1) * (n + 2) / 6) % 2 )== 1){
            b.pb(n * (n + 1) * (n + 2) / 6);
            m++;
        }
        n++;
    }
    vector<int> dp(1000001,6);
    dp[0] = 0;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= 1000000; j++) {
            if (j - a[i] >= 0){
                dp[j] = min(dp[j],dp[j - a[i]] + 1);
            }
        }
    }

    vector<int> dp2(1000001,INF);
    dp2[0] = 0;
    for(int i = 1; i < m; i++) {
        for(int j = 1; j <= 1000000; j++) {
            if (j - b[i] >= 0){
                dp2[j] = min(dp2[j],dp2[j - b[i]] + 1);
            }
        }
    }

    while(1){
        int x;cin>>x;
        if(x == 0){
            break;
        }
        cout << dp[x] << ' ' << dp2[x] << endl;
    }
    
    return 0;
}

C++: #include <algorithm>
#include <array>
#include <iostream>
#include <limits>

using namespace std;

int main()
{
    array<int, 1000001> dp = {};
    fill(begin(dp), end(dp), numeric_limits<int>::max());
    dp[0] = 0;
    auto dp2 = dp;
    auto tetrahedral = [](int n) { return n * (n + 1) * (n + 2) / 6; };
    for (int i = 1; tetrahedral(i) < dp.size(); ++i) {
        const auto t = tetrahedral(i);
        for (int j = 0; j + t < dp.size(); ++j) {
            dp[j + t] = min(dp[j + t], dp[j] + 1);
        }
        if (t % 2 == 1) {
            for (int j = 0; j + t < dp2.size(); ++j) {
                dp2[j + t] = min(dp2[j + t], dp2[j] + 1);
            }
        }
    }

    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            return 0;
        }

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

C++: #include <iostream>

using namespace std;

typedef long long ll;


ll memo[110];
ll memo2[110];

ll calc(int n) {
  return n * (n + 1) * (n + 2) / 6;
}

int dfs(int depth, int n) {
  int ans = 9999;
  if (memo[n] != 0) return memo[n];
  for (int i = n; i >= 1; i--) {
    ll t = calc(i);
    if (n - t < 0) continue;
    if (n - t == 0) {
      memo[n] = depth;
      return depth;
    }
    ans = min(ans, dfs(depth + 1, n - t));
  }
  memo[n] = ans;
  return ans;
}

int dfs_odd(int depth, int n) {
  int ans = 9999;
  if (memo2[n] != 0) return memo2[n];
  for (int i = n; i >= 1; i--) {
    if (i % 2 == 0) continue;
    ll t = calc(i);
    if (t % 2 == 0) continue;
    if (n - t < 0) continue;
    if (n - t == 0) {
      memo2[n] = depth;
      return depth;
    }
    ans = min(ans, dfs_odd(depth + 1, n - t));
  }
  memo2[n] = ans;
  return ans;
}
  
int main() {
  int N;
  while (cin >> N, N != 0) {
    for (int i = 0; i < 110; i++) {
      memo[i] = 0;
      memo2[i] = 0;
   }
    cout << dfs(1, N) << " " << dfs_odd(1, N) << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <map>
#include <vector>
#include <utility>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vec vector
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

using namespace std;

int main(){
    vector<int> v,oddv;
    for(ll i=1;;i++){
        if(i*(i+1)*(i+2)/6<=2000000){
            v.pb(i*(i+1)*(i+2)/6);
        }
        else break;
    }
    int ans1[1000010],ans2[1000010];
    rep(i,0,1000010) ans1[i]=ans2[i]=INF;
    ans1[0]=0; ans2[0]=0;
    rep(i,0,1000000){
        ans1[i]=i; ans2[i]=i;
        for(int j=0;i>=v[j];j++){
            ans1[i]=min(ans1[i-v[j]]+1,ans1[i]);
            if(v[j]%2==1)ans2[i]=min(ans2[i],ans2[i-v[j]]+1);
        }
    }

    int n;
    while(cin>>n&&n){
        cout<<ans1[n]<<" "<<ans2[n]<<endl;
    }
    
    return 0;
}