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 <bits/stdc++.h>

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
// #define LOG(...)
#define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for(int i = (int)(n - 1); i >= 0; --i)
#define RFOR(i, a, b) for(int i = (int)(b - 1); i >= (int)(a); --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)
#define BIT(x, i) (((x) >> (i)) & 1)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vc> vvc;
typedef vector<vll> vvll;

const int INF = (int)1e9;

int main() {
  vi pollock;
  for(int i = 0, v; ( v = i * (i + 1) * (i + 2) / 6) <= 1000000; i++) {
    pollock.push_back(v);
  }

  vi dpall(100001, INF);
  vi dpodd(100001, INF);
  dpall[0] = dpodd[0] = 0;
  for (auto m : pollock) {
    for(int i = 0; i + m < dpall.size(); i++) {
      dpall[i + m] = min(dpall[i + m], dpall[i] + 1);
    }
    if (m % 2 == 1) {
      for(int i = 0; i + m < dpodd.size(); i++) {
        dpodd[i + m] = min(dpodd[i + m], dpodd[i] + 1);
      }
    }
  }

  int n;
  while(cin >> n, n) {
    printf("%d %d\n", dpall[n], dpodd[n]);
  }
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;

#define N 1000007
ll s[N], t[N];

int main() {

    for(ll i=0; i<N; ++i) s[i] = t[i] = 10000000;
    s[0] = t[0] = 0;
    for(ll i=0; i<N; ++i) {
        ll j = 1;
        while(i + j*(j+1)*(j+2)/6 < N) {
            ll p = j*(j+1)*(j+2)/6;
            s[i+p] = min(s[i]+1, s[i+p]);
            if(p % 2 == 1) {
                t[i+p] = min(t[i]+1, t[i+p]);
            }
            ++j;
        }
    }

    int n;
    while(cin >> n && n) {
        cout << s[n] << " " << t[n] << endl;
    }

    return 0;
}

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

const int inf = 1000000009;

int main() {
    vector<int> memo(1000000, inf);     memo[0] = 0;
    vector<int> odd_memo(1000000, inf); odd_memo[0] = 0;

    for (int i=0; i<1000000; i++) {
        memo[i]     = i;
        odd_memo[i] = i;
    }

    for (int l=2; l<85; l++) {
        const int n = (l*(l+1)*(l+2))/6;
        for (int i=0; i<1000000; i++) {
            if (i-n >= 0) {
                memo[i] = min(memo[i-n]+1, memo[i]);
                if (l%2==1) {
                    odd_memo[i] = min(odd_memo[i-n]+1, odd_memo[i]);
                }
            }
        }
    }

    int n; 
    while (cin >> n, n!=0) {
        cout << memo[n] << " " << odd_memo[n] << endl;
    }
}

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

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

int main()
{
  int block_num = 0;
  int cnt = 1;
  vector<int> block_nums;
  while (true)
  {
    block_num = count_block(cnt);
    if (block_num > 1000000)
    {
      break;
    }
    block_nums.push_back(block_num);
    cnt += 1;
  }
  int size_block_nums = block_nums.size();
  vector<int> dp(1000000 + 1, INF);
  vector<int> odd_dp(1000000 + 1, INF);
  dp.at(0) = 0;
  odd_dp.at(0) = 0;
  for (int i = 0; i < 1000000; ++i)
  {
    for (int j = 0; j < size_block_nums; ++j)
    {
      int next_num = i + block_nums.at(j);
      if (next_num > 1000000)
      {
        break;
      }
      int temp = dp.at(i) + 1;
      if (dp.at(i + block_nums.at(j)) > temp)
      {
        dp.at(i + block_nums.at(j)) = temp;
      }
      if (block_nums.at(j) % 2 == 1)
      {
        temp = odd_dp.at(i) + 1;
        if (odd_dp.at(i + block_nums.at(j)) > temp)
        {
          odd_dp.at(i + block_nums.at(j)) = temp;
        }
      }
    }
  }
  while (true)
  {
    int n;
    cin >> n;
    if (n == 0)
    {
      break;
    }
    // for (int i = 0; i < block_nums.size(); ++i)
    // {
      //   cout << block_nums.at(i) << endl;
      // }
    cout << dp.at(n) << ' ' << odd_dp.at(n) << endl;

    // for (int i = 0; i < n + 1; ++i)
    // {
    //   dp.at(i) = INF;
    // }
    // dp.at(0) = 0;
    // for (int i = 0; i < n; ++i)
    // {
    //   for (int j = 0; j < size_block_nums; ++j)
    //   {
    //     if (block_nums.at(j) % 2 == 0)
    //     {
    //       // cout << block_nums.at(j) << endl;
    //       continue;
    //     }
    //     int next_num = i + block_nums.at(j);
    //     if (next_num > n)
    //     {
    //       break;
    //     }
    //     int temp = dp.at(i) + 1;
    //     if (dp.at(i + block_nums.at(j)) > temp)
    //     {
    //       dp.at(i + block_nums.at(j)) = temp;
    //     }
    //   }
    // }
    // // for (int i = 0; i < n + 1; ++i)
    // // {
    // //   cout << dp.at(i) << endl;
    // // }
    // cout << dp.at(n) << endl;
  }
}