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;

int main(){
    int n;
    vector<int> sime(1e2*5);
    for(int i=0;i<sime.size();i++){
        sime[i]=i*(i+1)*(i+2)/6;
    }
    while(cin>>n,n){
        const int INF=1e7;
        vector<int> times(n+1,INF);
                vector<int> odtimes(n+1,INF);   
        times[0]=0;
        odtimes[0]=0;
        for(int k=1;;k++){
            if(n<sime[k]) break;
            for(int i=0;i<times.size();i++){
                if(i-sime[k]>=0) times[i]=min(times[i],times[i-sime[k]]+1);                
            }
            if(sime[k]%2==1){
             for(int i=0;i<odtimes.size();i++){
                if(i-sime[k]>=0) odtimes[i]=min(odtimes[i],odtimes[i-sime[k]]+1);                
            }      
            }
        }
        
        cout<<times[n]<<" "<<odtimes[n]<<endl;
        
    }
}

C++: #include <iostream>

using namespace std;

int p(int i){
  return i * (i + 1) * (i + 2) / 6;
}


int main(void){

  int n = 100000;

      /* ???????¨??????? */
      int ans1[n+1];
      int ans2[n+1];
      for(int i = 1 ; i < n + 1 ; i++){
        ans1[i+1] = -1;
        ans2[i+1] = -1;
      }

      for(int i = 1 ; p(i) < n + 1 ; i++){
        ans1[p(i)] = 1;
        if(p(i) % 2 == 1){ ans2[p(i)] = 1; }
      }

      for(int i = 2 ; i <= n ; i++){
        if(ans1[i] == 1){
        }else{
          int min = 100000;
          for(int j = 1 ; j < i ; j++){
            if(ans1[j] + ans1[i - j] < min){
              min = ans1[j] + ans1[i - j];
            }
          }
          ans1[i] = min;
        }
      }

      for(int i = 2 ; i <= n ; i++){
        if(ans2[i] == 1){
        }else{
          int min = 100000;
          for(int j = 1 ; j < i ; j++){
            if(ans2[j] + ans2[i - j] < min){
              min = ans2[j] + ans2[i - j];
            }
          }
          ans2[i] = min;
        }
      }



  while(1){
    cin >> n;
    if(n == 0){return 0;}

    cout << ans1[n] << " " << ans2[n] << endl;
  }
}

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

vector<unsigned int> triq,subtriq;

void addtriq(unsigned int max){
	while(triq.back()<max){
		triq.push_back((triq.size()+1)*(triq.size()+2)*(triq.size()+3)/6);
		if(triq.back()%2==1)subtriq.push_back(triq.back());
	}
	return;
}

void calc(unsigned int cur,vector<unsigned int> list,unsigned int& cmin,unsigned int cstp){
	if(cstp>=cmin)return;
	for(vector<unsigned int>::reverse_iterator ri=list.rbegin();ri!=list.rend();++ri){
		int d=cur-(*ri);
		if(d==0){
			cmin=cstp;
			break;
		}
		if(d>0){
			calc(d,list,cmin,cstp+1);
		}
	}
	return;
}

int main(){
	triq.push_back(1);
	subtriq.push_back(1);
	while(true){
		unsigned int n,cmin;
		cin>>n;
		if(n==0)break;
		addtriq(n);
		cmin=-1;
		calc(n,triq,cmin,1);
		cout<<cmin<<' ';
		cmin=-1;
		calc(n,subtriq,cmin,1);
		cout<<cmin<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <queue>

using namespace std;

typedef pair<int, int> pii;

int main() {
    int table[1000000];
    int max;
    for (int i = 1; i < 1000000; i++) {
        table[i] = i * (i + 1) * (i + 2) / 6;
        if (table[i] >= 1000000) {
            max = i - 1;
            break;
        }
    }

    int m;
    while (cin >> m, m) {
        bool used[1000000];
        fill_n((bool *)used, 1000000, false);
        priority_queue<pii, vector<pii>, greater<pii>> q;
        q.push({0, 0});
        while (!q.empty()) {
            pii p = q.top(); q.pop();
            int count = p.first;
            int total = p.second;

            // goal
            if (total == m) {
                cout << count << " ";
                break;
            }

            for (int i = 1; i < max; i++) {
                int sum = table[i] + total;
                if (sum <= m && !used[sum]) {
                    q.push({count+1, sum});
                    used[sum] = true;
                }
            }
        }
        while(!q.empty())
            q.pop();
        fill_n((bool *)used, 1000000, false);
        q.push({0, 0});
        while (!q.empty()) {
            pii p = q.top(); q.pop();
            int count = p.first;
            int total = p.second;

            // goal
            if (total == m) {
                cout << count << endl;
                break;
            }

            for (int i = 1; i < max; i++) {
                int sum = table[i] + total;
                if (table[i] % 2 && sum <= m && !used[sum]) {
                    q.push({count+1, sum});
                    used[sum] = true;
                }
            }
        }
    }
    
    return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int dp[1000010];
int dp2[1000010];

signed main() {
	int n;
	while (cin >> n && n) {
		rep(i, 0, 1000010) {
			dp[i] = 10;
			dp2[i] = 10000000;
		}
		dp[0] = 0;
		dp2[0] = 0;
		rep(i, 1, 200) {
			int a = i*(i + 1)*(i + 2) / 6;
			rep(j, 0, n + 1) {
				if (j + a > n) continue;
				dp[j + a] = min(dp[j + a], dp[j] + 1);
				if (a % 2 == 0) continue;
				dp2[j + a] = min(dp2[j + a], dp2[j] + 1);
			}
		}
		cout << dp[n] << " " << dp2[n] << endl;
	}
}