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 <vector>
#include <list>
#include <set>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <deque>

using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
using pii=pair<int,int>;
using vs=vector<string>;
using vvi=vector<vi>;
using vpii=vector<pii>;
using si=set<int>;
using vl=vector<ll>;


#define REP(i,a) for(int i=0;i<a;i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rREP(i,a) for(int i=(a)-1;i>=0;i--)
#define rFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define out(S) cout<<(S)<<endl;
#define beginend(v) (v).begin(),(v).end()
#define IfOut(condition,text) if(condition){out(text);return 0;}
#define IfOutElse(condition,if_text,else_text) if(condition){out(if_text);return 0;}else{out(else_text);return 0;}
#define mod(s) ((s)%(ll)(1e9+7))
ll modpow(ll i, ll j) { ll tmp = 1; while (j) { if (j % 2)tmp = mod(tmp*i); i = mod(i*i); j /= 2; }return tmp; }
#define divmod(a,b) (mod(a*modpow((ll)b,(ll)(1e9+5))))
#define pb(i) push_back(i)
#define fst first
#define snd second
#define Foreach(item,collection) for(auto item:collection)
#define INF (int)1e10
#define removeAll(vec,deleg) auto itr=remove_if(beginend(vec),deleg);vec.erase(itr,vec.end());
void removeAt(string& s, int index) { s.erase(index, 1); }
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }
ll manhattanDistance(ll x1, ll y1, ll x2, ll y2) { return (abs(x2 - x1) + abs(y2 - y1)); }
vector<ll> sieveOfEratosthenes(int max) {ll prime;double sqrtmax = sqrt(max);vector<ll> primeVec, searchVec;FOR(i, 2, max + 1) searchVec.push_back(i);do{prime = searchVec[0];primeVec.push_back(prime);auto itr = remove_if(beginend(searchVec), [=](ll x)->bool {return x%prime == 0; });searchVec.erase(itr, searchVec.end());} while (prime < sqrtmax);primeVec.reserve(primeVec.size() + searchVec.size());primeVec.insert(primeVec.end(), beginend(searchVec));return primeVec;}
ll sum(vi v) {ll sum=0;Foreach(i,v){sum+=i;}return sum;}
#define ShowAll(v) Foreach(i,v) out(i);
bool isInnerIndex(int kx,int ky,int mx,int my){ return (kx>=0&&kx<mx&&ky>=0&&ky<my); }
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;

vl llist,oddlist;

void makeList(int max){
    int n=1;
    bool f=true;
    while(f){
        ll next=n*(n+1)*(n+2)/6;
        if(next>max){f=false;}
        llist.pb(next);
        n++;
    }
}

int bfs(int target){
    si q;
    Foreach(i,llist) {if(i==target){return 1;}if(i<=target){q.insert(i);}}
    auto mm=*max_element(beginend(q));
    int cnt=(target-mm)/mm;
    target=(target)%mm+mm;
    Foreach(i,q) if(i==target) return cnt+1;
    cnt+=2;
    while(1){
        si next;
        Foreach(x,q){
            Foreach(k,llist){
                if(k+x>target) break;
                if(k+x==target) {next.clear();q.clear();return cnt;}
                if(k+x<target) next.insert(k+x);
            }
        }
        q=next;
        next.clear();
        cnt++;
    }
}

int bfs2(int target){
    si q;
    Foreach(i,oddlist){
        if(i==target) return 1;
        if(i<target) q.insert(i);
        if(i>target) break;
    }
    auto mm=*max_element(beginend(q));
    int cnt=(target-mm)/mm;
    target=target%mm+mm;
    Foreach(i,q)if(target==i) return cnt+1;
    cnt+=2;
    while (1)
    {
        si next;
        Foreach(x,q){
            Foreach(k,oddlist){
                if(k+x>target)break;
                if(k+x==target){next.clear();q.clear();return cnt;}
                if(k+x<target)next.insert(k+x);
            }
        }
        q=next;
        next.clear();
        cnt++;
    }
}



int main(){
    int n;
    vl query;
    while (cin>>n,n)
    {
        query.pb(n);
    }
    auto mm=max_element(beginend(query));
    makeList(*mm);
    oddlist=llist;
    removeAll(oddlist,[](ll x){return x%2==0;});
    Foreach(i,query){
        cout<<bfs(i)<<" "<<bfs2(i)<<endl;
    }
    return 0;
}

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

#define NUM 1000000

int n,tetra_sum[NUM],odd_sum[NUM];

void tetrahedral(int sum[],int tetra)
{
  for(int i=tetra;i<NUM;i++)
    sum[i]=min(sum[i],sum[i-tetra]+1);
}

int main()
{
  tetra_sum[0]=0; odd_sum[0]=0;
  for(int i=1;i<NUM;i++){
    tetra_sum[i]=NUM; odd_sum[i]=NUM;
  }
  for(int i=1;i<=180;i++){
    int tetra=i*(i+1)*(i+2)/6;
    tetrahedral(tetra_sum,tetra);
    if(tetra%2) tetrahedral(odd_sum,tetra);
  }
  for(;;){
    cin>>n;
    if(!n) break;
    cout<<tetra_sum[n]<<" "<<odd_sum[n]<<endl;
  }
}

C++: #include "bits/stdc++.h"

using namespace std;
typedef long long ll;

int simen[201];

int dp1[2][1000001];
int dp2[2][1000001];

int main()
{
	for(int i=1;i<201;i++)
	{
		simen[i]=i*(i+1)*(i+2)/6;

	}
	fill(dp1[0],dp1[1],1e8-1);
	dp1[0][0]=0;
	for(int i=1;i<201;i++)
	{
		for(int j=0;j<1000001;j++)
		{
			if(j<simen[i])
				dp1[i&1][j]=dp1[(i-1)&1][j];
			else
				dp1[i&1][j]=min(dp1[i&1][j-simen[i]]+1,dp1[(i-1)&1][j]);
		}
	}
	fill(dp2[0],dp2[1],1e8-1);
	dp2[0][0]=0;
	for(int i=1;i<201;i++)
	{
		for(int j=0;j<1000001;j++)
		{
			if(simen[i]%2==0 || j<simen[i])
				dp2[i&1][j]=dp2[(i-1)&1][j];
			else
				dp2[i&1][j]=min(dp2[i&1][j-simen[i]]+1,dp2[(i-1)&1][j]);
		}
	}

	while(1)
	{
		int n;
		cin>>n;
		if(n==0)
			break;
		cout<<dp1[0][n]<<" "<<dp2[0][n]<<endl;
	}
	return 0;
}