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 <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
	int n, s;
	vector<int> flags;

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

		flags.clear();
		for ( int i = 0; i < 10; i++ )
		{
			flags.push_back( i < n ? 1 : 0 );
		}
		sort( flags.begin(), flags.end() );

		int count = 0;

		do
		{
			int sum = 0;

			for ( unsigned int i = 0; i < flags.size(); i++ )
			{
				if ( flags[i] )
				{
					sum += i;
				}
			}

			if ( s == sum )
			{
				count++;
			}
		} while ( next_permutation( flags.begin(), flags.end() ) );

		cout << count << endl;
	}
	
	return 0;
}

C++: #include<iostream>
using namespace std;
int solve(int n,int m){
  if(n==1)return (0<=m&&m<=9);
  int res=solve(n-1,m-n+1);
  if(m-n>=0)res+=solve(n,m-n);
  if(m>=10)res-=solve(n,m-10);
  return res;
}
int main(){
  int n,m;
  while(cin>>n>>m&&n&&m){
    cout<<solve(n,m)<<endl;
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

int r;

void rec(int n, int s, int x) {
  if (!n && !s) {
    r++;
    return;
  }
  for (; x >= 0; x--)
    if (x <= s)
      rec(n-1, s-x, x-1);
}

int main() {
  for (;;) {
    int n, s;
    cin >> n >> s;
    if (!n && !s) return 0;
    r = 0;
    rec(n, s, 9);
    cout << r << endl;
  }
  return 0;
}

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

int n,s;
int cnt;

void solve(int a,int b,int i){
  if(a == n && b == s){
    cnt++;
    return;
  }
  if(a == n) return;
  if(i == 10) return;

  solve(a+1,b+i,i+1);
  solve(a,b,i+1);
}

int main(){

  while(true){
    cin >> n >> s;
    if(!n && !s) break;

    cnt = 0;
    solve(0,0,0);

    cout << cnt << endl;
  }

}

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

int n,s;

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

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

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

int counter(int n, int s,int a){
	if(n == 1)
		if(0 <= s && s <= a){
			return 1;
		} else {
			return 0;
		};
	if(n == 0) return 0;
	int max = a;
	int count = 0;
	for(int j = 1; j <= a; j++){
		if(s - j >= 0)
			count += counter(n - 1, s - j, j - 1);
	}
	return count;
}
int main(){
	int n,s;
	while(cin >> n >> s){
		if(n == 0 && s == 0) break;
		cout << counter(n, s, 9) << endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
  int n,s,j,k;
  int a[11][46];
  for(int s=0;s<46;s++)
  for(int n=0;n<10;n++)
    a[n][s]=0;
  for(int i=0;i<1024;i++){
    for(j=i,n=0;j>0;j/=2)n+=j%2;
    for(j=i,s=0,k=0;j>0;j/=2,k++)s+=k;
    a[n][s]++;
  }
  cin>>n>>s;
  for(;n||s;cout<<a[n][s]<<endl,cin>>n>>s);
}

C++: #include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
using namespace std;
int main(){
int n,s;
while(cin>>n>>s,n||s){
bool in[10]={0};
rep(i,n)in[i]=1;
sort(in,in+9);
int co=0;
do{
int sum=0;
rep(i,10)if(in[i])sum+=i;
if(sum==s)co++;
}while(next_permutation(in,in+9));
cout<<co<<endl;
}
}

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

// n個の重複しない整数(min ~ max)の和としてsを表す組み合わせの数
int ci(int n, int s, int min, int max) {
  // 特殊なパターンを処理
  if (s < min || n < 1) return 0;
  if (n == 1) return (s > max)? 0: 1;
  
  // 最も小さい数で場合分けし再帰処理
  int r = 0;
  for (int i=min; i<s && i<=max; i++) r += ci(n - 1, s - i, i + 1, max);
  return r;
}

int main() {
  while (true) {
    int n, s;
    cin >> n >> s;
    if (!n && !s) break;
    cout << ci(n, s, 0, 9) << endl;
  }
  return 0;
}

C++: #include<string>
#include<vector>
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<functional>
#include<algorithm>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<cmath>
#include<ctime>
#include<complex>

using namespace std;

#define REP(i,s,e) for(int i=int(s);i<int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)




vector<int>v(10,0);
int n,s,c=0;

void f(int i,int sum,int t){

if(t==n){
if(sum==s) c++;
else return;
}
else{

v[i]=1;
sum+=i;
t++;

REP(j,i+1,9)
if(v[j]==0) f(j,sum,t);

}
}

int main(){

while(true){

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


rep(i,10-n) f(i,0,0);

cout << c << endl;

vector<int>v(10,0);
c=0;

}

	return 0;
}

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(pos > 9)
        return;

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

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

    return 0;
}

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

#define SIZE 300005
#define MOD 1000000007LL
#define INF INT_MAX / 3
#define LLINF 1LL << 60
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define FORALL(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FOREACH(i,c) for(auto (i) : (c))
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef valarray<int> Array;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cout<<a[i];if(i==a.size()-1)cout<<endl;else cout<<" ";}}
int gcd(int a,int b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
int lcm(int a,int b){return a==0||b==0?0:a*b/gcd(a,b);}

int n, s;
int ans;
void solve(int num, int m, int sum)
{
  if(sum > s || m > 10) return;
  if(num == 0)
  {
    ans += (sum == s);
    return;
  }
  solve(num-1,m+1,sum+m);
  solve(num,m+1,sum);
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  while (1)
  {
    scanf("%d %d",&n,&s);
    if(n==0 && s==0) break;
    ans = 0; solve(n,0,0);
    printf("%d\n",ans);
  }
  return 0;
}

C++: #include<iostream>

using namespace std;

int rec(int n, int p, int s){
	if(s<0) return 0;
	if(n==0)return s==0;
	int res=0;
	for(;p<=9;p++){
		res+=rec(n-1,p+1,s-p);
	}
	return res;
}

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