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 <algorithm>
#include <cstring>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int used[10];
int rec(int n, int s, int x) {
  // cout << n << " " << s << endl;
  if (n==0) {
    if (s==0)
      return 1;
    else
      return 0;
  }
  int ret = 0;
  for(int i=x;i<10;i++) {
    if (used[i] == 0 && s-i>=0) {
      used[i] = 1;
      ret += rec(n-1, s-i, i+1);
      used[i] = 0;
    }
  }
  return ret;
}

int main() {
  int n, s;
  while(cin>>n>>s,n+s) {
    if (s>50||n>10) {
      cout << 0 << endl;
      continue;
    }
    memset(used,0,sizeof(used));
    cout << rec(n,s,0) << endl;
  }
}

C++: #include <cstdio>
#include <cstring>
bool used[10];
int n,s;
int dfs(int x,int y,int sum) {
	if(x==n) return (sum==s);
	if(sum>=s) return 0;
	int ret=0;
	for(int i=y+1;i<=9;i++) {
		ret+=dfs(x+1,y,sum);
		if(!used[i]) {
			used[i]=true;
			ret+=dfs(x+1,i,sum+i);
			used[i]=false;
		}
	}
	return ret;
}
int main() {
	while(scanf("%d %d",&n,&s),n|s) {
		memset(used,0,sizeof(used));
		printf("%d\n",dfs(0,-1,0));
	}
}

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

using namespace std;

int n, a[10], s;
int ret;

void rec(bool data[10], int cnt, int deep)
{
	if (deep == 10){
		if (cnt == n){
			int sum = 0;
			for (int i = 0; i < 10; i++){
				if (data[i]) {
					sum += a[i];
					// cout << a[i] << " " ;
				}
			}
			// cout << " -> " << sum << endl;
			if (sum == s) ret++;
		}
		return;
	}
	rec(data, cnt, deep + 1);
	data[deep] = true;
	rec(data, cnt + 1, deep + 1);
	data[deep] = false;
	return;
}

int main(void)
{
	for (int i = 0; i < 10; i++){
		a[i] = i;
	}
	while (cin >> n >> s, n || s) {
		ret = 0;
		
		bool data[10];
		fill(data, data + 10, false);
		rec(data, 0, 1);
		data[0] = true;
		rec(data, 1, 1);
		

		cout << ret << endl;
	}

	return 0;
}

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;
  for(int i=x; i<10; i++) if(m-i>x) a+=ans(n-1,m-i,i+1);
  return a;
}

C++: // 0030.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define roop(a,t) for(int a=0;a<t;a++) 
int bit(int n, int s, int now)
{
	if (s < 0) { return 0; }
	if ((s != 0 || n != 0) && now == 10)
	{
		return 0;
	}
	if (s == 0 && n == 0 && now == 10)
	{
		return 1;
	}
	return bit(n - 1, s - now, now + 1) + bit(n, s, now + 1);
}
int main()
{
	
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, s;
	while (true) {
		cin >> n >> s;
		if (n == s&&n == 0) { break; }
		//vector<int>a;
		cout <<bit(n,s,0) << endl;
	}
	return 0;
}

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

int n, s;

int solve(int i, int n, int s) {
  if(n == 0 && s == 0) return 1;
  if(i > 9 || n < 0 || s < 0) return 0;

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

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

  return 0;
}

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

int n,s,res;

void dfs(int decided, int i, int sum){
  if(decided == n){
    if (sum == s) res++;    
    return;
  }

  //0~9を選り好みしてn個決められなかったとき終了
  if(i > 9) return;

  //iを足さない
  dfs(decided,i+1,sum);

  //iを足す
  dfs(decided+1,i+1,sum+i);
}


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

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

int n, s;
int ans;

void tadoru(int f, int step, int sum)
{
	if(step == n){
		if(sum == s){
			ans++;
		} else {
			return;
		}
	}
	if(sum > s) return;

	for(int i=f+1; i<10; i++){
		tadoru(i, step+1, sum+i);
	}
	return;
}

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

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>

typedef long long ll;
using namespace std;

typedef pair<int,int> P;

map<string,int> freq;

int main()
{
	int n;
	while(~scanf("%d",&n)){
		int s;
		scanf("%d",&s);
		
		int* bits = new int[10]();

		for(int i=0;i<n;i++) bits[i] = 1;
		reverse(bits,bits+10);

		if(n==0 && s==0) break;

		int res = 0;
		do{
			int sum = 0;
			for(int i=0;i<10;i++){
				sum += bits[i] ? i : 0;
			}
			//cout << "sum " << sum << endl;
			if(sum == s) res++;
		}while(next_permutation(bits,bits+10));

		cout << res << endl;
	}
}

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

#define loop(v, f, l) for(int v = (f), v##_ = (l); v < v##_; ++v)

using namespace std;

typedef long long int lint;
static inline int in(){ int x; scanf("%d", &x); return (x); }
static inline lint inl(){ lint x; scanf("%lld", &x); return (x); }

int dp[9][101];

void init();
void make_dp(int sum, int prevused, bool* used, int depth);

void init()
{
	bool used[10] = {false};
	make_dp(0, -1, used, 0);
}

void make_dp(int sum, int prevused, bool* used, int depth)
{
	if( depth == 10 )return;
	
	for(int i = prevused + 1; i < 10; i++)
	{
		if( !used[i] )
		{
			sum += i;
			used[i] = true;
			dp[depth][sum]++;
			make_dp(sum, i, used, depth + 1);
			used[i] = false;
			sum -= i;
		}
	}
}

int main()
{
	int n, s;
	init();

	while(true)
	{
		scanf("%d%d", &n, &s);
		if( n == 0 && s == 0 )break;
		printf("%d\n", dp[n - 1][s]);
	}
	return (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<map>
#include<list>
#include<cmath>
#include<stack>
#include<string>
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;

int A[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
int cunt = 0;

void depth(int n, int s, int i){

	if (n == 0 && s == 0){
		cunt++;
		return;
	}
	else if (n == 0) return;
	else if (s < 0) return;
	else if (i == 10) return;


	depth(n - 1, s - A[i], ++i);
	depth(n, s, ++i);

}

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