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

int dfs(int idx, int rem, int res){
  if(rem == 0 && res == 0){
    return 1;
  }
  if(idx < 0 || rem < 0 || res < 0){
    return 0;
  }
  return dfs(idx-1, rem-1, res-idx) + dfs(idx-1, rem, res);
}

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

C++: #include <iostream>

using namespace std;

int n, s, cnt;

void dfs(int next, int sum, int depth) {
    if (depth == n && sum == s) {
        cnt++;
        return;
    }

    if (next == 10 || depth == n || sum > s) return;

    dfs(next + 1, sum + next, depth + 1);
    dfs(next + 1, sum, depth);
}

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

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

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

int main(){
	int n,s;
	
	while(cin>>n>>s,n||s){
		res=0;
		dfs(0,0,n,0,s);
		cout<<res<<endl;
	}
	
	return 0;
}
a
void dfs(int now,int idx,int n,int sum,int s){
	if(now==n&&sum==s) {
		res++;
		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;
	
	if(idx>9) return false;
	
	return false;
}

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

int main() {
int n,s,ans;
while(cin>>n>>s){
	ans=0;
	if(n==0){
		break;
	}
	if(n==1){
		if(0<=s && s<=9){
			ans=1;
		}
		else{
			ans=0;
		}
	}
	if(n==2){
		for (int k=0;k<=8;k++){
			for (int l=k+1;l<=9;l++){
				if(k+l==s){
					ans=ans+1;
				}
			}
		}
	}
	if(n==3){
		for (int k=0;k<=7;k++){
			for (int l=k+1;l<=8;l++){
				for (int m=l+1;m<=9;m++){
				if((k+l)+m==s){
					ans=ans+1;
				}
				}
			}
		}
	}
	if(n==4){
		for (int k=0;k<=6;k++){
			for (int l=k+1;l<=7;l++){
				for (int m=l+1;m<=8;m++){
					for(int o=m+1;o<=9;o++){
				if((k+l)+(m+o)==s){
					ans=ans+1;
				}
					}
				}
			}
		}
	}
	if(n==5){
		for (int k=0;k<=5;k++){
			for (int l=k+1;l<=6;l++){
				for (int m=l+1;m<=7;m++){
					for(int o=m+1;o<=8;o++){
						for(int p=o+1;p<=9;p++){
				if((k+l)+((m+o)+p)==s){
					ans=ans+1;
				}}
					}
				}
			}
		}
	}
	if(n==6){
		for (int k=0;k<=6;k++){
			for (int l=k+1;l<=7;l++){
				for (int m=l+1;m<=8;m++){
					for(int o=m+1;o<=9;o++){
				if((k+l)+(m+o)==45-s){
					ans=ans+1;
				}
					}
				}
			}
		}
	}
	if(n==7){
		for (int k=0;k<=7;k++){
			for (int l=k+1;l<=8;l++){
				for (int m=l+1;m<=9;m++){
				if((k+l)+m==45-s){
					ans=ans+1;
				}
				}
			}
		}
	}
	if(n==8){
		for (int k=0;k<=8;k++){
			for (int l=k+1;l<=9;l++){
				if(k+l==45-s){
					ans=ans+1;
				}
			}
		}
	}
	if(n==9){
		if(36<=s && s<=45){
			ans=1;
		}
		else{
			ans=0;
		}
	}
	cout<<ans<<endl;
}
	return 0;

}

C++: // 2014/09/12 Tazoe

#include <iostream>
using namespace std;

int DFS(int n, int s, int m)
{
	if(n==0 && s==0)
		return 1;
	else if(n<=0)
		return 0;
	else if(s<=0)
		return 0;
	else if(m>9)
		return 0;

	int cnt = 0;

	cnt += DFS(n-1, s-m, m+1);
	cnt += DFS(n, s, m+1);

	return cnt;
}

int main()
{
	while(true){
		int n, s;
		cin >> n >> s;

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

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

	return 0;
}

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

int n,s;
int cnt;

void solve(int a,int b,int c){
  if(a == n && b == s){
    cnt++;
    return;
  }
  if(b >= s) return;
  if(n <= a) return;
  if(n-1 == a && s-b < c) return;

  for(int i=c;i<10;i++) solve(a+1,i,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>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &((x)[0]), &((x)[n])
#define SUBIF(a, b, x) ((x) ? (b) : (a))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define pb push_back
#define EPS (1e-20)
#define INF 2147483647LL
#define MOD 1000000007LL
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using namespace std;


int n, s;
VI comb;


int cntBit(int bit){
	int cnt = 0;
	do {
		cnt += bit&1;
	} while(bit/=2);
	return cnt;
}


void makeComb(){
	rep(i, 0, 1<<10)
		if(cntBit(i) == n) comb.pb(i);
}


int solve(){
	int ans = 0;
	for(int x : comb){
		int sum = 0;
		repe(i, 0, 9)
			if((x>>i)&1) sum += i;
		if(sum == s) ans++;
	}
	return ans;
}


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

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

int main() {
	int n,s;
	while(cin>>n>>s,n)
	{
		int c=0;
		int comb=(1<<n)-1;
		while(comb<(1<<10))
		{
			int sum=0;
			for(int i=0;i<10;i++)
			{
				if(comb>>i&1)sum+=i;
			}
			if(sum==s)c++;
			int x=comb&-comb,y=comb+x;
			comb=(((comb&~y)/x)>>1)|y;
		}
		cout<<c<<endl;
	}
	return 0;
}

C++: #include<iostream>
#include<stdio.h>
using namespace std;
/*
int solve(int n,int m){
  if(2*m>90-(n-1)*n)return 0;
  if(2*m<(n-1)*n)return 0;
  if(n==1)return (0<=m&&m<=9?1:0);
  int res=0;
  if(m-n+1>=0)res+=solve(n-1,m-n+1);
  if(m-n>=0)res+=solve(n,m-n);
  if(m-10>=0)res-=solve(n,m-10);
  return res;
}
*/
int dp[11][101];

int main(){
  int n,m;
  for(int i=0;i<11;i++)
    for(int j=0;j<101;j++)
      dp[i][j]=0;
  for(int i=0;i<=9;i++)dp[1][i]=1;

  for(int i=2;i<=10;i++){
    for(int j=0;j<=100;j++){
      if(j-i>=0)dp[i][j]+=dp[i][j-i];
      if(j-(i-1)>=0)dp[i][j]+=dp[i-1][j-(i-1)];
      if(j-10>=0)dp[i][j]-=dp[i-1][j-10];
 
    }

  }
  /*
  for(int i=0;i<=10;i++){
    for(int j=0;j<=50;j++){
      printf("%2d ",dp[i][j]);
    }
    cout<<endl;
  }
  */
  while(cin>>n>>m&&n&&m){
    cout<<dp[n][m]<<endl;
  }
  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;

/*
0 1 2 3 4 5 6 7 8 9

*/

//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 a = 0, S;

void dfs(int i, int s, int n) {
	//cout << i << " " << s << " " << n << endl;
	if (s == S&&n == 0) {
		a++;
		return;
	}
	if (i == 10 || n == 0)
		return;

	dfs(i + 1, s + i, n - 1);
	dfs(i + 1, s, n);
}

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

	return 0;
}