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

void func(int start,int num,int current);
int s,res;
vector<int> ans;

int main(void){
  int n;
  cin >> n; cin >> s;
  while(n!=0 && s!=0){
    res = 0;
    func(0,n,0);
    ans.push_back(res);
    cin >> n; cin >> s;
  }
  for(vector<int>::iterator it=ans.begin(),it_e=ans.end();
      it!=it_e;++it)
    cout << *it << endl;
}
  
void func(int start,int num,int current){
  int temp=0;
  for(int i=start; i<10; i++){
    if(current+i<=s) temp = current+i;
    else break;
    if(num!=1) func(i+1,num-1,temp);
    else if(temp==s) {
      res++;
    }
    temp=0;
  }
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <utility>
#include <queue>
#include <stdio.h>
#include <string>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000007
using namespace std;
typedef long long int ll;

vector<int> used(10,0);
int n, s, ans;

void solve(int m, int sum){
    if (m==0) {
        if (sum == s) {
            ans++;
        }
        //cout << "|"<<ans<<"|"<<endl;
        return;
    }
    for (int i=0; i<10; i++) {
        if (used[i]==0) {
            //cout << i <<" "<<m<< endl;
            used[i]=1;
            solve(m-1, sum+i);
            used[i]=0;
        }
    }
}


int main(){
    while (1) {
        cin >> n >> s;
        if(n==0 and s == 0) break;
        ans = 0;
        solve(n, 0);
        cout << ans/6 <<endl;
    }
}

C++: #include <iostream>
#include <vector>
#include <stdio.h>
#include <string.h>

using namespace std;

int N, S, ans, dp[50][50][50];

void rec(int base, int x, int used) {
    if(x > S || used > N || dp[base][x][used] == 1) return;
    if(x == S && used == N) {
        if(!dp[base][x][used]) {
            dp[base][x][used] = 1;
            ans += 1;
        }
        return;
    }
    dp[base][x][used] = 1;
    for(int i = base; i <= 9 && x + i <= S; i++) {
        rec(i + 1, x + i, used + 1);
        rec(i + 1, x, used);
    }
}

int main(void) {
    while(1) {
        scanf("%d%d", &N, &S);
        if(N == 0 && S == 0) break;
        ans = 0;
        memset(dp, 0, sizeof(dp));
        for(int i = 0; i <= S; i++) {
            rec(i + 1, i, 1);
        }
        printf("%d\n", ans);
    }
    return 0;
}

C++: 



#include <iostream>
#include <cstdio>
#include <map>

using namespace std;

#define PI	pair<int , int>
#define MP	make_pair



PI input;
int ans;


void Dfs(int n , int now , int index)
{
	if (n > input.first || now > input.second)	{	return ;}

	if (n == input.first)
	{
		if (input.second == now)
		{
			ans++;
		}
		return;
	}

	for (int i = index + 1; i < 10; i++)
	{
		Dfs(n + 1 , now + i , i);
	}
}


int main(void)
{
	while (1)
	{
		ans = 0;
		cin >> input.first >> input.second;

		if (input.first == 0 && input.second == 0)
		{
			break;
		}

		for (int i = 0; i < 10; i++)
		{
			Dfs(1 , i , i);
		}

		cout << ans << endl;
	}

	return 0;
}

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

inline int ans(int n, int m, int x)
{
	int a = 0;
	if (n == 0 && m == 0) return 1;
	if (n > 0) for (int i = x; i < 10; i++) if (m - i >= 0) a += ans(n - 1, m - i, i + 1);
	return a;
}

int main(void)
{
	int  n, s, num[] = {1,2,3,4,5,6,7,8,9};
	while (cin >> n >> s)
	{
		if (n == 0 && s == 0) break;
		cout << ans(n, s, 0) << endl;
	}
	return 0;
}

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

int n, s, res = 0;

void dfs(int sum,int now, int cnt) {
	if (now == 10) {
		if (sum == s&&cnt == n) {
			res++;
		}
		return;
	}
	dfs(sum, now + 1, cnt);
	dfs(sum + now, now + 1, cnt + 1);
	return;
}

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

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

int dfs(int n, int sum, int before) {
    int ret = 0;
    if(n < 0 || before > 9) return(0);
    else if(n == 0) {
        if(sum == key) return(1);
        else           return(0);
    } else if(sum >= key) return(0);
    for(int r = before; r <= 9; r++) {
        ret += dfs(n - 1, sum + r, r + 1);
    }
    return(ret);
}

int main(void) {
    int n;
    while(cin >> n >> key, n + key != 0) {
        cout << dfs(n, 0, 0) << endl;
    }
    return(0);
}

C++: #include<cstdio>
using namespace std;
int saiki(int n,int m,int cnt);
int main(){
    int n,m;
    while(1){
        scanf("%d%d",&n,&m);
        if(n == 0 && m == 0)break;
        int ans = 0;
        int cnt = 0;
        ans = saiki(n,m,cnt);
        printf("%d\n",ans);
    }
    return 0;
}
int saiki(int n,int m,int cnt){
    if(n == 0&&m == 0)return 1;
    if(cnt >= 10)return 0;
    return saiki(n-1,m-cnt,cnt+1)+saiki(n,m,cnt+1);
}

C++: #include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>

using namespace std;

int solve(int n, int s, int d = 0, int ss = 0, int bn = 0){
	if(ss == s && n == d){
		return 1;
	}
	if(n == d || ss > s){
		return 0;
	}
	int count = 0;


	for(int i = bn; i <= 9; i++){
		count += solve(n, s, d+1, ss+i, i+1);
	}

	return count;
}

int main(){
	int n, s;

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

	return 0;
}

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

int func(int num, int rest, int before){
	//if(before + 1 < 0) return 0;
	if(num == 0){
		if(rest == 0){
			//cout << before << endl;
			return 1;
		}
		return 0;
	}
	int res = 0;
	for(int i = 0; i <= rest && i <= before; ++i){
		res += func(num - 1, rest - i, i - 1);
	}
	return res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, s;
	while(cin >> n >> s && (n != 0 || s != 0) ){
		cout << func(n, s, 9) << 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, 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 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 || num == n)
	{
		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++: //Sum of Integers
#include<bits/stdc++.h>
using namespace std;

int depth, s, n;

void solve(int d, int x, int sum){
  if(d==0 && sum==s){n++; return;}
  for(int i=x+1; i<10; i++){
    solve(d-1, i, sum+i);
  }
}

int main(){

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