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 <algorithm>

using namespace std;
typedef long long ll;

#define REP_N(i,n,s) for(ll i=0; i<(ll)n; i+=s)
#define REP(i,n) REP_N(i,n,1)

ll table[1000000];
ll pollock[1000001];
ll dp[1000001];

void solution(ll output[1000001], int interval) {
	output[0] = 0;
	ll current_i = interval-1;
	REP(i, 1000001) if(i!=0) {
		ll minimum = 1000001;
		REP_N(j, current_i+1, interval) if(j!=0) minimum = min(output[i - table[j]] + 1, minimum);
		output[i] = minimum;

		if (table[current_i + interval] == i) current_i += interval;
	}
}

int main() {
	//freopen("Text.txt", "r", stdin);
	
	{
		ll i = 0;
		table[0] = 0;
		while (1000001 > table[i++]) table[i] = i*(i + 1)*(i + 2) / 6;
	}

	solution(pollock, 1);
	solution(dp, 4);

	while (true) {
		int n;
		cin >> n;
		if (n==0) break;
		
		cout << pollock[n] << " " << dp[n] << endl;
	}

}

C++: #include<iostream>
#include<vector>
#define MAX 1000000
#define INF 1000000000
using namespace std;
typedef long long ll;
int main(){
  ll num=0,cnt=3,i=0;
  vector<ll> n_list,o_list;
  while(num<=MAX){
    num = (cnt)*(cnt-1)*(cnt-2);
    num/=6;
    n_list.push_back(num);
    if(num%2==1){
      o_list.push_back(num);
    }
    cnt++;
  }
  ll n;
  cin >> n;
  while(n!=0){
    vector<ll> dp(n+1),odp(n+1);
    fill(dp.begin(),dp.end(),INF);
    fill(odp.begin(),odp.end(),INF);
    dp[0]=0;
    odp[0]=0;
    for(int i=0;i<n_list.size();i++){
      for(int j=n_list[i];j<=n;j++){
        dp[j]=min(dp[j],dp[j-n_list[i]]+1);
      }
    }
    for(int i=0;i<o_list.size();i++){
      for(int j=o_list[i];j<=n;j++){
        odp[j]=min(odp[j],odp[j-o_list[i]]+1);
      }
    }
    cout << dp[n]<<" "<<odp[n]<<endl;
    cin >> n;
  }
}

C++: #include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

void init(vector<int>* all, vector<int>* odd){
  int x;
  for(int i=1; ; ++i){
    x = i*(i+1)*(i+2)/6;
    if(x > 1000000) break;
    all->push_back(x);
    if(x%2 == 1) odd->push_back(x);
  }
  reverse(all->begin(), all->end());
  reverse(odd->begin(), odd->end());
}

int search(int x, int& n, const vector<int>& data){
  for(int i=x; i<data.size(); ++i){
    if(data[i] <= n) return i;
  }
}

int solve(int& n, const vector<int>& data){
  int x = search(0, n, data);
  int ans=n, ans_, y, m;
  for(int i=x; i<data.size(); ++i){
    y = i; ans_=0; m=n;
    while(1){
      y = search(y, m, data);
      m -= data[y];
      ++ans_;
      if(m == 0 || ans < ans_) break;
    }
    ans = min(ans, ans_);
  }
  return ans;
}

int main(){
  vector<int> all, odd;
  init(&all, &odd);
  int n;
  while(1){
    cin >> n;
    if(!n) break;
    cout << solve(n, all) << " " << solve(n, odd) << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    vector<int> table;
    int cur = 1;
    int bound = 1e+6;
    for(;;){
        ll val = (ll)cur * (cur + 1) * (cur + 2) / 6;
        if(val > bound) break;
        table.emplace_back(val);
        ++cur;
    }
    vector<int> dp(bound, INF);
    dp[0] = 0;
    vector<int> dp2 = dp;
    for(int x : table){
        for(int i = 0; i < bound - x; ++i){
            chmin(dp[i + x], dp[i] + 1);
            if(x % 2)   chmin(dp2[i + x], dp2[i] + 1);
        }
    }
    
    for(;;){
        int n;
        cin >> n;
        if(n == 0)  return 0;
        cout << dp[n] << ' ' << dp2[n] << '\n';
    }
}

C++: #define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
const int W = 1e6;
signed main() {
	vector<int>c(1, 0), odd(1, 0);
	for (int i = 1; i*(i + 1)*(i + 2) / 6 < W; i++) {
		c.push_back(i*(i + 1)*(i + 2) / 6);
		if (c[i] & 1)odd.push_back(c[i]);
	}
	vector<int>v1(W, INF), v2(W, INF); v1[0] = v2[0] = 0;
	rep(i, 1, c.size()) {
		rep(j, c[i], W) {
			v1[j] = min(v1[j], v1[j - c[i]] + 1);
		}
	}
	rep(i, 1, odd.size()) {
		rep(j, odd[i], W) {
			v2[j] = min(v2[j], v2[j - odd[i]] + 1);
		}
	}

	int n;
	while (cin >> n, n) {
		cout << v1[n] << " " << v2[n] << endl;
	}
	return 0;
}