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;

int cnt, n, s;

void dfs(int num, int d, int sum) {
    if (d == n) {
        if (sum == s) {
            cnt++;
        }
        return;
    }
    if (num == 10) {
        return;
    }
    
    dfs(num + 1, d, sum);
    dfs(num + 1, d + 1, sum + num);
}

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

C++: #include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <list>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <math.h>

using namespace std;

int combi(int n, int s, vector<int> usedNum){
	int combiCount = 0;
	int tmp;
	bool usedFlag = false;

	n--;
	for(int i = 0; i <= 9; i++){
		for(int j = 0; j < usedNum.size(); j++){
			if(usedNum[j] == i) usedFlag = true; 
		}
		if(usedFlag){
			usedFlag = false;
			continue;
		}

		tmp = s - i;
		
		if(n != 0){
			usedNum.push_back(i);
			combiCount += combi(n, tmp, usedNum);
		}
		else if(n == 0 && tmp == 0){
			usedNum.pop_back();
			return ++combiCount;
		}
	}

	usedNum.pop_back();
	return combiCount;
}


int main(){
	int n, s;
	int combiCount = 0;
	vector<int> usedNum;
	while(cin >> n >> s && (n != 0 || s != 0)){
		combiCount = combi(n, s, usedNum);
		cout << combiCount << endl;
	}
	return 0;
}

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

using i64 = long long int;

int main(){
    int n, s;
    while(cin >> n >> s, n != 0){
        int ans = 0;
        for(int i=0;i<(1<<10);++i){
            int sum = 0, bit = 0;
            for(int j=0;j<10;++j){
                if((i>>j)&1){
                    sum += j;
                    bit++;
                }
            }
            if(bit == n && sum == s)ans++;
        }
        cout << ans << endl;
    }

    return 0;
}

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

void select( int* x, bitset<10> b, int n, int s, int i, int& c )
{
    if( i == 10 )
    {
        if( b.count() == n )
        {
            int sum = 0;
            for( int j = 0; j < 10; j++ )
            {
                if( b[j] == 1 )
                    sum += x[j];
            }
            if( sum == s )
                c++;
        }
        return;
    }
    b[i] = 0;
    select( x, b, n, s, i + 1, c );

    b[i] = 1;
    select( x, b, n, s, i + 1, c );
}

int main()
{
    int x[10];
    bitset<10> b;
    int n, s;

    for( int i = 0; i < 10; i++ )
        x[i] = i;

    while( cin >> n >> s )
    {
        int cnt = 0;
        if( n == 0 && s == 0 )
            break;
        select( x, b, n, s, 0, cnt );
        cout << cnt << endl;
    }

    return 0;
}

C++: #include<iostream>
#include <sstream>
#define SSTR( x ) static_cast< std::ostringstream & >( ( std::ostringstream() << std::dec << x ) ).str()
using namespace std;

// n個の重複しない整数(min ~ max)用いてsを表す組み合わせの数
int ci(int n, int s, int min, int max, string str) {
  if (s < min || n < 1) return 0;
  if (n == 1) {
    if (s > max) return 0;
    //cout << str << s << endl;
    return 1;
  }
  int r = 0;
  for (int i=min; i<s && i<=max; i++) {
    r += ci(n - 1, s - i, i + 1, max, str + SSTR(i) + " ");
  }
  return r;
}

int main() {
  while (true) {
    int n, s;
    cin >> n >> s;
    if (!n && !s) break;
    cout << ci(n, s, 0, 9, "") << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<vector>
#include<string>
#include<cstdlib>
#include<sstream>
#include<queue>
#include<deque>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#define INF 2147483647
#define lli long long int
#define MOD 1000000007

using namespace std;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;

void printv(vi v){
	for(int i = 0; i < v.size(); i++){
		cout << v[i] << " ";
		}cout << endl;
		return ;
		}

int main() {
	while(1){
	
	int n,s; cin >> n >> s;
	if (n + s == 0) break;
	int ans = 0;
	vi loop(10,1);
	for (int i = 0; i < 10; i++){
		if (10 - i > n){
			loop[9-i] = 0;
		}
		
	}

	
	
	vi aold_used(10,0);
	vi bold_used(10,0);
	vi cold_used(10,0);
	vi dold_used(10,0);
	vi eold_used(10,0);
	vi fold_used(10,0);
	vi gold_used(10,0);
	vi hold_used(10,0);
	vi iold_used(10,0);
	vi jold_used(10,0);
	for (int a = 0; a <= 9*loop[0]; a++){
		vi used(10,0);
		aold_used = used;
		used[a] = 1;
		for (int b = a*loop[1]; b <= 9*loop[1]; b++){
			bold_used = used;
			if (used[b] == 1 and loop[1] != 0) continue;
			else if(loop[1] != 0) used[b] = 1;
			for (int c = b*loop[2]; c <= 9*loop[2]; c++){
				cold_used = used;
				if (used[c] == 1 and loop[2] != 0) continue;
				else if(loop[2] != 0) used[c] = 1;
				for (int d = c*loop[3]; d <= 9*loop[3]; d++){
					dold_used = used;
					if (used[d] == 1 and loop[3] != 0) continue;
					else if(loop[3] != 0) used[d] = 1;
					for (int e = d*loop[4]; e <= 9*loop[4]; e++){
						eold_used = used;
						if (used[e] == 1 and loop[4] != 0) continue;
						else if(loop[4] != 0) used[e] = 1;
						for (int f = e*loop[5]; f <= 9*loop[5]; f++){
							fold_used = used;
							if (used[f] == 1 and loop[5] != 0) continue;
							else if(loop[5] != 0) used[f] = 1;
							for (int g = f*loop[6]; g <= 9*loop[6]; g++){
								gold_used = used;
								if (used[g] == 1 and loop[6] != 0) continue;
								else if(loop[6] != 0) used[g] = 1;
								for (int h = g*loop[7]; h <= 9*loop[7]; h++){
									hold_used = used;
									if (used[h] == 1 and loop[7] != 0) continue;
									else if(loop[7] != 0) used[h] = 1;
									for (int i = h*loop[8]; i <= 9*loop[8]; i++){
										iold_used = used;
										if (used[i] == 1 and loop[8] != 0) continue;
										else if(loop[8] != 0) used[i] = 1;
										for (int j = i*loop[9]; j <= 9*loop[9]; j++){
											jold_used = used;
											if (used[j] == 1 and loop[9] != 0) continue;
											else if(loop[9] != 0) used[j] = 1;
											if (a + b + c + d + e + f + g + h + i + j == s){
												//cout << a << " " << b << " " << c << " " << d << " " << e << " " << f << " " << g << " " << h << " " << i << " " << j << endl;
												ans++;
											}
											used = jold_used;
										}	
										used = iold_used;
									}
									used = hold_used;
								}
								used = gold_used;
							}
							used = fold_used;
						}
						used = eold_used;
					}
					used = dold_used;
				}
				used = cold_used;
			}
			used = bold_used;
		}
		used = aold_used;
	}

	cout << ans << endl;
	}
}

C++: #include<iostream>
using namespace std;
int ans(int n, int m, int x);
int main(){
  int n,m;
  while(cin >>n>>m,n||m){
    cout <<ans(n,m,0)<<endl;
  }
  return 0;
}
int ans(int n, int m, int x){
  int a=0;
  if(n == 1 && m>=x) return 1;
  if(n>1) for(int i=x; i<10; i++) if(m-i>0) a+=ans(n-1,m-i,i+1);
  return a;
}

C++: #include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

typedef vector<int> vi;

int n, s;

//??????p????????¶ c???????????°??? sum????¨?
int dfs(int p, int c, int sum) {
	if (c == 10) return p == 0 && sum == s;
	
	return dfs(p - 1, c + 1, sum + c) + dfs(p, c + 1, sum);
}

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