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 rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
using namespace std;
int main(){
	int x, y;
	while(cin >> x >> y && (x||y) ) {
		int b[15][15] = {};
		rep(i,y) {
			rep(j,x) {
				cin >> b[i][j];
			}
		}
		int ret[20][20] = {};
		rep(i,x) {
			if(b[0][i] == 0) {
				ret[0][i+1] = 1;
			}
		}
		rep2(i,1,y) {
			rep(j,x) {
				if(b[i][j] == 0) {
					ret[i][j+1] += ret[i-1][j] + ret[i-1][j+1] + ret[i-1][j+2];
					rep2(k,-1,2) {
						if(b[i-1][j+k] == 2) ret[i][j+1] -= ret[i-1][j+k+1];
					}
				} else if(b[i][j] == 2) {
					if(y <= i+2 || b[i+2][j] != 1) ret[i+2][j+1] += ret[i-1][j+1];
				}
			}
		}
		int ans = 0;
		rep2(i,y-1,y+2) {
			rep(j,x) {
				ans += ret[i][j+1];
			}
		}
		cout << ans << endl;
	}
}

C++: #define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair<int,string> P;

static const double eps = 1e-8;

const int moveTo[][2] = {{-1,1},{0,1},{1,1}};

int stage[17][17];
int sum=0;

void dfs(int sx,int sy,int w,int h){
	//space:0 tree:1 jump:2

	int now = stage[sy][sx];
	if(now == 1) return;

	if(sy>=h-1){
		sum++;
		return;
	}

	if(now == -1) return;

	if(now == 2){
		int dx = sx;
		int dy = sy + 2;
		if(!(dx < 0 || dx >= w || dy < 0)){
			if(!(stage[dy][dx] == 1)){
				dfs(dx,dy,w,h);
			}
		}

	}

	else{
		for(int i=0;i<3;i++){
			int dx = sx + moveTo[i][0];
			int dy = sy + moveTo[i][1];
			if(dx < 0 || dx >= w || dy < 0) continue;
			if(stage[dy][dx] == 2 && dx != sx) continue;
			if(stage[dy][dx] == 1) continue;

			dfs(dx,dy,w,h);
		}
	}
}

int main(){
	int w,h;
	while(~scanf("%d %d",&w,&h)){
		if(w==h && h==0) break;
		memset(stage,-1,sizeof(stage));
		for(int y=0;y<h;y++){
			for(int x=0;x<w;x++){
				scanf("%d",&stage[y][x]);
			}
		}

		int res = 0;
		for(int sx=0;sx<w;sx++){
			dfs(sx,0,w,h);
		}

		printf("%d\n",sum);
		sum = 0;
	}
}

C++: #include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

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

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)
			sum += pattern[width-1][x];

		cout << sum << endl;
	}
}

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

using namespace std;


const int MAX = 15;
int c[MAX+1][MAX+1];
int memo[3][MAX+1][MAX+1];
int X, Y;

int solve(int x0, int x, int y)
{
	if( -1 < x && x < X && Y-1 <= y )
		return 1;
	
	int& n = memo[x-x0+1][x][y];
	if( n != -1 )
		return n;
	
	int r = 0;
	int p = c[x][y];

	if( p != 2 ) {

		if( -1 < x-1 && c[x-1][y+1] != 1 )
			r += solve(x,x-1,y+1);

		if( c[x][y+1] != 1 )	
			r += solve(x,x,y+1);

		if( x+1 < X && c[x+1][y+1] != 1 )
			r += solve(x,x+1,y+1);

	} if( p == 2 && x == x0 ) {

		if( c[x][y+2] != 1 )
			r += solve(x,x,y+2);
	}

	n = r;
	return n;
}

int main(int argc, char* argv[])
{
	while(1) {

		cin >> X;
		cin >> Y;

		if( X == 0 && Y == 0)
			break;

		for( int j = 0; j < Y; j++ ) {		
			for( int i = 0; i < X; i++ ) {
				int p; cin >> p;
				c[i][j] = p;
				memo[0][i][j] = -1;
				memo[1][i][j] = -1;
				memo[2][i][j] = -1;
			}
		}

		int r = 0;
		for( int i = 0; i < X; i++ ) {
			if( c[i][0] != 1 )
				r += solve(i,i,0);
		}

		cout << r << endl;
	}

    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;

int main(){
  int W, H, mas[16][16];
  while( cin >> W >> H, W){
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
        cin >> mas[i][j];
      }
    }
    vector< vector< int > > dp( H + 1, vector< int >(W, 0));
    for(int i = 0; i < W; i++){
      if(mas[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(mas[i][j] == 0){
          for(int k = -1; k <= 1; k++){
            if(j + k < 0 || j + k >= W) continue;
            if((i == H - 1 && k == 0) || (i != H - 1 && k == 0 && mas[i + 1][j + k] == 2) || (i != H - 1 && mas[i + 1][j + k] == 0)){
              dp[i + 1][j + k] += dp[i][j];
            }
          }
        } else if(mas[i][j] == 2){
          if(i >= H - 2 || mas[i + 2][j] != 1){
            dp[max(H, i + 2)][j] += dp[i][j];
          }
        }
      }
    }

    int ret = 0;
    for(int i = 0; i < W; i++){
      ret += dp[H][i];
    }
    cout << ret << endl;
  }
}