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

using namespace std;

#define INF 1000000
#define MAX 1000000

int main(){
	vector <int> v(200);
	for(int i = 0; i < 200; i++)
		v[i] = i * (i + 1) * (i + 2) / 6;
	
	vector <int> d(MAX + 1, INF);
	vector <int> d2(MAX + 1, INF);
	
	d[0] = d2[0] = 0;
	for(int i = 1; i <= MAX; 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);
		}
	}
	
	while(1){
		int s;
		cin >> s;
		
		if(s == 0)
			break;
		
		
		
		
		cout << d[s] << " " << d2[s] << endl;
	}
	
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec; typedef pair<int, int> pi;
int dd[] = { 0, 1, 0, -1, 0 };
#define MAX 1000000
int all[MAX];
int odd[MAX];
int main()
{
	int cnt = 1;
	ivec A;
	while (true)
	{
		int d = cnt * (cnt + 1) * (cnt + 2) / 6;
		if (d < MAX)
		{
			A.push_back(d);
		}
		else break;
		cnt++;
	}
	for (int j = 0; j < MAX; j++)
	{
		all[j] = j;
		odd[j] = j;
	}

	for (int i = 1; i < A.size(); i++)
	{
		for (int j = A[i]; j < MAX; j++)
		{
			all[j] = min(all[j], all[j - A[i]] + 1);
			if (A[i] % 2 == 0)continue;
			odd[j] = min(odd[j], odd[j - A[i]] + 1);
		}
	}
	


	while (true)
	{
		int s;
		scanf("%d", &s);
		if (s == 0)break;
		printf("%d %d\n", all[s], odd[s]);
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define MOD 998244353
template<class T>inline bool chmax(T& a,T b){if (a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if (a>b){a=b;return 1;}return 0;}
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

int main() {
    while (true){
        ll n;
        cin >> n;
        if (n==0){
            break;
        }
        ll dp[n+1],odddp[n+1];
        fill(dp,dp+n+1,INF);
        fill(odddp,odddp+n+1,INF);
        dp[0]=odddp[0]=0;
        for (ll i=1;;i++){
            ll x=i*(i+1)*(i+2)/6;
            if (x>n)break;
            for (ll j=x;j<=n;j++){
                dp[j]=min(dp[j],dp[j-x]+1);
                if (x&1){
                    odddp[j]=min(odddp[j],odddp[j-x]+1);
                }
            }
        }
        cout << dp[n] << " " << odddp[n] << endl;
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
const int  N = 1000100;

int t1[200];
int t2[200];
int dp1[N] = {0};
int dp2[N] = {0};

int main(){
	int i,j,k=2,s;
	
	t1[1] = t2[1] = 1;
	dp1[1] = dp2[1] = 1;
	for(i = 2; i < N; i++){
		t1[i] = t1[i-1] * (i+2) / (i-1);
		if(t1[i] > N) break;
		dp1[t1[i]] = 1;
		if(t1[i]%2){ dp2[t1[i]] = 1; t2[k++] = t1[i];}
	}

	for(i = 2; i < N; i++){
		if(dp2[i]) continue;
		for(j = 1; t2[j] < i; j++){
			if(!dp2[i] || (1 + dp2[i-t2[j]]) < (dp2[i])){
				dp2[i] = 1 + dp2[i-t2[j]];
			}
		}
		if(dp1[i]) continue;
		for(j = 1; t1[j] < i; j++){
			if(!dp1[i] || (1 + dp1[i-t1[j]]) < (dp1[i])){
				dp1[i] = 1 + dp1[i-t1[j]];
			}
		}
	}

	while(cin >> s, s)
		cout << dp1[s] << ' ' << dp2[s] << endl;

	return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(int i = 0; i < n; i++)



int main() {
    ll s4[101];
    vector<ll> s4_k;
    s4[0] = 1;
    for(int i = 1; i < 101; i++){
        s4[i] = i * (i + 1) * (i + 2) / 6;
        if(s4[i] & 1){
            s4_k.push_back(i * (i + 1) * (i + 2) / 6);
            // cout << s4[i] << endl;
        }
    }
    vector<ll> dp1(100001, INF), dp2(100001, INF);
    dp1[0] = 0;
    REP(i, 101){
        REP(j, 100001){
            if(s4[i] <= j){
                dp1[j] = min(dp1[j], dp1[j - s4[i]] + 1);
            }
        }
    }
    
    dp2[0] = 0;
    REP(i, s4_k.size()){
        REP(j, 100001){
            if(s4_k[i] <= j){
                dp2[j] = min(dp2[j], dp2[j - s4_k[i]] + 1);
            }
        }
    }
    
    ll n;
    cin >> n;
    while(n != 0){
        cout << dp1[n] << ' ' << dp2[n] << endl;
        
        cin >> n;
    }
}