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<set>
#include<stack>
using namespace std;
static int n, k, s;
void dfs(int deep,int sum,int array[],int arrayLength,set<set<int> > *SET)
{
	if (deep > n)return;
	if (arrayLength > k)return;
	if (sum > s)return;

	if (sum == s && arrayLength == k)
	{
		set<int> addSet;
		for (int i = 0; i < arrayLength; i++)
		{
			addSet.insert(array[i]);
		}
		(*SET).insert(addSet);
	}

	if (arrayLength >= k)return;
	if (sum >= s)return;

	for (int i = deep + 1; i <= n; i++)
	{
		if (sum + i > s)continue;
		int newArray[11];
		for (int j = 0; j < arrayLength; j++)
		{
			newArray[j] = array[j];
		}
		newArray[arrayLength] = i;
		dfs(i, sum + i, newArray,arrayLength + 1,SET);
	}

	return;
}
int main()
{
	while (cin >> n >> k >> s && n != 0 || k != 0 || s != 0)
	{
		set<set<int> >SET;
		for (int i = 1; i <= n; i++)
		{
			int array[11];
			array[0] = i;
			dfs(i, i, array,1,&SET);
		}

		cout << SET.size() << endl;
	}
	return 0;
}

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

int main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	for(int n, k, s; cin >> n >> k >> s && n;) {
		vector<vector<int>> dp(k + 1, vector<int>(s + 1, 0));
		dp[0][0] = 1;
		for(int i = 1; i <= n; ++i) {
			for(int j = s; j >= i; --j) {
				for(int l = k - 1; l >= 0; --l) {
					dp[l + 1][j] += dp[l][j - i];
				}
			}
		}
		cout << dp[k][s] << endl;
	}
	return EXIT_SUCCESS;
}

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

#define nmax 20
#define kmax 10
#define smax 155

int C(int n, int k, int s) {
	int count = 0;
	if( k == 0 ) {
		if( s == 0 ) return 1;
		else return 0;
	}
	for(int i = 1; i <= n; i++) {
		count += C(i - 1, k - 1, s - i);
	}
	return count;
}
 
int main(void){
   // FILE* fp_in = freopen("data.txt", "r", stdin);

	while( 1 ) {
		int n, k, s;
		cin >> n >> k >> s;
		if( n == 0 && k == 0 && s == 0 ) break;
		cout << C(n,k,s) << endl;
	}


  // while(1){}
 
   return 0;
}

C++: #include<iostream>
#include<cmath>
#include<bitset>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int cnt(int n){
	int res=0;
	for(int i=0;(1<<i)<n;i++)if(n&(1<<i))res++;
	return res;
}

int sum(int n){
	int res=0;
	for(int i=0;(1<<i)<=n;i++){
		if((n&(1<<i))>0)res+=(i+1);
	}
	return res;
}

int main(){
	int n,k,s;
	while(cin>>n>>k>>s,n||k||s){
		int ans=0;
		rep(i,pow(2,n)){
			if(cnt(i)==k && sum(i)==s)ans++;
		}
		cout<<ans<<endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f(i,x,n) for(int i=x;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<30;
int dp[13][203];

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N,K,S;cin>>N>>K>>S;
        if(N+K+S==0) break;
        
        memset(dp,0,sizeof(dp));
        
        dp[0][0]=1;
        
        for(int i=1;i<=N;i++){
            for(int k=S;k>=i;k--){
                for(int j=0;j<K;j++){
                    dp[j+1][k]+=dp[j][k-i];
                }
            }
        }
        
        cout<<dp[K][S]<<endl;
    }
}

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

int n, s, k;

int dfs(int i, int cnt, int total){
  if(cnt == k){
    return total == s ? 1 : 0;
  }else if(i > n){
    return 0;
  }

  int ret = 0;
  for(int j=i;j<=n;j++){
    if(total + j <= s){
      ret += dfs(j + 1, cnt + 1, total + j);
    }
  }

  return ret;
}

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

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

int c=0,n,k,s;

void check(int i,int sm,int _k){
    if(i>n||_k<0||sm>s) return;
    if(sm==s&&_k==0) c++;
    else{
        check(i+1,sm+i,_k-1);
        check(i+1,sm,_k);
    }
}

int main(void){
    while(cin>>n>>k>>s,n){
        n++;
        check(1,0,k);
        cout<<c<<endl;
        c=0;
    }
}

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

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

int main() {
    while(true) {
        int N, K, S; cin >> N >> K >> S;
        if(N == 0 && K == 0 && S == 0) break;
        cout << solve(N, K, S) << endl;
    }
}

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

int n,k,s;
int dp(int i,int num,int cnt)
{
  //  cerr<<i<<" "<<num<<" "<<cnt<<endl;
  if(num==0 && cnt==0)
    return 1;
  if(i>n)
    return 0;
  if(num<0)
    return 0;
  if(cnt<0)
    return 0;

  int ans=0;
  ans+=dp(i+1,num-i,cnt-1);
  ans+=dp(i+1,num,cnt);
  return ans;

}


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