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 <cstring>

using namespace std;

int dp[21][11][156];

int main()
{
  int n, k, s;

  while (1) {
    cin >> n >> k >> s;
    if (n == 0 && k == 0 && s == 0) break;
    memset(**dp, 0, sizeof(dp));
    dp[0][0][0] = 1;

    for (int i = 0; i < n; i++) {
      for (int j = 0; j <= k; j++) {
        for (int l = 0; l <= s; l++) {
          dp[i + 1][j][l] += dp[i][j][l];
          if (l >= i + 1 && j != 0) {
            dp[i + 1][j][l] += dp[i][j - 1][l - (i + 1)];
          }
        }
      }
    }
    cout << dp[n][k][s] << endl;
  }
}

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

#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define SZ(x) (int)(x).size()

void solve(int n, int k, int s) {
    vector<int> v(n);
    rep(i,n) v[i] = i+1;

    int ans = 0;
    rep(mask, 1<<n) {
        int sum = 0, cnt = 0;
        rep(i,n) if(mask&(1<<i)) {
            sum += i+1;
            ++cnt;
        }
        if(cnt == k and sum == s) ++ans;
    }

    cout << ans << "\n";
}

int main() {
    int n,k,s;
    while(cin>>n>>k>>s, n) solve(n,k,s);
    return 0;
}

C++: #include<iostream>
#include<cstring>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

int main(){
	int n,k,s;
	int dp[11][21][200];
	while(cin>>n>>k>>s,s|k|s){
		memset(dp,0,sizeof(dp));
		dp[0][0][0]=1;
		rep(i,k){
			rep(j,21){
				rep(g,s+1){
					for(int h=j+1;h<=n;h++){
						dp[i+1][h][g+h] += dp[i][j][g];
					}
				}
			}
		}
		int ans=0;
		rep(i,21)ans+=dp[k][i][s];
		cout<<ans<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>

using namespace std;

int main() {
	int n, k, s;

	while (cin >> n >> k >> s) {
		if (n == 0 && k == 0 && s == 0) {
			break;
		}

		vector< vector< vector<long long int> > > dp(n + 1, vector< vector<long long int> >(k + 1, vector<long long int>(s + 1, 0)));
		for (int i = 0; i <= n; i++) {
			dp[i][0][0] = 1;
		}
		for (int i = 1; i <= k; i++) {
			for (int j = 1; j <= n; j++) {
				for (int kk = 1; kk <= s; kk++) {
					dp[j][i][kk] += dp[j - 1][i][kk];
					if (kk - j >= 0) {
						dp[j][i][kk] += dp[j - 1][i - 1][kk - j];
					}
				}
			}
		}
		cout << dp[n][k][s] << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int calc(int prev,int n,int k,int s) {
    if(k==0) {
        return s==0;
    }
    if(s<0) return 0;
    int sum=0;
    for(int i=prev+1;i<=n;i++) {
        sum+=calc(i,n,k-1,s-i);
    }
    return sum;
}
int main() {
    int n,k,s;
    while(scanf("%d %d %d",&n,&k,&s),n) {
        printf("%d\n",calc(0,n,k,s));
    }
}

C++: #include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

signed main() {
    int N, K, S;
    while(cin >> N >> K >> S, N || K || S) {
        // i ??\????????°?????? j ????????£??? k ????????????????????????
        int dp[25][25][255] = {};
        dp[0][0][0] = 1;
        repq(i,1,N) {
            repq(j,0,K) {
                repq(k,0,S) {
                    // i ???????????¨ ????¨???? i ?¢???????
                    if(k - i >= 0 && j != 0) dp[i][j][k] += dp[i-1][j-1][k-i];

                    // i ?????????????????¨ ????¨???????????????????
                    dp[i][j][k] += dp[i-1][j][k];
                }
            }
        }
        cout << dp[N][K][S] << endl;
    }
    return 0;
}

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

int main(){
  int n, k, s;

  while(cin >> n >> k >> s){
    if(n == 0) break;

    int ans = 0;

    for(int i = 1; i < (1 << n); i++){
      if(__builtin_popcount(i) != k) continue;

      int sum = 0;

      for(int j = 0; j < n; j++){
        if(!(i & (1 << j))) continue;
        sum += j + 1;
      }

      if(sum == s){
        ans++;
      }
    }

    cout << ans << endl;
  }
}

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

int main() {
  int n,k,s;
  // nは整数，kは集合の数，sは合計
  while(cin>>n>>k>>s,n&&k&&s) {
    int ans=0;
    for (int bits = 0; bits < (1<<n); bits++) {
      if (__builtin_popcount(bits)!=k) continue;
      int res=0;
      for (int i=1; i<n+1; i++) {
        if (bits & 1<<(i-1)) { res += i; }
      }
      if (res == s) ans++;
    }
    cout << ans << endl;
  }
}