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<string.h>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;

int n,s;

int solve(int now,int last,int count){
    if(count==n&&now==s){
        return 1;
    }
    if(count==n||now>s){
        return 0;
    }
    int co=0;
    for(int i=last+1;i<10;i++){
        co+=solve(now+i,i,count+1);
    }
    return co;
}
int main()
{
    
    while(cin>>n>>s){
        if(n==0&&s==0)break;
        int count=0;
        for(int i=0;i<10;i++){
            count+=solve(i,i,1);
        }
        cout<<count<<endl;
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int ans;
bool def_2(int i,int j,int s){
	if(j==0){
		if(s==0){
			ans++;
		}else return false;
	}
	if(i>9)return false;
	if(s<=0)return false;
	def_2(i+1,j,s);
	def_2(i+1,j-1,s-i);
	return false;
}
int def(int k,int n,int s){
	if(n==0){
		if(s==0) return 1;
		else return 0;
	}
	int a=0;
	for(int i=k;i<=9;++i){
		a+=def(i+1,n-1,s-i);
	}
	return a;
}
main(){
	int s,n;
	while(cin>>n>>s,n||s){
		ans=0;
		cout<<def(0,n,s)<<endl;
		//cout<<ans<<endl;
	}
}

C++: #include <iostream>
//#include <fstream>
using namespace std;
int ans,n,s;

void dfs(int cnt,int sum,int i){
	if(sum>s||cnt>n||i>9){
		return;
	}
	if(sum==s&&cnt==n){
		++ans;
		return;
	}
	dfs(cnt,sum,i+1);
	dfs(cnt+1,sum+i,i+1);
	return;
};

int main(){
	while(cin>>n>>s&&n&&s){
		ans=0;
		dfs(0,0,0);
		cout << ans << "\n";
	}
	return 0;
}

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

int s;

void com(int c,int p[100],int a,int b){
	if(c==a){
		int m = 0;
		for(int i=1;i<=a;i++) m += p[i];
		if(m==b) s++;
	}
	else{
		for(int i=p[c]+1;i<=b-p[c];i++){
			p[c+1] = i;
			com(c+1,p,a,b);
		}
	}
}

int main(){
	int a,b;
	while(1){
		cin >> a >> b;
		if(a+b==0) break;
		s = 0;
		int p[100];
		p[0] = -1;
		com(0,p,a,b);
		cout << s << endl;
	}
}

C++: #include <iostream>
using namespace std;
int main(){
  int n,s,j,k;
  int a[11][46];
  for(int s=0;s<46;s++)for(int n=0;n<11;n++)a[n][s]=0;
  for(int i=0;i<1024;i++){
    for(j=i,n=0;j>0;j/=2)n+=j%2;
    for(j=i,s=0,k=0;j>0;j/=2,k++)s+=j%2*k;
    cout<<n<<","<<s<<endl;
    a[n][s]++;
  }
  while(true){
    cin>>n>>s;
    if(!n&&!s)
      break;
    cout<<a[n][s]<<endl;
  }
  return 0;
}
//  for(cin>>n>>s;n||s;cout<<a[n][s]<<endl,cin>>n>>s);

C++: #include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <math.h>
#include <stdlib.h>

using namespace std;

void saiki();

int n,s;
int ans=0;
int num[10]={0};



int main(){

  while(1){

  scanf("%d %d",&n,&s);
  if(n==0 && s==0) break;

  if(n>s) printf("0\n");
  else{
    for(int i=0;i<n;i++) num[i]=i;
    //再起
    saiki();
  }

  }
  return 0;
}



void saiki(){
  int i,memo=0;

  //確認
  for(i=0;i<n;i++){
    memo+=num[i];
  }


  //もし同じだったら
  if(memo==s){

    ans++;

    if(num[0]==0){
      //初期化
      for(i=0;i<n;i++) num[i]=i;
      //+1
      for(i=n-ans-1;i<n;i++) num[i]+=1;
      saiki();
    }
    
    else{
      printf("%d\n",ans);
    }
  }
  
  //違っていたら
  else{
    num[n-1]+=1;
    saiki();
  }
  
}

C++: #include <iostream>
using namespace std;int main(){int n,s,j,k,a[11][46];for(int s=0;s<46;s++)for(int n=0;n<11;n++)a[n][s]=0;for(int i=0;i<1024;i++){for(j=i,n=0;j>0;j/=2)n+=j%2;for(j=i,s=0,k=0;j>0;j/=2,k++)s+=j%2*k;a[n][s]++;}for(cin>>n>>s;n||s;s<46?cout<<a[n][s]:cout<<0,cout<<endl,cin>>n>>s);}

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

int cnt, n, s;
bool used[10];

void rec(int pos, int t, int sum ){
    if ( t == n ){
	if ( sum == s ) cnt++;
	return;
    }
    if ( pos > 9 ) return;

    rec(pos+1, t, sum);
    rec(pos+1, t+1, sum + pos);
}   
 
main(){
    while( cin >> n >> s && n && s ){
	cnt = 0;
	rec(0,  0, 0);
	cout << cnt << endl;
    }
}

C++: #include <iostream>
using namespace std;
 
int main() {
	int n,s;
	while(cin>>n>>s){
		int dp[114][514]={};
		dp[0][0]=1;
		for(int i=0;i<=9;i++){
			for(int j=n-1;j>=0;j--){
				for(int l=s-i;l>=0;l--){
					if(dp[j][l]!=0)dp[j+1][l+i]+=dp[j][l];
				}
			}
		}
		cout<<dp[n][s]<<endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,ans,cnt,sum;
  while(cin >> a >> b){
    if(a==0 and b==0){
      break;
    }
    ans=0;
    for(int i0=0;i0<2;i0++){
      for(int i1=0;i1<2;i1++){
        for(int i2=0;i2<2;i2++){
          for(int i3=0;i3<2;i3++){
            for(int i4=0;i4<2;i4++){
              for(int i5=0;i5<2;i5++){
                for(int i6=0;i6<2;i6++){
                  for(int i7=0;i7<2;i7++){
                    for(int i8=0;i8<2;i8++){
                      for(int i9=0;i9<2;i9++){
                        cnt=i0+i1+i2+i3+i4+i5+i6+i7+i8+i9;
                        sum=i1*1+i2*2+i3*3+i4*4+i5*5+i6*6+i7*7+i8*8+i9*9;
                        if(cnt==a and sum==b){
                          ans++;
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

int counter;

void search( int n, int s, int csum, int begin, int depth ){
  for( int i = begin; i <= 9; i++ ){
    if( depth == n ){
      if( csum + i == s ){ counter++; }
      return;
    }

    if( csum >= s ){ return; }
    search( n, s, csum + i, i + 1, depth + 1 );
  }
}

int main(){
  int n, s;
  while( 1 ){
    counter = 0;
    cin >> n >> s;
    if( !n && !s ){ return 0; }
    search( n, s, 0, 0, 0 );
    cout << counter << endl;
  }
}

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

int cnt,n,s;

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

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

  return 0;
}

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

int rec(int n, int s, int num)
{
  if (n == 0 && s == 0) return 1;
  if (n == 0 || num == 10) return 0;

  return rec(n, s, num + 1) + rec(n - 1, s - num, num + 1);
}

signed main()
{  
  int n, s;
  
  while (cin >> n >> s, n || s) {
    cout << rec(n, s, 0) << endl;
  }

  return (0);
}

C++: #include <iostream>  
using namespace std;  
  
int ans, s, n;  
  
void dfs(int i, int sum, int n){  
    if((sum == s) && (n == 0)){  
        ans++;  
        return;  
    }  
    if((i == 10) || (n == 0)) return;  
    dfs(i+1, sum, n);  
    dfs(i+1, sum+i, n-1);  
}  
  
int main(){  
    while(cin >> n >> s){  
        ans = 0;  
        if(n == 0 && s == 0) break;  
        dfs(0, 0, n);  
        cout << ans << endl;  
    }  
    return 0;  
}

C++: #include <cstdio>

using namespace std;

int rec(int x, int acc, int n, int s) {
  if (x == 10) {
    return n == 0 && acc == s;
  }

  int ret = 0;
  ret += rec(x+1, acc, n, s);
  if (n > 0)
    ret += rec(x+1, acc+x, n-1, s);
  
  return ret;
}

int solve(int n, int s) {
  return rec(0, 0, n, s);
}

int main(int argc, char *argv[])
{
  int n, s;
  while (~scanf(" %d %d", &n, &s)) {
    if (n == 0 && s == 0)
      break;
    int ret = solve(n, s);
    printf("%d\n", ret);
  }
  
  return 0;
}