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
//------------------------------------------
#include <bits/stdc++.h>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline long long toLL(string s) {long long v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const double EPS = 1e-12;
const long INF = 1000001;
const LL MOD=100007;

long dp1[1000003],dp2[1000003];
int main(){
	LL t=1;
	vector<LL>poll,odd;
	LL n=1;
	while(t<=1000000){
		t=n*(n+1)*(n+2)/6LL;
		poll.PB(t);
		if(t%2)odd.PB(t);
		n++;
	}
	REP(i,1000002){
		dp1[i]=dp2[i]=INF;
	}
	dp1[0]=dp2[0]=0;
	dp1[1]=dp2[1]=1;
	FOR(i,2,1000001){
		auto itr1=upper_bound(ALL(poll),i);
		auto itr2=upper_bound(ALL(odd),i);
		//itr1--;itr2--;
		for(auto itr=poll.begin();itr!=itr1;itr++)dp1[i]=min(dp1[i],dp1[i-*itr]+1);
		for(auto itr=odd.begin();itr!=itr2;itr++)dp2[i]=min(dp2[i],dp2[i-*itr]+1);
	}
	long tt;
	while(cin>>tt&&tt!=0){
		cout<<dp1[tt]<<" "<<dp2[tt]<<endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int prime[200],dprime[100];
int dp[2000001];
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<=2000000;i++)
			dp[i]=i%4+i/4;
		for(int i=0;i<=n;i++){
			for(int j=0;j<count;j++)
				dp[i+prime[j]]=min(dp[i+prime[j]],dp[i]+1);
		}
		cout<<dp[n]<<" ";
		for(int i=0;i<=n;i++)
			dp[i]=i%35+i/35;
		for(int i=0;i<=n;i++){
			for(int j=0;j<dcount;j++)
				dp[i+dprime[j]]=min(dp[i+dprime[j]],dp[i]+1);
		}
		cout<<dp[n]<<endl;
	}
	return 0;
}

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

using namespace std;

int N;

typedef long long ll;

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

vector<int> makeS(int mod, int d) {
	int n = 1;
	vector<int> res;
	while (1) {
		if ( f(n) > N ) break;
		if ( f(n) % mod == d ) {
			res.push_back( f(n) );
		}
		++n;
	}
	return res;
}

const int inf = 1e9;
const int maxN = 1000000;
int dp[maxN+1];
int solve(const vector<int>& s) {
	fill(dp, dp+maxN, inf); dp[0] = 0;
	for (int i = 0; i < s.size(); ++i) {
		for (int j = 0; j <= N; ++j) {
			int nj = j + s[i];
			if (nj <= N) {
				dp[nj] = min(dp[nj], dp[j]+1);
			}
		}
	}
	return dp[N];
}

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

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

#define M 1000000

int odd[M + 10], all[M + 10];

void update(int *ar, int x){
	for(int i = x; i <= M; ++i){
		ar[i] = min(ar[i], ar[i - x] + 1);
	}
}

int main(){
	for(int i = 1; i <= M; ++i){
		odd[i] = all[i] = 10000000;
	}

	for(int i = 1; ; ++i){
		int x = i * (i + 1) * (i + 2) / 6;
		if(x > M){ break; }
		update(all, x);
		if(x & 1){ update(odd, x); }
	}
	
	int n;
	while(scanf("%d", &n), n){
		printf("%d %d\n", all[n], odd[n]);
	}
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define MAX 1000000
vector<int> v, vk;
void Setm(){
	for (int i = 1;; i++){
		int seti = (i * (i + 1) * (i + 2)) / 6;
		if (seti > MAX) break;
		v.push_back(seti);
		if (seti % 2 != 0) vk.push_back(seti);
	}
}

int main(){
	int n;
	Setm();
	while (1){
		cin >> n;
		if (n == 0) break;
		int min1 = MAX; //??¶??°+?\???°??§????¨?????????°
		int min2 = MAX; //?\???°??§????¨?????????°
		vector<int> st1;
		for (int i = 0; i < v.size(); i++){
			if (v[i] > n) break;
			st1.push_back(v[i]);
		}
		vector<int> st2;
		for (int i = 0; i < vk.size(); i++){
			if (v[i] > n) break;
			st2.push_back(vk[i]);
		}
		while (st1.size() != 0){
			int ans = n;
			int cnt = 0;
			
			for (int i = st1.size() - 1; i >= 0; i--){
				if (ans == 0) break;
				if (st1[i] <= ans){
					ans -= st1[i];
					cnt++;
					i++;
				}
			}
			min1 = min(min1, cnt);
			st1.erase(st1.end() - 1);
		}
		while (st2.size() != 0){
			int ans = n;
			int cnt = 0;

			for (int i = st2.size() - 1; i >= 0; i--){
				if (ans == 0) break;
				if (st2[i] <= ans){
					ans -= st2[i];
					cnt++;
					i++;
				}
			}
			min2 = min(min2, cnt);
			st2.erase(st2.end() - 1);
		}
		cout << min1 << " " << min2 << endl;
	}
	return 0;
}