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 <math.h>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;

typedef long long ll;

ll N;
const int MAX = 1e6+1;
ll dp[MAX];
ll kidp[MAX];

ll calc(ll x){
    return x *(x+1) * (x+2) / 6;    
}

int main(){

    vector<ll> nums;
    vector<ll> kinums;
    int k = 1;
    for(int i=0; i<190; i++){
        ll num = calc(k);
        nums.push_back(num);
        if(num % 2==1){
            kinums.push_back(num);
        }
        k++;
        // cout << num << endl;
    }
    fill(dp, dp+MAX, 1e9);
    fill(kidp, kidp+MAX, 1e9);
    sort(nums.begin(), nums.end());
    
    dp[0] = 0;
    kidp[0] = 0;
    for(int i=0; i<MAX; i++){
        for(int j=nums.size()-1; j>=0; j--){
            ll u = nums[j];
            if(i - u >= 0 && dp[i] > dp[i-u]+1){
                dp[i] = dp[i-u] + 1;
            }
        }
        for(int j=kinums.size()-1; j>=0; j--){
            ll u = kinums[j];
            if(i - u >= 0 && kidp[i] > kidp[i-u]+1){
                kidp[i] = min(kidp[i], kidp[i-u] + 1);
            }
        }
    }


    while(1){
        cin >> N;
        if(!N) break;

        cout << dp[N] << " " << kidp[N] << endl;
    }
    return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
	int N;
	int tri[200];
	static int ansA[1000000], ansB[1000000];
	for(int i=0;i<200;i++) tri[i] = i*(i+1)*(i+2)/6;
	ansA[0] = ansB[0] = 0;
	for(int i=1;i<1000000;i++){
		ansA[i] = ansB[i] = i;
		for(int j=0;i-tri[j]>=0;j++){
			ansA[i] = min(ansA[i], ansA[i-tri[j]]+1);
			if(tri[j]%2==1)
				ansB[i] = min(ansB[i], ansB[i-tri[j]]+1);
		}
	}
	while(cin >> N, N)
		cout << ansA[N] << " " << ansB[N] << endl;
}

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

int main(){
 int pol[201],ans[N],ans2[N];

 for(int i=0;i<N;i++)ans[i]=ans2[i]=N;
 for(int i=1;i<201;i++){
   pol[i]=i*(i+1)*(i+2)/6;
   if(pol[i]<N){
     ans[pol[i]]=1;
   if(pol[i]%2)ans2[pol[i]]=1;
   }
 }
 for(int i=1;i<=N;i++)
   for(int j=1;j<201;j++){
     if(i-pol[j]>=0 && pol[j]<N) ans[i]=min(ans[i-pol[j]]+ans[pol[j]],ans[i]);
     if(i-pol[j]>=0 && pol[j]%2 && pol[j]<N)ans2[i]=min(ans2[i-pol[j]]+ans2[pol[j]],ans2[i]);
   }
 while(1){
   
  int n;
   cin>>n;
   if(n==0) break;
  cout<<ans[n]<<" "<<ans2[n]<<endl;
 }

  
  return 0;
}

C++: #include<bits/stdc++.h>
const int MAX=1e6+10;
using namespace std;
int main(){
    vector<int>precal;
    vector<int>dp(MAX,MAX);
    vector<bool>flag(MAX,false);
    int n;
    precal.push_back(0);
    dp[0]=0;
    for(int i=1;;i++){
        int cnt=((i)*(i+1)*(i+2))/6;
        if(cnt>MAX)break;
        precal.push_back(cnt);
        flag[cnt]=true;
    }
    for(int i=1; i<=MAX-9;i++){
        if(flag[i]){dp[i]=1; continue;}
        int index=(int)(upper_bound(precal.begin(),precal.end(),i)-precal.begin());
        for(int j=0; j<=index;j++)
            dp[i]=min(dp[i],dp[precal[j]]+dp[i-precal[j]]);
    }
    vector<int>oddcal;
    vector<int>odp(MAX,MAX);
    vector<bool>oddflag(MAX,false);
    oddcal.push_back(0);
    odp[0]=0;
    for(int i=1;;i++){
        int cnt=(i*(i+1)*(i+2))/6;
        if(cnt>MAX)break;
        if(!(cnt%2))continue;
        oddcal.push_back(cnt);
        oddflag[cnt]=true;
    }
    for(int i=1; i<=MAX-9;i++){
        if(oddflag[i]){odp[i]=1;continue;}
        int index=(int)(upper_bound(oddcal.begin(), oddcal.end(), i)-oddcal.begin());
        for(int j=0;j<=index;j++)
            odp[i]=min(odp[i],odp[oddcal[j]]+odp[i-oddcal[j]]);
        
    }
    while(cin>>n,n){
        cout<<dp[n]<<" "<<odp[n]<<endl;
    }
}

C++: #include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
int pol[185];
vector<int> oddPol;
int minN[1000000];
int oddN[1000000];
int main(){
    for(int i=1;i<1000000;i++){
        minN[i]=5;
        oddN[i]=1000000;
    }
    for(int i=1;i<=180;i++){
        pol[i]=i*(i+1)*(i+2)/6;
        minN[pol[i]]=1;
        if(pol[i]%2==1){
            oddPol.push_back(pol[i]);
            oddN[pol[i]]=1;
        }
    }
    for(int i=1;i<1000000;i++){
        for(int j=1;pol[j]<=i && j<=180 && i+pol[j]<1000000;j++){
            minN[i+pol[j]]=min(minN[i+pol[j]],minN[i]+1);
        }
        for(int j=0;oddPol[j]<=i && j<oddPol.size() && i+oddPol[j]<1000000;j++){
            oddN[i+oddPol[j]]=min(oddN[i+oddPol[j]],oddN[i]+1);
        }
    }
    /*for(int i=1;i<=40;i++){
        cout<<i<<":"<<oddN[i]<<endl;
    }*/
    int n;
    while(cin>>n,n!=0){
        cout<<minN[n]<<" "<<oddN[n]<<endl;
    }
    return 0;
}