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 <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){
  if (d == 0) return (k == 0) & 1;
  int res = 0;
  FOR(i, pn + 1, n + 1){
    int nk = k - i;
    if(nk < 0) continue;
    res += dfs(nk, n, i, d - 1);
  }
  return res;
}

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

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

C++: #include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

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

using namespace std;

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

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int n,k,s;//k使う個数,s合計
int ans = 0;
void dfs(int sum,int i,int cnt){
	if(sum==s&&cnt==0){
		ans++;
		return ;
	}
	if(i>n||cnt==0)return;
	dfs(sum+i,i+1,cnt-1);
	dfs(sum,i+1,cnt);
}

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

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

    int 
main (void)
{
    int DP[21][156][11];
    memset(DP, 0, sizeof(DP));
    DP[0][0][0] = 1;

    for (int n = 1; n <= 20; n++)
    {   
        for (int s = 0; s <= 155; s++)
        {   
            for (int k = 0; k <= 10; k++)
                DP[n][s][k] = DP[n-1][s][k];
        }                                                                       
        for (int s = 0; s <= 155; s++)
        {   
            for (int k = 1; k <= 10; k++)
            {   
                if (s+n <= 155)
                    DP[n][s+n][k] += DP[n-1][s][k-1];
            }   
        }   
    }   

    while (1) 
    {   
        int N, K, S;
        cin >> N >> K >> S;
        if (N == 0)
            break;
        cout << DP[N][S][K] << endl;
    }   
    return 0;
}

C++: 
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1335

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

int main()
{
	int N,K,S;
	while(cin >> N >> K >> S && N)
	{
		int ans=0;
		rep( bit, 1<<N )
		{
			if(__builtin_popcount(bit)!=K){ continue; }	
			int res=0;
			REP( n, 1, N+1 ){
				if( bit&1<<(n-1) ){ res+=n; }
			}
			if(res == S){ ans++; }
		}
		cout << ans << endl;
	}

	return 0;
}

C++: #include <iostream>

using namespace std;

int N, K, S;

int dfs(int sum, int cnt, int max_)
{
	int total = 0;

	if (sum == S && cnt == K) { return 1; }

	if (cnt != K)
	{
		for (int i = max_ + 1; i <= N; i++)
		{
			total += dfs(sum + i, cnt + 1, i);
		}
	}

	return total;
}

int main()
{
	while (true)
	{
		cin >> N >> K >> S;

		if (N == 0 && K == 0 && S == 0) { break; }

		cout << dfs(0, 0, 0) << endl;
	}

	return 0;
}