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<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) {
    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\n", ans);
  }

  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define mp make_pair
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
template<typename T> inline T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }





int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    int n;
    while (cin >> n && n) {
        int k, s;
        cin >> k >> s;
        
        int dp[13][200][23] = {0};
        // 数列, sum, 最後の数
        
        dp[0][0][0] = 1;
        rep(i, k) rep(j, s + 1) rep(l, n + 1) {
            rep3(m, l + 1, n + 1) {
                if (j + m <= s) dp[i + 1][j + m][m] += dp[i][j][l];
            }
        }
        int ans = 0;
        rep(i, n + 1) ans += dp[k][s][i];
        cout << ans << endl;
        /*
        rep(i, k + 1) {
            cout << "i " << i << endl;
            rep(j, s + 1) { rep(l, n + 1) cout << dp[i][j][l] << " "; cout << endl; }
        }*/
    }
}

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

int dp[200][200][200];
int dfs(int n,int k,int s){
	if( n < 0 || k < 0 || s < 0 ) return 0;
	if( n == 0 && k == 0 && s == 0) return 1;
	if( dp[n][k][s] != -1 ) return dp[n][k][s];
	int ans = dfs(n-1,k-1,s-n) + dfs(n-1,k,s);
	return dp[n][k][s] = ans;
}
int main(){
	memset(dp,-1,sizeof(dp));
	int n,k,s;
	while(cin >> n >> k >> s && n){
		cout << dfs(n,k,s) << endl;
	}
	
	
}

C++: #include<iostream>
using namespace std;
int n,k,s;
int dfs(int now,int less,int u)
{
	if(!less)return now==0;
	else
	{
		int cnt=0;
		for(int i=u+1;i<=n&&i<=now;i++)
		{
			cnt+=dfs(now-i,less-1,i);
		}
		return cnt;
	}
}
main()
{
	while(cin>>n>>k>>s,n)
	{
		cout<<dfs(s,k,0)<<endl;
	}
}

C++: #include <numeric>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;

int main(){
    int n,k,s,i,c,res;
    while(1){
        scanf("%d",&n);
        scanf("%d",&k);
        scanf("%d",&s);
        if(!n && !k && !s){break;}
        vector<int> t(n,0);
        int cd[n];
        for(i=0;i<n;i++){cd[i]=i+1;}
        for(i=0;i<k;i++){t[n-i-1]=1;}    
        res=0;
        do{
            c=0;
            for(i=0;i<n;i++){c+=(t[i]*cd[i]);}
            if(c==s){res++;}
        } while(next_permutation(t.begin(),t.end()));
        printf("%d\n",res);
    }
    return 0;
}

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

int n,k,s;

int dfs(int i, int k, int s) {
    if (k == 0 && s == 0) return 1;
    if (i > n || k == 0 && s != 0 || s < i*k+k-1) return 0;
    return dfs(i+1,k,s)+dfs(i+1,k-1,s-i);
}

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

C++: #include<bits/stdc++.h>
using namespace std;
int N, K, S;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    while(true) {
        cin >> N >> K >> S;
        if(N == 0) break;
        int ans = 0;
        for(int i = 0; i < (1 << N); i++) {
            int now = 0;
            int num = 0;
            for(int j = 0; j < N; j++) {
                if(i & (1 << j)) {
                    num++;
                    now += j + 1;
                }
            }
            ///cerr << i << " " << num <<
            if(num == K && now == S) ans++;
        }
        cout << ans << endl;
    }
    return 0;
}

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

long dp[25][200][30]; //dp[何個目まで足したか][残ってる数]
int n, k;

long rec(int a, int b, int c){ //a番目,残りb,前に足した数c
	if(dp[a][b][c]>=0) return dp[a][b][c];
	
	long ret=0;
	if(a==k && b>=0){
		if(b==0) ret=1;
		else ret=0;	
	}
	else if(b<0) ret=0;
	else{
		for(int i=c-1; i>0; --i) ret+=rec(a+1, b-i, i);
		//printf("%d %d = %ld\n", a, b, ret);
	}
	//printf("ret dp[%d][%d] = %ld\n", a, b, ret);
	return dp[a][b][c]=ret;
}

int main(){
	while(1){
		int s;
		scanf(" %d %d %d", &n, &k, &s);
		if(n==0) break;	
		
		memset(dp, -1, sizeof(dp));
		printf("%ld\n", rec(0, s, n+1) );
	}
	return 0;
}