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 FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

typedef long long LL;
template<typename T> using V = std::vector<T>;
template<typename T> using VV = std::vector<std::vector<T>>;
template<typename T> using VVV = std::vector<std::vector<std::vector<T>>>;

template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> inline void print(T x) { std::cout << x << std::endl; }
template<class T> inline void print_vec(const std::vector<T> &v) { for (int i = 0; i < v.size(); ++i) {  if (i != 0) {std::cout << " ";} std::cout << v[i];} std::cout << "\n"; }
template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; }
template<class T> inline double euclidean_distance(T y1, T x1, T y2, T x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }
template<class T> inline double manhattan_distance(T y1, T x1, T y2, T x2) { return abs(x1 - x2) + abs(y1 - y2); }

const int INF = 1L << 30;
const double EPS = 1e-9;
const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy4 = { 0, 1, 0, -1 }, dx4 = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）
const std::vector<int> dy8 = { 0, -1, 0, 1, 1, -1, -1, 1 }, dx8 = { 1, 0, -1, 0, 1, 1, -1, -1 };

using namespace std;


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

	while (true) {
		int N, K, S;
		cin >> N >> K >> S;
		if (N == 0 and K == 0 and S == 0) {
			break;
		}

		vector<vector<vector<int>>> dp(N + 10, vector<vector<int>>(K + 10, vector<int>(S + 10)));
		dp[1][0][0] = 1;

		FOR(i, 1, N + 1) {
			FOR(j, 0, K + 1) {
				FOR(k, 0, S + 1) {
					dp[i + 1][j][k] += dp[i][j][k];
					if (k + i < dp[0][0].size()) {
						dp[i + 1][j + 1][k + i] += dp[i][j][k];
					}
				}
			}
		}
		print(dp[N + 1][K][S]);
	}

	return 0;
}

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

using namespace std;

int func(int x, int n, int k, int s){
	int ret = 0;
	if(s < 0) return 0;
	if(k < 0) return 0;
	if(n < 0) return 0;
	if(s == 0 && k==0) return 1;
	for(int i=min(n,s);i>=0;i--){
		//for(int j=0;j<x;j++) cout << " ";
		//cout << i << endl;
		ret += func(x+1, i-1,k-1,s-i);
	}
	return ret;
}

int main(){
	int n,k,s;
	while(cin >> n >> k >> s, n){
		cout << func(0, n, k, s) << endl;
	}
	
	return 0;
}

C++: #include <iostream>
#define N 20
using namespace std;
int n,k,s,C;
void Ess(int,int,int);
int main(){
  bool r;
  while(1){
    cin >> n >> k >> s;
    if(n==0&&k==0&&s==0) break;
    C=0;
    Ess(0,0,0);
    cout << C << endl;
  }
  return 0;
}
void Ess(int x,int sum,int cnt){
  if(n==x){
    if(cnt==k&&sum==s) C++;
    return ;
  }
  Ess(x+1,sum,cnt);
  Ess(x+1,sum+x+1,cnt+1);
}

C++: #include <bits/stdc++.h>
using namespace std;

int memo[21][11][156];

int rec(int n, int k, int s){
    if(n == 0 || k == 0) return (k==0 && s==0 ? 1 : 0);
    // if(memo[n][k][s] != -1) return memo[n][k][s];
    int res = 0;
    for(int i=1;i<=min(n,s);i++){
        res += rec(i-1, k-1, s-i);
    }
    return memo[n][k][s] = res;
}

bool solve(){
    int n, k, s;
    cin >> n >> k >> s;
    if(n == 0) return true;
    memset(memo, -1, sizeof(memo));
    cout << rec(n, k, s) << endl;
    return false;
}

int main(){
    while(!solve());
    return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
const int N = 20;

// next_combination version
// given an integer cur, next_combination returns an integer nxt s.t.
//   nxt has the same number of 1s as cur
//   nxt is bigger than cur
//   no integer between cur and nxt has the same number of 1s as cur (and nxt)
int next_combination(int cur)
{
  int r1 = cur & -cur;   // extracts the rightmost 1
  int moved1 = cur + r1; // cancel the rightmost run of 1s and put 1 on its left
  int rm1s = cur & ~moved1; // extracts the rightmost run of 1s
  int reset = (rm1s / r1) >> 1; // the run of 1s moved to LSD and made its length decreased by 1
  int nxt = moved1 | reset; // new combination
  return nxt;
}
int main(int argc, char *argv[])
{
  for(;;) {
    int n, k, s;
    cin >> n >> k >> s;
    if(n == 0 && k == 0 && s == 0) break;
    int cnt = 0;
    if(k <= n) {
      const int fin = ((1<<k) - 1) << (n-k);
      for(int i = (1<<k) - 1; i <= fin; i = next_combination(i)) {
        int ss = 0;
        for(int j = 1, x = 1; j <= i; j<<=1, x++) {
          if(i & j) { ss+=x; }
        }
        if(s == ss) cnt++;
      }
    }
    cout << cnt << endl;
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;

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

int MOD=1e9+7;
ll INF=1e18;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};

int main(){
    int n, k, s;
    while(cin>>n>>k>>s, n){
        int dp[25][15][400];
        memset(dp, 0, sizeof(dp));

        dp[1][0][0]=1;
        for(int i=1; i<=n; i++){
            for(int j=0; j<=k; j++){
                for(int l=0; l<=s; l++){
                    if(l+i<=s && j+1<=k) dp[i+1][j+1][l+i]+=dp[i][j][l];
                    dp[i+1][j][l]+=dp[i][j][l];
                }
            }
        }
        cout << dp[n+1][k][s] << endl;
    }
}