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>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    vi v;
    REP(i, 1, 1e3) {
        v.push_back(i*(i+1)*(i+2)/6);
        if(v.back() > 1e6) break;
    }
    vl dp1(1e6+10, INF), dp2(1e6+10, INF);
    dp1[0] = 0;
    dp2[0] = 0;
    for(auto&& x : v) {
        for(int i = 0; i+ x < dp1.size(); ++i) {
            chmin(dp1[i+x], dp1[i]+1);
            if(x&1LL) chmin(dp2[i+x], dp2[i]+1);
        }
    }
    int n;
    while(cin >> n && n) {
        cout << dp1[n] << " " << dp2[n] << endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
#include<algorithm>
#define int long long
using namespace std;
typedef pair<int,int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000000000
int MOD=1000000007;

signed main() {
  vector<int>seisi(0);
  vector<int>seisiki(0);
  int k=1,t=1;
  while(k<=1000000){
    k=t*(t+1)*(t+2)/6;
    seisi.push_back(k);
    if(k%2==1) seisiki.push_back(k);
    t++;
  }

  int dpkisu[1000001],dp[1000001];
  rep(i,1000001){
    dpkisu[i]=INF;
    dp[i]=INF;
  }
  dpkisu[0]=0;
  dp[0]=0;
  for(int x=1;x<1000001;x++){
    rep(i,seisi.size()){
      if(seisi[i]<=x){
        dp[x]=min(dp[x],dp[x-seisi[i]]+1);
      }
    }
    rep(i,seisiki.size()){
      if(seisiki[i]<=x){
        dpkisu[x]=min(dpkisu[x],dpkisu[x-seisiki[i]]+1);
      }
    }

  }
  while(true){
    int l;cin>>l;
    if(l==0) exit(0);
    cout<<dp[l]<<' '<<dpkisu[l]<<endl;
  }
}

C++: #include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

#define INF 1000000

int main(){
	vector <int> v(200);
	for(int i = 0; i < 200; i++)
		v[i] = i * (i + 1) * (i + 2) / 6;
	
	while(1){
		int s, ans1, ans2;
		cin >> s;
		
		if(s == 0)
			break;
		
		for(int k = 1; k <= 2; k++){
			vector <int> d(s + 1, INF);
			
			d[0] = 0;
			for(int i = 1; i <= s; i++){
				for(int j = 0; v[j] <= i; j++){
					if(k == 1)
						d[i] = min(d[i], d[i - v[j]] + 1);
					else{
						if(v[j] % 2 != 0)
							d[i] = min(d[i], d[i - v[j]] + 1);
					}
				}
			}
			if(k == 1)
				ans1 = d[s];
			else
				ans2 = d[s];
			
		}
		
		cout << ans1 << " " << ans2 << endl;
	}
	
	return 0;
}

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

using namespace std;

const int MAX_N = 1000000;

vector<int> tetra;
vector<int> tetra_odd;

short dp[MAX_N+1];
short dp_odd[MAX_N];

void init() {
	int n = 1;
	while (true){
		int m = n * (n + 1) * (n + 2) / 6;
		if (m >= MAX_N * 10) {
			break;
		}
		tetra.push_back(m);
		if (m % 2 == 1) {
			tetra_odd.push_back(m);
		}
		n++;
	}
}

void solve() {
	dp[0] = dp_odd[0] = 0;
	for (int i = 1; i < MAX_N; i++) {
		short ans = 10;
		short ans_odd = 100;
		for (int j = 0; tetra[j] <= i; j++) {
			//cout << i << " " << tetra[j] << endl;
			ans = min(ans, dp[i-tetra[j]]);
		}
		
		for (int j = 0; tetra_odd[j] <= i; j++) {
			ans_odd = min(ans_odd, dp_odd[i-tetra_odd[j]]);
		}
		dp[i] = ans + 1;
		dp_odd[i] = ans_odd + 1;
		//cout << i << " " << dp[i] << " " << dp_odd[i] << endl;
	}
}

int main() {
	init();
	solve();
	while (true) {
		int n;
		cin >> n;
		if (n == 0) {
			break;
		}
		
		cout << dp[n] << " " << dp_odd[n] << endl;
	}
}

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

using namespace std;

int pollock[201];
int dp1[1000001] = { 0 };
int dp2[1000001] = { 0 };

void dp() {
	for (int i = 1; i <= 200; i++) {
		pollock[i] = i*(i + 1)*(i + 2) / 6;
	}

	for (int i = 0; i < 1000000; i++) {
		dp1[i] = i;
		dp2[i] = i;
	}

	for (int i = 2; i <= 1000000; i++) {
		for (int j = 1; j <= 200; j++) {
			if (pollock[j] > i) break;
			if (dp1[i - pollock[j]] + 1 < dp1[i]) dp1[i] = dp1[i - pollock[j]] + 1;
			if (pollock[j] % 2 == 1) {
				if (dp2[i - pollock[j]] + 1 < dp2[i]) dp2[i] = dp2[i - pollock[j]] + 1;
			}
		}
	}
}

int main() {
	dp();
	ifstream fin("test.txt");
	ofstream fout("ans.txt");
	int n;
	while (true) {
		cin >> n;
		if (n == 0) break;
		cout << dp1[n] << " " << dp2[n] << endl;
	}
	return 0;
}