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 count(int n,int s,int i)
{
  if(n == 1){
    if(i <= s && s < 10) return 1;
    return 0;
  }
  int res = 0;
  for(; i<10; i++){
    res += count(n-1, s-i,i+1);
  }
  return res;
}
int main()
{
  int n,s;
  while(cin >> n >> s, n!=0){
    int cnt = count(n,s,0);
    cout << cnt << endl;
  }
  return 0;
}

C++: #include<iostream>

using namespace std;

int n, s;
int c = 0;
int i = 0;
int j = 0;
int q = 0;
int sum = 0;
int date[15] = { 0 };



int sub(int start,int n,int x){
	if (x == n){
		for (int i = 0; i < n; i++){
			
				sum += date[i];
		}
		if (sum == s){
			q++;
		}
		sum = 0;
		return 0;
	}

	for (int i = start; i < 10;i++){

		date[x] = i;

		sub(i + 1, n, x + 1);
	
	}


}



int main(){

	n = 0;
	while (true){
		cin >> n >> s;
		if (n == 0 && s == 0)break;
		sub(0, n, 0);


		cout << q << endl;
		q = 0;
	}
}

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

int n,k,count;
int value[10] = {0,1,2,3,4,5,6,7,8,9};

void dfs(int i,int sum,int num)
{
	if(num == n) 
	{
		if(sum == k)
		{
			count++;
		}
		return;
	}

	if(i == 10)
	{
		return;
	}
	
	dfs(i+1,sum,num);
	dfs(i+1,sum + value[i],num+1);
}
int main()
{
	while(cin >> n >> k && n && k)
	{
		count = 0;
		dfs(0,0,0);
		cout << count << endl;

	}
	return 0;
}

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

int n,s;

int dfs(int i, int sum){
  if(i == n){
    if(sum == s) return sum;
  }

  //iを足さない
  if(dfs(i+1,sum) != 0) return sum;

  //iを足す
  if(dfs(i+1,sum+i) != 0) return sum;

  return 0;
}



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

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

int func(int n, int s, int sum = 0, int mx = -1){
  if(n == 0){
    return (s == sum) ? 1 : 0;
  }

  int ans = 0;
  for(int i = mx + 1; i <= 9; i++){
    ans += func(n - 1, s, sum + i, i);
  }
  return ans;
}


int main(void){
  while(true){
    int n, s;
    cin >> n >> s;
    if(n == 0 && s == 0){ break; }
    cout << func(n, s) << endl;
  }
  
  return 0;
}

C++: #include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>
#include<map>
#include<queue>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)
#define in(i,j,k) ((i)>=(j)&&(i)<=(k))

int main(){
	int n,s,l,a,c;
	while(scanf("%d%d",&n,&s)){
		l=min(10,s);
		vector<int> v(l);
		rep(i,n)v[i]=1;
		c=0;
		do{
			a=0;
			rep(i,l)a+=i*v[i];
			c+=s==a;
		}while(prev_permutation(v.begin(),v.end()));
		printf("%d\n",c);
	}
	return 0;
}

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

int res;
const int d[10]={0,1,2,3,4,5,6,7,8,9};

void dfs(int now,int idx,int n,int sum,int s){
	
	if(idx>9) return false;
	
	if(now==n&&sum==s) {
		res++;
		return true;
	}
	
	if(dfs(now,idx+1,n,sum,s)) return true;
	
	if(dfs(now+1,idx+1,n,sum+d[idx],s)) return true;
	
	return false;
}

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

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

int main(void)
{
	int n, s;
	while(cin >> n >> s)
	{
		int res = 0;
		if(n==0 && s==0) break;
		if(s<(n-1)*(n-2)/2 || s>(19-n)*n/2) res = 0;

		for(int i=0; i<=7; i++)
		{
			for(int j=i+1; j<=8; j++)
			{
				for(int k=j+1; k<=9; k++)
				{
					if(i+j+k == s)
						res++;
				}
			}
		}

		cout << res << endl;
	}
	return 0;
}

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

int x,y,z[50]={};

int mySet(int d,int e){
	int a=0;
	if(d==x){
		if(e==y){
			return 1;
		}else{
			return 0;
		}
}
	for(int i=0;i<=9;i++){
		z[d]=i;
		a+=mySet(d+1,e+i);
	}
	return a;
}

int main(void){
	while(1){
		cin>>x>>y;
		if(x==0&&y==0){
			break;
		}else{
			cout<<mySet(0,0)<<endl;
		}
	}
	return 0;
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <queue>
#include <vector>
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <cctype>
#include <cstdlib>
#include <string.h>
#include <utility>
#include <cstdio>
#include <set>
#include <map>
#include <assert.h>
using namespace std;

#define INF (1 << 20)
#define EPS (1e-10)
#define EQ(a,b) (fabs((a)-(b)) < EPS)

#define ll long long
#define LL long long

int flg[10];

int dfs(int n, int s) {
	int ret = 0;
	if (n == 0) return s == 0;
	for (int i = 0; i < 10; ++i) {
		if (flg[i]) continue;
		flg[i]++;
		ret += dfs(n-1, s-i);
		flg[i]--;
	}
	return ret;
}

int main() {
	int n, s;
	while (cin >> n >> s) {
		if (n == 0) break;
		int res = dfs(n, s);
		while (n != 0) res /= n--;
		cout << res << endl;
	}
	return 0;
}

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

int dp[10][11][101];	//dp[今作った項][今使った数(昇順に使う)+1][今の和]

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

C++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
const int MAX = (int)2e5 + 5;

int n, s;

ll dfs(int v, int sum, int depth) {
	ll res = 0;
	if (depth == n) {
		if (sum == s) return 1;
		else return 0;
	}
	REP(i, v + 1, 10) {
		ll tmp = dfs(i, sum + i, depth + 1);
		res += tmp;
		if (false) {
			cout << "dfs(" << i << "," << sum + i << "," << depth + 1
				<< ") = " << tmp << endl;
		}
	}
	return res;
}

int main() {
	while (1) {
		cin >> n >> s;
		if (n == 0) break;
		// dump(dfs(2, 6, 3));
		cout << dfs(-1, 0, 0) << endl;
	}
	return 0;
}

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

int res;
const int d[10]={0,1,2,3,4,5,6,7,8,9}

int main(){
	int n,s;
	
	while(cin>>n>>s,n||s){
		res=0;
		dfs(0,0,n,0,s);
		cout<<res<<endl;
	}
	
	return 0;
}
a
void dfs(int now,int idx,int n,int sum,int s){
	if(now==n&&sum==s) {
		res++;
		return true;
	}
	
	if(dfs(now,idx+1,n,sum,s)) return true;
	
	if(dfs(now+1,idx+1,n,sum+d[idx],s)) return true;
	
	if(idx>9) return false;
	
	return false;
}