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 ans = 0;
void dfs(int n,int s,int d){
	if (s < 0) return;
	if (s == 0 and n == 0){
		ans++;
		return;
	}
	if (n == 0) return;	
	d++;
	if (d == 10)return;
//	cout << "n=" << n;
//	cout << " s=" << s;
//	cout << " d=" << d <<  endl;
	//???????????´???
	dfs(n-1,s-d,d);
	//?????°????????£?????´???
	dfs(n,s,d);
return;
}

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

return 0;
}

C++: #include<iostream>

int count=0;

int method(int n,int s,int k){
  if(k>9){
    return 0;
  }
  if(s==0&&n==0){
    count++;
    return 0;
  }
  if(s==0||n==0||k>s){
    return 0;
  }
  if(s-k>=0){
    method(n-1,s-k,k+1);
  }
  method(n,s,k+1);
  return 0;
}

int main(){
  int n,s;

  while(std::cin >> n >> s){
    if(n==0&&s==0){
      break;
    }
    count =0;
    method(n,s,0);

    std::cout << count << std::endl;
  }
}

C++: #include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <math.h>
#include <functional>
#include <algorithm>
#include <utility>

typedef long long Int;
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
#define REPS(a,i,n) for(int i = a ; i < n ; ++i)
using namespace std;

int ans;
int a, b;

void solve(int i, int _b, int sum){
	if (sum == a && _b == 0){
		ans++;
		return;
	}
	if (_b == 0 || i == 10)return;
	if (i != -1)
		solve(i + 1, _b - 1, sum + i);
	solve(i + 1, _b, sum);
}

int main(){
	while (cin >> b >> a, a||b){
		ans = 0;
		solve(-1, b, 0);
		cout << ans << endl;

	}
	return 0;
}

C++: #include <iostream>

using namespace std;

/*	MaxNum以下のnHmNum個の数字でnNumToMakeを作るとき
	何通りの答えがあるかを返す							*/
int dfs(int nhmNum,int nNumToMake,int MaxNum){
	if(nhmNum == 0){
		if(nNumToMake == 0){
			return 1;
		}else{
			return 0;
		}
	}
	if(nNumToMake < 0)
		return 0;
		
	int ans = 0;
	for(int i = 0;i < MaxNum;i++){
		ans += dfs(nhmNum - 1,nNumToMake - i,i);
	}
	return ans;
}

int main() {
	int hmNum,Sum;
	while(1){
		cin >> hmNum;
		cin >> Sum;
		if(hmNum == 0 && Sum == 0)
			break;
		cout << dfs(hmNum,Sum,10) << endl;
	}
	return 0;
}

C++: #include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<utility>

using namespace std;

int n, s;

int cntBit(int bit)
{
	int cnt = 0;

	do
	{
		cnt += bit & 1;

		bit /= 2;

	} while (bit);

	return cnt;
}

int main(void)
{

	while (cin >> n >> s,n!=0||s!=0)
	{
		int cnt = 0;

		for (int i = 0; i < 1024; i++)
		{
			if (cntBit(i) != n)continue;

			int sum = 0;

			for (int j = 0; j < 10; j++)
				if ((i >> j) & 1)sum += j;

			if (sum == s)cnt++;
		}

		cout << cnt << endl;
	}
	

	return 0;
}

C++: //0030 Sum of Integers
//0 ©ç 9 Ì©çÙÈé n ÂÌðæèoµÄvª s ÆÈégÝí¹ÌðoÍµÄI¹·évOðì¬µÄ­¾³¢B
//n ÂÌÍ¨Ì¨Ì 0 ©ç 9 ÜÅÆµAPÂÌgÝí¹É¯¶Íg¦Ü¹ñ

#include<iostream>
using namespace std;

static const int N = 10;
int n, s;
bool isUse[N];

int Calc(int d, int useNum, int sum)
{
	if(sum > s || useNum > n || useNum+(N-d) < n)
		return 0;
	if(d == 10)
	{
		if(sum == s)
			return 1;
		else
			return 0;
	}
	
	int result = 0;
	isUse[d] = true;
	result += Calc(d+1, useNum+1, sum+d);
	isUse[d] = false;
	result += Calc(d+1, useNum, sum);

	return result;
}

int main(void)
{
	while(cin >> n >> s, n)
	{
		fill(isUse, isUse+N, false);
		cout << Calc(0, 0, 0) << endl;
	}
	return  0;
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int n,s;
int Sum_of_Integers(int i,int sum,int v);
int main(){
  while(1){
    cin >> n >> s;
    if(!n && !s)break;
    cout <<  Sum_of_Integers( 0 , 0 , -1) << endl;
  }
}
int Sum_of_Integers(int i,int sum,int v){
  int ret = 0;
  if(i > n || sum > s)return 0; // あふれたとき
  if(i == n && sum == s)return 1;
  for(int j=0;j<=9-sum;j++){
    if(v<j)ret += Sum_of_Integers( i + 1, sum + j , j );
  }
  return ret;
}

C++: #include<iostream>

using namespace std;

int ans = 0;
void dfs(int n,int s,int d){
	if (s < 0) return; 
	if (s == 0 and n == 0){ // 
		ans++;
		return;
	}
	if (n == 0) return;	
	d++;
	if (d == 10)return;
	//???????????´???
	dfs(n-1,s-d,d);
	//?????°????????£?????´???
	dfs(n,s,d);
return;
}

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

return 0;
}

C++: #include<iostream>
#include<vector>
#include<string>
#include<cstdio>
using namespace std;
int ans;
int n;
int s;

void count_ans(int k,int C,int j){
	if(k==n){
		if(C==s){
			ans++;
		}
	}else{
		for(int i=j+1;i<10;i++){
			count_ans(k+1,C+i,i);
		}
	}
	
}


int main(){
	while(cin>>n>>s,(n!=0)||(s!=0)){
		ans=0;
		count_ans(0,0,-1);
		cout<<ans<<endl;
	}
}

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;
		if(n == 0 && sum == 0)
			break;
		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 <iostream>
using namespace std;

int n, s, dp[11][46];

void set(){
    for(int i = 0; i < 10; i++){
        dp[1][i] = 1;
    }
    for(int i = 1; i < 10; i++){
        for(int j = 0; j < 46; 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;
}

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

using namespace std;

int n,s;
int cnt;
 
void solve(int a,int b,int c){
    if(b==n && s==c){
        cnt++;
    }
    if(b<n){
        for(int i=a+1;i<=9;i++)solve(i,b+1,c+i);
    }
}

int main(void){
    while(1){
        scanf("%d%d",&n,&s);
        cnt=0;
        if(n==0)break;
        solve(-1,0,0);
        printf("%d\n",cnt);
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int n, s;
int cou;
void dfs(int i, int sum,int num_of_add) {
	if (sum == s&&num_of_add==n) {
		cou++;
		return;
	}
	if (n == num_of_add||i==10)return;
	dfs(i + 1, sum, num_of_add);
	dfs(i + 1, sum + i, num_of_add + 1);
}
int main() {
	while (cin >> n >> s,n != 0 || s != 0) {
		cou = 0;
		dfs(0, 0, 0);
		cout << cou << endl;
	}
}

C++: #include <iostream>
using namespace std;
int n, s, cnt;

void dfs(int depth, int num, int sum) {
  if (depth == 0 && sum == s) {
    cnt++;
    return;
  }
  if (num == 10 || depth == 0) return;
  dfs(depth, num + 1, sum);
  dfs(depth - 1, num + 1, sum + num);
}

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

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

int main() {
	int N, S;
	vector<int> v(10);
	for (int i = 0; i < 10; i++) {
		v.at(i) = i;
	}

	while (cin >> N >> S) {
		if (N == 0 && S == 0) {
			break;
		}

		int cnt = 0;
		for (int tmp = 0; tmp < (1 << 10); tmp++) {
			bitset<10> bs(tmp);

			if (bs.count() == N) {
				int sum = 0;
				for (int i = 0; i < 10; i++) {
					if (bs.test(i)) sum += i;
				}

				if (sum == S) cnt++;
			}
		}

		cout << cnt << endl;
	}
}