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 <stdio.h>
#include <stdlib.h>
#include <string.h>

int n, s, ans, dp[15][1<<8][15];

void rec(int base, int sum, int used) {
    if(sum == s) {
        if(used == n && dp[base][sum][used] == 0) ans += 1;
    }
    if(sum > s || used > n) return;
    dp[base][sum][used] = 1;
    for(int i = base; i < 10; i++) {
        rec(i + 1, sum + i, used + 1);
    }
}

int main(void) {
    while(scanf("%d%d", &n, &s) == 2 && !(n + s == 0)) {
        ans = 0;
        memset(dp, 0, sizeof(dp));
        rec(0, 0, 0);
        printf("%d\n", ans);
    }
    return 0;
}

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

using namespace std;

int s, n, cnt = 0;

void solve(int x, int y, int sum){
	if(y == n){
		if(sum == s){
			++cnt;
		}
		return ;
	}
	if(x > 9) return ;
	solve(x + 1, y + 1, sum + x);
	solve(x + 1, y, sum);
}

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

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

int func(int n, int s, int i){
	if(!n){
    	if(!s)return 1;
    	else return 0;
    }
	if(i >= 10 || s-i < 0)return 0;
	return test(n, s, i+1) + test(n-1, s-i, i+1);
}

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

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

int n,s;

int dfs(int i,int c,int sum){
	int res=0;
	if(c+10-i<n || s<sum)return 0;
	if(c==n&&sum==s)return 1;
	res += dfs(i+1,c,sum);
	res += dfs(i+1,c+1,sum+i);
	return res;
}
int main(){
	while(cin>>n>>s,n||s)cout<<dfs(0,0,0)<<endl;
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
	int n,s;
	while(cin>>n>>s,n||s){
		if(n>10||s>45){
			cout<<"0"<<endl;
			continue;
		}
		if(n==1&&s<10&&s>=0){
			cout<<"1"<<endl;
			continue;
		}
		int min = (int)pow(10.0,n-2);
		int lim = (int)pow(10.0,n);
		stack<int> st;
		vector<int> res;
		st.push(0);
		while(!st.empty()){
			int top = st.top();
			int tmp=top;
			int cur=0;
			while(tmp>0){
				cur+=tmp%10;tmp/=10;
			}
			st.pop();
			if(top>min&&cur==s){
				//cout << top << endl;
				res.push_back(top);
			}else{
				if(top*10>=lim) continue;
				for(int i=top%10+1;i<10;++i){
					st.push(top*10+i);
				}
			}
		}
		cout<<res.size()<<endl;
	}
	return 0;
}

C++: #include<iostream>

using namespace std;

int dfs(int x,int n,int s){
  
  if(n==0)
    return (s==0);
  
  if(x==10)
    return 0;
  
  int res=0;
  
  for(int i=x;i<=9;++i){
    res+=dfs(i+1,n-1,s-i);
  }
  return res;
}

int main(){
  int n,s;

  while(cin>>n>>s,n,s){
    cout<<dfs(0,n,s)<<endl;
  }
}

C++: #include <stdio.h>
int n, s, count = 0,cur;
int digits[10] ;
int dataSet[50] ;
void dfs(int cur){
if(cur == n){
 int sum = 0;
 for(int i = 0; i < n; i++) {sum += digits[i];}
 if(sum == s) {count++;}
 return;
}
for (int i = cur; i < 10; i++) {
 if (digits[cur-1] < i) {
  digits[cur] = i;
 }
 dfs(cur+1);
}
}
int main(void){
int num = 0;
while(scanf("%d %d",&n,&s)!= EOF){
 if(n == 0 && s == 0){
  break;
 }
 count = 0;
 dfs(0);
 dataSet[num] = count;
 num++;
            
}
       for (int i = 0; i < num; i++) {printf("%d\n", dataSet[i]);}
return 0;
}

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

int n,s;

int recursion(int sum,int num,int cnt){
  if(sum > s || cnt > n) return 0;
  if(cnt == n && sum == s) return 1;
  if(num > 10) return 0;
  int hoge = 0;
  hoge += recursion(sum+num,num+1,cnt+1);
  hoge += recursion(sum,num+1,cnt);
  return hoge; 
}

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

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

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

bool dfs(int now,int idx,int n,int sum,int s){
	
	
	if(now==n&&sum==s) {
		res++;
		return true;
	}
	
	if(idx>9) return true;
	
	if(dfs(now,idx+1,n,sum,s)) return true;
	
	if(dfs(now+1,idx+1,n,sum+d[idx],s)) return true;
	
	return false;
}

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

C++: #include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <cctype>
#include <iostream>
#include <set>
#include <string>
#include <queue>
using namespace std;
string::size_type size(string x){
	string::size_type size=x.size();
	return size;
}
#define fu(i,l,k) for(int i=l;i<k;i++)
#define fd(i,l,k) for(int i=l;i>k;i--)
#define fi first
#define se second
double pi(){
	return M_PI;
}
typedef set<int> set_i;
typedef set<string> set_s;
int n, k;
int ans = 0;
void dfs(int i,int j, int sum)
{
    if (i == n)
    {
        if (sum == k)ans++;
    }
    else if (j<=9&&sum<=k)
    {
        dfs(i + 1, j + 1, sum + j);
        dfs(i, j + 1, sum);
    }
}
 
int main()
{
    while (cin>>n>>k)
    {
        if (n == 0 && k == 0)return 0;
        ans = 0;
        dfs(0, 0, 0);
        cout << ans << endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int ans,n,s;

void dfs(int i,int sum,int m){
	if(i==0){
		if(sum==s){
			ans++; //o(m);
		}
		return;
	}
	if(m==9) return;
	rep(j,m,10){
		dfs(i-1,sum+j,j+1);
	}
}

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

C++: #include <iostream>

using namespace std;

int n, s;
int count = 0;

void DFS(int sum, int pre, int depth)
{
	if(depth > n || sum > s)
	{
		return;
	}
	else if(sum == s && depth == n)
	{
		++count;
		return;
	}
	for(int i = pre + 1; i < 10; ++i)
	{
		DFS(sum + i, i, depth + 1);
	}
}

void solve()
{
	while(cin >> n >> s, n || s)
	{
		count = 0;
		for(int i = 0; i < s / n + 1; ++i)
		{
			DFS(i, i, 1);
		}
		cout << count << endl;
	}
}

int main()
{
	solve();
	return(0);
}

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

void solve(int n, int s, int sum, int x){
	//cout << "t " << n << ' ' << s << ' ' << sum << ' ' << x << endl;
	if(n == 0){
		if(sum == s) ans++;
		return;
	}
	if(sum > s) return;

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

int main(void){
	int n, s;
	while(1){
		cin >> n >> s;
		if(n == 0 && s == 0) break;
		ans = 0;
		solve(n, s, 0, 10);

		cout << ans << endl;
	}
}

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

int n,s;

int recursion(int sum,int num,int cnt){
  if(sum > s || cnt > n) return 0;
  if(cnt == n && sum == s) return 1;
  if(num > 9) return 0;
  int hoge = 0;
  hoge += recursion(sum+num,num+1,cnt+1);
  hoge += recursion(sum,num+1,cnt);
  return hoge; 
}

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

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

int dp[1001][1001], n, s;

void set(){
    for(int i = 0; i <= 1000; i++){
        dp[1][i] = 1;
    }
    for(int i = 1; i < 1000; i++){
        for(int j = 0; j <= 1000; j++){
            dp[i+1][j] = 0;
            if( j >= i ) dp[i+1][j] += dp[i][j-i];
            if( j > i ) dp[i+1][j] += dp[i+1][j-i-1];
        }
    }
}

int main(){
    set();
    while(true){
        cin >> n >> s;
        if(n == 0 && s == 0) break;
        cout << dp[n][s] << endl;
    }
    return 0;
}