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 <bits/stdc++.h>

using namespace std;

#define TEMP_T template<typename T>
TEMP_T void sort(T& v){ sort(v.begin(), v.end()); }
TEMP_T void revs(T& v){ reverse(v.begin(), v.end()); }
TEMP_T void uniq(T& v){ sort(v); v.erase(unique(v.begin(), v.end())); }
TEMP_T void show(T& v, char delim=' ', char end='\n'){ for(int i=0; i<v.size()-1; i++) cout << v[i] << delim; cout << v[v.size()-1] << end; }
TEMP_T T    cums(T& v){ T r; r.push_back(v[0]); for(int i=1; i<v.size(); i++) r.push_back(r[i-1] + v[i]); return r; }
TEMP_T void maxe(T& v, T m){ v = max(v, m); }
TEMP_T void mine(T& v, T m){ v = min(v, m); }

static inline int in(){ int x; scanf("%d", &x); return x; }

struct Solver {
  int pattern[64];
  int n;
  Solver(int n) : n(n) {
    memset(pattern, 0, sizeof(pattern));
  }
  void solve(int it=0, int c=0, int s=0){
    if (c == n){
      pattern[s]++;
      return;
    }
    for (int i = it; i <= 9; i++){
      solve(i + 1, c + 1, s + i);
    }
  }
};

int main()
{
  int n, s;
  while (n = in(), s = in(), n != 0 && s != 0){
    Solver solver(n);
    solver.solve();
    if (s < 64){
      printf("%d\n", solver.pattern[s]);
    }
    else puts("0");
  }

  return 0;
}

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

using namespace std;

int N, S, ans, dp[15][1<<15][15];

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<vector>
#include<string>
#include<cstdio>
using namespace std;
int ans;
int n;
int s;

void count_ans(int k,int C,int j){
    if(k==n){
        if(C==s){
            ans++;
        }
    }else{
        for(int i=j+1;i<10;i++){
            count_ans(k+1,C+i,i);
        }
    }

}


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

C++: #include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;

const int MAX_D = 10;
const int MAX_N = 10;
const int MAX_S = 100;
int memo[MAX_D + 1][MAX_N + 1][MAX_S + 1];

int sum_of_integers(int d, int n, int s)
{
	if (memo[d + 1][n][s] != -1) return memo[d + 1][n][s];
	if (n == 0) return s == 0;
	if (s < 0) return 0;
	int res = 0;
	for (int i = d + 1; i <= 9; i++) res += sum_of_integers(i, n - 1, s - i);
	return memo[d + 1][n][s] = res;
}

int main(){
	memset(memo, -1, sizeof(memo));
	int n, s;
	while (cin >> n >> s, n || s){
		cout << sum_of_integers(-1, n, s) << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

#define int				long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )	for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )	FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP				make_pair
#define X				first.first
#define Y				first.second

typedef pair<int, int> P;

template<class T>bool chmax( T& a, const T& b ) { if( a < b ) { a = b; return 1; } return 0; }
template<class T>bool chmin( T& a, const T& b ) { if( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9 + 7;

int ans;

void dfs( int n, int s, int i ) {
	if( i > 9 ) {
		if( n == 0 && s == 0 ) ans++;
		return;
	}

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

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

C++: #include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
using namespace std;

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

int sum[1024];

inline unsigned next_set(unsigned x)
{
  unsigned smallest = x & -x;
  unsigned ripple = x + smallest;
  unsigned new_smallest = ripple & -ripple;
  unsigned ones = ((new_smallest / smallest) >> 1) - 1;
  return ripple | ones;
}

int main()
{
  memset(sum, 0, sizeof(sum));
  REP(i, 1024)
    REP(j, 10)
      if (i & (1 << j))
        sum[i] += j;

  int n, s;
  while (scanf("%d%d", &n, &s), n|s) {
    int count = 0;
    for (int S = (1<<n)-1; S < 1<<10; S = next_set(S))
      if (sum[S] == s)
        ++count;
    printf("%d\n", count);
  }
}

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

int t;
int n[10];

void sousa(int a, int b){
	for(n[a-1] = n[a]; n[a-1] >= 0; n[a-1]--){
		if(a-1 < 0 || b < 0){
			cout << "out" << endl;
			break;
		}
		else if(a-1 == 0 && b-n[a-1] == 0){
			cout << "ok" << endl;
			t++;
			break;
		}
		else{
			cout << "lasting" << endl;
			sousa(a-1, b-n[a-1]);
		}
	}
}
int main(){
	vector<int> array;
	int n, m;
	while(cin >> n >> m){
		n[a] = 9;
		if(n == 0 && m == 0){
			break;
		}
		if(m > 45){
			array.push_back(0);
			continue;
		}
		t = 0;
		sousa(n, m);
		array.push_back(t);
	}
	for(int i = 0; i < array.size(); i++){
		cout << array[i]/2 << endl;
	}
}

C++: #include <iostream>
using namespace std;
int main(){
	int n,s,ans;
	while(cin>>n>>s!=0&&n!=0){
		ans=s-n;
		if(ans<0)ans=0;
		cout<<ans<<endl;
	}
	return 0;
}

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

using namespace std;

int vis[10], ans, cs;

void dfs(int vis[], int i, int cs, int s) {
	if (i > 9) return ;
	if (cs == 3) {
		int sum = 0;
		for (int i=0; i<10; ++i) {
			if (vis[i]) sum += i;
		}
		if (sum == s) ++ans;
		cs = 0;
	}
	else {
		vis[i] = 0;
		dfs(vis, i+1, cs, s);
		vis[i] = 1;
		dfs(vis, i+1, cs+1, s);
		vis[i] = 0;
	}
}

int main() {
	int n, s;
	while (scanf("%d%d", &n, &s), n + s) {
		cs = ans = 0;
		for (int i=0; i<10; ++i) vis[i] = 0;
		dfs(vis, 0, cs, s);
		printf ("%d\n", ans);
	}
	return 0;
}

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

using namespace std;
const int N = 12;
int n, s;
int ans = 0;

void bt(int sum, int index, int pos) {
	if(sum == 0 && pos == n) {
		ans++;
		return;
	}
    if(pos == n) return;
	
	if(sum < 0) return;
	
	for(int i = index; i <= s; i++) {
		bt(sum - i, i + 1, pos + 1);
	}
}



int main() {
	//freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout);
	while(true) {
	    cin >> n >> s;
	    if(!n && !s) return 0;
	    bt(s, 0, 0);
	    cout << ans << "\n";
	    ans = 0;
	}
    return 0;
}