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 <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

int dx[]={-1, 0, 1};

int d[21][21];
ll dp[21][21];
int w, h;

bool isOutofRange(int x, int y){
	if(x < 0 || x >= w || y < 0) return true;
	return false;
}

int main(){
	while(cin>>w>>h && w && h){
		rep(i, h) rep(j, w) cin>>d[i][j];
		rep(i, 21) rep(j, 21) dp[i][j] = 0LL;
		for(int i = 0; i < w; i++){
			if(d[0][i] != 1) dp[0][i] = 1LL;
		}

		for(int i = 0; i < h-1; i++){
			for(int j = 0; j < w; j++){
				if(d[i][j]!=0) continue;
				for(int k = 0; k < 3; k++){
					int nx = j + dx[k], ny = i+1;
					if(isOutofRange(nx, ny)) continue;
					if(d[ny][nx] == 0) {
						dp[ny][nx] += dp[i][j];
					}
				}
				if(d[i+1][j]==2) dp[i+2][j]+=dp[i][j];
			}
		}
		ll ans = 0ll;
		rep(i, w){
			ans += dp[h-1][i];
			ans += dp[h][i];
		}
		cout<<ans<<endl;
		// rep(i, h) {
		// 	rep(j, w){
		// 		cout<<dp[i][j]<<" ";
		// 	}
		// 	cout<<endl;
		// }
	}
	
}

C++: #include <iostream>

using namespace std;

int main() {
	int width, height, m[15][15];
	while (cin >> width >> height, width && height) {
		for (int y = 0; y < height; ++y)
			for (int x = 0; x < width; ++x)
				cin >> m[y][x];

		int sum = 0, pattern[15][15] = {0};
		for (int x = 0; x < width; ++x)
			pattern[0][x] = 1;

		for (int y = 0; y < height-1; ++y)
			for (int x = 0; x < width; ++x)
				if (m[y][x] == 0) {
					if (x - 1 >= 0 && m[y+1][x-1] == 0) pattern[y+1][x-1] += pattern[y][x];
					if (x + 1 < width && m[y+1][x+1] == 0) pattern[y+1][x+1] += pattern[y][x];
					if (m[y+1][x] != 1) pattern[y+1][x] += pattern[y][x];
				}
				else if (m[y][x] == 2) {
					if (y + 2 == height) sum += pattern[y][x];
					else if (m[y+2][x] != 1) pattern[y+2][x] += pattern[y][x];
				}

		for (int x = 0; x < width; ++x)
			sum += pattern[width-1][x];

		cout << sum << endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
	int n, m;
	while (true){
		cin >> n >> m;
		if (n == 0 && m == 0){
			break;
		}
		int map[100][100] = { 0 };
		int dp[100][100] = { 0 };
		for (int i = 0; i < m; i++){
			for (int i2 = 0; i2 < n; i2++){
				cin >> map[i][i2];
			}
		}
		for (int i = 0; i < n; i++){
			if (map[0][i] == 0){
				dp[0][i] = 1;
			}
		}
		for (int i = 0; i < m-1; i++){
			for (int i2 = 0; i2 < n; i2++){
				if (map[i][i2] == 0){
					if (map[i + 1][i2] == 0 || map[i + 1][i2] == 2){
						dp[i + 1][i2] += dp[i][i2];
					}
					if (i2+1<m&&map[i + 1][i2 + 1] == 0){
						dp[i + 1][i2 + 1] += dp[i][i2];
					}
					if (i2 - 1 >= 0 && map[i + 1][i2 - 1] == 0){
						dp[i + 1][i2 - 1] += dp[i][i2];
					}
				}
				if (map[i][i2] == 2){
					if (map[i + 2][i2] == 0 || map[i + 2][i2] == 2){
						dp[i + 2][i2] += dp[i][i2];
					}
				}
			}
		}
		int ans = 0;
		for (int i = 0; i < n; i++){
			ans += dp[m - 1][i];
			ans += dp[m][i];
		}
		cout << ans << endl;
	}
}

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

int c[17][15];
int p[17][15];

int main() {
    int w, h;
    while (cin >> w >> h, w|h) {
        for (int y = 0; y < h; y++) {
            for (int x = 0; x < w; x++) {
                int ci;
                cin >> ci;
                c[y][x] = ci;
            }
        }
        for (int x = 0; x < w; x++) {
            c[h][x] = c[h+1][x] = 2;
        }
        memset(p, 0, sizeof(p));
        for (int y = 0; y < h+2; y++) {
            for (int x = 0; x < w; x++) {
                if (c[y][x] == 1) {
                    continue;
                }
                if (y == 0) {
                    p[y][x] = 1;
                    continue;
                }
                if (c[y][x] == 0) {
                    if (x > 0 && c[y-1][x-1] == 0) {
                        p[y][x] += p[y-1][x-1];
                    }
                    if (x+1 < w && c[y-1][x+1] == 0) {
                        p[y][x] += p[y-1][x+1];
                    }
                }
                if (c[y-1][x] == 0) {
                    p[y][x] += p[y-1][x];
                }
                if (y >= 2 && c[y-2][x] == 2) {
                    p[y][x] += p[y-2][x];
                }
            }
        }
        int ans = 0;
        for (int y = h; y < h+2; y++) {
            for (int x = 0; x < w; x++) {
                ans += p[y][x];
            }
        }
        cout << ans << endl;
    }
}

C++: // 2011/07/31 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int X, Y;
		cin >> X >> Y;
		if(X==0&&Y==0)
			break;

		int C[18][17];
		for(int i=0; i<=Y+2; i++)
			for(int j=0; j<=X+1; j++)
				C[i][j] = 1;

		for(int i=1; i<=Y; i++)
			for(int j=1; j<=X; j++)
				cin >> C[i][j];

		for(int i=Y+1; i<=Y+2; i++)
			for(int j=1; j<=X; j++)
				C[i][j] = 0;

		int DP[18][17];
		for(int i=0; i<=Y+2; i++)
			for(int j=0; j<=X+1; j++)
				DP[i][j] = 0;

			for(int j=1; j<=X; j++)
				if(C[1][j]==0)
					DP[1][j] = 1;

		for(int i=1; i<=Y-1; i++)
			for(int j=1; j<=X; j++)
				if(C[i][j]==0){
					for(int k=j-1; k<=j+1; k++)
						if(C[i+1][k]==0){
							DP[i+1][k] += DP[i][j];
						}
						else if(C[i+1][k]==1){
							DP[i+1][k] = 0;
						}
						else if(C[i+1][k]==2){
							if(k==j)
								DP[i+1][k] += DP[i][j];
						}
				}
				else if(C[i][j]==1){
					DP[i][j] = 0;
				}
				else if(C[i][j]==2){
					if(C[i+2][j]==1)
						DP[i+2][j] = 0;
					else
						DP[i+2][j] += DP[i][j];
				}

			for(int j=1; j<=X; j++)
				if(C[Y][j]==1){
					DP[Y][j] = 0;
				}

		int sum = 0;
		for(int i=Y; i<=Y+1; i++)
			for(int j=1; j<=X; j++)
				sum += DP[i][j];

		cout << sum <<endl;
	}

	return 0;
}