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>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;

int N[20];
int ans, sum, n, k, s;

void subsetsum(int x, int y)
{
  FOR(i,x,n){
    if(y){
      sum += N[i];
      subsetsum(i+1,y-1);
      if(sum == s && y == 1)
        ans++;
      sum -= N[i];
    }else{
      break;
    }
  }
}

int main()
{
  REP(i,20)
    N[i] = i+1;
  while(1){
    ans = sum = 0;
    cin >> n >> k >> s;
    if(n == 0 && k == 0 && s == 0) break;
    subsetsum(0,k);
    cout << ans << endl;
  }
}

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

  return 0;
}

C++: #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1335>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
int N,K,S;
ll dp[22][12][200];
ll solve(){
    ll res = 0;
    fill(**dp,**dp+22*12*200,0);
    dp[1][0][0] = 1;
    for(int i = 1; i <= N;i++){
        for(int j = 0; j <= K;j++){
            for(int k = 0; k <= S; k++){
                if(dp[i][j][k] == 0) continue;
                dp[i+1][j][k] += dp[i][j][k];
                dp[i+1][j+1][k+i] += dp[i][j][k];
            }
        }
    }
    res = dp[N+1][K][S];
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    while(cin >> N >> K >> S,N){
        cout << solve() << endl;
    }
    return 0;
}

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

int rec(const int& maxnum, int cnt, int mul, int foo) {
  if(cnt == 0) return mul == 0;
  if(foo > maxnum || mul < 0) return 0;
  return rec( maxnum, cnt - 1, mul - foo, foo + 1) + rec( maxnum, cnt, mul, foo + 1);
}

int main() {
  int a, b, c;
  while( cin >> a >> b >> c, a){
    cout << rec( a, b, c, 1) << endl;
  }
}

C++: #include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
int main(){
	while(true){
		int n,k,s;
		scanf("%d%d%d",&n,&k,&s);
		if(n+k+s==0)break;
		int ans = 0;
		REP(msk,1<<n)if(__builtin_popcount(msk)==k){
			int x = 0;
			REP(i,n)if(msk>>i&1)x += (i+1);
			if(x==s)ans++;
		}
		printf("%d\n",ans);
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
using lli = long long int;

lli dfs(int n, int k, int s, int sum = 0, int prev = 0, int depth = 0){
  if(s < sum)return 0;
  if(depth == k) return sum == s;
  lli res = 0;
  for (int i = prev + 1; i <= n; i++) {
    res += dfs(n, k, s, sum + i, i, depth + 1);
  }
  return res;
}

int main(){
  int n, k, s;
  while(std::cin >> n >> k >> s, n){
    std::cout << dfs(n, k, s) << std::endl;
  }
  return 0;
}

C++: #include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;

int getans(int sum, int amax, int rest) {
	if (sum < rest)return 0;
	if (sum > rest*amax)return 0;
	if (rest == 1) {
		if (1 <= sum&&sum <= amax)return 1;
	}
	int ans = 0;
	for (int i = 1; i <= amax; ++i) {
		ans += getans(sum - i, i - 1, rest - 1);
	}
	return ans;
}

int main() {
	while (1) {
		int N, K, S; cin >> N >> K >> S;
		if (!N)break;
		int ans(getans(S, N, K));
		cout << ans << endl;
	}
	return 0;
}

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

int n=0;
bool flag[20]={false};
//int table[1048576][156];
/*
int trans(){
  int cnt=0;
  for(int i=n-1;i>=0;i--){
    cnt+=flag[i];
    cnt=(cnt<<1);
  }
  return cnt;
}
*/
int solve(int sum,int k,int start){
  //int c=trans();
  if(k==0 && sum==0) return 1;
  if(sum <= 0) return 0;
  if(k<=0) return 0;
  // if(table[c][sum]!=-1) return table[c][sum];
  int cnt=0;
  for(int i=start;i>=0;i--){
    if(!flag[i]){
      flag[i]=true;
      cnt+=solve(sum-i-1,k-1,i-1);
      flag[i]=false;
    }
  }
  //  if(c < 1024)
  //   return (table[c][sum]=cnt);
    // else return cnt;
  return cnt;
}

int main(){
  int k,s;
  while(cin>>n>>k>>s,n){
    //  memset(table,-1,sizeof(table));
    for(int i=0;i<20;i++)
      flag[i]=false;
    cout<<solve(s,k,n-1)<<endl;
  }
  return 0;
}