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;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

vi od,all;

void solve(int n){
	vi aldp(n+1,INF),oddp(n+1,INF);
	aldp[0]=0;oddp[0]=0;
	rrep(i,all.size()){
		rep(j,n){
			if(aldp[j]==INF)continue;
			if(j+all[i]>n)j=n;
			else chmin(aldp[j+all[i]],aldp[j]+1);
		}
	}
	rrep(i,od.size()){
		rep(j,n){
			if(oddp[j]==INF)continue;
			if(j+od[i]>n)j=n;
			else chmin(oddp[j+od[i]],oddp[j]+1);
		}
	}
	puta(aldp[n],oddp[n]);
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	for(int i=1;(i)*(i+1)*(i+2)/6<=1E6;i++){
		all.push_back((i)*(i+1)*(i+2)/6);
		if((i)*(i+1)*(i+2)/6%2==1)od.push_back((i)*(i+1)*(i+2)/6);
	}
	while(cin>>n,n)solve(n);
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<cstring>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
#define MAX_N 1000000
#define MAX_P 190
typedef unsigned int uint;
int p[MAX_P];
int op[MAX_P];
int pn[MAX_N];
int opn[MAX_N];
#define INF 1000000
int main()
{
//	REP(i,MAX_P) p[i]=i*(i+1)*(i+2)/6;
	int c=0;
	REP(i,MAX_P)
	{

		p[i]=i*(i+1)*(i+2)/6;
		if((p[i]%2) ==1)
		{
			c++;
			op[c]= p[i];
		}
	}
	memset(pn,INF,MAX_N*sizeof(int));
	memset(opn,INF,MAX_N*sizeof(int));
	pn[0]=opn[0]=0;
	for(int i=0;i<MAX_N;i++)
	{
		for(int j=0;j<MAX_P;j++)
		{
			if(i+p[j] > MAX_N) break;
			pn[i+p[j] ]=min(pn[i+p[j]] ,pn[i]+1);
			
		}
	}
	for(int i=0;i<MAX_N;i++)
	{
		for(int j=0;j<MAX_P;j++)
		{
			if(i+op[j] > MAX_N) break;
			opn[i+op[j] ]=min(opn[i+op[j]] ,opn[i]+1);

		}
	}
	int n;
	while(cin >> n &&n)
	{
		cout << pn[n]  <<" " << opn[n] << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;

vector<ll> f;
ll ans[1000001];
ll ans_odd[10000001];

int main(){
    for(ll i = 1; i < 240; i++){
        ll tmp = i*(i+1)*(i+2)/6;
        if(tmp > 1000000) break;
        f.push_back(tmp);
    }
    for(int i = 0; i <= 1000000; i++){
        ans[i] = INF;
        ans_odd[i] = INF;
    }
    ans[0] = 0;
    ans[1] = 1;
    ans_odd[0] = 0;
    ans_odd[1] = 1;
    for(ll i = 0; i <= 1000000; i++){
        for(int j = 0; j < f.size(); j++){
            if(i+f[j] > 1000000) break;
            ans[i+f[j]] = min(ans[i+f[j]], ans[i]+1);
            if((f[j]%2)==1){
                ans_odd[i+f[j]] = min(ans_odd[i+f[j]], ans_odd[i]+1);
            }
        }
    }
    while(true){
        ll n;
        cin >> n;
        if(n == 0) break;
        cout << ans[n] << " " << ans_odd[n] << endl;
    }
}

C++: #include<stdio.h>
#include<algorithm>
#define INF 810114514
#define MAX 1000000

int dp[MAX];
int dp_odd[MAX];
int main(){
    dp[0] = 0;
    dp_odd[0] = 0;
    for(int i=1; i<MAX; i++){
        dp[i] = MAX+1;
        dp_odd[i] = MAX+1;
    }
    for(int n=1; n*(n+1)*(n+2)/6 < MAX; n++){
        int p = n*(n+1)*(n+2)/6;
        for(int i=0; i+p < MAX; i++){
            dp[i+p] = std::min(dp[i+p], dp[i] + 1);
            if(p&1) dp_odd[i+p] = std::min(dp_odd[i+p], dp_odd[i] + 1);
        }
    }
    int x;
    scanf("%d",&x);
    while(x != 0){
        printf("%d %d\n", dp[x], dp_odd[x]);
        scanf("%d",&x);
    }

    return 0;
}