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 <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <cstdio>
#include <climits>
#include <cmath>
#include <array>
#include <functional>
#include <sstream>
#include <list>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const double eps=1e-9;
const int inf=1e9;
typedef pair<int,int> P;
int dp[25][15][170];
int main(int argc,char const* argv[])
{
  int n,k,s;
  while(cin >> n >> k >> s && n)
    {
      memset(dp,0,sizeof(dp));
      /*i under 1 set in i under 2 set in ... in i under n set*/  
      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++)
		{
		  if(l-i>=0 && j!=0) dp[i][j][l]+=dp[i-1][j-1][l-i];
		  dp[i][j][l]+=dp[i-1][j][l];
		}
	    }
	}
      cout << dp[n][k][s] << endl;
    }
  return 0;
}

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

typedef uint32_t u32;
typedef uint64_t u64;

int dfs(int remain_n, int remain_sum, int remain_choice) {
  if( remain_choice < 0 ) return 0;
  if( remain_n <= 0 ) {
    if( remain_sum == 0 and remain_choice == 0 ) return 1;
    return 0;
  }
  int res = 0;
  res += dfs(remain_n - 1, remain_sum, remain_choice);
  res += dfs(remain_n - 1, remain_sum - remain_n, remain_choice - 1);
  return res;
}

int main() {

  int dp[16][160];
  int n, k, s;

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

C++: #include <iostream>
using namespace std;
int n,k,s;
int total;
void solve(int i,int knum,int res){
	for(int j = i;j <= n;j++){
		if(j+res > s)break;
		if(knum == k && res + j == s)total++;
		else if(knum < k && res + j < s)solve(j+1,knum+1,res+j);
	}
}

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

C++: #include<iostream>
using namespace std;
int main(){
  int n,k,s;
  int i,j,l,o=0,sum;
  int a[10];
  cin >> n >> k >> s;
  while(n!=0){
    o=0;
    for(a[0]=n;a[0]>0;a[0]--){
      if(k==1){
	sum=0;
	for(i=0;i<1;i++) sum+=a[i];
	if(sum==s) o++;
      }else{
	for(a[1]=a[0]-1;a[1]>0;a[1]--){
	  if(k==2){
	    sum=0;
	    for(i=0;i<2;i++) sum+=a[i];
	    if(sum==s) o++;
	  }else{
	    for(a[2]=a[1]-1;a[2]>0;a[2]--){
	      if(k==3){
		sum=0;
		for(i=0;i<3;i++) sum+=a[i];
		if(sum==s) o++;
	      }else{
		for(a[3]=a[2]-1;a[3]>0;a[3]--){
		  if(k==4){
		    sum=0;
		    for(i=0;i<4;i++) sum+=a[i];
		    if(sum==s) o++;
		  }else{
		    for(a[4]=a[3]-1;a[4]>0;a[4]--){
		      if(k==5){
			sum=0;
			for(i=0;i<5;i++) sum+=a[i];
			if(sum==s) o++;
		      }else{
			for(a[5]=a[4]-1;a[5]>0;a[5]--){
			  if(k==6){
			    sum=0;
			    for(i=0;i<6;i++) sum+=a[i];
			    if(sum==s) o++;
			  }else{
			    for(a[6]=a[5]-1;a[6]>0;a[6]--){
			      if(k==7){
				sum=0;
				for(i=0;i<7;i++) sum+=a[i];
				if(sum==s) o++;
			      }else{
				for(a[7]=a[6]-1;a[7]>0;a[7]--){
				  if(k==8){
				    sum=0;
				    for(i=0;i<8;i++) sum+=a[i];
				    if(sum==s) o++;
				  }else{
				    for(a[8]=a[7]-1;a[8]>0;a[8]--){
				      if(k==9){
					sum=0;
					for(i=0;i<9;i++) sum+=a[i];
					if(sum==s) o++;
				      }else{
					for(a[9]=a[8]-1;a[9]>0;a[9]--){
					  sum=0;
					  for(i=0;i<10;i++) sum+=a[i];
					  if(sum==s) o++;
					}
				      }
				    }
				  }
				}
			      }
			    }
			  }
			}
		      }
		    }
		  }
		}
	      }
	    }
	  }
	}
      }
    }
	   
    cout << o << endl;
    cin >> n >> k >> s;
  }
}

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

using namespace std;
using i64 = long long int;
using ui64 = unsigned long long int;

////////////////////////////////

i64 dfs(int n,int k,int s){
  i64 ret = 0LL;
  if(k == 0){
    if(s == 0)return 1LL;
    else return 0LL;
  }
  for(int i=n-1;i>0;i--){
    ret += dfs(i,k-1,s-i);
  }
  return ret;
}

int main()
{
  int n,k,s;
  while(cin >> n >> k >> s,n && k && s){
    cout << dfs(n+1,k,s) << endl;
  }
  
}

C++: // ACM-ICPCアジア地区予選2013 A. Equal Sum Sets

#include <iostream>

using namespace std;

int main(){
	int n, k, s;
	while(cin >> n >> k >> s && n){
		int res = 0;
		for(int i=0;i<(1<<n);i++){
			int cnt = 0, sum = 0;
			for(int j=0;j<n;j++){
				if((1<<j)&i){
					cnt++;
					sum += j+1;
				}
			}
			if(k==cnt && s==sum) res++;
		}
		cout << res << endl;
	}
}