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>
#define N 15
using namespace std;
void func(int,int);
int jump(int,int);
int X,Y,data[N][N],memo[N][N];
int main(){
  while(1){
    cin >> X >> Y;
    if(X==0&&Y==0) break;
    for(int i=0;i<Y;i++)
      for(int j=0;j<X;j++) cin >> data[i][j],memo[i][j]=0;
    for(int i=0;i<X;i++)
      if(data[0][i]==0) func(0,i);
    int cnt=0;
    for(int i=0;i<X;i++) cnt+=memo[0][i];
    cout << cnt << endl;
  }
  return 0;
}
void func(int y,int x){
  if(y>=Y-1){
    memo[Y-1][x]=1;
    return ;
  }
  if(y+1<Y&&0<=x-1&&data[y+1][x-1]==0){
    if(memo[y+1][x-1]==0) func(y+1,x-1);
    memo[y][x]+=memo[y+1][x-1];
  }
  if(y+1<Y&&x+1<X&&data[y+1][x+1]==0){
    if(memo[y+1][x+1]==0) func(y+1,x+1);
    memo[y][x]+=memo[y+1][x+1];
  }
  if(y+1<Y&&data[y+1][x]==0){
    if(memo[y+1][x]==0) func(y+1,x);
    memo[y][x]+=memo[y+1][x];
  }
  if(y+1<Y&&data[y+1][x]==2){
    int r=jump(y+1,x);
    if(r==-2) memo[y][x]+=1;
    else if(r!=-1){
      func(r,x);
      memo[y][x]+=memo[r][x];
    }
  }
  if(memo[y][x]==0) data[y][x]=1;
}
int jump(int y,int x){
  while(1){
    y+=2;
    if(data[y][x]==1) break;
    if(y>=Y-1) return -2;
    if(data[y][x]==0) return y;
  }
  return -1;
}

C++: #include<iostream>
#include<string>
#include<cstdlib>
#include<cmath>
#include<algorithm>

using namespace std;


int main() {
	while(1) {
		int x, y;
		cin >> y >> x;
		if(x==0 && y==0) break;
		int field[x][y];
		for(int i=0; i<x; i++) {
			for(int j=0; j<y; j++) {
				cin >> field[i][j];
			}
		}
		int dp[x+1][y];
		for(int i=0; i<x+1; i++) {
			for(int j=0; j<y; j++) {
				dp[i][j] = 0;
			}
		}
		for(int i=0; i<x; i++) {
			for(int j=0; j<y; j++) {
				if(i==0 && field[i][j] == 0) dp[i][j] = 1;
				else {
					if(field[i][j] == 0) {
						if(0<j && field[i-1][j-1] == 0) dp[i][j] += dp[i-1][j-1];
						if(field[i-1][j] == 0) dp[i][j] += dp[i-1][j];
						if(j<y-1 && field[i-1][j+1] == 0) dp[i][j] += dp[i-1][j+1];
					}
					if(field[i][j] == 2) {
						dp[i][j] += dp[i-1][j];
						dp[i+2][j] += dp[i][j];
					}
				}
			}
		}
		for(int i=0; i<y; i++) dp[x][i] += dp[x-1][i];
		int sum=0;
		for(int i=0; i<y; i++) sum += dp[x][i];
		cout << sum << endl;

		//for(int i=0; i<x+1; i++) {
			//for(int j=0; j<y; j++) {
				//cout << dp[i][j] << ' ';
			//}
			//cout << endl;
		//}
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int gole, X, Y;
int map[15][15];

bool check(int x, int y, int flag) { // flag: ツ陳シツ進ツつオツづつォツつスツつゥ
	if (x < 0 || x >= X) return false;
	if (y >= Y) { gole += flag; return false; }
	if (map[y][x] == 1) return false;
	if (!flag && map[y][x] == 2) return false;
	return true;
}

int main() {
	while (cin >> X >> Y, X || Y) {
		int pattern[15][15] = {0};
		gole = 0;
		for (int y = 0; y < Y; ++y)
			for (int x = 0; x < X; ++x)
				cin >> map[y][x];

		for (int x = 0; x < X; ++x)
			if (map[0][x] == 0)
				pattern[0][x] = 1;

		for (int y = 1; y < Y; ++y)
			for (int x = 0; x < X; ++x) {
				if (map[y-1][x] == 0) {
					if (check(x-1, y, false)) pattern[y][x-1] += pattern[y-1][x];
					if (check(x,   y, true))  pattern[y][x]   += pattern[y-1][x];
					if (check(x+1, y, false)) pattern[y][x+1] += pattern[y-1][x];
				}
				else if (map[y-1][x] == 1) continue;
				else if (check(x, y+1, pattern[y-1][x])) pattern[y+1][x] += pattern[y-1][x];
			};

		cout << gole << endl;

		for (int x = 0; x < X; ++x) gole += pattern[Y-1][x];

		cout << gole << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int W, H;
	while(cin >> W >> H, W) {
		int b[15][20] = { 0 };
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				cin >> b[i][j];
			}
		}

		int dp[15][20] = { 0 };
		for(int i = 0; i < W; i++) {
			if(b[0][i] != 1)
				dp[0][i] = 1;
		}

		for(int i = 0; i < H - 1; i++) {
			for(int j = 0; j < W; j++) {
				if(b[i][j] == 0) {
					for(int d = -1; d <= 1; d++) {
						if(j + d < 0 || W <= j + d) continue;
						if(b[i + 1][j + d] == 0 || b[i + 1][j + d] == 2 && d == 0)
							dp[i + 1][j + d] += dp[i][j];
					}
				}
				else if(b[i][j] == 2) {
					dp[i + 2][j] += dp[i][j];
				}
			}
		}

		int ans = 0;
		for(int i = H - 1; i <= H; i++) {
			for(int j = 0; j < W; j++) {
				if(b[i][j] != 1)
					ans += dp[i][j];
			}
		}
		cout << ans << endl;
	}
}

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

int main() {
	int map[15][15];
	int dp[16][15];
	int X, Y;
	int dx[] = { -1, 0, 1 };

	while (cin >> X >> Y, X||Y) {
		memset(dp, 0, sizeof(dp));

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

		for (int i=0; i<X; i++) { 
			dp[0][i] = (map[0][i]==1) ? 0 : 1;
			dp[Y][i] = 0;
		}

		for (int y=0; y<Y-1; y++)
		for (int x=0; x<X; x++) {
			int p;
			switch (map[y][x]) {
				case 0:
					for (int i=0; i<3; i++) {
						p = x + dx[i];
						if (p<0 || p>=X) continue;
						if (map[y+1][p]==1 || (map[y+1][p]==2 && i!=1)) continue;
						dp[y+1][p] += dp[y][x];
					}
					break;
				case 1:
					break;
				case 2:
					if (map[y+2][x]!=1) dp[y+2][x] += dp[y][x];
					break;
			}
		}
		
		int ans = 0;
		for (int i=0; i<X; i++)
			ans += dp[Y-1][i] + dp[Y][i];

		cout << ans << endl;
	}
	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;
}