Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	io := NewIo()
	defer io.Flush()
	for {
		N, K, S := io.NextInt(), io.NextInt(), io.NextInt()
		if N == 0 {
			break
		}
		dp := [21][11][156]int{}
		for i := 0; i <= N; i++ {
			dp[i][0][0] = 1
		}
		for i := 1; i <= N; i++ {
			for j := 1; j <= K; j++ {
				for k := 1; k <= S; k++ {
					if k-i >= 0 {
						dp[i][j][k] += dp[i-1][j-1][k-i]
					}
					dp[i][j][k] += dp[i-1][j][k]
				}
			}
		}
		io.Println(dp[N][K][S])
	}
}

// I/O template
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buff []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buff = append(buff, line...)
		if !isPrefix {
			break
		}
	}
	return string(buff)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	s := io.tokens[io.nextToken]
	io.nextToken++
	return s
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntSlice(a []int) {
	b := make([]interface{}, 0, len(a))
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func (io *Io) PrintStringSlice(a []string) {
	b := make([]interface{}, 0, len(a))
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func ExampleIo() {
	io := NewIo()
	defer io.Flush()
	a := make([]int, 0, 3)
	a[0], a[1], a[2] = io.NextInt(), io.NextInt(), io.NextInt()
	io.Println(a)
	io.PrintIntSlice(a)
	Log("io", a)
}

C++: #include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repp(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;

int dp[11][21][200];

signed main(){
    int n ,k, s;
    while(1){
        cin >> n >> k >> s;
        if(n + k + s == 0) break;
        rep(i, 0, 11) rep(j, 0, 21) rep(l, 0, 200){
            dp[i][j][l] = 0;
        }
        dp[0][0][0] = 1;
        rep(i, 0, k){
            rep(j, 0, n + 1){
                rep(l, 0, 160){
                    rep(m, j + 1, n + 1){
                        if(l + m > 155) continue;
                        dp[i + 1][m][l + m] += dp[i][j][l];
                    }
                }
            }
        }
        int ans = 0;
        rep(i, 0, n + 1){
            ans += dp[k][i][s];
        }
        cout << ans << endl;
    }
}

C++: #include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int N, K, S;

int dfs(int cnt, int n, int sum){
  if(cnt == K && sum == S) return 1;
  int res = 0;
  if(cnt < K && sum + n <= S) FOR(i, n, N + 1) res += dfs(cnt + 1, i + 1, sum + i);
  return res;
}

int main() {
  while(cin >>N >>K >>S && N) cout <<dfs(0, 1, 0) <<endl;
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;

int cnt;

void dfs(int n, int k, int s) {
    if (k == 0 && s == 0) {
        cnt++;
        return;
    }
    if (n <= 0 || k <= 0 || s <= 0) {
        return;
    }

    dfs(n - 1, k - 1, s - n);
    dfs(n - 1, k, s);
}

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int n, k, s;
    while (cin >> n >> k >> s, n) {
        cnt = 0;
        dfs(n, k, s);
        cout << cnt << endl;
    }

}

C++: #include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

int main()
{
    while (true) {
        int n, k, s;
        cin >> n >> k >> s;
        if (n == 0 && k == 0 && s == 0) {
            break;
        }

        vector<int> v(n);
        iota(begin(v), end(v), 1);

        int count = 0;

        std::string bitmask(k, 1); // K leading 1's
        bitmask.resize(n, 0);      // N-K trailing 0's

        // print integers and permute bitmask
        do {
            int sum = 0;
            for (int i = 0; i < n; ++i) // [0..N-1] integers
            {
                if (bitmask[i]) {
                    sum += i + 1;
                }

                // std::cout << " " << i;
            }
            if (sum == s) {
                count += 1;
            }
            // std::cout << std::endl;
        } while (std::prev_permutation(bitmask.begin(), bitmask.end()));
        cout << count << endl;
    }
}

C++: #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++) 
using namespace std;

int main() {
  for (int n, k, s; cin >> n >> k >> s, n;) {
    int ans = 0;
    REP(b, 1 << n) {
      if (__builtin_popcount(b) != k) continue;
      int sum = 0;
      REP(i, n) {
        if (b >> i & 1) sum += i + 1;
      }
      if (sum == s) ans++;
    }
    cout << ans << endl;
  }
}

C++: #include <iostream>
#define llint long long

using namespace std;

llint n, m, s;
llint dp[25][15][165];

int main(void)
{
	while(1){
		cin >> n >> m >> s;
		if(n == 0 && m == 0 && s == 0) break;
		
		for(int i = 0; i <= n; i++){
			for(int j = 0; j <= m; j++){
				for(int k = 0; k <= s; k++){
					dp[i][j][k] = 0;
				}
			}
		}
		dp[0][0][0] = 1;
		for(int i = 0; i < n; i++){
			for(int j = 0; j <= m; j++){
				for(int k = 0; k <= s; k++){
					dp[i+1][j][k] += dp[i][j][k];
					dp[i+1][j+1][k+i+1] += dp[i][j][k];
				}
			}
		}
		cout << dp[n][m][s] << endl;
	}
	return 0;
}