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<iostream>
#include<cmath>
#include<ctype.h>
#include<vector>
#include<cstdlib>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<stack>
#include<map>

#define ll long long
#define LL long long
#define ULL unsigned long long 
#define ull unsigned long long 
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)

using namespace std;
int n,s;
int ans=0;
void solve(int sum,int i,int num) {
	if (sum == s&&i == n) {
		ans++;
		return;
	}
	if (num==9) return;
	solve(sum, i,num+1);
	solve(sum + num, i + 1,num+1);

}

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

C++: #include<stdio.h>
int sum (int n,int s,int cnt);

int N,S,latte;

int main (void)
{
    int i;
    while(1){
        scanf("%d%d",&N,&S);
        if(N==0&&S==0)break;
        latte = 0;
        printf("ans = %d\n",sum(0,0,0));
        printf("latte = %d\n",latte);
    }
    return 0;
}
int sum(int n,int s,int cnt)
{
    latte++;
    if(s>S || cnt>N || s+(n+9)*(9-n+1)/2<S) return 0;
    if(n>9){
        if(cnt==N && s==S) return 1;
        else return 0;
    }
    return sum(n+1,s+n,cnt+1)+sum(n+1,s,cnt);
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#pragma region defins
#define ll long long
#define loop(i,n) for (int i = 0; i < n; i++)
#define loops(i,f,n) for (int i = (f); i < n; i++)
#define INF 100000000000000
#define sort(a) sort(a.begin(),a.end())
#define rsort(a) sort(a.rbegin(),a.rend())
using namespace std;
#pragma endregion
int n, s, ans;
void dfs(int num, int sum, int count)
{
	//cout << "num:" << num << " sum:" << sum << " count:" << count << endl;
	if (sum == s&&count == n)
	{
		ans++;
		//cout << "ans: " << ans << endl;
	}
	if (sum > s || num == 9 || count == n)return;
	dfs(num + 1, sum + num, count + 1);
	dfs(num + 1, sum, count);
}

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

C++: #include <stdio.h>
int ans=0, n,m;
void dfs(int i, int s, int sum)
{
	if(sum==m && s==0)
	{
		ans++;
		return;
	}
	if(i==10 || s==0)return;
	dfs(i+1, s, sum);
	dfs(i+1, s-1, sum+i);
}
int main(void)
{
	while(1)
	{
		scanf("%d %d",&n,&m);
		if(n==0&&m==0)break;
		ans=0;
		dfs(0, n, 0);
		printf("%d\n",ans);
	}
	return 0;
}

C++: using namespace std;
#include <iostream>
#include <string>
#include <set>
#include <functional>
#include <vector>
#include <algorithm>

int main()
{
	int n,s;
	while(cin>>n>>s&&(n||s)){
		if(!n){cout<<"0"<<endl;continue;}
		int comb=(1<<n)-1,ans=0;
		while(comb<1<<10){
			int sum=0;
			for(int i=0;i<10;i++){
				sum+=i*((comb>>i)&1);
			}
			//cout<<"sum:"<<sum<<endl;
			if(sum==s)ans++;
			int x=comb&-comb,y=comb+x;
			comb=((comb&~y)/x>>1)|y;
		}
		cout<<ans<<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>
#include <stdio.h>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int ans, sum;
void dfs(int i, int s, int n){
	/*cout << "i = " << i;
	cout << " s = " << s;
	cout << " n = " << n << endl;*/
	if(s == sum && n == 0){
		ans++;
		return;
	}
	if(i == 10 || n == 0) return;
	dfs(i+1, s+i, n-1);
	dfs(i+1, s, n);

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

	return 0;
}

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

int dfs(int n, int sum, int before) {
    int ret = 0;
    if(n == 0 && sum == key) return(1);
    if(n > 0) {
        for(int r = before; r <= 9; r++) {
            ret += dfs(n - 1, sum + r, r + 1);
        }
    }
    return(ret);

}

int main(void) {
    int n;
    while(cin >> n >> key, n + key != 0) {
        cout << dfs(n, 0, 0) << endl;
    }
    return(0);
}

C++: #include <iostream>

using namespace std;

int dfs(int n, int s, int minimum) {
    if (n == 0 && s == 0) {
        return 1;
    }
    if (n <= 0 && s <= 0) {
        return 0;
    }
    int ret = 0;
    for (int i = minimum; i < 10; ++i) {
        ret += dfs(n - 1, s - i, i + 1);
    }
    return ret;
}

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

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll; 
typedef pair<ll, ll> PL;

int n, s;
int ans = 0;
//int a[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
bool d[10];
vector< vector<int> > C;

void dfs(int i, int sum){
	if (i == n&&sum == s){
		vector<int> vi;
		if (C.empty()){
			REP(j, 10){
				if (d[j] == 1){
					vi.push_back(j);
				}
			}
			C.push_back(vi);
			ans++;
			return;
		}
		bool f = 1;
		REP(j, C.size()){
			int co = 0;
			REP(k, n){
				if (d[C[j][k]] == 1) co++;
			}
			if (co == n){
				f = 0;
				break;
			}
		}
		if (f){
			ans++;
			REP(l, 10){
				if (d[l] == 1){
					vi.push_back(l);
				}
			}
			C.push_back(vi);
		}
	}

	for (int j = 0; j < 10; j++){
		if (d[j] == 0){
			d[j] = 1;
			dfs(i + 1, sum + j);
			d[j] = 0;
		}
	}
	return;
}

int main(){
	while (cin >> n >> s&&n&&s){
		dfs(0, 0);
		cout << ans << endl;
		REP(i, C.size()){
			REP(j, C[i].size()){
				cout << C[i][j] << " ";
			}
			cout << endl;
		}
		C.clear();
		ans = 0;
	}
}

C++: using namespace std;
#include <iostream>
#include <string>
#include <set>
#include <functional>
#include <vector>
#include <algorithm>

int main()
{
	int n,s;
	while(cin>>n>>s&&(n||s)){
		int comb=(1<<n)-1,ans=0;
		while(comb<1<<10){
			int sum=0;
			for(int i=0;i<10;i++){
				sum+=i*((comb>>i)&1);
			}
			cout<<"sum:"<<sum<<endl;
			if(sum==s)ans++;
			int x=comb&-comb,y=comb+x;
			comb=((comb&~y)/x>>1)|y;
		}
		cout<<ans<<endl;
	}
    return 0;
}