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;

// dp[n][s] := n個の数字を使って合計がsのときの組合せ数
int dp[10][110] = {0};

int main(){
	dp[0][0] = 1;
	for(int i = 0; i < 10; i++){
		for(int j = 100; j >= 0; j--){
			for(int k = 9; k >= 1; k--){
				if( j - i >= 0 ){
					dp[k][j] += dp[k - 1][j - i];
				}
			}
		}
	}
	
	int n, s;
	while( cin >> n >> s , n || s ){
		cout << dp[n][s] << endl;
	}
}

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

using namespace std;

const int INF = 1e+9;

int n, a[21], ans;

void dfs(int diff, int k)
{
    if (k == n)
    {
        ans = min(ans, abs(diff));
    }
    else
    {
        dfs(diff + a[k], k + 1);
        dfs(diff - a[k], k + 1);
    }
}

int main()
{
    while (cin >> n, n)
    {
        for (int i = 0; i < n; i++)
        {
            cin >> a[i];
        }

        ans = INF;

        dfs(0, 0);

        cout << ans << endl;
    }
}

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

int n,s;

int dfs(int n,int s,int k){
    if(n==0){
        return (s==0)?1:0;
    }
    int res=0;
    for(int i=k;i<10;i++){
        res+=dfs(n-1,s-i,i+1);
    }
    return res;
}

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

C++: #include <iostream>
using namespace std;
int n,s,c;
void f(int m,int a,int t){
	if(a == n - 1){
		if(t == s) ++c;
		return;
	}
	for(int i = m + 1;i < 10;++i){
		f(i,a + 1,t + i);
	}
}
int main(){
	while(cin >> n >> s && (n != 0 && s != 0)){
		c = 0;
		for(int i = 0;i < 10;++i)f(i,0,i);
		cout << c << endl;
	}
	return 0;
}

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

int n,s,ans ;

void cal( int i , int sum , int N ){
	if( sum==s && N==0 ){
		ans++;
		return;
	}
	if( i==10 || N==0 ) return;
	
	cal( i+1 , sum , N ) ;
	cal( i+1 , sum+i , N-1 ) ;
}

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

C++: #include<iostream>
#include<iomanip>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<algorithm>
#include<cmath>
#include<memory>
#include<array>

using namespace std;

int n, s;

int count( int x, int d, int z )
{
  int ret = 0;
  
  if ( z < 0 )
    return 0;

  if ( x == n )
    if ( d == z )
      return 1;
    else
      return 0;

  for ( int i = d + 1; i <= 9; ++i )
    ret += count( x + 1, i, z - d );

  return ret;
}

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

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

using namespace std;

int n, s;

int dfs(int now, int sum, int i)
{
	if (sum > s) return 0;

	if (now == n) {
		if (sum == s) return 1;
		return 0;
	}

	int res = 0;

	for (int j = 0; j < 10; ++j) if (i < j) res += dfs(now + 1, sum + j, j);

	return res;
}

int main()
{
	while (cin >> n >> s, n || s) cout << dfs(0, 0, -1) << endl;
}

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

int num_count, sum;

void dfs(int i, int s, int n) {
  if (s == sum && n == 0) {
    num_count++;
    return;
  }

  if (i == 10 || n == 0) {
    return;
  }

  dfs(i + 1, s + i, n - 1);
  dfs(i + 1, s, n);
}


int main(void) {
  int i, n;

  while (true) {
    cin >> n >> sum;
    if (n == 0 && sum == 0) break;

    num_count = 0;
    dfs(0, 0, n);
    cout << num_count << endl;
  }

  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
 
int N,S;
int dfs(int n,int t,int sum){
    if(n==10)return 0;
    if(t==N){
          if(sum==S)return 1;
          else return 0;
    }
    return dfs(n+1,t,r)+dfs(n+1,t+1,r+p);
}
int main(){
    while(cin>>N>>S,n||s)cout<<dfs(0,0,0)<<endl;
    return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
    int const ns[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
    int ss[11][46] = {};
    for( int i=0; i<1024; ++i ) {
        int sum = 0, n = 0;
        for( int j=0; j<10; ++j ) {
            if ( i & 1 << j ) {
                sum += ns[j];
                ++n;
            }
        }
        ++ss[n][sum];
    }

    int n, s;
    while( cin >> n >> s, n||s ) {
        cout << ( ( n >= 0 && n <= 10 && s >= 0 && s <= 45 ) ? ss[n][s] : 0 ) << endl;
    }
}

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n, s;
  while (cin >> n >> s, n) {
    int c = 0;
    rep(i, 1024) if (bitset<64>(i).count() == n) {
      int t = 0;
      rep(j, 9) if (i >> j & 1) t += j + 1;
      c += t == s;
    }
    cout << c << endl;
  }
}

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

int solver(int cnt, int s, int d){
    if(d == 0) return (s==0)?1:0;
    int sum = 0;
    for(int i=cnt+1; i<=9; ++i){
        sum += solver(i, s-i, d-1);
    }
    return sum;
}

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

C++: #include <iostream>

using namespace std;

int sum(const int* a,const int n){
	int sum=0;
	for(int i=0;i<n;i++) sum+=a[i];
	return (sum);
}

int main(){
	while(1){
	int n,s,count;
	cin >> n >> s ;
	count=0;
	if(n==0 && s==0) break;		//終了条件
	int* a=new int[n];
	for(int j=0;j<n;j++) a[j]=j; //初期化
	
	for(int k=n;k>0;k--){	
		if(a[k-1]<=a[k]-2) a[k-1]++;
		a[n-1]=a[n-2]+1;
		while(1){
			 if(a[n-1]>9) break;
			if(sum(a,n) ==s) count++;
			a[n-1]++;
			};
	
	};
	cout << count << '\n' ;
	delete[] a;
	}; //whileの終わり

}

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

using namespace std;

int n, s, cont, cost;

void dps(int sum, int i, int cost);

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

    return 0;
}

void dps(int sum, int i, int cost)
{
	if(cost == n && sum == s) {
		cont++;
		//cout << cont << ":" << i << endl;
	}

	else if(cost < n && i < 9) {
		dps(sum+i, i+1, cost+1);
		dps(sum, i+1, cost);
	}
}