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 <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))),(c).end())
# define LOWER(s)    transform(ALL((s)),(s).begin(),TL<char>)
# define UPPER(s)    transform(ALL((s)),(s).begin(),TU<char>)
# define mp          make_pair
# define eb          emplace_back
# define FOR(i,a,b)  for(LL i=(a);i<(b);i++)
# define RFOR(i,a,b) for(LL i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)


int N, S;
int ans = 0;

void dfs(int s, int i, int cnt) {
	if (cnt == N&& s == S) {
		ans++;
		return;
	}
	else if (cnt == N || s >= S||i==10){
		return;
	}
	else {
		dfs(s + i, i + 1, cnt + 1);
		dfs(s, i + 1, cnt);
	}
}

int main() {
	while (cin >> N >> S && (N != 0 || S != 0)) {
		ans = 0;
		dfs(0, 0, 0);
		cout << ans << endl;
	}
}

C++: #include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
using namespace std;

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


int n,s;
int ans=0;


int solve(int c,int d,int s){
	if(c==n){
		if(s<=9&&s>=d){
			ans++;
		}
	}
	else{
		for(int i=d;i<10;i++){
			solve(c+1,i+1,s-i);
		}
	}
	return ans;
}
	
	

int main(){
	while(cin>>n>>s,n||s){
		if(s>45) cout<<0<<endl;
		ans = 0;
		cout << solve(1,0,s) <<endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
 
typedef long long ll;
typedef pair<int, int> ii;

#define EPS 1e-8

int main(){
	
	int n, s;
	
	while(cin >> n >> s, n){
		int ans = 0;
		rep(i, 1<<10){
			int tmp = i;
			int j = 0;
			int cnt = 0;
			int sum = 0;
			while(tmp != 0){
				
				if(tmp % 2 != 0){
					sum += j;
					cnt++;
				}
				tmp = tmp >> 1;
				j++;
			}
			if(cnt != n) continue;
			if(sum == s) ans++;
		}
		cout << ans << endl;
	}

	
	return 0;
}

C++: #include <iostream>
#include <bitset>

using namespace std;

int main() {
    int a[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
    int n, s, sum, cnt;

    while (cin >> n >> s) {
        if (!n && !s) { break; }
        cnt = 0;
        for (int i = 0; i < (1 << 10); i++) {
            sum = 0;
            for (int j = 0; j < 10; j++) {
                // if (bitset<10>(i).test(j)) {
                if (i >> j) & 1) {
                    sum += a[j];
                }
            }
            if (sum == s && bitset<10>(i).count() == n) { cnt++; }
        }
        cout << cnt << endl;
    }
    return 0;
}

C++: #include<cstdio>
#include<algorithm>

using namespace std;
int main(void)
{
	int n,sum,log;
	int a[5001] = {0};
	while(scanf("%d",&n))
	{
		sum = 0;
		if(n == 0) break;
		for(int i = 0;i < n;i++) scanf("%d",&a[i]);
		
		for(int i = 0;i < n;i++)
		{
			log = 0;
			for(int j = i;j < n;j++)
			{
				log += a[j];
				if(sum <= log)
				{
					log = sum;
				}
			}
		}
		printf("%d\n",sum);
	}
	return 0;
}

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;
		}
	else
		cnt = 1;

	return cnt;
}

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

	return 0;
}

C++: #include <stdio.h>

int main(void)
{
	int n;
	int s;
	int i, j, k;
	int dp[16][64];	
	for (i = 0; i < 16; i++){
		for (j = 0; j < 64; j++){
			dp[i][j] = 0;
		}
	}
	
	dp[0][0] = 1;
	for (i = 0; i <= 9; i++){
		for (j = 9; j >= 0; j--){
			for (k = 0; k < 64; k++){
				if (dp[j][k] != 0){
					dp[j + 1][k + i] += dp[j][k];
				}
			}
		}
	}
	
	while (scanf("%d %d", &n, &s), n != 0 &&s != 0){
		if (s < 64){
			printf("%d\n", dp[n][s]);
		}
		else {
			printf("0\n");
		}
	}
	
	return (0);
}

C++: #include<iostream>

using namespace std;

int n,s,ans;

void dfs(int now,int sum,int times){
	if(n < times)
		return;
	if(n == times && s == sum){
		ans++;
		return;
	}
	for(int i = now + 1;i < 9;i++)
		dfs(i,sum + i,times + 1);
}

int main(){
	while(cin >> n >> s,n+s != 0){
		ans = 0;
		for(int i = 0;i <= 9;i++){
			dfs(i,i,1);
		}
		cout << ans << endl;
	}
	return 0;
}