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 <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <math.h>
#include <functional>
#include <algorithm>
#include <utility>

typedef long long Int;
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
#define REPS(a,i,n) for(int i = a ; i < n ; ++i)
using namespace std;

int ans;
int a, b;

void solve(int i, int _b, int sum){
	if (sum == a && _b == 0){
		ans++;
		return;
	}
	if (_b == 0 || i == 10)return;
	if (i != -1)
		solve(i + 1, _b - 1, sum + i);
	solve(i + 1, _b, sum);
}

int main(){
	while (cin >> b >> a, a&&b){
		ans = 0;
		solve(-1, b, 0);
		cout << ans << endl;

	}
	return 0;
}

C++: //AOJ Problem0030

#include<iostream>

using namespace std;

int ans;

void solve(int n,int s,int m,int sum,int max){//n:何個か s:目的値 m:何回目か sum:現在の合計 max:最大の足した数
	
	if(m>n || sum>s){
		return;
	}

	else if(n==m && sum==s){
		ans++;
		return;
	}

	else{
		for(int i=max+1;i<=s;i++){
		
			solve(n,s,m+1,sum+i,i);
		}
	}
}

int main(){

	int n,s;

	for(;;){

		cin>>n;
		cin>>s;
		if(n==0&&s==0){
			break;
		}
		ans=0;

		for(int i=0;i<=s;i++){
			solve(n,s,1,i,i);
		}

		cout<<ans<<endl;
	}

	return 0;
}

C++: #include<stdio.h>

int dp[10][10][120];

int main(){
  int i, j, k, n, s;
  dp[0][0][0] = dp[0][1][0] = 1;
  for(i = 1;i < 10;i++){
    for(j = 0;j < 10;j++){
      for(k = 0;k < 120;k++){
	dp[i][j][k] = dp[i - 1][j][k];
	if(k - i >= 0 && j > 0){
	  dp[i][j][k] += dp[i - 1][j - 1][k - i];
	}
      }
    }
  }
  while(scanf("%d%d", &n, &s)){
    if(n == 0 && s == 0)return 0;
    printf("%d\n", dp[9][n][s]);
  }
}

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

void dfs(int cnt,int sum,bool flag[],int j){
	if(sum>s||cnt>n){
		return;
	}
	if(sum==s&&cnt==n){
		++ans;
		return;
	}
	for(int i=j; i<=9; ++i){
		dfs(cnt+1,sum+i,flag,i+1);
	}
	return;
};

int main(){
	while(cin>>n>>s&&n&&s){
		ans=0;
		bool f[10];
		for(int i=0; i<=9; ++i){
			f[i]=false;
		}
		dfs(0,0,f,0);
		cout << ans << "\n";
	}
	return 0;
}

C++: #include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
#define INF 100000000
typedef long long ll;

int main(void) {
    int n, s;
    while (1) {
        cin >> n >> s;
        if (n == 0 && s == 0) break;
        int ans = 0;
        for (int i = 0; i < (1 << 10); i++) {
            int num = 0, sum = 0;
            for (int j = 0; j <= 9; j++) {
                if ((i >> j) % 2 == 1) {
                    num++;
                    sum += j;
                }
            }
            if (num == n && sum == s) ans++;
        }
        cout << ans << endl;
    }
    return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#define INF 111111
using namespace std;
int dp[10][101];
int Sum_of_Integers(int i,int sum,int v);
int main(){
  int n,s;
  while(1){
    cin >> n >> s;
    if(!n && !s)break;
    memset( dp , -1 , sizeof(dp) ); // -1で初期化
    int k = Sum_of_Integers( n , s , INF );
    if(k == 0){
      cout << k << endl;
    }else {
      cout << k << endl;
    }
  }
}
int Sum_of_Integers(int i,int sum,int v){
  int ret = 0;
  if(i < 0 || sum < 0)return 0;
  if(dp[i][sum] >= 0)return dp[i][sum];
  if(i == 0 && sum == 0)return 1;
  for(int j=sum;j>=0;j--){
    if(v>j)ret += Sum_of_Integers( i - 1 , sum - j , j );
  }
  return ret;
}

C++: #define _USE_MATH_DEFINES
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>
using namespace std;

int ans,sum;
void dfs(int i,int s,int n){
	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&&!sum)return 0;
		ans=0;
		dfs(0,0,n);
		cout<<ans<<endl;

	}

	return 0;
}

C++: #include <stdio.h>
int n, s, count = 0, digits[10]; // n 個の整数の和がsになる
void dfs(int cur) {              // cur = 0   {}
   if(cur == n) {               // cur = 1   {a}
       int sum = 0;             // cur = 2   {a, b}
       for(int i = 0; i < n; i++) { sum += digits[i]; }
       if(sum == s) { count++; }
       return;
   }
   for(int i = 0; i < 10; i++) {
       digits[cur] = i; // FIXME: 重複を避ける
       dfs(cur+1);  
   }
}
int main(void){
   n = 3; s = 6; count = 0;
   dfs(0);
   printf("%d\n", count);
 scanf("%d",&n);
    scanf("%d",&s);
    func(0,0,0);

    printf("%d",count);
  return 0;
}

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){
		 return count+1;
		}
		return count;
	}

	solve(i+1,sum+i,used+1);
	
	solve(i+1,sum,used);
	
	
	return count;
}

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

return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	//バックトラック法
	while(1){
		int n,s,i,j,a,b,c=0;;
		cin>>n>>s;
		if(n==0&&s==0)break;
		for(i=0;i<(1<<10);i++){//1<<10は2^10
			a=0;b=0;
			for(j=0;j<=9;j++){
				if((i>>j)&1!=0){//iの2^jの桁が1→ok
					a+=j;b++;//bはたし算の項の数
				}
			}
			if(a==s&&b==n){
				c++;
			}
		}
		cout<<c<<endl;
	}
    return 0;
}

C++: #include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>
#include<map>
#include<queue>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)
#define in(i,j,k) ((i)>=(j)&&(i)<=(k))

int main(){
	int n,s,l,a,c;
	vector<int> v;
	for(;;){
		scanf("%d%d",&n,&s);
		if(n==0 && s==0)break;
		l=min(10,s+1);
		v.clear();
		rep(i,l)v.push_back(i<n);
		c=0;
		do{
			a=0;
			rep(i,l)a+=i*v[i];
			c+=(s==a);
		}while(prev_permutation(v.begin(),v.end()));
		printf("%d\n",c);
	}
	return 0;
}

C++: #include<iostream>

using namespace std;

int ans,n,s;
int nums[10];

void search(int num,int t)
{
	if(num>9)
		return;
	int sum;
	if(t==n)
	{
		for(int i=0;i<num;i++)
			sum+=nums[i]*i;
		if(sum==s)
			ans++;
		return;
	}
	nums[num+1]=0;
	search(num+1,t);
	nums[num+1]=1;
	search(num+1,t+1);
	return;
}

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

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

int ct, n, s;

void sum(int m, int i, int n){
  if (n == 0 && m == s){
    ct++;
    return;
  }
  if (n == 0 || i == 10)  return;
  sum(m, i + 1, n);
  sum(m + i, i + 1, n - 1);
}

int main()
{
  while (cin >> n >> s, n){
    ct = 0;
    sum(0, 0, n);
    cout << ct << 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&&s!=0)){
        num=serch(0,s,n,0);
        cout<<num<<endl;
    }
}