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<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


#define repi(i,a,b) for(ll i = (a); i < (b); i++)
#define rep(i, n) for(ll i = 0; i < (n); ++i)


ll MOD = 1000000007;
int main() {
	vector<int> s;
	vector<int> k;
	for (int j = 1; true; ++j) {
		int x = j * (j + 1) * (j + 2) / 6;
		s.push_back(x);
		if (x % 2 == 1) k.push_back(x);
		if (x > 1000000) break;
	}
	vector<pair<int, int>> res;
	vector<pair<int, int>> ans;
	unordered_map<int, int> idx;
	list<int> q1;
	list<int> q2;	
	for(int i = 1; true; ++i) {
		int c; 
		cin >> c;
		if (c == 0) break;
		q1.push_back(c);
		q2.push_back(c);
		idx.insert(pair<int, int>(c, i));
	}
	res.resize(idx.size());
	bitset<1000001> b;
	b[0] = true;
	for (int i = 1; !q1.empty(); ++i) {
		bitset<1000001> buf = b;
		for (int j : s) buf |= (b << j);
		for (auto it = q1.begin(); it != q1.end();) {
			if (buf[*it]) {
				res[idx[*it]-1].first = i;
				it = q1.erase(it);
			}
			else it++;
		}
		b = buf;
	}
	b.reset();
	b[0] = true;
	for (int i = 1; !q2.empty(); ++i) {
		bitset<1000001> buf = b;
		for (int j : k) buf |= (b << j);
		for (auto it = q2.begin(); it != q2.end();) {
			if (buf[*it]) {
				res[idx[*it]-1].second = i;
				it = q2.erase(it);
			}
			else it++;
		}
		b = buf;
	}
	rep(i, res.size()) cout << res[i].first << " " << res[i].second << endl;
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;
typedef pair<int, int> P;

int d[1000001], d2[1000001];

int main()
{
	int tet[1001];
	for (int i = 1; i <= 1000; i++){
		tet[i] = i * (i + 1) * (i + 2) / 6;
	}
	
	fill(d, d + 1000001, INF);
	queue<P> que;
	for (que.push(P(0, 0)); que.size(); que.pop()){
		P p = que.front();
		if (d[p.first] <= p.second) continue;
		d[p.first] = p.second;
		for (int i = 1; p.first + tet[i] <= 1000000; i++){
			que.push(P(p.first + tet[i], p.second + 1));
		}
	}
	
	fill(d2, d2 + 1000001, INF);
	while (!que.empty()) que.pop();
	for (que.push(P(0, 0)); que.size(); que.pop()){
		P p = que.front();
		if (d2[p.first] <= p.second) continue;
		d2[p.first] = p.second;
		
		for (int i = 1; p.first + tet[i] <= 1000000; i++){
			if (tet[i] % 2 == 0) continue;
			que.push(P(p.first + tet[i], p.second + 1));
		}
	}
	
	int n;
	while (scanf("%d", &n), n){
		cout << d[n] << " " << d2[n] << endl;
	}
	
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int INF = 1000000007;
    int MAX = 1000100;

    vector<int> pollock;
    vector<int> dp(MAX, INF);
    vector<int> oddDp(MAX, INF);
    for (int i = 1; i <= int(pow(6 * MAX, 1.0 / 3.0)); i++) {
        pollock.push_back(i * (i + 1) * (i + 2) / 6);
    }
    dp[0] = 0;
    oddDp[0] = 0;
    for (int i = 0; i <= MAX; i++) {
        for (int j = 0; j < pollock.size(); j++) {
            if (i + pollock[j] > MAX) continue;
            dp[i + pollock[j]] = min(dp[i] + 1, dp[i + pollock[j]]);
            if (pollock[j] % 2 == 1) {
                oddDp[i + pollock[j]] = min(oddDp[i] + 1, oddDp[i + pollock[j]]);
            }
        }
    }
    while (1) {
        int n;
        cin >> n;
        if (!n) break;
        cout << dp[n] << " " << oddDp[n] << endl;
    }
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

const ll inf = LONG_LONG_MAX / 2 - 1;
vector<ll> cnt(200), odd;

void solve(ll n) {
    if (cnt[0] == 0) {
        rep(i, sz(cnt)) {
            cnt[i] = (i + 1) * (i + 2) * (i + 3) / 6;
            if (cnt[i] % 2 == 1) odd.push_back(cnt[i]);
        }
    }
    vector<ll> dp(n + 1, inf);
    rep(i, n + 1) dp[i] = i;
    reps(i, 1, sz(cnt)) {
        reps(j, cnt[i], n + 1) {
            dp[j] = min(dp[j], dp[j - cnt[i]] + 1);
        }
    }
    ll ans1 = dp[n];
    rep(i, n + 1) dp[i] = i;
    reps(i, 1, sz(odd)) {
        reps(j, odd[i], n + 1) {
            dp[j] = min(dp[j], dp[j - odd[i]] + 1);
        }
    }
    ll ans2 = dp[n];
    printf("%lld %lld\n", ans1, ans2);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    while(true) {
        ll t;
        cin >> t;
        if (t == 0) break;
        solve(t);
    }
    return 0;
}