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;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 1145141919
#define MOD 1000000007
#define ALL(a) begin((a)),end((a))
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
typedef vector<edge> edges;
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///
vi all, odd, v;
int allt[1000005], oddt[1000005];

int main()
{
	v.push_back(0);
	FOR(i, 1, 1000) v.push_back(v[i - 1] + i);
	all.push_back(0);
	FOR(i,1, v.size())
	{
		all.push_back(all[i - 1] + v[i]);
		if (i & 1) odd.push_back(all[i - 1] + v[i]);
		if (all[i] > 1000000) break;
	}
	int n;
	fill(ALL(allt), INF); fill(ALL(oddt), INF);
	REP(i, 1000001)REP(j, all.size())
	{
		int t = i + all[j];
		if (t >= 1000001) break;
		allt[t] = min(allt[i] + 1, allt[t]);
	}
	REP(i, 1000001)REP(j, all.size())
	{
		int t = i + odd[j];
		if (t >= 1000001) break;
		oddt[t] = min(oddt[i] + 1, oddt[t]);
	}
	while (cin >> n, n) cout << allt[n] << " " << oddt[n] << endl;
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

const int MAX = 1111111;

int dpall[MAX];
int dpodd[MAX];
vi tri, all, odd;

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);

	tri.push_back(1);
	FOR(i, 2, MAX)
	{
		int t = tri.back() + i;
		if (t >= MAX) break;
		tri.push_back(t);
	}

	all.push_back(1);
	odd.push_back(1);
	FOR(i, 2, MAX)
	{
		int t = all.back() + tri[i-1];
		if (t >= MAX) break;
		all.push_back(t);
		if (t % 2 == 1) odd.push_back(t);
	}

	REP(i, MAX)
	{
		dpall[i] = dpodd[i] = MAX;
	}

	for (auto i : all) dpall[i] = 1;
	for (auto i : odd) dpodd[i] = 1;

	FOR(i, 1, MAX)for (auto j : all)
	{
		int t = i + j;
		if (t >= MAX) break;
		chmin(dpall[t], dpall[i] + 1);
	}
	FOR(i, 1, MAX)for (auto j : odd)
	{
		int t = i + j;
		if (t >= MAX) break;
		chmin(dpodd[t], dpodd[i] + 1);
	}
	int n;
	while (cin >> n, n)
	{
		cout << dpall[n] << " " << dpodd[n] << endl;
	}
	return 0;
}

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

long dp[1000000];
long dpo[1000000];

int main(){
    int N;
    dp[0] = 0;
    dp[0] = 0;
    for(int i = 1;i < 1000000;i++){
            dp[i] = 1000000;
            dpo[i] = 1000000;
        }
    for(int i= 0;i < 1000;i++){
        long a = (i * (i + 1) * (i + 2)) / 6;
        for(int j = a;j < 1000000;j++){
            dp[j] = min(dp[j],dp[j - a] + 1);
            if(a % 2 == 1){
                dpo[j] = min(dpo[j],dpo[j - a] + 1);
            }
        }
    }
    for(int i = 0;;i++){
        scanf("%d",&N);
        if(N == 0){
            break;
        }
        printf("%ld %ld\n",dp[N],dpo[N]);
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int prime[200],dprime[100];
int dp[1000001];
int main(){
	int a=1,b=2,count=1,dcount=1;
	prime[0]=1,dprime[0]=1;
	while(true){
		a+=b;
		b++;
		if(prime[count-1]+a>=1000000)
			break;
		if((prime[count-1]+a)%2==1){
			dprime[dcount]=prime[count-1]+a;
			dcount++;
		}
		prime[count]=prime[count-1]+a;
		count++;
	}
	int n;
	while(true){
		cin>>n;
		if(n==0)
			break;
		for(int i=0;i<=n;i++)
			dp[i]=i%4+i/4;
		for(int i=0;i<=n;i++){
			int f=2;
			while(true){
				dp[i+prime[f]]=min(dp[i+prime[f]],dp[i]+1);
				f++;
				if(f==count)
					break;
				if(prime[f]>n)
					break;
			}
		}
		cout<<dp[n]<<" ";
		for(int i=0;i<=n;i++)
			dp[i]=i%35+i/35;
		for(int i=0;i<=n;i++){
			int f=2;
			while(true){
				dp[i+dprime[f]]=min(dp[i+dprime[f]],dp[i]+1);
				f++;
				if(f==dcount)
					break;
				if(prime[f]>n)
					break;
			}
		}
		cout<<dp[n]<<endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
  int i,j,k,b[1e6],c[1e6],a[190],n;
  for(i=0;a[i-1]<1e6;i++)a[i]=i*(i+1)*(i+2)/6;
  for(j=0;j<=1e6;j++)b[j]=c[j]=j;
  for(j=2;j<i;j++)for(k=a[j];k<=1e6;k++){
    b[k]=min(b[k],b[k-a[j]]+1);
    if(a[j]%2)c[k]=min(c[k],c[k-a[j]]+1);
  }
while(cin>>n,n)cout<<b[n]<<' '<<c[n]<<endl;
return 0;
}