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<map>
#include<tuple>
using namespace std;

typedef tuple<int,int,int> T;
map<T,int> memo;

int dp(int n, int k, int s) {
  if (s < k || n < 1 || s < 1) {
    return 0;
  } else if (k == 1 && s <= n) {
    return 1;
  } else if (memo.find(make_tuple(n, k, s)) != memo.end()) {
    return memo[make_tuple(n, k, s)];
  } else {
    int ans = dp(n - 1, k, s - k) + dp(n - 1, k - 1, s - k);
    memo[make_tuple(n, k, s)] = ans;
    return ans;
  }
}

int main() {
  int n, k, s;
  while (cin >> n >> k >> s && n) {
    cout << dp(n, k, s) << endl;
  }
}

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

int dp[21][11][156] = {0};

int main(){
    int n,k,s;
    for(int i=1;i<21;++i)
            dp[i][1][i] = 1;
    for(int i=1;i<21;++i){
        for(int j=1;j<11;++j){
            for(int l=1;l<156;++l){
                dp[i][j][l] += dp[i-1][j][l];
                if(l - i > 0)
                    dp[i][j][l] += dp[i-1][j-1][l-i];
            }
        }
    }
    while(scanf("%d %d %d",&n,&k,&s), n != 0 || k != 0 || s != 0){
        printf("%d\n",dp[n][k][s]);
    }

    return 0;
}

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

int N, K, S;

int dfs(int i, int k, int sum) {
    if(i > N && k < K) {
        return 0;
    }
    if(k == K) {
        return S == sum;
    }
    return dfs(i+1, k, sum) + dfs(i+1, k+1, sum+i);
}

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

C++: #include<bits/stdc++.h>
using namespace std;
  
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
  
typedef long long ll;
typedef pair<int, int> ii;
 
int main(){
     
    vector<vector<vector<ll>>> ans(21, vector<vector<ll>>(11, vector<ll>(256)));
      
    REP(i, 1, 21){
        ans[i][1][i] = 1;
        REP(j, 1, 11){
            for(int k = 0; k <= 255; k++){
                ans[i][j][k] += ans[i - 1][j][k];
                if(k - i >= 0) ans[i][j][k] += ans[i - 1][j - 1][k - i];
            }
        }
    }
     
    int n, k, s;
    while(cin >> n >> k >> s, n, k, s){
        cout << ans[n][k][s] << endl;
    }
     
  
    return 0;
}

C++: #include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
double EPS=1e-10;
int INF=1e9;
int dp[11][156];
int main(){
      int n,k,s;
      while(cin>>n>>k>>s&&(n||k||s)){
            memset(dp,0,sizeof(dp));
            dp[0][0]=1;
            for(int i=1;i<=n;i++){
                  for(int j=k;j>=1;j--){
                        for(int l=i;l<=s;l++){
                              dp[j][l]+=dp[j-1][l-i];
                        }
                  }
            }
            cout<<dp[k][s]<<endl;
      }
}

C++: #include <iostream>

using namespace std;
 
int n,k,s,ans;
 
void rec(int num,int kk,int sum){
    if(kk < 0 || sum < 0) return;
 
    if(kk == 0 && sum == 0){
	ans++; return;
    } 
    for(int i = num ; i >= 1 ; i--){
	rec(i-1,kk-1,sum-i);
    }
}
 
int main(){
    while(cin >> n >> k >> s, n | k | s){
	ans = 0; rec(n,k,s);
	cout << ans << endl;
    }
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repeat(i, j, n) for(int i = (j); i < (n); i++)
#define all(v) begin(v), end(v)

using namespace std;
int main() {
  while(1){
    int n,k,s;
    cin>>n>>k>>s;
    if(n==0)
      return 0;
    int ans=0;
    for(int state=0;state<(1<<n);state++){
      int count=0,sum=0;
      for(int i=0;i<n;i++)
        if(state&(1<<i)){
            count++;
            sum+=i+1;
        }
      if(count==k && sum==s)
        ans++;
    }
    cout<<ans<<endl;
  }
  return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n,k,s;
  while(1){
    cin>>n>>k>>s;
    if(n==0 && k==0 && s==0)break;
    int ans=0,bit;
    rep(bit,1<<n){
      int tmp=0,sum=0;
      rep(i,n)
        if(bit&1<<i){//i?????????bit????????£???????????°            
          tmp++;
          sum+=i+1;
        }
      if(tmp==k && sum==s)ans++;
    }
    cout<<ans<<endl;
  }
}