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++: //http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1335
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
using ll = long long;
using namespace std;

int const MOD = 1e9 + 7;

int main(void)
{
    int n, k, s;
    while (cin >> n >> k >> s, n || k || s)
    {
        int ans = 0;
        for (int bit = 0; bit < (1 << n); ++bit)
        {
            int check = 0;
            int sum = 0;
            for (int i = 0; i < n; ++i)
            {
                if (1 & (bit >> i))
                {
                    check++;
                    sum += i + 1;
                }
            }
            if (check != k)
                continue;
            if (sum == s)
                ans++;
        }
        cout << ans << endl;
    }

    return 0;
}

C++: #include<iostream>
using namespace std;
int n,k,s,an;
void ss(int j,int sum,int kai){
  if(kai==k-1&&j<s-sum&&s-sum<=n)an++;
  if(kai<k-1&&s-sum>j)
    for(int i=j+1;i<=n;i++)ss(i,sum+i,kai+1);  
}

int main(){
  while(1){
    cin>>n>>k>>s;
    if(n==0)break;
    an=0;
    ss(0,0,0);
    cout<<an<<endl;
  } 
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int n,k,s;

int dp(int x,int y,int z)
{
	if(z==k)
	{
		if(y==s)return 1;
	}
	if(x==n+1)return 0;
	int ans = 0;
	for(int i=x+1;i<=n;i++)
	{
		ans+=dp(i,y+i,z+1);
	}
	return ans ;
}
int main ()
{
	
	while(cin>>n>>k>>s&&n)
	{
	cout<<dp(0,0,0)<<endl;
	}
}

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

using int64 = long long;

int main() {
  static int64 dp[30][20][200];
  dp[0][0][0] = 1;

  for (int i = 1; i <= 20; i++) {
    for (int j = 0; j <= 10; j++) {
      for (int sum = 0; sum <= 155; sum++) {
        dp[i][j][sum] += dp[i - 1][j][sum];
        if (j > 0 and sum - i >= 0) {
          dp[i][j][sum] += dp[i - 1][j - 1][sum - i];
        }
      }
    }
  }
  int n, k, s;
  while (cin >> n >> k >> s, n | k | s) {
    cout << dp[n][k][s] << endl;
  }
  return 0;
}

C++: #include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
int n,k,s;

int dfs(int nRest,int kRest,int sRest){
  if(kRest==1) return nRest>=sRest?1:0;
  int result=0;
  for(int i=min(nRest,sRest-1);i>1;i--){
    result+=dfs(i-1,kRest-1,sRest-i);
  }
  return result;
}

void solve(){
  cout<<dfs(n,k,s)<<endl;
}

int main(){ _;
  while(cin>>n>>k>>s,(n|k|s)!=0){
    solve();
  }
}

C++: #include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#define INF 100005
#define inf 0x0f0f0f0f0f0f0f0fLL
#define _int64 long long 

using namespace std;
int idx;

struct NODE {
	static const int KD = 2;
	int id;
	_int64 x[KD], dis;
	void read(int m) { for (int i=0; i<m; i++) scanf("%I64d", &x[i]); }
	void show(int m) { for (int i=0; i<m; i++) printf("%I64d%c", x[i], i==m-1?'\n':' '); }
	bool operator < (const NODE &o) const { return x[idx] < o.x[idx] ; }
}	tmp, pt[INF];

struct KDT
{
	static const int M = 100005 ;
	int mark[M], spt[M], D;
	NODE tre[M], ret;
	void clear() { memset(mark, 0, sizeof(mark)); }
	template <class TP> TP sqr(TP x) { return x*x; }
	void build(int l, int r, int cut)
	{
		if (l>r) return;
		int mid=(l+r)/2;
		spt[mid]=cut, idx=spt[mid];
		nth_element(tre+l, tre+mid, tre+r+1);
		build(l, mid-1, (cut+1)%D);
		build(mid+1, r, (cut+1)%D);
	}
	void query(int l, int r, NODE &o)
	{
		if (l>r) return;
		int mid=(l+r)/2;
		_int64 dis=0;
		for (int i=0; i<D; i++) dis+=sqr(o.x[i]-tre[mid].x[i]);
		
		if (mark[tre[mid].id]==0 && dis<o.dis) o.dis=dis, ret=tre[mid];
		
		_int64 rad=sqr(o.x[spt[mid]]-tre[mid].x[spt[mid]]);
		if (o.x[spt[mid]] < tre[mid].x[spt[mid]])
		{
			if (query(l, mid-1, o), rad<=o.dis) query(mid+1, r, o);
		}
		else
		{
			if (query(mid+1, r, o), rad<=o.dis) query(l, mid-1, o);
		}
	}
}	kdt;

int main()
{
	//freopen("1.txt", "r", stdin);
	int cas, T;
	
	for (cas=scanf("%d", &T); cas<=T; cas++)
	{
		kdt.clear(), kdt.D=2;
		int n;
		for (int i=scanf("%d", &n); i<=n; i++) kdt.tre[i].read(2), kdt.tre[i].id=i, pt[i]=kdt.tre[i];
		kdt.build(1, n, 0);
	
		for (int i=1; i<=n; i++)
		{
			tmp=pt[i];
			kdt.mark[tmp.id]=1;
			tmp.dis=inf, kdt.query(1, n, tmp);
			printf("%I64d\n", tmp.dis);
			kdt.mark[tmp.id]=0;
		}
	}
	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 dfs(int n, int k, int s) {
    if (k == 0 && s == 0) {
        return 1;
    }
    if (n <= 0 || k <= 0 || s <= 0) {
        return 0;
    }

    int ret = 0;
    ret += dfs(n - 1, k - 1, s - n);
    ret += dfs(n - 1, k, s);
    return ret;
}

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

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

}