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>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int sum, cnt;

void dfs(int c, int s, int n)
{
    if (s == sum && n == 0)
        cnt++;
    if (c == 10 || n == 0)
        return;
    dfs(c+1, s+c, n-1);
    dfs(c+1,s,n);
}

int main(void)
{
    int n;
    while (cin >> n >> sum) {
        if (n == 0 && sum == 0) break;
        cnt = 0;
        dfs(0, 0, n);
        
        cout << cnt << endl;
    }
    

    return 0;
}

C++: #include <stdio.h>
int ex(int n,int sum,int num)
{
    if(n == 0&&sum == 0)return 1;
    if(n == 0||num == 10)return 0;
    return ex(n,sum,num + 1) + ex(n - 1,sum - num,num + 1);
}
int main()
{
    while(1)
    {
        int n,sum;
        scanf("%d%d",&n,&sum);
        if(n == 0&&sum == 0)break;
        printf("%d\n",ex(n,sum,0));
    }
    return 0;
}

C++: #include <iostream>

using namespace std;

int answer;

void saiki( int number, int sum, int t )
{

	if( number == 0 ){
		if( sum == 0 ){
			answer++;
			return;
		} else {
			return;
		}
	}

	if( sum < 0 ) return;

	if( t > 9 ) return;


	saiki( number - 1, sum - t, t + 1 );

	saiki( number, sum, t + 1 );

}

int main(void)
{
	int number, sum;

	while( cin >> number >> sum && ( number || sum ) ){
		answer = 0;
		saiki( number, sum, 0 );
		cout << answer << endl;
	}
	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()
{

        printf("%d\n",3);
	//Puzzle puz;

	//puz.play();

    return 0;
}

C++: #include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <map>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

typedef vector<int> vi;
int n, s;

int solve(int remain, int k, int depth)
{
	if(depth == n)
		return remain == 0;

	int ans = 0;
	reep(i, k, min(10, remain+1)){
		ans += solve(remain-i, i+1, depth+1);
	}
	return ans;
}

int main()
{
	while(scanf("%d %d", &n, &s), n||s){
		printf("%d\n", solve(s, 0, 0));
	}

	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int a,b,ans;
void dfs(int n,int s,int bit,int bef);
int main(){

  cin >> a >> b;
  while(a!=0&&b!=0){
    
    ans = 0;
    dfs(0,0,0,-1);
    cout << ans << endl;
    cin >> a >> b;
  }

  return (0);
}

void dfs(int n,int s,int bit,int bef){
  
  if(n == a){
    if(s == b) ans++;
  }

  else {
    
    for(int i=0;i<=9;i++){
      if( ((1<<i)&bit)==0 && bef<i){
	dfs(n+1,s+i,bit|(1<<i),i);
      }
    }
  }
  
}

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

int hoge(int b, int n, int s) {
    if (n == 1)
        return (0 <= s && s <= 9 && b <= s)? 1 : 0;
    int sum = 0;
    for (int i = b; i <= 9; ++i)
        sum += hoge(i+1, n-1, s-i);
    return sum;
}

int main(void) {
    int n, s;
    while (cin >> n >> s && n!=0 && s!=0) {
        cout << hoge(0, n, s) << endl;
    }
    return 0;
}

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

int s;
int cmb;
void count( int n ,int k,int sa ){
  if( DEBUG )
    cout << "n="<<n<<" k="<< k << " sa="<<sa 
	 << " cmb="<<cmb << endl;


  if( n<1 && sa==s ){ ++cmb; return; }
  --n;
  for( int i=k;i<=9;i++ ){
    if( sa+i > s)
      break;
    if( DEBUG )
      cout << " i="<<i<<endl;
    count( n,i+1, sa+i );
  }
}


int main(){
  int n;
  while( cin>>n>>s && (n||s) ){
    if( DEBUG )
      cout << "\nn="<<n<<" s="<<s << endl;
    cmb = 0;
    count( n,0,0 );
    cout << cmb << 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;
	for(;;){
		scanf("%d%d",&n,&s);
		if(n==0 && s==0)break;
		l=min(10,s);
		vector<int> v(l,0);
		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>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int n, s;
int dp[10][100][10];
int solve(int i, int j, int k);

int main(void){
	
	while(cin >> n >> s){
		if(n == 0 && s == 0){break;}
		fill_n(**dp,10*100*10,-1);
		cout << solve(0,0,10) << endl;
	}
}

int solve(int now, int sum, int b1){
	if(now == n){
		if(sum == s){return 1;}
		else return 0;
	}
	if(dp[now][sum][b1] != -1){return dp[now][sum][b1];}
	now++;
	int t = 0;
	for(int i = 0; i < 10; i++){
		if(b1 != 10 && b1 >= i){continue;}
		t += solve(now, sum + i, i);
	}
	return dp[now][sum][b1] = t;
}

C++: #include <stdio.h>

double n, s, dp[11][1001];

int main(void)
{	
	int i, j, k;
	int s, n;
	
	dp[0][0] = 1;
   	
  	for(i = 0; i < 101;i++)
    	for(j = 9; j >= 0; j--)
      		for(k = 0; i + k < 1001; k++)
        		dp[j + 1][k + i] += dp[j][k];
				
	
	/*for (i = 0; i < 10; i++){
		for (j = 0; j < 20; j++){
			printf("%2.0lf ",dp[i][j]);
		}
		printf("\n");
	}*/
	
	while (1){
		scanf("%d %d", &n, &s);
		if (n == 0 && s == 0) break;
		
		printf("%.0lf\n", dp[n][s]);
	}
	
	return (0);
}

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

int avail_inc(int depth, int sum, int minval) {
	if (depth == 0)
		return (sum == 0 ? 1 : 0);

	int ret = 0;
	for (int i = minval; i <= 9 && i <= sum; i++)
		ret += avail_inc(depth-1, sum-i, i+1);
	return ret;
}

int avail_dec();

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

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    while(true){
        int n, s;
        cin>>n>>s;
        if(n==0&&s==0) break;
        int c=0;
        for(int i=0; i<8; i++){
            for(int j=i+1; j<9; j++){
                int k=s-i-j;
                if(j<k&&k<=9) c++;
            }
        }
        cout<<c<<'\n';
    }
    return 0;
}

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

int count=0;
void searchComb(int n, int s, int minimum);

int main()
{
    int n,s;

    while (cin >> n >> s)
    {
        count=0;
        if(n==0 && s==0)
        {
            break;
        }
        searchComb(n, s, 0);
        cout << count << endl;
    }
    return 0;
}


void searchComb(int n, int s, int minimum)
{
    if(n<=0)
    {
        if(s==0)
        {
            count++;
        }

        return;
    }

    for(int i= minimum; i<10; i++)
    {
        if(s-i >= 0)
        {
            searchComb(n-1, s-i, i+1);
        }
    }
}