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>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int n, s;
int ans;
bool used[10];

void dfs (int curr, int curr_s, int pre )
{
	if (curr >= n ){
		if (curr_s == s ) ans++;
		return;
	} // end if

	for (int i = pre+1; i < 10; i++ ){
		if (!used[i] ){
			used[i] = true;
			dfs (curr+1, curr_s + i, i );
			used[i] = false;
		} // end if
	} // end rep
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.Sum_of_Integers", "r", stdin );
	while (scanf ("%d %d", &n, &s ), n, s ){
		memset (used, false, sizeof (false ) );
		ans = 0;
		dfs (0, 0, -1 );
		printf ("%d\n", ans );
	} // end loop
		
	return 0;
}

C++: #include<cstdio>
#include<iostream>

using namespace std;

int num[10]={0};

int solve(int a,int b){
	int cnt=0;
	if(b==0&&a==0) return 1;
	if(b<0||a<0) return 0;

	for(int i=0;i<10;i++){
		if(num[i]==0){
			num[i]=1;
			cnt+=solve(a-1,b-i);
			num[i]=0;
		}
	}
	return cnt;
}

int kaizyo(int a){
	if(a==0) return 1;
	return kaizyo(a-1)*a;
}

int main(void){

	int n,s;

	while(1){
		cin>>n>>s;
		if(n==0&&s==0) break;
		cout<<solve(n,s)/kaizyo(n)<<endl;;
	}

	return 0;
}

C++: #include <iostream>

using namespace std;

int n, s, ans;

void rep(int start, int depth, int sum) {
	for (int i = start; i < 10; i++) {
		if (depth == n) {
			if (sum + i == s) {
				ans++;
				return;
			}
		}
		else {
			rep(i+1, depth+1, sum + i);
		}
	}
}

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

C++: #include<iostream>
#include<array>
int main()
{
	while (true)
	{
		int num, sum;
		std::cin >> num >> sum;
		if (num == 0 && sum == 0)
		{
			break;
		}
		std::array<int, 9>nums{ 0,0,0,0,0,0,0,0,0 };
		auto calc_sum = [&nums]()
		{
			int s = 0;
			for (auto i : nums)
			{
				s += i;
			}
			return s;
		};
		int cnt = 0;
		for (int i = 0; i <= 10 - num; i++)
		{
			nums[0] = i;
			if (num == 1)
			{
				if (calc_sum() == sum)
				{
					cnt++;
				}
				continue;
			}
			for (int j = i + 1; j <= 11 - num; j++)
			{
				nums[1] = j;
				if (num == 2)
				{
					if (calc_sum() == sum)
					{
						cnt++;
					}
					continue;
				}
				for (int k = j + 1; k <= 12 - num; k++)
				{
					nums[2] = k;
					if (num == 3)
					{
						if (calc_sum() == sum)
						{
							cnt++;
						}
						continue;
					}
					for (int l = k + 1; l <= 13 - num; l++)
					{
						nums[3] = l;
						if (num == 4)
						{
							if (calc_sum() == sum)
							{
								cnt++;
							}
							continue;
						}
						for (int m = l + 1; m <= 14 - num; m++)
						{
							nums[4] = m;
							if (num == 5)
							{
								if (calc_sum() == sum)
								{
									cnt++;
								}
								continue;
							}
							for (int n = m + 1; n <= 15 - num; n++)
							{
								nums[5] = n;
								if (num == 6)
								{
									if (calc_sum() == sum)
									{
										cnt++;
									}
									continue;
								}
								for (int o = n + 1; o <= 16 - num; o++)
								{
									nums[6] = o;
									if (num == 7)
									{
										if (calc_sum() == sum)
										{
											cnt++;
										}
										continue;
									}
									for (int p = o + 1; p <= 17 - num; p++)
									{
										nums[7] = p;
										if (num == 8)
										{
											if (calc_sum() == sum)
											{
												cnt++;
											}
											continue;
										}
										for (int q = p + 1; q <= 18 - num; q++)
										{
											nums[8] = q;
											if (calc_sum() == sum)
											{
												cnt++;
											}
											continue;
										}
									}
								}
							}
						}
					}
				}
			}
		}
		std::cout << cnt << std::endl;
	}
	return 0;
}

C++: #include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n) for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int w[50],cnt=0,s,n;  
  
void solve(int a, int sum, int n){  
    if(sum==s && !n){  
        w[cnt]++;  
        return;  
    }  
    if(a==10 || !n)
		return;  
    solve(a+1, sum, n); 
    solve(a+1, sum+a, n-1);
}  
  
int main(){
	while(cin>>n>>s, n || s){  
        w[cnt]=0;    
        solve(0, 0, n);
		cnt++;
    }
	REP(i,cnt)
		cout<<w[i]<<"\n";
    return 0;  
}

C++: #include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef vector <int> vi;
typedef vector <vi> vvi;

vvi x(11, vi(101));
int reverse(string &s){
    int n = s.size(), n2 = n/2;
    for (int i=0; i<n2; i++)
        swap(s[i], s[n-1-i]);
    return 0;
}

string dec2bin(int n, bool r=false){
	string s="";
	while (n>0){
		if (n%2==1) s+="1";
		else s+="0";
		n/=2;
	}
	if (s=="") s="0";
	if (!r) reverse(s);
	return s;
}

int main(void){
	int m=pow(2,10);
	for (int i=0; i<10; i++)
		for (int j=0; j<101; j++)
			x[i][j] = 0;

	string s;
	for (int i=1; i<m; i++){
		s = dec2bin(i, true);
		s += string(10-s.size(),'0');

		int n=0, c=0;
		for (int i2=0; i2<s.size(); i2++)
			if (s[i2]=='1'){
				n += i2;
				c++;
			}
		x[c][n]++;		
	}

	while (true){
		int a1,a2;
		cin>>a1>>a2;
		if (a1==0 && a2==0) break;
		cout<<x[a1][a2]<<endl;
	}
	return 0;
}

C++: //再帰関数と深さ優先探索を使う

#include<cstdio>

using namespace std;

void dfs(int,int,int,int);

int cnt=0,num=0;

int main(void){
	int n,s,i=0,sum=0;	//n=組み合わせの数、s=合計
	
	while(1){
		scanf("%d %d",&n,&s);
		if(n==0 && s==0)	break;
		dfs(n,s,i,sum);
		printf("%d\n",cnt);
		cnt=0;
		num=0;
	}

	return 0;
}

void dfs(int n,int s,int i,int sum){
	num++;
	while(1){
		if(i>=10-n+num){
			num--;
			break;
		}
		else{
			if(num==n){
				if(sum+i==s)	cnt++;
			}
			else{
				sum+=i;
				dfs(n,s,i+1,sum);
				sum-=i;
			}
		}
		i++;
	}
	return;
}