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>
using namespace std;

const int MAX_SIZE = 15;
char field[MAX_SIZE+1][MAX_SIZE+3];
int dp[MAX_SIZE+1][MAX_SIZE+3];
int w, h;

bool judge(int i, int j){
	if(j > 0 && j <= w && field[j][i] == '0' && j <= h)
		return true;
	return false;
}

int main(){
	while(cin >> w >> h){
		if(w == 0 && h == 0) break;
		for(int i = 1; i <= h; i++){
			for(int j = 1; j <= w; j++)
				cin >> field[j][i];
		}
		int pattern = 0;
		for(int i = 0; i < MAX_SIZE+1; i++){
			for(int j = 0; j < MAX_SIZE+3; j++){
				dp[i][j] = 0;
			}
		}
		for(int i = 1; i <= w; i++){
			if(field[i][1] == '0')
				dp[i][1] = 1;
		}
		for(int i = 1; i < h; i++){
			for(int j = 1; j <= w; j++){
				if(field[j][i] == '2' && field[j][i+2] != '1'){
					dp[j][i+2] += dp[j][i];
				}else if(field[j][i] == '0'){
					if(field[j][i+1] != '1') dp[j][i+1] += dp[j][i];
					if(judge(i+1, j-1)) dp[j-1][i+1] += dp[j][i];
					if(judge(i+1, j+1)) dp[j+1][i+1] += dp[j][i];
				}else{
					dp[j][i] = 0;
				}
			}
			
		}
		int count = 0;
		for(int i = h; i <= h+1; i++){
			for(int j = 1; j <= w; j++){
				count += dp[j][i];
			}
		}
		cout << count << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <iomanip>

using namespace std;

char mapData[15][15];
int dp[15][15];
int h, w;
int dx[] = {-1, 0, 1};

main(){
  while(cin >> w >> h && (h || w)){ 
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin >> mapData[i][j];
      }
    }
    fill(dp[0], dp[15], 0);
    for(int i=0;i<w;i++){
      if(mapData[0][i] != '1')
	dp[0][i] = 1;
    }
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(dp[i][j] == 0) continue;
	if(mapData[i][j] == '2'){
	  int ty = i + 2;
	  if(ty<0 || ty>=h) continue;
	  if(mapData[ty][j] == '1') continue;
	  dp[ty][j] += dp[i][j];
	}else{
	  for(int k=0;k<3;k++){
	    int ty = i + 1;
	    int tx = j + dx[k];
	    if(ty<0 || ty>=h) continue;
	    if(tx<0 || tx>=w) continue;
	    if(mapData[ty][tx] == '1') continue;
	    if(mapData[ty][tx] == '2' && k != 1) continue;
	    dp[ty][tx] += dp[i][j];
	  }
	}
      }
    }
    int ans = 0;
    for(int i=0;i<w;i++){
      if(mapData[h-2][i] == '2') ans += dp[h-2][i];
      if(mapData[h-1][i] != '1') ans += dp[h-1][i];
    }
    cout << ans << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <vector>

using namespace std;

#define loop(i,a,b) for(int i=a; i<b; i++)
#define rep(i,b) loop(i,0,b)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

int main(){
    int w,h;
    while(cin>>w>>h, w||h){
        int G[100][100]={};
        int dp[100][100]={};

        rep(i,h)rep(j,w) cin>> G[i][j];
        rep(i,w) dp[0][i] = G[0][i]==0;

        rep(i,h-1) rep(j,w){
            if( G[i][j]==1){
                dp[i][j]=0;
            } else if(G[i][j]==2){
                if(G[i+2][j]!=1){
                    dp[i+2][j]+=dp[i][j];
                }
            } else {
                if(G[i+1][j]==2) dp[i+1][j]+=dp[i][j];
                loop(k,-1,2){
                    if(0<=j+k && j+k<w && G[i+1][j+k]==0){
                        dp[i+1][j+k]+=dp[i][j];
                    }
                }
            }
        }

        ull res=0;
        for(int i: {h-1,h}) rep(j,w){
            res+=dp[i][j];
        }

        cout<<res<<endl;
    }
}

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

using namespace std;

int field[20][20];
int dp[20][20];

int n, m;

bool isIn(int x, int y){
    return 0 <= x && x < n && 0 <= y && y < m;
}

int main(){
    while(cin >> n >> m, n+m){
        for(int i=0; i < n; i++) for(int j=0; j< m; j++){cin >> field[i][j];}
        for(int i=0; i< 20; i++) for(int j=0; j< 20; j++) dp[i][j] = 0;
        for(int i=0; i < m; i++) dp[0][i] = 1;
        for(int i=0; i < n-1; i++){
            for(int j=0; j < m; j++){
                if(field[i][j] == 0){
                    for(int k=-1; k <= 1; k++){
                        if(isIn(i+1, j+k) && !(k != 0 && field[i+1][j+k] == 2)){
                            dp[i+1][j+k] += dp[i][j];
                        }
                    }
                }
                else if(field[i][j] == 2) dp[i+2][j] += dp[i][j];
            }
        }
        for(int i=0; i< m; i++) if(field[n-1][i] != 1)dp[n][i] += dp[n-1][i];
        long long count = 0;
        for(int i=0; i< m; i++) count += dp[n][i];
        cout << count << endl;
    }
}