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<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
//#define mt make_tuple
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	vi dp(1000010,inf);
	vi dp2(1000010,inf);
	dp[0]=dp2[0]=0;
	loop(i,1,180)rep(j,1000010){
		int t=i*(i+1)*(i+2)/6;
		if(j+t<1000010)dp[j+t]=min(dp[j+t],dp[j]+1);
		if(t%2&&j+t<1000010)dp2[j+t]=min(dp2[j+t],dp2[j]+1);
	}
	int n;
	while(cin>>n,n)cout<<dp[n]<<" "<<dp2[n]<<endl;
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion
#pragma region chminmax
template <typename T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

int main()
{
    vector<int> in;
    int n = 0;
    while (true)
    {
        int k;
        cin >> k;
        chmax(n, k);
        if (!k)
            break;
        in.emplace_back(k);
    }

    vector<int> dp(n + 5, 1e6);
    vector<int> dp2(n + 5, 1e6);
    dp[0] = 1;
    dp2[0] = 1;

    int h = 1;
    int i = 1;
    while (h <= n)
    {
        rep(j, n + 1)
        {
            chmin(dp[h], 1);

            if (j - h >= 0)
            {
                chmin(dp[j], dp[j - h] + 1);
            }

            if (h % 2 == 0)
            {
                continue;
            }

            chmin(dp2[h], 1);

            if (j - h >= 0)
            {
                chmin(dp2[j], dp2[j - h] + 1);
            }
        }

        i++;
        h = i * (i + 1) * (i + 2) / 6;
    }

    for (int k : in)
    {
        cout << dp[k] << " " << dp2[k] << endl;
    }

    return 0;
}

C++: #include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
#include <memory>
#include <memory.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P,P> P2;
const int INF = 1 << 30;
const double EPS = 1E-9;

int c[1000000];
int co[1000000];
int po[300];

int main(){
	int n;
	fill(c, c + 1000000, INF);
	fill(co, co + 1000000, INF);
	c[0] = co[0] = 0;
	for(int i = 0; i < 300; i++){
		po[i] = i * (i + 1) * (i + 2) / 6;
	}
	for(int i = 0; i < 1000000; i++){
		for(int j = 1; j < 300; j++){
			if(i + po[j] >= 1000000) break;
			if(c[i + po[j]] > c[i] + 1){
				c[i+po[j]] = c[i] + 1;
			}
		}
	}
	for(int i = 0; i < 1000000; i++){
		for(int j = 1; j < 300; j++){
			if(!(po[j] & 1)) continue;
			if(i + po[j] >= 1000000) break;
			if(co[i+po[j]] > co[i] + 1){
				co[i+po[j]] = co[i] + 1;
			}
		}
	}
	while(cin >> n && n){
		cout << c[n] << " " << co[n] << endl;
	}
	return 0;
}

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

#define INF 1e7

using namespace std;

int dp(int n,vector<int> tetra){
	int num;
	num=distance(tetra.begin(),upper_bound(tetra.begin(),tetra.end(),n)-1);

	vector<int> pre(n+1,INF),now(n+1,INF);

	for(int i=0;i<=n;i++){
		pre[i]=i;
	}
	now[0]=0;
	for(int i=2;i<=num;i++){
		for(int j=1;j<=n;j++){
			if(j-tetra[i]>=0){
				now[j]=min(pre[j],now[j-tetra[i]]+1);
			}
			else now[j]=pre[j];
		}
		now.swap(pre);
	}
	return pre[n];
}

int main(){
	vector<int> t(1,0),t1(1,0);
	int c=1;
	while(t[c-1]<=(int)1e6){
		int temp;
		temp=c*(c+1)*(c+2)/6;
		t.push_back(temp);
		if(temp%2==1 ){
			t1.push_back(temp);
		}
		c++;
	}
	while(true){
		int n;
		cin >> n;
		if(n==0)break;
		
		/*
		for(int i=0;i<s.size();i++){
			for(int j=0;j<s[i].size();j++){
				if(s[i][j]==INF) cout << "0";
				else cout << s[i][j];
				cout << " ";
			}
			cout << endl;
		}
		*/
		cout << dp(n,t) << " " << dp(n,t1) << endl;
	}
	return 0;
}