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 <numeric>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int n,k,s,i,j,c,res=0;
    while(1){
        scanf("%d",&n);
        scanf("%d",&k);
        scanf("%d",&s);
        if(!n && !k && !s){break;}
        vector<int> t(n,0);
        vector<int> cd(n);
        iota(cd.begin(),cd.end(),1);
        for(i=0;i<k;i++){t[n-i-1]=1;}    
        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<bits/stdc++.h>
using namespace std;

int DP(int n,int k,int s){

  int dp[156][12];
  
  for(int i=0 ; i <= 155  ; i++){
    for(int j=0 ; j <= 11 ; j++){
      dp[i][j]=0;
    }
  }
  
  dp[0][0]=1;

  for(int i=1 ; i <= n ; i++){
    for(int K=k ; K >= 0 ; K--){
      for(int j=0 ; j <= s ; j++){
	if(dp[j][K] != 0 && i+j <= s && K+1 <= k){
	  dp[i+j][K+1]+=dp[j][K];
	}
      }
    }
  }
  
  return dp[s][k]; 
}
int main(){
  
  int n,k,s;

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

  return 0;
}

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

using namespace std;

const int MAX_N = 25;
const int MAX_K = 15;
const int MAX_S = 156 + 20;
int n, k, s;
int memo[MAX_N][MAX_K][MAX_S];

void init()
{
    for (int i = 0; i < MAX_N; i++)
        for (int j = 0; j < MAX_K; j++)
            for (int k = 0; k < MAX_S; k++)
                memo[i][j][k] = -1;
}

int rec(int add, int num, int sum)
{
    if (memo[add][num][sum] >= 0)
        return memo[add][num][sum];

    if (num == k && sum == s)
        return 1;

    if (add > n || num > k || sum > s)
        return 0;

    int res = rec(add + 1, num + 1, sum + add);
    res += rec(add + 1, num, sum);

    return memo[add][num][sum] = res;
}

int main()
{

    while (cin >> n >> k >> s, n || k || s) {
        init();
        cout << rec(1, 0, 0) << endl;
    }

    return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double PI = 3.14159265358979;
const double E = 2.718281828459045;
const double root2 = sqrt(2);
typedef pair<int, int> P;
typedef unsigned int ui;
int main() {
	int n, k, s;
	while (cin >> n >> k >> s) {
		if (n == 0)break;
		int dp[21][11][156] = {};
		dp[0][0][0] = 1;
		for (int i = 1; i <= n; i++) {
			for (int j = 0; j <= k; j++) {
				for (int l = 0; l <= s; l++) {
					dp[i][j][l] += dp[i - 1][j][l];
					if (j - 1 >= 0&&l-i>=0) {
						dp[i][j][l] += dp[i - 1][j - 1][l - i];
					}
				}
			}
		}
		cout << dp[n][k][s] << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<string>
#include<cstdlib>
#include<sstream>
#include<queue>
#include<deque>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#define INF 2147483647
#define lli long long int
#define MOD 1000000007
#define pb push_back

using namespace std;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;

lli ans;

void dfs(int n,int k,int s){
	if (s < 0) return;
	if (k == 0 and s == 0){
		ans++;
		return;
	}
	if (n == 0) return;
	if (k == 0) return;
	//not select
	dfs(n-1,k,s);
	//select
	dfs(n-1,k-1,s-n);

	return;
	

}

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

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

int main(){
	int n, k, s;
	while(scanf("%d%d%d", &n, &k, &s), n){
		vector<vector<int> > dp(k + 1, vector<int>(s + 1));
		dp[0][0] = 1;
		for(int i = 1; i <= n; ++i)
		for(int j = k; j > 0; --j)
		for(int t = s; t >= i; --t){
			dp[j][t] += dp[j - 1][t - i];
		}
		printf("%d\n", dp[k][s]);
	}
}

C++: #include <bits/stdc++.h>
#define range(i, a, n) for(int (i) = (a); (i) < (n); (i)++)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
using namespace std;
int main(void){
    for(int n, k, s; cin >> n >> k >> s, n;){
        vector<vector<int>> dp(k + 1, vector<int>(s + 1));
        dp[0][0] = 1;
        range(i, 1, n + 1){
            for(int j = k; j > 0; j--){
                for(int l = s; l >= i; l--){
                    dp[j][l] += dp[j - 1][l - i];
                }
            }
        }

        cout << dp[k][s] << endl;
    }

    return 0;
}

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

int num,cnt,sum,ans;

void func(int n,int i,int s){
  if(i==cnt && s==sum) ans++;
  if(i==cnt || n>num) return;
  func(n+1,i+1,s+n);
  func(n+1,i,s);
}

int main(void){
  while(cin >> num >> cnt >> sum,num!=0){
    ans=0;
    func(1,0,0);
    cout << ans << endl;
  }
}