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 <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

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




int main(){
	vector<int> dp1(1000100,inf);
	vector<int> dp2(1000100,inf);
		vector<int> opt1;
		vector<int> opt2;
		for(int i = 1; i*(i+1)*(i+2) <= 6*1000000; ++i){
			int t = i*(i+1)*(i+2)/6;
			opt1.push_back(t);
			if(t%2)opt2.push_back(t);
		}
		dp1[0] = 0;
		dp2[0] = 0;
		REP(i,1000100){
			rep(j,opt1.size()){
				if(opt1[j]>i)continue;
				chmin(dp1[i], dp1[i-opt1[j]]+1);
			}
		}
		REP(i,1000100){
			rep(j,opt2.size()){
				if(opt2[j]>i)continue;
				chmin(dp2[i], dp2[i-opt2[j]]+1);
			}
		}
		// REP(i,opt1.size()-1){
		// 	REP(j,N){
		// 		if(opt1[i]>j){
		// 			chmin(dp1[i][j], dp1[i-1][j]);
		// 		}else{
		// 			chmin(dp1[i][j], dp1[i-1][j]);
		// 			chmin(dp1[i][j], dp1[i-1][j-opt1[i]]+1);
		// 			chmin(dp1[i][j], dp1[i][j-opt1[i]]+1);
		// 		}
		// 	}
		// }
		// REP(i,opt2.size()-1){
		// 	REP(j,N){
		// 		if(opt2[i]>j){
		// 			chmin(dp2[i][j], dp2[i-1][j]);
		// 		}else{
		// 			chmin(dp2[i][j], dp2[i-1][j]);
		// 			chmin(dp2[i][j], dp2[i-1][j-opt2[i]]+1);
		// 			chmin(dp2[i][j], dp2[i][j-opt2[i]]+1);
		// 		}
		// 	}
		// }
		// ans1 = dp1[opt1.size()-1][N];
		// ans2 = dp2[opt2.size()-1][N];
		int N;
		int ans1, ans2;
		while(true){
			scanf("%d",&N);
			if(!N)break;
			ans1 = dp1[N]; ans2 = dp2[N];
			printf("%d %d\n",ans1,ans2);
		}
	return 0;
}

C++: #include <iostream>
using namespace std;
#define rep(i, n) for(int i=0;i<(n);i++)
 
const int m = 1000001;
 
int dp[2][1000001];
 
int main() {
 
    rep(i, 2)rep(j, m)dp[i][j] = j;
 
    for(int i=1,a;a=i*(i+1)*(i+2)/6,a<m;i++)
        rep(k, m-a) {
            if(dp[0][k]< dp[0][k+a])dp[0][k+a] = dp[0][k] + 1;
            if(a%2 && dp[1][k] < dp[1][k+a])dp[1][k+a] = dp[1][k] + 1;
        }
 
    for(int n;cin>>n,n;)cout<<dp[0][n]<<' '<<dp[1][n]<<endl;
 
    return 0;
}

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

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
 
using namespace std;

using ll = long long;

vector<int> v, v1;

int main(){
	for(int i = 1;i * (i + 1) * (i + 2) / 6 <= 1e6;i++){
		v.push_back(i * (i + 1) * (i + 2) / 6);
	}
	for(int i = 1;i * (i + 1) * (i + 2) / 6 <= 1e6;i++){
		//cout<<i*(i+1)*(i+2)/6<<endl;
		if(i * (i + 1) * (i + 2) / 6 % 2 == 1)v1.push_back(i * (i + 1) * (i + 2) / 6);
	}
	int n = 1e6;
	vector<vector<int>> dp(2, vector<int>(n + 1, 1e9));
		dp[0][0] = 0;
		for(int i = 0;i < v.size();i++){
			for(int j = 0;j < n + 1;j++){
				dp[(i + 1)%2][j] = min(dp[i%2][j], dp[(i + 1)%2][j]);
				if(j + v[i] > n){
					continue;
				}

				dp[(i + 1)%2][j + v[i]] = min(dp[(i + 1)%2][j + v[i]], dp[i % 2][j] + 1);
				dp[(i + 1)%2][j + v[i]] = min(dp[(i + 1)%2][j] + 1, dp[(i + 1)%2][j + v[i]]);
			}
		}
		vector<vector<int>> dp1(2, vector<int>(n + 1, 1e9));
		dp1[0][0] = 0;
		for(int i = 0;i < v1.size();i++){
			for(int j = 0;j < n + 1;j++){
				dp1[(i + 1)%2][j] = min(dp1[i%2][j], dp1[(i + 1)%2][j]);
				if(j + v1[i] > n){
					continue;
				}

				dp1[(i + 1)%2][j + v1[i]] = min(dp1[(i + 1)%2][j + v1[i]], dp1[i%2][j] + 1);
				dp1[(i + 1)%2][j + v1[i]] = min(dp1[(i + 1)%2][j] + 1, dp1[(i + 1)%2][j + v1[i]]);
			}
		}
	while(cin >> n){
		if(n == 0)return 0;
		
		cout<<dp.back()[n]<<" "<<dp1.back()[n]<<endl;
	}
}

C++: #include <stdio.h>
#include <string.h>
#include <vector>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define INF (1<<28)

int dp[2][1000001];

int main() {
    vector<int> a[2];
    for(int i=1;; i++) {
        const int k = i*(i+1)*(i+2)/6;
        if(k>1000000) break;
        if(k%2) a[0].push_back(k);
        else a[1].push_back(k);
    }
    rep(i, 1000001) dp[0][i] = INF;
    dp[0][0] = 0;
    rep(k, a[0].size()) rep(i, 1000001-a[0][k]) {
        dp[0][i+a[0][k]] = min(dp[0][i+a[0][k]], dp[0][i]+1);
    }
    memcpy(dp[1], dp[0], sizeof(dp[0]));
    rep(k, a[1].size()) rep(i, 1000001-a[1][k]) {
        dp[0][i+a[1][k]] = min(dp[0][i+a[1][k]], dp[0][i]+1);
    }
    for(;;) {
        int n;
        scanf("%d", &n);
        if(n==0) return 0;
        printf("%d %d\n", dp[0][n], dp[1][n]);
    }
}