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 sum,s,ans;
int sbsum(int i,int s,int num){
  if(s == sum && num == 0)
    {ans++; return 0;}
  if(i == 10)
    return 0;
  if(num == -1)
    return 0;
  sbsum(i+1,s,num);
  sbsum(i+1,s+i,num-1);
}

int main(){
  int num;
  while(cin >> num >> sum && !(num == 0 && sum == 0)){ 
    ans=0;
    sbsum(0,0,num);
    cout << ans << endl;
  }
}

C++: #include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>

using namespace std; using namespace placeholders;

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

template < typename T > inline void input_n( vector< T > &out ) { copy_n( istream_iterator< T >( cin ), out.size(), out.begin() ); };
template < typename T > inline T fromString( const string &s ) { T res; istringstream iss( s ); iss >> res; return res; };
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( e, c ) for ( auto &e : c )
#define ALL( c ) (c).begin(), (c).end()
#define AALL( a, t ) (t*)a, (t*)a + sizeof( a ) / sizeof( t )
#define DRANGE( c, p ) (c).begin(), (c).begin() + p, (c).end()

#define PB( n ) push_back( n )
#define EM emplace
#define EB emplace_back
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

int solve( int c, int n, int s )
{
	if ( c < 0 )
	{
		return n == 0 && s == 0;
	}

	return solve( c - 1, n, s ) + solve( c - 1, n - 1, s - c );
}


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

	for ( int n, s; cin >> n >> s, ( n | s ); cout << solve( 9, n, s ) << endl );

	return 0;
}

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

C++: #include <iostream>

int Judge(int n, int remain, int start)
{
	if (n == 1)
	{
		if (remain < 0)
		{
			return 0;
		}
		if (remain < start)
		{
			return 0;
		}
		if (remain > 9)
		{
			return 0;
		}
		return 1;
	}
	else
	{
		int ret = 0;
		for (int i = start; i < 9; ++i)
		{
			ret += Judge(n - 1, remain - i, i + 1);
		}
		return ret;
	}
}

int main()
{
	int n, s;

	while (std::cin >> n >> s )
	{
		if (n == 0 && s == 0)
		{
			break;
		}
		std::cout << Judge(n, s, 0) << std::endl;
	}

	return 0;
}

C++: #include <cmath>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <cstdio>
#include <cctype>
#include <queue>
#include <complex>
#include <climits>
#include <cstring>

using namespace std;

const int INF = 1 << 29;
typedef long long ll;
typedef pair<int,int> PI;

int n, s, t, res;

void dfs(int n, int t, int sum){
	if(n == 0 && sum == s) {
		res++;
		return ;
	}
	if(sum > s) return ;
	for(int i=t+1; i<=s; ++i){
		dfs(n-1, i, sum+i-1);
	}
}

int main(void){
	while(cin >> n >> s, n|s){
		if(n == 0 && s == 0) break;
		res = 0;
		int ans;
		dfs(n, 0, 0);
		cout << res << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define EXIST(v,i) (find(all(v), i) != (v).end())
#define ERASE(v,i) (v).erase(remove(all(v), i), (v).end())
#define INDEX(v,i) (find(all(v), i) - (v).begin())
#define rep(i,n) for(int i = 0; i < (int)n; ++i)
#define debug(x) cerr << #x << " = " << (x) << endl;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

const int INF = 100000000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;

int main() {
	for(int n, s; cin >> n >> s && (n || s);) {
		int ret = 0;
		for(int i = 0; i < (1<<10); i++) {
			int sum = 0;
			if(__builtin_popcount(i) != n) continue;
			for(int j = 0; j < 10; j++) {
				if((1 << j) & i) sum += j;
			}
			if(sum == s) ret++;
		}
		cout << ret << endl;
	}
	return 0;
}

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

int n, s;

int countAns(int sum, int pos, int last){
	int ans = 0;
	if (pos > n) {
		return 0;
	}else if(pos==n && sum==s){
		return 1;
	}else if(sum > s){
		return 0;
	}

	for (int i = last+1; i < 10; i++) {
		ans += countAns(sum+i, pos+1, i);
	}
	return ans;
}

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

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

// n個の重複しない整数(min ~ max)用いてsを表す組み合わせの数
int ci(int n, int s, int min, int max) {
  if (s < min || n < 1) return 0;
  if (n == 1) return (s > max)? 0: 1;
  int r = 0;
  for (int i=min; i<s && i<=max; i++) {
    r += ci(n - 1, s - i, i + 1, max);
  }
  return r;
}

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

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

using namespace std;

int dfs(int x, int n, int s)
{
    if (n == 0) {
        return (s == 0);
    }
    if (x == 10) return 0;
            
    int res = 0;
    for (int i = x; i <= 9; i++) {
        res += dfs(i + 1, n - 1, s - i);
    }
    return res;
}

int main()
{
    int n, s;
    while (cin >> n >> s, n) {
        cout << dfs(0, n, s) << 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;
}