Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

func solve(a, b, c int) int {
	if a == 1 && b >= c && b < 10 {
		return 1
	}
	if a == 1 {
		return 0
	}
	ret := 0
	for i := c; i < 10 && i < b; i++ {
		ret += solve(a-1, b-i, i+1)
	}
	return ret
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for {
		scanner.Scan()
		a, _ := strconv.Atoi(scanner.Text())
		if a == 0 {
			break
		}
		scanner.Scan()
		b, _ := strconv.Atoi(scanner.Text())
		fmt.Println(solve(a, b, 0))
	}
}

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

int bitnum(int n) {
	n = (n&0x55555555) + ((n>>1)&0x55555555);
	n = (n&0x33333333) + ((n>>2)&0x33333333);
	n = (n&0x0f0f0f0f) + ((n>>4)&0x0f0f0f0f);
	n = (n&0x00ff00ff) + ((n>>8)&0x00ff00ff);
	return (n&0x0000ffff) + ((n>>16)&0x0000ffff);
}

int main() {
	int n, s;
	while (cin >> n >> s, n&&s) {
		int num = 0;
		for (int i = 0; i < 1<<10; i++) {
			if (bitnum(i) != n) continue;
			int sum = 0;
			for (int j = 0; j < 10; j++)
				if ((i>>j) & 1)
					sum += j;
			if (sum == s)
				num++;
		}
		cout << num << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
//Global 
int n, s;
const int MAX_N = 1000;
int a[10] = { 0,1,2,3,4,5,6,7,8,9 };
int counter;


void solve(int i, int SUM, int use)
{
	if (i == 10) {
		if (SUM == s && use == n) {
			counter++;
		}
	}
	if (i <= 9) {
		solve(i + 1, SUM, use);
		solve(i + 1, SUM + a[i], use + 1);
	}
}


int main()
{
	while (true) {
		cin >> n >> s;
		if (n == 0 && s == 0) {
			break;
		}
		counter = 0;
		solve(0, 0, 0);
		cout << counter << endl;
	}
	return 0;
}

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

int c[11][11][46];

int solve(int n, int index, int s) {
    if (s < 46 && c[n][index][s] >= 0) {
        return c[n][index][s];
    }
    if (n == 0 && s == 0) {
        return 1;
    } else if (n == 0 || s <= 0 || s < index || 9 < index) {
        return 0;
    }
    int res = 0;
    res += solve(n - 1, index + 1, s - index);
    res += solve(n, index + 1, s);
    return c[n][index][s] = res;
}

int main() {
    while (true) {
        int n, s;
        cin >> n >> s;
        if ((n | s) == 0) {
            break;
        }
        memset(c, -1, sizeof(c));
        cout << solve(n, 0, s) << endl;
    }
}

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

int sum( int n, int s, int x ) {
	if( n == 0 ) {
		return s == 0;
	}

	int result = 0;

	for( int i = x; i <= 9; ++i ) {
		result += sum( n-1, s-i, i+1 );
	}

	return result;
}

int main() {
	ios_base::sync_with_stdio( false );

	int n, s;
	while( cin >> n >> s ) {
		if( n == 0 && s == 0 ) { break; }

		cout << sum( n, s, 0 ) << '\n';
	}
}

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

int memo[10][1000][20];
//3,2,1
int dfs(int c,int h,int m)//c:選んだ回数、h:残りの数字、m以下の数字から選ぶ
{
	if(c==0&&h==0)
		return 1;
	if(h<0||m<0||c<0)
		return 0;
	/*if(memo[c][h][m] != -1)
		return memo[c][h][m];*/
	int res = 0;
	for(int i=0;i<=m;++i){
		res += dfs(c-1,h-i,i-1);
	}
	//memo[c][h][m] = res;
	return res;
}

int main(void)
{
	while(1){
		int n,s;
		cin >> n >> s;
		if(n==0&&s==0)
			return 0;
		memset(memo,-1,sizeof(memo));
		cout << dfs(n,s,9) << endl;
	}
	return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<iomanip>
#include<list>
#include<math.h>
#include<stack>

using namespace std;

int n = 0;
int s = 0;
static int ans;

void check(int atai, int num, int count){
	if (num > s) {
		if (count == n) {
			if (atai == s) {
				ans++;
			}
		}
		return;
	}
	check(atai + num, num + 1, count + 1);
	check(atai, num + 1, count);
}


int main(int argc, char **argv)
{
	while (cin >> n >> s) {
		if (n == 0 && s == 0) {
			break;
		}
		check(0, 0, 0);
		cout << ans << endl;
	}
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int ans,s;
void dfs(int n, int b,int sum);
int main(){
  int n;
  while(1){
    scanf("%d %d",&n,&s);
    ans = 0;
    if(n == 0 && s == 0)break;
    for(int i = 0; i <= 9; i++){
      dfs(n,i,i);
    }
    printf("%d\n",ans);
  }
}
void dfs(int n, int b,int sum){
  if(sum == s && n == 1){
    ans++;
  }
  for(int i = b + 1; i <= 9; i++){
    dfs(n-1,i,sum + i);
  }
}

C++: #include<stdio.h>

int ans;

void func(int n, int index, int count){
	if(n < 0)return;
//	printf("%d %d %d\n", n, index, count);
	if(count == 0 && n == 0){
		ans++;
		return;
	}
	if(index==0)return;
	
	for(int i = index-1; i >= 0; i--){
		func(n-i, i, count-1);
	}
}
	

int main(void){
	
	int n,s;
	
	while(scanf("%d %d", &n, &s)){
		if(n == 0 && n==s)break;
		ans = 0;
		
		func(s, 10, n);
		printf("%d\n", ans);
	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int n,s,count;
 
int solve(int i,int sum,int used){
	if(i==10){
		if(s==sum&&used==n){
 
		count++;
		}
		return count;
	}
	solve(i+1,sum+i,used+1);
 
	solve(i+1,sum,used);
 
 
	return count;
}
 
int main(){
 
	while(cin>>n>>s,n||s){
	count=0;
 
	cout<<solve(0,0,0)<<endl;
	}
 
return 0;
}

C++: #include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>
#include <algorithm>
#include <cctype>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const double pi=acos(-1);

int n,s,ans;

void func(int x,int y,int z){
	if(!x&&!y){
		ans++;
		return;
	}
	if(!x||y<=0||z==10) return;
	for(int i=z;i<10;i++) func(x-1,y-i,i+1);
}

int main(){
	while(1){
		cin>>n>>s;
		if(!n&&!s) break;
		ans=0;
		func(n,s,0);
		cout<<ans<<endl;
	}
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

const int MAX_M = 9;
const int MAX_N = 10;
const int MAX_S = 100;
const int M = MAX_M;
const int N = MAX_N;
const int S = MAX_S;
ll dp[MAX_N+1][MAX_S+1];
int n, s;

int main()
{
  dp[0][0] = 1LL;
  rep(i, M+1) rev(j, N) rep(k, S-i+1) dp[j+1][k+i] += dp[j][k];

  while((cin >> n >> s) && n){
    cout << dp[n][s] << endl;
  }


  return 0;
}

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

int rec(int n, int s, int num)
{
  if (n == 0 && s == 0) return 1;
  if (n == 0 || num == 19) return 0;

  return rec(n, s, num + 1) + rec(n - 1, s - num, num + 1);
}

signed main()
{  
  int n, s;
  
  while (cin >> n >> s, n || s) {
    cout << rec(n, s, 0) << endl;
  }

  return (0);
}