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;

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

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; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
 
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;

int main(){
    std::vector<int> dum(200);
    dum[0]=1;
    rrep(i,1,200){
        dum[i]=(i+1)+dum[i-1];
    }
    std::vector<int> p(200);p[0]=1;
    std::vector<int> pp;
    rrep(i,1,200){
        p[i]=p[i-1]+dum[i];
    }
    //erep(i,p)std::cout << i << std::endl;
    erep(i,p){
        if(i%2==1)pp.pb(i);
    }
    int m=p.size(),mm=pp.size();
    std::vector<int> dp(1000001,INF),ddp(1000001,INF);
    dp[0]=0;
    ddp[0]=0;
    rep(i,1000001){
        erep(j,p){
          //  if(i==0)std::cout << j << std::endl;
            if(i+j<=1000000)chmin(dp[i+j],dp[i]+1);
            else break;
        }
        erep(j,pp){
            if(i+j<=1000000)chmin(ddp[i+j],ddp[i]+1);
            else break;
        }
    }
    for(;;){
        int nn;
        std::cin >> nn;
        if(nn==0)exit(0);
        else ppri(dp[nn],ddp[nn]);
    }
}

C++: #include <cstdio>
#include <iostream>
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)

typedef long long ll;

const int INF=1e9;
const int N=1000001;
int mem[N],memo[N];


int tetra(int x)
{
    return x*(x+1)*(x+2)/6;
}
int main()
{
    REP(i,N)
    {
        mem[i]=INF;
        memo[i]=INF;
    }
    mem[0]=0;
    memo[0]=0;
    for(int j=200;j>=1;j--)
    {
        int c = tetra(j);
        REP(i,N)
        {
            if(i+c>=N) continue;
            if(c%2==1)
            {
                memo[i+c]=min(memo[i+c], memo[i]+1);
            }

            mem[i+c]=min(mem[i+c], mem[i]+1);
        }
    }

    /*
    REP(i,30)
        cout<<mem[i]<<" \n"[i==29];
    REP(i,30)
        cout<<memo[i]<<" \n"[i==29];
        */

    int n;
    while(cin>>n,n)
    {
        cout<<mem[n]<<" "<<memo[n]<<endl;
    }
}

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

const int MAX_N = 100001;
const int INF = 1<<27;
vector<int> N3, N4;

void makeN3() {
  N3.push_back(0);
  for(int i = 1, s = 1; s <= MAX_N; s += ++i) {
    N3.push_back(s);
  }
}

void makeN4() {
  N4.push_back(0);
  for(int i = 1, s = N3[1]; s <= MAX_N; s += N3[++i]) {
    N4.push_back(s);
  }
}

int solve(int N, bool oddOnly) {
  int T[MAX_N];
  fill(T, T+N+1, INF);
  T[0] = 0;
  for(int i = 1; i <= N; ++i) {
    for(int j = 1; j < N4.size() && N4[j] <= i; ++j) {
      if(oddOnly && N4[j]%2 == 0) continue;
      T[i] = min(T[i], T[i-N4[j]] + 1);
    }
  }
  return T[N];
}

int main() {
  int N;
  makeN3();
  makeN4();
  while(cin >> N && N) {
    cout << solve(N,false) << " " << solve(N,true) << endl;
  }
  return 0;
}