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<stdio.h>
#include<string.h>

char table[1000000][1],tablek[1000000];
int po[182];

int main(){
	int i,j,k,n;
	
	memset(po,0,sizeof(po));
	memset(table,0,sizeof(table));
	memset(tablek,0,sizeof(tablek));
	
	for(i=1;i<182;i++){
		po[i]=i*(i+1)*(i+2)/6;
		if(po[i]<1000000)table[po[i]][0]=1;
	}
	
	for(i=1;i<5;i++){
		for(j=1;j<1000000;j++){
			if(table[j][0]==i){
				for(k=1;k<182;k++){
					if(j+po[k]>=1000000)break;
					if(table[j+po[k]][0]==0)table[j+po[k]][0]=i+1;
				}
			}
		}
	}
	
	n=1000000-1;
	
	for(i=1;i<182;i++){
		if(po[i]<1000000 && po[i]%2==1){
			tablek[po[i]]=1;
			--n;
		}
	}
	for(i=1;n>0;i++){
		for(j=1;j<1000000;j++){
			if(tablek[j]==i){
				for(k=1;k<182;k++){
					if(j+po[k]>=1000000)break;
					if(tablek[j+po[k]]==0 && po[k]%2==1){
						tablek[j+po[k]]=i+1;
						--n;
					}
				}
			}
		}
	}
	
	while(scanf("%d",&n)>=0){
		if(n==0)break;
		printf("%d %d\n",table[n][0],tablek[n]);
	}
	
	
	return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const int MAX = 1000005;

int main() {
  vector<int> dp(MAX, INF), odddp(MAX, INF);
  dp[0] = 0;
  odddp[0] = 0;
  for (int i = 1;; ++i) {
    int w = i * (i+1) * (i+2) / 6;
    if (w >= MAX) break;
    FOR(j, w, MAX) {
      dp[j] = min(dp[j], dp[j-w] + 1);
      if (w & 1) odddp[j] = min(odddp[j], odddp[j-w] + 1);
    }
  }

  int n;
  while (cin >> n) {
    if (n == 0) break;
    cout << dp[n] << " " << odddp[n] << endl;
  }

  
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lpin(a,i,n) for(int i=0;i<n;i++){cin>>a[i];}

void calc(int a[],int f){
  for(int i=f*(f+1)*(f+2)/6;i<=1000000;i++){
    if(a[i]==0) a[i]=a[i-f*(f+1)*(f+2)/6]+1;
    else if(a[i]>a[i-f*(f+1)*(f+2)/6]+1) a[i]=a[i-f*(f+1)*(f+2)/6]+1;
  }
}

int x[1000001],b[1000001];
int main(){
  for(int i=1;i*(i+1)*(i+2)/6<1000000;i++){
    calc(x,i);
  }
  for(int i=1;i*(i+1)*(i+2)/6<1000000;i++){
    if(i*(i+1)*(i+2)/6%2==1){
    calc(b,i);
    }
  }
  while(1){
    int z;
    cin>>z;
    if(z==0) break;
    cout<<x[z]<<" "<<b[z]<<endl;
  }
  return 0;
}

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

#define MAX 1000001

long long int flag[MAX] = {};
long long int flag2[MAX] = {};

int main() {

	vector< long long int > l, l2;

	for( long long int i = 1; ; i++ ) {

		long long int a = i * ( i + 1 ) * ( i + 2 ) / 6;

		if ( a >= MAX ) break;

		l.push_back( a );
		if ( ( a % 2 ) != 0 ) l2.push_back( a );

	}
	
	for ( long long int i = 1; i < MAX; i++ ) {
		flag[i] = MAX + 1;
		flag2[i] = MAX + 1;
	}

	for ( long long int i = 0; i < l.size(); i++ ) {
		for ( long long int j = 0; j + l[i] < MAX; j++ ) {
			flag[ j + l[i] ] = min( flag[ j + l[i] ], flag[ j ] + 1 );
		}
	}
	for ( long long int i = 0; i < l2.size(); i++ ) {
		for ( long long int j = 0; j + l2[i] < MAX; j++ ) {
			flag2[ j + l2[i] ] = min( flag2[ j + l2[i] ], flag2[ j ] + 1 );
		}
	}

	while( true ) {

		long long int in;
		cin >> in;
		if ( in == 0 ) break;

		cout << flag[in] << " " << flag2[in] << endl;

	}

	return 0;

}

C++: #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
const int INF_i = 1 << 30;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};
int main() {
    while(1){
        ll N;
        cin >> N;
        if(N == 0) break;
        vector<ll> tetra;
        ll n = 1;
        while(n*(n+1)*(n+2)/6 <= N){
            tetra.pb(n*(n+1)*(n+2)/6);
 
            n++;

        }
        
        vector<ll> dp(N+2,INF);
        dp[0] = 0;
        vector<ll> odp(N+2,INF);
        odp[0] = 0;
        rep(i,tetra.size()){
            rep(j,N+1){
                if(j-tetra[i]>=0){
                    dp[j] = min({dp[j], dp[j-tetra[i]]+1}); 
                    if(tetra[i]%2 == 1){
                        odp[j] = min({odp[j], odp[j-tetra[i]]+1});
                    }
                }
                
            }
        }

        
        /*rep(i,otetra.size()){
            rep(j,N+1){
                if(j-otetra[i]>=0){
                    odp[j] = min({odp[j], odp[j-otetra[i]]+1}); ;
                }
            }
        }*/
        
        cout << dp[N]<<" "<< odp[N]<< endl;
    }



    return 0;
    

}