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 <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int n;

vector<ll> table, table2;

ll dp[2][2][1001000];

int main() {
	for (int i = 1; i*(i + 1)*(i + 2) / 6 <= 100000; i++) {
		table.push_back(i*(i + 1)*(i + 2) / 6);
		if ((i*(i + 1)*(i + 2) / 6) % 2 == 1)table2.push_back(i*(i + 1)*(i + 2) / 6);
	}
	REP(i, 2) {
		REP(j, 2) {
			REP(k, 1001000)dp[i][j][k] = INF;
		}
	}
	dp[0][0][0] = 0;
	dp[1][0][0] = 0;

	REP(i, table.size()) {
		int num = table[i];
		REP(j, 1000000) {
			if (j - num >= 0) {
				dp[0][(i + 1) % 2][j] = min(dp[0][(i + 1) % 2][j - num] + 1, dp[0][i % 2][j]);
			}
			else dp[0][(i + 1) % 2][j] = dp[0][i % 2][j];
		}
	}

	for (int i = 0; i < table2.size(); i++) {
		int num = table2[i];
		//cout << num << endl;
		REP(j, 1000000) {
			if (j - num >= 0) {
				dp[1][(i + 1) % 2][j] = min(dp[1][(i + 1) % 2][j - num] + 1, dp[1][i % 2][j]);
			}
			else dp[1][(i + 1) % 2][j] = dp[1][i % 2][j];
		}
	}
	
	while (cin >> n&&n) {
		cout << dp[0][table.size() % 2][n] << " "
			<< dp[1][table2.size() % 2][n] << endl;
	}
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 45;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  vector<P> ans;
  vector<int> dp(1000005, INF), odd_dp(1000005, INF);
  dp[0] = odd_dp[0] = 0;
  vector<int> f;
  vector<int> input;
  while(true) {
    int n; cin >> n;
    if(n == 0) break;
    input.push_back(n);
  }

  f.push_back(0);
  for(int i = 1;;++i) {
    if((i*(i+1)*(i+2))/6 > 2000000) break;
    f.push_back((i*(i+1)*(i+2))/6);
  }

  for(int i = 1; i <= 1000000; ++i) {
    for(int j = 1;; ++j) {
      if(i-f[j] < 0) break;
      chmin(dp[i], dp[i-f[j]]+1);
      if(f[j]%2==1) chmin(odd_dp[i], odd_dp[i-f[j]]+1);
    }
  }
  for(auto in : input) ans.emplace_back(dp[in], odd_dp[in]);
  for(auto x : ans) cout << x.first << " " << x.second << "\n";
}

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

int main(){
  vector<int> T;
  {
    int t = 1;
    while(true){
      long long s = t*(t+1)*(t+2)/6;
      if(s > 1e6) break;
      T.push_back(s);
      ++t;
    }
  }
  const int INF = 1e9;

  int n = 1e6;

  vector<int> dp(n+1,INF), dp2(n+1,INF);
  dp[0] = 0;
  dp2[0] = 0;
  for(int i = 0; i <= n; ++i){
    for(auto e : T){
      if(i+e > n) break;
      dp[i+e] = min(dp[i+e],dp[i]+1);
      if(e%2)
        dp2[i+e] = min(dp2[i+e],dp2[i]+1);
    }
  }


  while(cin >> n, n){
    cout << dp[n] << " " << dp2[n] << endl;
  }
}