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 <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#define INF (2000000000)
#define MOD (1000000007)
using namespace std;

typedef vector<int> VI;
typedef vector<int>::iterator VII;
typedef vector<double> VD;
typedef vector<double>::iterator VDI;
typedef vector<long>::iterator VL;
typedef vector<long>::iterator VLI;
typedef pair<int, int> P;


int dp[11][156];

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

C++: #include <iostream>

using namespace std;

int ans[21][11][156];

int main(void){

  for(int k = 1 ; k <= 10 ; k++){
    for(int s = 1 ; s <= 155 ; s++){
      ans[1][k][s] = 0;
      }
    }
  ans[1][1][1] = 1;

  for(int n = 1 ; n <= 20 ; n++){
    for(int s = 1 ; s <= 155 ; s++){
      ans[n][1][s] = (n >= s)?(1):(0);
      }
    }

  for(int n = 2 ; n <= 20 ; n++){
    for(int k = 2 ; k <= 10 ; k++){
      for(int s = 1 ; s <= 155 ; s++){
        ans[n][k][s] = ans[n - 1][k][s] + ans[n - 1][k - 1][s - n];
      }
    }
  }

  while(1){
    int n, k, s;
    cin >> n >> k >> s;
    if(n == 0 && k == 0 && s == 0){
      return 0;
    }else{
      cout << ans[n][k][s] << endl;
    }
  }

}

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

int dp[22][11][156];

int main ()
{
    int n, m, p;

    for (int i = 0; i <= 20; i++) {
        dp[i][1][i] = 1;
    }

    for (int i = 1; i <= 20; i++) {
        for (int k = 1; k <= 155; k++) {
            for (int j = 1; j <= 10; j++) {
                if (dp[i][j][k]) {
                    dp[i + 1][j][k] += dp[i][j][k];
                    if (j < 10 && k + i + 1 <= 155)
                        dp[i + 1][j + 1][k + i + 1] += dp[i][j][k];
                }
            }
        }
    }

    while (cin >> n >> m >> p, (n || m || p)) {
        cout << dp[n][m][p] << endl;
    }

    return 0;
}

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

int main(){

    while(1){
        int N, K, S; cin >> N >> K >> S;
        if(!N) break;

        int dp[22][22][160] = {};      //dp[n][k][s] :=   n以下の数字をk個使ってsを作る組み合わせ
        dp[0][0][0] = 1;
        for(int n = 1; n <= N; n++){
            for(int k = 0; k <= K; k++){
                for(int s = 0; s <= S; s++){
                    if(s - n >= 0 && k != 0) dp[n][k][s] += dp[n - 1][k - 1][s - n];

                    dp[n][k][s] += dp[n - 1][k][s];
                }
            }
        }
        cout << dp[N][K][S] << endl;
    }

    return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
const int N = 20;

// DP version: O(n_max k_max s_max) for initialization, O(1) for each data
int dp[21][11][156];
void init(){
  // base case: n = 0. no solution except for k = 0 and s = 0
  for(int k = 0; k < 11; k++) {
    for(int s = 0; s < 156; s++) {
      dp[0][k][s] = 0;
    }
  }
  dp[0][0][0] = 1;
  // incrementing n
  for(int n = 1; n < 21; n++) {
    for(int k = 0; k < 11; k++) {
      for(int s = 0; s < 156; s++) {
        int cnt = 0;
        if(k > 0 && s >= n) cnt += dp[n-1][k-1][s-n]; // using n
        if(n > k) cnt += dp[n-1][k][s]; // not using n
        dp[n][k][s] = cnt;
      }
    }
  }
}
int main(int argc, char *argv[])
{
  init();
  for(;;) {
    int n, k, s;
    cin >> n >> k >> s;
    if(n == 0 && k == 0 && s == 0) break;
    cout << dp[n][k][s] << endl;
  }
  return 0;
}

C++: #include <numeric>
#include <vector>
#include <algorithm>
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);
        vector<int> cd(n);
        iota(cd.begin(),cd.end(),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 <algorithm>
#include <numeric>
#include <map>
#include <vector>
#include <cmath>
#include <iostream>

using namespace std;

const int maxn = 22, maxk = 12, maxs = 157;
int dp[maxn][maxk][maxs];

int rec(int n, int k, int s) {
  if (k < 0) return 0;
  if (dp[n][k][s] < 0) {
	int res = 0;
	for (int i = 1; i < n; i++) {
	  res += rec(i, k-1, s-i);
	}
	dp[n][k][s] = res;
  }
  return dp[n][k][s];
}

int main() {
  fill_n(dp[0][0], maxn*maxs*maxk, -1);
  for (int n = 0; n < maxn; n++)
	dp[n][0][0] = 1;
  while (true) {
	int p, q, r;
	cin >> p >> q >> r;
	if (p == 0 && q == 0 && r == 0) break;
	cout << rec(p+1, q, r) << endl;
  }
}