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>

int tetrahedral_number (int n)
{
    return (n * (n + 1) * (n + 2)) / 6;
}


const int MAX_NUM = 1000000;

int* solve_regular_problem ()
{
    int* solutions = new int[MAX_NUM + 1];

    std::fill (solutions, solutions + MAX_NUM + 1, MAX_NUM);

    solutions[0] = 0;

    int cnt = 0;

    int i = 1;

    for (int tetra_num = 1; tetra_num < MAX_NUM; tetra_num = tetrahedral_number (++i))
    {

        for (int j = tetra_num; j < MAX_NUM; j++)
        {
            solutions[j] = std::min (solutions[j], solutions[j - tetra_num] + 1);
        }

    }

    return solutions;
}

int* solve_odd_problem ()
{
    int* solutions = new int[MAX_NUM + 1];

    std::fill (solutions, solutions + MAX_NUM + 1, MAX_NUM);

    solutions[0] = 0;

    
    int i = 1;

    for (int tetra_num = 1; tetra_num < MAX_NUM; tetra_num = tetrahedral_number(++i))
    {
        if (tetra_num % 2 != 0)
        {
            for (int j = tetra_num; j < MAX_NUM; j++)
            {
                solutions[j] = std::min (solutions[j], solutions[j - tetra_num] + 1);
            }

        }

    }

    return solutions;
}

int main ()
{

    auto solutions = solve_regular_problem ();

    auto odd_solutions = solve_odd_problem ();

    int n = 0;
    while (std::cin >> n, n != 0)
    {

        std::cout << solutions[n] << " " << odd_solutions[n] << std::endl;

    }

    return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
  int a[190]={0},b[60]={0},c[1000001]={0,1,2,3},d[1000001],k=0,i,j,n;
  for(i=1;i<190;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<189;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-1;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;
}

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

vector<int> poloc;
vector<int> poloc_odd;

void make_poloc()
{
	int n=1;
	while(1){
		int a = n*(n+1)*(n+2)/6;
		if(a > 1000000)
			break;
		
		poloc.push_back(a);
		if(a % 2 == 1)
			poloc_odd.push_back(a); 
		n++;
	}
}

int main()
{
	make_poloc();

	int n;
	int dp[1000001];
	for(int i=0;i<=1000000;i++){
		dp[i] = 1000000;
	}
	dp[0] = 0;
	for(int i=0;i<poloc.size();i++){
		for(int j=0;j<=1000000;j++){
				if(j+poloc[i] <= 1000000)
					dp[j+poloc[i]] = min(dp[j+poloc[i]],dp[j]+1);
			
		}
	}
	int dpp[1000001] = {0};
	for(int i=0;i<=1000000;i++){
		dpp[i] = 1000000;
	}
	dpp[0] = 0;
	for(int i=0;i<poloc_odd.size();i++){
		for(int j=0;j<=1000000;j++){
				if(j+poloc_odd[i] <= 1000000)
					dpp[j+poloc_odd[i]] = min(dpp[j+poloc_odd[i]],dpp[j]+1);
		}
	}
	
	while(cin >> n){
		if(n==0)
			break;
		cout << dp[n] << " " << dpp[n] << endl;
	}

	return 0;
	
}

C++: #include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 2;
double eps = 1e-11;

int dp[2][1000010];
int dpodd[2][1000010];

int main() {
    int num[200];
    int oddnum[200];
    int odd = 1;
    int N = 1000000;
    for (int i = 1; i < 200; i++) {
        num[i] = i * (i + 1) * (i + 2) / 6;
        if (num[i] % 2 == 1) {
            oddnum[odd] = num[i];
            odd++;
        }
    }
    for (int i = 0; i < 2; i++) {
        fill(dp[i], dp[i] + N + 10, iinf);
        fill(dpodd[i], dpodd[i] + N + 10, iinf);
    }
    dp[0][0] = 0;
    int last = 0;
    for (int i = 1; i < 200; i++) {
        fill(dp[i % 2], dp[i % 2] + N + 10, iinf);
        if (num[i] > N) {
            last = i - 1;
            break;
        }
        for (int j = 0; j <= N; j++) {
            if (j < num[i]) {
                dp[i % 2][j] = dp[(i + 1) % 2][j];
            } else {
                dp[i % 2][j] = min(dp[(i + 1) % 2][j], dp[i % 2][j - num[i]] + 1);
            }
        }
    }
    dpodd[0][0] = 0;
    int oddlast = 0;
    for (int i = 1; i < odd; i++) {
        fill(dpodd[i % 2], dpodd[i % 2] + N + 10, iinf);
        if (oddnum[i] > N) {
            oddlast = i - 1;
            break;
        }
        for (int j = 0; j <= N; j++) {
            if (j < oddnum[i]) {
                dpodd[i % 2][j] = dpodd[(i + 1) % 2][j];
            } else {
                dpodd[i % 2][j] = min(dpodd[(i + 1) % 2][j], dpodd[i % 2][j - oddnum[i]] + 1);
            }
        }
    }
    while (1) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        cout << dp[last % 2][n] << " " << dpodd[oddlast % 2][n] << endl;
    }
}