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 <iostream>
#include <cstring>
using namespace std;

int slove(int n,int k,int s){
  if(s<0 || k<0)
    return 0;

  if(s == 0 && k == 0){
    return 1;
  }
  int ans = 0;
  for(int i=n;i>0;i--){
    ans+=slove(i-1,k-1,s-i);
  }
  return ans;
}

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

C++: #include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
// #include <bits/stdc++.h>

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REP(i, n) for(int i=0; i<(int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int dfs(int k, int n, int pn, int d, vi a){
  if (d == 0) {
    // if(k == 0) {
    //   for(auto aa:a) LOG("%2d ", aa);
    //   LOG("\n");
    // }
    return (k == 0) & 1;
  }
  int res = 0;
  FOR(i, pn + 1, n + 1){
    int nk = k - i;
    if(nk < 0) continue;
    vi aa = a;
    aa.push_back(i);
    res += dfs(nk, n, i, d - 1, aa);
  }
  return res;
}

int main() {
  int n, s, k;
  while(cin >> n >> s >> k, n | s | k) {

    vi a;
    cout << dfs(k, n, 0, s, a) << endl;
  }
}

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

int main() {
	int n,k,s;
	while(cin>>n>>k>>s){
		if(!n&&!k&&!s)return 0;
		int dp[114][514]={};
		dp[0][0]=1;
		for(int i=1;i<=n;i++){
			for(int j=k-1;j>=0;j--){
				for(int l=s-i;l>=0;l--){
					if(dp[j][l]!=0)dp[j+1][l+i]+=dp[j][l];
				}
			}
		}
		cout<<dp[k][s]<<endl;
	}
	return 0;
}

C++: 
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#include <cstring>
#include <cstdio>
#include <stack>
#define INF 1000000000
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;

int n,k,s;
int ans = 0;
vector<int> used(21,0);

void dfs(int m, int sum){
    if(m==0){
        if(sum == s) ans++;
        return;
    }
    for (int i=1; i<=n;i++) {
        if (used[i]==0){
            for (int j=1; j<=i; j++) {
                if(used[j]==0) used[j]=m;
            }
            dfs(m-1, sum+i);
            for (int j=1; j<=i; j++) {
                if(used[j]==m)used[j]=0;
            }
        }
    }
    return;
}

int main(){
    for(;;){
        cin >>n>>k>>s;
        if(!n)break;
        rep(i,21)used[i]=0;
        ans = 0;
        dfs(k,0);
        cout << ans <<endl;
    }
}

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

int RES;

void dfs(int cur, int left, int sum) {
    if (cur > 0) {
        dfs(cur-1, left, sum);
        if (left && sum >= cur) dfs(cur-1, left-1, sum-cur);
    } else if (sum == 0 && left == 0) RES++;
}

int main() {
    int N, K, S;

    while (cin >> N >> K >> S && (N || K || S)) {
        RES = 0; dfs(N, K, S);
        cout << RES << endl;
    }

    return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;

#define INF 1000000000

// try to use from bigger number
int search(int n, int k, int s){
  if(k==1){
    if(n>=s) return 1;
    else return 0;
  }
  int res=0;
  for(int i=min(n,s-1); i>1; i--){
    // use i
    res += search(i-1, k-1, s-i);
  }
  return res;
}

int main(){
  int n,k,s;
  while(scanf("%d %d %d", &n, &k, &s), n|k|s){
    cout<<search(n,k,s)<<endl;
  }
  return 0;
}

C++: #include <algorithm>
#include <iostream>
#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;
        }

        // n 個から k 個選ぶためのビットマスク
        vector<bool> bitMask(n);
        for (int i = 0; i < k; ++i) {
            bitMask[i] = true;
        }
        sort(begin(bitMask), end(bitMask));
        int count = 0;
        do {
            int sum = 0;
            for (int i = 0; i < n; ++i) {
                // 組み合わせに選ばれた値
                if (bitMask[i]) {
                    // 0からなので1ずらす
                    sum += i + 1;
                }
            }
            if (sum == s) {
                count += 1;
            }
        // 次のマスクを求める
        } while (next_permutation(begin(bitMask), end(bitMask)));
        cout << count << endl;
    }
}