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>

using namespace std;
#define reps(i,f,n) for(int i = f; i <= n; ++i)
#define rep(i,n) reps(i,0,n-1)

//[cnt][sum]
int dp[16][256];
const int INF = 1e8;

int main(void){
  int to, c, s;
  while(1){
    cin >> to >> c >> s;
    if(to == 0)break;
    rep(i,16)rep(j,256)dp[i][j] = 0;
    dp[0][0] = 1;
    reps(i,1,to){
      for(int j = c-1; j >= 0; --j){
        reps(k,0,s){
          if(dp[j][k] != 0 && k + i <= s){
            dp[j+1][k + i] += dp[j][k];
          }
        }
      }
    }
    cout << dp[c][s] << endl;
  }
  return 0;
}

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

int memo[32][16][256];
int N, K, S;
vector<int> data;
map<vector<int>, bool> m;

int rec(int p, int k, int s){
	if(s < 0)
		return 0;
	if(k >= K){
		if(s == 0){
			return 1;
		}
		else{
			return 0;
		}
	}
	if(memo[p][k][s] != -1)
		return memo[p][k][s];
	
	int res = 0;
	for(int i = p - 1; i > 0; --i){
		res += rec(i, k + 1, s - i);
	}
	return memo[p][k][s] = res;
}

int main() {
	while(cin >> N >> K >> S && (N || K || S)){
		data.clear();
		memset(memo, -1, sizeof(memo));
		cout << rec(N + 1, 0, S) << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
const int INF = 100000000;
using namespace std;

int main(){
    int n, m, s;
    while(cin >> n >> m >> s, n||m||s){
        int dp[21][11][200] = {0};
        rep(i,n + 1) dp[i][0][0] = 1;
        range(k,1,n + 1){ //?????¨?????????????????§???
            range(i,1,m + 1){//?????£???????´???°
                range(j,1,s + 1){//???
                    dp[k][i][j] += dp[k - 1][i][j];
                    if(j - k >= 0) dp[k][i][j] += dp[k - 1][i - 1][j - k];

                    //cout << k << ' ' << i<<' '<<j<< endl;
                    //debug(dp[k][i][j])
                }
            }
        }
        cout << dp[n][m][s] << endl;
    }
}

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

using namespace std;

int solve(int n, int k, int s)
{
  if(n < 0 || k < 0 || s < 0) return 0;
  if(n == 0 && k == 0 && s == 0) return 1;
  return solve(n-1, k-1, s-n) + solve(n-1, k, s);
}

int main()
{
  int n, k, s;
  while(cin >> n >> k >> s, n || k || s){
    cout << solve(n, k, s) << endl;
  }
  return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>

using namespace std;

int counter(int n, int k, int s);

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

int counter(int n, int k, int s)
{
	int ans = 0;
	if(s < 1) ans = 0;
	else if(k > 1){
		for(int i = n - 1; i > 1; i--){
			ans += counter(i, (k - 1), (s - i));
		}
	} else if(k == 1){
		if(s < n && 0 < s) ans = 1;
		else ans = 0;
	}
	return ans;
}

C++: #include<iostream>
using namespace std;
int n,k,s,ans;

void dfs(int a=0,int sum=0,int cnt=0){
  if(cnt==k){
    if(sum==s)ans++;
    return;
  }
  for(int i=a+1;i<=n;i++)dfs(i,sum+i,cnt+1);
}

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

C++: #include <iostream>
using namespace std;
int main(){
	int n,k,s;
	long a;
	while(cin>>n>>k>>s){
		if(n==0&&k==0&&s==0) break;
		int h[k],t=0;
		h[0]=0;
		for(int i=0;i<k-1;i++){
			h[k-1-i]=n-i;
			t=t+n-i;
		}
		int ct=0;
		do{
			if(s-t<h[1]&&s-t>0){
				ct++;
			}
			for(int i=0;i<k-1;i++){
				if(h[i+1]-h[i]>1){
					h[i+1]--;
					break;
				}
				else if(h[i+1]-h[i]==1&&h[i+2]-h[i+1]>1){
					h[i+2]--;
					for(int j=0;j<i+1;j++){
						h[i+1-j]=h[i+2-j]-1;
					}
					break;
				}
			}
			t=0;
			for(int i=0;i<k-1;i++){
				t=t+h[i+1];
			}
		} while(t>(k-1)*k/2);
		if(k==1&&s<=n){
			cout<<1<<endl;
		}else{
			cout<<ct<<endl;
		}
	}
    return 0;
}

C++: #include <map>
#include <set>
#include <queue>
#include <ctime>
#include <cmath>
#include <string>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

struct NODE {
	int x, v;
	void rd()
	{
		char str[5];
		scanf("%s", str);
		str[0] == 'R' ? v = 1 : v = -1 ;
		scanf("%d", &x);
	}
	void work() { x += v ; }
}	ant[33];

int main()
{
	//freopen("1.txt","r",stdin);
	int n, m;
	while (cin >> n >> m, n || m)
	{
		for (int i = 1; i <= n ; i++) ant[i].rd();

		int cnt = 0, ti = 0;
		int ans1, ans2;

		while (cnt < n)
		{
			ti ++;
			for (int i = 1; i <= n; i++) ant[i].work();
			for (int i = 1; i <= n; i++)
				for (int j = i + 1; j <= n; j++)
					if (ant[i].x == ant[j].x)
						swap (ant[i].v, ant[j].v);
			for (int i = 1; i <= n; i++)
				if (ant[i].x == m)
				{
					ans1 = i, ans2 = ti, cnt ++;
				}
			for (int i = 1; i <= n; i++)
				if (ant[i].x == 0)
				{
					ans1 = i, ans2 = ti, cnt ++;
				}
		}

		cout << ans2 << ' ' << ans1 << endl;
	}
    return 0;
}