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;

// グローバル変数としてn, s, ansを定義
int n, s, ans;

void dfs(int i, int sum, int N){  // iは深さ、sumは和、Nは使用した項数
	// 最初はi,sum,Nともに0であることに注意
	
	// 使用した項数がちょうどnかつ、和がsであれば、ans++
	if(N==n && sum==s){
		ans++;
		return;
	}
	// 深さが最後まで到達または、使用した項数がnにもかかわらず和がsでなければ終了
	if(i==10 || N==n){
		return;
	}
	// その数を足す
	dfs(i+1, sum+i, N+1);
	// 足さない
	dfs(i+1, sum, N);
}


int main()
{
	while(cin>>n>>s, (n!=0)&&(s!=0)){
		// ansを初期化
		ans = 0;
		dfs(0, 0, 0);
		cout<<ans<<endl;
		
	}
	return 0;
}

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

using namespace std;

int main() {
    int n, s, cnt, sum;
    int a[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};

    while (true) {
        cin >> n >> s;
        if (!n && !s) break;

        int arr[10] = {0};
        for (int i = 0; i < n; i++) { arr[9-i] = 1 };
        cnt = 0;
        do {
            sum = 0;
            for (int i = 0; i < 10; i++) {
                if(arr[i]) { sum += a[i]; }
            }
            if (sum == s) cnt++;
        } while(next_permutation(arr, arr+10));

        cout << cnt << endl;
    }
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int serch(int i,int j,int n,int co)
{
    if(i==10)return 0;
    else if(co==n&&j==0)return 1;
    else if(j<0||co==n||j<i)return 0;
    return serch(i+1,j-i,n,co+1)+serch(i+1,j,n,co);
}
int main()
{
    int n,s,num;
    while(cin>>n>>s&&n!=0){
        num=serch(0,s,n,0);
        cout<<num<<endl;
    }
}

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 n, s, ans = 0;
void dfs(int cnt, int sum, int now);
int main() {
    while (1) {
        cin >> n >> s;
        if (n == 0 && s == 0) break;
        ans = 0; //when call dfs next time, ans should start from 0
        dfs(0, 0, 0);
        cout << ans << endl;
    }
}
void dfs(int cnt, int sum, int now) {
    if (now > 9) {
        if (cnt == n && sum == s) {
            ans++;
        }
        return;
    }
    dfs(cnt + 1, sum + now, now + 1);
    dfs(cnt, sum, now + 1);
    return;
}

C++: #include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#define rep(i,n) for(i=0;i<n;i++)
#define rep_r(i,n) for(i=n-1;i>=0;i--)
#define debug_i(x) printf("x:%d\n",x)
#define debug_s(str) printf("str:%s\n",str)
#define debug_c(c) printf("c:%c\n",c) 

int main()
{
	int i,j,k;
	int n,s,kep,count=0,ans=0,a_c=0;
	int num[11]={0,1,2,3,4,5,6,7,8,9};
	int bit[11]={};
	int sum=0;
	scanf("%d %d",&n,&s);
	rep(i,1023)
	{
		sum++;
		kep=sum;
		for(j=0;;j++)
		{
			if(kep>0)
			{
			bit[j]=kep%2;
			kep/=2;
			}
			else 
			{
				break;
			}
		}
		rep(j,10)if(bit[j]==1)count++;
		if(count==n)
		{
			rep(k,10)ans+=bit[k]*k;
			if(ans==s)a_c++;
		}
		count=0;
		ans=0;
	}
	printf("%d\n",a_c);
	
	
	return 0;
}

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

int dfs(int pos,int selected,int sum){
	if(selected == n)return (sum == s)?1:0;
	if(pos == 10)return 0;
	return dfs(pos+1,selected,sum)+dfs(pos+1,selected+1,sum+pos);
}

int main(){
	while (1) {
		cin>>n>>s;
		if(!(n+s))break;
		cout<<dfs(0,0,0)<<endl;
	}
	return 0;
}

C++: #include <iostream>

int n, s;
int num[10]={0,1,2,3,4,5,6,7,8,9};
int ans=0;
int func(int de, int k, int sum){
	int res = 0;
	if(de == n){
		if(sum == s)ans++;
		return 0;
	}
	if(sum > s)return 0;
	for(int i = k; i < 10; ++i){
		res += func(de + 1, i + 1, sum + i);
		//res += func(de, i + 1, sum);
	}
	return res;
}

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

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

int n,s;

int recursion(int sum,int ans,int num,int cnt){
  if(sum > s || cnt > n) return 0;
  if(cnt == n && sum == s) return 1;
  if(sum + num > s) return 0;
  int hoge = 0;
  hoge += recursion(sum+num,ans,num+1,cnt+1);
  hoge += recursion(sum,ans,num+1,cnt);
  return hoge; 
}

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

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

int solve(int s, int n, int idx, int sum) {
	if (idx == 10) {
		return sum == s && n == 0;
	}

	return solve(s, n - 1, idx + 1, sum + idx) + solve(s, n, idx + 1, sum);
}

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

	return 0;
}

C++: #include<iostream>

using namespace std;

int n, s;
int c = 0;
int i = 0;
int j = 0;
int q = 0;
int date[15] = { 0 };



int sub(int start,int n,int x){
	if (x == n){
		for (int i = 0; i < n; i++){
			j = i - 1;
			/*cout << date[i];*/
			if (j>0){
				date[i] += date[j];
			}
			if (i == n - 1&&date[i]==s){
				q++;
			}
		}
		return 0;
	}

	for (int i = start; i < 10;i++){

		date[x] = i;

		sub(i + 1, n, x + 1);
	
	}


}



int main(){

	n = 0;
	while (true){
		cin >> n >> s;
		if (n == 0 && s == 0)break;
		sub(0, n, 0);


		cout << q << endl;
		q = 0;
	}
}

C++: #include <iostream>

using namespace std;

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

void dfs(int i, int sum, int k) {
    if (k == n && sum == s) { cnt++; }

    if (i == 10 || k == n || sum > s) { return; }
    // a[i]???????????´???
    dfs(i + 1, sum + a[i], k + 1);
    // a[i]?????????????????´???
    dfs(i + 1, sum, k);
}

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 <bits/stdc++.h>
using namespace std;

int main() {
	ios :: sync_with_stdio(false);
	for(int n, s; cin >> n >> s; ) if(n && s) {
		int p[10];
		iota(p, p + 10, 0);
		int ans = 0;
		do {
			if(accumulate(p, p + n, 0) == s)
				ans ++;
		}while(next_permutation(p, p + 10));
		for(int i = 1; i <= 10 - n; i ++)
			ans /= i;
		for(int i = 1; i <= n; i ++)
			ans /= i;
		cout << ans << '\n';
	}
	return 0;
}

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

int combination(int least,int n,int s)
{
	int sum = 0;
	if(n==1)
		return (least < s&&s<=9)?1:0;
	else
	{
		int sum  = 0;
		for(int i = least+1;i<=8;i++)sum +=combination(i,n-1,s-i);
		return sum;
	}
};

int main()
{
	while(true)
	{
	int n,s;
	cin >> n;
	cin >> s;
	if(n==0&&s==0)break;
	else cout << combination(-1,n,s) << endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int sum[11][101];
void rec(int d, int index, int s){
	if(d > 10){
		return;
	}
	for(int i = index+1; i < 10 ; i++){
		sum[d+1][s+i]++;
		rec(d+1, i, s+i);
	}
}
int main(){
	rec(0, -1, 0);
	int n, s;
	while(cin >> n >> s, (n || s)){
		cout << sum[n][s] << endl;
	}
	return 0;
}