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

using namespace std;
typedef long long LL;
static const double EPS = 1e-9;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n) 
int SumOfIntegers(int n, int s){
  if(n<0||s<0) return 0;
  if(n==1) return ((s<10)?1:0);
  int a[10],count=0,sum;
  REP(i,10) a[i] = i;
  do{
    sum = 0;
    REP(i,n) sum+=a[i];
    if(sum == s) count++;
  }while(next_permutation(a, a+sizeof(a)/sizeof(a[0])));
  int d=1;
  for(int i=10-n;i>0;i--) d*=i;
  for(int i=2; i<=n; i++) d*=i;
  return (count/d);
}

int main(void){
  int n,s;
  while(cin>>n>>s,n){
    cout << SumOfIntegers(n,s) << endl;
  }
  return 0;
}

C++: #include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
#include<cctype>

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int,int> pii;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int n,s;

int solve(int cnt,int sum,int now){
	if(cnt == 10){
		return sum == s && now == n;
	}
	int res1 = solve(cnt + 1,sum + cnt,now + 1);
	int res2 = solve(cnt + 1,sum,now);
	return res1 + res2;
}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	while(1){
		cin >> n >> s;

		if(n == 0 && s == 0) break;

		int ans = solve(0,0,0);

		cout << ans << endl;
	}

	return 0;
}

C++: #include<stdio.h>
int n,m;

int f(int depth, int sum, int s)
{
    if(depth == 10)
    {
        if(sum == 0 && s == m)return 1;
        return 0;
    }
    return f(depth+1,sum-1,s+depth) + f(depth+1,sum,s);
}
int main()
{
    while(scanf("%d%d",&n,&m),n+m)
    {
        printf("%d\n",f(0,n,0));
        return 0;   
    }    
}

C++: #include <stdio.h>
#include <string.h>

int dp[11][55][11];

int cnt_sum(int n, int s, int x){
  if(dp[n][s][x] != -1){
    return dp[n][s][x];
  }
  if(n == 0 && s == 0){
    return (1);
  }
  if(x>9){
    return (0);
  }
   
  return dp[n][s][x] = (cnt_sum(n-1, s-x, x+1) + cnt_sum(n, s, x+1));
}
int main(){
  int n, s;
  memset(dp,-1,sizeof(dp));
  while(1){
    scanf("%d %d", &n, &s);
    if(n == 0 && s == 0){
      break;
    }
    if(n >= 11 || s >= 46) printf("0\n");
    else printf("%d\n", cnt_sum(n, s, 0));
  }
  return 0;
}

C++: #include <iostream>

int n, sum, ans;

void solve(int n, int sum, int less);

int main(){
	while(true){
		ans = 0;
		std::cin >> n >> sum;
		solve(n, sum, 0);
		std::cout << ans << std::endl;
	}
	return 0;
}

void solve(int n, int sum, int less){
	if(n == 0){
		if(sum == 0){
			++ans;
			return;
		}
	}

	if(sum == 0)
		return;

	for(int i = less; i < 10; ++i)
		solve(n - 1, sum - i, i + 1);

	return;
}

C++: #include <cmath>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <cstdio>
#include <cctype>
#include <queue>
#include <complex>
#include <climits>

typedef long long ll;

using namespace std;

int n, s, res = 0;

void dfs(int num, int i, int sum){
	if(sum > s || 10 - i < n - num) return ;
	if(num == n){
		if(sum == s){
			res++;
			return ;
		} else {
			return ;
		}
	}
	dfs(num, i+1, sum);
	dfs(num+1, i+1, sum+i);

	return ;
}


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

	return 0;
}

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;

/*
9 50 0
8 50 1
7 49 2
6 47 3
*/

int a(int n, int s, int f) {
	int cnt = 0;
	if (n > 2)
		for (int i = f; i <= 9; i++) {
			if (s - i > i)cnt += a(n - 1, s - i, i + 1);
			else break;
		}
	else if (n == 2)
		for (int i = f; i <= 9; i++) {
			if (s - i <= 9 && s - i > i)cnt++;
			else break;
		}
	else
		cnt = 1;

	return cnt;
}

int main() {
	for (int n, s; cin >> n >> s && (n || s);)
		cout << a(n, s, 0) << endl;

	return 0;
}

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

int cnt; int N, Ans;

void choose(int k, int l, int digit) {
  if(k == Ans && l == N) { cnt++; return; }
  else if (k >= Ans) return;
  else if (l == N) return;
  else if (digit >= 10) return;
  
  choose(k+digit, l+1, digit+1);
  choose(k, l, digit+1);
}

int main () {
  while(cin>>N>>Ans && (N||Ans)) {
    cnt = 0;
    choose(0, 0, 0);
    cout << cnt << endl;
  }
  return 0;
}

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

int cnt; int N, Ans;

void choose(int k, int l, int digit) {
  if(k == Ans && l == N) { cnt++; return; }
  else if (k >= Ans) return;
  else if (l == N) return;
  else if (digit >= 10) return;
  
  choose(k+digit, l+1, digit+1);
  choose(k, l, digit+1);
}

int main () {
  while(cin>>N>>Ans, N||Ans) {
    cnt = 0;
    choose(0, 0, 0);
    cout << cnt << endl;
  }
  return 0;
}

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

int n;
int s;
int cc;
vector<int> re;


void test(int xs,int c,int lvl){
	if(lvl==n&&xs==s){
		cc++;
	}else{
		for(int i=c+1;i<s;i++){
			test(xs+i,i,lvl+1);
		}
	}
}

int main(){
	while(cin>>n>>s,!(n==0&&s==0)){
		cc=0;
		for(int i=0;i<n-1;i++){
			test(0,i,1);
		}
		re.push_back(cc);
	}
	for(int i=0;i<re.size();i++){
		cout<<re[i]<<endl;
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
int serch(int i,int j,int n)
{
    if(!n&&!j)return 1;
    else if(i==10||!n)return 0;
    return serch(i+1,j-i,n-1)+serch(i+1,j,n);
}
int main()
{
    int n,s;
    while(cin>>n>>s&&n!=0)cout<<serch(0,s,n)<<endl;
}

C++: #include <iostream>
using namespace std;
 
int dp[11][46] = {0};
 
int main()
{
    dp[0][0]=1;
    for(int k=0; k<10; k++)
    {
        for(int i=k; i>=0; i--)
        for(int j=0; j<46-k; j++)
        {
            dp[i+1][j+k] += dp[i][j];
        }
    }
 
    int N,S;
    while(cin>>N>>S, N||S)
    {
        if(0<=N && N<11 && 0<=S && S<46)
        {
            cout << dp[N][S] << endl;
        }
        else
        {
            cout << 0 << endl;
        }
    }
}

C++: #include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <iostream>


using namespace std;

int combinations(int n, int s, int p = 9)
{
	if (n == 0 && s == 0)
		return 1;
	else if (n == 0 && s != 0)
		return 0;

	if (p < 0)
		return 0;

	int res = 0;
	for (int i = p; i >= 0; --i)
		res += combinations(n-1, s-i, i-1);

	return res;
}
int main()
{
	int n, s;
	while (true)
	{
		scanf("%d %d", &n, &s);
		if (s == 0 && n == 0)
			break;

		printf("%d\n", combinations(n, s));
	}
	return 0;
}