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++: /**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define intv(x, a, b)((x)>=a && (x)<=b)
#define  rep(i, _begin, _end) for (__typeof(_end) end = _end, begin = _begin,  i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define  _for(i, end) for (__typeof(end) i = 0, _len = (end); i < (_len); i += 1)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define readint ({int t;cin >> t;t;})

const double PI = 2 * acos(.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1000000000000000005LL;;
const ll MOD = (ll) (1e9) + 7;

void _mod(ll &x) { x = mod(x, MOD); }

//const ll MOD = (ll) 998244353 ;
const double EPS = 1e-10;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}


//#define int ll

int least[2010101], _least[2010101];
int Num[301];
vector<int> _Num;



class ExactChange {
public:

    void solve(std::istream &cin, std::ostream &cout) {
        int N;
        N = 1e6;
        rep(i, 0, 301)Num[i] = (i + 1) * (i + 2) * (i + 3) / 6;
        int j = 0;
        rep(i, 0, 301)if ((i + 1) * (i + 2) * (i + 3) / 6 & 1)_Num.push_back((i + 1) * (i + 2) * (i + 3) / 6);
        Fill(least, (int) 1e7);
        Fill(_least, (int) 1e7);
        least[0] = _least[0] = 0;
        _for(i, 301)
            _for(j, (int) 1e6 + 1)
                if (j + Num[i] <= N)
                    least[j + Num[i]] = min(least[j + Num[i]], least[j] + 1);

        _for(i, SZ(_Num))
            _for(j, (int) 1e6 + 1)
                if (j + _Num[i] <= N)
                    _least[j + _Num[i]] = min(_least[j + _Num[i]], _least[j] + 1);
        while (cin >> N && N) {
            cout << least[N] << " " << _least[N] << endl;
        };
    };

};


#undef int

int main() {
    ExactChange solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(0);
    ios::sync_with_stdio(0);
    out << fixed << setprecision(20);
    solver.solve(in, out);
    return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int dp[1000010];
int dp2[1000010];

signed main() {
	int n;
	while (cin >> n && n) {
		rep(i, 0, 1000010) {
			dp[i] = 10;
			dp2[i] = 10000000;
		}
		dp[0] = 0;
		dp2[0] = 0;
		rep(i, 1, 150) {
			int a = i*(i + 1)*(i + 2) / 6;
			if (a > n) break;
			rep(j, 0, n + 1) {
				if (j + a > n) break;
				dp[j + a] = min(dp[j + a], dp[j] + 1);
				if (a % 2 == 0) continue;
				dp2[j + a] = min(dp2[j + a], dp2[j] + 1);
			}
		}
		cout << dp[n] << " " << dp2[n] << endl;
	}
}

C++: #include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
int MAX_NUM = 1000000;
main(){
    vector<int> V,W;
    for(int i = 1;i * (i + 1) * (i + 2) / 6 <= MAX_NUM;i++){
        int num = i * (i + 1) * (i + 2) / 6; 
        V.push_back(num);
        if(i % 4 == 1)W.push_back(num);
    }
    vector<int> t1(MAX_NUM,INF),t2(MAX_NUM,INF);
    t1[0] = t2[0] = 0;
    rep(i,0,V.size()){
        rep(j,0,MAX_NUM){
            if(j + V[i] > MAX_NUM)break;
            t1[j + V[i]] = min(t1[j + V[i]], t1[j] + 1);
        }
    }
    rep(i,0,W.size()){
        rep(j,0,MAX_NUM){
            if(j + W[i] > MAX_NUM)break;
            t2[j + W[i]] = min(t2[j + W[i]], t2[j] + 1);
        }
    }
    int N;
    cin >> N;
    while(N){
        cout << t1[N] << " " << t2[N] << endl;
        cin >> N;
    }
}