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 <cstdio>
#include <vector>
using namespace std;

#define MAX_S 100
#define MAX_N 10

int N, S;

int dfs(int n, int s, int count);

int main(){
	while(1){
		scanf("%d%d", &N, &S);
		if(N == 0 && S == 0) return 0;
		
		printf("%d\n", dfs(0, 0, 0));
	}
}

int dfs(int n, int s, int count){//今nまで足すか否かを決定し、その和がs
	if(count == N) return (s == S)? 1 : 0;
	
	if(n == 10 || s > S) return 0;
	
	return dfs(n + 1, s, count) + dfs(n + 1, s + n, count + 1);
}

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

int main(){
	int n,s,r,bit;
	int sum;
	
	while(cin >> n >> s , n , s){
		r = 0;
		for(int i=0;i < (1<<10) ;i++){
			sum = bit = 0;
			for(int j=0;j<10;j++)
				if( i & (1<<j) )bit++;
			if(bit != n)continue;
			
			for(int j=0;j<10;j++){
				if( i & (1<<j) )sum+=j;
			}

			if( sum == s )r++;
		}
		cout << r << endl;
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1234567;
const ll INF=1000000010;
const ll LINF=1000000000000000010LL;
const int MAX=10000010;
const double EPS=1e-3;
int dx[4]={0,1,0,1};
int dy[4]={0,0,1,1};
int dp[1010][1010];
int dfs(int i,int u,int s){
	if(i==9){
		if(u==0&&s==0){
			return 1;
		}else{
			return 0;
		}
	}
	int ret=0;
	ret+=dfs(i+1,u-1,s-i);
	ret+=dfs(i+1,u,s);
	return ret;
}
int main(){
	int n,s;
	while(cin>>n>>s,n+s){
		cout<<dfs(0,n,s)<<endl;
	}
}

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

map<pair<pair<int,int>,int>,int> memo; 

int BT( int N, int S, int d, int p, int s )
{
	if ( d==N )
		return s==S ? 1 : 0;

	pair<pair<int,int>,int> k = make_pair(make_pair(d,p),s);
	if ( memo.count(k)>0 )
		return memo[k];
	int ans = 0;
	for ( int i=p; i<=S; i++ )
		ans += BT(N,S,d+1,i+1,s+i);
	return memo[k]=ans;
}

int main()
{
	while ( true )
	{
		memo.clear();
		int n, s;
		cin >> n>>s;
		if ( n ==0 && s==0 )
			break;

		cout << BT(n,s,0,0,0) << endl;

	}

	return 0;
}

C++: #include<iostream>

using namespace std;

int n,s,c;

void dfs(int v,int sum,int M){//iは0から
	if(n==v){
		if(sum==s)c++;
	}else if(v<n){
		for(int i=M;i<=9;i++){
			if(sum+i<=s)dfs(v+1,sum+i,i+1);
		}
	}
}
int main(){
	while(true){
		cin>>n>>s;
		if(n==0&&s==0)break;
		dfs(0,0,0);
		cout<<c<<endl;
		c=0;
	}
return 0;
}

C++: #include <cstdio>
#include <cstring>
int n,s;
int dfs(int x,int y,int sum) {
	if(y==n) return (sum==s);
	if(x==10) return 0;
	return dfs(x+1,y,sum)+dfs(x+1,y+1,sum+x);
}
int main() {
	while(scanf("%d %d",&n,&s),n|s) {
		printf("%d\n",dfs(0,0,0));
	}
}

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

int nn, s;
int cmb;

void count( int n ,int k,int sa ){
  if( sa>s )
    return;

  if( DEBUG )
    cout << "n="<<n<<" k="<< k << " sa="<<sa 
	 << " cmb="<<cmb << endl;
  if( n==nn ){
    if( sa==s ) ++cmb;
    return;
  }

  for( int i=k;i<=9;i++ ){
    count( n+1,i+1, sa+i );
  }
}


int main(){
  while( cin>>nn>>s && (nn||s) ){
    if( DEBUG )
      cout << "\nnn="<<nn<<" s="<<s << endl;
    cmb = 0;
    count( 0,0,0 );
    cout << cmb << endl;
  }

  return 0;
}

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

int cnt; int N, Ans;

void choose(int k, int l, int digit) {
  if(l == N && k == Ans) { cnt++; return; }
  else if (l == N) return;
  else if (digit >= 10) return;
  
  choose(k+digit, l+1, digit+1);
  choose(k, l, digit+1);
}

int main () {
  while(cin>>N>>Ans) {
    if(N == 0 && Ans == 0) break;
    cnt = 0;
    choose(0, 0, 0);
    cout << cnt << endl;
  }
  return 0;
}

C++: #include <iostream>
using namespace std;
int n,s,spn;
void sp(int ne,int ns,bool* flag)
{
    if(ne==n&ns==s)spn++;
    for(int i=0;i<10;++i){
        if(flag[i])
            flag[i]=false;
            if(ns==s|ne>=n)continue;
            sp(ne+1,ns+i,flag);
    }
}
int main()
{
    while(1)
    {
        cin>>n>>s;if(!n)return 0;
        spn=0;
        bool flag[10]={true};
        sp(0,0,flag);
        spn/=(n*(n-1));
        cout<<spn<<endl;
    }
    return 0;
}

C++: #include<iostream>

int n, s;

int comb(int i, int sum, int c){
	if (i == 10){
		if (sum == s && c == n)return 1;
		else return 0;
	}

	return comb(i + 1, sum + i, c + 1) + comb(i + 1, sum, c);
}

int main(){
	while (std::cin >> n >> s, n || s){
		std::cout << comb(0, 0, 0) << std::endl;
	}
	return 0;
}

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

using namespace std;

int main() {
  int dp[11][101]{};
  dp[0][0] = 1;
  for (int i = 0; i < 10; ++i) {
    for (int j = i; j >= 0; --j) {
      for (int k = 0; k + i <= 100; ++k) dp[j + 1][k + i] += dp[j][k];
    }
  }
  int n, s;
  while (true) {
    cin >> n >> s;
    if (n == 0 && s == 0) break;
    cout << dp[n][s] << endl;
  }
}

C++: #include <iostream>
using namespace std;
int main( void )
{
  int n,s;
  while( 1 ){
    int ret = 0;
    cin>>n>>s;
    if( n==0 && s==0 ) break;
    for( int i=0; i < (1<<10); i++ ){
      int a=1,b=0,c=0;
      for( int j=0; j<10; j++ ){
        if( i & a ){ b += j; c++; }
        a <<= 1;
      }
      if( c == n && b == s ) ret++;
    }
    cout << ret << endl;
  }
  return 0;
}

C++: //0030
//template
//include-------------------------------------
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<stack>

using namespace std;

//typedef--------------------------------------
typedef vector<int> VI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

#define MP make_pair

//repetition-----------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

//constant-------------------------------------
const double PI = acos(-1.0);

//cout,cin-------------------------------------
#define COUT(x) cout<<(x)<<endl;
#define CIN(x) cin>>(x);

int dfs(int n,int s,int now){
	int ans=0;
	if(now>10) return 0;
	if(n==0) return s==0?1:0;
	ans+=dfs(n-1,s-now,now+1);
	ans+=dfs(n,s,now+1);
	return ans;
}

int main(){

	int n,s;
	while(cin>>n>>s){
		if(n==0 && s==0) break;
		COUT(dfs(n,s,0))
	}

	return 0;

}

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

std::uint16_t some_of_integer(std::uint16_t n, std::uint16_t s, std::uint16_t sum = 0, std::uint16_t i = 0)
{
	std::uint16_t num_cmb = 0;
	if (n == 0) {
		if (sum + i <= s && s <= sum + 9) {
			++num_cmb;
		}
	}
	else {
		for (; i < 9; ++i) {
			num_cmb += some_of_integer(n - 1, s, sum + i, i + 1);
		}
	}
	return num_cmb;
}

int main()
{
	std::uint16_t n, s;
	for (std::cin >> n >> s; !(n == 0 && s == 0); std::cin >> n >> s) {
		std::cout << some_of_integer(n - 1, s) << std::endl;
	}

	return 0;
}

C++: #include <iostream>

int sumOfIntegers(int min, int num, int sum);

int main()
{
    int num, sum;

    while (true) {
        std::cin >> num >> sum;

        if (num == 0 && sum == 0) {
            break;
        }

        std::cout << sumOfIntegers(0, num, sum) << std::endl;
    }

    return 0;
}

int sumOfIntegers(int min, int num, int sum)
{
    if (min > sum || min > 9 || num == 0) {
        return 0;
    }

    if (num == 0 && sum == 0) {
        return 1;
    }

    return (sumOfIntegers(min + 1, num, sum) + sumOfIntegers(min + 1, num - 1, sum - min));
}