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 <queue>
using namespace std;

int res;
const int d[10]={0,1,2,3,4,5,6,7,8,9};

void dfs(int now,int idx,int n,int sum,int s){
	if(now==n) {
		if(sum==s){
			res++;
                        return;
		}
	}
	if(idx<10){
		dfs(now,idx+1,n,sum,s);
		dfs(now+1,idx+1,n,sum+d[idx],s);
	}
}

int main(){
	int n,s;
	queue<int> que;
	while(cin>>n>>s,n||s){
		res=0;
		dfs(0,0,n,0,s);
		que.push(res);
	}

	while(que.size()){
		cout<<que.front()<<endl;
		que.pop();
	}

	return 0;
}

C++: #include <fstream>
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;

int cnt_sum_s(int n, int k, int s, int tmp_sum) {
  if (n == 0) {
    return (tmp_sum == s) ? 1 : 0;
  }

  int res = 0;
  for (int i = k+1; i < 10; i++) {
    res += cnt_sum_s(n-1, i , s, tmp_sum + i);
  }

  return res;
}

int main() {
  ifstream cin("../test.txt");
  while (true) {
    int n,s;
    cin >> n >> s;
    if (!(n|s)) break;

    int res = cnt_sum_s(n, -1, s, 0);

    cout << res << endl;
  }
}

C++: #include<iostream>

int n, s;

int solve(int ind, int n, int s){
	if (ind == 10){
		if (n == 0 && s == 0)return 1;
		else return 0;
	}
	return solve(ind + 1, n - 1, s - ind) + solve(ind + 1, n, s);
}

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

}

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

int func(int num, int rest, int before){
	if(before + 1 < 0) return 0;
	if(num == 0){
		if(rest == 0){
			//cout << before << endl;
			return 1;
		}
		return 0;
	}
	int cnt = 0;
	int res = 1;
	for(int i = 0; i <= rest && i <= before; ++i){
		int a = func(num - 1, rest - i, i - 1);
		if(a != 0){
			cnt ++;
			res *= a;
		}
	}
	return res * cnt;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, s;
	while(cin >> n >> s && n != 0 && s != 0){
		cout << func(n, s, 9) << endl;
	}
	
	return 0;
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PA;
using namespace std;
#define MAX  999999
int n1,s;
int counter = 0;
int dfs(int num,int c,int sum){
    if(sum == s && c == n1 && num<10){counter++; return 0;}
    if(sum > s || c > n1 || num >9){return 0;}
    dfs(num+1,c+1,sum+num);
    dfs(num+1,c,sum);
    return 0;
}
int main(){
    while(cin >> n1 >> s,n1+s){
        counter = 0;
        dfs(0,0,0);
        cout << counter <<endl;
    }
    
}

C++: #include<iostream>

using namespace std;

void dfs(int n,int s,int k);

int ans=0;

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

void dfs(int n,int sum,int k){
	if(n<0){
		return ;
	}
	if(n==0){
		if(sum==0){
			ans++;
		}
	}
	else{
		if(9<k){
			return ;
		}
		for(int i=k;n>0&&sum-i>=0;i++){
			dfs(n-1,sum-i,i+1);
		}
	}
}

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

void search(int num,int sum,int pos) {
  if(num == 0) {
    if(sum == s) {
      ans++;
      return;
    }
  }
  for(int i=pos;i<10;i++) {
    search(num-1,sum+i,i+1);
  }
}

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

C++: #include <cstdio>

int n, s, res;

void dfs(int prev, int deep, int sum);

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

void dfs(int prev, int deep, int sum)
{
	if (deep == n && sum == s){
		res++;
		return;
	}
	if (n < deep) return;
	if (s < sum) return;
	
	for (int i = prev + 1; i < 10; i++){
		dfs(i, deep + 1, sum + i);
	}
	
	return;
}

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

int ans = 0;

void dfs(int n, int s, int k){
	if( s < 0 ) return;
	
	if( n == 0 ){
		if( s == 0 ) ans++;
	}else{
		if( 9 < k ) return;
		for(int i = k; i <= 9; i++){
			dfs(n-1, s - i, i + 1);
		}
	}
}

int main(){
	int n, s;
	while( cin >> n >> s, n || s ){
		ans = 0;
		dfs(n, s, 0);
		cout << ans << endl;
	}
}

C++: #include<iostream>

using namespace std;

void dfs(int n,int s,int k);

int ans=0;

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

void dfs(int n,int sum,int k){
	if(n<0){
		return ;
	}
	if(n==0){
		if(sum==0){
			ans++;
		}
	}
	else{
		if(9<k){
			return ;
		}
		for(int i=k;i<=9;i++){
			dfs(n-1,sum-i,i+1);
		}
	}
}

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

int n, s;

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

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

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

int num=0;
bool data[10]={};

int fac(int n){
	if(n==1)return 1;
	return n*fac(n-1);
}

int func(int n,int s){
	if(s<0 || n<0){
		return 0;
	}
	if(s==0){
		if(n==0){return 1;}
		else if(n>=2){return 0;}
	}
	if(n==1){
		for(int j=0;j<10;j++){
			if(s==j && data[j]==0){
				return 1;
			}
		}
	}
	for(int i=0;i<10;i++){
		if(data[i]==0){
			data[i]=1;
			num+=func(n-1,s-i);
			data[i]=0;
		}
	}
	int nn=num;
	num=0;
	return nn;
}

int main(){
	int n,s;
	while(1){
		cin>>n>>s;
		if(n==0 && s==0)break;
		num=0;
		cout<<func(n,s)/fac(n)<<endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int answer;

void saiki( int number, int sum, int t )
{
	if( number == 0 ){
		if( sum == 0 ){
			answer++;
			return;
		} else {
			return;
		}
	}

	if( sum < 0 ) return;

	if( t > 9 ) return;


	saiki( number - 1, sum - t, t + 1 );

	saiki( number, sum, t + 1 );

}

int main(void)
{
	int number, sum;

	while( cin >> number >> sum && number != 0 && sum != 0 ){
		answer = 0;
		saiki( number, sum, 0 );
		cout << answer << endl;
	}
	return 0;
}

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

long dp[11][1001][101];
int n,s;
const int N=9;

long rec(int a, int b, int c){
	if(dp[a][b][c]>=0) return dp[a][b][c];
	
	long ret=0;	
	if(a==n && b>=0){
		if(b==0) ret=1;
		else ret=0;
	}
	else if(b<0) ret=0;
	else for(int i=c-1; i>=0; --i) ret+=rec(a+1, b-i, i);	
	
	return dp[a][b][c]=ret;
}

int main(){
	while(1){
		scanf(" %d %d", &n, &s);
		if(n==0) break;
			
		memset(dp, -1, sizeof(dp));
		printf("%ld\n", rec(0, s, N+1));
	}
}