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 n;
int k;
int s;
int ans;

void Rec(int idx, int total, int num) {
  if (num == k) {
    if (total == s) ans++;
    return;
  }

  if (idx > n) return;

  for (int i=idx; i<=n; i++) {
    Rec(i+1, total+i, num+1);
  }
}

int main() {
  while (1) {
    scanf("%d%d%d", &n, &k, &s);
    if ((n|k|s) == 0) return 0;

    ans = 0;
    Rec(1, 0, 0);
    printf("%d\n", ans);
  }
}

C++: #include "bits/stdc++.h"
#define pb push_back
#define mt make_tuple
#define all(a) (a).begin(),(a).end()
#define frep(i,a,n) for(int i=(a);i<(n);++i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define rrep(i, n) for(int i=n-1;i>=0;--i)
#define debug(x) cout << #x << " : " << x << " ------------ " << endl;
using namespace std;
int N, K, S;
int calc(int n, int k, int s, int count) {
    if (s == S && k == K) {
        return ++count;
    }
    if (n > N || s > S) {
        return count;
    }
    
    count = calc(n + 1, k + 1, s + n, count);
    
    return calc(n + 1, k, s, count);
}
int main()
{
    while (cin >> N >> K >> S, N | K | S) {
        cout << calc(1, 0, 0, 0) << endl;
    }
    return EXIT_SUCCESS;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int t[25];
int n,k,s;
int dfs(int hukasa,int now,int used){//深さ、now
	//cout<<now<<endl;
	int ret=0;
	if(hukasa>=n){
	if(now==s&&used==k){ret=1;}
	return ret;
	}
	if(now)ret++;
	int a1=dfs(hukasa+1,now+t[hukasa],used+1);
	int a2=ret=dfs(hukasa+1,now,used);
	//cout<<"ret"<<ret<<endl;
	return a1+a2;
}
int main(){
	for(int i=0;i<25;i++)t[i]=i+1;

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

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main()
{
   int n,s,t;
   int num;
   while(scanf("%d%d%d",&n,&s,&t)&&(n+s+t))
      {
           num=0;
        for(int i=1;i<=(1<<n);i++)
          {
             int sum=0,res=0;
            for(int j=1;j<=n;j++)
               {
                   if(i&(1<<(j-1)))
                          {
                               res++;
                               sum+=j;
                           }
                }
           if(res==s&&sum==t)  num++;
            }
            cout<<num<<endl;
       }
      return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int memo[21][11][160];

int rec(int n,int k,int s){
	if(n<0||k<0||s<0)
		return 0;
	if(k==0&&s==0)
		return 1;
	int &res=memo[n][k][s];
	if(res!=-1) return res;
	res=0;
	res+=rec(n-1,k,s);
	res+=rec(n-1,k-1,s-n);
	return res;
}

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

C++: #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using namespace std;

int memo[25][15][160];

int rec (int n, int k, int s) {
    if(n < 0 || k < 0 || s < 0) return 0;
    if(memo[n][k][s] >= 0) return memo[n][k][s];
    if(n == 0 && k == 0 && s == 0) return memo[n][k][s] = 1;
    memo[n][k][s] = rec(n - 1, k, s) + rec(n - 1, k - 1, s - n);
    return memo[n][k][s];
}

int main(){
    int n, k, s;
    // k : number of elements <- [1, n]
    // s : sum
    while (true) {
        scanf("%d%d%d", &n, &k, &s);
        if(n == 0 && k == 0 && s == 0) break;
        for (int i = 0; i <= n; ++i) {
            for (int j = 0; j <= k; ++j) {
                fill(memo[i][j], memo[i][j] + s + 1, -1);
            }
        }
        printf("%d\n", rec(n, k, s));
    }
    return 0;
}