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 FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

typedef long long LL;
template<typename T> using V = std::vector<T>;
template<typename T> using VV = std::vector<std::vector<T>>;
template<typename T> using VVV = std::vector<std::vector<std::vector<T>>>;

template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> inline void print(T x) { std::cout << x << std::endl; }
template<class T> inline void print_vec(const std::vector<T> &v) { for (int i = 0; i < v.size(); ++i) {  if (i != 0) {std::cout << " ";} std::cout << v[i];} std::cout << "\n"; }
template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; }
template<class T> inline double euclidean_distance(T y1, T x1, T y2, T x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }
template<class T> inline double manhattan_distance(T y1, T x1, T y2, T x2) { return abs(x1 - x2) + abs(y1 - y2); }

const int INF = 1L << 30;
const double EPS = 1e-9;
const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy4 = { 0, 1, 0, -1 }, dx4 = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）
const std::vector<int> dy8 = { 0, -1, 0, 1, 1, -1, -1, 1 }, dx8 = { 1, 0, -1, 0, 1, 1, -1, -1 };

using namespace std;


vector<int> solve(vector<int> &p) {
    vector<int> dp(1000010, INF);
    dp[0] = 0;

    FOR(i, 0, p.size()) {
        int v = p[i];
        FOR(j, 0, dp.size()) {
            if (dp[j] == INF) {
                continue;
            }
            if (j + v < dp.size()) {
                dp[j + v] = min(dp[j + v], dp[j] + 1);
            }
        }
    }

    return dp;
}

int main() {
    cin.tie(0);
	ios::sync_with_stdio(false);

    vector<int> p1, p2;
    FOR(i, 1, 200) {
        int v = i * (i + 1) * (i + 2) / 6;
        p1.emplace_back(v);
        if (v % 2 != 0) {
            p2.emplace_back(v);
        }
    }

    auto ans1 = solve(p1);
    auto ans2 = solve(p2);

    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        cout << ans1[n] << " " << ans2[n] << endl;
    }


	return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int c1[100000],c2[100000],i,m,p=0,dp1[100001],dp2[100001],k;
  for(i=0;i*(i+1)*(i+2)/6<=100000;i++){
    c1[i]=i*(i+1)*(i+2)/6;
    if(c1[i]%2==1){
      c2[p]=c1[i]; 
      p++; 
    }
  }
  while(1){
  cin >>m;
  if(m==0)break;
  for(int j=0;j<=m;j++){
    dp1[j]=j;
    dp2[j]=j;
    for(int k=0;k<i;k++){
      if(j-c1[k]>=0)dp1[j]=min(dp1[j],dp1[j-c1[k]]+1);
      if(k<p)
	if(j-c2[k]>=0){
	dp2[j]=min(dp2[j],dp2[j-c2[k]]+1);
       }
    }
  }
  cout << dp1[m]<<" "<<dp2[m]<<endl;
  }
 return 0;
}

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

#define MAXNUM 1000000
#define MAX 100
using namespace std;

int all[MAXNUM], odd[MAXNUM], fourall[MAXNUM], fourodd[MAXNUM];


int main()
{
	int n;
	int counter = 0;
	for (int i = 1; i < MAXNUM; i++){
		all[i] = MAX;
		odd[i] = MAX;

	}

	//1からMAXNUMまでの中に存在する正四面体数を洗い出す．
	int now = 0, four, allcounter = 0, oddcounter = 0;
	while (1){
		now++;
		four = now  *(now + 1)*(now + 2) / 6;
		all[four] = 1;
		fourall[allcounter++] = four;
		if (four % 2 == 1){
			odd[four] = 1;
			fourodd[oddcounter++] = four;
		}
		if (four > MAXNUM)
			break;
	}
	//cout << fourall[allcounter - 1] << endl;
	//cout << "ok" << endl;
	//cout << allcounter << endl;

	//1からMAXNUMまで，配列を埋める.
	for (int i = 1; i <= MAXNUM; i++){
		for (int j = 0; i > fourall[j]; j++){
			all[i] = min(all[i], 1 + all[i - fourall[j]]);
		}
			//cout << i << ":" << all[i]<<endl;

		for (int j = 0; i > fourodd[j]; j++){
			odd[i] = min(odd[i], 1 + odd[i - fourodd[j]]);
		}

	}

	//cout << "aaa" << endl;


	//入力
	while (cin >> n, n)
		cout << all[n] << " " << odd[n] << endl;

	return 0;

}

C++: #include <iostream>

using namespace std;

int main()
{
	static int p[1000];
	for(int i=0;i<1000;i++)
		p[i]=(i+1)*(i+2)*(i+3)/6;
	
	static int a[1000001],b[1000001];
	for(int i=0;i<1000001;i++)
		a[i]=b[i]=i;
	for(int i=0;i<1000;i++){
		for(int j=p[i];j<100001;j++)
			a[j]=min(a[j],a[j-p[i]]+1);
		if(!(p[i]&1)) continue;
		for(int j=p[i];j<100001;j++)
			b[j]=min(b[j],b[j-p[i]]+1);
	}
	
	for(int n;cin>>n,n;)
		cout<<a[n]<<" "<<b[n]<<endl;
	
	return 0;
}