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 <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <complex>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cmath>
#include <time.h>
#include <tuple>
#define all(c) ((c).begin(),(c).end())
#define rall(c) ((c).rbegin(),(c).rend())
//#define sort(v,n) sort(v,v+n)
#define ll long long
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//

int n, k, s;
int a[30];
ll cont;
inline void solve(int now,ll sum,int b) {
	if (b==n) {
		if (now==k && sum == s) {
			cont++; return;
		}
		else {
			return;
		}
	}
	else {
		solve(now + 1, sum + a[b], b + 1);
		solve(now, sum, b + 1);
	}
}

int main() {
	while (cin >> n >> k >> s, n) {
		for (int i = 0; i < n; i++) {
			a[i] = i + 1;
		}
		cont = 0;
		solve(0, 0, 0);
		cout << cont << endl;
	}
	return 0;
}

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

int main(){

  int n, k, s, f=0;
  while (scanf("%d%d%d", &n, &k, &s) && n!=0 && k!=0 && s!=0) {
	if (f==1) {
	  printf("\n");
	}

    f=1;
    int ans = 0;
	for (int i = 1; i < 1<<n; i++) {
      int sum = 0, cnt = 0;
	  for (int j = 0; j < n; j++) {
        if (i & (1<<j)) {
          sum += (j+1);
  		  cnt++;
		}
	  }
	  if (cnt==k && sum==s)
   	    ans++;
	}
    printf("%d", ans);
  }

  return 0;
}

C++: #include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<string>
#include<cstdio>
#include<queue>
#include<functional>
#include<tuple>
#include<iomanip>
#include<stack>
#include<cmath>
#define ll long long
using namespace std;
int cnt;
int rec(int n, int k, int s) {
	if (k == 0 && s == 0) return cnt + 1;
	if (n <= 0 || k <= 0 || s <= 0) return cnt;
	for (int i = k; i <= n; ++i) cnt=rec(i - 1, k - 1, s - i);
	return cnt;
}
int main() {
	int n, k, s;
	while (cin >> n >> k >> s && n&&k&&s) {
		cnt = 0;
		cout << rec(n, k, s) << endl;
	}
	return 0;
}

C++: #include <iostream>

#define N 20
#define K 10
#define S 155

using namespace std;

int count_sets(int n, int k, int s) {
    int count = 0;
    if (k == 0) {
        if (s == 0) {
            return 1;
        }
        return 0;
    }
    for (int i=1; i<=n; i++) {
        count += count_sets(i-1, k-1, s-i);
    }
    return count;
}

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

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;
int ct = 0;
int n,k,s;
void solve(int k_num,int min_n,int sum_set){
	for(int i = min_n + 1;i <= n;i++){
		if(k_num == k-1 && sum_set + i == s){
			ct++;
			return;
		}
		if(k_num + 1 < k)
			solve(k_num + 1,i,sum_set + i);
	}
	return;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	while(cin >> n >> k >> s,n){
		ct = 0;
		solve(0,0,0);
		cout << ct << endl;
		}
  return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <tr1/unordered_set>
#include <tr1/unordered_map>
#include <bitset>
#include <cassert>
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#define lson l, m, rt<<1
#define rson m+1, r, rt<<1|1
#define inf 1e9
#define debug(a) cout << #a" = " << (a) << endl;
#define debugarry(a, n) for (int i = 0; i < (n); i++) { cout << #a"[" << i << "] = " << (a)[i] << endl; }
#define clr(x, y) memset(x, y, sizeof x)
#define LL long long
#define uLL unsigned LL

using namespace std;
int dp[20][30][200];
int main()
{
    //freopen("input.txt","r",stdin);
    int n,k,s;
    while(scanf("%d%d%d",&n,&k,&s)&&(n||k||s))
    {
        memset(dp,0,sizeof(dp));
        dp[0][0][0]=1;
        for(int i=0;i<k;i++)
        {
            for(int j=0;j<=n;j++)
            {
                for(int t=0;t<=s;t++)if(dp[i][j][t])
                {
                    for(int p=j+1;p<=n;p++)
                    {
                        dp[i+1][p][t+p]+=dp[i][j][t];
                    }
                }
            }
        }
        int sum=0;
        for(int i=0;i<=n;i++)
            sum+=dp[k][i][s];
        printf("%d\n",sum);
    }
    return 0;
}

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

// n ??\????????´??°???k????????£????????????s??????????????????????????????????????????

int main() {
    int N, K, S;
    while (cin >> N >> K >> S and (N or K or S)) {
        int dp[30][30][300];
        fill(dp[0][0], dp[30][0], 0);
        dp[0][0][0] = 1;
        for (int i=1; i<=N; ++i) {
            for (int j=0; j<=K; ++j) {
                for (int k=0; k<=S; ++k) {
                    if ( k - i >= 0 and j != 0 ) dp[i][j][k] += dp[i-1][j-1][k-i];
                    dp[i][j][k] += dp[i-1][j][k];
                }
            }
        }
        cout << dp[N][K][S] << endl;
    }
}