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

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++){
	  if(field[i+1][j+dx] != 1 && (field[i+1][j+dx] == 0 || dx == 0)){
	    dp[i+1][j+dx] += dp[i][j];
	  }
	}
      }
      else 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>
#include <vector>
#include <array>

using namespace std;

int main()
{

    int height, width;

    while (cin >> width >> height) {
        if (height == 0 && width == 0) break;

        vector<vector<int>> field(height + 1, vector<int>(width + 2));

        // input
        for (int y = 0; y < height; ++y) {
            for (int x = 1; x < width + 1; ++x) {
                cin >> field.at(y).at(x);
            }
        }

        vector<vector<int>> dp(height + 1, vector<int>(width + 2));

        for (int x = 1; x < width + 1; ++x) {
            if (field.at(0).at(x) != 1) {
                dp.at(0).at(x) = 1;
            }
        }

        // dp
        array<int, 3> dx = {-1, 0, 1};


        for (int y = 0; y < height - 1; ++y) {
            for (int x = 1; x < width + 1; ++x) {
                switch (field.at(y).at(x)) {
                    case 0:
                        for (int i = 0; i < 3; ++i) {
                            // ?????????1??§???????????¨????????????
                            // ?¬???????2????????????????????????????????????
                            if (field.at(y + 1).at(x + dx.at(i)) != 1) {
                                switch (i) {
                                    case 1:
                                        dp.at(y + 1).at(x + dx.at(i)) += dp.at(y).at(x);
                                        break;
                                    default:
                                        if (field.at(y + 1).at(x + dx.at(i)) != 2) {
                                            dp.at(y + 1).at(x + dx.at(i)) += dp.at(y).at(x);
                                        }
                                        break;
                                }
                            }
                        }
                        break;
                    case 1:
                        break;
                    case 2:
                        // y = height - 2??§2????????£?????´????????????
                        if ( y + 2 >= height) {
                            dp.at(y + 1).at(x) += dp.at(y).at(x);
                        }
                        else {
                            dp.at(y + 2).at(x) += dp.at(y).at(x);
                        }
                        break;
                }
            }
        }

        int ans = 0;

        for (int x = 1; x < width + 1; ++x) {
            ans += dp.at(height - 1).at(x);
        }

        cout << ans << endl;
    }

    return 0;
}

C++: #include <iostream>
#include <cstring>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)
const int MAX_Y = 15;
const int MAX_X = 15;
int mx, my, c[MAX_Y][MAX_X], dp[MAX_Y][MAX_X];

const int dx[3] = {-1, 0, 1};
const int dy[3] = {1, 1, 1};

int dfs(int y, int x) {  
  int res = 0;
  if (dp[y][x] >= 0) return dp[y][x];
  
  if (y >= my - 1) return 1;
  
  if (c[y][x] == 2) {
    res += dfs(y+2, x);
    return dp[y][x] = res;
  }
  
  rep(z,3) {
    int tx = x + dx[z], ty = y + dy[z];
    if (tx < 0 || ty < 0 || tx >= mx || ty >= my) continue;
    if (c[ty][tx] == 1) continue;
    if (c[ty][tx] == 2 && tx != x) continue;
    res += dfs(ty, tx);
  }

  return dp[y][x] = res;
}

void solve() {
  memset(dp, -1, sizeof dp);
  rep(i,my) rep(j,mx) cin>>c[i][j];

  int res = 0;
  rep(i,mx) {
    if (c[0][i] == 1) continue;
    res += dfs(0, i);
  }
  cout<<res<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>mx>>my, mx||my) {
    solve();
  }
  return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int dp[18][18];
int kosu[16][16];
int ans;

int main(){
  int x,y;
  
  while(1){
    cin>>x>>y;
    if(x==0 && y==0) break;
    
    fill(dp[0],dp[18],0);
    ans=0;
    
    for(int i=0;i<y;i++){
      for(int l=0;l<x;l++){
        cin>>kosu[i][l];
      }
    }
    for(int i=0;i<x;i++)
      if(kosu[0][i]==0) dp[0][i]=1;
    
    for(int i=1;i<y;i++){
      for(int l=0;l<x;l++){
        
        if(kosu[i][l]==2){
          dp[i+2][l]=dp[i-1][l]+dp[i-2][l]+dp[i][l];
          dp[i][l]=0;
        }
        else if(kosu[i][l]==0)
          dp[i][l]+=dp[i-1][l-1]+dp[i-1][l]+dp[i-1][l+1];
      }
    }
    
    for(int i=0;i<x;i++)
      if(kosu[y-1][i]==2) ans+=dp[y-2][i];
    for(int i=0;i<x;i++)
      if(kosu[y-1][i]!=1) ans+=dp[y-1][i];
    
    printf("%d\n",ans);
  }
  return 0;
}

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

int main() {
	int s,i,j,x,y,c[15][15],d[17][15];
	while(cin >> x >> y) {
		if (x+y==0) break;
		for (i=0;i<y;i++) for (j=0;j<x;j++) cin >> c[i][j];
		for (i=0;i<y+2;i++) for (j=0;j<x;j++) d[i][j]=(i==0);
		for (i=0;i<y-1;i++) for (j=0;j<x;j++) {
			s=d[i][j];
			if (c[i][j]==0) { 
				if (j>0) if (c[i+1][j-1]==0) d[i+1][j-1]+=s;
				if (j<x-1) if (c[i+1][j+1]==0) d[i+1][j+1]+=s;
				if (c[i+1][j]!=1) d[i+1][j]+=s;
			}
			if (c[i][j]==2 && c[i+2][j]!=1) d[i+2][j]+=s;
		}
		s=0;
		for (i=y-1;i<=y;i++) for (j=0;j<x;j++) s+=d[i][j];
		if (y==1) s=0;
		cout << s << endl; 
	 }
	return 0;
}