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>
using namespace std;
#define rep(i,n) for(long long int i=0;i<n;++i)
typedef long long int ll;

int cal(int n){
    int ret=(ll)n*(n+1)*(n+2)/6;
    return ret;
}

int main(){

    vector<int> dp(1e+6,1e+6),odp(1e+6,1e+6);
    dp[0]=0;
    odp[0]=0;
    dp[1]=1;
    odp[1]=1;
    vector<int> c,oc;
    for(int i=0;cal(i)<2e+6;i++){
        c.push_back(cal(i));
        if(cal(i)%2==1){
            oc.push_back(cal(i));
        }
    }
    for(int i=2;i<1e+6;i++){
        for(int j=0;c[j]<=i;j++){
            dp[i]=min(dp[i],dp[i-c[j]]+1);
        }
    }
    for(int i=2;i<1e+6;i++){
        for(int j=0;oc[j]<=i;j++){
            odp[i]=min(odp[i],odp[i-oc[j]]+1);
        }
    }

    while(1){
        int n;
        cin >> n;
        if(n==0){
            break;
        }
        cout << dp[n] << " " << odp[n] << endl;
    }

    return 0;
}

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

int main()
{
  int N,S[1000],SS[1000],SSS[1000],P[100001],OP[100001],a=0;
  S[0]=0;P[0]=0;OP[0]=0;
  for(int i=1;i<100001;i++){
    OP[i]=P[i]=10000001;
  }
  for(int i=1;i<190;i++){
    S[i]=S[i-1]+i;
  }
  SS[0]=0;
  for(int i=1;i<190;i++){
    SS[i]=SS[i-1]+S[i];
    if(SS[i]%2==1)SSS[a++]=SS[i];
  }
  for(int i=0;i<a;i++){
    for(int j=SSS[i];j<100001;j++){
      OP[j]=min(OP[j],OP[j-SSS[i]]+1);
    }
  }
  for(int i=1;i<190;i++){
    for(int j=SS[i];j<100001;j++){
      P[j]=min(P[j],P[j-SS[i]]+1);
    }
  }
  while(1){
    cin>>N;
    if(N==0)break;
    cout<<P[N]<<" "<<OP[N]<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <map>
#include <vector>
#include <utility>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vec vector
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

using namespace std;

int main(){
    vector<int> v,oddv;
    for(ll i=1;;i++){
        if(i*(i+1)*(i+2)/6<=2000000){
            v.pb(i*(i+1)*(i+2)/6);
        }
        else break;
    }
    int ans1[1000010],ans2[1000010];
    rep(i,0,1000010) ans1[i]=ans2[i]=INF;
    ans1[0]=0; ans2[0]=0;
    rep(i,0,1000000){
        ans1[i]=i; ans2[i]=i;
        for(int j=0;i>=v[j];j++){
            ans1[i]=min(ans1[i-v[j]]+1,ans1[i]);
            if(v[j]%2==1)ans2[i]=min(ans2[i],ans2[i-v[j]]+1);
        }
    }

    int n;
    while(cin>>n&&n){
        cout<<ans1[n]<<" "<<ans2[n]<<endl;
    }
    
    return 0;
}

C++: // ACM-ICPCà\I2010 C. |bN\z

#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 <iostream>
using namespace std;

#define MAX 100000
#define INF (1<<24)
int n[1000],M;

int dp[100005];
int od[100005];

int main()
{
	for(M=1; ; M++)
	{
		int v=M*(M+1)*(M+2)/6;
		if(v>MAX) break;
		n[M]=v;
	}

	int N;
	while(cin >> N, N)
	{
		for(int i=0; i<=N; i++)
		{
			dp[i]=INF;
			od[i]=INF;
		}

		dp[0]=od[0]=0;

		for(int i=1; i<M; i++)
		for(int j=0; j<=N; j++) 
		{
			if(j+n[i] > N) break;
			if(dp[j]!=INF)
			{
				dp[j+n[i]]=min(dp[j+n[i]], dp[j]+1);
			}
			if(od[j]!=INF&&n[i]%2==1)
			{
				od[j+n[i]]=min(od[j+n[i]], od[j]+1);
			}
		}

		cout << dp[N] << " " << od[N] << endl;
	}


}

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

const int MAX = 1000100;

vector<int> tetras;
vector<int> oddTetras;

int dp[MAX];
int oddDp[MAX];

int main() {
	for (int i = 1; i < 200; i++) {
		int n = i * (i + 1) * (i + 2) / 6;
		tetras.push_back(n);
		if (n % 2 == 1)
			oddTetras.push_back(n);
	}

	for (int i = 0; i < MAX; i++) {
		dp[i] = oddDp[i] = i;
	}
	for (int i = 1; i < MAX; i++) {
		for (int j = 0; tetras[j] <= i; j++) {
			dp[i] = min(dp[i], dp[i - tetras[j]] + 1);
		}
		for (int j = 0; oddTetras[j] <= i; j++) {
			oddDp[i] = min(oddDp[i], oddDp[i - oddTetras[j]] + 1);
		}
	}

	int n;
	while (cin >> n , n != 0) {
		cout << dp[n] << " " << oddDp[n] << endl;
	}
}

C++: #include <iostream>
using namespace std;
int main(){
  int a[200]={0},b[150]={0},c[2000001]={0,1,2,3},d[2000001],k=0,i,j,n;
  for(i=1;i<200;i++)a[k++]=i*(i+1)*(i+2)/6;
  for(j=k=0;j<i;j++)if(a[j]%2)b[k++]=a[j];
  for(i=1;i<195;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;
}