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>

int count=0;

int method(int n,int s,int k){
  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 <bits/stdc++.h>

#define INF INT_MAX
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)

using namespace std;

class State{
public:
	int n;
	int sum;
	int lastnum;
	State(int nn,int s,int l):n(nn),sum(s),lastnum(l){};
};

int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);

	int n,s;
	while(scanf("%d %d",&n,&s) != EOF && n != 0){
		vector<State> v;	//first:?????¨?????°,second:????¨????
		v.push_back(State(0,0,0));
		int ans = 0;
		while(v.size() > 0){
			int nn = v.back().n;
			int sum = v.back().sum;
			int lsn = v.back().lastnum;
			v.pop_back();
			if(nn == n){
				if(sum == s){
					ans++;
				}
				continue;
			}
			for(int i = lsn;i <= 9;i++){
				v.push_back(State(nn+1,sum+i,i+1));
			}
		}
		cout << ans << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>
#include <numeric>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define For(i,a,b) for(int (i)=(a); (i)<(b); (i)++)

int fact(int n) {
    if (n == 0) return 1;
    else return n * fact(n-1);
}

void solve30(int n, int s) {
    int cnt = 0;
    vector<int> data = {0,1,2,3,4,5,6,7,8,9};
    int skip = fact(10 - n);
    int i = 0;
    do {
        if (i % skip == 0) if (accumulate(data.begin(), data.begin() + n, 0) == s) {
            cnt++;
        }
        i++;
    }while (next_permutation(data.begin(), data.end()));
    cout << cnt / fact(n) << endl;
}

int main() {
    int n, s;
    while(cin >> n >> s, n + s) {
        solve30(n, s);
    }
    return 0;
}

C++: // AOJ.cpp : アプリケーションのエントリ ポイントを定義します。
//

//#include "stdafx.h"
#include "stdio.h"
#include <vector>
#include <iostream>

using namespace std;

class Puzzle
{
public:
	vector<int> used;

	void play()
	{
		int n;
		int s;
		int ans = 0;
		used = vector<int>(10, 0);

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

			ans = try_sum(n, s, 0);
			printf("%d\n",ans);
		}
	}

	int try_sum(int n, int s, int min)
	{
		if (n == 0 && s == 0) return 1;
		if (n == 0 || s <= 0) return 0;
		int ans = 0;

		for (int ni = min; ni < 10; ni++) {
			if (used[ni] == 0 ) {
				used[ni] = 1;
				ans += try_sum(n - 1, s - ni, ni + 1);
				used[ni] = 0;
			}
		}

		return ans;
	}

};


int main()
{
	Puzzle puz;

	puz.play();

    return 0;
}

C++: #include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define LOOP(i,x,n) for(int i=(x);i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e10;

int f(int n,int s,int m){
  int tmp=0;
  if(n==0&&s==0)return 1;
  LOOP(i,m,10)if(s-i>=0)tmp+=f(n-1,s-i,i+1);
  return tmp;
}

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

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

using namespace std;

int main() {
    int n, s, cnt, sum;
    int a[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};

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

        int arr[10] = {0};
        for (int i = 0; i < n; i++) { arr[9-i] = 1; }
        cnt = 0;
        do {
            sum = 0;
            for (int i = 0; i < 10; i++) {
                if(arr[i]) { sum += a[i]; }
            }
            if (sum == s) cnt++;
        } while(next_permutation(arr, arr+10));

        cout << cnt << endl;
    }
    return 0;
}

C++: #include <cstdio>
#include <utility>
using namespace std;

#define gcu getchar_unlocked
int in() {
	int n = 0, c = gcu();
	// bool minus = false; if (c == '-') minus = true, c = gcu();
	do {n = 10 * n + (c - '0'), c = gcu();} while (c >= '0');
	return n; }
	// return minus ? -n : n; }
//void scan(string &s) {for (char c; !isspace(c = gcu()); s += c);}
bool scan(int &n) {n = in(); int c = gcu(); return (c != EOF)? ungetc(c, stdin), true: false;}
#define pcu putchar_unlocked
template <typename T>
void out(T n) {
	static char buf[20];
	char *p = buf;
	//if(n < 0) pcu('-'), n *= -1;
	if (!n) *p++ = '0';
	else while (n) *p++ = n % 10 + '0', n /= 10;
	while (p != buf) pcu(*--p); }
void out(const char *s){while(*s)pcu(*s++);}
void out(char c){pcu(c);}
//void out(string &s){for (char c: s) pcu(c);}
template <typename head, typename... tail>
void out(head&& h, tail&&... t){out(h);out(move(t)...);}
//template <typename T>
//void out(vector<T> &v){for(T &x:v)out(' '),out(x);out('\n');}
//void out(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
#undef svo

int f(int n, int s, int j) {
	if (j > 10)
		return 0;
	if (n == 0)
		return s ? 0 : 1;
	int c = 0;
	for (int i = j; i <= 9; i++)
		if (s - i >= 0)
			c += f(n - 1, s - i, i + 1);
	return c;
}

int main() {
	int n, s;
	while (scan(n) && scan(s) && (n || s)) {
		out(f(n, s, 0), '\n');
	}
}

C++: #define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

using namespace std;

int n, s;
int cnt = 0;

void dfs(int i, int sum, int c)
{
	if (c == n)
	{
		if (s == sum)
		{
			cnt++;
		}
		return;
	}

	if (i > 9)
	{
		return;
	}

	dfs(i + 1, sum, c);

	dfs(i + 1, sum + i, c + 1);

	return;
}

int main()
{
	for (; cin >> n >> s;)
	{
		cnt = 0;
		if (n == 0 && s == 0)
		{
			break;
		}
		dfs(0, 0, 0);

		cout << cnt << endl;
	}
}

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

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

int dfs(int n,int s,int i){
  if(n == 0){
    if(s == 0)return 1;
    else return 0;
  }
  if(s <= 0)return 0;
  if(i > 9)return 0;

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

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

C++: #include <cstdio>

void calc(int from, int now_sum, int deep);

int n, s;
int ans;

int main(void)
{
    while (1){
        ans = 0;
        scanf("%d %d", &n, &s);
        if (n == 0 && s == 0) break;
        for (int i = 0; i < 10; i++){
            calc(i, i, n - 1);
        }
        printf("%d\n", ans);
    }
    
}

void calc(int from, int now_sum, int deep)
{
    if (deep == 0){
        if (now_sum == s){
            ans++;
        }
        return;
    }
    
    for (int i = from + 1; i < 10; i++){
        calc(i,  now_sum + i, deep - 1);
    }
}