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 <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int dfs (const int depth, const int sum, int currs, int currd, int j)
{
	int count = 0;
	int i;

	if (currd == depth){
		if (sum == currs){
			return 1;
		}else{
			return 0;
		} // end if
	} // end if
	++currd;
	
	for (i = j; i <= min(9,sum); ++i){
		currs += i;
		count += dfs (depth, sum, currs, currd, i+1);
		currs -= i;
	} // end for

	return count;
}
 

int main()
{
//	cut here before submit 
//	freopen("testcase.si", "r", stdin);
	string str = "";

	while (getline (cin, str ) ){
		int n, sum;
		int res = 0;
		stringstream ss(str);
		ss >> n >> sum;

		if (n == 0 && sum == 0){
			break;
		} // end if
		
		res = dfs (n, sum, 0, 0, 0 );

		cout << res << endl;
	} // end while
	
	return 0;
}

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

int cnt;

void choose(int n, int k, int digit) {
  if(n == 0 && k == 0) { cnt++; return; }
  else if (n <= 0) return;
  else if (k == 0) return;
  else if (digit >= 10) return;
  
  choose(n-digit, k-1, digit+1);
  choose(n, k, digit+1);
}

int main () {
  int n, ans;

  while(cin>>n>>ans, n||ans) {
    cnt = 0;
    choose(ans, n, 0);
    cout << cnt << endl;
  }
  return 0;
}

C++: #include <iostream>
using namespace std;
int n,s,count=0,digits[10];
void dfs(int cur,int start)
{
    if(cur==n){
    int sum=0;
    for(int i=0;i<n;i++){   sum+=digits[i]; }
    if(sum==s){ count++;    }
    return;
    }
    for(int i=start;i<10;i++){
        digits[cur]=i;
        dfs(cur+1,i+1);
    }
}
  int main(){ 
    while(1){
    cin>>n>>s;
    if(n==0&&s==0){
        break;
    }
    dfs(0,0);
    cout<<count<<endl;
     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&&s){
	count=0;
	cout<<solve(0,0,0)<<endl;
	}

return 0;
}

C++: #include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
#include<map>
using namespace std;

int main(){
    int mod=1000000007;
    int n,s,ans;
    int dp[11][101]={0};
    for (int i=0;i<10;++i) {
        for (int j=i;j>=0;--j) {
            for (int k=0;k+i<=100;++k) {
                dp[j+1][k+i]+=dp[j][k];
            }
        }
    }
    for (;;) {
        scanf("%d %d",&n,&s);
        if (n==0 && s==0) break;
        printf("%d\n",dp[n][s]);
    }
    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 > s) 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>
#include <vector>
#include <algorithm>
#include <stack>
#include <string>
#include <map>
#include <functional>
#include <cmath>
#include <cstdio>
using namespace std;

int main(){
  int n, s;
  while(cin >> n >> s, n, s){
    int cnt = 0;
    for(int i = 0; i <= 7; i++){
      for(int j = i + 1; j <= 8; j++){
        for(int k = j + 1; k <= 9; k++){
          if(i + j + k == s){
            cnt++;
          }
        }
      }
    }
    cout << cnt << endl;
  }
}

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

int dfs(int i, int s, int n){ // ???????????°????????????????????????????????¨????????°
  int ans = 0;
  if(i==10){
    if(s == 0 and n == 0) 
      return 1;
    else 
      return 0;
  }
  ans += dfs(i+1,s-i,n-1); // ??????
  ans += dfs(i+1,s  ,n  ); // ????????????
  return ans;
}


int main(){
  int s,n;
  while(1){
    cin >> n >> s;
    if(!s and !n) break;
    cout << dfs(0,s,n) <<  endl;
  }
}

C++: // dfs
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <cstdio>

using namespace std;

int ans, n, s;

void dfs(int pos, int t, int sum)
{
    if(t == n) {
        if(sum == s)
            ans++;
        return;
    }
    if(t > 9)
        return;

    dfs(pos+1, t, sum);
    dfs(pos+1, t+1, sum + pos);
}

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

    return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <functional>

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long

//#define scanf scanf_s
int n, s;
int cnt;

void dfs(int i, int j, int sum)
{
	if (i == n)
	{
		if (sum == s) cnt++;
	}
	else if (j <= 9&&sum<=s)
	{
		dfs(i + 1, j + 1, sum + j);
		dfs(i, j + 1, sum);
	}
}

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

C++: # include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <tuple>
# include <functional>
# include <utility>
# define INF 1000000000
# define MOD 1000000000+7
using namespace std;

int n, s;
int ans;
int dfs(int sum, int count,int num) {
	if (num > 9) {
		return 0;
	}
	if (count == n) {
		if (s == sum) {
			ans++;
		}
		return 0;
	}
	dfs(sum + num, count + 1, num + 1);
	dfs(sum, count, num + 1);
	return 0;
}

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

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

using namespace std;

struct sets { int i, sum, k; };

int n, s, cnt;
int a[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};

void dfs(int i, int sum, int k) {
    stack<sets> S;
    S.push(sets{i, sum, k});

    while (!S.empty()) {
        sets u = S.top();
        if (u.k == n && u.sum == s) { cnt++; }

        if (u.i == 10 && u.k == 0 && u.sum == 0) { break; }

        if (u.i < 10 && u.k < n) {
            S.push(sets{u.i + 1, u.sum, u.k});
            S.push(sets{u.i + 1, u.sum + a[u.i], u.k + 1});
        }
        else if (u.i == 10) {
            int tmp = u.k;
            while (S.top().k == tmp) { S.pop(); }
        }
        else { S.pop(); }
    }
}

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

C++: #include <iostream>

using namespace std;

int recursive(int n, int s, int lower)
{
	if(s < 0 || lower > 9)
		return 0;

	if(n == 1)
	{
		if(s < lower || 9 < s)
			return 0;

		return 1;
	}

	int count = 0;
	for(int i = lower; i <= 9; i++)
		count += recursive(n - 1, s - i, i + 1);
	
	return count;
}

int main()
{
	int n, s;
	while(cin >> n >> s)
	{
		if(n == 0 && s == 0)
			break;

		cout << recursive(n, s, 0) << endl;
	}

	return 0;
}