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<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<utility>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
 
using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 1e+9
#define EPS 1e-9
#define rep(i,j) for(int i = 0; i < (j); i++)
#define reps(i,j,k) for(int i = j; i < (k); i++)
typedef long long ll;
int main(){
    int w,h;
    while(scanf("%d%d",&w,&h),w|h){
        int stage[32][32]={{0}};
        int    dp[32][32]={{0}};
        rep(i,h)rep(j,w)scanf("%d",&stage[i+1][j+1]);

        reps(i,1,w+1)if(stage[1][i] == 0)dp[1][i] = 1;

        reps(i,2,h+1){
            reps(j,1,w+1){
                if(stage[i][j] == 2){
                    dp[i+2][j] += dp[i-1][j] + dp[i][j];
                    dp[i][j] = 0;
                }
                else if(stage[i][j] == 1){
                    dp[i][j] = 0;
                }
                else if(stage[i][j] == 0){
                    dp[i][j] += dp[i-1][j-1] + dp[i-1][j] + dp[i-1][j+1];
                }
            }
        }

        int ans = 0;
        rep(i,w+1){
            ans += dp[h][i] + dp[h+1][i] + dp[h+2][i];
        }
        printf("%d\n",ans);
    }
    return 0;
}

C++: #include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	while(true){
		int X=in(),Y=in();
		if(!X && !Y) break;
		vector<vector<int>> V(Y,vector<int>(X)),dp(Y,vector<int>(X,0));
		REP(i,Y){
			REP(j,X){
				V[i][j]=in();
			}
		}
		REP(i,X){
			if(V[0][i]==0) dp[0][i]=1;
		}
		REP(i,Y-1){
			REP(j,X){
				if(V[i][j]==0){
					if(j>0 && V[i+1][j-1]==0) dp[i+1][j-1]+=dp[i][j];
					if(V[i+1][j]!=1) dp[i+1][j]+=dp[i][j];
					if(j<X-1 && V[i+1][j+1]==0) dp[i+1][j+1]+=dp[i][j];
				}
				else if(V[i][j]==2){
					if(i+2<Y){
						if(V[i+2][j]!=1) dp[i+2][j]+=dp[i][j];
					}
					else dp[Y-1][j]+=dp[i][j];
				}
			}
		}
		out(accumulate(ALL(dp[Y-1]),0));
	}

	return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<string>
#include<map>
#include<queue>
#include<set>

using namespace std;

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

int main(){
	while(1){
		int w,h;
		cin>>w>>h;
		if(w==0)break;
		
		int dp[22][22]={0};
		int masu[22][22]={0};
		
		reps(i,h){
			reps(j,w){
				cin>>masu[i][j];
			}
		}
		
		reps(j,w){
			if(masu[1][j]!=0)continue;
			dp[1][j]=1;
		}
		
		reps(i,h-1){
			reps(j,w){
				if(masu[i][j]==0){
					if(masu[i+1][j]!=1) dp[i+1][j]+=dp[i][j];
					if(masu[i+1][j-1]==0) dp[i+1][j-1]+=dp[i][j];
					if(masu[i+1][j+1]==0) dp[i+1][j+1]+=dp[i][j];
				}
				if(masu[i][j]==1){
					
				}
				if(masu[i][j]==2){
					if(masu[i+2][j]!=1)dp[i+2][j]+=dp[i][j];
				}
			}
		}
		
		/*
		rep(i,h+3){
			rep(j,w+2){
				printf("%d ",dp[i][j]);
			}puts("");
		}*/
		
		int ans=0;
		rep(i,2){
			reps(j,w){
				ans += dp[h+i][j];
			}
		}
		printf("%d\n",ans);
	}
}

C++: 	#include <iostream>
	#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
	#define rep(x,to) rep2(x,0,to)
	using namespace std;
	int main(){
		int x, y;
		while(cin >> x >> y && (x||y) ) {
			int b[15][15] = {};
			rep(i,y) {
				rep(j,x) {
					cin >> b[i][j];
				}
			}
			int ret[20][20] = {};
			rep(i,x) {
				if(b[0][i] == 0) {
					ret[0][i+1] = 1;
				}
			}
			rep2(i,1,y) {
				rep(j,x) {
					if(b[i][j] == 0) {
						ret[i][j+1] += ret[i-1][j] + ret[i-1][j+1] + ret[i-1][j+2];
						rep2(k,-1,2) {
							if(b[i-1][j+k] == 2) ret[i][j+1] -= ret[i-1][j+k+1];
						}
					} else if(b[i][j] == 2) {
						if(y <= i+2 || b[i+2][j] != 1) {
							if(b[i-1][j] != 2) ret[i][j+1] += ret[i-1][j+1];
							ret[i+2][j+1] += ret[i][j+1];
						}
					}
				}
			}
			int ans = 0;
			rep2(i,y-1,y+2) {
				rep(j,x) {
					ans += ret[i][j+1];
				}
			}
			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+2;i++){
			for(int j=1;j<=X;j++){
				dp[i][j]=0;
			}
		}
		cout<<ans<<endl;
	}
}