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 <vector>

using namespace std;

int n;
vector<int> vec, vec2;
int dp[1000005], dp2[1000005];

int main(void)
{
  for(long long i = 1; i*(i+1)*(i+2)/6 <= 1000000; i++){
    long long x = i*(i+1)*(i+2)/6;
    if(x % 2) vec2.push_back(x);
    vec.push_back(x);
  }
  //for(int i = 0 ;i < vec.size(); i++) cout << vec[i] << " "; cout << endl;

  while(1){
    cin >> n;
    if(n == 0) break;

    for(int i = 0; i <= n; i++) dp[i] = dp2[i] = 1e9;
    dp[0] = dp2[0] = 0;
    for(int i = 0; i < n; i++){
      for(int j = 0; j < vec.size(); j++){
        if(i+vec[j] <= n) dp[i+vec[j]] = min(dp[i+vec[j]], dp[i]+1);
      }
      for(int j = 0; j < vec2.size(); j++){
        if(i+vec2[j] <= n) dp2[i+vec2[j]] = min(dp2[i+vec2[j]], dp2[i]+1);
      }
    }
    //for(int i = 0; i <= n; i++) cout<< dp[i] << " "; cout << endl;
    cout << dp[n] << " " << dp2[n] << endl;
  }
  return 0;
}

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

constexpr int MAX_N = 1e6;

template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }

vector<int> init() {
	vector<int> num;
	int sum = 0;
	for(int i = 1;; ++i) {
		sum += i;
		if(sum > MAX_N) break;
		num.emplace_back(sum);
	}

	partial_sum(num.begin(), num.end(), num.begin());
	return num;
}

int main() {
	const auto num = init();

	vector<int> dp(MAX_N + 1, INT_MAX);
	vector<int> odd_dp(MAX_N + 1, INT_MAX);
	dp[0] = odd_dp[0] = 0;

	for(unsigned i = 0; i < num.size(); ++i) {
		const int &value = num[i];

		for(int j = 0; j + value <= MAX_N; ++j) {
			chmin(dp[j + value], dp[j] + 1);
		}

		if(value & 1) {
			for(int j = 0; j + value <= MAX_N; ++j) {
				chmin(odd_dp[j + value], odd_dp[j] + 1);
			}
		}
	}

	for(int n; cin >> n && n;) {
		cout << dp[n] << " " << odd_dp[n] << endl;
	}

	return 0;
}

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<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;
vector<int> V,W;
int MAX_NUM = 1000000;
vector<int> table(MAX_NUM);
P dp(int N){
    P ans;
    table.assign(N+1,INF);
    table[0] = 0;
    rep(i,0,V.size()){
        rep(j,0,N+1){
            if(j - V[i] >= 0)table[j] = min(table[j], table[j - V[i]] + 1);
        }
    }
    ans.first = table[N]; 
    table.assign(N+1,INF);
    table[0] = 0;
    rep(i,0,W.size()){
        rep(j,0,N+1){
            if(j - W[i] >= 0)table[j] = min(table[j], table[j - W[i]] + 1);
        }
    }
    ans.second = table[N];
    return ans;
}
main(){
    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);
    }

    int N;
    cin >> N;
    while(N){
        auto ans = dp(N);
        cout << ans.first << " " << ans.second << endl;
        cin >> N;
    }
}

C++: #include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>

using namespace std;

#define INF 1000000

int dp[1000001];
int dp2[1000001];

int main(){
    int a[200];
    memset(dp, INF, sizeof(dp));
    memset(dp2, INF, sizeof(dp2));
    
    for(int i=1;i<200;i++){
        a[i] = i*(i+1)*(i+2)/6;
        if(a[i] > 1000000) break;
        dp[a[i]] = 1;
        if(a[i]%2) dp2[a[i]]=1;
    }

    for(int i=1;i<1000001;i++){
        for(int j=1;j<200;j++){
            if(i+a[j] > 1000000) break;
            dp[i+a[j]] = min(dp[i+a[j]], dp[i]+1);
            if(a[j]%2) dp2[i+a[j]] = min(dp2[i+a[j]], dp2[i]+1);
        }
    }
    int n;
    while(cin >> n && n){
        printf("%d %d\n", dp[n], dp2[n]);
    }
}