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 <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cctype>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <memory>
#include <functional>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i <= n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
 
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long LL;
typedef long long int LLI;

int solve(int cnt ,int sum,int now);
 int n=0,s=0;
int main(void)
{
     for(;;){
         cin >> n >> s;
        int ans = solve(0, 0, 0);  
         if(n == 0 && s == 0)break;
        cout << ans << endl;
        }
    return 0;  
}
int solve(int cnt ,int sum,int now)
{
    if(cnt == 10){
        return sum == s && now == n;
    }
    int res1 = solve(cnt+1,sum+cnt,now+1) ;
    int res2 = solve(cnt+1,sum,now);
    return res1+res2;
}

C++: #include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

int n;
int cnt=0;

void dfs(int depth , int k , int sum ){
	if(depth==n){
		if(k==0){
			cnt++;
			return;
		}
	}
	if(k<0) return;
	for(int i=sum; i<10 ; i++){
		dfs(depth+1 , k-i , i+1);
	}
}

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

C++: #include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;
typedef long long ll;

int dfs(int h,int n, int sum,int s){
    
    if(h==10){
        if(sum == s && n==0) return 1;
        return 0;
    }
    
    return dfs(h+1,n-1,sum+h,s)+dfs(h+1,n,sum,s);
    
}

int main(){
    int n,s;
    
    for(int i=0;i<n;i++){
        
        scanf("%d%d",&n,&s);
        
        if(n==0) break;
        
        printf("%d\n",dfs(0,n,0,s));
    }
    
    return 0;
}

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

int n,s;

int mySet(int d,int sum,int c){
  int count=0;
  if(d==n){
    if(sum==s){
      return 1;
    }else{
      return 0;
    }
  }
  for(int i=c;i<=9;i++){
    count+=mySet(d+1,sum+i,i+1);
  }
  return count;
}

int main(void){
  while(cin>>n>>s,n){
    cout<<mySet(0,0,0)<<endl;
  }
  return 0;
}

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

void find_dps(int sum, int now, int add_count) {
  //printf("%d %d : %d %d\n",sum,s,add_count,n);
  if (now > 9 || add_count > n || sum > s) {
    return;
  }
  if (sum == s && add_count == n) {
    count++;
    return;
  }
  find_dps(sum+now, now+1, add_count+1);
  find_dps(sum, now+1, add_count);
}

int main (int argc, char const* argv[]) {
  while (true) {
    cin>>n>>s;
    if (n==0 && s==0) break;
    count = 0;
    find_dps(0,0,0);
    cout<<count<<endl;
  }
  return 0;
}

C++: #include<iostream>
using namespace  std;
int dfs(int p,int n, int s)
{
	if (s == 0 && n == 0)return 1;
	int ret = 0;
	for (int i = p + 1; i <= 9; i++)
	{
		ret += dfs(i, n - 1, s - i);
	}
	return ret;
}
int main()
{
	int n, s;
	while (cin >> n >> s)
	{
		if (n == 0 && s == 0)break;
		cout << dfs(-1, n, s) << endl;
	}
	return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <string>
#include <cstdio>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstring>
#include <tuple>
#include <utility>
#include <list>
#include <cmath>
#include <unordered_map>

using namespace std;

typedef long long LL;
typedef vector<int> Array;
typedef pair<int, int> P;

const int INF = 1 << 29;
const LL MOD = 100000;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define all(c) (c).begin(), (c).end()

struct edge{ int to, cost; edge(int t, int c) :to(t), cost(c){} };

int main()
{
	//while (cin >> n)
	stringstream ss;
	//ss << "result" << i + 1 << ".txt";
	//FILE* fp_out = freopen(ss.str().c_str(), "w", stdout);

	int n;
	while (cin >> n && n)
	{
		int s; cin >> s;
		function<int(int, int, int)> dfs = [&](int now, int rem, int sum)
		{
			if (rem == 0 && sum == s) return 1;
			if (now == 10 || rem == 0 || sum > s) return 0;
			return dfs(now + 1, rem, sum) + dfs(now + 1, rem - 1, sum + now);
		};

		cout << dfs(0, n, 0) << endl;
	}

	return 0;
}

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

int main()
{
    int n, s, sum, ans;

    while(true) {

        cin >> n >> s;

        if(n == 0 && s == 0)
            break;

        int arr[10] = {0};

        for(int i = 0; i < n; i++)
            arr[9-i] = 1;

        ans = 0;

        do {
            sum = 0;
            for(int i = 0; i < 10; i++) {
                if (arr[i])
                    sum += i;
            }
            if (sum == s)
                ans++;
        } while(next_permutation(arr, arr+10));

        cout << ans << endl;
    }
    return 0;
}

C++: #include <iostream>

using namespace std;
int dp[10][45][10];

int dpc(int n,int s,int num)
{
  if(dp[n][s][num]!=-1)
    return dp[n][s][num];
  if(n==0)
    return 0;
  if(s==num && n==1)
    return 1;
  if(num==9)
    return 0;
  int sum=0;
  if(n-1>=0 && s-num>=0)
    sum+=dpc(n-1,s-num,num+1);
  sum+=dpc(n,s,num+1);
  dp[n][s][num]=sum;
  //  cout<<"sum="<<sum<<endl;
  return sum;
}

int main()
{
  int n,s;
  for(;cin>>n>>s,n;)
    {
      for(int i=0;i<10;i++)
	for(int j=0;j<45;j++)
	  for(int x=0;x<10;x++)
	    dp[i][j][x]=-1;
      cout<<dpc(n,s,0)<<endl;
    }
}

C++: #include <iostream>

using namespace std;

int t;
int func(int n, int s, int v, int p)
{
	int c = 0;

	if(n == 1 && s-v < t){
		t = v;
		return 1;
	} else if(n == 0 && v != 0){
		return 0;
	} else if(n == 0 && v == 0){
		t = p;
		return 1;
	}
	
	for(int i = p; i < t; i++){
		c += func(n-1, s, v-i, i+1);
	}
	
	return c;
}

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

C++: #include <stdio.h>

static void
init_pos(int* a, int n)
{
	int k = 0;
	for (int i = 0; i < n; i++) {
		a[i] = k++;
	}
}

static bool
next_pos(int* a, int n)
{
	for (int i = n - 1; i >= 0; i--) {
		if (a[i] >= 9 - (n-i-1)) {
			continue;
		} else {
			a[i] ++;
			int h = a[i] + 1;
			for (int k = i+1; k < n; k++) {
				a[k] = h ++;
			}
			return true;
		}
	}
	return false;
}

static int
check(int* a, int n, int s)
{
	int b = 0;
	for (int i = 0; i < n; i++) {
		b += a[i];
	}

	if (s == b) {
		return 1;
	} else {
		return 0;
	}
}

int
main(void)
{
	char line[80];

	int n, s;

	int a[10];
	
	while (true) {
		if (fgets(line, sizeof line, stdin) == NULL) {
			break;
		}
		if (sscanf(line, "%d %d", &n, &s) != 2) {
			break;
		}

		if (n == 0 && s == 0) {
			break;
		}

		init_pos(a, n);

		int m = check(a, n, s);
		
		while (next_pos(a, n)) {
			m += check(a, n, s);
		}

		printf("%d\n", m);
	}

	return 0;
}