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>
using namespace std;

#define MAX 1000000
#define INF 1000000000

int dp1[MAX + 1], dp2[MAX + 1];

int main()
{
    for (int i = 1; i <= MAX; i++)
    {
        dp1[i] = INF;
        dp2[i] = INF;
    }
    for (int n = 1; n * (n + 1) * (n + 2) / 6 <= MAX; n++)
    {
        int a = n * (n + 1) * (n + 2) / 6;
        for (int i = a; i <= MAX; i++)
        {
            dp1[i] = min(dp1[i], dp1[i - a] + 1);
        }
        if (a % 2 == 0)
            continue;
        for (int i = a; i <= MAX; i++)
        {
            dp2[i] = min(dp2[i], dp2[i - a] + 1);
        }
    }
    while (1)
    {
        int n;
        cin >> n;
        if (n == 0)
            break;
        cout << dp1[n] << " " << dp2[n] << endl;
    }
    return 0;
}

C++: #include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int dp[2][1000001];
const int INF=1e9;
int main(){
    vector<int>S;
    for(int i=1;true;i++){
        int val=i*(i+1)*(i+2)/6;
        if(val<=1000000)S.push_back(val);
        else break;
    }
    fill_n(*dp,2*1000001,INF);
    dp[0][0]=dp[1][0]=0;
    for(int i=1;i<=1000000;i++){
        for(int j=0;j<S.size();j++){
            int val=S[j];
            if(i-val<0)continue;
            dp[0][i]=min(dp[0][i],dp[0][i-val]+1);
            if(val&1)dp[1][i]=min(dp[1][i],dp[1][i-val]+1);
        }
    }
    int n;
    while(scanf("%d",&n),n){
        printf("%d %d\n",dp[0][n],dp[1][n]);
    }
    return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <string>
 
#define ll long long
 
using namespace std;
int main(void){
    ll  n, a[100000], b[100000], sum = 0, cntA=0, cntB=0, dp[100000][100000];
    while(cin >> n, n){
        int k=1;
        while(sum < n){
            sum = k * (k+1) * (k+2) / 6;
            if(sum <= n){
	            a[k] = sum;
	            cntA++;
	            if(k%2 == 1){
	                b[k] = sum;
	                cntB++;
	            }
            }
            k++;
        }
        for(int i=cntA;i>=0;i--){
        	for(int j=0;j<=n;j++){
        		dp[i][j] = 0;
            }
        }
        for(int i=cntA-1;i>=0;i--){
            for(int j=0;j<=n;j++){
            	if(j<a[i]){
            		dp[i][j] = dp[i+1][j];
        			cout << dp[i][j];
        		}else{
    				dp[i][j] = min(dp[i+1][j], dp[i+1][j-a[i]] + 1);
        		}
            }
        }
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int n,i,j,k,t=0,a[250]={},b[200]={},c[1000005]={2000000},d[1000005]={2000000};
  for(i=1;i<250;i++) {
    a[i-1]=i*(i+1)*(i+2)/6;
    if(a[i-1]%2==1)b[t++]=a[i-1];
  }
  for(i=c[0]=d[0]=0;i<250;i++) {
    for(j=a[i];j<1000005;j++){
      c[j]=min(c[j],c[j-a[i]]+1);
    }
  }
  for(i=0;i<t;i++) {
    for(j=b[i];j<1000005;j++){
      d[j]=min(d[j],d[j-b[i]]+1);
    }
  }
  while(cin>>n,n)cout<<c[n]<<" "<<b[n]<<endl;
return 0;
}

C++: #include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

const int MAX_V=1000010;
unsigned int dp[MAX_V]{};
unsigned int dpodd[MAX_V]{};
set<int> tetras{-1};
set<int> oddtetras{-1};
int main(){ _;
  int n;
  for(int i=1;;i++){
    int k=i*(i+1)*(i+2)/6;
    if(k>MAX_V)break;
    tetras.insert(k);
    if((k>>1)<<1!=k)//odd
      oddtetras.insert(k);
  }
  for(int i=1;i<MAX_V;i++){
    auto tetra=tetras.upper_bound(i);
    int j=*(--tetra);
    int k=*(--tetra);
    dp[i]=k<0?dp[i-j]+1:min(dp[i-j],dp[i-k])+1;
    auto oddtetra=oddtetras.upper_bound(i);
    j=*(--oddtetra);
    k=*(--oddtetra);
    dpodd[i]=k<0?dpodd[i-j]+1:min(dpodd[i-j],dpodd[i-k])+1;
  }
  while(cin>>n,n!=0){
    cout<<dp[n]<<" "<<dpodd[n]<<endl;
  }
}