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 syu(int *p,int n){
  int s=0;
  for(int i=0;i<n;i++) s += p[i];
  return s;
}
int main(){
  int n,s;
  while(cin>>n>>s){
    if(n==0&&s==0) break;
    int p[n],count=0;
    for(int a=0;a<=9;a++){
      p[0] = a;
      if(n==1&&syu(p,n)==s){
	count++;
	continue;
      }
      for(int b=a+1;b<=9;b++){
	p[1] = b;
	if(n==2&&syu(p,n)==s){
	  count++;
	  continue;
	}
	for(int c=b+1;c<=9;c++){
	  p[2] = c;
	  if(n==3&&syu(p,n)==s){
	    count++;
	    continue;
	  }
	  for(int d=c+1;d<=9;d++){
	    p[3] = d;
	    if(n==4&&syu(p,n)==s){
	      count++;
	      continue;
	    }
	    for(int e=d+1;e<=9;e++){
	      p[4] = e;
	      if(n==5&&syu(p,n)==s){
		count++;
		continue;
	      }
	      for(int f=e+1;f<=9;f++){
		p[5] = f;
		if(n==6&&syu(p,n)==s){
		  count++;
		  continue;
		}
		for(int g=f+1;g<=9;g++){
		  p[6] = g;
		  if(n==7&&syu(p,n)==s){
		    count++;
		    continue;
		  }
		  for(int h=g+1;h<=9;h++){
		    p[7] = h;
		    if(n==8&&syu(p,n)==s){
		      count++;
		      continue;
		    }      
		    for(int i=h+1;i<=9;i++){
		      p[8] = i;
		      if(n==9&&syu(p,n)==s){
			count++;
			continue;
		      }
		    }
		  }
		}
	      }
	    }
	  }
	}
      }
    }
    cout << count << endl;
  }
  return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int used[10];
int rec(int n, int s, int x) {
  if (n==0) {
    if (s==0)
      return 1;
    else
      return 0;
  }
  int ret = 0;
  for(int i=x;i<10;i++) {
    if (used[i] == 0 && s-i>=0) {
      used[i] = 1;
      ret += rec(n-1, s-i, i+1);
      used[i] = 0;
    }
  }
  return ret;
}

int main() {
  int n, s;
  while(cin>>n>>s,n+s) {
    if (s>24||n>10) {
      cout << 0 << endl;
      continue;
    }
    memset(used,0,sizeof(used));
    cout << rec(n,s,0) << endl;
  }
}

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()
{
	Puzzle puz;
	printf("%d\n",3);

	puz.play();

    return 0;
}

C++: #include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <cctype>
#include <iostream>
#include <set>
#include <string>
#include <queue>
using namespace std;
string::size_type size(string x){
	string::size_type size=x.size();
	return size;
}
#define fu(i,l,k) for(int i=l;i<k;i++)
#define fd(i,l,k) for(int i=l;i>k;i--)
#define fi first
#define se second
double pi(){
	return M_PI;
}
typedef set<int> set_i;
typedef set<string> set_s;
int ans=0,sum=0,s;
void calc(int n,int sum,int s){
	if(n==0){
		if(sum==s)ans++;
	}
	else{
		for(int i=0;i<10;i++){
			if(n!=0) calc(n-1,sum+=i,s);
		}
	}
}
int main(){
	int e=0,n[53]={},s[53]={};
	while(1){
		cin>>n[e]>>s[e];
		if(n[e]==0&&s[e]==0) break;
		e++;
	}
	for(int q=0;q<e;q++){
		sum=0;
		if(n[q]-1>s[q]||s[q]>45) cout<<"0"<<endl;
		else{
			calc(n[q],sum,s[q]);
			cout<<ans/2<<endl;
			ans=0;
		}
	}
}

C++: #include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
void func(int,int);
int s,n,sum,cnt;
int main(void)
{
	int i,j;
	while(1)	{
		scanf("%d %d",&n,&s);
		if(n==0 && s==0)	break;
		sum=0;	cnt=0;
		func(0,0);
		printf("%d\n",cnt);
	}
	return 0;
}
void func(int nn,int x)
{
	int i;
	if(n==nn)	{
		if(sum==s)	cnt++;
	}
	else {
		for(i=x;i<=9;i++)	{
			sum+=i;
			func(nn+1,i+1);
			sum-=i;
		}
	}
}

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

int dfs(int pos, int sum, int before) {
    int ret = 0;
    //深さが範囲外か、選択しきっていないのに答え以上か、繰り返し初期値が９を超えているなら
    if((pos > n || (pos < n && sum >= ans)) || before > 9) return(0);
    if(pos == n) {
        if(sum == ans) return(1);
        else           return(0);
    }
    for(int r = before; r <= 9; r++) {
        ret += dfs(pos + 1, sum + r, r + 1);
    }
    return(ret);
}

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

C++: #include<iostream>

using namespace std;
int n, s, ans;

void solve(int cnt, int num, int sum){
    if(n==cnt&&s==sum){
        ans++;
        return;
    }else if(cnt>n||num>9){
        return;
    }

    solve(cnt+1, num+1, sum+num);
    solve(cnt, num+1, sum);
}

int main(){

    while(1){
        cin>> n>> s;
        if(n==0&&s==0) break;

        ans=0;
        solve(0, 0, 0);

        cout<< ans<< endl;
    }
    return 0;
}

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

int dp[11][101];

int main(){
  int n,m;
  for(int i=0;i<11;i++)for(int j=0;j<101;j++)dp[i][j]=0;

  for(int i=0;i<=9;i++)dp[1][i]=1;

  for(int i=2;i<=10;i++){
    for(int j=1;j<=100;j++){
      if(j-i>=0)dp[i][j]+=dp[i][j-i];
      if(j-(i-1)>=0)dp[i][j]+=dp[i-1][j-(i-1)];
      if(j>9)dp[i][j]-=dp[i-1][j-10];
 
    }

  }
  /*
  for(int i=0;i<=10;i++){
    for(int j=0;j<=50;j++){
      printf("%2d ",dp[i][j]);
    }
    cout<<endl;
  }
  */
  while(cin>>n>>m&&n&&m){
    cout<<dp[n][m]<<endl;
  }
  return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
int n,s;
int solve(int se,int no,int sum){
  if(se>=10) return 0;
  if(sum>s && se>0) return 0;
  if(no>=n){
    if(sum==s) return 1;
    else return 0;
  } 
  return solve(se+1,no,sum)+solve(se+1,no+1,sum+se);
}
main(){
  while(1){
    int res;
    scanf("%d %d",&n,&s);
    if(n==0 && s==0) break;
    res=solve(0,0,0);
    printf("%d\n",res);
  }
}

C++: #define _USE_MATH_DEFINES
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<deque>
#include<list>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<map>
#include<queue>
#include<vector>
using namespace std;


int a(int n, int s, int f) {
	int cnt = 0;
	if (n > 2)
		for (int i = f; i <= 9; i++) {
			if (s - i > i)cnt+=a(n-1,s-i,i+1);
			else break;
		}
	else if (n == 2)
		for (int i = f; i <= 9; i++) {
			if (s - i <= 9 && s - i > i)cnt++;
			else break;
		}

	return cnt;
}

int main() {
	for (int n, s; cin >> n >> s && (n || s);)
		cout << a(n, s, 0) << endl;

	return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

int main() {
	int n, s;
	while (cin >> n >> s, n) {
		int cnt = 0;
		for (int i = (1 << n) - 1; i < 1 << 10; i++) {
			int use = 0, sum = 0;
			for (int j = 0; i >> j; j++) {
				if ((i >> j) & 1) { use++; sum += j; }
			}
			if (use == n&&sum == s)cnt++;
		}
		printf("%d\n", cnt);
	}
	return 0;
}