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 n,ans;
bool def(int i,int j,int s){
	if(j==0){
		if(s==0){
			ans++;
		}else return false;
	}
	if(i>9)return false;
	if(s<=0)return false;
	
	def(i+1,j,s);
	def(i+1,j-1,s-i);
	return false;
}
main(){
	int s;
	while(cin>>n>>s,n && s){
		ans=0;
		def(0,n,s);
		cout<<ans<<endl;
	}
}

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>

using namespace std;

int n,s,ans;

void dfs(int now,int sum,int times){
	if(n < times)
		return;
	if(n == times && s == sum){
		ans++;
		return;
	}
	for(int i = now + 1;i <= 9;i++)
		dfs(i,sum + i,times + 1);
}

int main(){
	while(cin >> n >> s,n+s != 0){
		ans = 0;
		for(int i = 0;i <= 9;i++){
			dfs(i,i,1);
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int n,s;

int cou (int i,int cn, int cs){
	if(cs > s|| cn > n)
		return 0;
	if((cn == n||cn==n-1) && cs == s)
		return 1;
	int ans=0;
	
	for(;i<10;i++)
		ans+=cou(i,cn+1,cs+i);
	return ans;
}


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

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

int n,s;
int dfs(int p,int t,int r){
    if(p==10){
        if(t==0&&r==s)return 1;
        return 0;
    }
    return dfs(p+1,t,r)+dfs(p+1,t-1,r+p);
}
int main(){
    while(cin>>n>>s,n||s)cout<<dfs(0,n,0)<<endl;
    return 0;
}

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

int n, s;
int used[10];
int ans = 0;

void func( int num, int sum )
{
	if( num == n ){
		if( sum == s ){
			ans++;
		}
		return;
	}
	
	for( int i = used[num]; i <= 9; i++ ){
		used[num+1] = i + 1;
		func( num + 1, sum + i );
		used[num+1] = 0;
	}
}

int main()
{
	while( 1 ){
		memset( used, 0, 10 );
		ans = 0;
		
	 	std::cin >> n >> s;
		if( !n && !s ) break;
		
		func( 0, 0 );
		
		std::cout << ans << std::endl;
	}

 	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#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
	
	for (i = j; i <= min(9, sum ); ++i){
		currs += i;
		count += dfs (depth, sum, currs, currd + 1, 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>
#include <stack>

using namespace std;
 
struct set { int next, sum, depth; };
 
int n, s, cnt;

void dfs(int next, int sum, int depth) {
    stack<set> S;
    set tmp;
    tmp.next = next; tmp.sum = sum; tmp.depth = depth;
    S.push(tmp);
    while (!S.empty()) {
        set u = S.top();

        if (u.depth == n && u.sum == s) {
            cnt++;
        }
        if (u.next == 10 && u.depth == 0 && u.sum == 0) break;
        if (u.next < 10 && u.depth < n && u.sum < s) {
            tmp.next = u.next + 1;
            tmp.sum = u.sum;
            tmp.depth = u.depth;
            S.push(tmp);
 
            tmp.next = u.next + 1;
            tmp.sum = u.sum + u.next;
            tmp.depth = u.depth + 1;
            S.push(tmp);
        }
        else if (u.next == 10) {
            int tmp = u.depth;
            while (S.top().depth == tmp) {
                S.pop();
            }
        }
        else {
            S.pop();
        }
    }
}
 
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<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>

#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n) for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int, int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

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

int combination(int a, int n,int s){
	if (a == 10){
		return s == 0 && n == 0;
	}
	else
		return combination(a + 1, n - 1, s - a) + combination(a + 1, n, s);
}

int main(){
	int n, s;

	do{
		cin >> n >> s;
		if (n == 0 || s == 0)
			break;

		cout << combination(0, n, s) << endl;
	} while (1);

	return 0;
}

C++: #include<iostream>

using namespace std;
int n, s, ans;

void solve(int cnt, int num, int sum){
    if(n==cnt&&s==sum){
        ans++;
        return;
    }else if(cnt>n||num>9||sum>=s){
        return;
    }

    solve(cnt+1, num+1, sum+num);
    solve(cnt, num+1, sum);
}

int main(){

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

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

        cout<< ans<< endl;
    }
    return 0;
}

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

int km(int m, int n, int s) { //m～9の数から異なるn個を引っ張ってsとなる組み合わせを出力
	int i = 0;
	int count = 0;

	if (n == 1) {
		if (m <= s && s <= 9) { count=1; }
	}
	else {
		for (i = m; i <= 8; i++) {
			count += km(i + 1, n - 1, s - i);
		}
	}
	return count;
}

int main(void) {
	int n = 0;
	int s = 0;
	while (true) {
		n = 0;
		s = 0;

		scanf("%d %d", &n, &s);
		if (n == 0 && s == 0) { break; }

		printf("%d\n", km(0, n, s));

		
	}
	return 0;
}

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

int solve(int i,int sum,int used){
	if(i==10){
		if(s==sum&&used==n){
			
		 count++;c++;
		}
		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;c=0;
	solve(0,0,0);
	cout<<c<<endl;
	}

return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
	while (1)
	{
		int n, s;
		int ans = 0;
		cin >> n >> s;
		if (n == 0 && s == 0)break;
		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)ans++;
			int x = comb&-comb, y = comb + x;
			comb = ((comb&~y) / x >> 1) | y;
		}
		cout << ans << endl;
	}
	return 0;
}