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> 

#define int long long
#define double long double

#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define ALL(v) (v).begin(), (v).end()

#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

using pi = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vpi = vector<pi>;
using vvi = vector<vi>;
using vvb = vector<vb>;

const int INF = 1e16;
const int MOD = 1e9+7;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    const int MAX = 1e6;
    int n = 1;
    vi pollock;
    while(true)
    {
        if(n*(n+1)*(n+2)/6 > MAX) break;
        pollock.pb(n*(n+1)*(n+2)/6);
        n++;
    }

    vi ans(MAX+1, INF);
    REP(i, pollock.size()) ans[pollock[i]] = 1;
    ans[0] = 0;
    REPS(i, MAX)
    {
        REP(j, pollock.size())
        {
            if(i >= pollock[j]) chmin(ans[i], ans[i-pollock[j]]+1);
        }
    }
    vi ans2(MAX+1, INF);
    REP(i, pollock.size()) if(pollock[i] % 2 == 1) ans2[pollock[i]] = 1;
    ans2[0] = 0;
    REPS(i, MAX)
    {
        REP(j, pollock.size())
        {
            if(pollock[j] % 2 == 1 && i >= pollock[j]) chmin(ans2[i], ans2[i-pollock[j]]+1);
        }
    }
    while(true)
    {
        int x; cin >> x;
        if(x == 0) break;
        cout << ans[x] << " " << ans2[x] << endl;
    }
}

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

int main(){
  int i,j,k;
  int x,y;
  int inf = 1 << 10;
  int m[200]={};
  int memo[1000005]={};
  int memo2[1000005]={};
  vector <int>  odd;
  fill(memo,memo+1000005,inf);
  fill(memo2,memo2+1000005,inf);
  for(i=1;i<201;i++) {
    m[i-1]=i*(i+1)*(i+2)/6;
    if(m[i-1]%2==1) odd.push_back(m[i-1]);
  }
  memo[0]=0;
  for(i=0;i<200;i++) {
    for(j=m[i];j<1000005;j++){
      memo[j]=min(memo[j],memo[j-m[i]]+1);
    }
  }
  memo2[0]=0;
  for(i=0;i<odd.size();i++) {
    for(j=odd[i];j<1000005;j++){
      memo2[j]=min(memo2[j],memo2[j-odd[i]]+1);
    }
  }
  int n;
  cin >> n;
  while(n!=0){
    cout << memo[n] << " " <<  memo2[n] << endl;
    cin >> n;
  }
  return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

#define rep(i, a) for (int (i) = 0; (i) < (a); (i)++)
#define reps(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define MP(a, b) make_pair((a), (b))
#define pb(a) push_back((a))
#define all(v) (v).begin(), (v).end()

#define MAX 1000000

int dp[MAX];
int dpk[MAX];
vector<int> v;
vector<int> vk;
int vn = 0;
int s = 1;


int main()
{
	v.pb(1);
	vk.pb(1);
	for (int i = 2; ;i++) {
		s += i;
		if (s + v[vn] >= MAX) break;
		v.pb(s+v[vn]);
		vn++;
		if (v[vn] % 2) vk.pb(v[vn]);
	}
	v.pb(MAX+1);
	vk.pb(MAX+1);
	reps(i, 1, MAX) {
		dp[i] = dp[i-1] + 1;
		for (int j = 1; v[j] <= i; j++) {
			dp[i] = min(dp[i], dp[i-v[j]] + 1);
		}
	}
	reps(i, 1, MAX) {
		dpk[i] = dpk[i-1] + 1;
		for (int j = 1; vk[j] <= i; j++) {
			dpk[i] = min(dpk[i], dpk[i-vk[j]] + 1);
		}
	}
	int n;
	cin >> n;
	while(n) {
		cout << dp[n] << " " << dpk[n] << endl;
		cin >> n;
	}
}

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

const int MAX = 1000100;
const int INF = 1<<29;

int main() {
    vector<int> dp(MAX, INF), odddp(MAX, INF);
    dp[0] = odddp[0] = 0;
    for (int i = 1;; ++i) {
        int num = i * (i+1) * (i+2) / 6;
        if (num >= MAX) break;
        for (int j = num; j < MAX; ++j) {
            dp[j] = min(dp[j], dp[j-num]+1);
            if (num & 1) odddp[j] = min(odddp[j], odddp[j-num]+1);
        }
    }
    int n;
    while (cin >> n) {
        if (n == 0) break;
        cout << dp[n] << " " << odddp[n] << endl;
    }
}

C++: #include <iostream>
#include <queue>

using namespace std;

typedef pair<int, int> pii;

int main() {
    int table[1000000];
    int max;
    for (int i = 1; i < 1000000; i++) {
        table[i] = i * (i + 1) * (i + 2) / 6;
        if (table[i] >= 1000000) {
            max = i - 1;
            break;
        }
    }

    int m;
    while (cin >> m, m) {
        priority_queue<pii, vector<pii>, greater<pii>> q;
        q.push({0, 0});
        while (!q.empty()) {
            pii p = q.top(); q.pop();
            int count = p.first;
            int total = p.second;

            // goal
            if (total == m) {
                cout << count << " ";
                break;
            }

            for (int i = 1; i < max; i++) {
                if (table[i] + total <= m)
                    q.push({count+1, table[i] + total});
            }
        }
        while(!q.empty())
            q.pop();
        q.push({0, 0});
        while (!q.empty()) {
            pii p = q.top(); q.pop();
            int count = p.first;
            int total = p.second;

            // goal
            if (total == m) {
                cout << count << endl;
                break;
            }

            for (int i = 1; i < max; i++) {
                if (table[i] % 2 && table[i] + total <= m)
                    q.push({count+1, table[i] + total});
            }
        }
    }
    
    return 0;
}