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

int main()
{
    int Atop=0, Btop=0, n, ball;
    cin >> n;
    while (n-->0) {
        bool fine = true;
        for (int i = 0; i < 10; ++i) {
            cin >> ball;
            if (ball > max(Atop, Btop)) {
                if (Atop > Btop) Atop = ball;
                else Btop = ball;
            } else if (Atop < ball) {
                Atop = ball;
            } else if (Btop < ball) {
                Btop = ball;
            } else {
                fine = false;
                break;
            }
        }
        cout << (const char *)(fine ? "YES" : "NO") << endl;
    }
}

C++: #include <cmath>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <cstdio>
#include <cctype>
#include <queue>
#include <complex>
#include <climits>
#include <cstring>

using namespace std;

const int INF = 1 << 29;
typedef long long ll;
typedef pair<int,int> PI;

int n, s, t, res;

void dfs(int n, int t, int sum){
	if(n == 0 && sum == s) {
		res++;
		return ;
	}
	if(sum > s || n <= 0) return ;
	for(int i=t+1; i<=s; ++i){
		dfs(n-1, i, sum+i-1);
	}
}

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

	return 0;
}

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

int dp[11][46] = {0};

int main()
{
	dp[0][0]=1;
	for(int k=0; k<10; k++)
	{
		for(int i=k; i>=0; i--)
		for(int j=0; j<46-k; j++)
		{
			dp[i+1][j+k] += dp[i][j];
		}
	}

	int N,S;
	while(cin>>N>>S, N||S)
	{
		cout << dp[N][S] << endl;
	}
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;

int go(int p, int n, int s) {
	if (n == 0 && s == 0) return 1;
	if (s <= 0) return 0;
	int res = 0;
	REP (i, p + 1, 9) res += go(i, n - 1, s - i);
	return res;
}

int main() {
	for (int n, s; cin >> n >> s, (n | s) != 0; ) {
		cout << go(-1, n, s) << endl;
	}
	
	return 0;
}

C++: #include <iostream>
#include <string.h>
using namespace std;
int n,s;
int tmp[11];
int cnt;
void rec(int m)
{
	for(int i=tmp[m-1]+1;i<=9;i++)
	{
		tmp[m]=i;
		if(m<n) rec(m+1);
		if(m!=n) continue;
		int sum=0;
		for(int j=1;j<=n;j++) sum+=tmp[j];
		if(sum==s) cnt++;
	}
}
int main()
{
	while(1)
	{
		cin >> n >> s ; if(!n && !s) break;
		memset(tmp,0,sizeof(tmp));
		tmp[0]=-1; cnt=0;
		rec(1);
		cout << cnt << '\n' ;
	}
}

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

int main()
{
  int n, s;
  int i, ,j, tmp;
  int sum, count;
  int ans;

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

    ans=0;
    for(i=0; i<1024; i++){
      tmp=i; sum=0; count=0;
      for(j=0; j<10; j++){
        if(tmp%2==1){
          sum+=j;
          count++;
        }
        tmp/=2;
      }
      if(count==n && sum==s) ans++;
    }
    printf("%d\n", ans);
  }

  return 0;
}

C++: #include<iostream>
using namespace std;
int count;
void ans(int a,int b,int c,int n,int s){
  if(b==s&&c==n) count++;
  if(b>s||c==n) goto END;
  for(int i=a+1;i<=9;i++) ans(i,b+i,c+1,n,s);
 END:;
}
int main(){
  int n,s;
  while(cin>>n>>s){
    if(n==0&&s==0) break;
    count = 0;
    for(int i=0;i<=9;i++) ans(i,i,1,n,s);
    cout << count << endl;
  }
  return 0;
}

C++: #include<bits/stdc++.h>

using namespace std;

int s, n, cnt = 0;

void solve(int x, int y, int sum){
	if(y == n){
		if(sum == s){
			++cnt;
		}
		return ;
	}
	if(x > 9) return ;
	solve(x + 1, y + 1, sum + x);
	solve(x + 1, y, sum);
	return ;
}

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

C++: #include<iostream>

using namespace std;

int n,s;
int solve(int now,int sum,int num){
	if(num>n)return 0;
	int ans=0;
	
	for(int i=now+1;i<10;i++){	
		if(sum+i<s)ans+=solve(i,sum+i,num+1);
		else if(sum+i==s && num+1==n)return 1;
	}
	return ans;
}

int main(){
	while(cin>>n>>s && n+s){
		cout<<solve(-1,0,0)<<endl;
	}
}

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

int n ;
int s ;
int ans ;
int sum ;
bool vis[12] ;

void init ( ) ;
void DFS ( int source , int k ) ;

int main ( )
{
	while ( scanf ( "%d %d" , &n , &s ) == 2 && ( n && s ) ) {
		init ( ) ;
		DFS ( 0 , 0 ) ;
		printf ( "%d\n" , ans ) ;
	}
	return 0 ;
}

void init ( )
{
	memset ( vis , false , sizeof ( vis ) ) ;
	ans = 0 ;
	sum = 0 ;
}

void DFS ( int source , int k )
{
	if ( source == n ) {
		if ( sum == s ) {
			ans++ ;
		}
		return ;
	}
	for ( int i = k ; i <= 9 ; i++ ) {
		if ( vis[i] == false ) {
			vis[i] = true ;
			sum += i ;
			DFS ( source + 1 , i ) ;
			vis[i] = false ;
			sum -= i ;
		}
	}
}

C++: #include <stdio.h>

int sum[10][46]={0};
int main() {
	for(int i=0; i<1<<10; i++) {
		int sumi = 0, count = 0;
		for(int j=0; j<10; j++) {
			if(i & (1<<j)) {
				sumi += j;
				count++;
			} 
		}
		sum[count][sumi]++;
	}

	int n = -1, s = -1;
	if(freopen("D:\\test.txt", "r", stdin) == NULL) return -1;
	while(scanf("%d%d", &n, &s) !=EOF) {
		if(n == 0 && s == 0) break;
		printf("%d\n", sum[n][s]);
	}
	return 0;
}

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

int main(){
	int a, b, c, n, s, cnt;
	while(true){
		cnt = 0;
		cin>>n>>s;
		if(n==0&&s==0)
			break;
		for(a=0;a<10;a++){
			for(b=0;b<10;b++){
				for(c=0;c<10;c++){
					if(a+b+c == s){
						if(a!=b && b!=c && a!=c){
							cnt++;
						}
					}
				}
			}
		}
		cnt /= 6;
		cout << cnt << endl;
	}
	return 0;
}

C++: #include <cstdio>

using namespace std;

int count(int n, int s, int begin) {
  if (n == 1) { return begin <= s && s <= 9 ? 1 : 0; }
  if (9 - begin < n) { return 0; }
  if (n * (begin + n - 1) / 2 > s) { return 0; }
  int acc = 0;
  for (int i = begin; i < s; ++i) {
    acc += count(n - 1, s - i, i + 1);
  }
  return acc;
}

int main() {
  while (true) {
    int n, s;
    scanf("%d %d", &n, &s);
    if (n == 0 && s == 0) { break; }
    printf("%d\n", count(n, s, 0));
  }

  return 0;
}