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 main() {
    int n, s;
    while (cin >> n >> s, n || s) {
        int cnt = 0;
        int cmb = (1 << n) - 1;
        while (cmb < 1 << 10) {
            int sum = 0;
            for (int i=0; i<=9; ++i) {
                if ((cmb >> i) & 1) {
                    sum += i;
                }
            }
            if (sum == s) {
                cnt ++;
            }
            int x = cmb & -cmb, y = cmb + x;
            cmb = ((cmb & ~y) / x >> 1) | y;
        }
        cout << cnt << endl;
    }
    return 0;
}

C++: #ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

long long int saiki ( int N , int M , int O )
{
	if( N == 1 )
	{
		return M > O;
	}

	long long int ans = 0;
	for( int i = O + 1; i <= min ( 9 , M ); i++ )
	{
		ans += saiki ( N - 1 , M - i , i );
	}
	return ans;
}

int main ()
{
	int N , M;
	while( cin >> N >> M , N || M )
	{
		cout << saiki ( N , M , -1 ) << endl;
	}
}

C++: #include <iostream>

using namespace std;

int n , s;

int dfs(int i , int sum , int N){

	if(N == 0 && sum == 0) return 1;//yes
	if(N == 0 || i == 10) return 0;//no

	return dfs(i + 1 , sum , N) + dfs(i + 1 , sum - i , N - 1);
}

int main(){

	while(cin >> n >> s , s){

		cout << dfs(0 , s , n) << endl;
	}
	return 0;
}

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

using namespace std;

typedef long long int lli;

int n, s;

bool used[10];

lli dfs(bool used[10], int now, int sum)
{
	if (sum > s) return 0;

	if (now == n) {
		if (sum == s) return 1;
		return 0;
	}

	int res = 0;

	for (int i = 0; i < 10; ++i) {
		if (used[i]) continue;
		used[i] = true;
		res += dfs(used, now + 1, sum + i);
		used[i] = false;
	}

	return res;
}

lli fact(int n)
{
	if (n <= 1) return 1;
	return n * fact(n - 1);
}

int main()
{
    int f[10];
    for(int i = 1; i < 10; ++i) f[i] = fact(i);
	while (cin >> n >> s, n || s) {
		memset(used, false, sizeof(used));
        cout << dfs(used, 0, 0) / f[n] << endl;
	}
}

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

int n, s, res = 0, w = 1;
int a[10] = { 0 };

void dfs(int sum, int cnt) {
	if (cnt == n) {
		if (sum == s) {
			res++;
		}
	}
	for (int i = 0; i < 10; i++) {
		if (a[i] == 0) {
			a[i] = 1;
			dfs(sum + i, cnt + 1);
			a[i] = 0;
		}
	}
	return;
}

int main() {
	while (1) {
		res = 0; w = 1;
		cin >> n >> s;
		if (n == 0 && s == 0) return 0;
		dfs(0, 0);
		for (int i = 1; i <= n; i++) {
			w *= i;
		}
		cout << res / w << endl;
	}
	return 0;
}

C++: #include <iostream> 

int main(){
	int a,b;	
	while(std::cin>>a>>b&&a!=0&&b!=0){
		int d2=0,d3=0,d4=0,d5=0,d6=0,d7=0,d8=0,d9=0;
		int o=0;
		for(int d=0;d<10;d++){
			if(a>1&&d<=10-a){
				for(d2=d+1;d2<10;d2++){
			if(a>2&&d2<=10-a+1){
				for(d3=d2+1;d3<10;d3++){
			if(a>3&&d3<=10-a+2){
				for(d4=d3+1;d4<10;d4++){
			if(a>4&&d4<=10-a+3){
				for(d5=d4+1;d5<10;d5++){
			if(a>5&&d5<=10-a+4){
			for(d6=d5+1;d6<10;d6++){
			if(a>6&&d6<=10-a+5){
				for(d7=d6+1;d7<10;d7++){
			if(a>7&&d7<=10-a+6){
				for(d8=d7+1;d8<10;d8++){
			if(a>8&&d8<=10-a+7){
				for(d9=d8+1;d9<10;d9++){
		if(a==9&&b==d+d2+d3+d4+d5+d6+d7+d8+d9){
			o++;
		}
			}
		}
		if(a==8&&b==d+d2+d3+d4+d5+d6+d7+d8+d9){
			o++;
		}
			}
		}
		if(a==7&&b==d+d2+d3+d4+d5+d6+d7+d8+d9){
			o++;
		}
			}
		}
		if(a==6&&b==d+d2+d3+d4+d5+d6+d7+d8+d9){
			o++;
		}
			}
		}
		if(a==5&&b==d+d2+d3+d4+d5+d6+d7+d8+d9){
			o++;
		}
			}
		}
		if(a==4&&b==d+d2+d3+d4+d5+d6+d7+d8+d9){
			o++;
		}
			}
		}if(a==3&&b==d+d2+d3+d4+d5+d6+d7+d8+d9){
			o++;
		}
			}
		}if(a==2&&b==d+d2+d3+d4+d5+d6+d7+d8+d9){
			o++;
		}
		}
		if(a==1&&b==d+d2+d3+d4+d5+d6+d7+d8+d9){
			o++;
		}
			}
		}
		std::cout<<o<<std::endl;
	}
	return 0;
}

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

int main()
{
  int n, s;
  int i, ,j, tmp;
  int sum, count;
  int ans;
  char c;

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

    ans=0;
    for(i=0; i<1024; i++){
      tmp=i; sum=0; count=0;
      for(j=0; j<10; j++){
        if(tmp%2==1){
          sum+=i;
          count++;
        }
        tmp=tmp>>1;
      }
      if(count==n && sum==s) ans++;
    }
    printf("%d\n", ans);
  }

  reutrn 0;
}

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

int main() {
	ios :: sync_with_stdio(false);
	for(int n, s; cin >> n >> s; ) if(n && s) {
		int p[10];
		iota(p, p + 10, 0);
		int ans = 0;
		do {
			if(accumulate(p, p + n, 0) == s)
				ans ++;
		}while(next_permutation(p, p + 10));
		for(int i = 1; i <= 10 - n; i ++)
			ans /= i;
		cout << ans << '\n';
	}
	return 0;
}

C++: #include <stdio.h>
int ans, n, s;

void p(int count, int sum, int num){

	if ( sum>s || count>n ) return;

	for (int i=num+1 ; i<=9 , sum+i<=s ; i++){
		if ( (sum+i)==s && count==n ) ans++;
		p( count+1 , sum+i , i );
	}
}

int main(){
	while ( 1 ){
		ans = 0;
		scanf("%d %d", &n, &s);
		if ( n==0 && s==0 ) break;

		p( 1 , 0 , -1 );
		printf("%d\n", ans);		
	}
	return 0;
}