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 <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) field[i][j] = 1;
		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);
		rep(i, Y - 1) rep(j, X) {
			if(field[i][j] == 0) {
				if(field[i + 1][j] != 1) dp[i + 1][j] += dp[i][j];
				if(j - 1 >= 0 && field[i + 1][j - 1] == 0) dp[i + 1][j - 1] += dp[i][j];
				if(j + 1 < X && field[i + 1][j + 1] == 0) dp[i + 1][j + 1] += dp[i][j];
			}
			else if(field[i][j] == 2) {
				dp[i + 2][j] += dp[i][j];
			}
		}
		/*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) if(field[Y - 1][i] != 1) res += dp[Y - 1][i];
		rep(i, X) res += dp[Y][i];
		printf("%d\n", res);
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <map>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int main(){
	while(true){
		int maxX,maxY;
		cin >> maxX >> maxY;			if(!maxX&&!maxY) return 0;

		int tizu[maxX+2][maxY+2];
		FOR(y,0,maxY+2){
			FOR(x,0,maxX+2){
				if(x==0||x==maxX+1||y==0||y==maxY+1){tizu[x][y]=1;continue;};
				cin >> tizu[x][y];
			}
		}

		int dp[maxX+2][maxY+2];
		FOR(y,0,maxY+2){
			FOR(x,0,maxY+2){
				dp[x][y]=0;
				if(x==0||x==maxX+1){
					continue;
				}
				if(y==0){
					continue;
				}
				if(y==1){
					if(tizu[x][y]==0) dp[x][y]+=1;
					continue;
				}
				if(y==maxY+1){
					if(tizu[x][y-1]==0) dp[x][y]+=dp[x][y-1];
					if(tizu[x][y-1]==2) dp[x][y]+=dp[x][y-1];
					if(tizu[x][y-2]==2) dp[x][y]+=dp[x][y-2];
					continue;
				}
				if(tizu[x][y]==0){
					if(tizu[x-1][y-1]==0) dp[x][y]+=dp[x-1][y-1];
					if(tizu[x][y-1]==0)   dp[x][y]+=dp[x][y-1];
					if(tizu[x+1][y-1]==0) dp[x][y]+=dp[x+1][y-1];
					if(tizu[x][y-2]==2)   dp[x][y]+=dp[x][y-2];
					continue;
				}
				if(tizu[x][y]==1){
					continue;
				}
				if(tizu[x][y]==2){
					if(tizu[x][y-1]==0) dp[x][y]+=dp[x][y-1];
					if(tizu[x][y-2]==2) dp[x][y]+=dp[x][y-2];
					continue;
				}
			}
		}


		int res = 0;
		FOR(x,1,maxX+1){ res += dp[x][maxY+1];};
		cout << res << endl;

	}
}

C++: #include <stdio.h>

int main(void){
	int x,y,i,j;
	while(scanf("%d%d",&x,&y),x,y){
		int masu[20][20]={ 0 };
		int dp[20][20]={0};
		int ans=0;
		for(i=1;i<=y;i++){
			for(j=1;j<=x;j++){
				scanf("%d",&masu[i][j]);
			}
		}
		for(i=0;i<=y;i++)masu[i][0]=1;
		for(j=0;j<=x;j++)masu[0][j]=1;
		
		for(j=1;j<=x;j++){
			if(masu[1][j]==0)dp[1][j]=1;
		}
		for(i=2;i<=y;i++){
			for(j=1;j<=x;j++){
				if(masu[i][j]==0){
					if(masu[i-1][j-1]==0)dp[i][j]+=dp[i-1][j-1];
					if(masu[i-1][j]==0)	 dp[i][j]+=dp[i-1][j];
					if(masu[i-1][j+1]==0)dp[i][j]+=dp[i-1][j+1];
					if(masu[i-2][j]==2){
						dp[i][j]+=dp[i-2][j];
					}
				}
				if(masu[i][j]==1){
					dp[i][j]=0;
				}
				if(masu[i][j]==2){
					if(dp[i-1][j]==0)dp[i][j]=dp[i-1][j];
					if(masu[i-2][j]==2)dp[i][j]+=dp[i-2][j];
				}
			}
		}
		for(i=1;i<=x;i++){
			ans+=dp[y][i];
			if(masu[y-1][i]==2)ans+=dp[y-1][i];
		}
		
		printf("%d\n",ans);
	}
	
	return 0;
}

C++: #include <cstdio>
using namespace std;

int main()
{
	int map[100][100];
	int dp[100][100];
	
	int X, Y;
	while (scanf("%d %d", &X, &Y), X + Y){
		for (int i = 0; i < 100; i++){
			dp[0][i] = 1;
			for (int j = 1; j < 100; j++){
				dp[j][i] = 0;
			}
		}
		
		for (int i = 0; i < Y; i++){
			for (int j = 0; j < X; j++){
				scanf("%d", &map[i][j]);
			}
		}
		
		for (int i = 0; i < Y; i++){
			for (int j = 0; j < X; j++){
				if (map[i][j] == 0){
					for (int k = -1; k <= 1; k++){
						if (j + k >= 0 && j + k < X && (map[i + 1][j + k] == 0 || (k == 0 && map[i + 1][j + k] == 2)) && (i < Y - 1 || k == 0)){
							dp[i + 1][j + k] += dp[i][j];
						}
					}
				}
				else if (map[i][j] == 2){
					dp[i + 2][j] += dp[i][j];
				}
			}
		}
		
		int sum = 0;
		for (int i = 0; i < X; i++){
//			printf("%d ", dp[Y][i]);
			sum += dp[Y][i];
			sum += dp[Y + 1][i];
		}
		
		printf("%d\n", sum);
	}
	
	return 0;
}

C++: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class t>
using table = vector<vector<t>>;
const ld eps=1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt"

int main() {
	while (1) {
		int H, W; cin >> W >> H;
		if (!H)break;
		vector<vector<int>>field(H + 3, vector<int>(W + 2,1));
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				cin >> field[i][j+1];
			}
		}
		for (int i = H; i < H + 3; ++i) {
			for (int j = 1; j <= W; ++j) {
				field[i][j] = 0;
			}
		}
		vector<vector<long long int>>nums(H + 3, vector<long long int>(W + 2, 0));
		for (int j = 0; j < W + 2; ++j) {
			if (!field[0][j])nums[0][j] = 1;
		}
		long long int ans = 0;
		if (H==1) {
			cout << accumulate(nums[0].begin(), nums[0].end(), 0) << endl;
		}
		else {
			for (int i = 0; i < H - 1; ++i) {
				for (int j = 1; j < W + 1; ++j) {
					for (int dx = -1; dx <= 1; ++dx) {
						const int nextx = j + dx;
						int nexty = i + 1;

						if (field[nexty][nextx] == 1) {

						}
						else if (field[nexty][nextx] == 2) {
							if (!dx) {
								while (1) {
									nexty += 2;
									if (nexty >= H - 1 && field[nexty][nextx] != 1) {
										ans += nums[i][j];
										break;
									}
									else {
										if (field[nexty][nextx] == 1) {
											break;
										}
										else if (field[nexty][nextx] == 0) {

											nums[nexty][nextx] += nums[i][j];
											break;
										}
									}
								}

							}
						}
						else {
							if (nexty >= H - 1)ans += nums[i][j];
							else {
								nums[nexty][nextx] += nums[i][j];
							}
						}
					}

				}
			}
			cout << ans << endl;
		}
		
	}
	return 0;
}