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

using namespace std;

//正四面体数を返す
int getRt(int n){
	return (n) * (n + 1) * (n + 2) / 6;
}

int main(void){
	//FILE* fp_in = freopen("data.txt", "r", stdin);
	
	while(1){
		int n, tmp;
		cin >> n;
		if( n == 0 ) break;

		//nに最も近く、かつn以下の正四面体数は？
		int p = 0;
		for(int i = 1; getRt(i) <= n; i++)
			p = i;

		//■■■■奇数以外の正四面体数を含む場合■■■■
		vector<int> cntlist;
		for(int i = p; i >= 1; i--) {
			int cnt = 0;
			tmp = n;
			for(int j = i; j >= 1; j--) {
				cnt += tmp / getRt(j);
				tmp %= getRt(j);
			}
			cntlist.push_back(cnt);
		}
		sort(cntlist.begin(), cntlist.end());
		cout << cntlist.at(0) << " ";

		//■■■■奇数の正四面体数のみの場合■■■■
		vector<int> cntlist2;
		for(int i = p; i >= 1; i--) {
			int cnt = 0;
			tmp = n;
			for(int j = i; j >= 1; j--) {
				if( getRt(j) % 2 == 0 ) continue;
				cnt += tmp / getRt(j);
				tmp %= getRt(j);
			}
			cntlist2.push_back(cnt);
		}
		sort(cntlist2.begin(), cntlist2.end());
		cout << cntlist2.at(0) << endl;

	}

	//while(1){}

	return 0;
}

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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    vi sn(1100);
    REP(i,1,1100) sn[i] = i*(i+1)*(i+2) / 6;
    vi dp1(1000010, INF);
    vi dp2(1000010, INF);
    dp1[0] = 0;
    rep(i,1000010){
        rep(j,1100){
            if(i - sn[j] >= 0)
                dp1[i] = min(dp1[i], dp1[i-sn[j]] + 1);
        }
    }
    dp2[0] = 0;
    rep(i,1000010){
        rep(j,1100){
            if(i - sn[j] >= 0 && sn[j] & 1)
                dp2[i] = min(dp2[i], dp2[i-sn[j]] + 1);
        }
    }
    int x;
    while(cin >> x){
        if(x == 0) break;
        cout << dp1[x] << " " << dp2[x] << endl;
    }
    return 0;
}

C++: #include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

const int MAX_V=1000010;
unsigned int dp[MAX_V];
unsigned int dpodd[MAX_V];
set<int> tetras{-1};
set<int> oddtetras{-1};
int main(){ _;
  int n;
  REP(i,MAX_V)dp[i]=dpodd[i]=-1;
  dp[0]=dpodd[0]=0;
  for(int i=1;;i++){
    int k=i*(i+1)*(i+2)/6;
    tetras.insert(k);
    if((k>>1)<<1!=k)//odd
      oddtetras.insert(k);
    if(k>MAX_V)break;
  }
  for(int i=1;i<MAX_V;i++){
    auto tetra=tetras.upper_bound(i);
    auto oddtetra=oddtetras.upper_bound(i);
    for(int j=0;j<200;j++){
      int k=*(--tetra);
      if(k<0)break;
      dp[i]=min(dp[i],dp[i-k]+1);
    }
    for(int j=0;j<200;j++){
      int k=*(--oddtetra);
      if(k<0)break;
      dpodd[i]=min(dpodd[i],dpodd[i-k]+1);
    }
  }
  while(cin>>n,n!=0){
    cout<<dp[n]<<" "<<dpodd[n]<<endl;
  }
}

C++: #include<iostream>
#include<queue>

using namespace std;
int tri[1500];
int tetra[190];

class Node{
public:
	int deep;
	int sum;
	int num;
	Node(int d,int s,int n){
		deep=d;
		sum=s;
		num=n;
	}
	bool operator < (const Node &o) const{
		return deep >o.deep;
	}
};
typedef priority_queue <Node> PQ;
int getTriNum(int n){
	if(tri[n]!=0)return tri[n];
	return (tri[n]=getTriNum(n-1)+n);
}

int getTetraNum(int n){
	if(tetra[n]!=0)return tetra[n];
	return (tetra[n]=getTetraNum(n-1)+getTriNum(n));
}
int dijkstra(int limit){
	PQ pq;
	pq.push(Node(0,0,1));
	while(!pq.empty()){
		Node cur=pq.top();
		pq.pop();
		if(cur.sum==limit)return cur.deep;
		for(int i=cur.num;i<=182;i++){
			if(cur.sum+tetra[i]>limit)break;
			pq.push(Node(cur.deep+1,cur.sum+tetra[i],i));
		}
	}
	return -1;
}
int dijkstra2(int limit){
	PQ pq;
	pq.push(Node(0,0,1));
	while(!pq.empty()){
		Node cur=pq.top();
		pq.pop();
		if(cur.sum==limit)return cur.deep;
		for(int i=cur.num;i<=182;i++){
			if(cur.sum+tetra[i]>limit)break;
			if(!(tetra[i]%2))continue;
			pq.push(Node(cur.deep+1,cur.sum+tetra[i],i));
		}
	}
	return -1;
}

int
main(){
	tetra[1]=tri[1]=1;
	getTetraNum(182);
	while(true){
		int n;
		cin>>n;
		if(!n)break;
		int count;
		if((count=dijkstra(n))>0){
			cout<<count;
		}
		if((count=dijkstra2(n))>0){
			cout<<" "<<count<<endl;
		}
	}
	return 0;
}