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<cstdio>

using namespace std;

int run[15][15],w,h;

int ski(int x,int y,bool s)	// s : go straight in previous step?
{
	if(y>=h)			return 1;
	if(run[y][x]==1)	return 0;
	if(run[y][x]==2){
		if(s)	return ski(x,y+2,true);
		else	return 0;
	}

	// plane slope (run[y][x]==0)
	if(y==h-1)	return 1;

	int cnt=0;
	for(int dx=-1;dx<=1;dx++){
		int xx=x+dx;
		if(0<=xx && xx<w)	cnt+=ski(xx,y+1,!dx);
	}
	return cnt;
}

int main()
{
	for(;scanf("%d%d",&w,&h),w;){
		for(int y=0;y<h;y++)
			for(int x=0;x<w;x++)
				scanf("%d",run[y]+x);

		int cnt=0;
		for(int x=0;x<w;x++)	cnt+=ski(x,0,true);
		printf("%d\n",cnt);
	}

	return 0;
}

C++: #include<iostream>
#define MAX 1000
#include<cstring>
using namespace std;
int s[MAX][MAX],dp[MAX][MAX],d[]={1,0,-1},ans;
int w,h;
int func(int y,int x){
	if(y>=h-1)
	return 1;
	if(dp[y][x]!=-1)
	return dp[y][x];
	int sum=0;
	if(s[y][x]==2&&s[y+2][x]!=1)
		sum+=func(y+2,x);
	else{
	for(int i=0;i<3;i++){
		if(x+d[i]>=0&&x+d[i]<w){
			if(s[y+1][x+d[i]]==0)
			sum+=func(y+1,x+d[i]);
			else if(s[y+1][x+d[i]]==2&&i==1)
			sum+=func(y+1,x+d[i]);
		}
	}
	}
	return dp[y][x]=sum;
}
int main(){
	while(cin>>w>>h,w||h){
		for(int i=0;i<h;i++)
			for(int j=0;j<w;j++)
				cin>>s[i][j];
		for(int i=h;i<h+2;i++)
			for(int j=0;j<w;j++)
				s[i][j]=0;
		ans=0;
		memset(dp,-1,sizeof(dp));
		for(int i=0;i<w;i++)
		if(s[0][i]!=1)
			ans+=func(0,i);
		cout<<ans<<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];
		rep(i, 0, 20) rep(j, 0, 20) d[i][j] = 1;
		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] == 2 && d[i + 2][j] != 1) {
					dp[i + 2][j] += dp[i][j];
				}
				else if (d[i][j] == 0) {
					rep(k, -1, 2) {
						if (0 <= j + k && j + k < x && d[i + 1][j + k] == 0) {
							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 <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;

#define MAX 17
#define f first
#define s second
typedef pair<int, int> P;

unsigned long long ans;
int X, Y;
int field[MAX][MAX];
int dp[MAX][MAX];

int solve(){
  for(int i = 0 ; i < Y ; i++){
    for(int j = 0 ; j <= X ; j++){
      if(field[i][j] == 0){
	for(int dx = -1 ; dx <= 1 ; dx++){
	  int ny = i+1, nx = j+dx;
	  if(nx < 0 || nx > X) continue;
	  if(field[ny][nx] == 1) continue;
	  if(field[ny][nx] == 2 && field[ny+2][nx] == 1) continue;
	  if(field[ny][nx] == 2 && dx != 0) continue;
	  dp[ny][nx] += dp[i][j];
	}
      }
      else if(field[i][j] == 2 && field[i-2][j] != 2) dp[i][j] = dp[i-1][j];
      if(field[i][j] == 2 && field[i+2][j] != 1){
	dp[i+2][j] += dp[i][j];
      }
    }
  }
  
  int res = 0;
  for(int i = 0 ; i <= X ; i++){
    res += dp[Y][i] + dp[Y+1][i];
  }
  return res;
}

void init(){
  memset(dp, 0, sizeof(dp));
  for(int i = 0 ; i <= X ; i++){
    if(field[0][i] == 0) dp[0][i] = 1;
  }
}

int main(){
  while(cin >> X >> Y, X && Y) {
    X--, Y--;
    for(int i = 0 ; i <= Y ; i++) {
      for(int j = 0 ; j <= X ; j++) {
	cin >> field[i][j];
      }
    }
    
    init();
    cout << solve() << endl;
  }
  return 0;
}

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

int w, h, c[15][15];
int res;

void dfs(int x, int y) {
	if (y >= h-1) {
		++res;
		return;
	}
	if (c[y][x] == 1) return;
	if (c[y][x] == 0) {
		for (int i = 0; i < 3; ++i) {
			int nx = x + i - 1, ny = y + 1;
			if (0 <= nx && nx < w && ((x == nx && c[ny][nx] == 2) || c[ny][nx] == 0)) dfs(nx, ny);
		}
	}
	if (c[y][x] == 2) dfs(x, y+2);
	return;
}

int main(void) {
	while (cin >> w >> h, w && h) {
		for (int i = 0; i < h; ++i) {
			for (int j = 0; j < w; ++j) cin >> c[i][j];
		}
		res = 0;
		for (int i = 0; i < w; ++i) {
			if (c[0][i] == 0) dfs(i, 0);
		}
		cout << res << endl;
	}
	return 0;
}

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

int main() {
    enum { TREE = 1, JUMP = 2 };
    int x, y;
    while (cin >> x >> y, x) {
        vector<vector<int>> field(y, vector<int>(x));
        for (auto &v: field) for (int &vi: v) cin >> vi;
        vector<vector<int>> dp(y + 1, vector<int>(x, 0));
        for (int j = 0; j < x; j++) dp[0][j] = field[0][j] == 0;
        for (int i = 0; i < y - 1; i++) for (int j = 0; j < x; j++) {
            for (int k: {-1, 0, 1}) if (j + k >= 0 && j + k < x) {
                int ni = i + 1, nj = j + k;
                if (k == 0) {
                    if (field[i][j] == JUMP) ni++;
                } else {
                    if (field[i][j] == JUMP || field[ni][nj] == JUMP) continue;
                }
                if (ni < y && field[ni][nj] == TREE) continue;
                dp[ni][nj] += dp[i][j];
            }
        }
        int ans = 0;
        for (int j = 0; j < x; j++) ans += dp[y - 1][j] + dp[y][j];
        cout << ans << endl;
    }
    return 0;
}