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 <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;
		for(int i=1;i<=Y+2;i++){
			for(int j=1;j<=X;j++){
				dp[i][j]=0;
			}
		}
		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;
			}
		}
		for(int i=1;i<=Y;i++){
			for(int j=1;j<=X;j++){
				if(c[i][j]==0){
					for(int k=0;k<3;k++){
						if(c[i+1][j+k-1]==0) dp[i+1][j+k-1]+=dp[i][j];
						else if(k==1&&c[i+1][j+k-1]==2) dp[i+1][j+k-1]+=dp[i][j];
					}
				}
				if(c[i][j]==2){
					if(c[i+2][j]!=1) dp[i+2][j]+=dp[i][j];
				}
			}
		}
		for(int i=1;i<=X;i++){
			if(c[Y-1][i]==2){
				ans+=dp[Y-1][i];
			}
		}
		for(int i=1;i<=X;i++){
			ans+=dp[Y][i];
		}
		printf("%lld\n",ans );
	}
}

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)
			if (m[height-1][x] != 1) sum += pattern[height-1][x];

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

C++: #include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;


signed main() {
	int y, x;
	while (1) {
		cin >> y >> x;
		if (y + x == 0) break;
		int d[20][20] = { 0 };
		rep(i, 0, y) {
			rep(j, 0, x) {
				cin >> d[i][j];
			}
		}
		int dp[20][20] = { 0 };
		rep(i, 0, x) {
			if (d[0][i] == 0) dp[0][i] = 1;
		}
		rep(i, 0, y) {
			rep(j, 0, x) {
				if (d[i][j] == 1) continue;
				if (d[i][j] == 2) {
					dp[i + 2][j] += dp[i][j];
					continue;
				}
				rep(k, -1, 2) {
					if (j + k < 0 || j + k >= x || d[i + 1][j + k] != 0) continue;
					dp[i + 1][j + k] += dp[i][j];
				}
				if (d[i + 1][j] == 2) {
					dp[i + 1][j] += dp[i][j];
				}
			}
		}
		/*cout << endl;
		rep(i, 0, y + 2) {
			rep(j, 0, x) {
				cout << dp[i][j] << " ";
			}
			cout << endl;
		}*/
		int ans = 0;
		rep(i, 0, x) {
			ans += dp[y - 1][i];
			if (d[y - 2][i] == 2) {
				ans += dp[y - 2][i];
			}
		}
		cout << ans << endl;
	}
}

C++: #include<iostream>
#include<utility>
#include<queue>
#include<functional>
#include<cstring>
#include<vector>
#include<climits>
#include<map>
using namespace std;
#define FOR(i,n) for(int i=0;i<(int)n;i++)
#define FORI(i,k,n) for(int i=k;i<(int)n;i++)
#define ALL(x) (x).begin(),(x).end()
typedef pair<int,int> pii;
typedef vector<int> vi;
#define int long long

main()
{
	while(1)
	{
		int a[20][20];
		int dp[20][20]={};
		int x,y;
		
		cin>>x>>y;if(x==0&&y==0)break;
		FOR(i,20)FOR(j,20)a[i][j]=1;
		FORI(i,1,y+1)
		{
			FORI(j,1,x+1)
			{
				cin>>a[i][j];
			}
		}
		FORI(i,1,x+1)
		{
			if(a[1][i]==0)dp[1][i]=1;
			a[y+1][i]=0;
		}
		FORI(i,1,y)
		{
			FORI(j,1,x+1)
			{
				if(a[i][j]==2&&a[i+2][j]!=1)
				{
					dp[i+2][j]+=dp[i][j];
				}
				else
				{
					for(int k=-1;k<=1;k++)
					{
						if(a[i+1][j+k]==0)
						{
							dp[i+1][j+k]+=dp[i][j];
						}
					}
					if(a[i+1][j]==2)dp[i+1][j]+=dp[i][j];
				}
			}
		}
		
		int ans=0;
		FORI(i,1,x+1)ans+=dp[y][i]+dp[y+1][i];
		cout<<ans<<endl;
		
	}
}

C++: #include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>

using namespace std;

int main()
{
	int x, y;
	while (scanf("%d %d", &x, &y), x | y)
	{
		int topo[16][15 + 2];
		memset(topo, 0, sizeof(topo));
		for (int i = 0; i < y; ++i)
			for (int j = 1; j <= x; ++j)
				scanf("%d", &topo[i][j]);

		int dp[16][15 + 2];
		memset(dp, 0, sizeof(dp));
		for (int i = 1; i <= x; ++i)
			dp[0][i] = 1;

		for (int i = 0; i < y-1; ++i)
		{
			for (int j = 1; j <= x; ++j)
			{
				if (topo[i][j] == 0 && i < y-1)
				{
					for (int k = -1; k <= 1; ++k)
						if (topo[i+1][j+k] != 1 && (topo[i+1][j+k] == 0 || k == 0))
							dp[i+1][j+k] += dp[i][j];
				}
				else if (topo[i][j] == 2 && topo[i+2][j] != 1)
					dp[i+2][j] += dp[i][j];
			}
		}
		int ans = 0;
		for (int i = y-1; i <= y; ++i)
			for (int j = 1; j <= x; ++j)
				ans += dp[i][j];
		printf("%d\n", ans);
	}

	return 0;
}