Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
	)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		buf := strings.Split(scanner.Text(), " ")
		X, _ := strconv.Atoi(buf[0])
		Y, _ := strconv.Atoi(buf[1])
		if X == 0 && Y == 0 {
			break
		}
		tbl := make([][]int, Y+2)
		field := make([][]int, Y+2)
		for i := range field {
			field[i] = make([]int, X+2)
			tbl[i] = make([]int, X+2)
			for j := range field[i] {
				field[i][j] = 2
				tbl[i][j] = 0
			}
		}
		buf_ := make([][]string, Y)
		for i := range buf_ {
			scanner.Scan()
			buf_[i] = strings.Split(scanner.Text(), " ")
		}
		for i := 1; i <= Y; i++ {
			for j := 1; j <= X; j++ {
				field[i][j], _ = strconv.Atoi(buf_[i-1][j-1])
				switch field[i][j] {
				case 0:
					if i == 1 {
						tbl[i][j] = 1 // スタートy=1
					} else {
						if field[i-1][j-1] != 2 {
							tbl[i][j] += tbl[i-1][j-1] // 左上からやってくる
						}
						if field[i-1][j] != 2 {
							tbl[i][j] += tbl[i-1][j] // 真上からやってくる
						}
						if field[i-1][j+1] != 2 {
							tbl[i][j] += tbl[i-1][j+1] // 右上からやってくる
						}
						if field[i-2][j] == 2 {
							tbl[i][j] += tbl[i-2][j] // ジャンプしてくる
						}
					}
				case 1:
					tbl[i][j] = 0 // 障害物あり
				case 2:
					if field[i-1][j] != 2 {
						tbl[i][j] += tbl[i-1][j] // 真上からくる
					}
					if field[i-2][j] == 2 {
						tbl[i][j] += tbl[i-2][j] // ジャンプ台からジャンプしてくる
					}
				}
			}
		}
		sum := 0
		for i := 1; i <= X; i++ {
			sum += tbl[Y][i] // とびこさないでゴール
			if field[Y-1][i] == 2 {
				sum += tbl[Y-1][i] // 飛び越してゴール
			}
		}
		fmt.Println(sum)
	}
}

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

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;
int vv[20][20];
int table[20][20];
/*
1 1 1 1 1 
1 1 1 1 1 
1 1 3 1 1 
0 3 3 0 1 
4 3 3 1 0 
4 0 0 0 0 
*/
/*
5 5
0 0 0 0 1
2 1 0 2 0
1 0 0 1 1
0 2 1 2 0
0 1 0 0 0
*/
void mainmain(){
	int w,h;
	while(cin>>w>>h,w||h){
		rep(i,20){
			rep(j,20){
				vv[i][j]=0;
			}
		}
		rep(i,20){
			rep(j,20){
				table[i][j]=0;
			}
		}
		reep(i,1,w+1){
			vv[0][i]=1;
		}
		rep(i,h){
			rep(j,w){
				cin>>table[i+1][j+1];
			}
		}
		rep(i,h){
			reep(j,1,w+1){
				if(table[i][j]==2){
					vv[i+2][j]+=vv[i][j];
					continue;
				}
				if(table[i][j]==1) continue;
				vv[i+1][j]+=vv[i][j];
				if(i&&j-1>0&&table[i+1][j-1]==0){
					vv[i+1][j-1]+=vv[i][j];
				}
				if(i&&j+1<=w&&table[i+1][j+1]==0){
					vv[i+1][j+1]+=vv[i][j];
				}
			}
		}
		int ans=0;
		reep(i,h,h+2){
			reep(j,1,w+1){
				ans+=vv[i][j];
			}
		}
		cout<<ans<<endl;
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

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

using namespace std;

#define MAX 16

int main()
{
    int H, W;
    while (cin >> W >> H, W) {
        vector<vector<int>> a(H, vector<int>(W));
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                cin >> a[i][j];
            }
        }
        int dp[MAX][MAX] = {{}};
        for (int i = 0; i < W; i++) {
            dp[0][i] = (a[0][i] == 0);
        }

        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (dp[i][j] == 0 || a[i][j] == 1) continue;
                if (a[i][j] == 2) {
                    int ni = min(i + 2, H - 1);
                    if (i + 2 < H && a[i+2][j] == 1) continue;
                    dp[ni][j] += dp[i][j];
                } else {
                    if (i + 1 == H) continue;
                    for (int k = -1; k <= 1; k++) {
                        int ni = i + 1;
                        int nj = j + k;
                        if (nj < 0 || nj >= W) continue;
                        if (a[ni][nj] == 1) continue;
                        if (a[ni][nj] == 2 && j != nj) continue;
                        dp[ni][nj] += dp[i][j];
                    }
                }
            }
        }
        int res = 0;
        for (int i = 0; i < W; i++) {
            res += dp[H-1][i];
        }
        cout << res << endl;
    }
    return 0;
}

C++: //配るDP
#include<iostream>
#include<algorithm>
using namespace std;

int X,Y;
int c[15][15];
int dp[15][15];
int main(){
	while(cin>>X>>Y,X|Y){
		int ans=0;
		for(int i=0;i<Y;i++)
			for(int j=0;j<X;j++)
				cin>>c[i][j];
		fill_n((int*)dp,15*15,0);
		for(int j=0;j<X;j++){
			if(c[0][j]!=1)dp[0][j]=1;
		}
		for(int i=0;i<Y;i++){
			for(int j=0;j<X;j++){
				if(dp[i][j]==0)continue;
				if(Y-1==i || c[i][j]==2 && Y-2==i){
					ans += dp[i][j];
					continue;
				}
				for(int dx=-1;dx<=1;dx++){
					if(j+dx<0 || X<=j+dx)continue;
					if(c[i][j]==2){
						if(dx==0 && c[i+2][j]!=1){
							dp[i+2][j] += dp[i][j];
						}
					}
					else{
						if(c[i+1][j+dx]==0)dp[i+1][j+dx] += dp[i][j];
						else if(c[i+1][j+dx]==2 && dx==0)dp[i+1][j] += dp[i][j];
					}
				}
			}
		}
		cout<<ans<<endl;
	}
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#define fi first
#define se second
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=10000009;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };
int c[20][20];
long long int dp[20][20];
int main() {
	int X,Y;
	while(true){
		long long int ans=0;
		cin>>X>>Y;
		if(X+Y==0) break;
		for(int i=1;i<=Y;i++){
			for(int j=1;j<=X;j++){
				cin>>c[i][j];
			}
		}
		for(int i=1;i<=X;i++){
			if(c[1][i]==1){
				dp[1][i]=0;
			}
			if(c[1][i]==0){
				dp[1][i]=1;
			}
			if(c[1][i]==2){
				dp[1][i]=1;
				dp[3][i]=1;
			}
		}
		for(int i=2;i<=Y;i++){
			for(int j=1;j<=X;j++){
				if(c[i][j]==1) dp[i][j]=0;
				else if(c[i][j]==0){
					for(int k=0;k<3;k++){
						if(c[i-1][j-1+k]!=2){
							dp[i][j]+=dp[i-1][j-1+k];
						}
					}
				}
				else{
					if(c[i-1][j]!=2){
						dp[i][j]+=dp[i-1][j];
					}
					dp[i+2][j]+=dp[i][j];
				}
			}
		}
		for(int i=Y;i<=Y+2;i++){
			for(int j=1;j<=X;j++){
				ans+=dp[i][j];
			}
		}
		for(int i=1;i<=Y+1;i++){
			for(int j=1;j<=X;j++){
				dp[i][j]=0;
			}
		}
		cout<<ans<<endl;
	}
}