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;
int prime[200],dprime[100];
int dp[1000001];
int main(){
	int a=1,b=2,count=1,dcount=1;
	prime[0]=1,dprime[0]=1;
	while(true){
		a+=b;
		b++;
		if(prime[count-1]+a>=1000000)
			break;
		if((prime[count-1]+a)%2==1){
			dprime[dcount]=prime[count-1]+a;
			dcount++;
		}
		prime[count]=prime[count-1]+a;
		count++;
	}
	int n;
	while(true){
		cin>>n;
		if(n==0)
			break;
		for(int i=0;i<=n;i++)
			dp[i]=i;
		for(int i=0;i<=n;i++){
			int f=1;
			while(true){
				dp[i+prime[f]]=min(dp[i+prime[f]],dp[i]+1);
				f++;
				if(f==count)
					break;
				if(prime[f]>n)
					break;
			}
		}
		cout<<dp[n]<<" ";
		for(int i=0;i<=n;i++)
			dp[i]=i;
		for(int i=0;i<=n;i++){
			int f=1;
			while(true){
				dp[i+dprime[f]]=min(dp[i+dprime[f]],dp[i]+1);
				f++;
				if(f==dcount)
					break;
				if(prime[f]>n)
					break;
			}
		}
		cout<<dp[n]<<endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define BORDER (int)1e6
#define INF (int)1e7

using namespace std;

int main(){
	vector<int> t(1,0),t1(1,0);
	int c=1;
	while(t[c-1]<=BORDER){
		int temp;
		temp=c*(c+1)*(c+2)/6;
		t.push_back(temp);
		if(temp%2==1 ){
			t1.push_back(temp);
		}
		c++;
	}

    vector<int> table(BORDER,0),table1(BORDER,0);

    for(int i = 1; i < BORDER; i++){
        int ans = INF;
        for(int j = 1; j < t.size(); j++){
            if(t[j] > i)break;
            if(i - t[j] >= 0){
                ans = min( ans, table[i-t[j]]+1);
            }
        }
        table[i] = ans;
        ans = INF;
        for(int j = 1; j < t1.size(); j++){
            if(t1[j] > i) break;
            if(i - t[j] >= 0){
                ans = min( ans, table1[ i - t1[j]] + 1);
            }
        }
        table1[i] = ans;
    }



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

C++: #include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fr first
#define se second
#define pb push_back

//----***入出力***---
#define print(out) cout<< out  << "\n";
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

vector<vector<int>>dp(30,vector<int>(500,0));

signed main(){
  int a;
  vector<int> input;
  while(true){
    cin>>a;
    if(a==0)break;
    input.push_back(a);
  }
  vector<int> pollock(200),dp0(1000010),dp1(1000010);

  REP(i,0,200){
    pollock[i]=(i+1)*(i+2)*(i+3)/6;
  }
  dp0[0]=dp1[0]=0;
  REP(i,1,1000002){
    dp0[i]=dp1[i]=i;
    REP(j,0,200){
      if(i<pollock[j])break;
      dp0[i]=min(dp0[i],dp0[i-pollock[j]]+1);
      if(pollock[j]%2==1){
        dp1[i]=min(dp1[i],dp1[i-pollock[j]]+1);
      }
    }
  }
  // debug(dp1)
  each(v,input){
    cout<<dp0[v]<<' '<<dp1[v]<<"\n";
  }


}

C++: #include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int inf = 1e9;
const int maxN = 1000000;

ll f(ll n) {
	return n * (n+1) * (n+2) / 6;
}

vector<int> makeS(int mod, int d) {
	vector<int> res;
	for (int n = 1; f(n) <= maxN; ++n) {
		if ( f(n) % mod == d ) {
			res.push_back( f(n) );
		}
	}
	return res;
}
vector<int> solve(const vector<int>& s) {
	vector<int> dp(maxN+1, inf); dp[0] = 0;
	for (int i = 0; i < s.size(); ++i) {
		for (int j = 0; j <= maxN; ++j) {
			int nj = j + s[i];
			if (nj <= maxN) {
				dp[nj] = min(dp[nj], dp[j]+1);
			}
		}
	}
	return dp;
}

int main() {
	vector<int> s0 = makeS(1, 0);
	vector<int> s1 = makeS(2, 1);
	vector<int> dp1 = solve(s0);
	vector<int> dp2 = solve(s1);
	int N;
	while (cin >> N, N) {
		cout << dp1[N] << " " << dp2[N] << endl;
	}
}