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<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
long long int fie[110][11][1100];
int main(){
    while(1){
        memset(fie,0,sizeof(fie));
        int N,S;
        cin>>N>>S;
        if(N==0&&S==0)break;
        fie[1][0][0]=1;fie[1][1][1]=1;
        for(int i=1;i<9;i++){
            for(int j=0;j<10;j++){
                for(int k=0;k<=1000;k++){
                    fie[i+1][j][k]+=fie[i][j][k];
                    fie[i+1][j+1][k+i+1]+=fie[i][j][k];
                }
            }
        }
        cout<<fie[9][N][S]+fie[9][N-1][S]<<endl;
    }
    return 0;
}

C++: //再帰関数と深さ優先探索を使う

#include<cstdio>

using namespace std;

void dfs(int,int,int,int);

int cnt=0,num=0;

int main(void){
	int n,s,ans,i=0,sum=0;	//n=組み合わせの数、s=合計
	
	while(1){
		scanf("%d %d",&n,&s);
		if(n==0 && s==0)	break;
		dfs(n,s,i,sum);
		printf("%d\n",cnt);
		cnt=0;
		num=0;
	}

	return 0;
}

void dfs(int n,int s,int i,int sum){
	num++;
	while(1){
		if(i==11-n){
			num--;
			break;
		}
		else{
			if(num==n){
				if(sum+i==s)	cnt++;
			}
			else{
				sum+=i;
				dfs(n,s,i+1,sum);
				sum-=i;
			}
		}
		i++;
	}
	return;
}

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

int solve(int n, int index, int s) {
    if (n == 0 && s == 0) {
        return 1;
    } else if (n == 0 || s <= 0 || index > s) {
        return 0;
    }
    int res = 0;
    res += solve(n - 1, index + 1, s - index);
    res += solve(n, index + 1, s);
    return res;
}

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

C++: #include <cstdio>
#include <cstring>

using namespace std;

int main(void){
	int n, s, i, j, ans, sum, num;
	while(1){
		scanf("%d%d",&n,&s);
		if(n == 0 && s == 0)
			break;
		ans = 0;
		for(i = 0;i < (1 << 10);i++){
			num = sum = 0;
			for(j = 0;j < 10;j++){
				if(1 << j & i){
					num++;
					sum += j;
				}
			}
			if(num == n && sum == s){
				ans++;
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int n,s;
int ans;
void solve(int sum,int idx,int n){
  if(n==0 && sum==s){
    ans++;
    return;
  }else if(n==0 || idx==10){
    return;
  }

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

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

C++: #define _USE_MATH_DEFINES
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<deque>
#include<list>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<map>
#include<queue>
#include<vector>
using namespace std;

int a, S;
void dfs(int i, int s, int n) {
	if (s == S&&n == 0) {
		a++;
		return;
	}
	if (i == 10 || n == 0)
		return;

	dfs(i + 1, s + i, n - 1);
	dfs(i + 1, s, n);
}

int main() {
	for (int n; cin >> n >> S && (n || S);) {
		a = 0;
		dfs(0, 0, n);
		cout << a << endl;
	}

	return 0;
}

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

int t;
int num[10];

void sousa(int a, int b){
	for(num[a-1] = num[a]; num[a-1] >= 0; num[a-1]--){
		if(a-1 < 0 || b < 0){
			break;
		}
		else if(a-1 == 0 && b-num[a-1] == 0){
			t++;
			break;
		}
		else{
			sousa(a-1, b-num[a-1]);
		}
	}
}
int main(){
	vector<int> array;
	int n, m;
	while(cin >> n >> m){
		if(n == 0 && m == 0){
			break;
		}
		if(m > 45){
			array.push_back(0);
			continue;
		}
		t = 0;
		num[n] = 9;
		sousa(n, m);
		array.push_back(t);
	}
	for(int i = 0; i < array.size(); i++){
		cout << array[i]/2 << endl;
	}
}

C++: #include <iostream>

using namespace std;

int n, s, cnt;

void dfs(int i, int sum, int depth) {
    if (i > 9 || depth > n) return;

    if (sum == s && depth == n) {
        cnt++;
        return;
    }

    dfs(i+1, sum, depth);
    dfs(i+1, sum + i, depth + 1);
}

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 <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>

//#define PI 3.141592653589

using namespace std;


int ans;
int n, s;


/*
iはこれまでに足し合わせた数字の数

*/
void dfs(int i, int kazu, int sum)
{
	if (i == n && sum == s)
	{
		ans++;
		return;
	} else if (i == n) {
		return;
	} else if (kazu == 9) {
		return;
	}
	
	dfs(i, kazu+1, sum);
	dfs(i+1, kazu+1, sum+kazu);
}


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

C++:  
 #include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int a[10]={0,1,2,3,4,5,6,7,8,9};
 int n,s;
 int count_2;
 
 void dfs(int step,int i,int sum)
 {
   if(sum>s||step>n) return;
   if(step==n&&i==10&&sum==s)
   {
     count_2++;
     return;                          
   }     
   dfs(step,i+1,sum) 
   dfs(step+1,i+1,sum+a[i])
   return;
 }
  
 int main()
 {
   while(cin>>n>>s)
   {
     if(n==0&&s==0) break;
     else
     {
       count_2=0;
       dfs(0,0,0);    
     } 
     cout<<count_2<<endl;               
   }
   //while(1);     
   return 0;  
 }

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){

  int n,s;
  int plus,sum,ans,memo;
  bool retu[10];

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

    int sub = pow(2,n) - 1;

    for(plus=sub;plus<1024;plus++){
      sum = memo = 0;
      for(int i=9,j=512,a=plus;i>=0;i--,j/=2){
	if(a/j==1){
	  a -= j;
	  retu[i] = true;
	  memo++;
	  sum += i;
	}
	else
	  retu[i] = false;
      }
      if(memo == n)
	if(sum==s)
	  ans++;
    }
    cout << ans << endl;
  }

  return 0;
}

C++: #include<cstdio>
#include<iostream>
using namespace std;
int n,s;
int func(int num, int cnt, int sum) {
	if(num > 9) return 0;
	if(cnt == n) {
		if(sum == s) return 1;
		return 0;
	}
	return func(num+1,cnt+1,sum + num) + func(num+1,cnt,sum);
}
int main() {
	while(cin >> n >> s,(n|s)) {
		printf("%d\n",func(0,0,0));
	}
	return 0;
}