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, 21) rep(j, 21) dp[i][j] = 0LL, d[i][j]=0;;
		rep(i, h) rep(j, w) cin>>d[i][j];
		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 <cstring>
#include <iostream>
using namespace std;
const int MAX_W = 15;
const int MAX_H = 15;

int w, h;
int field[MAX_H + 1][MAX_W + 2];
int dp[MAX_H + 1][MAX_W + 2];

void printfield() {
	for (int i = 0; i < h + 1; i++) {
		for (int j = 0; j <= w + 1; j++) {
			cout << '\t' << dp[i][j] << '(' << field[i][j] << ')';
		}
		cout << endl;
	}
}

int main () {
	while (cin >> w >> h, w || h) {
		memset(field, 0, sizeof(field));
		memset(dp, 0, sizeof(dp));
		for (int i = 0; i < h + 1; i++) {
			field[i][0] = 1;
			dp[i][0] = 0;
			field[i][w + 1] = 1;
			dp[i][w + 1] = 0;
		}
		for (int i = 0; i < h; i++) {
			for (int j = 1; j <= w; j++) {
				cin >> field[i][j];
			}
		}
		for (int i = 1; i <= w; i++) {
			if (field[0][i] == 0) dp[0][i] = 1;
		}
		for (int i = 0; i < h - 1; i++) {
			for (int j = 1; j <= w; j++) {
				if (field[i][j] == 0) {
					dp[i + 1][j] += dp[i][j];
					if (field[i + 1][j + 1] != 2) dp[i + 1][j + 1] += dp[i][j];
					if (field[i + 1][j - 1] != 2) dp[i + 1][j - 1] += dp[i][j];
				}
				else if (field[i][j] == 2) {
					dp[i + 2][j] += dp[i][j];
				}
			}
		}
//		printfield();
		int sum = 0;
		for (int i = h - 1; i < h + 1; i++) {
			for (int j = 1; j <= w; j++) {
				if (field[i][j] != 1) {
					sum += dp[i][j];
				}
			}
		}
		cout << sum << endl;
	}
	return 0;
}

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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
#define MOD 1e9 + 7

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

int X, Y;
int field[20][20];
int dp[20][20];

int main() {
	while(scanf("%d %d", &X, &Y), X || Y) {
		rep(i, Y) rep(j, X) scanf("%d", &field[i][j]);
		memset(dp, 0, sizeof(dp));
		rep(j, X) dp[0][j] = (field[0][j] == 0);
		FOR(i, 1, Y) rep(j, X) {
			if(field[i][j] == 0) {
				FOR(k, -1, 2) dp[i][j] += dp[i - 1][j + k];
			}
			else if(field[i][j] == 2) {
				dp[i + 2][j] += dp[i - 1][j] + dp[i][j];
				dp[i][j] = 0;
			}
		}
		rep(i, X) dp[Y][i] += dp[Y - 1][i];
		/*rep(i, Y) {
			rep(j, X) printf("%2d", dp[i][j]);
			puts("");
		}
		rep(i, X) printf("%2d", dp[Y][i]);
		*/
		int res = 0;
		rep(i, X) res += dp[Y][i];
		printf("%d\n", res);
	}
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
#include <iomanip>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
	int X, Y;
	while(cin >> X >> Y && X)
	{
		vector<vint> field(Y + 1, vint(X, 0)), dp(Y + 1, vint(X, 0));
		rep(y, Y) rep(x, X)
			cin >> field[y][x];

		fill(ALL(dp[0]), 1);
		rep(y, Y) rep(x, X)
		{
			// y, x ツつゥツづァツづ個配ツづゥDP
			if(field[y][x] == 1) continue;

			if(field[y][x] == 2 || y + 1 == Y)
			{
				dp[min(y + 2, Y)][x] += dp[y][x];
			}
			else
			{
				int dx[] = {-1, 1};

				dp[y + 1][x] += dp[y][x];
				rep(i, 2)
				{
					int nx = x + dx[i];
					if(0 <= nx && nx < X && field[y + 1][nx] != 2)
						dp[y + 1][nx] += dp[y][x];
				}
			}
		}

		cout << accumulate(ALL(dp[Y]), 0) << endl;
	}
}