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"

#define REP(i,num) for(ll i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

template<typename T>
bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>
bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	vll Q(200),O;
	REP(i,200){
		Q[i] = (i+1ll)*(i+2ll)*(i+3ll)/6ll;
		if(Q[i]%2) O.push_back(Q[i]);
	}

	vll dp(1000010),dp2(1000010);
	REP(i,1000010){
		dp[i]=1ll<<60;
		dp2[i]=1ll<<60;
	}
	dp[0]=0,dp2[0]=0;
	int X=Q.size(),Y=O.size();
	REP(i,X){
		REP(j,1000000){
			if(j+Q[i]<=1000000) chmin(dp[j+Q[i]],dp[j]+1);
		}
	}
	REP(i,Y){
		REP(j,1000000){
			if(j+O[i]<=1000000) chmin(dp2[j+O[i]],dp2[j]+1);
		}
	}
	while(true){
		int N=in();
		if(!N) break;
		
		out(dp[N],dp2[N]);
	}
	return 0;
}

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

int main(){
  int i,j,k;
  int x,y;
  int inf = 1 << 10;
  int m[200]={};
  int memo[1000005]={};
  int memo2[1000005]={};
  vector <int>  odd;
  fill(memo,memo+1000005,inf);
  fill(memo2,memo2+1000005,inf);
  for(i=1;i<201;i++) {
    m[i-1]=i*(i+1)*(i+2)/6;
    if(m[i-1]%2==1) odd.push_back(m[i-1]);
  }
  memo[0]=0;
  for(i=0;i<200;i++) {
    for(j=m[i];j<1000005;j++){
      memo[j]=min(memo[j],memo[j-m[i]]+1);
    }
  }
  memo2[0]=0;
  for(i=0;i<odd.size();i++) {
    for(j=odd[i];j<1000005;j++){
      memo2[j]=min(memo2[j],memo2[j-odd[i]]+1);
    }
  }
  int n;
  cin >> n;
  while(n!=0){
    cout << memo[n] << " " <<  memo2[n] << endl;
    cin >> n;
  }
  return 0;
}

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

using namespace std;

#define INF 100000

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

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

using namespace std;

typedef pair<int, int> pii;
typedef pair<pii, int> ppiii;

int main() {
    int table1[100000];
    int max1;
    for (int i = 1; i < 100000; i++) {
        table1[i] = i * (i + 1) * (i + 2) / 6;
        if (table1[i] >= 1000000) {
            max1 = i - 1;
            break;
        }
    }
    int table2[100000];
    int max2;
    for (int i = 1; i < 100000; i++) {
        int n = i;
        do {
            table2[i] = n * (n + 1) * (n + 2) / 6;
            n++;
        } while (table2[i] % 2 == 0);
        if (table2[i] >= 1000000) {
            max2 = i - 1;
            break;
        }
    }

    int m;
    while (cin >> m, m) {
        bool used[1000000];
        fill_n((bool *)used, 1000000, false);
        priority_queue<ppiii, vector<ppiii>, greater<ppiii>> q;
        q.push({{0, 0}, 1});
        while (!q.empty()) {
            ppiii p = q.top(); q.pop();
            int count = p.first.first;
            int total = p.first.second;
            int now = p.second;

            // goal
            if (total == m) {
                cout << count << " ";
                break;
            }

            for (int i = now; i < max1; i++) {
                int sum = table1[i] + total;
                if (sum <= m && !used[sum]) {
                    q.push({{count+1, sum}, i});
                    used[sum] = true;
                }
            }
        }
        while(!q.empty())
            q.pop();
        fill_n((bool *)used, 1000000, false);
        q.push({{0, 0}, 1});
        while (!q.empty()) {
            ppiii p = q.top(); q.pop();
            int count = p.first.first;
            int total = p.first.second;
            int now = p.second;

            // goal
            if (total == m) {
                cout << count << endl;
                break;
            }

            for (int i = now; i < max2; i++) {
                int sum = table2[i] + total;
                if (table2[i] % 2 && sum <= m && !used[sum]) {
                    q.push({{count+1, sum}, i});
                    used[sum] = true;
                }
            }
        }
    }
    
    return 0;
}