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 <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
#include <stack>
   
using namespace std;

int main()
{
    vector<vector<int> > tetra(2);
    for(int i = 1; (i * (i + 1) * (i + 2)) / 6 < 1000001; i++){
        tetra[0].push_back((i * (i + 1) * (i + 2)) / 6);
        tetra[((i * (i + 1) * (i + 2)) / 6) % 2].push_back((i * (i + 1) * (i + 2)) / 6);
    }
    // for(int i = 0; i < 2; i++){
    //     for(int j = 0; j < tetra[i].size(); j++){
    //         cout << tetra[i][j] << endl;
    //     }
    //     cout << endl;
    // }
    int result[1000001][2];
    for(int i = 0; i < 1000001; i++){
        for(int j = 0; j < 2; j++){
            result[i][j] = 1000001;
        }
    }
    result[0][0] = 0;
    result[0][1] = 0;
    for(int i = 0; i < 2; i++){
        for(int j = 0; j < tetra[i].size(); j++){
            for(int k = 0; k + tetra[i][j] < 1000001; k++){
                result[k + tetra[i][j]][i] = min(result[k + tetra[i][j]][i], result[k][i] + 1);
            }
        }
    }
    int n;
    while(1){
        cin >> n;
        if(n == 0)break;
        cout << result[n][0] << " " << result[n][1] << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cstring>
#define MAX 1000000
using namespace std;

int tetra[200];
int dp[MAX];
int dp2[MAX];

int main(void){
	int n;
	memset(dp,MAX,sizeof(dp));
	memset(dp2,MAX,sizeof(dp2));
	dp[0]=dp2[0]=0;
	for(int i=1;i<200;i++)
		tetra[i]=i*(i+1)*(i+2)/6;
	for(int i=1;i<200;i++){
		for(int j=0;j<MAX;j++){
			if(j+tetra[i]>=MAX)
				continue;
			dp[j+tetra[i]]=min(dp[j+tetra[i]],dp[j]+1);
			if(tetra[i]%2)
				dp2[j+tetra[i]]=min(dp2[j+tetra[i]],dp2[j]+1);
		}
	}
	while(cin >>n,n)
		cout << dp[n] <<" " << dp2[n] << endl;
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 30;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


ll dp[1100000], dpo[1100000];

int main() {

    rep(i, 1100000) dp[i] = INF, dpo[i] = INF;
    dp[0] = 0, dpo[0] = 0;

    rep(i, 1100000-1) {
        for(ll j = 1; j * (j+1) * (j+2) / 6 <= 1e6; j++) {
            ll x = j * (j+1) * (j+2) / 6;
            if(i >= x) {
                chmin(dp[i], dp[i - x] + 1);
                if(x % 2 == 1) chmin(dpo[i], dpo[i - x] + 1);
            }
        }
    }

    ll n;
    while(cin >> n) {
        if (!n) return 0;

        cout << dp[n] << " " << dpo[n] << endl;
    }
}

C++: #include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

int main(){
  vi A(0);
  vi dp1(1000001, INT_INF), dp2(1000001, INT_INF);
  for(int i = 1; i*(i+1)*(i+2)/6 < 1000000; i++){
    int x = i*(i+1)*(i+2)/6;
    A.push_back(x);
    dp1.at(x) = 1;
    if(x%2 == 1) dp2.at(x) = 1;
  }
  for(int i = 1; i <= 1000000; i++){
    for(int j = 0; j < A.size(); j++){
      if(A.at(j) >= i) break;
      chmin(dp1.at(i), dp1.at(i-A.at(j))+1);
      if(A.at(j) % 2 == 1){
        chmin(dp2.at(i), dp2.at(i-A.at(j))+1);
      }
    }
  }
  //cout << dp1.at(40) << endl << dp2.at(40) << endl;


  queue<int> result;
  while(true){
    int n;
    cin >> n;
    if(n == 0) break;
    result.push(n);
  }
  while(!result.empty()){
    int x = result.front(); result.pop();
    cout << dp1.at(x) << ' ' << dp2.at(x) << endl;
  }

}

C++: #include <iostream>
#include <vector>
int INF = 1e9;
std::vector<int> boroc(200);
void init(int n){
    for(int i = 0; i < n; i++) boroc[i] = i*(i + 1)*(i + 2) / 6;
}
int main(){
    int n = 1000000;
    init(200);
    int dp[n + 1], dp2[n + 1];
    for(int i = 0; i < n + 1; i++){
        dp[i] = INF;
        dp2[i] = INF;
    }
    dp[0] = 0;
    dp2[0] = 0;
    for(int i = 0; i < 200; i++){
        if(boroc[i] > n) break;
        dp[boroc[i]] = 1;
        if(boroc[i] % 2 == 1) dp2[boroc[i]] = 1;
    }
    for(int i = 1; i < 200; i++){
        int t = boroc[i];
        for(int j = 1; j + t < n; j++){
            dp[j + t] = std::min(dp[j] + 1, dp[j + t]);
        }
        if(t % 2 == 1){
            for(int j = 1; j + t < n; j++) dp2[j + t] = std::min(dp2[j] + 1, dp2[j + t]);
        }
    }
    while(1){
        int N;
        std::cin >> N;
        if(N == 0) break;
        std::cout << dp[N] << ' ' << dp2[N] << std::endl;
    }
}