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>
#include<vector>
using namespace std;
int saiki(int,int,int,int);
int n,s,cnt=0;
int main(){
	while(1){
		cin>>n>>s;
		if(n==0&&s==0)break;
		saiki(0,0,-1,10);
		cout<<cnt<<endl;
		cnt=0;
	}
	return 0;
}
int saiki(int i,int sum,int mae,int last){
	if(i==n)return sum;
	for(int j=mae+1;j<=(last<=9?last:9);++j){
		if(saiki(i+1,sum+j,j,s-(sum+j))==s)cnt++;
	}
	return -1;
}

C++: #include "bits/stdc++.h"

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1;i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

#define LL long long int
#define LD long double

#define INF 999999999
#define PI 3.14159265358979

#define _CRT_SECURE_NO_WARNINGS

using namespace std;

//================================================
int func(int n, int s, int c) {
	if (n == 1 && s == 1) return 1;
	
	if (s > 0 && n == 0 || n >= 2 && s <= 0 || c < 0){
		return 0;
	}

	if (c > s) {
		return func(n, s, c - 1);
	} else {
		return func(n - 1, s - c, c - 1) + func(n, s, c - 1);
	}
}


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n, s;
	while (cin >> n >> s) {
		if (n == 0 && s == 0 ) break;
		cout << func(n, s, 9) << "\n";
	}
	return 0;
}

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

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

int N, S, CNT = 0;

void dfs(int i, int sum, int total){
	if(total == N && sum == S){
		CNT++;
		return;
	}
	if(i == 10 || total == N){
		return;
	}
	
	dfs(i+1,sum+i,total+1);
	dfs(i+1,sum,total);
}

int main(){
	
	while(cin >> N >> S){
		if(N == 0 && S == 0) break;
		
		CNT = 0;
		dfs(0,0,0);
		cout << CNT << endl;
		
	}
	
	return 0;
}

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

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int N, S;

int dfs(int num, int n, int s){
  if(n == N){
    if(s == S) return 1;
    return 0;
  }

  if(num == 10) return 0;

  return dfs(num+1, n+1, s+num) + dfs(num+1, n, s);
}

int main(){
  while(scanf("%d%d", &N, &S) && N+S){
    int v[10] = {};
    printf("%d\n", dfs(0, 0, 0));
  }
  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>
using namespace std;

int dfs(int x, int y, int z){
    int count =0;
    if(x==0 && y==0) return 1;
    if(x>0){
        for(int i =z; i<10; i++){
            if(y-i>=0) count+=dfs(x-1, y-i, i+1);
        }
    }
    return count;
}

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

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

// i --> 0 - 9までの数字
// sum --> 合計値
// cnt --> 和がSとなる組み合わせの数
// total --> 足す数(N個まで足す)
int N, S, cnt;
void dfs( int i, int sum, int total )
{
    //N回を満たしている 且つ 合計がSに達したものをcountする
    if( total == N && sum == S )
    {
        cnt++;
        return;
    }
    //0-9まで探索したら or 足す回数がN回に達したら 終わり
    if( i == 10 || total == N ) return;
    
    //合計に i を足す場合 -> 足す回数を +1 する
    dfs( i + 1, sum + i, total + 1 );
    //合計に i を足さない場合
    dfs( i + 1, sum, total );
}
int main()
{
    while( cin >> N >> S )
    {
        if( N == 0 && S == 0 ) break;
        //合計値の初期化
        cnt = 0;
        //dfs( 数字の0から, 合計値0から, 足す数字0から)
        dfs( 0, 0, 0 );
        cout << cnt << endl;
    }
    return 0;
}

C++: #include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;

int num, sum;
//now: 現在の数 cnt: 今なん回目？ add:何回足した？
int judge(int now, int cnt, int add)
{
	if(add == num)
	{
		if(now == sum)
			return 1;
		else
			return 0;
	}
	else if(cnt > 9)
	{
		return 0;
	}
	else
	{
		return judge(now + cnt, cnt+1, add+1) + judge(now, cnt+1, add);
	}
}

int main()
{
	while(cin >> num >> sum)
	{
		if(num == 0 && sum == 0)
			break;
		cout << judge(0, 0, 0) << endl;
	}
}

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

int t;
int num[10];

void sousa(int a, int b){
	for(num[a-1] = num[a]-1; num[a-1] >= 0; num[a-1]--){
		if(a-1 < 0 || b < 0){
			break;
		}
		else if(a-1 == 0 && b-num[a-1] == 0){
			t++;
			break;
		}
		else{
			sousa(a-1, b-num[a-1]);
		}
	}
}
int main(){
	vector<int> array;
	int n, m;
	while(cin >> n >> m){
		if(n == 0 && m == 0){
			break;
		}
		if(m > 45){
			array.push_back(0);
			continue;
		}
		t = 0;
		num[n] = 9;
		sousa(n, m);
		array.push_back(t);
	}
	for(int i = 0; i < array.size(); i++){
		cout << array[i] << endl;
	}
}

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

int numofbits(long bits)
{
	bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
	bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
	bits = ((bits >> 4) + bits) & 0x0f0f0f0f;
	bits += bits >> 8;
	return (bits + (bits >> 16)) & 0xff;
}

int main()
{
	int n, s;
	int count;
	int i, j;
	int sum;

	while (cin>>n>>s, n||s) {
		count = 0;
		for (i = 0; i < 1<<10; i++) {
			if ( numofbits(i) != n ) continue;
			sum = 0;
			for (j = 0; j < 10; j++) {
				if (i>>j & 1) sum += j;
			}
			if (sum == s) count++;
		}
		cout << count << endl;
	}

	return 0;
}

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

int a[10] = { 0,1,2,3,4,5,6,7,8,9 };
int n, s, r;

void dfs(int i, int sum, int n) {
	if (n == 0 && sum == s) {
		r++;
		return;
	}
	if (i == 10 || !n)return;
	dfs(i + 1, sum + a[i], n - 1);
	dfs(i + 1, sum, n);
	return;
}

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

}