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>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int MAXW = 16, W = 0, O = 1, J = 2;

int tile[MAXW][MAXW+ 5];
int dp[MAXW][MAXW];
int dx[3] = {0, -1, 1};

int main()
{
    int x, y;
    while(cin >> x >> y && x)
    {
        memset(dp, 0, sizeof(dp));
        memset(tile, W, sizeof(tile));
        rep(j,y)rep(i,x) cin >> tile[i][j];
        rep(i,x){ if(tile[i][0] == W) dp[i][0] = 1; }

        rep(i,x)
            if(tile[i][1] == W)
            {rep(k,3)if(i+dx[k]>=0 && i+dx[k]<x && tile[i+dx[k]][0] == W)dp[i][1] += dp[i + dx[k]][0];}
            else if(tile[i][1] == J && tile[i][0] == W) dp[i][1] += dp[i][0];
        for(int j=2;j<y;j++)rep(i,x)
        {

            if(tile[i][j] == O){ continue;}
            if(tile[i][j] == J)
            {
                if(tile[i][j-1] == W) dp[i][j] += dp[i][j-1];
                if(tile[i][j-2] == J) dp[i][j] += dp[i][j-2];
                continue;
            }
            rep(k,3)if((i+dx[k]>=0 && i+dx[k]< x)&& tile[i+dx[k]][j-1] == W)
                dp[i][j] += dp[i+dx[k]][j-1];
            if(tile[i][j-2] == J) dp[i][j] += dp[i][j-2];

        }
        //rep(j,y) { rep(i,x) cout << dp[i][j] << "\t"; cout << endl;}

        int ans = 0;
        REP(x){ ans += dp[i][y-1] ; if(tile[i][y-2] ==J) ans+= dp[i][y-2];}
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;

int main(){
  int x, y, course[15][15], route[20][20], i, j, sum;
  while(cin >> x >> y, x+y){
    sum = 0;
    for(i=0; i<20; i++){
      for(j=0; j<20; j++){
        route[i][j] = 0;
      }
    }
    for(i=0; i<y; i++){
      for(j=0; j<x; j++){
        cin >> course[i][j];
      }
    }
    for(i=0; i<y; i++){
      for(j=0; j<x; j++){
        if(i==0){
          if(course[i][j]==0){
            route[i][j] = 1;
	  }else{
            route[i][j] = 0;
          }
        }else{
          if(j==0){
            if(course[i][j]==0){
              if(course[i-1][j]==0){
                route[i][j] += route[i-1][j];
              }
              if(course[i-1][j+1]==0){
                route[i][j] += route[i-1][j+1];
              }
            }else if(course[i][j]==1){
              route[i][j] = 0;
            }else{
              if(course[i-1][j]==0){
                route[i][j] += route[i-1][j];
              }
              route[i+2][j] += route[i][j];
            }
          }else if(j==x-1){
            if(course[i][j]==0){
              if(course[i-1][j]==0){
                route[i][j] += route[i-1][j];
              }
              if(course[i-1][j-1]==0){
                route[i][j] += route[i-1][j-1];
              }
            }else if(course[i][j]==1){
              route[i][j] = 0;
            }else{
              if(course[i-1][j]==0){
                route[i][j] += route[i-1][j];
              }
              route[i+2][j] += route[i][j];
            }
          }else{
            if(course[i][j]==0){
              if(course[i-1][j]==0){
                route[i][j] += route[i-1][j];
              }
              if(course[i-1][j-1]==0){
                route[i][j] += route[i-1][j-1];
              }
              if(course[i-1][j+1]==0){
                route[i][j] += route[i-1][j+1];
              }
            }else if(course[i][j]==1){
              route[i][j] = 0;
            }else{
              if(course[i-1][j]==0){
                route[i][j] += route[i-1][j];
              }
              route[i+2][j] += route[i][j];
            }
          }
        }
      }
    }
    for(i=y-1; i<y+1; i++){
      for(j=0; j<x; j++){
        sum+=route[i][j];
      }
    }
    cout << sum << endl;
  }
}

C++: #include <iostream>
using namespace std;
int w,h;
int mp[18][18];
int memo[18][18];
int ans;
int count;

int saiki(int x,int y) {
  count++;
  // cout << x <<" "<<y <<endl;
  int dx[3] = {-1,0,1};
  int dy[3] = {1,1,1};
  
  if((y >= h-1 && mp[y][x] != 1)) ans++,memo[y][x]++;//,cout <<"ok"<<endl;  
  else if(mp[y][x] != 1) {
    for(int i=0;i<3;i++) {
      int nx = dx[i]+x;
      int ny = dy[i]+y;
      if(nx <0||ny <0||nx >= w|| ny>=h || memo[ny][nx] == -1) continue;
      
      if(memo[ny][nx] > 0) {
	ans+= memo[ny][nx];
	memo[y][x] += memo[ny][nx];
      }  
      else if(mp[ny][nx] == 0){
	saiki(nx,ny);
	if(memo[ny][nx] > 0) memo[y][x] += memo[ny][nx];
      } 
      else if(nx==x && mp[ny][nx] == 2){
	int ty = ny;
	while(mp[ty][nx] == 2) ty+=2;
	saiki(nx,ty);
	if(memo[ty][nx] > 0) memo[y][x] += memo[ty][nx];
      } 
    }
    if(memo[y][x] == 0) memo[y][x] = -1;
  }
}


int main() {

  while(1) {
    cin >> w >> h;
    if(w == 0 && h == 0) break;

    for(int i=0;i<h;i++) 
      for(int j=0;j<w;j++) 
	cin >> mp[i][j];


    for(int i=0;i<=15;i++) 
      for(int j=0;j<=15;j++) 
	memo[i][j] = 0;
    /*
      for(int i=0;i<h;i++) {
      for(int j=0;j<w;j++) 
      cout << mp[i][j];
      cout << endl;
      }
    */

    ans = 0;
    count = 0;
    for(int i=0;i<w;i++) {
      if(mp[0][i] !=1) saiki(i,0);
    }

    int ans2 = 0;
    for(int i=0;i<w;i++) 
      if(memo[0][i] > 0) ans2+=memo[0][i];

    cout << ans << endl;
    //cout << ans2 << endl;
    //cout << count << endl;
  }

  return 0;
}

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

int w, h;
vector< vector< int > > field, cnt;

int rec(int y, int x, int px){
	if(x < 0 || x > w - 1) return 0;
	if(y >= h) return 1;
	if(cnt[y][x] != -1) {
		if(field[y][x] == 2 && px != x) return 0;
		return cnt[y][x];
	}
	
	if(field[y][x] == 1) return cnt[y][x] = 0;
	else if(field[y][x] == 0) return cnt[y][x] = rec(y + 1, x - 1, x) + rec(y + 1, x, x) + rec(y + 1, x + 1, x);
	else{
		cnt[y][x] = rec(y + 2, x, x);
		
		if(px == x) return cnt[y][x];
		else return 0;
	}
}

int main(){
	
	while(cin >> w >> h, w){
		field.resize(h);
		cnt.resize(h);
		for(int i = 0; i < h; ++i){
			field[i].resize(w);
			cnt[i].resize(w);
			for(int j = 0; j < w; ++j){
				cin >> field[i][j];
				cnt[i][j] = -1;
			}
		}
		
		for(int i = 0; i < w; ++i){
			cnt[h - 1][i] = (field[h - 1][i] == 1 ? 0 : 1);
		}
		
		int sum = 0;
		for(int i = 0; i < w; ++i){
			sum += rec(0, i, i);
		}
		
		cout << sum << endl;
	}
	
	return 0;
}