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>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<queue>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef pair<int,P> Pii;
typedef long long int ll;
typedef pair<ll,ll> LLP;
int dx[6] = {1,0,0,-1,1,-1};
int dy[6] = {0,1,-1,0,1,-1};
#define INF 100000007
#define MOD 1000000007
#define ARRAY_MAX 1000005
//const ll INF = 1e17;

int dp[ARRAY_MAX];//dp[i]:数字iを作るのに必要な数字の個数
int dp2[ARRAY_MAX];
int num[300];

int main(){


    REP(i,ARRAY_MAX){
        dp[i] = dp2[i] = INF;
    }
    vector<int> odd;
    REP(i,200){
        num[i] = (i+1)*(i+2)*(i+3)/6;
        if(num[i] % 2 == 1){
            //奇数
            odd.push_back(num[i]);
        }
    }

    dp[0] = 0;
    for(int i = 0;i < 200;i++){
        for(int j = num[i];j < ARRAY_MAX;j++){
            dp[j] = min(dp[j],dp[j-num[i]]+1);
        }
    }

    dp2[0] = 0;//奇数のみ
    for(int i = 0;i < 200;i++){
        for(int j = num[i];j < ARRAY_MAX;j++){
            dp[j] = min(dp[j],dp[j-num[i]]+1);
        }
    }

    for(int i = 0;i < odd.size();i++){
        for(int j = odd[i];j < ARRAY_MAX;j++){
            dp2[j] = min(dp2[j],dp2[j-odd[i]]+1);
        }
    }

    int n;
    while(cin >> n,n){
        cout << dp[n] << " " << dp2[n] << endl;
    }



    return 0;
}

C++: using namespace std;
int main(){
  int n,cpn,data[N],i,cnt,minv,cal,l;
  for(i=1;i<=N;i++) data[i]=(i*(i+1)*(i+2))/6;
  while(1){
    cin >> n;
    if(n==0) break;
    cnt=n;
    cpn=n;
    minv=INFINITY;
    l=0;
    while(cnt){
      n=cpn;
      cal=0;
      for(i=n-l;i>=1;i--){
	cal+=n/data[i];
	n%=data[i];
      }
      minv=min(minv,cal);
      cnt--;
      l++;
    }
    cout << minv;
    n=cpn;
    cnt=n;
    minv=INFINITY;
    l=0;
    while(cnt){
      n=cpn;
      cal=0;
      for(i=n-l;i>=1;i--){
	if(data[i]%2==1){
	  cal+=n/data[i];
	  n%=data[i];
	}
      }
      minv=min(minv,cal);
      cnt--;
      l++;
    }
    cout << ' ' << minv << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;

int main() {
	
	int min0[1000000];
	int min1[1000000];
	fill(min0,min0+1000000,100);
	fill(min1,min1+1000000,100);

	for(int j=1;j<300;j++){
		int n = j*(j+1)*(j+2)/6;
		if( n>=1000000) break;
		min0[n] = 1;
		if((n%2)==1){
			min1[n] = 1;
		}
	}


	for(int i=1;i<1000000;i++)
	{
		for(int j=1;j<300;j++){
			int n = j*(j+1)*(j+2)/6;
			if( n+i>=1000000) break;
			min0[n+i] = min( min0[n+i], min0[i]+1);
			if( (n%2)==1){
				min1[n+i] = min( min1[n+i], min1[i]+1);
			}
		}
	}


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

	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
  int a[200]={0},b[150]={0},c[1500001]={0,1,2,3},d[1500001],k=0,i,j,n,p;
  for(i=1;i<200;i++)a[k++]=i*(i+1)*(i+2)/6;
  for(j=k=0,p=i;j<i;j++)if(a[j]%2)b[k++]=a[j];
  for(i=1;i<198;i++)for(j=a[i];j<a[i+1];j++)c[j]=c[j-a[i]]+1;
  for(i=0;i<36;i++)d[i]=i;
  for(i=1;i<k-2;i++)for(j=b[i];j<b[i+1];j++)d[j]=d[j-b[i]]+1;
  while(cin>>n,n)cout<<c[n]<<' '<<d[n]<<endl;
}

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

#define rep(i,n) for(int i=0;i<(int)n;++i)
#define SZ(a) (int)((a).size())
#define mp make_pair
#define pb push_back
#define F first
#define S second
typedef pair<int,int> PI;
int dx[] = {0,1,0,-1};
int dy[] = {-1,0,1,0};


int dp[1200000];
int odp[1200000];
int n;
void solve(){
  
}

int main(){
  rep(i,1200000) dp[i]=1<<28;
  rep(i,1200000) odp[i]=1<<28;

  dp[0]=0;
  odp[0]=0;
  
  for(int i=1;;++i){
    int p = i*(i+1)*(i+2)/6;
    if(p>1100000) break;
    //cout <<  i << endl;
    for(int j=0;j+p<1200000;++j)
      dp[j+p]=min(dp[j+p],dp[j]+1);
    if(p&1)
      for(int j=0;j+p<1200000;++j)
        odp[j+p]=min(odp[j+p],odp[j]+1);
      // for(int j=110000-p;j>=0;--j)
      //   odp[j+p]=min(odp[j+p],odp[j]+1);
  }
  
  //return 0;
  
  while(cin >> n,n) cout << dp[n] << " " << odp[n] << endl;
}